Skip to content

Instantly share code, notes, and snippets.

View cicorias's full-sized avatar

Shawn Cicoria cicorias

View GitHub Profile
@cicorias
cicorias / mock_notification.js
Created March 14, 2017 09:30 — forked from danfinlay/mock_notification.js
A simple metamask notification code example.
var state = {
imageifyIdenticons: false,
txData: {
"id":1467868023090690,"txParams":{"data":"0xa9059cbb0000000000000000000000008deb4d106090c3eb8f1950f727e87c4f884fb06f0000000000000000000000000000000000000000000000000000000000000064","from":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825","value":"0x16345785d8a0000","to":"0xbeb0ed3034c4155f3d16a64a5c5e7c8d4ea9e9c9","origin":"MetaMask","metamaskId":1467868023090690,"metamaskNetworkId":"2"},"time":1467868023090,"status":"unconfirmed","containsDelegateCall":false
},
accounts: {
'0xfdea65c8e26263f6d9a1b5de9555d2931a33b825': {
balance: "0x15e578bd8e9c8000",
}
},
@cicorias
cicorias / truffle-config.js
Created March 12, 2017 17:06 — forked from tomconte/truffle-config.js
Example Truffle 3.0 configuration file to allow deploying contracts to an Azure "Bletchley" Ethereum consortium network. Based on the Truffle docs for Infura (http://truffleframework.com/tutorials/using-infura-custom-provider).
var bip39 = require("bip39");
var ethwallet = require('ethereumjs-wallet');
var ProviderEngine = require("web3-provider-engine");
var WalletSubprovider = require('web3-provider-engine/subproviders/wallet.js');
var Web3Subprovider = require("web3-provider-engine/subproviders/web3.js");
var Web3 = require("web3");
// Insert raw hex private key here, e.g. using MyEtherWallet
var wallet = ethwallet.fromPrivateKey(Buffer.from('324a58ceac32c9a5a465a57a87600c086df72aa4ae0c6beb062436a2b6c0a2a6', 'hex'));
@cicorias
cicorias / compile-deploy-sign.js
Created March 12, 2017 00:06 — forked from tomconte/compile-deploy-sign.js
Shows how to compile and deploy a Smart Contract using client-side transaction signature, i.e. does not require the account to be unlocked in the Ethereum node.
const fs = require('fs');
const solc = require('solc');
const Web3 = require('web3');
const Tx = require('ethereumjs-tx')
// Private key to use to sign the transactions
// To decrypt your private key, use e.g. https://www.myetherwallet.com/#view-wallet-info
// You will find your private key file in e.g. .ethereum/keystore or .parity/keys
// In this example the key should correspond to the web3.eth.coinbase address
var privateKey = new Buffer('088c110b6861b6c6c57461370d661301b29a7570d59cb83c6b4f19ec4b47f642', 'hex')
@cicorias
cicorias / web3-solc-contract-compile-deploy.js
Created March 12, 2017 00:06 — forked from tomconte/web3-solc-contract-compile-deploy.js
Compiling and deploying an Ethereum Smart Contract, using solc and web3.
const fs = require('fs');
const solc = require('solc');
const Web3 = require('web3');
// Connect to local Ethereum node
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
// Compile the source code
const input = fs.readFileSync('Token.sol');
const output = solc.compile(input.toString(), 1);
@cicorias
cicorias / PriceFeed_cryptocompare
Created March 10, 2017 04:03 — forked from anonymous/PriceFeed_cryptocompare
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.9+commit.364da425.js&optimize=undefined&gist=
// Ethereum + Solidity
// This code sample & more @ dev.oraclize.it
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";
contract PriceFeed is usingOraclize {
uint public ETHUSD;
function PriceFeed(){
oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS);
contract EscrowContract {
address buyer;
address seller;
address agent;
// Each party has an entry here with the timestamp of their acceptance
uint[3] acceptances;
bool active;
@cicorias
cicorias / npm-upgrade-bleeding.sh
Created December 30, 2016 20:54 — forked from othiym23/npm-upgrade-bleeding.sh
a safe way to upgrade all of your globally-installed npm packages
#!/bin/sh
set -e
set -x
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f3)
do
npm -g install "$package"
done
@cicorias
cicorias / wifi_scan.m
Last active December 22, 2016 16:14 — forked from pavel-a/wifi_scan.m
Wi-Fi scan for Apple OS X (maybe works for iOS too)
//
// wifi_scan.m
// WifiDump
//
// Created by Shawn Cicoria on 12/22/16.
// Copyright © 2016 CedarLogic, LLC. All rights reserved.
//
/* The official example for CoreWLAN is now obsolete,
@cicorias
cicorias / backup_github.sh
Created November 22, 2016 16:09 — forked from xaprb/backup_github.sh
Shell script to back up all of an organization's GitHub repos
#!/bin/sh
LOGIN=YOURLOGIN
TOKEN=YOURTOKEN
ORG=YOURORG
DONE=0
PAGE=0
# sample output:
# "total_private_repos": 50,
@cicorias
cicorias / backup-github.sh
Created November 22, 2016 16:08 — forked from rodw/backup-github.sh
A simple script to backup an organization's GitHub repositories, wikis and issues.
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
# NOTE: if you have more than 100 repositories, you'll need to step thru the list of repos
# returned by GitHub one page at a time, as described at https://gist.github.com/darktim/5582423
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files
GHBU_ORG=${GHBU_ORG-"<CHANGE-ME>"} # the GitHub organization whose repos will be backed up
# (if you're backing up a user's repos instead, this should be your GitHub username)
GHBU_UNAME=${GHBU_UNAME-"<CHANGE-ME>"} # the username of a GitHub account (to use with the GitHub API)