Skip to content

Instantly share code, notes, and snippets.

/*
* This file is part of the "plgl" project
* (c) 2014 Paul Asmuth <paul@paulasmuth.com>
*
* All rights reserved. Please contact me to obtain a license.
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <plgl/engine.h>
@asmuth
asmuth / statsd_bridge.rb
Created November 10, 2014 14:59
statsd fork/bridge (forward statsd data to multiple hosts)
#!/usr/bin/env ruby
require "socket"
udp = UDPSocket.new
udp.bind('0.0.0.0', 8125)
targets = [
["localhost", 8125],
["other.host.net", 8125]
]
@asmuth
asmuth / CMakeLists.txt
Created December 22, 2014 11:58
most simple CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(blahblah)
set(PROJ_SOURCES
src/a.cc
src/b.cc)
if(APPLE)
set(CMAKE_CXX_FLAGS "-std=c++0x -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
else()
@asmuth
asmuth / gist:1064005
Created July 4, 2011 22:10
json<->marshal loading in ruby1.8<->ruby1.9
require 'json'
MY_JSON_FILE = File.open('big_json.json').read
MY_MARSHAL_FILE = File.open('big_json.dat').read
class FileLoader
def load_via_json
JSON.parse(MY_JSON_FILE)
end
@asmuth
asmuth / gist:1285498
Created October 13, 2011 20:54
if you're happy and you know it (ruby --debug)
puts "if you're happy and you know it, NoMethodError"
(nil.fnord rescue nil)
@asmuth
asmuth / gist:1373907
Created November 17, 2011 17:55
mongoid-bug?
require 'rubygems'
require 'rspec'
require 'mongoid'
describe "is this a bug?" do
Mongoid.configure do |config|
config.master = Mongo::Connection.new('localhost','27017').db('mongotest')
end
@asmuth
asmuth / gist:1557137
Created January 3, 2012 21:54
FnordMetric: setting user picture/name and unique gauges
# i hope this helps...
# to set the username and picture send these events to fm
# -> you don't need to define any event handlers
# -> the session token (_session) could be your unique session id
# or the unique user id (it's hashed)
# set the user name
{ "_type": "_set_name", "name": "Tingle Tangle Bob", "_session": "mysessiontoken" }
@asmuth
asmuth / node.rb
Created February 13, 2012 21:20
bp ultrasimple social graph (wip)
# the "abstract" node
class BPGraph::Node
# initialize an instance with id of the correct subclass from a node_key
def self.load(node_key)
end
def initialize(node_id)
@node_class ||= :node
@asmuth
asmuth / gist:1852251
Created February 17, 2012 09:47
[ruby/rake] deploy with foreman/deamonize (w/o capistrano)
namespace :tlnt do
desc "deploy to staging environment"
task :deploy_staging => :environment do
deploy_to_environment(:staging)
end
desc "restart staging environment"
task :restart_staging => :environment do
restart_environment(:staging)
@asmuth
asmuth / squirrelclock.c
Created February 17, 2012 22:45
squirrelclock! :)
#include <stdio.h>
#include <time.h>
void clearscreen(){
fputs("\033[H\033[2J", stdout);
}
int main(int argc, char* argv[]){
char *frame01 =