Skip to content

Instantly share code, notes, and snippets.

@buccolo
buccolo / extjs_tweets.js
Created Mar 14, 2011
Gets the lastest 10 tweets from the user's Twitter.
View extjs_tweets.js
var dsTweets = new Ext.data.JsonStore({
fields : [{name: 'text', type: 'string'}],
proxy : new Ext.data.ScriptTagProxy({
url : 'http://twitter.com/status/user_timeline/buccolo.json?count=10'
})
});
dsTweets.load({ callback: function(){
var tweets = store.query('');
@buccolo
buccolo / BruteDH.rb
Created Dec 10, 2011
Brute-forcing Diffie-Hellman's secret exponent.
View BruteDH.rb
#!/usr/bin/ruby
p = 1373
B = 805
i = 1
brute = 1
target = 397
while (brute != target)
brute = B ** i % p
@buccolo
buccolo / Vigenere.rb
Created Dec 10, 2011
Vigenere Encryption
View Vigenere.rb
#!/usr/bin/ruby
class String; def ord; self[0]; end; end
phrase = "tobeornottobethatisthequestion"
keyword = "hamlet"
len = keyword.length
keyindex = 0
@buccolo
buccolo / OrdP.rb
Created Dec 11, 2011
Computes OrdP values
View OrdP.rb
#!/usr/bin/ruby
if ARGV.length != 2
print "syntax: ./Ord prime number\n"
exit
end
number = ARGV[1].to_f
number_print = ARGV[1].to_f
prime = ARGV[0].to_f
@buccolo
buccolo / EPhi.rb
Created Dec 15, 2011
Euler Phi (n)
View EPhi.rb
#!/usr/bin/ruby
require 'rational'
number = ARGV[0].to_i
current = 0
phi = 0
while (current < number)
if (number.gcd(current) == 1)
View FixBorder.rb
class FixBorders
def go_horse!
all_images = load_image_list
all_images.each do |image|
# download original
# convert different sizes
# upload to S3
end
end
@buccolo
buccolo / gist:2640901
Created May 9, 2012
Password frequency from latest Twitter hacked accounts
View gist:2640901
# cat pwd.txt | cut -d : -f 2 | sort | uniq -c | sort -f -r
freq password
1270 315475
487 123456
176 123456789
68 102030
59 123
50 12345
44 1234
View Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu-precise64-chef"
config.vm.box_url = "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_chef-11.4.4.box"
config.vm.network :private_network, ip: "10.0.0.10"
config.vm.hostname = "detroit"
config.vm.provision :chef_solo do |chef|
View default.rb
# Executes nginx recipe.
include_recipe "detroit::nginx"
# Creates deploy directory with correct permissions.
directory "/data/www" do
owner "nginx"
group "nginx"
mode "755"
end
View nginx.conf.erb
worker_processes 3;
http {
server {
listen 80;
location / {
root /data/www;
}
}