Skip to content

Instantly share code, notes, and snippets.

View artob's full-sized avatar
⌨️
Coding

Arto Bendiken artob

⌨️
Coding
View GitHub Profile
@graphitemaster
graphitemaster / zlib_compress.c
Created August 27, 2011 06:27
ZLIB compression in 200 LOC
// ~zlib compression in 200 LOC quality allowed (5-8), where 5 is lowest, and 8 is heighest, the lower
// the quality the smaller the file. By graphitemaster, licensed unded public domain.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* fast lookup tables for length and distance */
static const unsigned short zlib_lengthc[] = {
0x003, 0x004, 0x005, 0x006, 0x007, 0x008, 0x009, 0x00A, 0x00B, 0x00D,
0x00F, 0x011, 0x013, 0x017, 0x01B, 0x01F, 0x023, 0x02B, 0x033, 0x03B,
@ktomk
ktomk / valid_utf8_bytes.php
Created October 4, 2011 19:10
filter valid utf-8 byte sequences
<?php
/**
* filter valid utf-8 byte sequences
*
* take over all valid bytes, drop an invalid sequence until first
* non-matching byte, start over at that byte.
*
* @param string $str
* @return string
*/
@chitchcock
chitchcock / 20111011_SteveYeggeGooglePlatformRant.md
Created October 12, 2011 15:53
Stevey's Google Platforms Rant

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

@alexindigo
alexindigo / redis.conf
Created October 23, 2011 02:08 — forked from carlzulauf/redis.conf
Redis upstart script (/etc/init/)
description "redis server"
start on runlevel [2345]
stop on shutdown
expect fork
exec sudo -u redis /usr/local/bin/redis-server /usr/local/etc/redis.conf
respawn
root@ip-10-85-129-240:~# lxc-create --name u6 -t ubuntu -f /usr/share/doc/lxc/examples/lxc-veth.conf | tee ~/u6.log
debootstrap is /usr/sbin/debootstrap
Checking cache download in /var/cache/lxc/oneiric/rootfs-amd64 ...
Copy /var/cache/lxc/oneiric/rootfs-amd64 to /var/lib/lxc/u6/rootfs ...
Copying rootfs to /var/lib/lxc/u6/rootfs ...Please change root-password !
Reading package lists...
Building dependency tree...
The following NEW packages will be installed:
lxcguest
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
@runa
runa / tor_signal.rb
Created October 31, 2011 21:33
send signal to running tor daemon
module Tor
class Controller
def signal(name)
send_command(:signal,name)
read_reply
end
end
end
@benjchristensen
benjchristensen / JavadocFilter.java
Created November 30, 2011 20:29
Doclet for filtering public classes from Javadoc
import java.lang.reflect.Array;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
import com.sun.javadoc.Doc;
import com.sun.javadoc.DocErrorReporter;
@tmiz
tmiz / CoreLocationTest.m
Created December 1, 2011 12:08
Using CoreLocation on Mac OS X with command-line
//
// Using CoreLocation on Mac OS X with command-line
// $ clang CoreLocationTest.m -framework cocoa -framework CoreLocation
// $ ./a.out
// location service enabled
// 2011-12-01 21:03:01.839 a.out[10214:903] latitude,logitude : 35.606647, 140.695538
// 2011-12-01 21:03:01.842 a.out[10214:903] timestamp : 2011-12-01 21:01:36 +0900
// tmiz [email protected]
//
#import <cocoa/cocoa.h>
@provegard
provegard / ssdp-test.py
Created December 5, 2011 21:52
Small SSDP server/client test in Python
#!/usr/bin/python
# Python program that can send out M-SEARCH messages using SSDP (in server
# mode), or listen for SSDP messages (in client mode).
import sys
from twisted.internet import reactor, task
from twisted.internet.protocol import DatagramProtocol
SSDP_ADDR = '239.255.255.250'
@jimbojsb
jimbojsb / gist:1630790
Created January 18, 2012 03:52
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2: