Skip to content

Instantly share code, notes, and snippets.

@gevans
gevans / output.txt
Created August 29, 2015 07:24
$ go list std # go1.4.2
cmd/addr2line
cmd/cgo
cmd/fix
cmd/go
cmd/gofmt
cmd/nm
cmd/objdump
cmd/pack
cmd/pprof
cmd/yacc
@gevans
gevans / shellshock.sh
Created September 26, 2014 00:37
Let's just run this in the office and see what happens...
#!/usr/bin/env bash
video_url='https://www.youtube.com/watch?v=dQw4w9WgXcQ'
exists() {
which "$1" &> /dev/null
}
os="$(uname)"
@gevans
gevans / bitcoin-bootstrap.sh
Created July 26, 2014 02:32
Provision a bitcoin node!
#!/usr/bin/env bash
# JSON-RPC user (see bitcoind -rpcuser)
RCP_USER='changeme'
# JSON-RPC password (see bitcoind -rpcpassword)
RPC_PASSWORD='changeme'
# JSON-RPC IP whitelist (see bitcoind -rpcallowip)
RPC_ALLOWED_IPS='127.0.0.1'
@gevans
gevans / hash_with_indifferent_access.rb
Created May 6, 2014 04:10
Mongoid extension to support fields with type `HashWithIndifferentAccess`
module Extensions
module HashWithIndifferentAccess
def mongoize
::HashWithIndifferentAccess.mongoize(self)
end
module ClassMethods
def demongoize(object)
@gevans
gevans / README.md
Last active August 29, 2015 13:57
Patches to add --no-client-reconnect CLI option to bfgminer 3.10.0, cgminer 3.7.2, and sgminer 4.1.153

These patches add a new CLI option: --no-client-reconnect. The changes are adapted from Kalroth's cgminer fork to be compatible with BFGMiner, CGMiner, and SGMiner. This solves a few reported security issues.

Usage

Patches can be applied to the source in a number of ways...

BFGMiner

# In a git clone:
@gevans
gevans / hash_ext.rb
Created March 15, 2014 23:56
Extension to Ruby's Numeric for easy conversion between hash rate units (adapted from https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/numeric/bytes.rb).
##
# Example:
#
# 123.kilohashes + 1.hash * 1.megahash
# => 1123000
#
class Numeric
KILOHASH = 1000
MEGAHASH = KILOHASH * 1000
GIGAHASH = MEGAHASH * 1000
@gevans
gevans / .gitignore
Last active December 27, 2015 03:19
Use a global gitignore. They're super helpful in avoiding redundancy (e.g. ignoring .DS_Store in every freaking project ever).
##
# OSX
##
.DS_Store
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
@gevans
gevans / README.md
Last active December 20, 2015 13:09

A quick monkey patch for use within Rails request specs. Adds boolean methods like ok?, not_found?, and unauthorized? to allow querying the name of a response status rather than its code. Within RSpec, expections can be specified easily as be_ok, be_not_found, and be_unauthorized. Like in a Rails action:

respond_with @some_object, status: 201

In my opinion, the above doesn't read as well as this:

respond_with @some_object, status: :created
@gevans
gevans / encryption-decryption.rb
Created July 16, 2013 00:24
A couple examples of using asymmetric RSA signing and encryption using Ruby's OpenSSL libraries.
require 'openssl'
key = OpenSSL::PKey::RSA.new(2048)
p encrypted_string = key.public_encrypt('my plaintext string', OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)
p decrypted_string = key.private_decrypt(encrypted_string, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)
@gevans
gevans / example.rb
Last active December 16, 2015 01:59
# app/models/example.rb
class Example
include Mongoid::Document
field :data, type: Hashie::Mash
end