Skip to content

Instantly share code, notes, and snippets.

var urls = [
/* Wildcard CORS enabled - Works in PhantomJS 1.9.0 */
'http://updates.html5rocks.com',
/* CORS disabled - Fails in PhantomJS 1.9.0 (and every other version) */
'http://www.google.com',
/* Hack workaround? */
/*
function(httpGet, callback) {
phantom.page.settings = (phantom.page.settings || {});
phantom.page.settings.webSecurityEnabled = false;
<div id="stack" style="height: 275px;">
<!--
"_id" : ObjectId("53f371ff540d630d415e7c86"),
"owner" : "351070185040940",
"jobownerid" : ObjectId("53d6b1ffcb4ebce61621a693"),
"title" : "Javascript Ninja",
"description" : "Javascript Ninja Needed !!!",
@achiko
achiko / 2of3.md
Last active August 29, 2015 14:22 — forked from anonymous/2of3.md

2-of-3 Escrow Example with Electrum

This is gmaxwell's 2-of-2 escrow example, adapted to Electrum and to a lesser extent, GFM.

The Scenario

Archey wants to pay Bertha 0.001 BTC for a Twitter Platinum invite, but prevent Bertha from cheating him. Archey selects Iceland to act as

@achiko
achiko / Git Heroku
Created July 1, 2013 12:08
Heroku SSH Guide
https://devcenter.heroku.com/articles/keys
Uploading SSH keys:
http://stackoverflow.com/questions/5136744/unable-to-push-master-to-heroku
type in gem install heroku
Then upload rsa key of github to heroku
$ heroku keys:add
@achiko
achiko / gist:5994343
Created July 14, 2013 13:49
Heroku mongolab connect
// http://stackoverflow.com/questions/10406668/how-do-i-use-node-mongodb-native-to-connect-to-heroku
// You connect to your mongolab database (so you can't create a new "blog" database). process.env.MONGOLAB_URI includes the // database name as well. See your mongolab uri:
heroku config | grep MONGOLAB_URI
It looks like: mongodb://heroku_app123456:password@dbh73.mongolab.com:27737/heroku_app123456
@achiko
achiko / es.sh
Created September 30, 2013 19:26
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below
# NEW WAY / EASY WAY
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.5.deb
sudo dpkg -i elasticsearch-0.90.5.deb
var myStore;
subjectStore.on('load', function() {
//--- Do Something
}, myStore, { single: true } );
contract tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData); }
contract MyToken {
/* Public variables of the token */
string public name;
string public symbol;
uint8 public decimals;
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
@achiko
achiko / Random generator
Created March 21, 2016 12:38 — forked from alexvandesande/Random generator
A very simple random generator. A miner can influence the number by not publishing a block with an unwanted outcome, and forfeiting the 5 block reward.
contract random {
/* Generates a random number from 0 to 100 based on the last block hash */
function randomGen(uint seed) constant returns (uint randomNumber) {
return(uint(sha3(block.blockhash(block.number-1), seed ))%100);
}
/* generates a number from 0 to 2^n based on the last n blocks */
function multiBlockRandomGen(uint seed, uint size) constant returns (uint randomNumber) {
uint n = 0;
for (uint i = 0; i < size; i++){
geth --mine --minerthreads=4 --identity "MyNodeName" --genesis CustomGenesis.json --rpc --rpcport "8000" --rpccorsdomain "*" --datadir "C:\Users\user\AppData\Roaming\Ethereum\testnet" --port "30303" --nodiscover --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcapi "db,eth,net,web3" --autodag --networkid 1900 --nat "any" --unlock 8dc76d4bd88d9e38b5eca20ef82b0fe2d9bff369