readline = require "readline"
rl = readline.createInterface
input: process.stdin
output: process.stdout
You could use named functions to better read callbacks instead of deeply nested
#crawler-js-container | |
#crawler-js | |
:coffeescript | |
window.joystick = {}; | |
($ document).ready -> | |
MicroEvent.mixin VirtualJoystick | |
window.joystick = new VirtualJoystick({ | |
container : document.getElementById('crawler-js-container'), | |
mouseSupport : true | |
}) |
# Conway's Game of Life, in LiveScript | |
# ==================================== | |
# | |
# Conway's Game of Life is a cellular automaton, published by John H Conway | |
# in 1970, fulfilling the design principles but greatly simplifying the | |
# research of von Neumann, into a hypothetical machine that could build | |
# copies of itself. It is a zero-player game, meaning there is no input, and | |
# the game will progress on its own with a 'seed', or configuration, to | |
# begin with. | |
# |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2013 plugnburn | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
#!/bin/sh | |
echo "Enter your AWS Access Key: " | |
read access_key | |
echo "Enter your AWS Secret Key: " | |
read secret_key | |
encrypted=$(echo $secret_key | openssl aes-256-cbc -a -salt) |
# Selenium launcher is a great npm module for booting | |
# selenium server via a Node.js process. | |
selenium = require 'selenium-launcher' | |
soda = require 'soda' | |
process.env.NODE_ENV = "cucumber" | |
# This is our app's file. | |
server = require '../../server' | |
# We add some empty variables to store the web browser |
angular.module('catalog-diff') | |
.directive 'scheduleHeatmap', -> | |
margin = | |
top: 30 | |
right: 0 | |
bottom: 30 | |
left: 30 |
// Here is an example of a plain old function that returns a promise. | |
// Nothing magic about that. | |
function sleep(sec) { | |
return new Promise(function (resolve, reject) { | |
setTimeout(function () { | |
resolve(undefined); | |
}, sec * 1000); | |
}); | |
} |
This is a little style and expressiveness test for various stream libraries. It is certainly not a proof of anything, so much as an ability to showcase how some basic features of streams fit together with different libraries.
Problem statement: given a library of streams, implement an API analogous to fgrep
, i.e., a literal string grepper.
Specifically, implement a function fgrep(test, filenames[, limit=10])
, which takes a source string, a list of filenames, and an optional concurrency limit, and produces a stream of Match
records { filename: string, lineNumber: number, line: string }
, representing all lines of all files that contain the string test
. For each matching record, filename
is the name of the file where the match was found, lineNumber
is the one-indexed line number where the match was found, and line
is the contents of the line where the match was found.
The limit
argument indicates the maximum number of concurrent filehandles that should b
fmap :: ... => (a -> b) -> (f a -> f b) | |
(.) :: (y -> z) -> (x -> y) -> (x -> z) | |
fmap :: (f2 a -> f2 b) -> (f1 (f2 a) -> f1 (f2 b)) | |
fmap :: (a -> b) -> (f2 a -> f2 b) | |
(.) :: (y -> z ) -> (x -> y ) -> (x -> z ) | |
(.) :: ((f2 a -> f2 b) -> (f1 (f2 a) -> f1 (f2 b))) -> ((a -> b) -> (f2 a -> f2 b)) -> ((a -> b) -> (f1 (f2 a) -> f1 (f2 a))) | |
(.) fmap fmap :: (a -> b) -> (f1 (f2 a) -> f1 (f2 b)) | |
^--- (.) fmap fmap = fmap . fmap |