Skip to content

Instantly share code, notes, and snippets.

View mikemaccana's full-sized avatar

Mike MacCana mikemaccana

View GitHub Profile
@mikemaccana
mikemaccana / manipulating-arrays.js
Created February 26, 2020 17:47 — forked from DMeechan/manipulating-arrays.js
Reading, manipulating, and writing arrays in JavaScript
// runTests();
const fs = require("fs");
const fileOne = "../exports/someA.csv";
const fileTwo = "../exports/someB.csv";
const fileThree = "../exports/someC.csv";
const outputFile = "../exports/someOut.csv";
const arrayOne = readFile(fileOne);
@mikemaccana
mikemaccana / promise_monad.md
Last active June 21, 2017 11:02 — forked from VictorTaelin/promise_monad.md
async/await is just the do-notation for the Promise monad

async/await is just the do-notation of the Promise monad

CertSimple just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I wholeheartedly agree.

In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but failed to. Finally, async/await is here and, combined with Promises, it solves the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.

First, let's illustrate the 3 styles by implementing a

@mikemaccana
mikemaccana / promise_monad.md
Created June 21, 2017 10:59 — forked from VictorTaelin/promise_monad.md
async/await is just the do-notation for the Promise monad

async/await is just the do-notation of the Promise monad

Mike MacCana just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I fully heartedly agree.

In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but they failed too. Finally, async/await is here and, combined with Promises, they solve the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.

First, let's illustrate the 3 styles by implementing a function that r

#!/bin/bash
# herein we backup our indexes! this script should run at like 6pm or something, after logstash
# rotates to a new ES index and theres no new data coming in to the old one. we grab metadatas,
# compress the data files, create a restore script, and push it all up to S3.
TODAY=`date +"%Y.%m.%d"`
INDEXNAME="logstash-$TODAY" # this had better match the index name in ES
INDEXDIR="/usr/local/elasticsearch/data/logstash/nodes/0/indices/"
BACKUPCMD="/usr/local/backupTools/s3cmd --config=/usr/local/backupTools/s3cfg put"
BACKUPDIR="/mnt/es-backups/"
YEARMONTH=`date +"%Y-%m"`