Skip to content

Instantly share code, notes, and snippets.

View JohnAllen's full-sized avatar

John Allen JohnAllen

View GitHub Profile
@jboner
jboner / latency.txt
Last active May 2, 2024 09:45
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@karpathy
karpathy / min-char-rnn.py
Last active May 1, 2024 11:00
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
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)
@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({
@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);
}
@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,

@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
}
}
@justsml
justsml / fetch-api-examples.md
Last active February 24, 2024 18:05
JavaScript Fetch API Examples
@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