Skip to content

Instantly share code, notes, and snippets.

/**
* Creates the delta that would take this state to the newer state
*/
public GameStateDelta getDeltaTo(GameState newer) {
GameStateDelta delta = new GameStateDelta();
Set<GameObject> dissapeared = Sets.difference(this.getGameObjects(), newer.getGameObjects());
Set<GameObject> appeared = Sets.difference(newer.getGameObjects(), this.getGameObjects());
Set<Long> continued = Sets.intersection(this.getGameObjectIds(), newer.getGameObjectIds());
public class Fireball extends GameObject implements Updatable {
private static final int VELOCITY = 5;
@NetworkData
private Vector2D pos;
@NetworkData
private final Vector2D speed;
@NetworkData
@maraoz
maraoz / gist:9834017
Last active August 29, 2015 13:57 — forked from matiu/gist:9833812
/* create and sign */
var tx = TransactionBuilder.init(opts)
.addUtxos(utxos)
.addOutputs(outs)
.addKeys(keys)
.build();
broadcast(tx.serialize());
@maraoz
maraoz / gist:10297571
Created April 9, 2014 17:59
ci.testling.com build output for bitpay/bitcore
Traceback (most recent call last):
File "/testling/bin/node-v0.10.24/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 18, in <module>
sys.exit(gyp.script_main())
File "/testling/bin/node-v0.10.24/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 534, in script_main
return main(sys.argv[1:])
File "/testling/bin/node-v0.10.24/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 527, in main
return gyp_main(args)
File "/testling/bin/node-v0.10.24/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 503, in gyp_main
options.circular_check)
File "/testling/bin/node-v0.10.24/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 129, in Load
@maraoz
maraoz / gist:10776497
Created April 15, 2014 21:20
is this secure from browser extensions inspecting the secret value?
var Hasher = (function(){
var secret = 42;
var Hasher = function() {
};
Hasher.prototype.setSecret = function(s) {
secret = s;
};
Hasher.prototype.hash = function(x) {
@maraoz
maraoz / gist:51a0018ecf9afcd3c007
Last active August 29, 2015 14:01
m-of-n finder script output with scriptSig < 500 bytes limit
case 1-of-1
max size: 113
case 1-of-2
max size: 147
case 2-of-2
max size: 221
case 1-of-3
max size: 182
case 2-of-3
@maraoz
maraoz / gist:8393f72a998bae58d585
Created June 11, 2014 19:16
bip32 non-deterministic derivation bug
var hk = new HierarchicalKey('tprv8ZgxMBicQKsPdSF1avR6mXyDj5Uv1XY2UyUHSDpAXQ5TvPN7prGeDppjy4562rBB9gMMAhRfFdJrNDpQ4t69kkqHNEEen3PX1zBJqSehJDH');
console.log(hk.derive('m/45/0/0/0').extendedPrivateKeyString());
console.log(hk.derive('m/45/0/0/0').extendedPrivateKeyString());
console.log(hk.derive('m/45\'/0/0/0').extendedPrivateKeyString());
console.log(hk.derive('m/45\'/0/0/0').extendedPrivateKeyString());
Outputs:
tprv8iDdrJ7doYBh2MpWDAPHopqUZ8jftExnk3v98yGFfEJPAfUBszoswxqg5doKrQS7whF6q5Q4cdK2Bdn3HWA4tURnjdPyPv83fpuamjELFmP
tprv8iDdrJ7doYBh2MpWDAPHopqUZ8jftExnk3v98yGFfEJPAfUBszoswxqg5doKrQS7whF6q5Q4cdK2Bdn3HWA4tURnjdPyPv83fpuamjELFmP
@maraoz
maraoz / gist:7dbbd94070c689286da3
Created June 16, 2014 15:16
brain wallets in bitcore
var bitcore = require('bitcore');
var password = 'an example of an insecure password';
var privateKey = bitcore.util.sha256(password);
var key = new bitcore.Key();
key.private = privateKey;
key.regenerateSync();
var addr = new bitcore.Address.fromKey(key);
@maraoz
maraoz / gist:1f07abe80e88291f8bc9
Created July 21, 2014 18:07
Copay new architecture thoughts
The objectives are:
- make copay work in all platforms.
- make it as decentralized as possible.
- allow async operations (mainly transaction proposals)
- allow remote encrypted key storage
### Keybase proof
I hereby claim:
* I am maraoz on github.
* I am maraoz (https://keybase.io/maraoz) on keybase.
* I have a public key whose fingerprint is B27B D36C DF12 AA21 2788 E780 64F3 727B FE0B 3196
To claim this, I am signing this object: