Skip to content

Instantly share code, notes, and snippets.

View L8D's full-sized avatar

Tenor L8D

View GitHub Profile
@L8D
L8D / test1.js
Created January 6, 2016 21:17 — forked from anonymous/test1.js
var http = require('http');
var fs = require('fs');
// write out numbers
function writeNumbers(res) {
var counter = 0;
}
// increment global, write to client
for (var i = 0; i < 100; i++) {
counter++;
res.write(counter.toString() + '\n');
@L8D
L8D / app.js
Last active August 28, 2015 06:35
Setting ExpressJS server timeout using best practices
var express = require('express'),
http = require('http'),
app = express();
var server = http.createServer(app);
var timeout = 0;
server.setTimeout(timeout, function() {
server.listen(app.get('port'), function() {
@L8D
L8D / async.js
Last active August 27, 2015 21:09 — forked from Hanspagh/async.js
function findOrCreate(id) {
return Promise.try(function() {
return db.find(id);
}).then(function(result) {
if (result == null) {
return db.create(id);
} else {
return result;
}
});
@L8D
L8D / wm.js
Last active August 29, 2015 14:27 — forked from gajus/wm.js
let wm = new WeakMap();
class Foo {
constructor () {
var privateData = {};
wm.set(this, privateData);
privateData.myProperty = 1;
}
@L8D
L8D / weird-adder.hs
Last active August 29, 2015 13:56 — forked from dydx/weird-adder.hs
-- weird-adder.hs - Josh Sandlin - 6:45PM - 2/14/2010
-- wierd-adder.hs - Tenor Biel - 12:09PM - 2/13/201
-- Really weird way to add a range of numbers
-- takes an upper limit and returns a list of pairs
pairedRange :: Int -> [(Int, Int)]
pairedRange x = zip (filter odd [1..x]) (filter even [1..x])
-- adds a list of pairs
addPairs :: Num a => [(a, a)] -> [a]
@L8D
L8D / gist:8980539
Last active August 29, 2015 13:56 — forked from tibbe/gist:568670
test :: Num a => [a] -> [a]
test = filter $ (== 0) . (`mod` 2)
@L8D
L8D / fizzbuzz.hs
Last active August 29, 2015 13:56 — forked from mmisono/fizzbuzz.hs
main = putStr . unlines . map fizzbuzz $ [1..100]
divBy = ((== 0) .) . mod
fizzbuzz :: Int -> String
fizzbuzz x | x `divBy` 15 = "FizzBuzz"
| x `divBy` 5 = "Buzz"
| x `divBy` 3 = "Fizz"
| otherwise = show x
@L8D
L8D / cat.hs
Last active August 29, 2015 13:56 — forked from Siim/cat.hs
import System.Environment (getArgs)
main = do
args <- getArgs
if null args then interact id else mapM ((>>= putStr) . readFile) args
@L8D
L8D / test.js
Last active January 4, 2016 00:19 — forked from oroce/test.js
var gimmeFullscreenMethod = function() {
'use strict';
var el = document.documentElement, open, cancel, video;
open = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen;
cancel = el.exitFullscreen || el.webkitExitFullscreen || el.mozExitFullscreen || el.msExitFullscreen;
if (open) {
return {