Skip to content

Instantly share code, notes, and snippets.

View tcr's full-sized avatar
🚮
bad command or file name

Tim Ryan tcr

🚮
bad command or file name
View GitHub Profile
@tcr
tcr / summary.md
Created October 23, 2011 06:45
What’s a better alternative to tinychat?

It’s beautiful.

@tcr
tcr / summary.md
Created October 22, 2011 08:03
What’s a good reference for Blackberry UI elements?

This is the most comprehensive example I've seen to date.

@tcr
tcr / code.coffee
Created October 22, 2011 02:05
How do you insert text into the middle of a text node, and also move the cursor with it?
insertData = (n, offset, str) ->
if offset > 0
prefix = n.nodeValue.substr(offset-1, 1)
n.insertData offset-1, prefix + str
n.deleteData offset-1 + str.length + 1, 1
else
n.parentNode.insertBefore n.ownerDocument.createTextNode(str), n
@tcr
tcr / async.coffee
Created July 19, 2011 05:40 — forked from walling/async.coffee
Lean and Mean Serial function in CoffeeScript
# Lean and Mean Serial/Parallel DSL for CoffeeScript
# - based of https://gist.github.com/1090670 by timcameronryan,
# https://gist.github.com/1091019 by walling
serial = (spec) ->
steps = (func for key, func of spec when key != 'catch')
next = (err, args...) ->
return spec.catch(err) if err
steps.shift().apply(next, args) if steps.length > 0
next null
@tcr
tcr / async.coffee
Created July 18, 2011 21:13
Serial/Parallel functions in CoffeeScript
# Asynchronous DSL for CoffeeScript
serial = (f) ->
next = -> arr.shift().apply(null, arguments) if arr.length
arr = (v for k, v of f(next))
next()
null
parallel = (f, after = ->) ->
res = {}; arrc = 0
@tcr
tcr / selection.coffee
Created June 13, 2011 01:28
Cross-Browser Selection Utilities
########################################################################
# Cross-Browser Selection Utilities
# Provides a 'selection' object with an API supporting
# all modern browsers (using window.getSelection())
# and IE5+ (using TextRanges)
########################################################################
root = this
if root.getSelection
@tcr
tcr / imousepad.html
Created March 16, 2011 03:27
imousepad.html - HTML5 WebSocket demo for iMousePad.
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Mousepad (Disconnected)</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<style>
body, html { padding: 0; margin: 0; background: black; overflow: hidden }
@tcr
tcr / imousepad.py
Created March 15, 2011 08:26
imousepad.py - Server for iMousePad HTML5 demo.
#!/usr/bin/env python
# References:
# http://stackoverflow.com/questions/4372657/websocket-handshake-problem-using-python-server/5282208#5282208
# http://popdevelop.com/2010/03/a-minimal-python-websocket-server/
# http://ubuntuforums.org/showthread.php?t=715256
#
# mouse
#
&#x5C;&#x30;&#x30;&#x36;&#x38;&#x5C;&#x75;&#x30;&#x30;&#x37;&#x34;&#x5C;&#x75;&#x30;&#x30;&#x37;&#x34;&#x5C;&#x75;&#x30;&#x30;&#x37;&#x30;&#x5C;&#x75;&#x30;&#x30;&#x33;&#x41;&#x5C;&#x75;&#x30;&#x30;&#x32;&#x46;&#x5C;&#x75;&#x30;&#x30;&#x32;&#x46;&#x5C;&#x75;&#x30;&#x30;&#x37;&#x37;&#x5C;&#x75;&#x30;&#x30;&#x37;&#x37;&#x5C;&#x75;&#x30;&#x30;&#x37;&#x37;&#x5C;&#x75;&#x30;&#x30;&#x32;&#x45;&#x5C;&#x75;&#x30;&#x30;&#x37;&#x39;&#x5C;&#x75;&#x30;&#x30;&#x36;&#x46;&#x5C;&#x75;&#x30;&#x30;&#x37;&#x35;&#x5C;&#x75;&#x30;&#x30;&#x37;&#x34;&#x5C;&#x75;&#x30;&#x30;&#x37;&#x35;&#x5C;&#x75;&#x30;&#x30;&#x36;&#x32;&#x5C;&#x75;&#x30;&#x30;&#x36;&#x35;&#x5C;&#x75;&#x30;&#x30;&#x32;&#x45;&#x5C;&#x75;&#x30;&#x30;&#x36;&#x33;&#x5C;&#x75;&#x30;&#x30;&#x36;&#x46;&#x5C;&#x75;&#x30;&#x30;&#x36;&#x44;&#x5C;&#x75;&#x30;&#x30;&#x32;&#x46;&#x5C;&#x75;&#x30;&#x30;&#x37;&#x37;&#x5C;&#x75;&#x30;&#x30;&#x36;&#x31;&#x5C;&#x75;&#x30;&#x30;&#x37;&#x34;&#x5C;&#x75;&#x30;&#x30;&#x36;&#x33;&#x5C;&#x75;&#x30;&#x30;&#x36;&#x38;&#x5C;&#x75;&#x30;&#x3
# namespaces
NS: ->
ns: (->)
ns::dontEnum: (key) ->
ns::[key]: @[key]
delete @[key]
return new ns()
blocks: new NS()