Skip to content

Instantly share code, notes, and snippets.

Avatar
🐛
squashin bugs.

nick comer nkcmr

🐛
squashin bugs.
View GitHub Profile
@nkcmr
nkcmr / proposal.md
Last active Jul 17, 2019
Informal Golang Proposal: `catch` block as an alternative to `if err != nil`
View proposal.md

Informal Golang Proposal: catch block as an alternative to if err != nil

PLEASE NOTE: I am not a language designer or have any experience in implementing or mainting a language or compiler. So, I would love to write out the EBNF syntax for what I am about to propose, but alas, I wouldn't know where to start. So, please forgive the informal nature of the proposal and feel free to ask questions; hopefully I'll be able to keep up with actual experts in this field and if not I apologize for my naivety in advance!

When the try() proposal was closed, I was relieved. There is a problem to be solved here, but try, to me at least, created more problems while trying to solve one.

The main problems, I think it created were the following:

  • try reduced the visiblility of failures. For example:
@nkcmr
nkcmr / torrent_file_processing.js
Created Oct 10, 2013
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 ;-;
View torrent_file_processing.js
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;
View 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")"
View bindata-pack.go
package main
import (
"fmt"
"io/ioutil"
"math"
"os"
"strconv"
"strings"
"text/template"
View 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 BBCA B79B BD4A 436E DA81 E4CF DD79 7F0B 1769 BCA1

To claim this, I am signing this object:

@nkcmr
nkcmr / authr-rule.json
Last active May 11, 2018
JSON schema for authr rules as of authr-v1.1.1
View authr-rule.json
{
"type": "object",
"additionalProperties": false,
"required": [
"access",
"where"
],
"properties": {
"access": {
"type": "string",
View 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:

View ejson.php
<?php
date_default_timezone_set('UTC');
$foo = '{"bar":{"$date":1358205756553},"pop":{"goes":{"err":{"$binary":"c3VyZS4="},"the":{"weasel":{"$date":1358205756553,"$tz":"America/New_York"}}}}}';
class EJSON {
protected static $customTypes = [];
public static function type($marker, $decoder) {
if (!is_callable($decoder)) {
@nkcmr
nkcmr / main.go
Created Jun 11, 2017
a concurrent network diagnostic tool of sorts
View main.go
package main
import (
// "io/ioutil"
"bytes"
"encoding/json"
"fmt"
"io"
"os"
"os/exec"
@nkcmr
nkcmr / README.md
Last active Apr 23, 2017
simple deluge complete scope that uploads stuff to google drive
View README.md

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