Skip to content

Instantly share code, notes, and snippets.

View shaliko's full-sized avatar

Shalva Usubov shaliko

View GitHub Profile
module MetricSystem
def self.convert(from, to, value)
raise ArgumentError if from.blank? || to.blank? || value.blank?
from = from.to_sym
to = to.to_sym
if from == :kg && to == :g
value.to_f * 1000
module MetricSystem
def self.convert(from, to, value)
raise ArgumentError if from.blank? || to.blank? || value.blank?
from = from.to_sym
to = to.to_sym
if from == :kg && to == :g
value.to_f * 1000
<?xml version="1.0" encoding="UTF-8"?>
<estates>
<estate>
<id>1</id>
<title>N Maplewood Ave, Chicago IL</title>
<city_title>Chicago</city_title>
<state_title>IL</state_title>
<price>1234567</price>
<square>3500</square>
<beds>3</beds>
$() // Always use jQuery
jQuery.noConflict();
jQuery // Always returns an array
//Making chains methods
jQuery("#container div.gallery").addClass('active').removeClass('hidden').css({ backgroundColor:"yellow" })
job = Delayed::Job.last
assert_equal(Delayed::PerformableMethod, job.payload_object.class)
assert_equal("AR:User:#{@user.id}", job.payload_object.object)
assert_equal(:my_method, job.payload_object.method)
assert_equal([1,2,3], job.payload_object.args)
require 'net/http'
require 'net/https'
http = Net::HTTP.new('usubov.com', 443)
http.use_ssl = true
path = '/messages'
data = "user_id=1234567890"
headers = {
"Content-Type" => "text/html; charset=ISO-8859-4"
}
@shaliko
shaliko / gist:939850
Created April 24, 2011 20:25
Delete all gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
@shaliko
shaliko / gist:963270
Created May 9, 2011 20:06
git config
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.unstage 'reset HEAD --'
git config --global alias.last 'log -1 HEAD'
@shaliko
shaliko / gist:1104710
Created July 25, 2011 17:54
convertor.rb
require 'yaml'
class Convertor
def initialize(text)
@text = text
end
def prepare
response = ""
@shaliko
shaliko / application.js
Created August 18, 2011 13:00
DEPRECATION WARNING: :popup has been deprecated
//jQuery
$('a[data-popup]').live('click', function(e) {
window.open($(this).href);
e.preventDefault();
});
//Prototype.js
document.on("click", "a[data-popup]", function(event, element) {
if (event.stopped) return;
window.open($(element).href);