Skip to content

Instantly share code, notes, and snippets.

(╯°□°)╯︵ ┻━┻

David Larlet davidbgk

(╯°□°)╯︵ ┻━┻
View GitHub Profile
davidbgk / mr-robot-religion.txt
Created Jul 23, 2016
Transcript of Mr Robot S02E03 about religion
View mr-robot-religion.txt
Is that what God does?
He helps?
Tell me,
why didn't God help
my innocent friend
who died for no reason
while the guilty roam free?
Okay, fine.
Forget the one-offs.
How about the countless wars
davidbgk / utils.css
Last active Mar 24, 2021
Let's start to reference some CSS utils
View utils.css
/* Applying it to the html element will provide smooth scrolling to anchors */
html {
scroll-behavior: smooth;
/* Remove animations for folks who set their OS to reduce motion.
1. Immediately jump any animation to the end point
2. Remove transitions & fixed background attachment
davidbgk / .zshrc
Last active Mar 15, 2021
Configuration file for ZSH (macOS), current status
View .zshrc
# to avoid Last login blah
# touch .hushlogin
PROMPT='%(?.%F{green}√.%F{red}?%?)%f %B%F{235}%2~%f%b %# '
# case insensitive path-completion
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]} l:|=* r:|=*'
# partial completion suggestions
davidbgk /
Created Apr 11, 2017
An attempt to create the simplest HTTP Hello world in Python3
import http.server
import socketserver
from http import HTTPStatus
class Handler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
self.wfile.write(b'Hello world')
davidbgk / index.html
Created May 10, 2016
Test DOM Content Loaded and promises
View index.html
<!doctype html>
<meta charset=utf-8>
<title>Test DOM Content Loaded and promises</title>
console.log(document.querySelector('main')) // => null
document.ready = new Promise(
(resolve) => document.addEventListener('DOMContentLoaded', resolve))
document.ready.then(() => console.log(document.querySelector('main'))) // => <main>
davidbgk / utils.js
Last active Feb 1, 2021
Let's start to reference some JS utils
View utils.js
// More resources: + + +
const qsa = (selector) => Array.from(document.querySelectorAll(selector))
// Another way inspired by fluorjs
function $(selector, root = document) {
if (selector instanceof Node) {
return [selector]
return root.querySelectorAll(selector)
davidbgk /
Last active Feb 1, 2021
Let's start to reference some Python utils
def neighborhood(iterable, first=None, last=None):
Yield the (previous, current, next) items given an iterable.
You can specify a `first` and/or `last` item for bounds.
iterator = iter(iterable)
previous = first
current = next(iterator) # Throws StopIteration if empty.
for next_ in iterator:
davidbgk /
Created Oct 28, 2010
Easily add an empty choice to a Django ChoiceField
from django import forms
class EmptyChoiceField(forms.ChoiceField):
def __init__(self, choices=(), empty_label=None, required=True, widget=None, label=None,
initial=None, help_text=None, *args, **kwargs):
# prepend an empty label if it exists (and field is not required!)
if not required and empty_label is not None:
choices = tuple([(u'', empty_label)] + list(choices))
davidbgk / index.html
Created Dec 7, 2015
Fake favicon, to avoid extra request to server
View index.html
<!-- Fake favicon, to avoid extra request to server -->
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
View hooks-in-a-nutshell.js
// WARNING: There's much more to know/do around hooks, and
// this is just a simplification of how these work.
// shared references, updated
// per each hook invoke
let execution = null;
let current = null;
let context = null;
let args = null;