Skip to content

Instantly share code, notes, and snippets.

Avatar
🚮
bad command or file name

Tim Ryan tcr

🚮
bad command or file name
View GitHub Profile
View fetch_channel_data.py
import urllib
import urllib.parse
import urllib.request
import sys
ip = input('Enter IP address: ')
path = input('Enter path to save data to (with trailing \): ')
while 1:
print('')
View RocketGame.js
var RocketGame;
var __extends = function(child, parent) {
var ctor = function(){ };
ctor.prototype = parent.prototype;
child.__superClass__ = parent.prototype;
child.prototype = new ctor();
child.prototype.constructor = child;
};
RocketGame = function() {
var text;
View NameSpaces.coffee
# namespaces
NS: ->
ns: (->)
ns::dontEnum: (key) ->
ns::[key]: @[key]
delete @[key]
return new ns()
blocks: new NS()
View gist:479614
\0068\u0074\u0074\u0070\u003A\u002F\u002F\u0077\u0077\u0077\u002E\u0079\u006F\u0075\u0074\u0075\u0062\u0065\u002E\u0063\u006F\u006D\u002F\u0077\u0061\u0074\u0063\u0068\u0&#x3
@tcr
tcr / imousepad.py
Created Mar 15, 2011
imousepad.py - Server for iMousePad HTML5 demo.
View imousepad.py
#!/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
#
@tcr
tcr / imousepad.html
Created Mar 16, 2011
imousepad.html - HTML5 WebSocket demo for iMousePad.
View imousepad.html
<!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 / selection.coffee
Created Jun 13, 2011
Cross-Browser Selection Utilities
View selection.coffee
########################################################################
# 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 / async.coffee
Created Jul 18, 2011
Serial/Parallel functions in CoffeeScript
View async.coffee
# 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 / async.coffee
Created Jul 19, 2011 — forked from walling/async.coffee
Lean and Mean Serial function in CoffeeScript
View async.coffee
# 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 / code.coffee
Created Oct 22, 2011
How do you insert text into the middle of a text node, and also move the cursor with it?
View code.coffee
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
You can’t perform that action at this time.