Skip to content

Instantly share code, notes, and snippets.

@clehner
clehner / irssi-growl.sh
Created September 28, 2012 04:27
Growl notifications for remote Irssi
#!/bin/sh
server='127.0.0.1'
log='irclogs/*/*.log'
ssh "$server" "tail -n1 -f $log" | sed -l 's/^[^ ]* < //' | while read line; do
sender="${line%>*}"
msg="${line#*> }"
growlnotify -m "$msg" "$sender"
done
@clehner
clehner / shapemaker.html
Created June 23, 2011 04:56
Draw simple shapes with points.
<!doctype html>
<html>
<head>
<title>Shape Maker</title>
<style type="text/css">
body {
font-family: Helvetica, Arial, sans-serif;
line-height: 1.5em;
font-size: 14px;
}
@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;
@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:
// 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 / 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
<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 / 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") {