Skip to content

Instantly share code, notes, and snippets.

Eth wrangling.

justin j. moses justinjmoses

Eth wrangling.
Block or report user

Report or block justinjmoses

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
justinjmoses / index.html
Created Oct 20, 2019
Synthetix top holders lock status
View index.html
<header><img src="" /></header>
<p class="helper-text">Note: these results aren't strictly ordered to increase performance.</p>
<button name="begin">Begin</button>
<button name="stop">Stop</button>
<li id="tokenHolders"><strong>Token Holders:</strong><var>?</var></li>
justinjmoses / totalIssuedSynths.js
Created Jul 3, 2019
Get total issued debt at some specific block
View totalIssuedSynths.js
const { SynthetixJs } = require('synthetix-js');
const snxjs = new SynthetixJs();
(async () => {
const provider = snxjs.ethers.getDefaultProvider();
const currentBlock = await provider.getBlockNumber();
const totalDebtInSystemAtBlock = await snxjs.Synthetix.contract.totalIssuedSynths(
justinjmoses / exchanges.js
Created Jul 3, 2019
Get all SynthExchange events in the last 24hours using The Graph
View exchanges.js
const graphAPI = '';
const ts = Math.floor(;
const oneDayAgo = ts - (3600 * 24);
const response = await fetch(graphAPI, {
method: 'POST',
body: `{"query":"{synthExchanges(orderBy:timestamp, orderDirection:desc, where:{timestamp_gt: ${oneDayAgo}}){id,from,gasPrice,fromAmount,fromCurrencyKey,toCurrencyKey,block,timestamp,toAddress}}","variables":null}`
const json = await response.json();
justinjmoses / vcheck.js
Created May 14, 2019
Node script to check npm version of package (expects piped in versions from npm)
View vcheck.js
'use strict';
const version = process.argv[2];
// Simple script to exit non-zero if the given version
// usage: npm view [package] versions | node vcheck [version]
// eg: npm view synthetix versions | node vcheck 2.4.1
justinjmoses / random-split.js
Created Dec 4, 2018
Function to split up some given number into a fixed number of parts.
View random-split.js
const random = require('random-js')();
// Splits up number into times random parts
const splitter = (number, times) => {
const ran = random.real(0, number);
if (times < 2) {
return [number];
const halved = times / 2;
if (times % 2 === 0) {
justinjmoses / EOS Smart Contract
Last active Nov 12, 2018
Getting started writing Smart Contracts with EOS
View EOS Smart Contract

Getting started writing Smart Contracts with EOS

This information has been extrapolated from

Latest version of EOS when writing: 1.4.0

Note: the Developer Portal has a number of older links inside it. Some of the URLs contain older version numbers. For example, if you use the breadcrumbs at the top, things can get confusing as the latest version shows as v1.3.0 which has different C++ syntax due to the latest changes in eosio.cdt )Contract Development Toolkit)

Environment Setup

justinjmoses / Deferred.js
Last active May 11, 2018
Migrating to jQuery 3 Promises A+
View Deferred.js
module.exports = class Deferred {
constructor() {
this._promise = new Promise((resolve, reject) => {
this._resolve = resolve;
this._reject = reject;
resolve(value) {
justinjmoses /
Last active Mar 28, 2017
Git show branches with most recent commits
# via
git for-each-ref --sort=committerdate refs/heads/ --format="%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))"
View index.html
<!DOCTYPE html>
<meta charset="utf-8"/>
<title>es6 proxy #jsbench #jsperf</title>
<script src=""></script>
<script src="./suite.js"></script>
<h1>Open the console to view the results</h1>
justinjmoses /
Last active Feb 16, 2017
Create dynamic objects in a nodejs6 REPL with Proxy

#Create dynamic objects in a nodejs6 REPL with Proxy

Nodejs 6.x comes with ES6 Proxy support baked in. Just like Ruby's method-missing (aka ghost methods), you can intercept getters and setters on an object and, like ActiveRecord in Rails, write rich APIs that can take any method or property name you like.

They are particularly fun in a REPL, where you might want to handle undefined variables.

For example, say we started a nodejs REPL via:

You can’t perform that action at this time.