This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var logfmt = require('./logfmt'); | |
myTimelyFunction = function() { | |
logfmt.log({ "foo": "bar", "a": 14, baz: 'hello kitty'}) | |
} | |
logfmt.time(function(done){ | |
myTimelyFunction(); | |
done('timely_function'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var logfmt = require('./logfmt'); | |
myTimelyFunction = function(done) { | |
logfmt.log({ "foo": "bar", "a": 14, baz: 'hello kitty'}) | |
done('timely_function'); | |
} | |
logfmt.time(myTimelyFunction); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |