Skip to content

Instantly share code, notes, and snippets.

var friends = document.getElementById("friends").getElementsByTagName("a")
var clickEvent = document.createEvent("MouseEvents");
clickEvent.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
for(var i = 0; i < friends.length; i++) {friends[i].dispatchEvent(clickEvent);}
This is an example gist!
require 'rubygems'
require 'RMagick'
require 'narray'
class WaveformRenderer
# image size in pixel
DEFAULT_WIDTH = 1024
DEFAULT_HEIGHT = 512
# default graph color
DEFAULT_COLOR = "#666"
#
# $TM_FILENAME
#
# Created by `id -P | awk -F ":" '{ print $8 }'` on `date "+%d/%m/%Y"`.
#
# Copyright (c) 2010 ${2:$TM_ORGANIZATION_NAME}
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
import csv
import json
f = open( 'photos.csv', 'r' )
reader = csv.DictReader( f, fieldnames = ( "thumbpath", "imgpath", "imgsrc", "width", "height", "thumbsrc", "thumbwidth", "thumbheight" ) )
out = json.dumps( [ row for row in reader ] )
print out
class Contact < Tableless
column :email, :string
column :message, :text
validates_presence_of :email, :message
end
define_index do
indexes content
indexes :name, :sortable => true
indexes comments.content, :as => :comment_content
indexes [author.first_name, author.last_name], :as => :author_name
has author_id, created_at
end
require 'spec_helper'
describe AdminController do
before { login }
it "should be accessible only by admins!"
end
# A simple expiring cache suitable for use with the PStore store.
#
# Usage:
# SimpleCache.fetch('my_data', 15.minutes) do
# MyModel.expensive_query
# end
#
require 'pstore'
@potomak
potomak / merge_foo_into_master.sh
Created October 21, 2010 13:51
Merge foo branch into master branch (http://lwn.net/Articles/210045/)
# create foo branch
git checkout -b foo
# do some stuff on foo branch
# add changes and commit
git add .
git commit -m "add foo feature"
# merge foo branch into master branch