Skip to content

Instantly share code, notes, and snippets.

View grimen's full-sized avatar

Jonas Grimfelt grimen

View GitHub Profile
@mikehale
mikehale / jquery.copyable.js
Created January 21, 2010 21:11
A jquery API for ZeroClipBoard
/*
Requirements:
This script requires the jquery.includeMany plugin and ZeroClipboard.
Example:
$("#elementToClickOn").copyable(function(e, clip) {
clip.setText($("#elementWithText").html());
});
@dbackeus
dbackeus / payex.rb
Created March 1, 2011 11:46
Simple helper module to help communicate with payex.
module Payex
mattr_accessor :account_number
mattr_accessor :encryption_key
MD5_CHECK_FIELDS = {
"pxorder/pxorder.asmx/Initialize7" => [:accountNumber, :purchaseOperation, :price, :priceArgList, :currency, :vat, :orderID, :productNumber, :description, :clientIPAddress, :clientIdentifier, :additionalValues, :externalID, :returnUrl, :view, :agreementRef, :cancelUrl, :clientLanguage],
"pxagreement/pxagreement.asmx/CreateAgreement3" => [:accountNumber, :merchantRef, :description, :purchaseOperation, :maxAmount, :notifyUrl, :startDate, :stopDate],
"pxagreement/pxagreement.asmx/DeleteAgreement" => [:accountNumber, :agreementRef],
"pxorder/pxorder.asmx/Complete" => [:accountNumber, :orderRef],
"pxagreement/pxagreement.asmx/AutoPay2" => [:accountNumber, :agreementRef, :price, :productNumber, :description, :orderId, :purchaseOperation],
@cowboy
cowboy / multi-firefox-fixer.sh
Created March 14, 2011 02:17
Multi-Firefox Fixer: Run multiple versions of Firefox simultaneously! (note: doesn't work on Windows)
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" ]; then cat <<EOF
Multi-Firefox Fixer - v0.2 - 4/26/2011
http://benalman.com/
Usage: `basename "$0"`
Run this shell script from beside (in the same parent directory as) one or more
Firefox*.app or Aurora*.app applications and it will "fix" those Firefoxes to
@Achillefs
Achillefs / google_product_api.rb
Created April 13, 2011 16:03
Perform product searches using the new Google Products API
require "uri"
require "active_support"
# Get auth token from Googles
auth_uri = "https://www.google.com/accounts/ClientLogin"
params = {
"accountType" => "HOSTED_OR_GOOGLE",
"Email" => "yer_gmail",
"Passwd" => "yer_gpass",
"source" => "organization-appname-version",
# Pass in the name of the site you wich to create a cert for
domain_name = ARGV[0]
if domain_name == nil
puts "Y U No give me a domain name?"
else
system "openssl genrsa -out #{domain_name}.key 1024"
system "openssl req -new -key #{domain_name}.key -out #{domain_name}.csr -subj '/C=US/ST=NJ/L=Monroe/O=MyCompany/OU=IT/CN=#{domain_name}'"
system "cp #{domain_name}.key #{domain_name}.key.bak"
@weskoop
weskoop / powjs.plugin.zsh
Created August 9, 2011 05:51
powjs is an oh-my-zsh plugin to quickly configure your Node project for use with Pow.
# powjs r1 - @weskoop
# Config.ru concept and file by Assaf Arkin http://labnotes.org/2011/08/06/using-pow-with-your-node-js-project/
function powjs {
if [[ $# -ne 0 ]]; then
if [[ $1 == "config" ]]; then
echo "Creating Node compatible config.ru..."
cat > config.ru <<POWJS
require "net/http"
@jakearchibald
jakearchibald / gist:1168514
Created August 24, 2011 16:49
Preventing images & other media downloading
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<script id="whatever">document.write('<!'+'--')</script>
<img src="filth.jpg" />
<!---->
<script>
// filth.jpg will start loading now for users without js.
@joakimk
joakimk / migrate_with_annotation.rake
Created September 7, 2011 16:08
Script to automatically annotate models after db:migrate is run.
# Used with:
# gem 'annotate', :git => 'git://github.com/ctran/annotate_models.git'
if Rails.env.development?
def after_task(task_name, &new_task)
old_task = Rake.application.instance_variable_get('@tasks').delete(task_name.to_s)
desc old_task.full_comment
task task_name do
old_task.invoke
new_task.call
@assaf
assaf / gist:1207141
Created September 9, 2011 19:41
rescueFrom for jQuery AJAX requests
rescue_from = {}
# Associate status code with an HTTP status code. First argument is the status
# code, second argument is a function that accepts the XHR object. For example:
# $.rescueFrom 404, (xhr)-> alert("Oh no, page not found!")
$.rescueFrom = (status, fn)->
rescue_from[status] = fn
# Default handling for unsuccessulf HTTP status code. Finds and calls most
# appropriate handler based on the HTTP status code (see `$.rescueFrom`).
@josevalim
josevalim / rbx_partial_application.diff
Created September 17, 2011 20:59
Partial application on rubinius. Apply the diff to rubinius project and run `rake build`. Idea by @josevalim, code by @wycats.
diff --git a/lib/compiler/ast/transforms.rb b/lib/compiler/ast/transforms.rb
index 19e1cfb..4e52ec2 100644
--- a/lib/compiler/ast/transforms.rb
+++ b/lib/compiler/ast/transforms.rb
@@ -59,6 +59,71 @@ module Rubinius
end
end
+ # Provide an underscore node that allows partial application in Ruby.
+ # Instead of doing a method call, we are going to generate a lambda