Skip to content

Instantly share code, notes, and snippets.

View altamic's full-sized avatar

Michelangelo Altamore altamic

View GitHub Profile
@altamic
altamic / IMSIPlugin.java
Created September 17, 2012 13:57
PhoneGap IMSIPlugin
package it.telecomitalia.IMSIPlugin;
import org.json.JSONArray;
import android.content.Context;
import android.telephony.TelephonyManager;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
diff --git a/spec/bitcoin/bitcoin_spec.rb b/spec/bitcoin/bitcoin_spec.rb
index 0b42851..a766a57 100644
--- a/spec/bitcoin/bitcoin_spec.rb
+++ b/spec/bitcoin/bitcoin_spec.rb
@@ -35,6 +35,10 @@ describe 'Bitcoin Address/Hash160/PubKey' do
.should == "0026f5494b39ea04b7bcb05e583acf3b0102d61f"
Bitcoin.hash160_from_address("11122RGUQSszAsTpptd2h8sdyYGR6nKs6f")
.should == "0000daec8d6f05e949710f202c4f73258aa7791e"
+ Bitcoin.hash160_from_address("11119uLoMQCBHmKevdsFKHMaUoyrwLa9Y")
+ .should == "00000090c66372823859c935149e2e32d276a1e6"
loop do
addr = Bitcoin.generate_address
break if addr[0][1] == "1"
end
addr
Bitcoin.hash160_from_address(addr[0]) == addr[-1]
__END__
@altamic
altamic / altamic.js
Created May 31, 2012 09:15
how my nickname is obtained - js
"Michelangelo Altamore".split(' ').reverse().map(function(x) { return x.toLowerCase().substring(0,4)}).join('').substring(0,7)
// => "altamic"
@altamic
altamic / altamic.rb
Created May 23, 2012 10:26
how my nickname is obtained
"Michelang­elo Altam­ore".split­(' ').re­verse.map { |x| x.dow­ncase[0,4]­}.join[0,7­]
# => "altamic"
words = Hash.new
File.open("dictionary.txt", "r") do |file|
while line = file.gets
word = line.chomp
words[word.split('').sort!.join('')] += [word]
end
end
loop do
@altamic
altamic / block_chain.rb
Created August 26, 2011 14:46
Blockchain consisting of proof of work as from lian
#
# Ruby Example of the 'proof of work' explanation
# from https://en.bitcoin.it/wiki/Proof_of_work
#
# note: block data passed to do_work is simplified.
# bitcoin blockchain is more complex too.
#
require 'digest/sha2'
# trick for checking syntax of ruby code
eval("BEGIN{return true}; #{code}")
# lib/bitcoin/protocol/configuration.rb
Bitcoin::Protocol.configure do
register_constant :MAGIC, :production => [0xf9, 0xbe, 0xb4, 0xd9],
:test => [0xfa, 0xbf, 0xb5, 0xda]
register_constant :VERSION, 318
register_constant :SUB_VERSION, '.1'
register_constant :SERVICES, { :node_network => 1 }
@altamic
altamic / bitdump.sh
Created January 25, 2011 22:20
dumps Bitcoin network traffic
#!/usr/bin/env sh
# bitdump.sh
#
# captures Bitcoin network traffic
SELF=`basename $0`
if [[ $1 = "" ]]; then
DEFAULT="en1"