Skip to content

Instantly share code, notes, and snippets.

View pechorin's full-sized avatar
🌴
(do (code) (love lists))

andrey pechorin pechorin

🌴
(do (code) (love lists))
View GitHub Profile

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

def self.force_refetch!(&block)
is_feched = false
while is_feched == false
begin
RcbBank.set!
RcbBank.fetch_rates!
RcbBank.store_rates
is_feched = true
# Drop this file in config/initializers to run your Rails project on Ruby 1.9.
# This is three separate monkey patches -- see comments in code below for the source of each.
# None of them are original to me, I just put them in one file for easily dropping into my Rails projects.
# Also see original sources for pros and cons of each patch. Most notably, the MySQL patch just assumes
# that everything in your database is stored as UTF-8. This was true for me, and there's a good chance it's
# true for you too, in which case this is a quick, practical solution to get you up and running on Ruby 1.9.
#
# Andre Lewis 1/2010
# encoding: utf-8
yes_no_conditions_creator = lambda {|yes_or_no,field_name|
if yes_or_no == 'yes'
{:conditions => "books.#{field_name.to_s} = true"}
elsif yes_or_no == 'no'
{:conditions => "books.#{field_name.to_s} = false or books.#{field_name.to_s} is null"}
else
{}
end
}

REE

3.0.5

development

order index

4.51s - firebug Completed 200 OK in 1677ms (Views: 749.7ms | ActiveRecord: 134.0ms)

order ajax update

# server at 8081
require 'rubygems'
require 'faye/websocket'
app = lambda do |env|
ws = Faye::WebSocket.new(env)
ws.onmessage = lambda do |event|
puts event.data
if event.data == 'started'
@pechorin
pechorin / gist:2480007
Created April 24, 2012 14:12
грубый черновик :D
# БЫЛО
# нужно создать такие коллбеки, которые могут быть скипнуты, если переменная skip_<имя_коллбека> возвращает true
class A
attr_accessor :skip_send_faye_notify
after_create :send_faye_notify
def send_faye_notify
unless @skip_senf_faye_notify
send
# Concern
module SkipSpecificCallback
extend ActiveSupport::Concern
module ClassMethods
def with_skip(callback_name, *args)
options = args.extract_options!
raise Exception, ":on not specified" if options[:on].blank?
attribute_name = "skip_#{callback_name}"
@pechorin
pechorin / gist:2499364
Created April 26, 2012 12:54
state miaso
class A
state_machine do
state :active
state :removed
event :remove do
transition :active => :removed
end