Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike MacCana mikemaccana

View GitHub Profile
@mikemaccana
mikemaccana / manipulating-arrays.js
Created Feb 26, 2020 — forked from DMeechan/manipulating-arrays.js
Reading, manipulating, and writing arrays in JavaScript
View manipulating-arrays.js
// 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);
View operator-overloading.js
// Stolen from https://github.com/rauschma/op_overload and ported to ES6
const log = console.log.bind(console)
var operands = []
class Point {
constructor(x, y) {
if (arguments.length === 0) {
x = 0
View gist:d9372cbd1acddbd4ff1ac1d015882168
// Stolen from https://github.com/mikemaccana/agave/blob/master/index.js
const MILLISECONDS_IN_SECOND = 1000,
SECONDS_IN_MINUTE = 60,
MINUTES_IN_HOUR = 60,
HOURS_IN_DAY = 24,
DAYS_IN_WEEK = 7,
DAYS_IN_MONTH = 30,
DAYS_IN_YEAR = 365
// Normally you'd name functions with a verb, but since
@mikemaccana
mikemaccana / runme.js
Created Apr 25, 2019
Unfuck webchat.freenode.net
View runme.js
var styles = `
.qwebirc-qui .ircwindow div {
font-family: medium-content-serif-font,Georgia,Cambria,"Times New Roman",Times,serif;
margin: 26px auto 0 auto;
max-width: 650px;
}
.qwebirc-qui .lines {
font-size: 18px;
line-height: 1.58;
@mikemaccana
mikemaccana / instructions.md
Created Sep 11, 2017
Moving to yarn for modules everywhere / monorepo pattern
View instructions.md

Moving to yarn for modules everywhere / monorepo pattern

https://github.com/npm/npm/issues/17929 still occurs in npm 5.4.1 - private packages on the local disk are deleted whenever npm is used.

If npm fixes this in future great, but in the meantime, for others having the issue, if you're using monorepo / modules everywhere:

  • Install yarn and run yarn config set workspaces-experimental true
  • Move your private packages to /packages
  • Add a yarn workspace to your package.json with:
View config.yml
# See https://circleci.com/docs/2.0/configuration-reference (badly written)
# And https://circleci.com/docs/2.0/configuration-reference/#full-example (better)
version: 2
jobs:
build:
docker:
# Circle does not currently have a node 8 image
# https://circleci.com/docs/2.0/circleci-images/#nodejs
- image: circleci/node:latest
@mikemaccana
mikemaccana / gist:badf6c16f203e05c02b42f93cb740b46
Last active Jun 28, 2017
Awful Microsoft crypto article - 'use DES' and other bad ideas. Now 404d.
View gist:badf6c16f203e05c02b42f93cb740b46

Do not follow this advice, it is awful.

This is an archive of https://support.microsoft.com/en-us/help/307010

How to encrypt and decrypt a file by using Visual C#

For a Microsoft Visual Basic .NET version of this article, see 301070 .

This article refers to the following Microsoft .NET Framework Class Library namespaces: System.IO

@mikemaccana
mikemaccana / promise_monad.md
Last active Jun 21, 2017 — forked from MaiaVictor/promise_monad.md
async/await is just the do-notation for the Promise monad
View promise_monad.md

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 Jun 21, 2017 — forked from MaiaVictor/promise_monad.md
async/await is just the do-notation for the Promise monad
View promise_monad.md

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

View gist:6f3b9c004c0e5ed55d9f
machine:
node:
version: 4.2.2
# From for occasional ELIFECYCLE errors compiling microtime
# https://discuss.circleci.com/t/using-node-js-4-0-on-circleci/26
# Modified to use 'pre' rather than 'override' so 'npm install' runs
# See https://circleci.com/docs/configuration
dependencies:
pre:
You can’t perform that action at this time.