Skip to content

Instantly share code, notes, and snippets.

class Renderable a where
render :: a -> IO ()
newtype Rectangle = Rectangle { width :: Double, height :: Double }
instance Renderable Rectangle where
render = undefined
newtype Circle = Circle { radius :: Double }
// Convert to jQuery please...
var field = $('password_confirmation_field');
field.hide();
$('user_password').observe('focus', field.show.bind(field));
// This the best?
var confirmation = $('#password_confirmation_field').hide();
$('#user_password').focus(function () {
confirmation.show();
});
{-# LANGUAGE OverloadedStrings #-}
module CommandParser where
import Data.Attoparsec.ByteString.Char8
import Data.Attoparsec.Combinator
import Control.Applicative
import Data.ByteString
data Command = Retrieve | Delete | New deriving Show
// Examples:
//
// HTML:
// <form action='messages/1/mark_unread'><input type='submit' class='button_to_link' value='Mark Unread'/></form>
//
// Rails:
// button_to "Mark as unread", mark_as_unread_message_path(message), :method => :put, :class => "button_to_link"
//
// jQuery:
// $(document).ready(function() {
@reinh
reinh / hack
Created August 28, 2008 02:15 — forked from rick/hack
#!/bin/sh -x
# hack
CURRENT=`git branch | grep "\*" | awk "{print $2}"`
git checkout master
git pull origin master
git checkout ${CURRENT}
git rebase master
@reinh
reinh / gist:41325
Created December 29, 2008 17:50 — forked from rezaprima/gist:39869
function current_git_branch {
git branch 2> /dev/null | grep '\*' | awk '{print $2}'
}
hack()
{
CURRENT=$(current_git_branch)
git checkout master
git pull origin master
git checkout ${CURRENT}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is the Parser 2 API version of the LetMeGoogleThatForYou *
* Ubiquity script compatible with Ubiquity 0.5+. *
* The Legacy parser version is available at *
* http://gist.github.com/45201 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
var icon = "http://letmegooglethatforyou.com/favicon.ico";
var tu_desc = "<a href=\"http://www.tinyurl.com\">TinyUrl</a>";
var lmg_desc = "<a href=\"http://lmgtfy.com\">Let Me Google That For You</a>";
@reinh
reinh / gist:180799
Created September 4, 2009 08:42 — forked from anonymous/gist:180794
def do_something
action = case
when self.play?: true ? 'play football' : 'do nothing'
when self.work?: 'go to work'
when self.sleep?: 'sleep'
else: 'What?'
end
return action
end
@reinh
reinh / run_tags.rb
Created November 3, 2009 22:32 — forked from tobias/run_tags.rb
#!/usr/bin/ruby
#-*-ruby-*-
# A script to run ctags on all .rb files in a project. Can be run on
# the current dir, called from a git callback, or install itself as a
# git post-merge and post-commit callback.
CTAGS = '/usr/bin/env ctags'
HOOKS = %w{ post-merge post-commit post-checkout }
HOOKS_DIR = '.git/hooks'
def update_main_artist
artist = rovi_artist ? Artist.find_or_create_by_name rovi_artist.name : artists.first
update_attribute :main_artist_id, artist.id
end