Skip to content

Instantly share code, notes, and snippets.

View cciollaro's full-sized avatar

Christopher cciollaro

  • Tokyo, JP
  • 23:05 (UTC +09:00)
View GitHub Profile

Keybase proof

I hereby claim:

  • I am cciollaro on github.
  • I am cciollaro (https://keybase.io/cciollaro) on keybase.
  • I have a public key ASDueUTB2-oaIgtSLWsUyhVumh4IYwjYrcCSl0NEur7yygo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am cciollaro on github.
  • I am cciollaro (https://keybase.io/cciollaro) on keybase.
  • I have a public key whose fingerprint is C448 1E99 EA31 E6C2 3B84 F63D E9FA BDBF 991B DE13

To claim this, I am signing this object:

@cciollaro
cciollaro / socialist_millionaire_sockets.rb
Last active May 10, 2016 21:06
socialist millionaire with tcp sockets
require 'socket'
#http://www.scribd.com/doc/34203336/How-to-Implement-RSA-in-Ruby#download
# Calculate a modular exponentiation eg: b^p mod m
def mod_pow(base, power, mod)
result = 1
while power > 0
result = (result * base) % mod if power & 1 == 1
base = (base * base) % mod
power >>= 1
@cciollaro
cciollaro / socialist_milli.rb
Last active August 29, 2015 14:03
socialist millionaire in ruby
#http://www.scribd.com/doc/34203336/How-to-Implement-RSA-in-Ruby#download
# Calculate a modular exponentiation eg: b^p mod m
def mod_pow(base, power, mod)
result = 1
while power > 0
result = (result * base) % mod if power & 1 == 1
base = (base * base) % mod
power >>= 1
end
result
@cciollaro
cciollaro / ghost_thing.rb
Last active August 29, 2015 14:02
ghost parser
class Array
alias :peek :last
end
trials = gets.to_i
trials.times do |x|
stack = []
ctr = 0
ptr = 0
str = gets.chomp
@cciollaro
cciollaro / cycle_sort.rb
Created April 14, 2014 23:21
cycle sort
blocks = (0..8).to_a.shuffle
puts blocks.inspect
i = 0
while i < 8
until i == blocks[i]
j = blocks[i]
#swap blocks[i] with blocks[blocks[i]]
blocks[i], blocks[j] = blocks[j], blocks[i]
end
@cciollaro
cciollaro / lowestsha512sum.rb
Last active August 29, 2015 13:56
lowest sha512 sum in ruby
require 'digest'
input = ARGV.first || "chris"
lowest_digest = Digest::SHA512.hexdigest(input)
lowest_input = input
begin
loop do
digest = Digest::SHA512.hexdigest(input)
if digest < lowest_digest
lowest_digest = digest
@cciollaro
cciollaro / test-guide
Created December 7, 2013 20:29
AVM testing structure
let's imagine you wanted to test Coin.js
1.) create test/coinTest.js
2.) write tests like these: http://pivotal.github.io/jasmine/. Jasmine is a really great library, go check out that page! :)
3.) when you've written your test, go to SpecRunner.html and include your test and dependencies like so:
<!-- include source files here... -->
<script type="text/javascript" src="js/Coin.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src="test/coinTest.js"></script>
@cciollaro
cciollaro / ModExp.java
Created October 17, 2013 23:36
A right-to-left binary modular exponentiation algorithm in java i.e. calculating a^b mod n
public class ModExp {
public static void main(String[] args) {
System.out.println(modExp(4,13,497));
}
public static int modExp(int a, int b, int n){
int d = 1;
String k = Integer.toBinaryString(b);
for(int i = 1; i <= k.length(); i++){
@cciollaro
cciollaro / CountingSort.java
Created October 5, 2013 22:55
stable counting sort in java
public class CountingSort{
public static void main(String[] args){
int[] a = {5,6,7,1,2,4,5,6,1,0,3,4,2};
printArray(countingSort(a, 7));
}
public static int[] countingSort(int[] a, int k){
int[] b = new int[a.length];
int[] c = new int[k + 1];
for(int i = 0; i < a.length; i++)