Skip to content

Instantly share code, notes, and snippets.

@maxtaco
maxtaco / postal.iced
Created July 20, 2014 01:26
Adapter to use jQuery's ajax with IcedCoffeeScript
#-----------------------------------
# Like postal, but returns like request() on node.
$.postal = ({ url, params, dataType, ok_http_status_codes, ok_json_status_codes, ok_empty_body}, cb) ->
headers = {}
if (t = window.csrf_token)? and t.length
headers["X-CSRF-Token"] = t
ok_http_status_codes or= [ 200 ]
ok_json_status_codes or= [ 'OK' ]
mkdir -p /vol/bitcoin0/src
cd src
export PRFX=/vol/bitcoin0/usr

# yum it up
sudo yum install boost-devel.x86_64 protobuf-devel

# download bitcoin source
import base64
import binascii
import hashlib
import hmac
import requests
import scrypt
import binascii
def hex2bin(hex):
return binascii.unhexlify(hex)
git bisect start
# bad: [440b9e2245740af0168cf27c1af6bc681bbe5754] src: node.cc use isolate->ThrowException
git bisect bad 440b9e2245740af0168cf27c1af6bc681bbe5754
# good: [b0e5f195dfce3e2b99f5091373d49f6616682596] src: lint lib/net.js
git bisect good b0e5f195dfce3e2b99f5091373d49f6616682596
# bad: [50cee6ecab869bd406a4a8806906c87a51b0b1b2] util: isObject should always return boolean
git bisect bad 50cee6ecab869bd406a4a8806906c87a51b0b1b2
# bad: [24ba9fdec8c4ba0fd367aef4a3f266f69d8655aa] punycode: update to v1.2.3
git bisect bad 24ba9fdec8c4ba0fd367aef4a3f266f69d8655aa
# bad: [4c1bb832afcb2c084e44f693e72bed2fbc12bfae] v8: reapply floating patches

Verifying myself: I am https://keybase.io/max

As part of this verification process, I am signing this object and posting as a gist as github user maxtaco

{
    "body": {
        "key": {
            "fingerprint": "8efbe2e4dd56b35273634e8f6052b2ad31a6631c",
            "host": "keybase.io",
@maxtaco
maxtaco / gist:7208985
Last active December 26, 2015 20:29
A way to configure remote access for ease of development and resilience to rooted remote clients.

An SSH configuration that protects against rooted remote clients but doesn't repeatedly require you to type a password

One problem we all now realize about the SSH authorized keys system is that from the server administrator's perspective, there's no way to know how the corresponding private keys are kept. Maybe they are unencrypted. Maybe they are guarded with weak passphrases. Maybe they are stored on comprimised machines.

At the same time, developers need remote access, whether they are telecommuting or fixing an emergency bug in the middle of the night. And remote access should not mean typing your password (or an OTP) for every remote shell that's required.

Here is a system that you can hack together to solve these problems in tandem.

Network Setup

# Cryptographic blinding: compute random r,
# r_e <- r^e mod n
# and x <- x*r_e mod n
n = @pub.n
await SRF().random_zn n, defer r
r_inv = r.modInverse(n)
r_e = r.modPow(@pub.e,n)
x_1 = x.multiply(r_e).mod(n)
# calculate xp and xq
@maxtaco
maxtaco / gist:5609503
Last active December 17, 2015 12:28
A library that simplifies short-circuiting errors in IcedCoffeeScript. Works with ICS 1.6.2c+. Thanks to @ashtuchkin.
# This is a pretty generic short-circuiter class that makes it
# convenient to error out of an iced function on the first error
# to occur.
#
# It assumes that every callback is of the form (err, otherstuff...)
# More general classes are possible using the same technique though.
#
class ErrorShortCircuiter
constructor : (@cb) ->
@maxtaco
maxtaco / gist:5208839
Last active December 15, 2015 05:29
Notes on a new EC2 server with an Amazon AMI

Notes on Setting up a New EC2 Node

sudo yum --enablerepo=epel install fail2ban
  • Some standard yum packages to install:
    • gcc
  • gcc-c++
@maxtaco
maxtaco / gist:5207740
Last active December 15, 2015 05:19
A simple DB backup script that keeps weeklies, monthlies, and yearlies, and ages.
#!/bin/sh
#
# A very simple database backup and rotation script, in four stages:
#
# 1. dump
# 2. compress
# 3. link
# 4. age
#