Skip to content

Instantly share code, notes, and snippets.

View adieuadieu's full-sized avatar
🤷‍♂️

Marco Lüthy adieuadieu

🤷‍♂️
View GitHub Profile
@yamafaktory
yamafaktory / record-from-const-array.ts
Created November 21, 2019 13:24
🔍 Typecheck object properties from array elements in TypeScript
const MY_ARRAY = ['a', 'b', 'c'] as const
const objectWithKeysFromConstArrayElements: Record<
typeof MY_ARRAY[number],
string
> = { a: 'foo', b: 'bar', c: 'foobar' }
@skrrp
skrrp / gist:c719e07979b86e5fb96f010c563ac455
Created March 22, 2019 11:57 — forked from solenoid/gist:1372386
javascript ObjectId generator
var mongoObjectId = function () {
var timestamp = (new Date().getTime() / 1000 | 0).toString(16);
return timestamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, function() {
return (Math.random() * 16 | 0).toString(16);
}).toLowerCase();
};
@swalkinshaw
swalkinshaw / tutorial.md
Last active February 26, 2025 21:15
Designing a GraphQL API

Get $h*t Done! - How to survive in a world of distractions

Why

Morpheus: You have to let it all go, Neo. Fear, doubt, and disbelief. Free your mind.

We live in a world full of distractions - both in our private and professional lives. I'll show you how to keep track of things and focus on what really matters.

Vote for this talk by pushing the ⭐ Star button ↗ on the top right ↗

#![feature(lang_items)]
#![no_std]
#[no_mangle]
pub fn add_one(x: i32) -> i32 {
x + 1
}
// needed for no_std
@jbellenger
jbellenger / NamedChunksPlugin.js
Last active July 21, 2017 15:36
named chunks
// All webpack chunks have an identifier that is written to both the chunk and
// the chunk manifest.
//
// By default, webpack uses "int" identifiers, where the identifiers are
// sequentially generated after chunks are ordered by OccurenceOrderPlugin.
//
// The result of this is that small code changes may cause chunks to be
// reordered, leading to a cascading change of chunk ids, and a large number of
// chunk rehashes that could have been avoided.
//
@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

@WarlaxZ
WarlaxZ / Policy
Last active February 5, 2018 01:01
Serverless IAM Requirements
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"cloudformation:CreateStack",
"cloudformation:UpdateStack",
"cloudformation:DescribeStacks",
"cloudformation:ListStacks",
@cpsubrian
cpsubrian / README.md
Last active December 6, 2023 11:03
Compile Xvfb for AWS Lamba
@yoki
yoki / html2markdown.py
Created May 23, 2016 05:19
Convert html file to markdown
def html2markdown(self, html):
# convert html to markdown.
# specification:
# remove all tag exccept tags listed in the cleanbody._repl
# when p/div tags are in the table tag, markdown converter (htmlformatter)
# confuses. so it is removed
# we need following in the header
# import re, html2text
# from bs4 import BeautifulSoup