This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QU | |
attr_reader :array | |
def initialize(array) | |
@array = array | |
end | |
def union(p,q) | |
return if p == q | |
@array[root(p)] = root(q) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name *.domain.com; | |
rewrite ^(.*) https://$host$1 permanent; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ValidParentheses | |
SYMBOLS = {"(" => ")", "[" => "]", "{" => "}"} | |
def initialize(array) | |
@array = array.split("") | |
@stack = [] | |
end | |
def process | |
@array.each do |i| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DecimalMark | |
def initialize(data) | |
@array = data.split("") | |
@new_array = [] | |
end | |
def process | |
i = 0 | |
loop do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FizzBuzz | |
def initialize(array) | |
@array = array | |
@new_array = [] | |
end | |
def process | |
@array.each do |e| | |
value = \ | |
if e % 3 == 0 && e % 5 == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReverseSentence | |
def initialize(string) | |
@array, @array_reversed = string.split(" "), [] | |
end | |
def process | |
@array_reversed << @array.pop while @array.any? | |
@array_reversed.join(" ") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveRecord::ConnectionAdapters::Mysql2Adapter | |
private | |
alias_method :configure_connection_without_strict_mode, :configure_connection | |
def configure_connection | |
configure_connection_without_strict_mode | |
strict_mode = "SQL_MODE='STRICT_ALL_TABLES'" | |
execute("SET #{strict_mode}", :skip_logging) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ip route |grep default # default via 10.235.9.1 dev eth0 | |
ip route change default via `ip route| awk '/^def/{print $3}'` dev eth0 initcwnd 16 | |
ip route |grep default # default via 10.235.9.1 dev eth0 initcwnd 16 | |
sysctl -w net.ipv4.tcp_slow_start_after_idle=0 | |
sysctl -a |grep net.ipv4.tcp_slow_start_after_idle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
class UnitTestError < StandardError; end | |
def describe(description, &block) | |
if Object.class_eval(&block) | |
print '.' | |
else | |
puts 'FAIL ' + description | |
raise UnitTestError |