Skip to content

Instantly share code, notes, and snippets.

View rn0's full-sized avatar
:bowtie:
testing

Piotr Kapera rn0

:bowtie:
testing
View GitHub Profile
@robertsosinski
robertsosinski / application.rb
Created April 6, 2009 14:53
A simple way to manage multiple parameters in Rails routing
before_filter :hash_options
def hash_options
params[:options] = Hash[*((params[:options].size % 2) == 0) ? params[:options] : (params[:options] + [nil])] if params[:options]
end
@kneath
kneath / ._what.md
Created December 4, 2009 18:23
Badass git pull alias (up) to show commit log that just got pulled in addition to changes

Badass git pull alternative

Add this little snippet to your ~/.gitconfig and it amps up your git pull by means of git up

  1. Adds in a list of the commits you're pulling down
  2. Auto-prunes remote branches
  3. Defaults to pull --rebase - gets rid of unnecessary merge commits. If you don't know what rebase does, this is probably safe for you. If you know what rebase does, you should know where this will not be safe for you.

Scott Chacon and Ryan Tomayko basically figured out how to do this and I am stealing all of the credit.

gemcutter => redis downloads spec
=================================
keys
----
downloads => global counter for all gem downloads
downloads:today => sorted set for downloads from today
downloads:rubygem:rails => counter for all rails downloads
downloads:version:rails-2.3.5 => counter for all rails 2.3.5 downloads
@rklemme
rklemme / dfs-convert.rb
Created March 9, 2010 13:25
DFS in nested Hashes
#! ruby19
require 'pp'
Converter = Struct.new :root, :converted do
def convert
@stack = []
self.converted = {}
dfs(root)
@jacqui
jacqui / field.rb
Created June 3, 2010 13:58
Using embedded documents to store field data
class Field
include MongoMapper::EmbeddedDocument
key :name, String
key :label, String, :required => true
key :helper_text, String
key :required, Boolean, :default => false
key :widget, String, :required => true
key :options, Array # => [[value, label], [value, label], [value, label]]
key :selected, String
pl:
errors:
messages:
not_found: "nie znaleziono"
already_confirmed: "już został aktywowany"
not_locked: "nie był zablokowany"
devise:
failure:
unauthenticated: 'Musisz się zalogować lub zarejestrować aby kontynuować.'
require 'rake/clean'
HAML = FileList['**/*.haml']
LESS = FileList['**/*.less']
COFFEE = FileList['**/*.coffee']
HTML = HAML.ext('html')
CSS = LESS.ext('css')
JS = COFFEE.ext('js')
# Rails 3.1
- Yehuda's Windy City Talk: http://dl.dropbox.com/u/2285145/Rails%203.pdf
## RSoC Merges
- Identity Map (ET)
- Code Reloading (JK)
- Benchmarking CI (YK)
✓ Engines++ (JV)
@paulirish
paulirish / utmstrip.user.js
Last active September 17, 2024 11:03
userscript: Drop the UTM params from a URL when the page loads
// ==UserScript==
// @name UTM param stripper
// @author Paul Irish
// @namespace http://github.com/paulirish
// @version 1.2
// @description Drop the UTM params from a URL when the page loads.
// @extra Cuz you know they're all ugly n shit.
// @include http*://*
// ==/UserScript==
@cowboy
cowboy / HEY-YOU.md
Last active October 25, 2024 15:29
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.