Skip to content

Instantly share code, notes, and snippets.

View Sija's full-sized avatar

Sijawusz Pur Rahnama Sija

View GitHub Profile
// Attempt to make a drop-and-forget bunch of scripts that mimick some missing html5 goodies automatically
// Example:
// $(document).ready(function() {
// ProvideHtml5.autofocus()
// ProvideHtml5.datepicker()
// ProvideHtml5.forcenumber()
// })
//
// Now a real git project, over here: http://github.com/sunny/provide-html5
gem 'cramp'
gem 'erubis', '2.6.5'
gem 'usher', "0.6.0"
@shinzui
shinzui / connection_fix.rb
Created February 24, 2010 02:26 — forked from defunkt/connection_fix.rb
MySQL has gone away fix
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
require "time"
require "date"
class Date
def to_time
Time.local(year, month, day)
end
end
class Time
@avsej
avsej / paperclip_attachments_to_json.rb
Created September 17, 2010 08:35
dump paperclip attachment urls to json
module PaperclipAttachmentsToJSON
module ClassMethods
def has_attached_file_with_explicit_urls(name, options = {})
has_attached_file_without_explicit_urls(name, options)
# explicit url method definition
url_method = <<-EOM
def %{name}_%{style}_url # def avatar_original_url
%{name}.url(:%{style}) # avatar.url(:original)
end # end
<html>
<head>
<title>Checkbox</title>
<style>
input[type=checkbox] {
display:none;
}
input[type=checkbox] + label
{
@stuartloxton
stuartloxton / gist:652483
Created October 28, 2010 22:35
Closure Memoization in PHP
<?php
function Memoize($function) {
$cache = array();
return function() use (&$cache, $function) {
$args = func_get_args();
$serialized = serialize($args);
if( isset($cache[$serialized]) )
return $cache[$serialized];
@hippietrail
hippietrail / stripgutenberg.pl
Created December 22, 2010 18:59
Strip headers/footers from Project Gutenberg texts
#!/usr/bin/perl
# stripgutenberg.pl < in.txt > out.txt
#
# designed for piping
# Written by Andrew Dunbar (hippietrail), released into the public domain, Dec 2010
use strict;
my $debug = 0;
@osteslag
osteslag / IR_Black.dvtcolortheme
Created February 20, 2011 10:54
IR_Black theme for Xcode 4, based on IR_Black for Xcode 3 by David Zhou, based on IR_Black for TextMate by Todd Werth. See links in comments below.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>DVTConsoleDebuggerInputTextColor</key>
<string>0.811765 0.796078 0.564706 1</string>
<key>DVTConsoleDebuggerInputTextFont</key>
<string>Inconsolata - 16.0</string>
<key>DVTConsoleDebuggerOutputTextColor</key>
<string>1 1 1 1</string>
@io41
io41 / paginated_collection.js
Created February 22, 2011 10:10 — forked from zerowidth/paginated_collection.js
Pagination with Backbone.js
// includes bindings for fetching/fetched
var PaginatedCollection = Backbone.Collection.extend({
initialize: function() {
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage');
typeof(options) != 'undefined' || (options = {});
this.page = 1;
typeof(this.perPage) != 'undefined' || (this.perPage = 10);
},
fetch: function(options) {