Skip to content

Instantly share code, notes, and snippets.

View emkman's full-sized avatar

Ethan Kravitz emkman

View GitHub Profile
@0xd18b
0xd18b / reinvest.md
Last active July 10, 2021 03:17
Reinvesting BLD Rewards

Compounding gains are a marvelous thing. Here is a simple script to claim and reinvest your BLD stake.

On your validator machine:

touch ~/reinvest.sh
chmod +x ~/reinvest.sh
vi ~/reinvest.sh

And add the following:

var http = require('http'),
request = require('request');
const geth_node_url = 'https://mainnet.infura.io/v3/<project_id>'
const anyblock_api_key = '<api_key>';
var trace_api = [
'trace_call',
'trace_callMany',
'trace_rawTransaction',
@sealocal
sealocal / yarn.config
Last active May 14, 2021 12:16
Install Yarn and NodeJS on AWS Elastic Beanstalk EC2 Instance with Amazon Linux Ruby Platform, prior to precompiling assets for a Rails app
files:
# If this file is edited, it must be removed from EC2 instance prior to deploy.
"/opt/elasticbeanstalk/hooks/appdeploy/pre/09_yarn_install.sh" :
mode: "000775"
owner: root
group: users
content: |
#!/usr/bin/env bash
set -xe
@joewiz
joewiz / post-mortem.md
Last active September 3, 2023 11:57
Recovery from nginx "Too many open files" error on Amazon AWS Linux

On Tue Oct 27, 2015, history.state.gov began buckling under load, intermittently issuing 500 errors. Nginx's error log was sprinkled with the following errors:

2015/10/27 21:48:36 [crit] 2475#0: accept4() failed (24: Too many open files)

2015/10/27 21:48:36 [alert] 2475#0: *7163915 socket() failed (24: Too many open files) while connecting to upstream...

An article at http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/ provided directions that mostly worked. Below are the steps we followed. The steps that diverged from the article's directions are marked with an *.

  1. * Instead of using su to run ulimit on the nginx account, use ps aux | grep nginx to locate nginx's process IDs. Then query each process's file handle limits using cat /proc/pid/limits (where pid is the process id retrieved from ps). (Note: sudo may be necessary on your system for the cat command here, depending on your system.)
  2. Added fs.file-max = 70000 to /etc/sysctl.conf
@maddiesch
maddiesch / time-helpers.swift
Created August 6, 2014 18:07
Simple implementation of x.hours.ago() and others.
enum FloatToDate {
case Second(Double)
case Minute(Double)
case Hour(Double)
case Day(Double)
case Week(Double)
case Month(Double)
case Year(Double)
func ago() -> NSDate {
@davisford
davisford / setup-avahi.sh
Created July 12, 2013 14:14
Setup avahi-daemon on Ubuntu for so you can reach hostname `ubuntu.local` from host OS
sudo apt-get install avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan
@sowenjub
sowenjub / import_notes_app_to_evernote.applescript
Last active August 26, 2021 03:39 — forked from pdxmph/import_notes_app_to_evernote.applescript
Updated to import the modification date as well since that's how notes are sorted in Note.app
tell application "Notes"
set theNotes to every note of the folder "Notes"
repeat with thisNote in theNotes
set myTitle to the name of thisNote
set myText to the body of thisNote
set myCreateDate to the creation date of thisNote
set myUpdateDate to the modification date of thisNote
tell application "Evernote"
set theTransferredNote to create note with html myText ¬
title myTitle ¬
@pnc
pnc / AppDelegate.m.patch
Created April 6, 2012 18:05
Fix to Marcus Zarra's consecutive migration code
--- 1.txt 2012-04-06 14:09:33.000000000 -0400
+++ 2.txt 2012-04-06 14:09:45.000000000 -0400
@@ -119,28 +119,35 @@
}
//END:progressivelyMigrateURLFindModels
//See if we can find a matching destination model
//START:progressivelyMigrateURLFindMap
NSMappingModel *mappingModel = nil;
//
// NSString+Levenshtein.h
// PyHelp
//
// Modified by Michael Bianco on 12/2/11.
// <http://mabblog.com>
//
// Created by Rick Bourner on Sat Aug 09 2003.
// rick@bourner.com