Skip to content

Instantly share code, notes, and snippets.

View dtjm's full-sized avatar

Sam Nguyen dtjm

  • Twilio SendGrid
  • Pacific Northwest
View GitHub Profile
@dtjm
dtjm / sig.go
Created March 24, 2014 21:56
A program that prints out what signal was caught
package main
import (
"flag"
"io"
"log"
"os"
"os/signal"
"syscall"
)
@dtjm
dtjm / cache.go
Created July 30, 2014 22:55
Go in-memory cache
package cache
import (
"errors"
"math"
"sync"
"time"
)
type ByteCacher interface {
@dtjm
dtjm / expvar.go
Last active August 29, 2015 14:06
Debugging Go Programs - view using https://godoc.org/code.google.com/p/go.tools/present
package main
import (
"expvar"
"io"
"io/ioutil"
"log"
"net/http"
_ "net/http/pprof"
"os"
import Network.Socket
import System.IO
import Control.Monad
import Control.Monad.Fix (fix)
import Control.Concurrent
import Debug.Trace
import System.Log.Logger
import System.Log.Handler.Syslog
import System.Log.Handler.Simple
import Data.Conduit
@dtjm
dtjm / writeroom-wrapper-googlecl.sh
Created July 10, 2010 06:55
A command-line wrapper you can use to call WriteRoom from GoogleCL
#!/bin/bash -x
# WriteRoom command-line launcher by Sam Nguyen
# Made to be used with googlecl docs
# Works with svn rev 341 of googlecl
#
# usage:
# google docs edit --title "My title" --editor /path/to/writeroom-wrapper-googlecl.sh
########################################
# * * * * * command to be executed
# - - - - -
# | | | | |
# | | | | +- - - - day of week (0 - 6) (Sunday=0)
# | | | +- - - - - month (1 - 12)
# | | +- - - - - - day of month (1 - 31)
# | +- - - - - - - hour (0 - 23)
# +- - - - - - - - minute (0 - 59)
@dtjm
dtjm / file-dialog-filters.diff
Created July 26, 2010 22:58
A script to install qcachegrind (the QT version of KCacheGrind) from the source tree at the KDE project. It will also install QT from homebrew with the required dependencies (which takes about 2 hours).
Index: qcachegrind/qcgtoplevel.cpp
===================================================================
--- qcachegrind/qcgtoplevel.cpp (revision 1155013)
+++ qcachegrind/qcgtoplevel.cpp (working copy)
@@ -792,7 +792,7 @@
file = QFileDialog::getOpenFileName(this,
tr("Open Callgrind Data"),
_lastFile,
- tr("Callgrind Files (callgrind.*)"));
+ tr("Cachegrind Files (*cachegrind.*);;Callgrind Files (*callgrind.*);;All Files (*)"));
### diff -ur daemontools-0.76.old/src/error.h daemontools-0.76/src/error.h
### via http://www.qmail.org/moni.csi.hu/pub/glibc-2.3.1/daemontools-0.76.errno.patch
### and http://whomwah.com/2008/11/04/installing-daemontools-on-centos5-x86_64/
--- daemontools-0.76.old/src/error.h 2001-07-12 11:49:49.000000000 -0500
+++ daemontools-0.76/src/error.h 2003-01-09 21:52:01.000000000 -0600
@@ -3,7 +3,7 @@
#ifndef ERROR_H
#define ERROR_H
-extern int errno;
@dtjm
dtjm / install-daemonize.sh
Created August 4, 2010 23:32
A script that will download, compile, and install daemonize. Works on Centos 5.4
#!/bin/bash
DIR=daemonize-src
[ -d $DIR ] || mkdir $DIR
cd $DIR
curl -L http://github.com/bmc/daemonize/tarball/release-1.6 | tar zxv
cd bmc-daemonize-*
./configure
make
sudo make install
@dtjm
dtjm / helpers.php
Created August 6, 2010 16:30
Helper functions for doing terminal output
<?php
function message($text) {
printf('%-48s: ', $text);
}
function succeed($text = ' OK ') {
$esc = chr(27);
echo "[{$esc}[0;33m$text{$esc}[0m$esc" . "\]\n";
}