Skip to content

Instantly share code, notes, and snippets.

Working from home

Andrew Mager mager

Working from home
Block or report user

Report or block mager

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
mager / sf.json
Created Apr 12, 2018
Example SF GeoJSON polygon
View sf.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
mager / deploy.js
Created Feb 2, 2018
Compile & deploy a BigGame contract
View deploy.js
const path = require('path');
const fs = require('fs');
const solc = require('solc');
const source = fs.readFileSync(bigGamePath, 'utf8');
const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const { MNEMONIC, INFURA_HOST } = process.env;
const provider = new HDWalletProvider(MNEMONIC, INFURA_HOST);
const web3 = new Web3(provider);
mager / lottery.test.js
Last active Feb 2, 2018
Testing a lottery contract (snippet)
View lottery.test.js
it('allows an account to enter', async () => {
await lottery.methods.enter().send({
from: accounts[0],
value: web3.utils.toWei('0.015', 'ether'),
const players = await lottery.methods.players().call({
from: accounts[0],
const balance = await lottery.methods.getBalance().call({
mager / inbox.sol
Created Feb 1, 2018
Inbox contract example
View inbox.sol
pragma solidity ^0.4.18;
contract Inbox {
string public message;
function Inbox(string initialMessage) public {
message = initialMessage;
function setMessage(string newMessage) public {
View ex-stats-tracker-usage.ex
iex> ExStatsTracker.counter(your_key, 1)
iex> ExStatsTracker.increment(your_key)
iex> ExStatsTracker.gauge(your_key)
iex> ExStatsTracker.timing(your_metric, 1)
iex> ExStatsTracker.histogram(your_metric, 1)
iex> ExStatsTracker.meter(your_metric, 1)
View ex-stats-tracker-config.ex
config :ex_stats_tracker,
host: “”,
  port: 1234,
  prefix: “your_prefix”
  flush_interval: 10000
  chunk_size: 20
mager / consul_mut_ex_example.ex
Created Mar 17, 2017
Simple consul_mut_ex example using do...while block
View consul_mut_ex_example.ex
iex> ConsulMutEx.lock(“test_key”, max_retries: 0) do
...> :acquired
...> else
...> :failed_to_acquire
...> end
mager / consul_backend.ex
Last active Feb 14, 2017
Consul backend for mutex library
View consul_backend.ex
defmodule ConsulMutEx.Backends.ConsulBackend do
@moduledoc """
Use Hashicorp's Consul KV store to acquire and release locks.
[Consul documentation](
alias Consul.Session
@timeout 1000
mager /
Last active Jan 18, 2016
Seattle delivery
from postmates import PostmatesAPI, DeliveryQuote, Delivery, Location, PostmatesAPIException
key = '[redacted]'
customer_id = '[redacted]'
api = PostmatesAPI(key, customer_id)
pickup = Location('Gather Food LLC', '1440 S. Jackson Street, Seattle, WA', '574-551-2847')
dropoff = Location('Bob', '1040 S. Jackson Street, Seattle, WA', '415-777-9999')
quote = DeliveryQuote(api, pickup.address, dropoff.address)
You can’t perform that action at this time.