Skip to content

Instantly share code, notes, and snippets.

Avatar

RKushnir

  • kloeckner.i GmbH
  • Berlin
View GitHub Profile
@RKushnir
RKushnir / check_availability.js
Created Mar 14, 2014
Show Intertop.ua product availability on click
View check_availability.js
$('.item_img').click(function(e) {
e.preventDefault();
var product_id = $(this).attr('href').match(/\/(\d+)\.html/)[1]
$.post('/shop/item/shops', {
region_id: '***region***',
size: '***size***',
product_id: product_id,
}, function(data) {
console.log(product_id, data.length > 0);
});
View action_controller_master.rb
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
GEMFILE
system 'bundle'
end
require 'bundler'
@RKushnir
RKushnir / action_controller_master.rb
Last active Dec 28, 2015
ActionController master bug report template issue
View action_controller_master.rb
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
GEMFILE
system 'bundle'
end
require 'bundler'
View listener.clj
(ns listener
(:require [clojure.java.io :as io])
(:import [java.net ServerSocket Socket])
(:import [java.io InputStreamReader BufferedReader]))
(def settings {:client-port 5000})
(defn get-reader [socket]
(BufferedReader. (InputStreamReader. (.getInputStream socket))))
View chef_solo_bootstrap.sh
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p385.tar.gz
tar -xvzf ruby-1.9.3-p385.tar.gz
cd ruby-1.9.3-p385/
CFLAGS="-march=native -O2" ./configure --prefix=/usr/local
make
make install
@RKushnir
RKushnir / circle.rb
Created Feb 12, 2012
Circle drawing algorithm
View circle.rb
class Circle
def initialize(radius)
@radius = radius
end
def draw
unless @canvas
diameter = 2 * @radius
@canvas = Array.new(diameter + 1){ ' ' * (2 * (diameter + 1)) }
key_points.each do |kx, ky|
View count_ships.rb
field = [
[1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, ],
[1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, ],
[1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, ],
[0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, ],
[1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, ],
[1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, ],
]
count = 0