Skip to content

Instantly share code, notes, and snippets.

View olauzon's full-sized avatar

Olivier Lauzon olauzon

View GitHub Profile
@olauzon
olauzon / change_hostname.sh
Created July 29, 2014 15:42
Change hostname on SmartOS machine
# http://wiki.joyent.com/wiki/display/jpc2/Setting+the+Host+Name+for+SmartMachine+Standard
sm-set-hostname mydomain.com
#!/usr/bin/python
import sys, os, re, socket, time
"""ARGF from Ruby in Python.
Released into the public domain by Andrew Gwozdziewycz, 2010
"""
class _ARGF(object):
def __init__(self):

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

@olauzon
olauzon / EchoClient.java
Created April 2, 2014 20:18
Port Netty in Action examples from Java to Clojure
package com.manning.nettyinaction.chapter2;
import java.net.InetSocketAddress;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
@olauzon
olauzon / set-utc.md
Last active August 14, 2016 11:32
Set timezone to UTC in SmartOS

Edit /etc/TIMEZONE

TZ=UTC

Run the following commands

rtc -z UTC
@olauzon
olauzon / jvm_dtrace.sh
Last active August 29, 2015 13:57
Attach DTrace to JVM
dtrace -ln 'hotspot$target:::' -p <pid>
wget http://www.cs.duke.edu/csl/docs/java/sample/dtrace/hotspot/gc_time_stat.d
chmod 755 gc_time_stat.d
./gc_time_stat.d -p <pid> 60
# See http://www.cs.duke.edu/csl/docs/java/sample/dtrace/hotspot/ for more scripts
@olauzon
olauzon / ordered_paths.clj
Last active December 24, 2015 03:09
Ordered paths
(defn ordered-paths
[coll]
(let [len (count coll)
end (dec len)]
(cond
(zero? len) coll
(zero? end) coll
:else
(loop [start 0
curr 1
@olauzon
olauzon / memoize-vs-deref.core.clj
Created August 13, 2013 18:08
Simple Clojure memoize vs deref benchmark
(ns memoize-vs-deref.core
(:use criterium.core))
(def test-vec
[{ :a 1 }
{ :f 6 }
{ :c 3 }
{ :d 4 }
{ :g 7 }
{ :h 8 }
@olauzon
olauzon / counter.cql
Created June 12, 2012 17:35
Cassandra counter example
-- Works with CQL SPEC 3.0.0 and Cassandra 1.1.1
-- Usage: cqlsh -3 < counter.cql
CREATE TABLE counters (
counter_name varchar,
value counter,
PRIMARY KEY (counter_name)
)
WITH comment='Aggregate counters';
@olauzon
olauzon / ruby_wat.rb
Created May 11, 2012 19:40
Ruby WAT
# 1.8.7
[1, 2, 3].to_s
# => "123"
# 1.9.3p194
[1, 2, 3].to_s
# => "[1, 2, 3]" # WAT?
# `Array#to_s` is an alias to `Array#inspect`