Skip to content

Instantly share code, notes, and snippets.

View michaelmrose's full-sized avatar
💭
Available to hire

Michael Rose michaelmrose

💭
Available to hire
View GitHub Profile
@michaelmrose
michaelmrose / recursiveRomanity2.js
Last active June 20, 2016 14:58
an attempt at writing a recursive roman numeral converter that would benefit from tco
var numerals = [1,4,5,9,10,40,50,90,100,400,500,900,1000];
var ohtheromanity = {1: "I", 4: "IV", 5:"V", 9: "IX", 10: "X", 40: "XL", 50: "L",
90: "XC", 100: "C", 400: "CD", 500: "D", 900: "CM", 1000: "M"};
function convert(n,str="") {
if (n === 0){return str;}
else {
var largestInclusiveNumber = numerals.filter(function(x){return x<=n;}).pop();
var remainder = n -= largestInclusiveNumber;
return convert(remainder,str.concat(ohtheromanity[largestInclusiveNumber]));
@michaelmrose
michaelmrose / Example.md
Last active October 12, 2018 23:42
A Colored Clojure Repl Via Neovim, Fish, and Lein

A Colored Clojure Repl Via Neovim, Fish, and Lein

We'll start with the assumption that your cwd in vim is set to the directory of a clojure file perhaps via autochdir.

Now with some vimscript we'll start a terminal buffer, set the proper syntax coloring, turn on rainbow parens and only then run lein repl. Note it doesn't work if these aren't done before lein repl.

function! NvimRepl()
 terminal
@michaelmrose
michaelmrose / Example.md
Created January 27, 2016 23:36
-e Example.md

A Colored Clojure Repl Via Neovim, Fish, and Lein

We'll start with the assumption that your cwd in vim is set to the directory of a clojure file perhaps via autochdir.

Now with some vimscript we'll start a terminal buffer, set the proper syntax coloring, turn on rainbow parens and only then run lein repl. Note it doesn't work if these aren't done before lein repl.

function! NvimRepl()
 terminal
@michaelmrose
michaelmrose / somefish.md
Last active January 27, 2016 23:51
some fish functions
    function in-terminal-or-out
      if in-terminal
        eval $argv
      else
        lilyterm -e ff $argv
      end
 end
@michaelmrose
michaelmrose / adder.js
Last active January 28, 2016 08:34
adder bonfire
function isNotNumber(n){
return typeof(n) !== 'number';
}
function adder(x){
if (isNotNumber(x))return;
return function(y){
if (isNotNumber(y) || isNotNumber(x)) return;
return x+y;
};
@michaelmrose
michaelmrose / program.js
Last active February 1, 2016 07:34
countLines.js
var fs = require('fs');
var q = require('q');
var file = process.argv[2];
var notreal = 24;
function countLinesOfFile(input){
q.nfcall(fs.readFile,input,"utf-8")
.then(function(data){
var n = countLines(data);
console.log(n);
@michaelmrose
michaelmrose / change.js
Created February 3, 2016 20:20
cash register
var possibleChange = [1,5,10,25,100,500,1000,2000,10000];
var coinValueToName = {1: "PENNY", 5: "NICKEL", 10: "DIME", 25: "QUARTER", 100: "ONE",
500: "FIVE", 1000: "TEN", 2000: "TWENTY", 10000: "ONE HUNDRED"};
var coinNameToValue = {"PENNY": 0.01, "NICKEL": 0.05, "DIME": 0.10, "QUARTER": 0.25,
"ONE": 1.00, "FIVE": 5.00, "TEN": 10.00, "TWENTY": 20.00, "ONE HUNDRED": 100.00};
var money = [["PENNY", 1.01], ["NICKEL", 2.05], ["QUARTER", 10.00], ["ONE", 100.00], ["TEN", 100.00]];
function drawer(price, cash, cid) {
price = price * 100;
@michaelmrose
michaelmrose / change2.js
Last active February 4, 2016 12:52
improved cash drawer implimentation
var tender = {1: "PENNY", "PENNY": 1, 5: "NICKEL","NICKEL": 5, 10: "DIME", "DIME": 10, 25: "QUARTER", "QUARTER": 25,
100: "ONE","ONE": 100, 500: "FIVE", "FIVE": 500, 1000: "TEN", "TEN": 1000, 2000: "TWENTY",
"TWENTY": 2000, a10000: "ONE HUNDRED", "ONE HUNDRED": 10000};
function numberOfTender(value,cid,possibleChange){
var maxTender = possibleChange.filter(function(x){return x<=value;}).pop();
var maxNumTender = Math.floor(value/maxTender);
var tenderAvailable = cid.map(function(n){if (n[0] == tender[maxTender]) return n[1];})
.filter(notUndefined)
.map(Number) / (maxTender/100) || 0;
var tender = {1: "PENNY", "PENNY": 1, 5: "NICKEL","NICKEL": 5, 10: "DIME", "DIME": 10, 25: "QUARTER", "QUARTER": 25,
100: "ONE","ONE": 100, 500: "FIVE", "FIVE": 500, 1000: "TEN", "TEN": 1000, 2000: "TWENTY",
"TWENTY": 2000, a10000: "ONE HUNDRED", "ONE HUNDRED": 10000};
function numberOfTender(value,cid,possibleChange){
var maxTender = possibleChange.filter(function(x){return x<=value;}).pop();
var maxNumTender = Math.floor(value/maxTender);
var tenderAvailable = cid.map(function(n){if (n[0] == tender[maxTender]) return n[1];})
.filter(notUndefined)
.map(Number) / (maxTender/100) || 0;
@michaelmrose
michaelmrose / destroyer.js
Last active May 13, 2016 05:13
seek and destroy challenge
function destroyer(arr, ...values){
return arr.filter(function(n){return values.indexOf(n) == -1;});
}
//added by gist.el at 1013