Skip to content

Instantly share code, notes, and snippets.

View stan's full-sized avatar
💭
¯\_(ツ)_/¯

stan

💭
¯\_(ツ)_/¯
View GitHub Profile
@tisba
tisba / gist:703646
Created November 17, 2010 16:59
TextMate command snippet for the gemedit gem
#!/usr/bin/env ruby
# REQUIREMENTS:
#
# gem install gemedit
#
# INSTALLATION:
#
# Create a new TextMate command, paste this code, assign an activation shortcut,
# set output to "Show as Tool Tip" and done.
@peter
peter / gist:715518
Created November 25, 2010 15:15
Make sure ActiveRecord saves NULL in your database instead of empty strings
module NullifyTextAttributes
def self.included(base)
base.class_eval do
before_validation :nullify_text_attributes
private
def nullify_text_attributes
self.class.columns.select { |c| [:text, :string].include?(c.type) }.each do |column|
send("#{column.name}=", nil) if read_attribute(column.name).blank?
end
@jimsynz
jimsynz / config.ru
Created November 25, 2010 20:48
Patch for Mongo::GridIO to respond to each as required by the Rack API.
# Patch Mongo::GridIO to contain an each method.
require File.join File.dirname(__FILE__), 'lib/kimono/grid_io'
Mongo::GridIO.send(:include, Kimono::GridIO)
# You probably want to implement something a bit smarter than just talking
# to localhost.
database = Mongo::Connection.new.db('kimono_production')
app = proc do |env|
begin
@ryanb
ryanb / github_tree_slider.js
Created December 6, 2010 17:23
This is how GitHub's new AJAX file browser works.
GitHub.TreeSlider = function () {
if (window.history && window.history.pushState) {
function a() {
if (e.sliding) {
e.sliding = false;
$(".frame-right").hide();
$(".frame-loading:visible").removeClass("frame-loading")
}
}
if (!($("#slider").length == 0 || !GitHub.shouldSlide)) if (!navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
@chriseppstein
chriseppstein / 1_sprites.scss
Created December 20, 2010 03:29
Spriting is so freaking easy now.
@import "flag/*.png";
@import "emblem/*.png";
.flag-sprite {
width: image-width("flag/us.png");
height: image-height("flag/us.png");
padding: 0;
}
.emblem-sprite {
@antirez
antirez / srt.tcl
Created December 20, 2010 17:00
stretch / sync an SRT subtitle file to exactly match your video file.
# Quick hack to stretch the .srt subtitles to match the one of your video.
# Check the time of the first and last sentence in your video file, then
# use this tool to convert the .srt file into one matching your video with:
#
# tclsh srt.tcl file.srt <your start time> <your end time> > output.srt
#
# Example:
#
# tclsh srt.tcl my.srt 00:00:24,000 00:44:15,000 > ~/Desktop/new.srt
#
20 times 60 feeds.
1.9.2
3.500000 0.180000 3.680000 3.805192
3.530000 0.180000 3.710000 3.790724
3.460000 0.170000 3.630000 3.715879
3.470000 0.180000 3.650000 3.708632
3.460000 0.180000 3.640000 3.680093
3.460000 0.170000 3.630000 3.675401
3.470000 0.180000 3.650000 3.674723
class HelloWorldController < AbstractController::Base
include AbstractController::Rendering
include AbstractController::Layouts
include AbstractController::Helpers
include AbstractController::Translation
include AbstractController::AssetPaths
include ActionController::UrlWriter
# Uncomment if you want to use helpers defined in ApplicationHelper in your views
# helper ApplicationHelper
@Kilian
Kilian / annoying.js
Created January 6, 2011 15:04
How to be an asshole
/**
* Annoying.js - How to be an asshole to your users
*
* DO NOT EVER, EVER USE THIS.
*
* Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com)
* Visit https://gist.github.com/767982 for more information and changelogs.
* Visit http://kilianvalkhof.com/2011/javascript/annoying-js-how-to-be-an-asshole/ for the introduction and weblog
* Check out https://gist.github.com/942745 if you want to annoy developer instead of visitors
*
#!/usr/bin/env python
#
# Converts any integer into a base [BASE] number. I have chosen 62
# as it is meant to represent the integers using all the alphanumeric
# characters, [no special characters] = {0..9}, {A..Z}, {a..z}
#
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
#