Skip to content

Instantly share code, notes, and snippets.

View JohnAllen's full-sized avatar

John Allen JohnAllen

View GitHub Profile
@captainsafia
captainsafia / deploy.js
Last active September 16, 2017 11:06
A quick Node script to allow multi-environment deploys with now
#! /usr/bin/env node
'use strict';
const program = require('commander');
const fs = require('fs');
const { spawn } = require('child_process');
program
.version('1.0.0')
.option('-e, --environment <environment>', 'Environment to deploy to')
anonymous
anonymous / -
Created September 29, 2017 13:58
pragma solidity ^0.4;
contract BigSpender {
uint writeToMe;
function writes(uint){
writeToMe = 1; // this throws if gas given is less than 20k
}
}
@xavierlepretre
xavierlepretre / promisifyWeb3.js
Created January 8, 2017 17:36
Convert `web3` asynchronous calls into Promises.
module.exports = {
promisify: function (web3) {
// Pipes values from a Web3 callback.
var callbackToResolve = function (resolve, reject) {
return function (error, value) {
if (error) {
reject(error);
} else {
resolve(value);
}
@LefterisJP
LefterisJP / TheCyber.md
Last active May 20, 2018 11:23
TheCyber

"The Cyber" Challenge

On 23/03/18 in the evening I got a PGP encrypted email with an invitation to a challenge involving two ethereum smart contracts called "The Cyber". I was intrigued and spent a bit of time solving the "GateKeeper" puzzles to enter the challenge. Now I would like to share it with whomever else wants to try solving it.

Below is the original message I got -- minus the passphrases.

Original Message

Hello

You have been formally invited to join theCyber, a decentralized club on the Ethereum blockchain. The contract (thecyber.eth | 0x97A99C819544AD0617F48379840941eFbe1bfAE1) is straightforward by design and deliberately avoids equity memberships, dues, contract ownership or migration, and voting or other governance. Rather, theCyber is intended to operate as a testbed that its members can use to communicate, attend events, and collaborate.

import tensorflow as tf
import numpy as np
NUM_STATES = 10
NUM_ACTIONS = 2
GAMMA = 0.5
def hot_one_state(index):
array = np.zeros(NUM_STATES)
@corinneling
corinneling / web-scraper-node-js.md
Last active February 24, 2022 23:21
Node web scraper with axios and cheerio

Node JS Web Scraper

I this is part of the first node web scraper I created with axios and cheerio. I took out all of the logic, since I only wanted to showcase how a basic setup for a nodejs web scraper would look.

const cheerio = require('cheerio'),
      axios = require('axios'),
      url = `<url goes here>`;
 
@learner-long-life
learner-long-life / Rinkeby.md
Last active August 30, 2022 22:32
How to get on Rinkeby Testnet in less than 10 minutes

How to get on Rinkeby Testnet in less than 10 minutes

Following instructions from the excellent https://www.rinkeby.io/

Synchronizing a Full Node

A full node lets you access all state. There is a light node (state-on-demand) and wallet-only (no state) instructions as well,

@rfikki
rfikki / ropsten-peers-latest.txt
Last active September 24, 2022 03:23
Updated July 15, 2020: Ropsten Latest Peers with Istanbul - IMPORTANT RUN THE LATEST RELEASE OF THE CLIENT - https://geth.ethereum.org/downloads/
admin.addPeer("enode://8c5131f577ee602ccaad5e5f600011c024d43d33e6af6f8a89ed26cbfadd7efe903a8e426dde4071b857e0838a2efa29ae3b268f8b55acd59e72d4a919673cbc@13.251.47.174:30303");
admin.addPeer("enode://798b8eba7b65cdd71bb061a6b18a1f7d16612d54e1aa542d8dc5c3573322b5dd7496c1eea100dbb84f8495d89f3d5ddb4142b0006a73cd32daa2f643bd5d1c76@175.24.29.183:30311");
admin.addPeer("enode://9a4be35fec78cf91e7e959029ae3f5d3d3e86446186eb14f181c8f3b9917f57839ef98d4ba53cf06eb4fea696ecc14796b34d96db4f4294864edfcab27dd9956@31.220.51.107:30303");
admin.addPeer("enode://2763ab6d19d6e7ce7a953ba95c9a87fe6ae5eac3434bf216282f53142d89cb5451faa701311d7de1d79cc8ecbd57f1781156e26f5722aee835547aeab870e385@52.237.88.221:30303");
admin.addPeer("enode://81488a6c0b62aa14a1172d607893b6317e4f2565ca2bd73c7c0b8bfd55842af6b7972218728d1f352b3fddc61d0dccbf92e81d2bbfdc375db44ae44ee332d4db@88.198.59.75:30303");
admin.addPeer("enode://3d55f613d74e90f5b8a4154d20d8a7260a973751c1402bf52adde2b08b72a9e0327a522bf187765f2d6e2a3b893dfe7aa41b204bce5f793bd9470f24fa3aafc
@robert52
robert52 / money.model.js
Last active November 11, 2022 17:40
Approaches to create and combine models in mongoose. Document referencing, model composition and many more.
'use strict';
const DEF_CURRENCY = 'USD';
const DEF_SCALE_FACTOR = 100;
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const ObjectId = Schema.ObjectId;
const MoneySchema = new Schema({
admin.addPeer("enode://da0c61fe14ba9da1a9835b59d811553d21787448724cfe6412bc17f0b14586df91826d8286b2137342d09a8631df5ea548cf301294b05657c2a90f9c3d526721@143.198.119.44:30303");
admin.addPeer("enode://3e2287c6caf363357efc600611ccb777e6997ef8b749b1f87e94d3a7d2b466bbefba163b0620c88804f18bc70cfbe68538720ac2644fc1c970848488cdca0c7a@143.198.114.251:30303");
admin.addPeer("enode://15ea76b5d30ce9eaabf6a9a8fe5ca0ff032534d296b5b8ca6e00a730d08a4aaa019077c382a6b2d08ebc7cf6f8eb888f5e00e0dd378798e3459a555538654370@157.230.6.79:30303");
admin.addPeer("enode://2e718763172902a8fa4bcdda45f77a5c2688de5230e184d154e4867922b8f6ad23e1016379715cb5f55f6c79060563f93896035e35dfb47361d08599d4908ae8@143.198.118.178:30303");
admin.addPeer("enode://9d45f21eeb37bd5555fac0c4094ae3d4d144d93e2313aeb891bf3054b0dcf6ca817961ed29ea1de00389b5c36dc6bbe9b00443e367b16ed8ba251cea6c242044@94.176.237.140:30303");
admin.addPeer("enode://2493b5b8407ccb1c448d7ad358e838066640f273442730caf80acde2fe98522b1d9dcebd2dc982efe44911a49779888fe72defc181c29596facff05e1