Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
(╯°□°)╯︵ ┻━┻

David Larlet davidbgk

💭
(╯°□°)╯︵ ┻━┻
View GitHub Profile
@davidbgk
davidbgk / web-servers.md
Created Jun 9, 2022 — forked from willurd/web-servers.md
Big list of http static server one-liners
View web-servers.md

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@davidbgk
davidbgk / previewImageUploads.js
Created May 15, 2022 — forked from adactio/previewImageUploads.js
Show inline previews of images that are going to be uploaded.
View previewImageUploads.js
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
(function (win,doc) {
'use strict';
if (!win.FileReader || !win.addEventListener || !doc.querySelectorAll) {
// doesn't cut the mustard.
return;
}
doc.querySelectorAll('input[type="file"][accept="image/*"]').forEach( function (fileInput) {
@davidbgk
davidbgk / github-proxy-client.js
Created Mar 17, 2022 — forked from DavidWells/github-proxy-client.js
Full Github REST api in 34 lines of code
View github-proxy-client.js
/* Ultra lightweight Github REST Client */
// original inspiration via https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb
const token = 'github-token-here'
const githubClient = generateAPI('https://api.github.com', {
headers: {
'User-Agent': 'xyz',
'Authorization': `bearer ${token}`
}
})
@davidbgk
davidbgk / .zshrc
Created Dec 15, 2021
Example of Python aliases + reimplementation of `cd` to auto de/activate the current virtualenv
View .zshrc
# aliases
alias -g ll='ls -al'
alias -g subl='open -a "Sublime Text"'
alias server='python3 -m http.server 8000 --bind 127.0.0.1'
alias rmvenv='deactivate && rm -rf venv/'
alias venv='python3 -m venv venv'
alias activate='source venv/bin/activate'
alias pipupgrade='python3 -m pip install --upgrade pip'
alias requirements='python3 -m pip install -r requirements.txt'
@davidbgk
davidbgk / index.html
Last active Oct 22, 2021
Opening details tag on hash/anchor
View index.html
<!doctype html><!-- This is a valid HTML5 document. -->
<!-- Screen readers, SEO, extensions and so on. -->
<html lang="en">
<!-- Has to be within the first 1024 bytes, hence before the `title` element
See: https://www.w3.org/TR/2012/CR-html5-20121217/document-metadata.html#charset -->
<meta charset="utf-8">
<!-- Why no `X-UA-Compatible` meta: https://stackoverflow.com/a/6771584 -->
<!-- The viewport meta is quite crowded and we are responsible for that.
See: https://codepen.io/tigt/post/meta-viewport-for-2015 -->
<meta name="viewport" content="width=device-width,initial-scale=1">
@davidbgk
davidbgk / userChrome.css
Created Oct 12, 2021 — forked from maxlath/userChrome.css
Hide "Firefox suggests" text in Firefox 93 search menu
View userChrome.css
/*
Create or edit userChrome.css in your Firefox profile folder,
typically found on Linux at ~/.mozilla/firefox/[some firefox profile folder]/chrome/userChrome.css
*/
.urlbarView-row[label]{
margin-block-start: 0 !important;
}
.urlbarView-row[label]::before{
@davidbgk
davidbgk / Makefile
Created Sep 27, 2021 — forked from baldurbjarnason/Makefile
node-less frontend testing using Firefox and TAP
View Makefile
.PHONY:test
test:
rm -rf ./my-profile; mkdir ./my-profile && echo "user_pref('devtools.console.stdout.content', true);user_pref('dom.allow_scripts_to_close_windows', true);user_pref('datareporting.policy.firstRunURL', '');" > ./my-profile/user.js && firefox --headless -profile ./my-profile -no-remote `pwd`/index.html | sed -n "/console.log: /p" | sed -e 's/console.log: "//' -e 's/"$$//' | ./tapview
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;
View httpserver.py
"""
Implements a simple HTTP/1.0 Server
"""
import socket
def handle_request(request):
"""Handles the HTTP request."""
@davidbgk
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
https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior */
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