Skip to content

Instantly share code, notes, and snippets.

View dmitry's full-sized avatar
🇪🇪
Water, earth and air.

Dmitry Polushkin dmitry

🇪🇪
Water, earth and air.
View GitHub Profile
From 67eb80e72d8d4782334aabf3b120adf6fdca5cda Mon Sep 17 00:00:00 2001
From: Rodrigo Rosenfeld Rosas <rr_rosas@yahoo.com.br>
Date: Thu, 25 Feb 2010 00:29:43 -0300
Subject: [PATCH] Include support for :full_message option to validations.
---
activemodel/lib/active_model/errors.rb | 54 +++++++++++++------
.../lib/active_model/validations/acceptance.rb | 2 +-
.../lib/active_model/validations/confirmation.rb | 2 +-
.../lib/active_model/validations/exclusion.rb | 2 +-
@jed
jed / LICENSE.txt
Created May 20, 2011 13:27 — forked from 140bytes/LICENSE.txt
generate random UUIDs
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@karmi
karmi / elastic_search_ngram_analyzer_for_urls.sh
Created May 24, 2011 15:32
NGram Analyzer in ElasticSearch
# ========================================
# Testing n-gram analysis in ElasticSearch
# ========================================
curl -X DELETE localhost:9200/ngram_test
curl -X PUT localhost:9200/ngram_test -d '
{
"settings" : {
"index" : {
"analysis" : {
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@cowboy
cowboy / jquery.ba-deparam.js
Created June 14, 2011 20:39
jQuery Deparam -- WORK IN PROGRESS -- NOT DONE YET
// jQuery Deparam - v0.1.0 - 6/14/2011
// http://benalman.com/
// Copyright (c) 2011 Ben Alman; Licensed MIT, GPL
(function($) {
// Creating an internal undef value is safer than using undefined, in case it
// was ever overwritten.
var undef;
// A handy reference.
var decode = decodeURIComponent;
@ryanb
ryanb / rails_3_1_update.txt
Created July 23, 2011 21:31
Possible output from a Rails 3.1 upgrade wizard
$ rake rails:update
Generating app/assets directory and content. (same as 3.1 app generator)
Do you want to move all public/stylesheets into app/assets/stylesheets? (recommended) [y]
Moving public/stylesheets into app/assets/stylesheets...
Existing application.css, merging content to the end of app/assets/stylesheets/application.css.
@bquorning
bquorning / gist:1146099
Created August 15, 2011 12:05
Careful Cutting To Get Faster RSpec Runs with Rails -- fix for Devise
# Don't need passwords in test DB to be secure, but we would like 'em to be
# fast -- and the stretches mechanism is intended to make passwords
# computationally expensive.
module Devise
module Models
module DatabaseAuthenticatable
def valid_password?(password)
return false if encrypted_password.blank?
@wesen
wesen / backbone-mixin.js
Created August 21, 2011 10:38
Merge backbone views (mixin pattern)
/**
* ## Merging mixin views in backbone.js ##
*
* really just more a test for tumblr gistr
*/
/**
* Merge the mixin (a Backbone.View) into another Backbone.View. Automatically merge events, defaults, and call the parent initializer.
**/
function mergeMixin(view, mixin) {
@mattsears
mattsears / README.md
Created September 5, 2011 07:41
Gittr: A Git key/value store

Gittr.rb

Git as a key-value store! Build with Grit, it supports SET, GET, KEYS, and DELETE operations. In addition, we can also get the change history of key/values.

And since it's Git, we can easily enhance it to include other awesome Git features such as branches, diffs, reverting, and more!

Example:

@heijmerikx
heijmerikx / gist:1261118
Created October 4, 2011 08:05
MySQL FIND_IN_SET to Postgresql...
def self.order(ids)
# The postgresql way
update_all(["position = STRPOS(?, ','||id||',')", ",#{ids.join(',')},"], { :id => ids })
# the mysql way
# update_all(['position = FIND_IN_SET(id, ?)', ids.join(',')],{ :id => ids })
end