This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat foo.js | |
require('share') | |
$ ls node_modules | |
share | |
$ head node_modules/share/package.json | |
{ | |
"name": "share", | |
"version": "0.4.1", | |
"description": "A database for concurrent document editing", | |
"keywords": ["operational transformation", "ot", "concurrent", "collaborative", "database", "server"], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.atom = atom = {} | |
atom.input = { | |
_bindings: {} | |
_down: {} | |
_pressed: {} | |
_released: [] | |
bind: (key, action) -> | |
@_bindings[key] = action |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getMoveFromPlayer(player_id, cb) { | |
process.spawn_child(whatever, cb) | |
} | |
function getNextMove() { | |
if (!gameStillRunning) { return } | |
getMoveFromPlayer(current_player, function (err, data) { | |
makeMove(data) | |
getNextMove() | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Opens a file in [path/to/current_file.*] that isn't already open. | |
function! RelatedFiles() | |
return filter(split(globpath(expand('%:h'), expand('%:t:r').'.*')), '!bufloaded(v:val)') | |
endfunction | |
function! OpenRelatedFile() | |
let files = RelatedFiles() | |
if len(files) > 0 | |
" always open .h files on the left. | |
if match(files[0], "\.h$") >= 0 | |
exec 'lefta vsplit '.files[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
coffee = require 'coffee-script' | |
vm = require 'vm' | |
connect = require 'connect' | |
browserChannel = require('browserchannel').server | |
comm = new (require('events').EventEmitter) | |
# TODO: sandbox | |
master = ((comm) -> | |
code = ''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="http://segment.io" onclick="track('clicked on segment.io')">Yay!</a> | |
<script> | |
function track(msg) { | |
new Image().src = "http://segment.io/track?msg=" + encodeURLComponent(msg) | |
} | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tag = (name, text) -> | |
parts = name.split /(?=[.#])/ # why yes, i am a ninja | |
tagName = "div" | |
classes = [] | |
id = undefined | |
for p in parts | |
switch p[0] | |
when '#' then id = p.substr 1 | |
when '.' then classes.push p.substr 1 | |
else tagName = p |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "System Events" to set terminal_open to process "iTerm" exists | |
if not terminal_open then | |
tell application "iTerm" to activate | |
else | |
tell application "iTerm" | |
set myterm to (make new terminal) | |
tell myterm | |
launch session "Default" | |
activate | |
end tell |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tested in Chrome 23, Firefox 16, and IE9 in standards mode (i.e. with <!DOCTYPE html>). | |
// Converts '#f00', 'red', 'hsl(0, 100%, 50%)' and 'rgb(255,0,0)' to {r:255,g:0,b:0}. | |
function cssColorToRGB(cssColor) { | |
var s = document.createElement('span') | |
document.body.appendChild(s) | |
s.style.backgroundColor = cssColor | |
var rgb = getComputedStyle(s).backgroundColor | |
document.body.removeChild(s) | |
var m = /^rgb\((\d+), (\d+), (\d+)\)$/.exec(rgb) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
T = function(s,v) { var x = t*v; return (x*(3+1*s[(x>>10)%s.length]))%255 }, | |
S = function(s,v) { var x = t*v; return (x*(3+1*s[(x>>10)%s.length]))%255>127?255:0 }, | |
(T("121312123321",1) + T("12131212332",1.005))/2 |