Skip to content

Instantly share code, notes, and snippets.

View fwoelffel's full-sized avatar

Frédéric Woelffel fwoelffel

View GitHub Profile
@err0r500
err0r500 / type-refinement.ts
Last active January 17, 2022 14:21
io-ts type refinement
import assert from 'assert';
import { isLeft, isRight } from 'fp-ts/lib/Either';
import { unsafeCoerce } from 'fp-ts/lib/function';
import * as t from 'io-ts';
// Int
export const IntC = t.brand(
t.number,
(s): s is t.Branded<number, { readonly IntBrand: unique symbol }> =>
Number.isInteger(s),
require ["include", "environment", "variables", "relational", "comparator-i;ascii-numeric", "spamtest"];
require ["fileinto", "imap4flags"];
# Stop processing for outbound emails
if address :all :comparator "i;unicode-casemap" :matches "From" ["username@protonmail.ch", "username@protonmail.com", "username@pm.me", #"username@example.com"] {
stop;
}
# Discard addresses where localpart is not 3
if not address :localpart :length "from" 3 {
@mattbell87
mattbell87 / remote-wsl.md
Last active July 26, 2024 16:17
VSCode Remote: Connect to WSL2 from another machine

VSCode Remote: Connect to WSL2 from another machine

Do you want to do remote development on your WSL2 container in Visual Studio Code? Read this.

Proxy jump method

  1. On the host set up OpenSSH for Windows
  2. Run wsl --update to make sure you are running the latest WSL
  3. Open WSL and install another SSH server inside WSL with sudo apt-get install openssh-server
  4. Now run sudo systemctl enable --now ssh to automatically start ssh when WSL starts.
@bryanjos
bryanjos / factory.ex
Created May 7, 2019 18:54
StreamData x ExMachina
defmodule AppTemplate.Factory do
alias AppTemplate.{Repo}
use ExMachina.Ecto, repo: Repo
alias AppTemplate.Generators
def user_factory do
Generators.generate(:user)
end
end
@adrianalonso
adrianalonso / pagination_promise_chain.js
Created January 6, 2019 11:58
Pagination Promise Chain
function getPaginatedElements(getResourcePromise, progressFn, limit = 25, offset = 0, elements = []) {
return new Promise((resolve, reject) =>
getResourcePromise({limit, offset})
.then(response => {
const newElements = elements.concat(response.records);
if (response.records.length === 0) {
resolve(newElements);
} else {
progressFn && progressFn(elements);
getPaginatedElements(getResourcePromise, progressFn, limit, offset+limit, newElements)
@jaytaylor
jaytaylor / delete-from-v2-docker-registry.md
Last active June 10, 2024 13:57
One liner for deleting images from a v2 docker registry

One liner for deleting images from a v2 docker registry

Just plug in your own values for registry and repo/image name.

registry='localhost:5000'
name='my-image'
curl -v -sSL -X DELETE "http://${registry}/v2/${name}/manifests/$(
    curl -sSL -I \
        -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
@JamieMason
JamieMason / migrate-to-lerna.sh
Last active April 25, 2019 18:58
Bash script to migrate multiple projects into one Lerna monorepo (https://lernajs.io)
#!/usr/bin/env bash
set -x
shopt -s extglob dotglob
cd "$HOME"
rm -rf "$HOME/TEMP_DIR"
mkdir "$HOME/TEMP_DIR"
cd "$HOME/TEMP_DIR"
git init
@boogie
boogie / receive.js
Created May 21, 2017 12:25
BETTER implementation with a "processing counter": RabbitMQ client closes the connection after 2 secs
#!/usr/bin/env node
'use strict';
const amqp = require('amqplib');
const sleep = async (ms) => new Promise(resolve => setTimeout(resolve, ms));
(async () => {
let processing = 0;
@ldez
ldez / gmail-github-filters.md
Last active July 16, 2024 09:41
Gmail and GitHub - Filters

Gmail and GitHub

How to filter emails from GitHub in Gmail and flag them with labels.

The labels in this document are just examples.

Pull Request

Filter Label

Oh my zsh.

Install with curl

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Enabling Plugins (zsh-autosuggestions & zsh-syntax-highlighting)

  • Download zsh-autosuggestions by