This file contains hidden or 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/bash | |
rspec spec --order rand:$RANDOM | |
while [ $? -eq 0 ]; do | |
rspec spec --order rand:$RANDOM | |
done |
This file contains hidden or 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 Downloader | |
CONCURRENCY = 50 | |
def initializer(urls) | |
@urls = urls | |
end | |
def download | |
EventMachine.run do | |
EM::Iterator.new(@urls, CONCURRENCY).each do |url, iterator| |
This file contains hidden or 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
require 'fog' | |
require 'benchmark' | |
storage = Fog::Storage.new({:provider => 'AWS', :aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'], :aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'], :region => 'eu-west-1'}) | |
directory = storage.directories.get('roadar-test1') | |
puts Benchmark.realtime { | |
directory.files.create( | |
:key => 'test.jpg', | |
:body => File.open("test.jpg"), |
This file contains hidden or 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
default[:tbb][:version] = '4.2-20140122oss' | |
default[:tbb][:url] = 'https://www.threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb42_20140122oss_src.tgz' | |
default[:tbb][:sha] = 'f1bd8d983f93a10e340ba63f3a479632ddca1562a5242814dd82a378d3233b75' |
This file contains hidden or 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
en: | |
active_admin: | |
filters: | |
predicates: | |
not_eq: "Not equals" |
This file contains hidden or 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
module CaptureFields | |
class Matcher | |
class << self | |
def match_quoted | |
'(?:\\\\"|[^\\"]|\\.)*' | |
end | |
def match_label | |
"(?::? \"#{match_quoted}\")" | |
end |
This file contains hidden or 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
# 1st way - do it automatically | |
# AR decides if it's better to use JOIN or separate query | |
User.includes(:profile) | |
# -> join or separate query | |
# 2nd way - always use JOIN | |
User.eager_load(:profile) | |
# -> SELECT `users`.`id` AS t0_r0, ..., `profiles`.`user_id` AS t1_r1, ... FROM `users` LEFT OUTER JOIN `profiles` ON `profiles`.`user_id` = `users`.`id` | |
# 3rd way - always do separate query |
This file contains hidden or 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 HashKeysDumper | |
def self.dump(hash) | |
hash.map do |k, v| | |
if v.is_a? Hash | |
keys = dump(v) | |
keys.map { |k1| [k, k1].join('.') } | |
else | |
k.to_s | |
end | |
end.flatten |
This file contains hidden or 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
apt-get -y install pptpd dnsmasq | |
Add/uncomment the following line in /etc/sysctl.conf: | |
net.ipv4.ip_forward=1 | |
Commit the changes by running as root: | |
sysctl -p |
This file contains hidden or 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
$ history | awk {'print $2, $3, $4'} | sort | uniq -c | sort -k1 -rn | head -n 30 | |
681 gs | |
84 ll | |
84 gc | |
80 gd | |
80 gca | |
66 ga . | |
60 gb | |
48 cd .. | |
43 gp |