Skip to content

Instantly share code, notes, and snippets.

@evnm
evnm / gist:1164076
Created August 23, 2011 01:23
git crunk
[alias]
crunk = checkout -b regrettable-late-night-coding-session
@evnm
evnm / array-sum-example
Created September 24, 2011 05:36
Java vs Scala array sum example
// Java.
int sum = 0;
for (int i = 0; i < arr.length; i++) {
sum += arr[i];
}
System.out.println(sum);
// Scala (ignoring arr.sum).
println(arr reduceLeft { _ + _ })
@evnm
evnm / brew-install-missing-unix-tools
Created October 24, 2011 05:27
A brew command to install useful tools missing from Mac OS X
# Legitimately-useful utilities missing from OS X.
brew install wget watch gnu-sed coreutils
# Up-to-date versions of included tools.
brew install git emacs
# Just for fun.
brew install fortune cowsay
Programming, when stripped of all the circumstantial irrelevancies
is nothing more and nothing less than "very effective thinking
so as to avoid unmastered complexity, to very vigorous
separation of your many different concerns".
-- Edsger Dijkstra
@evnm
evnm / app.js
Created October 30, 2011 23:48
A Node.js daemon for achieving TTL behavior of files within a Dropbox directory
var Log = require('log'),
log = new Log('info'),
DropboxClient = require('dropbox').DropboxClient,
dropbox = new DropboxClient("api_key", "api_secret",
"access_token", "access_token_secret");
/**
* Returns a function that checks the mtime of all files within dir
* and deletes any that are older than ttl.
*/
function checkForAndRmExpiredItems(dir, ttl) {
@evnm
evnm / gist:2127168
Created March 19, 2012 21:18 — forked from marcel/gist:2100703
giftube – Generates an animated gif from a YouTube url.
#!/usr/bin/env ruby
# giftube – Generates an animated gif from a YouTube url.
#
# Usage:
#
# giftube [youtube url] [minute:second] [duration]
#
# ex.
#
@evnm
evnm / gist:5695408
Last active December 18, 2015 00:18
Notes on Steve McConnell's "Managing Technical Debt" keynote presentation at the 2013 International Workshop on Managing Technical Debt

Slides: http://www.sei.cmu.edu/community/td2013/program/upload/TechnicalDebt-ICSE.pdf

Business vs Technical viewpoints

  • Business staff tends to be optimistic about debt
  • Technical staff tends to be pessimistic about debt (religious and aesthetic)
  • These attitudes are often not conscious
  • Debt is a tool, neither inherently good nor bad

Short- vs Long-term debt

  • Short: violating coding standards, "we'll write these unit tests after we ship"
@evnm
evnm / gitm
Last active December 21, 2015 01:28
A Git maintenance script. Prunes remote-tracking branches on origin and performs a deep repack on the repository.
#! /bin/sh
# A Git maintenance script.
set -e
root=`git rev-parse --show-toplevel`
echo "Performing maintenance tasks on Git repository in ${root}..."
git fetch
git remote prune origin
git repack -a -d --depth=250 --window=250
@evnm
evnm / FuturePool'd
Last active August 8, 2018 05:15
Comparing approaches to convert `java.util.concurrent.Future`s to `com.twitter.util.Future`s.
import com.twitter.util.{Future => TwitterFuture, FuturePool}
import java.util.concurrent.{Future => JavaFuture}
/**
* Convert a Java Future to a Twitter Future.
*/
def javaFutureToTwitterFuture[A](javaFuture: JavaFuture[A]): TwitterFuture[A] =
FuturePool.unboundedPool { javaFuture.get }
@evnm
evnm / test_changed
Last active December 28, 2015 11:19
A Ruby script that runs tests with Pants for all projects that have been modified in the current working tree.
#!/usr/bin/env ruby
#
# Run tests for all projects that have been modified in the Birdcage,
# relative to HEAD.
#
# For example, if you've edited files in three projects, this script will
# run tests serially for these three projects in one command.
print "Determining which files have been changed..."
$stdout.flush