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
-- Run this manually onto your DB. You can use it to convert binary to base58. | |
CREATE OR REPLACE FUNCTION base58(input_bytea bytea) | |
RETURNS text AS $body$ | |
declare | |
alphabet text[] = array[ | |
'1','2','3','4','5','6','7','8','9', | |
'a','b','c','d','e','f','g','h','i','j','k','m','n','o','p','q','r','s','t','u','v','w','x','y','z', | |
'A','B','C','D','E','F','G','H','J','K','L','M','N','P','Q','R','S','T','U','V','W','X','Y','Z' | |
]; | |
cnt integer = 58; |
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
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'); |
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
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() { |
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 findOrCreate(id) { | |
return Promise.try(function() { | |
return db.find(id); | |
}).then(function(result) { | |
if (result == null) { | |
return db.create(id); | |
} else { | |
return result; | |
} | |
}); |
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
let wm = new WeakMap(); | |
class Foo { | |
constructor () { | |
var privateData = {}; | |
wm.set(this, privateData); | |
privateData.myProperty = 1; | |
} |
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
-- 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] |
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
test :: Num a => [a] -> [a] | |
test = filter $ (== 0) . (`mod` 2) |
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
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 |
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
import System.Environment (getArgs) | |
main = do | |
args <- getArgs | |
if null args then interact id else mapM ((>>= putStr) . readFile) args |
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
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 { |
NewerOlder