Skip to content

Instantly share code, notes, and snippets.

View kolo's full-sized avatar

Dmitry Maksimov kolo

View GitHub Profile
class Proc
def bind(object)
block, time = self, Time.now
(class << object; self end).class_eval do
method_name = "__bind_#{time.to_i}_#{time.usec}"
define_method(method_name, &block)
method = instance_method(method_name)
remove_method(method_name)
method
end.bind(object)
From fad23f414a762d74bdcd77290ef206110327bb46 Mon Sep 17 00:00:00 2001
From: Dmitry Maksimov <dmtmax@gmail.com>
Date: Tue, 16 Mar 2010 08:47:04 +0300
Subject: [PATCH] Basic implementation of git-bisect
---
lib/grit.rb | 1 +
lib/grit/bisect.rb | 37 +++++++++++++++++++++++++++++++++
lib/grit/git.rb | 4 +++
lib/grit/repo.rb | 20 ++++++++++++++++++
require 'rubygems'
require 'sinatra'
class WelcomeController
@@controller = self.new
def self.method_missing(name, *args)
@@controller.send(name)
end
[user]
name = [NAME]
email = [EMAIL]
[core]
autocrlf = false
excludesfile = [PATH TO GITIGNORE]
[alias]
lg = log --format=\"%C(yellow)%h%Creset %s %C(yellow)%an%Creset (%ar)\" --graph
co = checkout
ci = commit
@kolo
kolo / message_sender_bserver.rb
Created March 1, 2011 14:37
MessageSenderObserver
class MessageSenderObserver < ActiveRecord::Observer
observe :attendee
def after_create(model)
model.user.post_message(:all, I18n::t("messages.#{model.class.name.underscore}.create",
:title => title_for(model),
:link => link_for(model)))
end
private
@kolo
kolo / warden.rb
Created March 23, 2011 14:42 — forked from cavalle/warden.rb
# Create a file `spec/acceptance/support/warden.rb' with the following
# contents:
Spec::Runner.configure do |config|
config.include Warden::Test::Helpers, :type => :acceptance
config.after(:each, :type => :acceptance) { Warden.test_reset! }
end
# Or, if you're using RSpec 2 / Rails 3, the contents should be the following
# instead:
# -*- coding: utf-8 -*-
class Ability
include CanCan::Ability
def initialize(user)
#
# Events
#
can :update, Event do |event|
@kolo
kolo / settings.rb
Created April 7, 2011 13:07
settings storage class
require 'yaml'
require 'test/unit'
TEST_CONFIG = <<END_OF_CONFIG
filename: settings.rb
development:
database: settings-development
port: 3366
test:
hostname: localhost
@kolo
kolo / gist:2724734
Created May 18, 2012 11:14 — forked from bartku/gist:2419852
world of tanks api
http://worldoftanks.eu/community/accounts/api/%API_VER%/?source_token=%TOKEN%&search=%NAME%&offset=0&limit=1
http://worldoftanks.eu/community/accounts/%PLAYER_ID%/api/%API_VER%/?source_token=%TOKEN%
http://worldoftanks.eu/community/clans/api/%API_VER%/?source_token=%TOKEN%&search=%CLAN_NAME%&offset=0&limit=1
http://worldoftanks.eu/community/clans/%CLAN_ID%/api/%API_VER%/?source_token=%TOKEN%
http://worldoftanks.eu/personal/api/%API_VER%/?source_token=%TOKEN%
login req: getlogin: https://worldoftanks.eu/auth/create/api/1.0/?source_token=%TOKEN%
gettoken: https://worldoftanks.eu/utils/csrf/api/1.0/?source_token=%TOKEN%
api versions: 1.0, 1.1, 1.2, 1.3
@kolo
kolo / tmux-new.sh
Created July 23, 2012 09:00
tmux startup script
#! /bin/sh
SESSION_NAME=${PWD##*/} # Current directory name will be used as session name
tmux new-session -d -s $SESSION_NAME
tmux new-window -t $SESSION_NAME:1 -n 'vim' 'vim'
tmux new-window -t $SESSION_NAME:2
tmux new-window -t $SESSION_NAME:3