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
# proof that rsystemm2 (http://rsystemm2.tumblr.com/) is bullshit | |
# designed to earn referral money from ladbrokes. | |
# | |
# this actually uses a 50% win chance, compared to roulettes 48.6% | |
# so it should be _more_ profitable than the "system" | |
# sample output in 2nd file. | |
def roulette_system | |
history = [] | |
predicted = nil |
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
[jgalang@rashomon:~/Code/skunkworks/2fa] | |
∴ ruby totp_demo.rb | |
Time(sec) Time (UTC format) Value of T(Hex) TOTP Mode OK | |
------------------------------------------------------------------------------------------ | |
59 1970-01-01 00:00:59 0000000000000001 94287082 SHA1 ✔ | |
59 1970-01-01 00:00:59 0000000000000001 46119246 SHA256 ✔ | |
59 1970-01-01 00:00:59 0000000000000001 90693936 SHA512 ✔ | |
1111111109 2005-03-18 01:58:29 00000000023523EC 07081804 SHA1 ✔ | |
1111111109 2005-03-18 01:58:29 00000000023523EC 68084774 SHA256 ✔ |
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
.form-actions | |
- if params[:action] == "new" | |
= button_tag type: "submit", class: "btn btn-success btn-cons", | |
id: "submit" do | |
= fa_icon "check" | |
%span Create | |
= link_to courses_path, class: "btn btn-danger btn-cons" do | |
= fa_icon "close" | |
%span Cancel |
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
def multi_tenantify(tenant, with_database = true) | |
connection_info = if use_tenant_specific_db_conf? | |
_tenants_name_value.with_indifferent_access[tenant].clone | |
else | |
@config.clone | |
end | |
if with_database | |
database_name = Apartment.tenant_name_transform(tenant) # to replace environmentify? | |
connection_info[:database] = database_name |
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
<tr class="foo"></tr> | |
<tr class="foo"></tr> | |
<tr></tr> | |
<tr class="bar"></tr> |
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
scope = RealModel.where(name: 'foo') | |
threads = [] | |
dbs.each do |db| | |
threads << Thread.new do | |
dynamic_class_name = "TempModel#{Thread.current.object_id}" | |
dynamic_class = Object.const_set(dynamic_class_name, Class.new(query_model)) | |
begin | |
con = retrieve_connection(db, resolver) | |
dynamic_class.establish_connection(con) | |
local_scope = dynamic_class.all.merge(scope) |
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
a = [1,2] | |
Benchmark.ips do |x| | |
x.report("reduce") { a.reduce(:*) } | |
x.report("other") { a[0] * a[1] } | |
x.compare! | |
end | |
Calculating ------------------------------------- | |
reduce 56.411k i/100ms |
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 SC | |
def self.set_var(val) | |
@var = val | |
end | |
def superclass_instance_get_var | |
puts self.class.instance_variable_get("@var") | |
end | |
def self.superclass_class_get_var |
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
module TestConcern | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def foobar(a,b,c) | |
puts "doin sum cool shiz in hurr liek: #{a}, #{b} and #{c}" | |
end | |
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
du | awk '{ if ($1>1000*1024) { print $0 } }' | |
# prints out a whole bunch of directories bigger than 1000mb | |
du --max-depth=3 | awk '{ if ($1>1000*1024) { print $0 } }' | |
# just hangs with no output (i waited 5 mins) whereas .. | |
du --max-depth=3 | |
# immediately outputs directories which i can see are bigger than 1000mb |