Skip to content

Instantly share code, notes, and snippets.


Jesper Rønn-Jensen jesperronn

View GitHub Profile
jesperronn / expense_type.rb
Created Sep 1, 2009
grouped_select for Rails 2.3 to simplify using optgroups
View expense_type.rb
class ExpenseType < ActiveRecord::Base
validates_uniqueness_of :name
#returns grouped options split in 'popular' and 'all'
def self.groups
all_types ={|t| [,]}
['popular', all_types[0..2]],
['all', all_types]
View form_options_helper_to_add_grouped_select.rb
### lib/form_options_helper.rb
require 'action_view/helpers/form_helper'
module ActionView
module Helpers
module FormOptionsHelper
def grouped_select(object, method, choices, options = {}, html_options = {}), method, self, options.delete(:object)).to_grouped_select_tag(choices, options, html_options)
View append query to urls.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" xml:lang="da" lang="da">
<title>jquery find all a elements and append to URLs only</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="" type="text/javascript"></script>
<script src="" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
/* Merge an arbitrary query string into all page links.
jesperronn / capinternal_systems_login_nordic_apps.user.js
Created Sep 23, 2009
Nordic capgemini applications: Bypass the annoying redirect not happening on Firefox because of HTML in HEAD element
View capinternal_systems_login_nordic_apps.user.js
// ==UserScript==
// @name cap nordic internal systems Firefox Login error
// @namespace
// @description Bypass the annoying redirect not happening on Firefox because of HTML in HEAD element
// @include
// @include
// @include
// @include
// @include
// @include
View unused.rb
#!/usr/bin/env ruby
# THis script looks for orphan image files in a GIT project
# For now, it looks for usages in the current source files via git grep
# usage:
# unused [foldername]
# unused ../images
require 'fileutils'
View parsepage.rb
#!/usr/bin/env ruby
# Script that wraps grabbing and selecting stuff from HTML page via CSS selectors
# Created 2009-10-01 by Jesper Rønn-Jensen,
# For usage, run parsepage.rb without arguments.
# Feel free to modify, fork and improve as long as you commit your changes back to me :)
def usage
<<-EOF #.gsub(' ', '')
=== USAGE ===
View list_compromised_files.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require "open-uri"
url= ''
#search_text = "viagra"
search_text = "bubbleGUM"
View wwwal-anondk_no_inline_s.user.js
// ==UserScript==
// @name Remove inline scroll so that page content prints properly
// @namespace
// @description remove scroll from al-anon pages
// @include*
// @require
// ==/UserScript==
$('#framen').css({'height': 'auto', width: 'auto'});
$('<style media="print">#menu {display: none;}</style>').appendTo('head');
#svnsync initialize --source-username jronn --source-password abcd1234 file:///Users/jesper/src/v2