Skip to content

Instantly share code, notes, and snippets.

@thinkjson
thinkjson / static.js
Created May 11, 2011 15:54
Static file server in Node.js
var express = require('express');
var app = express.createServer();
app.use(express.static(__dirname));
app.listen(parseInt(process.ARGV[2], 10) || 8080);
"""
Copyright (c) 2010 Mark Cahill
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
@thinkjson
thinkjson / i18n.js
Created August 5, 2011 11:56
Patched i18n class for Saiku 2.1
/* Saiku UI -- a user interface for the Saiku Server
Copyright (C) Paul Stoellberger, 2011.
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 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@thinkjson
thinkjson / gist:1177537
Created August 29, 2011 01:25 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
Day job:
Python programmer, data analyst, and DBA at Stetson University
Favorite Python project:
Django, because I'm a perfectionist that's always on a deadline
Favorite Conference:
TED, because being an inventor runs in the family
Python Experience Level:
var ReportDesigner = Backbone.View.extend({
initialize: function(args) {
this.workspace = args.workspace;
// Create a unique ID for use as the CSS selector
this.id = _.uniqueId("report_");
$(this.el).attr({ id: this.id });
this.add_button();
@thinkjson
thinkjson / look_busy.sh
Last active September 2, 2024 18:56
Look busy
#!/bin/bash
while [ -1 ]
do
cat /dev/urandom -b 10 | od | grep --color=always $(date +%H%M%S)
sleep .3
done
@thinkjson
thinkjson / junk
Created September 28, 2011 15:38
Generate sample data
DELIMITER $$
CREATE
PROCEDURE junk()
BEGIN
LOOP
INSERT INTO repo_user VALUES(NULL, 'Mark', 'Cahill', ROUND(RAND()*999999), ROUND(2+RAND()*2,2));
END LOOP;
END$$
@thinkjson
thinkjson / matrix.c
Created October 6, 2011 02:27
Matrix multiplication with fork() and IPC
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <string.h>
#define BASEPID 9000
#define MAX_SIZE 1000
@thinkjson
thinkjson / csv.js
Created October 20, 2011 16:14
WriteableStream loses writes
var fs = require('fs');
exports = module.exports = function(config) {
/**
* Rotate the log
*/
this.rotateLog = function() {
var timestamp = Math.floor((new Date()).getTime() / 1000);
self.oldLogfile = this.logfile;
self.oldLog = self.log;
self.logfile = self.config.buffer + self.config.input + timestamp + ".csv";
@thinkjson
thinkjson / gist:1351846
Created November 9, 2011 15:46
Chocolate peanut butter smoothie
4 tbsp. dark cocoa powder
2 tsp. honey
1/4 cup peanut butter
1 cup milk
1 cup plain greek yogurt
1/4 cup frozen blueberries
2 cups ice cubes
1 cup kale greens
1 cup spinach