I hereby claim:
- I am mandarg on github.
- I am mandarg (https://keybase.io/mandarg) on keybase.
- I have a public key whose fingerprint is F72F C522 44AA B51A 12F9 1A2D 3E34 DC3D 4FE7 4070
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
This are my cheat sheets that I have compiled over the years. Tired of searching Google for the same things, I started adding the information here. As time went on, this list has grown. I use this almost everyday and this Gist is the first bookmark on my list for quick and easy access.
I recommend that you compile your own list of cheat sheets as typing out the commands has been super helpful in allowing me to retain the information longer.
{~/sandbox}$ cat ./find_newline.py | |
#! /usr/bin/env python | |
import time | |
tries = 40 | |
upper = 2 ** 38 | |
lower = 0 | |
while tries >= 0: | |
mid = (upper + lower) / 2 |
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
// see: https://github.com/chadoe/docker-cleanup-volumes
$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
/* sidenotes.js: standalone JS library for parsing HTML documents with Pandoc-style footnotes and dynamically repositioning them into the left/right margins, when browser windows are wide enough. | |
Sidenotes are superior to footnotes where possible because they enable the reader to immediately look at them without requiring user action to 'go to' or 'pop up' the footnotes; even floating footnotes require effort by the reader. | |
sidenotes.js is inspired by the Tufte-CSS sidenotes (https://edwardtufte.github.io/tufte-css/#sidenotes), but where Tufte-CSS uses static footnotes inlined into the body of the page (requiring modifications to Pandoc's compilation), which doesn't always work well for particularly long or frequent sidenotes, sidenotes.js will rearrange sidenotes to fit as best as possible, and will respond to window changes. | |
Particularly long sidenotes are also partially 'collapsed'. | |
Author: Said Achmiz | |
2019-03-11 | |
license: MIT (derivative of footnotes.js, which is PD) | |
*/ |
1: 日 | |
2: 一 | |
3: 国 | |
4: 会 | |
5: 人 | |
6: 年 | |
7: 大 | |
8: 十 | |
9: 二 | |
10: 本 |
https://github.com/mohanson/gameboy - gameboy emulator
https://github.com/JakeStanger/mpd-discord-rpc - discordrpc for mpd
https://github.com/cristicbz/rust-doom - doom renderer
https://github.com/Aloxaf/silicon - a tool for creating pretty images of your source code for sharing
https://github.com/Rigellute/spotify-tui - a tui for spotify
https://github.com/atanunq/viu - view images in the terminal
const got = require('got'); | |
// Summary Mostly follow the steps in https://github.com/twilio-labs/function-templates/tree/main/forward-message-sendgrid | |
// except substitute the Discord webhook for the sendgrid call | |
exports.handler = function(context, event, callback) { | |
// todo: put this in the environment | |
// Get a webhook URL like this: https://www.digitalocean.com/community/tutorials/how-to-use-discord-webhooks-to-get-notifications-for-your-website-status-on-ubuntu-18-04 | |
const discord_url = "<your discord webhook URL here"; | |
console.log(event.Body) |
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.