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 Control.Applicative ((<*>)) | |
import Control.Parallel (par) | |
class Comonad w where | |
extend :: (w a -> b) -> w a -> w b | |
duplicate :: w a -> w (w a) | |
extract :: w a -> a | |
-- if monads are monoids on functions which produce side effects, | |
-- |
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 getGlobal = (function(g) { | |
if (g == null) { | |
if (typeof System !== 'undefined' && System != null && System.global != null && System.global.System === System) g = System.global; | |
else if (typeof self !== 'undefined' && self != null && self.self === self) g = self; | |
else if (typeof window !== 'undefined' && window != null && window.window === window) g = window; | |
else if (typeof global !== 'undefined' && global != null && global.global === global) g = global; | |
} | |
return function() { return g; }; | |
}(this)); |
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
qsort = (list) -> | |
return list if list.length <= 1 | |
pivotPoint = medianOfThree list | |
pivot = list[pivotPoint] | |
list.splice pivotPoint, 1, [] | |
[left, right] = partition list, (e) -> e < pivot | |
[(qsort left)..., pivot, (qsort right)...] | |
medianOfThree = (list) -> | |
return 0 if list.length < 3 |
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
console.log(JSON.stringify([].map.call(document.querySelectorAll('.content_body .media-body'), function(ratingEl){ | |
return { | |
title: ratingEl.childNodes[3].childNodes[1].textContent, | |
year: parseInt(ratingEl.childNodes[3].childNodes[2].textContent.slice(1, -1), 10), | |
rt_link: ratingEl.childNodes[3].childNodes[1].href, | |
rating: 20 * ratingEl.childNodes[5].querySelectorAll('.glyphicon-star').length + (/½/.test(ratingEl.childNodes[5].textContent) ? 10 : 0), | |
}; | |
}).sort(function(a, b){ return a.title > b.title ? 1 : -1; }))); |
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
$ eshost host --list | |
┌──────────────┬─────────┬──────────────────────────────────────────────────┬──────┐ | |
│ name │ type │ path │ args │ | |
├──────────────┼─────────┼──────────────────────────────────────────────────┼──────┤ | |
│ nashorn │ nashorn │ /usr/java/jdk1.8.0_66/bin/jjs │ │ | |
├──────────────┼─────────┼──────────────────────────────────────────────────┼──────┤ | |
│ v8 │ d8 │ /usr/bin/d8 │ │ | |
├──────────────┼─────────┼──────────────────────────────────────────────────┼──────┤ | |
│ jsc │ jsc │ /usr/bin/jsc │ │ | |
├──────────────┼─────────┼──────────────────────────────────────────────────┼──────┤ |
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 () { | |
var g, h; | |
function x() { f = ""; /* var-scoped f gets value "" */ } | |
function y() { g = f; /* g gets value of var-scoped f */ } | |
{ | |
/* var-scoped f is undefined, let-scoped f is a function */ | |
h = f; /* h gets value of let-scoped f, a function */ | |
f = 1; /* let-scoped f gets value 1 */ | |
x(); | |
y(); |
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 | |
import Data.Word | |
import Data.Bits | |
import Data.List | |
import Data.Maybe | |
import qualified Data.ByteString as B | |
import Codec.Crypto.AES | |
repeatedKeyXor = do |
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.List (unfoldr) | |
import Data.Tuple (swap) | |
import System.IO (hSetBuffering, stdout, BufferMode(..)) | |
placeValues base = reverse . unfoldr (\x -> if x == 0 then Nothing else Just $ swap $ divMod x base) | |
persistencePath base x = if x < base then [x] else x : (persistencePath base $ product $ placeValues base x) | |
persistence base n = length (persistencePath base n) - 1 | |
lowestNumberSuchThat f = head $ dropWhile (not . f) [0..] | |
main = do |
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
masksOfLength x = iterate (\y -> map (True:) y ++ map (False:) y) [[]] !! 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
// ==UserScript== | |
// @name Github Screenshots | |
// @description make a github repo presentable for screenshots | |
// @match https://github.com/* | |
// @version 0.0.1 | |
// ==/UserScript== | |
function hide (node) { | |
node.style.display = 'none'; | |
} |