Skip to content

Instantly share code, notes, and snippets.

@asmuth
asmuth / fibonacci_find.c
Created April 2, 2012 20:12
smallest fibonacci sequence longer than 10 chars...
#include <stdio.h>
#include <string.h>
#define MIN_CHARS 10
int main(char *argv, int argc){
int i, m = 10, f[3] = {0,1};
for(i = MIN_CHARS; i > 2; i--){
m *= 10;
@asmuth
asmuth / JSONRenderer.scala
Created April 25, 2012 21:18
simple (uber-hacky) json renderer in 40 lines of scala
import scala.collection.immutable.Map
/*
simple (uber-hacky) json renderer in 40 lines of scala
http://github.com/paulasmuth
usage:
JSONRenderer.render(Map(
"a_string" -> "fnord",
@asmuth
asmuth / CSVReader.scala
Created May 7, 2012 01:18
csv reader :)
package com.dawanda.recommender
import scala.collection.JavaConverters._
import scala.collection.mutable.Buffer
import scala.io._
import java.util.concurrent._
class CSVReader[T <: Any](next: (Map[Symbol, Int] => T)){
def read(file_path: String) : Buffer[T] = {
@asmuth
asmuth / server_monitor.sh
Last active December 12, 2015 03:28
Linux Server Health Monitor (Fyrehose/FnordMetric)
#!/bin/bash
# This scripts sends a JSON message containing system health
# information to a fyrehose channel.
#
# Usage:
# $ ./linux_health_monitor.sh [host] [port] [channel]
# e.g.
# $ ./linux_health_monitor.sh localhost 2323 my_channel
#
// FnordMetric Enterprise
// (c) 2011-2013 Paul Asmuth <[email protected]>
//
// Licensed under the MIT License (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of
// the License at: http://opensource.org/licenses/MIT
package com.fnordmetric.enterprise
import scala.collection.mutable.ListBuffer
@asmuth
asmuth / loveos_render.c
Last active December 16, 2015 17:19
product listview rendering in c (WIP)
// This file is part of the "LoveOS" project
// (c) 2013 DaWanda GmbH, Paul Asmuth <[email protected]>, et al.
// All rights reserved.
#include "plv.h"
#include "ruby.h"
VALUE loveos_render = Qnil;
// glue code to call the plv_load_json + plv_render methods from ruby
@asmuth
asmuth / fnord.asm
Last active February 6, 2017 03:22
print (hexa-)decimal numbers in pure x86 assembler (using the OSX/mach system call convention)
; compile & run on OSX
; $ nasm -f macho -o /tmp/fnord.o fnord.asm
; $ ld -o /tmp/fnord /tmp/fnord.o
; $ /tmp/fnord
section .data
section .text
global start
start:
/*
* This file is part of the "plgl" project
* (c) 2014 Paul Asmuth <[email protected]>
*
* 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()