Skip to content

Instantly share code, notes, and snippets.

View StevenACoffman's full-sized avatar

Steve Coffman StevenACoffman

View GitHub Profile
// 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
@StevenACoffman
StevenACoffman / fizzbuzz.js
Last active August 29, 2015 14:27 — forked from TGOlson/fizzbuzz.js
Point-free JavaScript FizzBuzz Kata
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]
]);
@StevenACoffman
StevenACoffman / setenv.sh
Created September 3, 2015 13:57 — forked from terrancesnyder/setenv.sh
./setenv.sh - example setenv.sh with defaults set for minimal time spent in garbage collection
#! /bin/sh
# ==================================================================
# ______ __ ____
# /_ __/___ ____ ___ _________ _/ /_ ( __ )
# / / / __ \/ __ `__ \/ ___/ __ `/ __/ / __ |
# / / / /_/ / / / / / / /__/ /_/ / /_ / /_/ /
# /_/ \____/_/ /_/ /_/\___/\__,_/\__/ \____/
#
# Multi-instance Apache Tomcat installation with a focus
# on best-practices as defined by Apache, SpringSource, and MuleSoft
@StevenACoffman
StevenACoffman / build.gradle
Last active November 12, 2015 23:30
Failing gradle to init new grails with gradle plugin --stacktrace --debug 2> stderr.txt > stdout.txt
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.grails:grails-gradle-plugin:2.1.2"
}
}
version "0.1"
@StevenACoffman
StevenACoffman / build.gradle
Created November 13, 2015 16:52
Default build.gradle from Grails 3.0.9 generated with grails create-app new-document
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
@StevenACoffman
StevenACoffman / generate_range.js
Last active December 23, 2015 23:10
Generate an array in a particular range
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
@StevenACoffman
StevenACoffman / promise_example.js
Last active January 7, 2016 18:43
Promise example
'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`);
@StevenACoffman
StevenACoffman / index.js
Last active January 27, 2016 18:10 — forked from roman01la/index.js
Broken but not sure why
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('')
@StevenACoffman
StevenACoffman / BigBingo
Created August 1, 2016 14:36 — forked from alangpierce/BigBingo
BigBingo (as of early July 2014)
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
@StevenACoffman
StevenACoffman / MineFieldMapper.java
Created August 30, 2016 17:59
MineSweeper Kata 45-minute Randori Result at Ithaka
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);