Skip to content

Instantly share code, notes, and snippets.

View jesperronn's full-sized avatar

Jesper Rønn-Jensen jesperronn

View GitHub Profile
@jesperronn
jesperronn / expense_type.rb
Created September 1, 2009 12:34
grouped_select for Rails 2.3 to simplify using optgroups
class ExpenseType < ActiveRecord::Base
validates_uniqueness_of :name
#returns grouped options split in 'popular' and 'all'
def self.groups
all_types = self.all.map{|t| [t.name, t.id]}
[
['popular', all_types[0..2]],
['all', all_types]
]
### 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 = {})
InstanceTag.new(object, method, self, options.delete(:object)).to_grouped_select_tag(choices, options, html_options)
end
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="da" lang="da">
<head>
<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="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="jquery.ba-url.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
/* Merge an arbitrary query string into all page links.
@jesperronn
jesperronn / capinternal_systems_login_nordic_apps.user.js
Created September 23, 2009 10:27
Nordic capgemini applications: Bypass the annoying redirect not happening on Firefox because of HTML in HEAD element
// ==UserScript==
// @name cap nordic internal systems Firefox Login error
// @namespace http://userscripts.org/users/103819
// @description Bypass the annoying redirect not happening on Firefox because of HTML in HEAD element
// @include http://applications.capgemini.se/applications/employee/employee.cfm
// @include http://applications.capgemini.se/applications/skills/skills.cfm
// @include http://applications.capgemini.se/applications/Staffing/staffing.cfm
// @include http://applications.capgemini.se/applications/common/common.cfm
// @include http://applications.capgemini.se/Applications/ADManager/ADManager.cfm
// @include http://applications.capgemini.se/Applications/Approve/Approve.cfm
#!/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'
#!/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, www.justaddwater.dk
#
# 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 ===
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require "open-uri"
url= 'http://justaddwater.dk/'
#search_text = "viagra"
search_text = "bubbleGUM"
// ==UserScript==
// @name www.al-anon.dk Remove inline scroll so that page content prints properly
// @namespace http://userscripts.org/users/103819
// @description remove scroll from al-anon pages
// @include http://al-anon.dk/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// ==/UserScript==
$('#framen').css({'height': 'auto', width: 'auto'});
$('<style media="print">#menu {display: none;}</style>').appendTo('head');
#!/bin/sh
DEST=/svnroot/dk_es_virkdk
SRC_URL=https://cs-blade1.common.capgemini.dk:8443/svn/virk.dk
SRC_USER=jronn
SRC_PASS=abcd1234
DST_USER=svnsync
#svnsync initialize --source-username jronn --source-password abcd1234 file:///Users/jesper/src/v2 https://cs-blade1.common.capgemini.dk:8443/svn/virk.dk