Skip to content

Instantly share code, notes, and snippets.

View creationix's full-sized avatar
💚
<3

Tim Caswell creationix

💚
<3
View GitHub Profile
Module.cache = {};
function Module(id) {
var cached = Module.cache[id];
if (cached) { return cached; }
Module.cache[id] = this;
this.exports = {};
this.id = id;
this.load();
@creationix
creationix / .jshintrc
Created November 7, 2014 00:45
Sublime Settings
{
// JSHint Default Configuration File (as on JSHint website)
// See http://jshint.com/docs/ for more details
"maxerr" : 50, // {int} Maximum error before stopping
// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : true, // true: Require {} for every new block or scope
@creationix
creationix / xinput-tweaks.sh
Created November 18, 2014 19:19
xinput tweaks for desktop
#!/usr/bin/sh
# Make sure the touch screen is not stretched across two screens
for i in $(xinput --list | grep 'HID Touch' | sed -e "s/.*id=\([0-9][0-9]*\).*/\1/p" | uniq)
do
xinput --map-to-output $i HDMI-0
done
# Don't use the joystick as a mouse
for i in $(xinput --list | grep 'Logitech Attack 3' | sed -e "s/.*id=\([0-9][0-9]*\).*/\1/p" | uniq)
@creationix
creationix / helpful.lua
Created November 19, 2014 22:11
Make luvit more helpful by suggesting possible corrections.
local uv = require('uv')
local colorize = require('utils').colorize
uv = setmetatable(uv, {
__index = function (table, wanted)
local closest = math.huge
local name = nil
for key in pairs(table) do
local distance = string.levenshtein(key, wanted)
if distance < closest then
@creationix
creationix / build.log
Created November 21, 2014 04:52
Building Luvit on a Raspberry PI in less than a second!
[tim@cherry luvit]$ time LUVI_APP=app LUVI_TARGET=luvit luvi-binaries/`uname -s`_`uname -m`/luvi
Creating new binary: /home/tim/luvit/luvit
Copying initial 1135139 bytes from /home/tim/luvit/luvi-binaries/Linux_armv6l/luvi
Zipping /home/tim/luvit/app
main.lua
modules/buffer.lua
modules/codec.lua
modules/codecs/http.lua
modules/codecs/tls.lua
modules/core.lua
@creationix
creationix / http-decoder.js
Created December 10, 2014 04:52
http-decoder for dukluv
"use strict";
module.exports = decoder;
function decoder() {
// This decoder is somewhat stateful with 5 different parsing states.
var mode; // state variable that points to various decoders
var bytesLeft; // For counted decoder
@creationix
creationix / luv.md
Last active August 29, 2015 14:11
luv docs

LibUV in Lua

The [luv][] project provides access to the multi-platform support library [libuv][] to lua code. It was primariliy developed for the [luvit] project as the uv builtin module, but can be used in other lua environments.

TCP Echo Server Example

Here is a small example showing a TCP echo server:

sample :ambi_drone, rate: 0.5
sample :ambi_drone, rate: 0.3
sample :ambi_drone, rate: 0.7
for i in 0..1000
sample :ambi_soft_buzz, rate: (0.3 + i * 0.01)
sample :ambi_soft_buzz, rate: (5 - i * 0.01)
sleep 2 / (i / 8 + 1)
end
@creationix
creationix / seti.css
Created January 5, 2015 14:40
Seti-ish theme for CodeMirror
/* theme based on seti-ui from atom and sublime text */
/* loosely ported to codemirror */
/* Created by Tim Caswell <tim@creationix.com> */
.cm-s-seti.CodeMirror {
background-color:#151718;
color:#d4d7d6;
font-family: Menlo, Vera Sans Mono, Ubuntu Mono, Consolas, Monaco, monospace;
}
@creationix
creationix / 1-publish.log
Last active August 29, 2015 14:13
log of first non-creationix package to lit
Jan 9 20:22:35 creationix lit[22580]: client connected: 127.0.0.1:51422
Jan 9 20:22:35 creationix lit[22580]: importing key: rphillips 0f:25:96:bf:98:13:d1:62:ab:27:fb:3d:8f:66:94:d2
Jan 9 20:22:35 creationix lit[22580]: importing key: rphillips d5:43:47:0e:20:22:02:a6:1c:4e:97:1e:2a:02:b7:c8
Jan 9 20:22:35 creationix lit[22580]: importing key: rphillips c2:db:d4:52:69:e6:42:dc:7a:2e:f4:8e:f1:b3:6b:8c
Jan 9 20:22:35 creationix lit[22580]: importing key: rphillips 65:74:06:38:e7:72:a9:cc:58:4a:5c:07:dc:48:af:dd
Jan 9 20:22:35 creationix lit[22580]: new package: rphillips/luvit-async/v0.0.2
Jan 9 20:22:35 creationix lit[22580]: client disconnected: 127.0.0.1:51422