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 / config
Created August 13, 2010 17:34
Wrapper to use OS X FileMerge when calling `svn diff`
### ~/.subversion/config
### Add this line to the [helpers] section
diff-cmd = ~/bin/svn-diffwrap.sh
@dtjm
dtjm / join_test.go
Last active November 26, 2023 13:18
Benchmarking various ways of concatenating strings in Go
package join
import (
"fmt"
"strings"
"testing"
)
var (
testData = []string{"a", "b", "c", "d", "e"}
::: {mbWgjAZ}{mbWgjAZxSNaAW_l9X8fNlg}{p2C53LZTT4qTYWW1XQIunw}{x.x.x.x}{x.x.x.x:9300}{zone=us-west-2a, distributed_snapshot_deletion_enabled=true}
Hot threads at 2023-09-29T20:45:22.684, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:
50.5% (252.5ms out of 500ms) cpu usage by thread 'elasticsearch[mbWgjAZ][[2023092902][9]: Lucene Merge Thread #444]'
2/10 snapshots sharing following 14 elements
app//org.apache.lucene.index.MultiTermsEnum.postings(MultiTermsEnum.java:361)
app//org.apache.lucene.index.MappedMultiFields$MappedMultiTermsEnum.postings(MappedMultiFields.java:127)
app//org.apache.lucene.codecs.PushPostingsWriterBase.writeTerm(PushPostingsWriterBase.java:122)
app//org.apache.lucene.codecs.blocktree.BlockTreeTermsWriter$TermsWriter.write(BlockTreeTermsWriter.java:864)
app//org.apache.lucene.codecs.blocktree.BlockTreeTermsWriter.write(BlockTreeTermsWriter.java:343)
#!/usr/bin/env bash
set -euo pipefail
echo "-- installing homebrew"
if ! type "brew" > /dev/null; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi
if [[ ! -x /opt/homebrew/bin/zsh ]]; then
@dtjm
dtjm / monitrc.vim
Created August 6, 2010 17:38
Vim syntax file for Monit configuration files
" Vim syntax file
" Language: Monit control file
" Maintainer: Sam Nguyen
" Latest Revision: 6 August 2010
if exists("b:current_syntax")
finish
endif
syn keyword monitCommand set check include
@dtjm
dtjm / gcd.go
Last active March 28, 2023 05:11
Binary GCD for Golang
package gcd
// GCD binary algorithm, derived from
// https://en.wikipedia.org/wiki/Binary_GCD_algorithm#Iterative_version_in_C
func GCD(u, v uint64) uint64 {
var shift uint
/* GCD(0,v) == v; GCD(u,0) == u, GCD(0,0) == 0 */
if u == 0 {
return v
@dtjm
dtjm / vsftpd.init
Created August 4, 2010 22:12
A patched init script for vsftpd that will create PID files under /var/run/vsftpd. If you have a configuration file /etc/vsftpd/vsftpd-foo.conf, it will create the PID file /var/run/vsftpd/vsftpd-foo.pid
#!/bin/bash
#
# vsftpd This shell script takes care of starting and stopping
# standalone vsftpd. Customized to be used with CentOS 5.4
# and Monit by creating PID files for each process
#
# chkconfig: - 60 50
# description: Vsftpd is a ftp daemon, which is the program \
# that answers incoming ftp service requests.
# processname: vsftpd
@dtjm
dtjm / haml_converter.rb
Created August 10, 2010 16:34
HAML plugin for jekyll
# _plugins/haml_converter.rb
module Jekyll
class HamlConverter < Converter
safe true
def setup
return if @setup
require 'haml'
@setup = true
@dtjm
dtjm / datatables.set_filter_debounce.js
Created June 23, 2011 22:14
Search filter debounce for Allan Jardine's DataTables plugin for jQuery. Requires Underscore.js
jQuery.fn.dataTableExt.oApi.fnSetFilterDebounce = function ( oSettings, iDelay ) {
/*
* Type: Plugin for DataTables (www.datatables.net) JQuery plugin.
* Name: dataTableExt.oApi.fnSetFilterDebounce
* Version: 0.01
* Description: Enables filtration debouncing which prevents filter from
* happening until keypresses have stopped for [iDelay] milliseconds.
* Uses code from Zygimantas' fnSetFilteringDelay
* Inputs: object:oSettings - dataTables settings object
@dtjm
dtjm / subversion-prompt.sh
Created August 19, 2010 18:13
Subversion PS1 prompt functions for bash
#
# If you want to see svn modifications:
# export SVN_SHOWDIRTYSTATE=1
#
# Put this in your PS1 like this:
# PS1='\u@\h:\W\[\033[01;33m\]$(__git_svn_ps1)\[\033[00m\]$ '
# Git/Subversion prompt function
__git_svn_ps1() {