Skip to content

Instantly share code, notes, and snippets.

// Ramda Code : https://cdnjs.cloudflare.com/ajax/libs/ramda/0.24.1/ramda.min.js
// Run the below examples at https://ramdajs.com/repl/
{
const the_numbers = [1, 2, 3, 4];
const addOne = R.map(R.add(1));
const timesTwo = R.map(R.multiply(2));
const appendToAccum = (acc, val) => R.append(val, acc);
/**
* ES6 versions of Either monad used in FP in JS
* Author: Luis Atencio
* https://github.com/luijar/functional-programming-js/blob/master/src/model/monad/Either.js
* Validation from from Quildreen Motta's
* https://folktale.origamitower.com/api/v2.3.0/en/folktale.validation.html
*/
// Run the below examples in the console
/**
* Custom Maybe Monad used in FP in JS book written in ES6
* Author: Luis Atencio
* https://github.com/luijar/functional-programming-js/blob/master/src/model/monad/Maybe.js
*/
class Maybe {
static just(a) { return new Just(a); }
static nothing() { return new Nothing(); }
static fromNullable(a) { return (a !== null && a !== undefined) ? Maybe.just(a) : Maybe.nothing(); }
static of(a) { return Maybe.just(a); }
/**
* ES6 versions of Either monad used in FP in JS
* Author: Luis Atencio
* https://github.com/luijar/functional-programming-js/blob/master/src/model/monad/Either.js
*/
// Run the below examples in the console
class Base_Either {
constructor(value) { this._value = value; }
{
const Tuple = function(_expected_types) {
const expected_types = [...arguments];
const isNull = a_value => (a_value === undefined || a_value === null);
const anyNull = (found_null, the_value) => (found_null || isNull(the_value));
const showNulls = the_value => isNull(the_value) ? 'NULL' : the_value.toString();
const constructorName = a_value => Object.getPrototypeOf(a_value).constructor.name;
const scalarType = a_value => a_value.charAt(0).toUpperCase() + a_value.slice(1);
const tupleType = a_value => typeof a_value == 'object' ? objectType(a_value) : scalarType(typeof a_value);
let myConsole = (function(){
let the_log_buffer=[[]], the_count=0, the_single_line=false;
const THE_CONSOLE=console, LINE_DIVIDER=' ~ ', ONE_LINE='ONE_LINE',
PARAMETER_SEPARATOR= ', ', NEW_LINE = Symbol();
const start = (line_type='NOT_ONE_LINE') => {
the_log_buffer=[[]];
the_count=0;
the_single_line = line_type == ONE_LINE;
console = myConsole;
@steenhansen
steenhansen / .emacs.d-customizations
Created August 20, 2019 06:31
.emacs.d-customizations
delsel.el
editing.el
elisp-editing.el
frame-cmds.el
frame-fns.el
highlight-symbol.el
kmb.el
kmb-for-windows.el
misc.el
msb.el
@steenhansen
steenhansen / conemu.txt
Last active February 26, 2022 20:29
ConEmu start directory
ConEmu set start directory:
1 Settings | Startup
[x] Specified named tasck
{Shells::PowerShell (Admin)}
2 Settings | Startup | Tasks
6 {Shells::PowerShell (Admin)}
Task parameters Example:
/dir "D:\my-dir\my-subdir"
@steenhansen
steenhansen / clj.formatter
Created July 13, 2019 06:11
clojure formatter
lein cljfmt fix
:plugins [[lein-cljfmt "0.6.4"]]
@steenhansen
steenhansen / grep-for-windows.txt
Last active July 13, 2019 06:04
Grep for Emacs in Windows
Get Gnu Grep installer
http://gnuwin32.sourceforge.net/packages/grep.htm
Run
grep-2.5.4-src-setup.exe
Install in
C:\Program Files (x86)\GnuWin32
To System.Path add