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
// fizzbuzz ramda-style | |
var R = require('ramda'); | |
R.forEach(R.cond([ | |
[R.pipe(R.modulo(R.__, 15), R.equals(0)), R.always('FizzBuzz')], | |
[R.pipe(R.modulo(R.__, 3), R.equals(0)), R.always('Fizz')], | |
[R.pipe(R.modulo(R.__, 5), R.equals(0)), R.always('Buzz')], | |
[R.T, R.identity] | |
]), R.range(1, 101)); | |
//with a helper 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
var R = require('ramda'); | |
var factorOf = R.compose(R.equals(0), R.flip(R.modulo)); | |
var getFizzBuzz = R.cond([ | |
[factorOf(15), R.always('FizzBuzz')], | |
[factorOf(5), R.always('Buzz')], | |
[factorOf(3), R.always('Fizz')], | |
[R.T, R.identity] | |
]); |
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
#! /bin/sh | |
# ================================================================== | |
# ______ __ ____ | |
# /_ __/___ ____ ___ _________ _/ /_ ( __ ) | |
# / / / __ \/ __ `__ \/ ___/ __ `/ __/ / __ | | |
# / / / /_/ / / / / / / /__/ /_/ / /_ / /_/ / | |
# /_/ \____/_/ /_/ /_/\___/\__,_/\__/ \____/ | |
# | |
# Multi-instance Apache Tomcat installation with a focus | |
# on best-practices as defined by Apache, SpringSource, and MuleSoft |
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
buildscript { | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
classpath "org.grails:grails-gradle-plugin:2.1.2" | |
} | |
} | |
version "0.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
buildscript { | |
ext { | |
grailsVersion = project.grailsVersion | |
} | |
repositories { | |
mavenLocal() | |
maven { url "https://repo.grails.org/grails/core" } | |
} | |
dependencies { | |
classpath "org.grails:grails-gradle-plugin:$grailsVersion" |
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
const start = 5; | |
const end = 20; | |
let myArray = Array.from(new Array(end - start)).map((_, index) => start + index); | |
console.log(myArray); // -> 5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 | |
//alernative | |
myArray = [...(new Array(end - start))].map((_, index) => start + index); | |
console.log(myArray); // -> 5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 | |
//alternative: arrayFrom takes optional map function parameter to avoid intermediate creation | |
myArray = Array.from(new Array(end - start),((_, index) => start + index)); // -> 5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 |
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
'use strict'; | |
const start = Date.now(); | |
const ordinals = { | |
1: 'First', | |
2: 'Second', | |
3: 'Third', | |
4: 'Fourth', | |
5: 'Fifth' | |
}; | |
const whatIsHappening = (result) => console.log(`${ordinals[result]} @ ${Date.now() - start} ms`); |
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
const mapping = (f) => (reducing) => (result, input, index) => reducing(result, f(input, index)); | |
const filtering = (predicate) => (reducing) => (result, input, index) => predicate(input) ? reducing(result, input, index) : result; | |
const ALPHABET = 'abcdefghijklmnopqrstuvwxyz'.split(''); | |
const NUMBERS = '0123456789'.split(''); | |
const isAlphaNumeric = (letter) => ALPHABET.indexOf(letter) !== -1 || NUMBERS.indexOf(letter) !== -1; | |
const periodicallyPad = (current, index) => index !== 0 && index % 5 === 0 ? ' ' + current : current; | |
const concatenate = (xs, x, index) => xs.concat(x); | |
const result = 'I AM SO EXCITED ABOUT TRANSDUCERS'.toLowerCase().split('') |
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
Snapshot of Khan Academy's BigBingo A/B testing framework and related code. | |
Here's a basic overview: | |
-summarize.py is the most interesting file. It contains all stages of the | |
summarize task, as well as the publish and archive steps that happen at the | |
end. | |
-bq_pipelines.py contains lots of useful pipelines for interacting with | |
BigQuery. QueryToTableBatchPipeline can run many simultaneous queries, and will | |
properly handle all batching and retry logic. | |
-config.py is where all experiment configuraiton lives. For this Gist, I |
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 java.util.*; | |
public class MineFieldMapper { | |
public List<String> map(List<String> mineField) { | |
if (mineField.size() == 3) { | |
return Arrays.asList("1", "*", "1"); | |
} | |
String s = mineField.get(0); |
OlderNewer