Skip to content

Instantly share code, notes, and snippets.

View nkcmr's full-sized avatar

nick comer nkcmr

View GitHub Profile
@nkcmr
nkcmr / bmrk.php
Created August 10, 2016 13:06
poor man's php benchmark
<?php
define("BENCH_ITERATIONS", 1000);
$scenarios = [];
// scenario one
$scenarios['one'] = function () {
$start = microtime(true);
// do stuff in between the microtimes
return microtime(true) - $start;
@nkcmr
nkcmr / ad-tracker-block.js
Last active August 10, 2016 20:27
ad/tracker blocker that works at a system level
'use strict'
const blacklist = [
/analytics/,
/fullstory/,
/amplitude/,
/crashlytics\.com/,
/doubleclick\.net/,
/chartbeat\.(net|com)/,
/deepintent\.com/,
@nkcmr
nkcmr / README.md
Last active April 23, 2017 10:18
simple deluge complete scope that uploads stuff to google drive

deluge to google drive uploader

simple uploader script for deluge, assign this script to be called on torrent complete and it will walk a directory and upload it to your google drive

install dependencies:

npm install googleapis async winston lodash mime twilio
@nkcmr
nkcmr / main.go
Created June 11, 2017 18:37
a concurrent network diagnostic tool of sorts
package main
import (
// "io/ioutil"
"bytes"
"encoding/json"
"fmt"
"io"
"os"
"os/exec"
@nkcmr
nkcmr / keybase.md
Created April 21, 2018 19:38
keybase.md

Keybase proof

I hereby claim:

  • I am nkcmr on github.
  • I am nkcmr (https://keybase.io/nkcmr) on keybase.
  • I have a public key whose fingerprint is 82D8 9697 B0E4 8E64 4E78 259A 1423 50B6 4205 77DE

To claim this, I am signing this object:

@nkcmr
nkcmr / authr-rule.json
Last active May 11, 2018 19:32
JSON schema for authr rules as of authr-v1.1.1
{
"type": "object",
"additionalProperties": false,
"required": [
"access",
"where"
],
"properties": {
"access": {
"type": "string",

Keybase proof

I hereby claim:

  • I am nkcmr on github.
  • I am nkcmr (https://keybase.io/nkcmr) on keybase.
  • I have a public key whose fingerprint is BBCA B79B BD4A 436E DA81 E4CF DD79 7F0B 1769 BCA1

To claim this, I am signing this object:

package main
import (
"fmt"
"io/ioutil"
"math"
"os"
"strconv"
"strings"
"text/template"
@nkcmr
nkcmr / goto.sh
Last active March 6, 2019 15:54
goto.sh
#!/bin/bash
goto() {
# create the shortcuts dir if necessary
if [ ! -d "$HOME/.shortcuts" ] ; then
mkdir -p "$HOME/.shortcuts"
fi
if [[ "$1" == "--list" ]] ; then
for f in "$HOME/.shortcuts/"* ; do
echo "$(basename "$f") -> $(tr -d '\n' < "$f")"
@nkcmr
nkcmr / torrent_file_processing.js
Created October 10, 2013 12:55
It took 2 days for me to figure out how to process torrent files in JavaScript. So I am publishing my findings. Fully commented and helpful links are dropped in. I hope if you find this it saves you a few hours of hair-pulling and cursing at your screen. Spoiler alert: If you don't know a whole lot about encodings, you're gonna have a bad time ;-;
var debug = require("debug")("torrent:read"); //npm install debug
var bencode = require("bencode"); //npm install bencode - https://en.wikipedia.org/wiki/Bencode
var fs = require("fs");
var crypto = require("crypto");
var _ = require("underscore"); //npm install underscore
var percent_encoding = {
encode: function(buffer) {
var ret = "", a2z, AtoZ, zero2nine, other_valid_symbols, all_unreserved_symbols;