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
return d.getUTCFullYear() | |
+ '-' + zeroFill(d.getUTCMonth() + 1, 2) | |
+ '-' + zeroFill(d.getUTCDate(), 2) | |
+ 'T' + zeroFill(d.getUTCHours(), 2) | |
+ ':' + zeroFill(d.getUTCMinutes(), 2) | |
+ ':' + zeroFill(d.getUTCSeconds(), 2) | |
+ '.' + zeroFill(d.getUTCMilliseconds() * 1000, 6) | |
+ 'Z'; |
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
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSB6JUsqH814A5N78yQv/vy2UvHDUQGSIkknGiwRyQjX5h4aodgM6unvcIo1kZUldDCa4kxoUP1hN2Slb9UNWH/gwvSwmHI5T6M8W6b2kEcv4PX5BBn+V2aNI5KULq3OOevIrv5ofYf0shqRmX39mxLd2UU5tVLGYrx9OdYFK+2aRU6PJfMU8g2z6ArEqIvur81TeFnqdCMcihkM/1SnmBn/7c+/TfvjNm6xBBk2MC5Pw6iSTGi/JkIllMCXfV8FFvs4hYl0vfUowbBFdp5VQNrbYIJ8Qnn09hAilyFTRTlidkgAiAjr78pkClsisUA/M9lSjeD6G/7yhfO8o+Xv9J seed@Alex |
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
def median_of a | |
return nil if a.empty? | |
sorted = a.sort | |
len = sorted.length | |
(sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0 | |
end |
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
def longest_string array | |
array.sort_by! &:length | |
max_length = array.last.length | |
array.reject { |x| x.length < max_length } | |
end |
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
/** | |
* The MIT License (MIT) | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy of | |
* this software and associated documentation files (the "Software"), to deal in | |
* the Software without restriction, including without limitation the rights to | |
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
* the Software, and to permit persons to whom the Software is furnished to do so, | |
* subject to the following conditions: | |
* |
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
{-# LANGUAGE LambdaCase #-} | |
import Control.Monad ((>=>)) | |
import Data.Maybe (listToMaybe, fromMaybe) | |
import Data.Char (toLower) | |
import Data.List (intercalate) | |
type Item = Int | |
type Stack = [Item] |
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 querystring = require('querystring'), | |
util = require('util'), | |
request = require('request'); | |
var ARTICLE_URL = 'http://api.diffbot.com/v2/article'; | |
exports.article = function(url, token, cb, options) { | |
options = options || {}; | |
if (!url || !token || !cb) throw TypeError('3 arguments required.'); |
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
#!/usr/bin/env node | |
var fs = require('fs'), | |
spawn = require('child_process').spawn, | |
argv = require('optimist').argv; | |
var gcc = spawn('gcc', [ | |
'--std=c99', | |
'-o', argv.o || argv._[0] ? argv._[0].split('.')[0] : 'a.out', | |
'-x', 'c', | |
'-' |
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
{-# LANGUAGE OverloadedStrings #-} | |
codeChar :: Char -> String | |
codeChar c = case c of | |
'+' -> "++*p;" | |
'-' -> "--*p;" | |
'>' -> "++p;" | |
'<' -> "--p;" | |
'.' -> "fputc(*p, mode ? f : stdout);" | |
'|' -> "fflush(mode ? f : stdout);" |
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 Data.Char (isSpace) | |
import Data.Maybe (listToMaybe, fromMaybe) | |
maybeRead :: Read a => String -> Maybe a | |
maybeRead = fmap fst . listToMaybe . reads | |
parseLine :: String -> (Int, String) | |
parseLine = uncurry ((,) . fromMaybe 1 . maybeRead) . break isSpace | |
makeLine :: (Int, String) -> String |
OlderNewer