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
/var/apps/*/shared/*.log { | |
daily | |
missingok | |
rotate 52 | |
compress | |
delaycompress | |
notifempty | |
create 777 root adm | |
} |
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
function GetCreditCardTypeByNumber(ccnumber) { | |
var cc = (ccnumber + '').replace(/\s/g, ''); //remove space | |
if ((/^(34|37)/).test(cc) && cc.length == 15) { | |
return 'AMEX'; //AMEX begins with 34 or 37, and length is 15. | |
} else if ((/^(51|52|53|54|55)/).test(cc) && cc.length == 16) { | |
return 'MasterCard'; //MasterCard beigins with 51-55, and length is 16. | |
} else if ((/^(4)/).test(cc) && (cc.length == 13 || cc.length == 16)) { | |
return 'Visa'; //VISA begins with 4, and length is 13 or 16. | |
} else if ((/^(300|301|302|303|304|305|36|38)/).test(cc) && cc.length == 14) { |
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
var DateHelper = { | |
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time | |
// Ruby strftime: %b %d, %Y %H:%M:%S GMT | |
time_ago_in_words_with_parsing: function(from) { | |
var date = new Date; | |
date.setTime(Date.parse(from)); | |
return this.time_ago_in_words(date); | |
}, | |
// Takes a timestamp and converts it to a relative time | |
// DateHelper.time_ago_in_words(1331079503000) |
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
# ey-cloud-recipes/cookbooks/redis-yml/recipes/default.rb | |
if ['app_master', 'app'].include?(node[:instance_role]) | |
redis_instance = node['utility_instances'].find { |instance| instance['name'] == 'redis' } | |
if redis_instance | |
node[:applications].each do |app, data| | |
template "/data/#{app}/shared/config/redis.yml"do | |
source 'redis.yml.erb' | |
owner node[:owner_name] |
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
cookie = 'XXX--YYY' | |
ActiveSupport::MessageVerifier.new(Rails.application.config.secret_token).verify(cookie) |
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
rand(36**8).to_s(36) |
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 'benchmark' | |
n = 1000000 | |
Benchmark.bmbm do |x| | |
x.report("assign single") { n.times do; c = 'a string'; end} | |
x.report("assign double") { n.times do; c = "a string"; end} | |
x.report("concat single") { n.times do; 'a string ' + 'b string'; end} | |
x.report("concat double") { n.times do; "a string " + "b string"; end} | |
x.report("use << single") { n.times do; 'a string ' << 'b string'; 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
require 'benchmark' | |
n = 100000 | |
Benchmark.bmbm do |x| | |
x.report("rescue") { n.times { raise NoMethodError rescue nil } } | |
x.report('logic') { n.times { nil if Kernel.const_defined? "Foo"; } } | |
x.report('throw') { n.times { catch(:foo) { throw(:foo) } } } | |
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
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d |
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 'benchmark/ips' | |
require 'multi_json' | |
require 'json' | |
require 'msgpack' | |
hash = { | |
"site_config"=> | |
{ | |
"created_at"=>"2014-03-24T19:58:25Z", | |
"data"=>"", |
OlderNewer