Attention: if you attempt to fork this gist, github will think that you are a spammer and you will have to confirm that you are human with them. Apparantly there are too many links in this list. Also I update it rather frequently (see revisions on the left), so it's probably wise to not fork it anyway.
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
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns | |
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms | |
Read 4K randomly from SSD* 150,000 ns 0.15 ms |
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 select_from_chosen(item_text, options) | |
field_id = find_field(options[:from])[:id] | |
within "##{field_id}_chzn" do | |
find('a.chzn-single').click | |
input = find("div.chzn-search input") | |
item_text.each_char do |char| | |
input.base.invoke('keypress', false, false, false, false, char.ord, nil); | |
end | |
find('ul.chzn-results').click | |
input.base.invoke('keypress', false, false, false, false, 40, nil); # down arrow |
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
RAILS_ENV=production rake db:setup | |
# produces the error below.....hmmm.....it's a no-worky | |
psql:/yourprojectpath/yourproject/db/structure.sql:29: ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/hstore.control": No such file or directory | |
# hstore postgresql extension needs to be installed, so.... | |
sudo apt-get install postgresql-contrib | |
# now your extension should be available to enable so log in with psql | |
psql -d yourproject_production -U yourdbuser -W |
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
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative" | |
# use: git lg |
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
## Ignore Visual Studio temporary files, build results, and | |
## files generated by popular Visual Studio add-ons. | |
# User-specific files | |
*.suo | |
*.user | |
*.sln.docstates | |
# Build results |
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
## The quick-and-nasty CVE-2013-0156 Heroku inspector! | |
## Originally brought to you by @elliottkember with changes by @markpundsack @ Heroku | |
## Download and run using: | |
## ruby heroku-CVE-2013-0156.rb | |
`heroku list`.split("\n").each do |app| | |
app = app.strip | |
# Some "heroku apps" lines have === formatting for grouping. They're not apps. | |
next if app[0..2] == "===" |
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
#!/usr/bin/env ruby | |
# | |
# Proof-of-Concept exploit for Rails SQL Injection (CVE-2013-0156) | |
# | |
# ## Advisory | |
# | |
# https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion | |
# | |
# ## Caveats | |
# |
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
str = "111222333" * 1000000 | |
a = Time.now | |
str.scan(/(0+|1+|2+|3+|4+|5+|6+|7+|8+|9+)/).map { |i| "#{i[0].size}#{i[0][0]}" }.join | |
puts Time.now - a | |
a = Time.now | |
str.scan(/((\d)\2*)/).map { |i| "#{i[0].size}#{i[1]}"}.join | |
puts Time.now - a |
NewerOlder