Skip to content

Instantly share code, notes, and snippets.

@buccolo
buccolo / extjs_tweets.js
Created March 14, 2011 17:12
Gets the lastest 10 tweets from the user's Twitter.
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 December 10, 2011 19:25
Brute-forcing Diffie-Hellman's secret exponent.
#!/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 December 10, 2011 21:00
Vigenere Encryption
#!/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 December 11, 2011 16:37
Computes OrdP values
#!/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 December 15, 2011 22:00
Euler Phi (n)
#!/usr/bin/ruby
require 'rational'
number = ARGV[0].to_i
current = 0
phi = 0
while (current < number)
if (number.gcd(current) == 1)
@buccolo
buccolo / FixBorder.rb
Last active October 3, 2015 07:37
Sortbits
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 01:06
Password frequency from latest Twitter hacked accounts
# 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
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|
# Executes nginx recipe.
include_recipe "detroit::nginx"
# Creates deploy directory with correct permissions.
directory "/data/www" do
owner "nginx"
group "nginx"
mode "755"
end
worker_processes 3;
http {
server {
listen 80;
location / {
root /data/www;
}
}