Skip to content

Instantly share code, notes, and snippets.

View shtirlic's full-sized avatar
📡

Serg Podtynnyi shtirlic

📡
View GitHub Profile
require 'rubygems'
require 'sinatra'
require "sinatra/reloader"
get '/h' do
'Helllllo world!'
end
get '/t' do
module Abominate
def replace_object new_object
raise Exception.new( "Ia! Ia! Cthulhu Fhtagn!" ) unless instance_variable_defined? "@i_know_this_is_an_abomination"
context = class << self ; self ; end
new_object.instance_variables.each do |var|
instance_variable_set( var, new_object.instance_variable_get( var ) )
end
@shtirlic
shtirlic / move_test.cs
Created October 17, 2010 18:45
Testing Rovio movement
private void button2_Click(object sender, EventArgs e)
{
int i = 0;
while (i < 10)
{
rc.ManualDrive(1, 1);
i++;
}
@shtirlic
shtirlic / time_formats.rb
Created May 24, 2011 14:51
Add milliseconds (by default) for to_xml method on date fields
class ActiveSupport::TimeWithZone
alias_method :original_xmlschema , :xmlschema
def xmlschema(fraction_digits = 3)
original_xmlschema(fraction_digits)
end
end
@shtirlic
shtirlic / unicorn.rb
Created August 17, 2011 09:19
Monkey patch Unicorn to have more info on logs
class Unicorn::HttpParser
alias old_read read
def read(socket)
env = old_read(socket)
DEFAULTS["rack.logger"].debug env["REQUEST_PATH"]
env
end
end
@shtirlic
shtirlic / git-backup
Created November 30, 2011 12:36
Script for git repo backup in dropbox via git bundle
#!/usr/bin/env ruby
if __FILE__ == $0
bundle_name = ARGV[0] if (ARGV[0])
bundle_name = `pwd`.split('/').last.chomp if bundle_name.nil?
bundle_name += ".git.bundle"
puts "Backing up to bundle #{bundle_name}"
`git bundle create ~/Dropbox/backup/git-repos/#{bundle_name} --all`
end
@shtirlic
shtirlic / growl.sh
Created January 8, 2012 06:00
Patched file for 1.3.2 Growl with android-notifier
#!/bin/sh
# ANDROID_NOTIFICATION is in the format DEVICE_ID/NOTIFICATION_ID/EVENT_TYPE/EVENT_CONTENTS
NOTIFICATION_TYPE="`echo $ANDROID_NOTIFICATION | sed 's/.*\/.*\/\(.*\)\/.*/\1/'`"
NOTIFICATION_DATA="`echo $ANDROID_NOTIFICATION | sed 's/.*\///'`"
if [ $NOTIFICATION_TYPE == "RING" ]; then
TEXT_TO_SAY="Call from"
elif [ $NOTIFICATION_TYPE == "SMS" ]; then
@shtirlic
shtirlic / gist:2146256
Created March 21, 2012 11:11
Disable Rack::Lint
module Rack
class Lint
def call(env = nil)
@app.call(env)
end
end
end
@shtirlic
shtirlic / gist:2159621
Created March 22, 2012 16:53
Sinatra base url helper
def base_url
@base_url ||= "#{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}"
end