Skip to content

Instantly share code, notes, and snippets.

View richdouglasevans's full-sized avatar
✌️

Rich richdouglasevans

✌️
  • Oxford, England
View GitHub Profile
@i-am-tom
i-am-tom / bifunctor-profunctor.js
Created June 26, 2017 18:32
The main examples from the "Bifunctor + Profunctor" post.
const { Left, Right } = require('fantasy-eithers')
const daggy = require('daggy')
Function.prototype.map = function (f) {
return x => f(this(x))
}
//- Where everything changes...
const login = user =>
user.name == 'Tom'
@VictorTaelin
VictorTaelin / promise_monad.md
Last active October 24, 2024 01:25
async/await is just the do-notation of 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 too. 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

@i-am-tom
i-am-tom / semigroup.js
Created March 13, 2017 21:10
Fantas, Eel, and Specification
const { tagged } = require('daggy')
const First = tagged('val')
First.prototype.concat = function (that) {
return this
}
const Min = tagged('val')
@ericclemmons
ericclemmons / example.md
Last active September 20, 2024 12:46
HTML5 <details> in GitHub

Using <details> in GitHub

Suppose you're opening an issue and there's a lot noisey logs that may be useful.

Rather than wrecking readability, wrap it in a <details> tag!

<details>
 Summary Goes Here
@kangax
kangax / quicksort.hs
Last active September 5, 2021 19:44
Haskell-inspired quick sort in ES6
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) =
let smallerSorted = quicksort (filter (<=x) xs)
biggerSorted = quicksort (filter (>x) xs)
in smallerSorted ++ [x] ++ biggerSorted
@ygotthilf
ygotthilf / jwtRS256.sh
Last active April 26, 2025 05:11
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@LuRsT
LuRsT / Dockerfile
Created September 19, 2015 10:31
Dockerfile for `hr`
FROM debian
RUN apt-get update && apt-get install -y curl
RUN curl https://raw.githubusercontent.com/LuRsT/hr/master/hr > /bin/hr
RUN chmod +x /bin/hr
@benfoxall
benfoxall / runkeeper-export.sh
Last active April 20, 2018 20:47
A bash script for exporting runkeeper data.
# Requires:
# a) `jq` to be installed
# b) A Bearer token (you can grab this from the healthgraph debug console)
export BEARER=MY_TOKEN_FROM_THE_CONSOLE
curl https://api.runkeeper.com/fitnessActivities?pageSize=100 -H "Authorization: Bearer $BEARER" > page1.json
curl https://api.runkeeper.com/fitnessActivities?pageSize=100&page=2 -H "Authorization: Bearer $BEARER" > page2.json
curl https://api.runkeeper.com/fitnessActivities?pageSize=100&page=3 -H "Authorization: Bearer $BEARER" > page3.json
@mefellows
mefellows / BundleConfig.ps1
Last active December 25, 2023 23:33
Sysprepped Windows AMI using Packer
$EC2SettingsFile="C:\\Program Files\\Amazon\\Ec2ConfigService\\Settings\\BundleConfig.xml"
$xml = [xml](get-content $EC2SettingsFile)
$xmlElement = $xml.get_DocumentElement()
foreach ($element in $xmlElement.Property)
{
if ($element.Name -eq "AutoSysprep")
{
$element.Value="Yes"
}
@LHSimon
LHSimon / netrunnerRedirect.html
Created April 20, 2015 23:39
This is designed to redirect to a random Netrunner card from http://netrunnerbd.com. I threw it together to work with the New Tab Redirect Chrome extension (https://chrome.google.com/webstore/detail/new-tab-redirect/icpgjfneehieebagbmdbhnlpiopdcmna?hl=en). It could all be done a lot better, but this was quick and it's done :-)
<html>
<head>
<script type="text/javascript">
var baseUrl = 'http://netrunnerdb.com/en/card/';
var maxSetId = 8;
var cardsCoreSet = 119;
var cardsBigBox = 55;
var cardsCycle = 120;