Skip to content

Instantly share code, notes, and snippets.

View gorm.txt
1 services/bulletprooftxmanager/bulletprooftxmanager.go: err = db.Create(&etx).Error
2 services/bulletprooftxmanager/eth_resender_test.go: require.NoError(t, db.Create(&attempt1_2).Error)
3 services/bulletprooftxmanager/eth_resender_test.go: require.NoError(t, db.Create(&attempt3_2).Error)
4 services/bulletprooftxmanager/eth_broadcaster_test.go: require.NoError(t, db.Create(&firstInProgress).Error)
5 services/bulletprooftxmanager/eth_broadcaster_test.go: err := db.Create(&secondInProgress).Error
6 services/bulletprooftxmanager/orm_test.go: require.NoError(t, db.Create(&attempt).Error)
7 services/bulletprooftxmanager/eth_confirmer_test.go: require.NoError(t, db.Create(&attempt2_3).Error)
8 services/bulletprooftxmanager/eth_confirmer_test.go: require.NoError(t, db.Create(&attempt2_2).Error)
9 services/bulletprooftxmanager/eth_confirmer_test.go: require.NoError(t, db.Create(&attempt4_2).Error)
10 services/bulletprooftxmanager/eth_confirmer_test.go: require.N
View Oracle.sol
pragma solidity ^0.6.0;
import "https://github.com/smartcontractkit/chainlink/evm-contracts/src/v0.6/Oracle.sol";
View ChainlinkExample.sol
pragma solidity ^0.6.0;
import "https://github.com/smartcontractkit/chainlink/evm-contracts/src/v0.6/ChainlinkClient.sol";
// MyContract inherits the ChainlinkClient contract to gain the
// functionality of creating Chainlink requests
contract ChainlinkExample is ChainlinkClient {
// Stores the answer from the Chainlink oracle
uint256 public currentPrice;
address public owner;
View gist:fa9d6e9070250479e310f591fc8a0c0f
0. (Optional but recommended) Make a dump/backup of your DB
1. STOP your node
2. Set env vars: ETH_GAS_BUMP_WEI=10000000000 and ETH_GAS_BUMP_THRESHOLD=1 and ETH_GAS_PRICE_DEFAULT=200000000000 on the node
3. Make sure your gas updater is updated to latest master from github and running with MAX_GAS_PRICE set high (suggest 500000000000 or more). Note that units are in GWei.
4. Get the keystore file from the node (found in the .env/tempkeys directory on the server). To extract the private key inside the container:
$ yum install python3
$ pip3 install eth-keyfile
$ python3 -c "import eth_keyfile; password = input('enter your password: '); print(eth_keyfile.extract_key_from_keyfile('.env/tempkeys/0xYOUR_KEY_FILE.json', password).hex())"
View gist:3e5fe8c48e954c1de6cbe4faa385b642
# set these parameters
provider_url = 'YOUR_INFURA_URL'
wallet_password = 'YOUR_WALLET_PASSWORD'
nonce_start = 29936
nonce_end = 29940
gas_price = 112 * 10**9
from web3 import Web3
web3 = Web3(Web3.HTTPProvider(provider_url))
with open('node_key') as keyfile:
encrypted_key = keyfile.read()
View job_locking_query
lock_jobs = """
WITH RECURSIVE jobs AS (
SELECT (j).*, pg_try_advisory_lock($1::integer, (j).id) AS locked
FROM (
SELECT j
FROM #{table} AS j
WHERE NOT (id = ANY($3))
AND failed_at IS NULL
ORDER BY enqueued_at, j.id
FOR UPDATE SKIP LOCKED
@samsondav
samsondav / observer.md
Created Nov 30, 2017 — forked from pnc/observer.md
Using Erlang observer/appmon remotely
View observer.md

Using OTP's observer (appmon replacement) remotely

$ ssh remote-host "epmd -names"
epmd: up and running on port 4369 with data:
name some_node at port 58769

Note the running on port for epmd itself and the port of the node you're interested in debugging. Reconnect to the remote host with these ports forwarded:

$ ssh -L 4369:localhost:4369 -L 58769:localhost:58769 remote-host
@samsondav
samsondav / look_and_say.ex
Last active May 17, 2017
Look and Say in Elixir
View look_and_say.ex
defmodule LookAndSay do
@moduledoc """
Documentation for LookAndSay.
"""
def main(args) do
number = hd args
IO.puts(look_and_say(number))
end
@samsondav
samsondav / database_comment.rb
Created Jul 2, 2016
Rails read Postgres database column comments
View database_comment.rb
# frozen_string_literal: true
# A tiny class for reading column database comments
class DatabaseComment
DATABASE_NAME = Rails.configuration.database_configuration[Rails.env]['database'].freeze
# Reads back a postgres comment based on table_name and column_name
# Sanitizes inputs but it would be better not to allow user input strings here regardless
def self.read(table_name, column_name)
unless table_name.is_a?(Symbol) && column_name.is_a?(Symbol)
raise TypeError, <<~STERN_WARNING
@samsondav
samsondav / disable-gmail-cmd-enter.user.js
Last active Oct 31, 2016
Disable cmd+enter send in gmail
View disable-gmail-cmd-enter.user.js
// ==UserScript==
// @name Gmail disable cmd+enter
// @namespace sampdavies@gmail.com
// @description Disables cmd+enter from sending an email in gmail
// @include ^https?:\/\/mail\.google\.com.*$
// @version 1
// @grant none
// ==/UserScript==
(function(){
var isMac = unsafeWindow.navigator.oscpu.toLowerCase().contains("mac os x");