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
@sstok
sstok / ShortArraySyntaxFixer.php
Last active August 29, 2015 14:03
ShortArraySyntaxFixer for PHP-CS-Fixer
use Symfony\CS\FixerInterface;
use Symfony\CS\Tokens;
class ShortArraySyntaxFixer implements FixerInterface
{
public function fix(\SplFileInfo $file, $content)
{
$tokens = Tokens::fromCode($content);
for ($index = 0, $c = $tokens->count(); $index < $c; $index++) {
@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
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ć.'
# 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)
@pwim
pwim / dateinput_converter.js
Created November 19, 2010 06:21
Convert Rails style date input to jQuery Tools' dateinput
// Based on http://snipt.net/boriscy/datetime-jquery-formtastic/
$.tools.dateinput.localize("ja", {
months: '1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月',
shortMonths: '1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月',
days: '日曜日,月曜日,火曜日,水曜日,木曜日,金曜日,土曜日',
shortDays: '日,月,火,水,木,金,土'
});
$.tools.dateinput.conf.format = 'yyyy-mm-dd';
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
$(function() {
// Hide the form button
$('#products_search input[type="submit"]').hide();
// Push searches onto the location hash
var inputTimeoutId = -1;
@ches
ches / embedded_callbacks.rb
Created December 30, 2010 13:22 — forked from zerobearing2/embedded_callbacks.rb
bubble down callbacks to embedded associations with mongoid
# encoding: utf-8
module Mongoid #:nodoc:
module Associations #:nodoc:
module EmbeddedCallbacks
# bubble callbacks to embedded associations
def run_callbacks(kind, *args, &block)
# now bubble callbacks down
self.associations.each_pair do |name, meta|
if meta.association == Mongoid::Associations::EmbedsMany