Skip to content

Instantly share code, notes, and snippets.

@tgoldenberg
tgoldenberg / blocks.js
Created March 13, 2018 13:43
Initial blocks to verify transactions
const MY_ADDRESS = "";
const FRIEND_ADDRESS = "";
const BLOCKS = [
// Genesis block
{
hash: "00000244a5bae572247ca9f5b9149fc3980fa90a7a70cd35030a29d81ebc88ea",
version: 1,
previousHash: "0000000000000000000000000000000000000000000000000000000000000000",
timestamp: 1231006505000,
@tgoldenberg
tgoldenberg / .babelrc
Last active March 19, 2018 15:37
Sample Babel configuration
{
"presets": ["stage-2"],
"plugins": [
["transform-async-to-generator"],
["module-resolver", {
"root": ["."],
"alias": {
"classes": "./src/classes",
"store": "./src/store",
"utils": "./src/utils",
// webpack.config.js
const webpack = require('webpack');
const fs = require('fs');
const env = process.env.WEBPACK_ENV;
const libraryName = 'nodecoin';
let plugins = [ ];
let outputFile = 'nodecoin.js';
if (env === 'production') {
@tgoldenberg
tgoldenberg / makeWallet.js
Last active March 19, 2018 19:38
Function that creates full Bitcoin wallets
import base58 from 'bs58';
import coinstring from 'coinstring';
import crypto from 'crypto';
import { ec } from 'elliptic';
import ripemd160 from 'ripemd160';
import secureRandom from 'secure-random';
import sha256 from 'js-sha256';
const ecdsa = new ec('secp256k1');
const DEFAULT_VERSION = { public: 0x0, private: 0x80 };
@tgoldenberg
tgoldenberg / bitcoinEcdsaProof.js
Last active April 10, 2018 20:40
Proof of ECDSA signing algorithm used in Bitcoin
const RIPEMD160 = require('ripemd160');
const EC = require('elliptic').ec;
const sha256 = require('js-sha256');
const ec = new EC('secp256k1'); // Bitcoin uses Elliptic Curve Digital Signing Algorithm (ECDSA) to verify transactions
let message = 'I want to send this money'; // This would normally be the transaction hash with amount of money, publicScriptKey
let publicKey = '040c1fbe8b870d636823963ff21ba6e5250571848714203a08ae8700e0d97a1d7bb94ae888af72ac9a4fe02d558599d27c8986398902fa9ac0c1654f5839db1af5';
let privateKey = '2ec6d2808dc7b9d11e49516cfc747435feae8e9872d63c92bc5bde68a894199f';
"""
ID: thomasa3
LANG: PYTHON3
PROG: ariprog
"""
import math
import time
# fin = open("ariprog.in", "r")
# fout = open("ariprog.out", "w")
"""
ID: thomasa3
LANG: PYTHON3
PROG: wormhole
"""
import itertools
from collections import defaultdict
fin = open('wormhole.in', 'r')
fout = open('wormhole.out', 'w')
"""
ID: thomasa3
LANG: PYTHON3
PROG: wormhole
"""
import itertools
from collections import defaultdict
# import time
@tgoldenberg
tgoldenberg / stock.js
Last active November 16, 2017 16:28
stock schema
const Ticker = {
symbol: String,
timestamp: Date,
trading:{
week52High: Number,
week52Low: Number,
percent_shorted: Number,
shares_outstanding: Number,
enterprise_value: Number,
dividend: Number,
@tgoldenberg
tgoldenberg / findInvestors.js
Created July 10, 2017 03:35
Get a list of investors, given a list of companies
require('dotenv').config(); /* store your Angel List API token */
const rp = require('request-promise');
const ACCESS_TOKEN = process.env.ACCESS_TOKEN; /* access token to access Angel List API */
const ANGEL_LIST = 'https://api.angel.co/1'; /* version of Angel List API */
const ACCELERATOR_ID = 'YOUR_ACCELERATOR_ID_HERE';
/* utility function to create query string */
function encodeQueryData(data) {