Skip to content

Instantly share code, notes, and snippets.

@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 {
@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: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:1562136
Created January 4, 2012 21:05
.ssh/config for multiplexed connections
Host *
ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r
@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: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 / 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 / vim.rb
Created September 23, 2012 16:10 — forked from vesln/vim.rb
Vim Formula with Ruby & Python support for OS X
require 'formula'
class Vim < Formula
homepage 'http://www.vim.org/'
version '7.3.666'
url 'https://vim.googlecode.com/hg/', :revision => '1e22adc6176e'
head 'https://vim.googlecode.com/hg/'
def ruby_bin
@bmatheny
bmatheny / production.conf
Created November 1, 2012 16:38
Bare minimum collins config
include "validations.conf"
collins_conf_dir = "/Users/bmatheny/Downloads/collins/conf"
# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
# If you deploy your application to several instances be sure to use the same
# key!
application.secret="AbFgHx0eJx8lalkja812389uasdlkajsdlka98012398uasdlkasdklajsd81298"
@bmatheny
bmatheny / gist:5060520
Last active December 14, 2015 08:49 — forked from jasoncodes/gist:1223731
# Run this script to install ruby 1.9.2-p290 under rbenv
VERSION=1.9.2-p290
brew update
brew install rbenv ruby-build rbenv-vars readline
if [ -n "${ZSH_VERSION:-}" ]; then
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.zshrc
else
echo 'eval "$(rbenv init - --no-rehash)"' >> ~/.bash_profile
fi