This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// very simple http server on libevent evhttp | |
#include <stdio.h> | |
#include <assert.h> | |
#include <event.h> | |
#include <evhttp.h> | |
#ifndef NDEBUG | |
#define AZ(foo) assert((foo) == 0) | |
#define AN(foo) assert((foo) != 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# print context switches per second | |
N=0; while true; do NP=$N; N=$(cat /proc/stat|grep ctxt|awk '{print $2}'); expr $N '-' $NP; sleep 1; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dump mysql databases | |
PASSWD='secret' | |
for db in hal_mail \ | |
hal_roundcubemail \ | |
hal_wiki \ | |
jforster_blog \ | |
kjallgren \ | |
mattias_wp \ | |
miken_digredi \ | |
mysql \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Embed fonts using CSS3 | |
Source: http://www.alistapart.com/articles/cssatten */ | |
@font-face { | |
font-family: "Kimberley"; | |
src: url(http://www.princexml.com/fonts/larabie/kimberle.ttf) format("truetype"); | |
} | |
h1 { font-family: "Kimberley", sans-serif; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cocoa forwardInvocation snippet | |
- (void)forwardInvocation:(NSInvocation *)invocation { | |
SEL se = [invocation selector]; | |
if ([window respondsToSelector:se]) | |
[invocation invokeWithTarget:window]; | |
else | |
[self doesNotRecognizeSelector:se]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# $Id: modersynk.sh 84 2008-01-14 10:50:55Z rasmus $ | |
if [ `id -u` != 0 ]; then | |
echo "Must be run as root" >&2 | |
exit 1 | |
fi | |
RSYNC=/usr/bin/rsync | |
BACKUP_BASE=/Volumes/Stuff/backup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HTTP client for testing high connection concurrency | |
// Authors: Richard Jones and Rasmus Andersson | |
// Released in the public domain. No restrictions, no support. | |
#include <sys/types.h> | |
#include <sys/time.h> | |
#include <sys/queue.h> | |
#include <stdlib.h> | |
#include <err.h> | |
#include <event.h> | |
#include <evhttp.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Skeleton Growl delegate/handler | |
static MyGrowlDelegate *_growl_delegate = nil; | |
static NSString *_notification_name = @"Transmission complete"; | |
@implementation MyGrowlDelegate | |
+ (void)initialize { | |
[GrowlApplicationBridge setGrowlDelegate:[isa sharedInstance]]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// print_r | |
// http://dev.base86.com/solo/47/actionscript_3_equivalent_of_phps_printr.html | |
package | |
{ | |
public function print_r(obj:*, level:int = 0, output:String = ""):* | |
{ | |
var tabs:String = ""; | |
for (var i:int = 0; i < level; i++, tabs += "\t"); | |
for (var child:* in obj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var xyz = {}; | |
xyz.receiverURL = '.res/save-proxy-image.php'; | |
xyz.resizeImage = function(img, dstw, dsth, fit) { | |
try { | |
var w = dstw; | |
var h = dsth; | |
if (img.naturalWidth === 0 || img.naturalHeight === 0) | |
return null; | |
if (img.naturalWidth > dstw || img.naturalHeight > dsth) { | |
if (fit) { |