Skip to content

Instantly share code, notes, and snippets.

💭
¯\_(ツ)_/¯

Marc Falzon falzm

💭
¯\_(ツ)_/¯
Block or report user

Report or block falzm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@falzm
falzm / ncsa_stats.awk
Created Jul 30, 2013
A poor man's NCSA log analyzer written in (G)AWK
View ncsa_stats.awk
# My first GAWK script
{
total_bytes += $10
}
$9 ~ /2[0-9]+/ {
n_sc_2xx++
}
@falzm
falzm / gist:6433872
Created Sep 4, 2013
Colorized manpages with less
View gist:6433872
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
View amqp_consumer.go
package main
import (
"github.com/streadway/amqp"
"log"
"os"
"os/signal"
"runtime"
"syscall"
"time"
@falzm
falzm / sorted_json.rb
Last active Nov 22, 2016 — forked from halkeye/sorted_json.rb
Puppet parser function for outputting JSON-formatted objects, in a sorted consistent way.
View sorted_json.rb
require 'json'
def sorted_json(obj)
case obj
when String, Fixnum, Float, TrueClass, FalseClass, NilClass
return obj.to_json
when Array
arrayRet = []
obj.each do |a|
arrayRet.push(sorted_json(a))
@falzm
falzm / aphyr_clojure_seq.clj
Last active Aug 29, 2015
Some Clojure exercise
View aphyr_clojure_seq.clj
;;; Solutions to http://aphyr.com/posts/304-clojure-from-the-ground-up-sequences problems
; 1. Write a function to find out if a string is a palindrome–that is, if it looks the same forwards and backwards.
(defn palindrome?
"Find out if the string is a palindrome"
[s]
(=
s
(apply str (reverse s))))
View collectd.clj
; Expire old events from the index every 5 seconds.
(periodically-expire 600)
(def graph (graphite {:host "127.0.0.1"}))
; Keep events in the index for 5 minutes by default.
(let [index (default :ttl 300 (update-index (index)))]
; Inbound events will be passed to these streams:
(streams
@falzm
falzm / gist:259aa4a303ec63e77efc
Created Jul 13, 2014
Testing standalone "_getPercentile()" Graphite function
View gist:259aa4a303ec63e77efc
#!/usr/bin/env python
# From https://github.com/graphite-project/graphite-web/blob/master/webapp/graphite/render/functions.py
import math
stats = [43.0, 54.0, 56.0, 61.0, 62.0, 66.0, 68.0, 69.0, 69.0, 70.0, 71.0,
72.0, 77.0, 78.0, 79.0, 85.0, 87.0, 88.0, 89.0, 93.0, 95.0, 96.0,
98.0, 99.0, 99.0]
@falzm
falzm / gist:52b3e66c149b9ba6fb58
Created Jul 13, 2014
Go percentile calculation implementation
View gist:52b3e66c149b9ba6fb58
package main
import (
"fmt"
"math"
"sort"
)
var s = []float64{
43.0, 54.0, 56.0, 61.0, 62.0, 66.0, 68.0, 69.0, 69.0, 70.0, 71.0,
@falzm
falzm / gist:b52c5ca32602e0779a2d
Created Jul 13, 2014
Go percentile calculation implementation from go-metrics
View gist:b52c5ca32602e0779a2d
// From https://github.com/rcrowley/go-metrics/blob/master/sample.go
package main
import (
"fmt"
"math"
"sort"
)
@falzm
falzm / commonlog2json.go
Last active Aug 29, 2015
Quick'n dirty HTTP combined access log JSON formatter
View commonlog2json.go
package main
import (
"bufio"
"fmt"
"os"
"regexp"
)
func main() {
You can’t perform that action at this time.