Archive for the ‘Code’ Category
Thursday, June 10th, 2010 by Jesper Rønn-Jensen
At a current project I work on, we use a Windows server to run our subversion repository.
I wanted to set up the pre-commit hook so that commits with empty comment are automatically rejected.
All commit-hook example files that go with Subversion are written in bash (as unix servers tend to be the normal).
Here is [...]
Tags: Code, subversion, svn, windows
Posted in Code | 1 Comment »
Wednesday, April 28th, 2010 by Jesper Rønn-Jensen
Grabbing data from Restful webservices has never been easier. I use this code in the Rails /db/seeds.rb file to grab data from the Danish webservice with addresses, municipalities, regions, etc.
I decided to import the data into a local database to ensure it could work offline.
Code from
/db/seeds.rb
file:
Now I can access municipalities in a grouped selectbox [...]
Tags: bootstrap, Code, rails, ruby
Posted in Code, Ruby on Rails | 1 Comment »
Tuesday, April 20th, 2010 by Jesper Rønn-Jensen
Hudson continuous integration server has a console which is good for testing scripts and access to commands that your Hudson jobs need.
The hudson console only let’s you run Groovy script. To run commands on the machine, Groovy has the method
“string”.execute()
. So now I can use this snippet to test versions of Ruby, JRuby, etc:
def commands [...]
Tags: Code, groovy
Posted in Code | 1 Comment »
Wednesday, December 9th, 2009 by Jesper Rønn-Jensen
I recently deleted a branch from our (svn) code repository. Did you know that it’s the general recommendation to delete a branch after a merge to ensure that nobody commits to it. (see svnmerge wiki for more on that advice)
Svn checkout, svn info, etc. all fail when you try to access the deleted branch immediately:
$ [...]
Posted in Code, Web Development | 2 Comments »
Monday, December 7th, 2009 by Jesper Rønn-Jensen
For a project I’m working on, I had to change some files with personal settings, and the files kept showing up with a
git status
.
Adding files to .gitignore that are already tracked does not work. (and it’s actually pretty well documented in the documentation). In stead, it’s possible to use this command:
git update-index –assume-unchanged [filename(s)]
From [...]
Tags: Code, git, ignore
Posted in Code | 1 Comment »
Tuesday, December 1st, 2009 by Jesper Rønn-Jensen
There are alternatives to Resolve Symlinks When Copying Files With Rsync .
How about firing up a (tiny) webserver that starts up quickly. Yehuda Katz suggested this some years ago:
Just drop this file in any directory, run the script, and it serves the files. I use this frequently for instance when I need to browser test [...]
Posted in Code | 5 Comments »
Wednesday, October 21st, 2009 by Jesper Rønn-Jensen
For my own convenience I created this script to identify css files where colors like #aaaaaa can be rewritten in the short form #aaa
(saves bandwith, but can also make it easier to identify similar colors)
grep -nE ‘#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3′ **/*.css
output from a random project:
css/actions.css:19: color: #000000;
css/actions.css:38: color: #000000 !important;
css/actions.css:53: color: #ffffff !important;
css/admin.css:90: color: #cccccc;
css/admin.css:94: color: #aaaaaa [...]
Tags: Code, CSS
Posted in CSS, Code | 2 Comments »
Thursday, October 15th, 2009 by Jesper Rønn-Jensen
In a project I’m working on there is a structure where images and css are common for some of the subprojects. One folder has static pages for testing HTML + CSS layout. This folder has some symlinks to the /css folder and /images folder.
Now, on my Mac during normal development, this works perfectly. But I [...]
Posted in Code | 1 Comment »
Monday, October 5th, 2009 by Jesper Rønn-Jensen
I often want to extract parts of HTML page. Often I find myself parsing a doc with Nokogiri and extracting it with a CSS selector. It’s pretty straight-forward from scratch.
To follow the Don’t Repeat Yourself principle, I created a script to make it a one-liner. Just run
ruby parsepage.rb [url] [css_selector]
Feel free to use and [...]
Tags: Code, nokogiri, ruby, script
Posted in Code | 4 Comments »
Wednesday, September 30th, 2009 by Jesper Rønn-Jensen
Here is a short one-liner that really annoyed my colleagues today.
I set my mac to read aloud all changes in the repository since yesterday:
git log –pretty=format:”%an commit %s, %ad.” –date=relative –since=yesterday |say
if you remove the “say” command in the end it’s actually pretty readable:
pagerbak commit VA17, 34 minutes ago.
pagerbak commit VA17 – Not used, [...]
Tags: Code, git, Humor, logging
Posted in Code, Humor, Web Development | Add Comment »
Tuesday, September 29th, 2009 by Jesper Rønn-Jensen
I learned this nice little hack to bypass the standard browser setting that normally prevents background images from being printed.
The hack makes use of converting the background-image to a list item with an image.
/* Hack, to trick the browser to print another logo
Unfortunetaly, Firefox on Windows doesn’t show logo on [...]
Tags: CSS, hack, webdevelopment
Posted in CSS, Code, Web Development | 5 Comments »
Tuesday, September 1st, 2009 by Jesper Rønn-Jensen
I made this addition today after (once again) struggling with option groups for a nested Rails model.
My solution: create a new tag for FormOptionsHelper: grouped_select
http://gist.github.com/179075
Tags: Code, rails, Ruby on Rails, Web Development
Posted in Code, Ruby on Rails | Add Comment »
Sunday, August 23rd, 2009 by Jesper Rønn-Jensen
UPDATE 9 hours later: Changed to “remote = origin” to the specific branch “remote = dean” which works!
Short explanation on how to pull changes from different Git repositories into your local Git repository.
Last week I worked with three different Github forks of a project. Now for standard, when you clone a Github repository, the remote [...]
Tags: Code, git
Posted in Code, Web Development | Add Comment »
Wednesday, July 8th, 2009 by Jesper Rønn-Jensen
Many of my colleagues know svn but are in general not (yet) ready jump over to using Git for bigger projects.
Today I had to import my existing Git repository into SVN. I had been working locally with a Git repos and wanted to keep my history before giving access to my colleagues.
The guide from [...]
Tags: Code, git, subversion, svn, Web Development
Posted in Code | 5 Comments »
Monday, March 9th, 2009 by Jesper Rønn-Jensen
For the last months I have been using Git to work with my Subversion repositories. Besides from reducing disk usage, Git also makes my work slightly faster and independent of network access — I can make commits to repository which is sync’ed later when I get online.
One challenge though: Using branches
I ran into some pitfalls [...]
Tags: git, svn, workflow
Posted in Code | 9 Comments »
Saturday, February 21st, 2009 by Jesper Rønn-Jensen
My problem this week: I wanted to share some work with a colleague. Unfortunately we have not yet setup our caplab environment with git server. Nor did i want to push this particular project to GitHub or Unfuddle. My alternative was a file-based setup:
Each developer’s machine has it’s own Git repository.
On my machine I had [...]
Tags: Code, git, ssh, svn, Web Development
Posted in Code, Web Development, justaddwater.dk | 1 Comment »
Saturday, January 17th, 2009 by Jesper Rønn-Jensen
A side benefit of switching from Subversion to Git for source control is that Git does not use shadow files and directories to find out what has changed.
I created two checkouts of a svn project — one using traditional svn and one using git (which can actually clone a svn repos — see explanation below).
[~/my-projects] [...]
Tags: Code, git, gitify, svn
Posted in Code | 3 Comments »
Friday, November 7th, 2008 by Jesper Rønn-Jensen
If you’re using Resource Controller for Ruby on Rails, you may want to look atthe plugin I just created.
From the readme file:
ResouceControllerRespondTo
==========================
Extends ResourceController plugin for Rails to make it respond_to .xml and .json formats
Based on code by Florent Piteau and Joe Fiorini… Jesper merely provided the glue and packed as plugin.
See resource controller forum thread [...]
Tags: Code, plugin, rails
Posted in Code, Ruby on Rails | 3 Comments »
Thursday, July 17th, 2008 by Jesper Rønn-Jensen
I used this quick trick today to help me clean up and refactor some javascript functions today:
if (“console” in window)
console.warn(‘DEPRECATED function call to ‘+ arguments.callee
+’\nCalled by:\n’+ arguments.callee.caller );
Which results in a fine deprecation warning in the console:
There is plenty of space for improvement here. Feel free to use or tamper … [...]
Tags: JavaScript
Posted in Code, JavaScript | 2 Comments »
Monday, June 23rd, 2008 by Jesper Rønn-Jensen
After reading Pragmatic Programmer at my recent vacation, I immediately found an urge to repeat myself and read it again.
Ironic that one of the most popular tips from it is “Don’t repeat yourself”.
Posted in Code, Inspiration | 5 Comments »
Wednesday, November 21st, 2007 by Jesper Rønn-Jensen
A problem in a current Rails app just found a decent solution, as Danish letters like æøå did not show up decently. It turned out (surprise) that Outlook had a problem accepting UTF-8 charset.
On the Meeting model in the Rails app I want to save to calendar in an Outlook compatible format. We solved it [...]
Posted in Code, Ruby on Rails | 4 Comments »
Tuesday, November 20th, 2007 by Jesper Rønn-Jensen
What’s Watir? Read “Watir: Another sweetspot for Enterprise Ruby”
Is it possible to run JavaScript functions or execute code from within your Watir test scripts? As a matter of fact it is, but I had a hard time finding the proper documentation for it. Here is what to do and how:
Call JavaScript Functions from [...]
Posted in Code, JavaScript | 1 Comment »
Wednesday, August 8th, 2007 by Jesper Rønn-Jensen
E-texteditor just got out of beta. I have actively contributed with improvement suggestions and error reports, as this editor has all needed features for rapid web devlopment, and has potential to become even better.
I suggest you check out the inspiring screencast and perhaps buy a trial if you like it.
More info:
E-Texteditor website: e-texteditor.com
Justaddwater.dk: E-Texteditor For [...]
Posted in Code, Productivity, Ruby on Rails, Software | 5 Comments »
Monday, April 30th, 2007 by Jesper Rønn-Jensen
Firebug keeps surprising me. I’ve recently been working on code for several web designs and this little trick helped me to understand existing HTML and CSS much faster. Just to give an example I use our Justaddwater RSS feed page (but could be any page).
Before you start, get Firebug for Firefox (if you haven’t got [...]
Posted in CSS, Code, Errors, Productivity, Web Development | 8 Comments »
Saturday, April 28th, 2007 by Jesper Rønn-Jensen
I have been looking a fast, intuitive editor for my Windows laptop.
Now I stopped looking. E-texteditor for windows is very intuitive and easy to use. I highly recommend watching the screencast (a short tour of some of the best features). Although it’s still in beta, it seems so much better than the alternatives.
I’m using [...]
Posted in CSS, Code, HTML, JavaScript, Productivity, Ruby on Rails, Software | 7 Comments »
Thursday, April 26th, 2007 by Jesper Rønn-Jensen
UPDATE May 1st, 2007 (forgot the two final steps 8 and 9).
I’ve run into the situation a couple of times where I get started on a client’s office, but due to delays and politics it takes time to get a proper versioning control server set up.
It turned out to be easy when I figured out [...]
Posted in Code, Productivity, Prototyping, Web Development | 5 Comments »
Thursday, February 15th, 2007 by Jesper Rønn-Jensen
It’s been a while where web standards don’t get the attention it deserves on this blog. In that spirit, here’s a behind-the-scenes view on how Technorati makes rounded corners on a faded background.
I remember Eric Meyer mentioned this solution back at a workshop in 2005 (before he could actually tell that it was for [...]
Posted in CSS, Code, HTML, Web Standards | 14 Comments »
Monday, January 29th, 2007 by Jesper Rønn-Jensen
2 years ago I wrote a small javascript to view, edit and delete cookies.
The really cool thing about this user interface is the inline editing of cookie names and values. I really like the principle that you hover the value that you inspect, can see that it’s editable. Then click directly and the text [...]
Posted in Code, JavaScript, justaddwater.dk | 10 Comments »
Thursday, August 24th, 2006 by Jesper Rønn-Jensen
Recently I’ve been working on a plugin for Ruby on Rails that help me out when creating new Rails applications in Danish. Previously, when we’ve created Danish prototypes for our customers all the default Rails error messages were still written in English.
I generalized it for use with any language, and currently (with the help from contributors) it’s now available for download on rubyforge.
Posted in Best of Justaddwater, Code, Ruby on Rails | 24 Comments »
Thursday, June 29th, 2006 by Jesper Rønn-Jensen
Project managers often have a hard time understanding web standards and why they matter. In this case, my arguments made a perfect business case for the managers of a particular project.
Posted in Browser, Code, Errors, HTML, JavaScript, Performance, Web Standards | 8 Comments »
Monday, June 26th, 2006 by Jesper Rønn-Jensen
Thomas and I are really looking forward to this week’s Copenhagen Rails Meetup. Remember to join us
- if you’re in Copenhagen this thursday
- if you’re working with Ruby on Rails professionally or in your spare time
- if you like free beer
Posted in Code, Events/seminars, Ruby on Rails | 7 Comments »
Saturday, June 10th, 2006 by Thomas Watson Steen
We can now finally reveal the venue for the Ruby on Rails meetup in Copenhagen:
After a bid of research we have found the very central Café Selina in the central Copenhagen (just next to The Rock and “Gammel Torv”).
To sign up for the meetup and for detailed address info, see our original meetup post “Ruby [...]
Posted in Code, Ruby on Rails, justaddwater.dk | Add Comment »
Wednesday, May 31st, 2006 by Jesper Rønn-Jensen
We’re arranging a meetup for Ruby on Rails geeks in the Copenhagen area. Thursday, June 29, 2006 at 20.30
Posted in Best of Justaddwater, Code, Ruby on Rails | 38 Comments »
Friday, May 19th, 2006 by Jesper Rønn-Jensen
You might wonder what a code example is doing here in a blog about usability and web standards. As you might know, Thomas and I are both web developers, and we’re really obsessed about making usable web applications.
What better way than to share code for things that make web apps more usable. Thomas has already [...]
Posted in Code, Ruby on Rails, Usability | 2 Comments »
Wednesday, April 12th, 2006 by Jesper Rønn-Jensen
Ruby on Rails might be the perfect match as a prototyping tool. It delivers consistent productivity gains compared to any other prototyping tool. Very few lines of code makes it easy to change. Here is why we use it at work as our preferred prototyping tool.
Posted in Best of Justaddwater, Businesscase, Code, Prototyping, Ruby on Rails | 27 Comments »
Saturday, March 11th, 2006 by Jesper Rønn-Jensen
I just sent this to the CSS-D discussion list
Hope you can help me with this. I want to limit a table cell height to only one line of text. My example below does not work – any height on td is simply ignored if content is long.
Problem here (according to for instance http://annevankesteren.nl/2004/01/css-tables ) [...]
Posted in CSS, Code, Web Standards | 6 Comments »
Monday, November 21st, 2005 by Jesper Rønn-Jensen
ASP.Net framework has severe problems producing HTML that follows webstandards. This is the first article of two where I take a closer look
Posted in CSS, Code, Web Standards | 2 Comments »