// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks. | |
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/) | |
(() => { | |
const SHOW_SIDES = false; // color sides of DOM nodes? | |
const COLOR_SURFACE = true; // color tops of DOM nodes? | |
const COLOR_RANDOM = false; // randomise color? | |
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com) | |
const MAX_ROTATION = 180; // set to 360 to rotate all the way round | |
const THICKNESS = 20; // thickness of layers | |
const DISTANCE = 10000; // ¯\\_(ツ)_/¯ |
#!/bin/bash | |
### | |
### my-script — does one thing well | |
### | |
### Usage: | |
### my-script <input> <output> | |
### | |
### Options: | |
### <input> Input file to read. | |
### <output> Output file to write. Use '-' for stdout. |
(setq jethro/org-agenda-todo-view | |
`(" " "Agenda" | |
((agenda "" | |
((org-agenda-span 'day) | |
(org-deadline-warning-days 365))) | |
(todo "TODO" | |
((org-agenda-overriding-header "To Refile") | |
(org-agenda-files '(,(concat jethro/org-agenda-directory "inbox.org"))))) | |
(todo "TODO" | |
((org-agenda-overriding-header "Emails") |
# | |
# This is the ultimate HAProxy 2.0 "Getting Started" config | |
# It demonstrates many of the features available which are now available | |
# While you may not need all of these things, this can serve | |
# as a reference for your own configurations. | |
# | |
# Have questions? Check out our community Slack: | |
# https://slack.haproxy.org/ | |
# |
version: "3" | |
services: | |
mongo1: | |
hostname: mongo1 | |
container_name: localmongo1 | |
image: mongo:4.0-xenial | |
expose: | |
- 27017 | |
ports: | |
- 27011:27017 |
# Gawk version | |
# Remote | |
grep -v "rem_address" /proc/net/tcp | awk '{x=strtonum("0x"substr($3,index($3,":")-2,2)); for (i=5; i>0; i-=2) x = x"."strtonum("0x"substr($3,i,2))}{print x":"strtonum("0x"substr($3,index($3,":")+1,4))}' | |
# Local | |
grep -v "rem_address" /proc/net/tcp | awk '{x=strtonum("0x"substr($2,index($2,":")-2,2)); for (i=5; i>0; i-=2) x = x"."strtonum("0x"substr($2,i,2))}{print x":"strtonum("0x"substr($2,index($2,":")+1,4))}' | |
# No Gawk | |
# Local | |
grep -v "rem_address" /proc/net/tcp | awk 'function hextodec(str,ret,n,i,k,c){ |
#!/usr/bin/env python3 | |
import sys | |
import json | |
import os | |
import os.path | |
import shutil | |
import logging | |
import tempfile | |
import glob | |
import argparse |
Ripgrep is a fast search tool like grep
. It's mostly a drop-in replacement for ag
, also know as the Silver Searcher.
helm-ag
is a fantastic package for Emacs that allows you to display search results in a buffer.
You can also jump to locations of matches. Despite the name, helm-ag
works with ripgrep (rg
) as well
as with ag
.
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.