Archive for the ‘Code’ Category
Git extract folder from project with history and tags
Wednesday, November 2nd, 2016 by Jesper Rønn-Jensen`git filter-branch` will extract a folder from a shared repository and rewrite history. This tip shows you by example. And also how to rewrite tags in the new repos.
Posted in Code, git | 1 Comment »
Ruby make list minimum length
Sunday, December 13th, 2015 by Jesper Rønn-JensenIn a Ruby on Rails app, I wanted a list to be at least of two items. This could be done in several ways. Here is a first naïve impementation: # Naïve implementation, just return whatever number I need def sum_up_a(existing) return 2 if existing == 0 return 1 if existing == 1 return 0 end […]
Tags: Code, ruby
Posted in Code, Ruby on Rails | 2 Comments »
Change history of SVN repository
Wednesday, April 15th, 2015 by Jesper Rønn-JensenSomebody asked me if it’s possible to change history of an SVN repository like you can do in Git. The easiest parts to change are: commit date commit log message With this, you can easily modify time stamps if, for instance, your svn server clock is wrong. Step 1: Modify repository to accept property changes […]
Posted in Code, git | Comments Off on Change history of SVN repository
Easter egg CSS circles
Sunday, March 29th, 2015 by Jesper Rønn-JensenEaster eggs instead of circles on your CSS. It’s easier than I thought.
Posted in Code, CSS | 4 Comments »
Git checkout old revisions by date
Friday, November 9th, 2012 by Jesper Rønn-JensenI wanted to do some code stats for a repository. This line checks out old revisions by date and shows code stats: git checkout `git rev-list -n 1 –before=”2012年03月01日″ master` Then, I ran cloc to count lines of code: cloc . Its really easy to register the point in time as a git branch so […]
Tags: git
Posted in Code | Comments Off on Git checkout old revisions by date
PhantomJS 1.7 build for Linux 64 bit
Friday, September 28th, 2012 by Jesper Rønn-JensenAt a project I work on, we needed PhantomJS to run from a Redhat Fedora 64 bit machine. Since phantomJs is just released this week, I needed to build it myself. I post this link to the binary in case it can benefit others. PhantomJs 1.7.0 built on Linux Redhat Fedora 64 bit […]
Tags: phantomjs, testing
Posted in Code, Continous integration, Testing | 4 Comments »
Forgotten Subversion Commands, Undo, Merge Branches and More
Thursday, June 28th, 2012 by Jesper Rønn-JensenIn a current project I use a lot of Subversion (svn) from the command-line. Subversion recently has lost terrain to Git for several reasons. But actually, svn is capable of doing many of the things I love from Git. Here are some less known commands I find extremely helpful. Undo last commit svn merge […]
Tags: Code, git, subversion, svn
Posted in Code, Web Development | Comments Off on Forgotten Subversion Commands, Undo, Merge Branches and More
GWT Developer Plugin now Works with Firefox 9
Saturday, January 28th, 2012 by Jesper Rønn-Jensen(UPDATED) The GWT developer plugin has been updated to works with Firefox 9, a couple of days ago. Its not yet officially available, but can be downloaded directly from the codebase: google-web-toolkit.googlecode.com/svn/trunk/ prebuilt folder in here is the gwt-dev-plugin.xpi, and it works like a charm :) Previously i wrote when the plugin was updated to […]
Tags: Code, gwt, Web Development
Posted in Code, Web Development | Comments Off on GWT Developer Plugin now Works with Firefox 9
Batch Screenshots with webkit2png
Monday, January 23rd, 2012 by Jesper Rønn-JensenFor projects I sometimes have lots of screenshots which I have to repeat whenever I change subtle things in the CSS or HTML. I ended up creating this little handy script based on webkit2png (download source) #!/usr/bin/env sh HOST=”http://localhost:8080/myproject/viewer” /usr/bin/python webkit2png -F -o “01dashboard” $HOST/dashboard /usr/bin/python webkit2png -F -o “02showdetail” $HOST/detail /usr/bin/python webkit2png -F -o […]
Tags: automation, Code, screenshot, webkit
Posted in Code | 1 Comment »
Maven mirrorOf * in settings.xml breaks the build
Friday, January 20th, 2012 by Jesper Rønn-JensenUsing maven behind a firewall in environments with an internal repository can be troublesome, and even break the build. Here is an option to set up Maven
Tags: Code, maven, nexus
Posted in Code | Comments Off on Maven mirrorOf * in settings.xml breaks the build
IntelliJ Structural Search to Convert from JUnit3 to Junit4
Wednesday, January 18th, 2012 by Jesper Rønn-JensenJust a quick tip for intellij users. For an old project i wanted to convert JUnit 3 testcases to JUnit4 format. Most stuff was already in place, but after the conversion, i found that some of the old “assertTrue”, “assertFalse”, and “assertEquals” statements were failing. So i ended up with some short search/replace, which are really […]
Tags: Code, editor, ide, intellij, Java
Posted in Code, Web Development | Comments Off on IntelliJ Structural Search to Convert from JUnit3 to Junit4
GWT Developer plugin for Firefox 7 is now Ready
Monday, October 10th, 2011 by Jesper Rønn-JensenUPDATED 2011年12月14日: Prebuilt folder now contains Firefox 8 version of the GWT developer plugin. Since Firefox 7 was released, i have defered upgrading for one simple reason: At work I am dependent on GWT Developer plugin. Today I found the ready-to-release plugin which actually works with Firefox 7: http://google-web-toolkit.googlecode.com/svn/trunk/plugins/xpcom/prebuilt/ in here is the gwt-dev-plugin.xpi, and […]
Tags: Code, gwt, Web Development
Posted in Code, Web Development | 29 Comments »
Collection of useful Git Tips to get started
Friday, September 30th, 2011 by Jesper Rønn-JensenI thought it was time to collect some of my most useful findings when working with Git. These are typically from situations where I found a useful way, which I wanted to jot down. Also I have answered and asked some questions on StackOverflow. The good thing about it, is that I am always able […]
Tags: git
Posted in Code, git | 4 Comments »
Java Friday Fun: @WTF annotations in code
Friday, September 16th, 2011 by Jesper Rønn-JensenTime for a little geeky gimmick. Some developers see and express a lot of “WTF??” while trying to understand code IN this spirit, i created a quick @WTF annotation for Java. Besides being completely useless (its removed at compile time), its only purpose is to give developers a new way to express themselves in code. […]
Tags: Code, Java, quality, Review, wtf
Posted in Code, Java | 4 Comments »
Windows delete all tmp files command
Tuesday, July 12th, 2011 by Jesper Rønn-JensenJust a quick note to self about this tip i found. It is a Windows (XP) helpful command line snippet that removes all your temporary files. Delete all files in temp folder: DEL /F /S /Q %TEMP% Taken from the “A-Z Index of the Windows CMD command line”
Tags: command-line, windows
Posted in Code | 4 Comments »
Windows SVN pre-commit-hook
Thursday, June 10th, 2010 by Jesper Rønn-JensenAt 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 […]
Tags: Code, subversion, svn, windows
Posted in Code | 2 Comments »
Seeding Rails App With RESTful Address Data
Wednesday, April 28th, 2010 by Jesper Rønn-JensenGrabbing 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 […]
Tags: bootstrap, Code, rails, ruby
Posted in Code, Ruby on Rails | 1 Comment »
Groovy for Hudson console
Tuesday, April 20th, 2010 by Jesper Rønn-JensenHudson 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, […]
Tags: Code, groovy
Posted in Code | 1 Comment »
How To Recover Deleted Subversion Branch
Wednesday, December 9th, 2009 by Jesper Rønn-JensenI 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 […]
Posted in Code, Web Development | 1 Comment »
How to make Git ignore files that already exist in your project
Monday, December 7th, 2009 by Jesper Rønn-JensenFor 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 […]
Tags: Code, git, ignore
Posted in Code, git, Web Development | 5 Comments »
Run Tiny Webserver From Any Directory
Tuesday, December 1st, 2009 by Jesper Rønn-JensenThere 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 […]
Posted in Code | 4 Comments »
How to Remove Trailing Space from source files
Thursday, November 26th, 2009 by Jesper Rønn-JensenWhen it comes to source code, i am a perfectionist. I cant stand to see trailing whitespace, interchanged tabs/spaces, etc. This Stackoverflow user asked How To Remove Trailing Whitespace Of All Files Recursively. This reply helped me to work around the fact that \s and \t are not supported in the mac version of sed: […]
Tags: Code, find, sed, shell, trailing, whitespace
Posted in Code | Comments Off on How to Remove Trailing Space from source files
Script identifying CSS shorthand possibilities
Wednesday, October 21st, 2009 by Jesper Rønn-JensenFor 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 […]
Tags: Code, CSS
Posted in Code, CSS | 2 Comments »
Resolve Symlinks When Copying Files With Rsync
Thursday, October 15th, 2009 by Jesper Rønn-JensenIn 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 […]
Posted in Code | 2 Comments »
Extract HTML Structure From Page With Simple Script
Monday, October 5th, 2009 by Jesper Rønn-JensenI 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 […]
Tags: Code, nokogiri, ruby, script
Posted in Code | 3 Comments »
Spoken Git Commit Log — Another Annoyance at the Office
Wednesday, September 30th, 2009 by Jesper Rønn-JensenHere 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 […]
Tags: Code, git, Humor, logging
Posted in Code, git, Humor, Web Development | 1 Comment »
Print CSS Background Logo Hack
Tuesday, September 29th, 2009 by Jesper Rønn-JensenI 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 print — […]
Tags: CSS, hack, webdevelopment
Posted in Code, CSS, Web Development | 8 Comments »
Selection Groups in Rails made less cumbersome
Tuesday, September 1st, 2009 by Jesper Rønn-JensenI 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 | 1 Comment »
How to add Git Pull Shortcut to Different Github Branches
Sunday, August 23rd, 2009 by Jesper Rønn-JensenUPDATE 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, […]
Tags: Code, git, github
Posted in Code, git, Web Development | 1 Comment »
Importing Existing Git repository into SVN
Wednesday, July 8th, 2009 by Jesper Rønn-JensenMany 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 […]
Tags: Code, git, subversion, svn, Web Development
Posted in Code | 7 Comments »
Using Git for SVN Repositories Workflow
Monday, March 9th, 2009 by Jesper Rønn-JensenFor 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 […]
Using Local File-based Git — Server Laziness
Saturday, February 21st, 2009 by Jesper Rønn-JensenMy 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 […]
Tags: Code, git, ssh, svn, Web Development
Posted in Code, justaddwater.dk, Web Development | Comments Off on Using Local File-based Git — Server Laziness
Git Side Benefit: Reducing Disk Usage
Saturday, January 17th, 2009 by Jesper Rønn-JensenA 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 […]
Plugin for Rails’s Resource Controller
Friday, November 7th, 2008 by Jesper Rønn-JensenIf 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 […]
Tags: Code, plugin, rails
Posted in Code, Ruby on Rails | 2 Comments »
Adding Deprecation Warning in JavaScript Console
Thursday, July 17th, 2008 by Jesper Rønn-JensenI 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 »
Don’t Repeat Yourself (Unless Reading Book)
Monday, June 23rd, 2008 by Jesper Rønn-JensenAfter 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 »
Public Danish Data REST Interface
Wednesday, May 28th, 2008 by Jesper Rønn-JensenChristian Dalager and I did an internal Capgemini SmartLunch presentation about REST interfaces in the public Danish sector. REST interface is great news for those in favor of easy-to-integrate, scalable SOA interfaces, and REST services is actually used more than SOAP, XMLRPC, etc. in companies offering multiple interfaces to their data (Amazon, Yahoo, Google, Ebay, […]
Tags: oiorest, Presentation, rest, smartlunch, Video
Posted in capgemini, Code, Events/seminars, Presentation, Ruby on Rails, smartlunch, Speaking | 3 Comments »
Converting UTF-8 Data to Outlook Compatible Charset
Wednesday, November 21st, 2007 by Jesper Rønn-JensenA 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 […]
Posted in Code, Ruby on Rails | 5 Comments »
How to Run JavaScript From Watir Scripts
Tuesday, November 20th, 2007 by Jesper Rønn-JensenWhat’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 »
Powerful Text Editor Released
Wednesday, August 8th, 2007 by Jesper Rønn-JensenE-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: […]
Posted in Code, Productivity, Ruby on Rails, Software | 5 Comments »