Skip to content

Instantly share code, notes, and snippets.

View randomradio's full-sized avatar
🎯
Focusing

i.an randomradio

🎯
Focusing
View GitHub Profile

Rusty's API Design Manifesto

The idea

Application Programming Interface (API) design is hard. But it's even harder to change once you get it wrong. So what you should do is to spend the effort to get it right the first time around.

In the Linux Kernel community Rusty Russell came up with a API rating scheme to help us determine if our API is sensible, or not. It's a rating from -10 to 10, where 10 is perfect is -10 is hell. Unfortunately there are too many examples at the wrong end of the scale.

Rusty's original descriptions

Rusty's API Design Manifesto

The idea

Application Programming Interface (API) design is hard. But it's even harder to change once you get it wrong. So what you should do is to spend the effort to get it right the first time around.

In the Linux Kernel community Rusty Russell came up with a API rating scheme to help us determine if our API is sensible, or not. It's a rating from -10 to 10, where 10 is perfect is -10 is hell. Unfortunately there are too many examples at the wrong end of the scale.

Rusty's original descriptions

@randomradio
randomradio / nginx.conf
Created May 30, 2023 07:27 — forked from nrollr/nginx.conf
NGINX config for SSL with Let's Encrypt certs
# UPDATED 17 February 2019
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
listen [::]:80;
server_name www.domain.com domain.com;
return 301 https://$host$request_uri;
}
# SSL configuration
@randomradio
randomradio / nginx.conf
Created May 30, 2023 07:27 — forked from nrollr/nginx.conf
NGINX config for SSL with Let's Encrypt certs
# UPDATED 17 February 2019
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
listen [::]:80;
server_name www.domain.com domain.com;
return 301 https://$host$request_uri;
}
# SSL configuration
@randomradio
randomradio / .tmux.conf
Last active February 18, 2019 07:10
tmux configuration. Vim styled keybinding.
# 0 is too far from ` ;)
set -g base-index 1
# reset keys
unbind-key -n S-Left
unbind-key -n S-Right
# custom binding
set -g prefix C-s
bind C-s send-prefix
@randomradio
randomradio / cleaner_v2.py
Last active July 9, 2018 05:54
Google document cleanup
import bs4
import cssutils
import logging
import urlparse
class HTML_cleaner(object):
soup = None;
highlighting_selectors = {}
@randomradio
randomradio / README.md
Created April 11, 2018 22:16
batch remove github repository

Bulk delete repositories, keep your github sane and remind you how many undone project you hoarded.

Delete all repos

  1. repos.txt contains a list of repository names in {UserName}/{RepoName} format, e.g. IanZhao/to-be-deleted. use this file to track all repositories you want to delete.
  2. Open fetchSaveRepo.js and update url with your github username.
  3. you need node-fetch to fetch contents, just do a npm init with default settings and run npm install node-fetch.
  4. run node fetchSaveRepo.js
  5. Generate a Authorization Token for repo delete access token
  6. Copy the token and put in in place TOKEN_HERE in deleteRepos.sh
@randomradio
randomradio / gist:ccdfc55ddffbaf022f9d0c34f2760b3e
Created August 10, 2017 16:39 — forked from GrahamDumpleton/gist:b380652b768e81a7f60c
Setting environment variables for Apache/mod_wsgi hosted Python application.

Django documentation says to use:

WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py
WSGIPythonPath /path/to/mysite.com

<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Require all granted

Difference between Debounce and Throttle

Debounce

Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.

Throttle

Difference between Debounce and Throttle

Debounce

Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.

Throttle