Skip to content

Instantly share code, notes, and snippets.

View mindscratch's full-sized avatar

Craig Wickesser mindscratch

View GitHub Profile
// see build.gradle for imports
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.util.StatusPrinter;
...
public abstract class Utilities {
public static final Logger logger = LoggerFactory.getLogger( "AnyUniqueStringHere" );
...
public static void printLoggerState() {
@jasonroelofs
jasonroelofs / Timings.txt
Created November 29, 2012 18:23
Using Go for embarrassingly parallel scripts
] wc -l domains.txt
783 domains.txt
] time go run domain_lookup_parallel.go
real 0m5.743s
user 0m0.359s
sys 0m0.355s
] time go run domain_lookup_sequential.go
@ryandotsmith
ryandotsmith / mem-lower-bound.md
Created November 27, 2012 16:06
Memory Lower Bound: Go vs. C

Have you ever wondered about the least amount of memory a C or Go program will use on a 64bit Linux machine? Kr & I have, here is the results of our curiosity:

A simple C program:

void
main()
{
  for (;;) {
 }
$VERBOSE = nil
require File.expand_path('../rooby', __FILE__)
Person = Rooby::Class.new 'Person' do
define :initialize do |name|
@name = name
end
define :name do
@thomseddon
thomseddon / gist:3511330
Last active September 8, 2025 14:36
AngularJS byte format filter
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
}
});
module Settings
def self.included(source)
source.class_eval do
def self.setting(*args)
args.each do |setting|
attr_accessor setting
define_method "#{setting}_on" do
self.send("#{setting}=", true)
end
@trek
trek / unit.js
Created July 22, 2012 02:40
Run your mocha unit tests suite via casper.js
// get a Casper object.
// See http://casperjs.org/
var casper = require('casper').create();
// this will be evaluated inside the context of the window.
// See http://casperjs.org/api.html#casper.evaluate for notes on
// the difference between casper's running environment and the
// DOM environment of the loaded page.
function testReporter(){
// casper is webkit, so we have good DOM methods. You're
@ryin
ryin / tmux_local_install.sh
Last active May 27, 2025 08:36
bash script for installing tmux without root access
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=1.8
@lgs
lgs / gist:3068455
Created July 7, 2012 22:50 — forked from adamlwatson/gist:1371577
Mongoid connection pooling in Goliath
require 'em-synchrony/em-mongo'
require 'mongoid'
mongoid_conn = Mongo::Connection.new 'localhost', 27017, :pool_size => 10
Mongoid.configure do |config|
begin
config.master = mongoid_conn.db('dbname')
rescue Exception=>err
abort "An error occurred while creating the mongoid connection pool: #{err}"
end
@billyvg
billyvg / gist:2932337
Created June 14, 2012 19:20
Backbone.js ListView + RowView
class ListView extends Backbone.View
constructor: (options) ->
super
@view = options.view if options.view?
@collection.on 'add', @addRow, @
@collection.on 'remove', @removeRow, @
@collection.on 'reset', @render, @
@