This file contains 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 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 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 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 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 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 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
parseLine = fmap tail . break (== ' ') | |
editLine = fmap f where | |
f s = s ++ "^http://mtgimage.com/card/" ++ s ++ ".jpg" | |
writeLine (x, y) = x ++ " " ++ y | |
main = interact $ unlines | |
. map ( writeLine | |
. editLine |
This file contains 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 qualified Data.Set as S | |
data Color | |
= White | |
| Blue | |
| Black | |
| Red | |
| Green | |
deriving (Enum, Eq, Ord) |
This file contains 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
" setup NERDTree button | |
nnoremap <silent> <leader>m :NERDTreeToggle<enter> | |
" map ctrl+hjkl to c-w movements | |
map <C-h> <C-w>h | |
map <C-j> <C-w>j | |
map <C-k> <C-w>k | |
map <C-l> <C-w>l | |
" pathogen stuff |
This file contains 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
<p> | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec fermentum | |
nec ante eget suscipit. Nullam gravida viverra quam a maximus. Proin nunc | |
massa, auctor id arcu a, imperdiet placerat tortor. Maecenas eget tristique | |
odio. Nullam fermentum orci erat, sed ultrices nunc volutpat sit amet. Duis | |
id nunc nisi. Morbi placerat eros in pretium dignissim. Mauris lacinia, | |
diam vitae euismod cursus, ligula ex vehicula nulla, vitae convallis nibh | |
sem ac velit. Nulla facilisi. Ut consectetur id mauris nec fermentum. Cras | |
nec cursus justo. Donec tempus quam nunc, sed faucibus lacus vulputate vel. | |
Integer egestas ex ut neque tristique dictum. Phasellus ut nulla mauris. |
OlderNewer