Skip to content

Instantly share code, notes, and snippets.

View djanatyn's full-sized avatar

Jonathan Strickland djanatyn

View GitHub Profile
@yoshuawuyts
yoshuawuyts / Q&A.md
Created March 16, 2016 05:58 — forked from novaluke/0-Q&A.md
I want to use Nix for development, but... -- answers to common concerns about Nix

Nix seems perfect for developers - until I try to use it...

Want to use Nix for development but you're not sure how? Concerned about the fluidity of nixpkgs channels or not being able to easily install arbitrary package versions?

When I first heard about Nix it seemed like the perfect tool for a developer. When I tried to actually use it for developing and deploying web apps, though, the pieces just didn't seem to add up.

@johnelliott
johnelliott / index.js
Last active October 11, 2022 18:04
Streaming HTML standard input demo
#! /usr/bin/env node
const http = require('http')
process.stdin.setRawMode(true)
process.stdin.resume()
process.stdin.setEncoding('utf8')
const server = http.createServer((req, res) => {
res.statusCode = 200
res.setHeader('Content-Type', 'text/html')
res.write('<html>')
@VictorTaelin
VictorTaelin / promise_monad.md
Last active May 10, 2024 04:22
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

// ==UserScript==
// @name Work Gmail multi-line email list
// @description Makes sure that the new (late 2018) Gmail interface always shows the three-line previews of email lists (mainly for split-pane mode).
// The new Gmail behaviour changes this to one-line when the list pane is wide enough (but not wide enough for my liking).
// @author Lucas Costi
// @namespace https://lucascosti.com
//// The scope below only matches the second Gmail account (which is always my work one).
// @match https://mail.google.com/mail/u/1/*
// @grant none
// ==/UserScript==
#!/usr/bin/awk -f
function line(x1, y1, x2, y2) {
printf(" <line x1='%d' y1='%d' x2='%d' y2='%d'/>\n",
x1, y1 + rand() * 5, x2, y2 + rand() * 10)
}
function path(d) {
printf(" <path d='%s'/>\n", d)
}
@SciresM
SciresM / spelunky2_extract.py
Created September 30, 2020 11:44
Quick and dirty Spelunky 2 asset extraction. Assets are a weird chacha20 variant, there are at least two cryptographic errors due to typos....
import zstd
from struct import pack as pk, unpack as up
import subprocess as sp
# Quick and dirty Spelunky 2 asset extraction, author SciresM.
# Assets are protected by a weird chacha20 variant.
# The developers made an unfortunate set of typos that
# significantly weakens the asset crypto...
def rotate_left(a, b):
@vivshaw
vivshaw / README.md
Last active May 2, 2022 20:55
🙈🙉🙊 Three Wise Monkeys 🙈🙉🙊
@ycz
ycz / dsmashLoading.js
Created October 22, 2021 22:12
6 Minutes of Down Smash 0-Deaths source code
const fs = require("fs");
const { SlippiGame } = require("@slippi/slippi-js");
const DSMASH_MOVE_ID = 12;
const SAMUS_ID = 16;
const BASE_DIR = "/mnt/c/Users/ycz/Documents/Slippi/Archive";
const RECORDS_FILE = "./dsmashStarts.json";
let loadedRecords;
try {
module Demo where
-- notice many of these don't have type signatures.
-- Haskell is smart enough figure out 99% of the type signatures for you.
-- any type signatures here are just to add clarity.
-- number
somenumber = 1
-- string
@kpmcc
kpmcc / tree.c
Created May 23, 2022 19:21
Simple tree example
// preprocessor macro - basically copies tree.h and puts
// the contents where the include goes
#include <stdio.h>
#include <stdlib.h>
#include "tree.h"
int print_tree_hello() {