Skip to content

Instantly share code, notes, and snippets.

View mikhailov's full-sized avatar

Anatoly Mikhaylov mikhailov

View GitHub Profile
@mikhailov
mikhailov / fizz_buzz.rb
Created September 26, 2015 16:52
FizzBuzz
class FizzBuzz
def initialize(array)
@array = array
@new_array = []
end
def process
@array.each do |e|
value = \
if e % 3 == 0 && e % 5 == 0
@mikhailov
mikhailov / decimal_mark.rb
Created September 26, 2015 16:23
DecimalMark
class DecimalMark
def initialize(data)
@array = data.split("")
@new_array = []
end
def process
i = 0
loop do
@mikhailov
mikhailov / valid_parentheses.rb
Last active September 26, 2015 15:19
ValidParentheses
class ValidParentheses
SYMBOLS = {"(" => ")", "[" => "]", "{" => "}"}
def initialize(array)
@array = array.split("")
@stack = []
end
def process
@array.each do |i|
@mikhailov
mikhailov / capistrano_log_recipes.rb
Created March 25, 2011 06:24
Capistrano extra recipes
namespace :log do
desc "A pinch of tail"
task :tailf, :roles => :app do
run "tail -n 10000 -f #{shared_path}/log/#{rails_env}.log" do |channel, stream, data|
puts "#{data}"
break if stream == :err
end
end
@mikhailov
mikhailov / gist:706275
Created November 19, 2010 09:09
nginx native ssl redirection without ssl_requirement
server {
listen 80;
server_name *.domain.com;
rewrite ^(.*) https://$host$1 permanent;
}
@mikhailov
mikhailov / qu.rb
Last active September 20, 2015 19:47
quick union
class QU
attr_reader :array
def initialize(array)
@array = array
end
def union(p,q)
return if p == q
@array[root(p)] = root(q)
@mikhailov
mikhailov / uf.rb
Last active September 20, 2015 18:54
union find
class UF
attr_reader :array
def initialize(array)
@array = array
end
def union(p,q)
return if p == q
@mikhailov
mikhailov / ajax_defaults.js
Created August 25, 2010 05:40
automatically show/hide ajax-spinner + disable/enable submit buttons
var spinner = $('#ajax-spinner');
$(document).ajaxSend(function() {
$('input[type=submit]').attr('disabled', 'disabled');
$('#warningBox').hide();
spinner.show()
}).ajaxStop(function() {
$('input[type=submit]').removeAttr('disabled');
spinner.hide()
});
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
begin
require "rubygems"
require "bundler"
rescue LoadError
raise "Could not load the bundler gem. Install it with `gem install bundler`."
end
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
raise RuntimeError, "Your bundler version is too old." +
"Run `gem install bundler` to upgrade."