Skip to content

Instantly share code, notes, and snippets.

@bmatheny
bmatheny / gist:3722111
Created September 14, 2012 14:10
Cheatsheet

zsh

  • !$ - Last argument of previous command

iterm2

  • CMD-shift-H - Paste history
  • CMD-; - Start typing word, will use history and show top 20 choices

Vim

@bmatheny
bmatheny / gist:2785402
Created May 25, 2012 02:18
Sample Heapster Config
#!/bin/sh
#
# foo init.d script.
#
# All java services require the same directory structure:
# /usr/local/$APP_NAME
# /var/log/$APP_NAME
# /var/run/$APP_NAME
APP_NAME="foo"
@bmatheny
bmatheny / mysqlpool.scala
Created March 30, 2012 02:07 — forked from tsuna/mysqlpool.scala
MySQL JDBC connection pool for Scala + Finagle
// Copyright (C) 2012 Benoit Sigoure
// Copyright (C) 2012 StumbleUpon, Inc.
// This library is free software: you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 2.1 of the License, or (at your
// option) any later version. This program is distributed in the hope that it
// will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
// General Public License for more details. You should have received a copy
// of the GNU Lesser General Public License along with this program. If not,
@bmatheny
bmatheny / gist:1562136
Created January 4, 2012 21:05
.ssh/config for multiplexed connections
Host *
ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r
@bmatheny
bmatheny / gist:1186011
Created September 1, 2011 11:43
Memcache Codec with Quit Support
import com.twitter.finagle.{Codec, Service}
import com.twitter.finagle.memcached.protocol.{Command, Response, Quit => MemcacheQuit, NoOp}
import com.twitter.finagle.memcached.protocol.text.{Encoder, Memcached, ResponseToEncoding}
import com.twitter.finagle.memcached.protocol.text.server.{Decoder => ServerDecoder, DecodingToCommand}
import com.twitter.logging.Logger
import com.twitter.util.Future
import org.jboss.netty.buffer.{ChannelBuffer, ChannelBuffers}
import org.jboss.netty.channel._
import org.jboss.netty.util.CharsetUtil
@bmatheny
bmatheny / gist:988962
Created May 24, 2011 15:50
hiredis assertion fails with no callbacks
int main (int argc, char **argv) {
int i = 0;
signal(SIGPIPE, SIG_IGN);
struct event_base *base = event_base_new();
redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379);
redisAsyncContext *c2 = redisAsyncConnect("127.0.0.1", 6379);
if (c->err) {
/* Let *c leak for now... */
@bmatheny
bmatheny / gist:983162
Created May 20, 2011 15:29
hiredis weirdness
static void
redis_connect_cb(const struct redisAsyncContext *c) {
struct node *n = c->data;
if ( !n || c->err ) {
ERROR_OUT("Node is null or error is %s\n", c->errstr);
return;
} else if ( !(c->c.flags & REDIS_CONNECTED) ) {
DEBUG_OUT("Not connected\n");
return;
} else {