Skip to content

Instantly share code, notes, and snippets.

@clehner
clehner / OpenTest.c
Created September 26, 2014 17:06
OpenTest: check PBOpen and PBOpenDF vs. FSOpen and OpenDF in MPW libraries
#include <stdio.h>
#include <string.h>
#include <StandardFile.h>
#include <Memory.h>
#include <Files.h>
#include <Devices.h>
OSErr MyOpenDF(ConstStr255Param fileName, short vRefNum, short *refNum)
{
OSErr oe;
@clehner
clehner / verification.md
Last active August 29, 2015 14:08
onename.io verification
@clehner
clehner / pull.php
Last active August 29, 2015 14:14
GitHub Web Hook for updating a repo
<?php
header('Content-Type: text/plain');
$secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$branch = 'master';
$hub_signature = @$_SERVER['HTTP_X_HUB_SIGNATURE'];
if (!$hub_signature) {
http_response_code(403);
exit('missing signature');
}
@clehner
clehner / update-cjdns
Last active August 29, 2015 14:20
cjdns updater script
#!/bin/sh
# update-cjdns
# Usage: put in crontab:
# 0 0 * * * /usr/local/sbin/update-cjdns
cd /opt/cjdns || exit 1
git pull | grep -q 'Already up-to-date' && exit 0
tmp="$(mktemp)"
@clehner
clehner / hashchange.js
Created March 26, 2010 22:35
Simulate onhashchange support
// Simulate onhashchange support in all browsers
"onhashchange" in window || (function () {
var lastHash = '';
function pollHash() {
if (lastHash !== location.hash) {
lastHash = location.hash;
var event = document.createEvent("HTMLEvents");
event.initEvent("hashchange", true, false);
document.body.dispatchEvent(event);
if (typeof onhashchange == "function") {
<head>
<title>swarm!</title>
<script type="text/javascript" language=JavaScript src="buzzWorker.js"></script>
<style>
.thing {
position:absolute;
}
.dying {
color:#ff0000;
font-weight:bold;
@clehner
clehner / append_content.py
Created July 26, 2010 04:21
A better blip.append_content() for python wave robots.
from BeautifulSoup import BeautifulSoup, NavigableString
from waveapi import element
import re
import htmlentitydefs
IMAGE_PLACEHOLDER = '***{{((IMAGE_ELEMENT))}}***'
def append_content_to_blip(blip, content, type=None):
if type == 'text/plain':
# Replace characters that Wave breaks on
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
// one way
foo ? bar.doSomething(el) : bar.doSomethingElse(el);
@clehner
clehner / classy.js
Created October 18, 2010 02:17
Simple and Fast Javascript Inheritance. (No fancy stuff)
/*
Classy - Simple and Fast Javascript Inheritance.
(No fancy stuff)
Inspiration:
http://ejohn.org/blog/simple-javascript-inheritance/
http://valums.com/javascript-oop/
http://www.broofa.com/blog/2009/02/javascript-inheritance-performance/
Example:
@clehner
clehner / accesscode.js
Created April 24, 2011 05:53
Access Code Generator & Validator
// Access Code Generator & Validator
// API:
// string generateAccessCode()
// Boolean validateAccessCode(codeString)
(function () {
// configure:
var difference = 5;