Skip to content

Instantly share code, notes, and snippets.

View joecannatti's full-sized avatar

Joe Cannatti joecannatti

View GitHub Profile
for i in `find . -name \*.rb` do
echo $i;
sed -i -e "/[:.]omc_data_service/ s/\([:.]\)omc_data_service/\1service/g" $i;
require 'pp'.
require 'ldap'.
include LDAP
begin
connection = Conn.new('10.86.115.136', 389).
connection.set_option(LDAP_OPT_PROTOCOL_VERSION, 2).
connection.bind do
puts "in bind"
base_dn = 'dc=prnewswire,dc=com'
scope = LDAP_SCOPE_ONELEVEL.
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
[[ -s /Users/joecannatti/.rvm/scripts/rvm ]] && source /Users/joecannatti/.rvm/scripts/rvmif [[ -s $HOME/.rvm/scripts/rvm ]] ; then source $HOME/.rvm/scripts/rvm ; fi
rvm package install zlib
//other
rvm install 1.9.2-head
rvm use --default 1.9.2-head
@joecannatti
joecannatti / project_euler26.rb
Created April 19, 2011 02:52
Project Euler 26 in Ruby
require 'prime'
Prime.each(1000).to_a.drop(3).map do |n,c=1|
c += 1 until (((10**c)-1) % n) == 0
{:num => n, :size => c}
end.sort{|a,b| a[:size] <=> b[:size]}.last
@joecannatti
joecannatti / bubblesort.c
Created May 12, 2011 05:07
naive bubble sort -- c
#include <stdio.h>
#include <stdlib.h>
int main(void){
for(int x = 0; x<1000; x++){
int data[] = {165,233,447,497,313,258,394,185,18,164,402,442,409,309,477,55,149,23,315,361,279,248,278,479,299,149,56,229,421,273,56,353,123,285,386,162,60,382,217,396,248,329,438,217,62,1,389,205,68,17,350,183,259,10,459,257,370,394,495,251,108,406,106,433,297,72,473,412,230,401,31,207,6,230,227,110,43,215,60,320,366,403,119,47,424,36,231,429,71,316,154,216,136,73,345,237,409,56,394,461,119,217,37,449,478,64,142,450,178,342,338,214,423,462,433,489,323,444,232,140,276,431,363,334,304,434,74,337,389,255,148,63,166,279,57,58,12,440,309,489,69,92,415,148,472,187,181,302,170,390,65,307,474,135,73,491,431,22,239,428,151,82,227,399,110,458,191,295,40,0,5,479,188,478,72,357,309,254,362,431,119,146,103,197,53,148,93,398,322,405,323,80,439,379,101,54,401,89,6,378,450,326,122,137,469,15,384,190,331,20,94,224,147,57,465,39,482,86,405,81,150,270,72,25,368,0,163,152,53,270,58,360,35,318,336,130,210,371,266,21,278,310,369,265,327,222
@joecannatti
joecannatti / bubblesort.rb
Created May 12, 2011 05:09
naive bubble sort -- ruby
data = []
1000.times do |n|
data = [165, 233,447,497,313,258,394,185,18,164,402,442,409,309,477,55,149,23,315,361,279,248,278,479,299,149,56,229,421,273,56,353,123,285,386,162,60,382,217,396,248,329,438,217,62,1,389,205,68,17,350,183,259,10,459,257,370,394,495,251,108,406,106,433,297,72,473,412,230,401,31,207,6,230,227,110,43,215,60,320,366,403,119,47,424,36,231,429,71,316,154,216,136,73,345,237,409,56,394,461,119,217,37,449,478,64,142,450,178,342,338,214,423,462,433,489,323,444,232,140,276,431,363,334,304,434,74,337,389,255,148,63,166,279,57,58,12,440,309,489,69,92,415,148,472,187,181,302,170,390,65,307,474,135,73,491,431,22,239,428,151,82,227,399,110,458,191,295,40,0,5,479,188,478,72,357,309,254,362,431,119,146,103,197,53,148,93,398,322,405,323,80,439,379,101,54,401,89,6,378,450,326,122,137,469,15,384,190,331,20,94,224,147,57,465,39,482,86,405,81,150,270,72,25,368,0,163,152,53,270,58,360,35,318,336,130,210,371,266,21,278,310,369,265,327,222,392,453,261,273,98,352,251,120,354,453,483,243,326,130,489,125,16
@joecannatti
joecannatti / bubblesort.pl
Created May 13, 2011 05:22
naive bubble sort -- perl
@data = ();
for($a=0;$a<1000;$a++){
@data = (165, 233,447,497,313,258,394,185,18,164,402,442,409,309,477,55,149,23,315,361,279,248,278,479,299,149,56,229,421,273,56,353,123,285,386,162,60,382,217,396,248,329,438,217,62,1,389,205,68,17,350,183,259,10,459,257,370,394,495,251,108,406,106,433,297,72,473,412,230,401,31,207,6,230,227,110,43,215,60,320,366,403,119,47,424,36,231,429,71,316,154,216,136,73,345,237,409,56,394,461,119,217,37,449,478,64,142,450,178,342,338,214,423,462,433,489,323,444,232,140,276,431,363,334,304,434,74,337,389,255,148,63,166,279,57,58,12,440,309,489,69,92,415,148,472,187,181,302,170,390,65,307,474,135,73,491,431,22,239,428,151,82,227,399,110,458,191,295,40,0,5,479,188,478,72,357,309,254,362,431,119,146,103,197,53,148,93,398,322,405,323,80,439,379,101,54,401,89,6,378,450,326,122,137,469,15,384,190,331,20,94,224,147,57,465,39,482,86,405,81,150,270,72,25,368,0,163,152,53,270,58,360,35,318,336,130,210,371,266,21,278,310,369,265,327,222,392,453,261,273,98,352,251,120,354,453,483,243,326,130,
@joecannatti
joecannatti / deletes.sh
Created June 7, 2011 00:08
Undo deletes
git status | awk '/deleted/ {print $3}' | xargs git checkout