Skip to content

Instantly share code, notes, and snippets.

View joecannatti's full-sized avatar

Joe Cannatti joecannatti

View GitHub Profile
class Task
attr_accessor :name
attr_accessor :assigned_to_user_id
attr_accessor :due_on
def save
Storer.store(self)
end
end
@joecannatti
joecannatti / shell.rb
Created August 22, 2012 12:53
shell.rb
scan 'patient-2-nvp', COLUMNS => ['d:subtype', 'd:ehrSystemIdQualifier'], LIMIT => 10 }
import org.apache.hadoop.hbase.filter.CompareFilter
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter
import org.apache.hadoop.hbase.filter.SubstringComparator
import org.apache.hadoop.hbase.util.Bytes
scan 'patient-2-nvp', { COLUMNS => ['d:ehrSystemIdQualifier'], LIMIT => 2000, FILTER => SingleColumnValueFilter.new(Bytes.toBytes('d'), Bytes.toBytes('ehrSystemIdQualifier'), CompareFilter::CompareOp.valueOf('EQUAL'), SubstringComparator.new('MEDS_HX_REVIEW')) }
scan 'patient-2-nvp', { COLUMNS => ['d:ehrSystemIdQualifier'], LIMIT => 20, FILTER => SingleColumnValueFilter.new(Bytes.toBytes('d'), Bytes.toBytes('provIds'), CompareFilter::CompareOp.valueOf('NOT_EQUAL'), BinaryComparator.new(Bytes.toBytes(''))) }
@joecannatti
joecannatti / pe18and67.rb
Created June 5, 2012 13:25
pe18and67.rb
triangle = []
File.open("data.txt").each do |line|
to_num = line.split.map(&:to_i)
triangle << to_num
end
def reduce_last_row(triangle)
row_index = triangle.size - 2
triangle[row_index].each_with_index do |value,col_index|
left = triangle[row_index+1][col_index]
triangle = []
File.open("data.txt").each do |line|
triangle << line.split
end
def calc_values(row, value, triangle, results, current_path=0)
if triangle.size == (row + 1)
results << current_path + triangle[row][value].to_i
else
calc_values(row + 1, value, triangle, results, current_path + triangle[row][value].to_i)
function find_roku {
for i in $(arp -a | awk '{print $2}' | sed "s/[(|)]//g"); do
curl $i:8060 &>/dev/null
if [[ "$?" == "0" ]]; then
echo $i
export ROKU_IP=$i
fi
done
}
@joecannatti
joecannatti / roku.sh
Created May 2, 2012 03:30
Print your roku ip address
for i in $(arp -a | awk '{print $2}' | sed "s/[(|)]//g"); do curl $i:8060 &>/dev/null; if [[ "$?" == "0" ]]; then echo $i; fi; done
@joecannatti
joecannatti / bike.pl
Created March 27, 2012 03:41
bike.pl
#!/usr/bin/env perl
use strict;
use warnings;
use LWP;
use Mojo::DOM;
my $browser = LWP::UserAgent->new;
my $url = "http://cleveland.craigslist.org/bik/";
my $response = $browser->get( $url );
@joecannatti
joecannatti / project_euler_40.html
Created January 4, 2012 01:20
project euler 40
<html>
<body>
<div id="output"></div>
<script>
var number = '';
for(var i=1; i<=1000000;i++){
number = number + i;
}
var answer = number[0] * number[9] * number[99] * number[999] * number[9999] * number[99999] * number[999999];
document.getElementById("output").innerHTML = answer;
@joecannatti
joecannatti / euler35.rb
Created December 28, 2011 04:41
euler35
#!/usr/bin/env ruby
require 'prime'
require 'mathn'
def shifts(arr)
res = []
tmp = arr.dup
(0..arr.length-1).each do |a|
tmp << tmp.shift
res << tmp.dup
@joecannatti
joecannatti / euler-34.rb
Created December 28, 2011 03:22
euler34
#!/usr/bin/env ruby
total = 0
(3..100000).each do |num|
res = num.to_s.chars.map { |d| d.to_i > 0 ? d.to_i.downto(1).inject(:*) : 1 }.inject(:+)
total += num if res == num
end
p total