Skip to content

Instantly share code, notes, and snippets.

/*
* a smart poller for jquery.
* (by github)
*
* simple example:
*
* $.smartPoller(function(retry) {
* $.getJSON(url, function(data) {
* if (data) {
* doSomething(data)
@WaYdotNET
WaYdotNET / align.el
Created November 15, 2010 14:40
Align function emacs
;; Align command !!!
;; from http://stackoverflow.com/questions/3633120/emacs-hotkey-to-align-equal-signs
;; another information: https://gist.github.com/700416
;; use rx function http://www.emacswiki.org/emacs/rx
(defun align-to-colon (begin end)
"Align region to colon (:) signs"
(interactive "r")
@tobyhede
tobyhede / install_rails.markdown
Created November 20, 2010 23:37
From 0 to Rails in several whiles using homebrew and rvm
~/projects/jruby ➔ jruby memory_mapped.rb
Reading and writing memory-mapped
2.355000 0.000000 2.355000 ( 2.299000)
1.943000 0.000000 1.943000 ( 1.942000)
2.014000 0.000000 2.014000 ( 2.014000)
1.899000 0.000000 1.899000 ( 1.899000)
1.870000 0.000000 1.870000 ( 1.870000)
Reading from disk
2.982000 0.000000 2.982000 ( 2.982000)
3.031000 0.000000 3.031000 ( 3.031000)
@nahi
nahi / twitter_jruby.rb
Created December 6, 2010 14:55
Twitter gem, rubytter + httpclient, and Twitter4J with JRuby
0% jruby -rubygems trouble/twitter/twitter4j.rb
Rehearsal -----------------------------------------------
twitter gem 5.856000 0.000000 5.856000 ( 5.856000)
rubytter 5.844000 0.000000 5.844000 ( 5.845000)
twitter4j 1.730000 0.000000 1.730000 ( 1.730000)
------------------------------------- total: 13.430000sec
user system total real
twitter gem 4.850000 0.000000 4.850000 ( 4.850000)
rubytter 5.110000 0.000000 5.110000 ( 5.111000)
@scottwb
scottwb / assets.rake
Created January 28, 2011 06:08
Rake task to rebuild all JS/CSS assets with Compass/Jammit, including workaround for the bugs within.
namespace :assets do
task :rebuild do
# Config the base names of all the jammit CSS packages you have defined
# in assets.yml. Could probably parse assets.yml to get this if
# we wanted to.
packages = ['common']
# This is because on OS X, you have to put an explicit empty string to the
# required extension argument with the -i parameter, but on Linux you
# do not.
/*
---
name: guilloche
script: guilloche.js
description: guilloche
provides: [Guilloche]
...
*/
@the55
the55 / raphael.arcs.js
Created February 5, 2011 18:26
2 raphael arc objects
// http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
Raphael.fn.arc = function(startX, startY, endX, endY, radius1, radius2, angle) {
var arcSVG = [radius1, radius2, angle, 0, 1, endX, endY].join(' ');
return this.path('M'+startX+' '+startY + " a " + arcSVG);
};
Raphael.fn.circularArc = function(centerX, centerY, radius, startAngle, endAngle) {
var startX = centerX+radius*Math.cos(startAngle*Math.PI/180);
var startY = centerY+radius*Math.sin(startAngle*Math.PI/180);
var endX = centerX+radius*Math.cos(endAngle*Math.PI/180);
(use 'clojure.contrib.monads)
(defn new-pair [value log] {:value value :log log})
(defn starting-pair [value] (new-pair value nil))
(defn log [base-value]
(fn [log]
(new-pair base-value (cons base-value log))))
(defmonad logging-m
@unnitallman
unnitallman / gist:944011
Created April 27, 2011 10:11
sqlite with activerecord outside rails
require 'active_record'
ActiveRecord::Base.logger = Logger.new(STDERR)
ActiveRecord::Base.colorize_logging = false
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:dbfile => ":memory:"
)