Skip to content

Instantly share code, notes, and snippets.

@wez
wez / msleep.c
Created May 24, 2011 02:39
How to sleep 0.5ms on Solaris
#define _POSIX_PTHREAD_SEMANTICS
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include <stdio.h>
static double compute_time_diff(struct timeval start, struct timeval end)
{
double diff = end.tv_sec - start.tv_sec;
@wez
wez / wez.itermcolors
Created March 2, 2011 01:11
Wez's iTerm 2 Colour selection
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Blue Component</key>
<real>0.0</real>
<key>Green Component</key>
<real>0.0</real>
@wez
wez / worker.js
Created October 20, 2009 02:54
playing with workers in titanium
var fs = Titanium.Filesystem;
var api = Titanium.API;
api.print("worker starting\n");
var path = fs.getResourcesDirectory() + fs.getSeparator() + 'worker.php';
api.print("PHP code is at " + path + "\n");
if (false) {
@wez
wez / sslclient.php
Created October 17, 2009 21:13
poor mans ssl client that reads "asynchronously" (every 100ms)
class SSLSocket {
public $s = null;
public $on_err = null;
public $on_read = null;
public $on_readComplete = null;
public $on_timeout = null;
public $on_write = null;
public $endpoint = null;
public $wbuffer = array();
public $timer = null;