Skip to content

Instantly share code, notes, and snippets.

View rockymadden's full-sized avatar
:octocat:
Setting status

Rocky Madden rockymadden

:octocat:
Setting status
  • UiPath
  • Pale Blue Dot
View GitHub Profile
@dypsilon
dypsilon / reader-t.js
Last active December 27, 2017 03:53
In this example, the save method produces an error and we use mapLower to call a special Future function "mapRej", which transforms all incoming errors.
const {tagged} = require('daggy');
// const
const K = (a) => (b) => a;
// Reader Transformer
module.exports = (M) => {
const ReaderT = tagged('run');
ReaderT.lift = ReaderT.prototype.lift = (m) => ReaderT(K(m));
@dypsilon
dypsilon / reader.js
Last active April 28, 2024 08:50
Example usage of the reader monad.
/**
* This short program will encrypt the user password
* and insert a new record into a mock database.
*/
const Reader = require('fantasy-readers');
const R = require('ramda');
const crypto = require('crypto');
// our mock database
const database = [
@DrBoolean
DrBoolean / free-er2.js
Created February 27, 2016 16:38
Free(er) Monads Pt2
const daggy = require('daggy')
const Task = require('data.task')
const _ = require('lodash')
const kleisli_comp = (f, g) => x => f(x).chain(g)
const compose = (f, g) => x => f(g(x))
const id = x => x
//=============FREE=============
const Free = daggy.taggedSum({Impure: ['x', 'f'], Pure: ['x']})
const {Impure, Pure} = Free
@Avaq
Avaq / combinators.js
Last active May 1, 2024 09:38
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
@gunar
gunar / recursiveDir.js
Last active March 6, 2016 00:21
Comparison of recursive directory listing methods in JavaScript
/*
* Comparison of methods to list all files in a directory
* and subdirectories ("recursive directory walk").
*
* gunargessner.com 2015-12-25
*
*/
var fs = require('fs');
var fsPath = require('path');
var _ = require('highland');
@dannguyen
dannguyen / faa-333-pdf-gathering.md
Last active June 19, 2021 13:18
Using wget + grep to explore inconveniently organized federal data (FAA Section 333 Exemptions)

if !database: wget + grep

The Federal Aviation Administration is posting PDFs of the Section 333 exemptions that it grants, i.e. the exemptions for operators who want to fly drones commercially before the FAA finishes its rulemaking. A journalist wanted to look for exemptions granted to operators in a given U.S. state. But the FAA doesn't appear to have an easy-to-read data file to use and doesn't otherwise list exemptions by location of operator.

However, since their exemptions page is just one giant HTML table for listing the PDFs, we can just use wget to fetch all the PDFs, run pdftotext on each file, and then [grep](https://medium.com/@rualthanzauva/grep-was-a-private-command-of-m

@angelbotto
angelbotto / pre-commit
Created September 12, 2015 22:32
Run all test before commits :)
#!/bin/bash
git stash -q --keep-index
echo -e "👮 Wait, run all test before commit!\n"
FAILS=`rspec --format progress | grep -E '(\d*) failure(s?)' -o | awk '{print $1}'`
git stash pop -q
if [ $FAILS -ne 0 ]; then
@CMCDragonkai
CMCDragonkai / http_streaming.md
Last active April 25, 2024 17:19
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

@mrkaspa
mrkaspa / ycombinator.js
Created May 27, 2015 20:48
Y Combinator JS and Recursive Calls
var trampoline = function (f) {
while (f && f instanceof Function) {
f = f.apply(f.context, f.args);
}
return f;
}
var thunk = function (fn) {
return function () {
var args = Array.prototype.slice.apply(arguments);
@markrendle
markrendle / explanation.md
Last active July 3, 2022 07:56
Why I was previously not a fan of Apache Kafka

Update, September 2016

OK, you can pretty much ignore what I wrote below this update, because it doesn't really apply anymore.

I wrote this over a year ago, and at the time I had spent a couple of weeks trying to get Kafka 0.8 working with .NET and then Node.js with much frustration and very little success. I was rather angry. It keeps getting linked, though, and just popped up on Hacker News, so here's sort of an update, although I haven't used Kafka at all this year so I don't really have any new information.

In the end, we managed to get things working with a Node.js client, although we continued to have problems, both with our code and with managing a Kafka/Zookeeper cluster generally. What made it worse was that I did not then, and do not now, believe that Kafka was the correct solution for that particular problem at that particular company. What they were trying to achieve could have been done more simply with any number of other messaging systems, with a subscriber reading messages off and writing