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
| def memstats | |
| size = `ps -o size= #{$$}`.strip.to_i | |
| 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
| #!/usr/bin/env ruby | |
| class GemDetails | |
| attr_accessor :name, :version, :changelog_file | |
| def initialize(name, version) | |
| @name, @version = name, version | |
| end | |
| def self.from_str(str) |
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 http = require('follow-redirects').http; | |
| //top 1000 | |
| var domains = ["google.com","facebook.com","youtube.com","yahoo.com","baidu.com","wikipedia.org","qq.com","linkedin.com","live.com","twitter.com","amazon.com","blogspot.com","taobao.com","google.co.in","sina.com.cn","wordpress.com","yahoo.co.jp","yandex.ru","bing.com","ebay.com","google.de","vk.com","hao123.com","163.com","tumblr.com","pinterest.com","google.co.uk","google.fr","googleusercontent.com","microsoft.com","msn.com","ask.com","mail.ru","google.co.jp","google.com.br","weibo.com","apple.com","paypal.com","google.ru","instagram.com","google.com.hk","xvideos.com","blogger.com","google.it","tmall.com","google.es","imdb.com","soso.com","craigslist.org","sohu.com","360.cn","go.com","amazon.co.jp","stackoverflow.com","bbc.co.uk","xhamster.com","google.com.mx","neobux.com","google.ca","fc2.com","cnn.com","imgur.com","alibaba.com","wordpress.org","flickr.com","espn.go.com","adcash.com","huffingtonpost.com","odnoklassniki.ru","t.co","conduit.com","thepira |
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
| # config/initializers/postgresql_patch.rb | |
| # | |
| class ActiveRecord::ConnectionAdapters::AbstractAdapter | |
| def translate_exception(exception, message) | |
| if exception.is_a?(PG::InvalidTextRepresentation) | |
| raise ActiveRecord::RecordNotFound | |
| else | |
| # override in derived class | |
| ActiveRecord::StatementInvalid.new(message, exception) | |
| 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
| function sign(req, res, next) { | |
| var fileName = req.body.fileName, | |
| expiration = new Date(new Date().getTime() + 1000 * 60 * 5).toISOString(); | |
| var policy = | |
| { "expiration": expiration, | |
| "conditions": [ | |
| {"bucket": bucket}, | |
| {"key": fileName}, |
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
| DISABLED_TASKS = [ | |
| 'db:drop', | |
| 'db:migrate:reset', | |
| 'db:schema:load', | |
| 'db:seed', | |
| # ... | |
| ] | |
| namespace :db do | |
| desc "Disable a task in production environment" |
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
| RUBY_GC_HEAP_FREE_SLOTS=4096 # Must be > 0 | |
| RUBY_GC_HEAP_INIT_SLOTS=10000 # Must be > 0 | |
| RUBY_GC_HEAP_GROWTH_FACTOR=1.8 # Must be > 1.0 | |
| RUBY_GC_HEAP_GROWTH_MAX_SLOTS=0 # Disabled; Must be > 0 | |
| RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR=2.0 # Must be > 0 | |
| RUBY_GC_MALLOC_LIMIT=16777216 # 16 MiB; Must be > 0 | |
| RUBY_GC_MALLOC_LIMIT_MAX=33554432 # 32 MiB; Must be > 0 | |
| RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR=1.4 # Must be > 1.0 | |
| RUBY_GC_OLDMALLOC_LIMIT=16777216 # 16 MiB; Must be > 0 | |
| RUBY_GC_OLDMALLOC_LIMIT_MAX=134217728 # 128 MiB; Must be > 0 |
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 "net/http" | |
| def start_server | |
| # Remove the X to enable the parameters for tuning. | |
| # These are the default values as of Ruby 2.2.0. | |
| @child = spawn(<<-EOC.split.join(" ")) | |
| XRUBY_GC_HEAP_FREE_SLOTS=4096 | |
| XRUBY_GC_HEAP_INIT_SLOTS=10000 | |
| XRUBY_GC_HEAP_GROWTH_FACTOR=1.8 | |
| XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0 |
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
| #you need to get new ctags, i recommend homebrew but anything will work | |
| brew install ctags | |
| #alias ctags if you used homebrew | |
| alias ctags="`brew --prefix`/bin/ctags" | |
| xcode-select --install | |
| brew install macvim --override-system-vim | |
| brew install git |
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
| #!/usr/bin/env ruby | |
| File.open("Readme.md", 'r') do |f| | |
| f.each_line do |line| | |
| forbidden_words = ['Table of contents', 'define', 'pragma'] | |
| next if !line.start_with?("#") || forbidden_words.any? { |w| line =~ /#{w}/ } | |
| title = line.gsub("#", "").strip | |
| href = title.gsub(" ", "-").downcase | |
| puts " " * (line.count("#")-1) + "* [#{title}](\##{href})" |