Skip to content

Instantly share code, notes, and snippets.

View pimeys's full-sized avatar

Julius de Bruijn pimeys

View GitHub Profile
td.message {
background-color: #000000;
color: #dedede;
}
td.date {
background-color: #000000;
}
tr.dateChange td {
@pimeys
pimeys / fold_excersizes.hs
Created October 20, 2011 08:50
strToInt and StrToDouble
import Data.Char
strToInt :: String -> Int
strToInt [] = 0
strToInt (x:xs)
| x == '-' = - strToInt xs
| otherwise = foldl step 0 (x:xs)
where step acc x = acc * 10 + (digitToInt x)
strToDouble :: String -> Double
@pimeys
pimeys / wireless.sh
Created November 22, 2011 13:36
Console wifi status
#!/bin/sh
iwconfig wlan0 2>&1 | grep -q no\ wireless\ extensions\. && {
echo wired
exit 0
}
essid=`iwconfig wlan0 | awk -F '"' '/ESSID/ {print $2}'`
stngth=`iwconfig wlan0 | awk -F '=' '/Quality/ {print $2}' | cut -d '/' -f 1`
bars=`expr $stngth / 10`
@pimeys
pimeys / quine.rb
Created December 1, 2011 15:36
Quine for ruby
q = 39
l = [
'q = 39',
'l = [',
' ',
']',
'',
'l.each_with_index do |line, index|',
' if index == 2',
' l.map{|line_| " " + q.chr + "#{line_}" + q.chr}.join(",\n").split("\n").each{|line_| puts line_}',
@pimeys
pimeys / omglog.rb
Created January 4, 2012 09:21
omglog for linux
#!/usr/bin/env ruby
# coding: utf-8
require 'rb-inotify'
CLEAR = "\n----\n"
YELLOW, BLUE, GREY, HIGHLIGHT = '0;33', '0;34', '0;90', '1;30;47'
SHORTEST_MESSAGE = 12
LOG_CMD = %{git log --all --date-order --graph --color --pretty="format: \2%h\3\2%d\3\2 %an, %ar\3\2 %s\3"}
LOG_REGEX = /(.*)\u0002(.*)\u0003\u0002(.*)\u0003\u0002(.*)\u0003\u0002(.*)\u0003/
@pimeys
pimeys / sound_log.rb
Created January 25, 2012 14:14
Sound log
require 'rubygems'
require 'bundler/setup'
require 'wavefile'
require 'json'
include WaveFile
format = Format.new(:mono, 16, 1000)
writer = Writer.new("sound.wav", format)
@pimeys
pimeys / gbrt.rb
Created March 28, 2012 08:14
A Nice List of Git Branches
#!/usr/bin/env ruby
def format_commit_info timestamp, time_desc, commit_id, message, ref_name
[
"#{timestamp.strftime("%y %b %d")}, #{timestamp.strftime("%l:%M%p").downcase}",
"(#{time_desc})",
commit_id,
message,
ref_name
]
@pimeys
pimeys / qsort_trace.txt
Created May 15, 2012 15:20
Quicksort trace
> (require racket/trace)
> (load "quicksort.rkt")
> (trace qsort)
> (qsort '(5 4 3 2 1))
>(qsort '(5 4 3 2 1))
> (qsort '(4 3 2 1))
> >(qsort '(3 2 1))
> > (qsort '(2 1))
> > >(qsort '(1))
> > > (qsort '())
@pimeys
pimeys / quicksort.rkt
Created May 15, 2012 15:22
Racket Quicksort
(define (qsort a)
(if (empty? a)
a
(let ([p (car a)])
(let ([tail (cdr a)])
(let ([lsr (filter (lambda (x) (< x p)) tail)])
(let ([grt (filter (lambda (x) (>= x p)) tail)])
(append (qsort lsr) (list p) (qsort grt))))))))
@pimeys
pimeys / pinger.rb
Created July 10, 2012 14:47
pinger
require 'net/http'
require 'uri'
GC.disable
threads = 100.times.map do
Thread.new do
10.times do
uri = URI.parse('http://example.com')
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)