Skip to content

Instantly share code, notes, and snippets.

View dimfeld's full-sized avatar

Daniel Imfeld dimfeld

View GitHub Profile
@dimfeld
dimfeld / ssh-with-mouse-fix
Last active February 6, 2018 01:57
run ssh and then disable mouse reporting
#!/bin/bash
# Run ssh and then disable mouse reporting. This is so that mouse scrolling
# will work properly in the local session if a tmux session drops.
/usr/bin/ssh "$@"
EXITCODE=$?
if tty -s; then
printf '\e[?1000l'
fi
@dimfeld
dimfeld / capnp-build.rs
Last active January 10, 2018 02:33
A build.rs script that filters out directives for building capnp files with non-Rust targets.
/*
Go's Cap'n Proto code generator needs some extra directives, but I don't want to require that
my Rust build environment has the relevant Go include files available. The script below filters
out the Go directives before sending the resulting files to the compiler to make this work.
*/
extern crate capnpc;
use std::env;
use std::path::PathBuf;
@dimfeld
dimfeld / jsonize.js
Created March 23, 2016 15:15
Convert JS-style objects into proper JSON
#!/usr/bin/env node
"use strict";
var fs = require("fs");
var vm = require("vm");
var sandbox = { value: null };
var context = vm.createContext(sandbox);
function convert(contents) {
vm.runInContext('value = ' + contents, context);
// DO NOT EDIT!
// Code generated by ffjson <https://github.com/pquerna/ffjson>
// DO NOT EDIT!
package main
import (
importedinceptionpackage "bitbucket.org/freshmedicalleads/datafuse/writer"
"bitbucket.org/freshmedicalleads/datafuse/vendor/github.com/pquerna/ffjson/inception"
// "github.com/pquerna/ffjson/inception"
@dimfeld
dimfeld / DirectOutputCommitter.scala
Created September 24, 2015 20:37 — forked from aarondav/DirectOutputCommitter.scala
DirectOutputCommitter.scala
/*
* Copyright 2015 Databricks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software

Keybase proof

I hereby claim:

  • I am dimfeld on github.
  • I am dimfeld (https://keybase.io/dimfeld) on keybase.
  • I have a public key whose fingerprint is 2814 2D19 F06B 2C7D 752B F055 4CC5 2454 DC43 1235

To claim this, I am signing this object:

@dimfeld
dimfeld / lip.py
Last active August 29, 2015 14:24
Linode IP Lookup
#!/usr/bin/python
import sys
import os
import os.path
import argparse
import json
import linode.api
key = None
set -g base-index 1
set -s escape-time 0
# Window Switching
bind-key -n C-NPage next
bind-key -n C-PPage prev
bind-key -n C-M-NPage swap-window -t +1
bind-key -n C-M-PPage swap-window -t -1
bind-key n next
#!/usr/bin/env node
"use strict";
var es = require('event-stream');
var Promise = require("bluebird");
var pg = Promise.promisifyAll(require("pg.js"));
var pt = require("stream").PassThrough;
var copyStream = require("pg-copy-streams").from;
var _ = require("lodash");
@dimfeld
dimfeld / setgopath.sh
Last active August 29, 2015 14:01
Bash function to easily set the GOPATH from any subdirectory thereof.
# Embed this function inside your .bashrc or equivalent.
function setgopath() {
# Assume we're in the src directory, and strip off src and everything after it.
DIR=${PWD/src*/}
if [ -d "$DIR/src" -a -d "$DIR/bin" -a -d "$DIR/pkg" ]; then
export GOPATH=$DIR
fi
}