Skip to content

Instantly share code, notes, and snippets.

View csquared's full-sized avatar

Chris Continanza csquared

  • ex-stripe, ex-coinbase, ex-heroku
  • Brooklyn, NY
View GitHub Profile
var split = require('split');
var logfmt = require('logfmt');
var through = require('through');
var _ = require('underscore');
var list = []
var parseLine = function(line){
if(/INFO/.test(line)) return;
exports.logger = logfmt.requestLogger(
elapsed: "measure#http.#{req.method.toLowerCase()}",
(req, res) ->
ns: "app-state"
source: req.url
status: res.statusCode
from: req.socket && (req.socket.remoteAddress || (req.socket.socket && req.socket.socket.remoteAddress))
"agent": req.headers["user-agent"]
"request_id": req.headers["x-request-id"]
var logfmt = require('./logfmt');
myTimelyFunction = function() {
logfmt.log({ "foo": "bar", "a": 14, baz: 'hello kitty'})
}
logfmt.time(function(done){
myTimelyFunction();
done('timely_function');
});
var logfmt = require('./logfmt');
myTimelyFunction = function(done) {
logfmt.log({ "foo": "bar", "a": 14, baz: 'hello kitty'})
done('timely_function');
}
logfmt.time(myTimelyFunction);
@csquared
csquared / push_pull_broker.c
Created June 10, 2013 17:28
Push-Pull ZMQ Broker to act as a proxy/intermediary between multiple PUSH and PULL sockets.
#include <stdio.h>
#include "zhelpers.h"
int main(void)
{
void *context = zmq_ctx_new();
void *reciever = zmq_socket(context, ZMQ_PULL);
zmq_bind(reciever, "tcp://127.0.0.1:5557");
puts("reciever on tcp://127.0.0.1:5557");
@csquared
csquared / StatusMonitor.ino
Last active April 29, 2019 12:59
Heroku Status Lights Monitor - Arduino Software
/*
Heroku Office Status Monitor
What it is: Arduino + Ethernet Shield
What it does: Networked device that provides status monitoring.
Components:
- Status site monitor
HTTP GET to http://outage-lights.herokuapp.com/status to consume current Heroku Platform status.
@csquared
csquared / test.coffee
Created September 21, 2012 02:05
Simple Coffeescript Bootstrap test with vows and api-easy
APIEasy = require('api-easy')
assert = require('assert')
process.env.NODE_DEBUG = true
process.env.NODE_ENV = 'test'
process.env.PORT = 8080
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL
app = require('../app')
suite = APIEasy.describe("api")
@csquared
csquared / build-psql.sh
Created September 21, 2012 01:14
Anvil Build Recipe for psql 9.2.0
#!/bin/sh
root=$(pwd)
cd $root/postgresql-*
./configure --prefix=/app/vendor --with-openssl
make && make install
rm -rf $root/*
mv /app/vendor/* $root/
# Here's the script I use from my local machine to build the psql binary and libpq
@csquared
csquared / serializes_json.rb
Created February 2, 2012 20:27
Serializes JSON
# serialize :field, Hash
# got you down?
# serializes_json :field
# to the rescue!
class ActiveRecord::Base
def self.serializes_json *args
args.each do |field_name|
eval <<-RUBY
def #{field_name}=(other)
@csquared
csquared / inject_vs_readability.rb
Created December 16, 2011 08:34 — forked from bbwharris/inject_vs_readability.rb
Inject vs. Readability
# inject is cool and elegant. I use it when I want to be cool. However, I tend to robotically begin the procedural
# way and end up at inject when I realize I am in that situation. See this simple example:
include ActionView::Helpers
class Link < Struct.new(:title, :url); end
a = Link.new("Google", "http://www.google.com")
b = Link.new("Hacker News", "http://news.ycombinator.com")
array_of_links = [a, b]