Skip to content

Instantly share code, notes, and snippets.

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

David Larlet davidbgk

💭
(╯°□°)╯︵ ┻━┻
View GitHub Profile
@davidbgk
davidbgk / utils.js
Last active Aug 2, 2020
Let's start to reference some JS utils
View utils.js
// More resources: https://1loc.dev/ + https://htmldom.dev/ + https://thisthat.dev/
const qsa = (selector) => Array.from(document.querySelectorAll(selector))
const currentAnchor = () => document.location.hash ? document.location.hash.slice(1) : ''
async function copyToClipboard (codeElement, alert) => {
try {
await navigator.clipboard.writeText(codeElement.innerText)
alert.innerHTML = `<div class="code-block__alert">Code copied!</div>`
@davidbgk
davidbgk / markup.py
Created Jun 13, 2020 — forked from miraculixx/markup.py
an extensible multi-markup reader in less than 100 lines of python code
View markup.py
# (c) miraculixx, licensed as by the terms of WTFPL, http://www.wtfpl.net/txt/copying/
# License: DO WHATEVER YOU WANT TO with this code.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
from io import StringIO
from contextlib import contextmanager
View install.md

To install this:

$ pip install getgist pyyaml && getgist miraculixx markup.py && alias markup="python markup.py"

Then use it from your Python code

from markup import markup

data = markup(file_or_str)
@davidbgk
davidbgk / .zshrc
Last active Jun 11, 2020
Configuration file for ZSH (macOS), current status
View .zshrc
# to avoid Last login blah
# touch .hushlogin
# https://scriptingosx.com/2019/07/moving-to-zsh-06-customizing-the-zsh-prompt/
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
davidbgk / index.html
Created Feb 18, 2020
An attempt to implement a smoothscrolling while keeping :target selector in CSS
View index.html
<!doctype html><!-- This is a valid HTML5 document. -->
<!-- Screen readers, SEO, extensions and so on. -->
<html lang="fr">
<!-- Has to be within the first 1024 bytes, hence before the <title>
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 / index.html
Last active Dec 30, 2019
Upload images form with drag & drop and previews and progress upload
View index.html
<!doctype html><!-- This is a valid HTML5 document. -->
<!-- Screen readers, SEO, extensions and so on. -->
<html lang=fr>
<!-- Has to be within the first 1024 bytes, hence before the <title>
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,minimum-scale=1,initial-scale=1,shrink-to-fit=no">
@davidbgk
davidbgk / setup.cfg
Created Dec 17, 2019 — forked from althonos/setup.cfg
A `setup.cfg` template for my Python projects
View setup.cfg
# https://gist.github.com/althonos/6914b896789d3f2078d1e6237642c35c
[metadata]
name = {name}
version = {version}
author = Martin Larralde
author-email = martin.larralde@ens-paris-saclay.fr
home-page = https://github.com/althonos/{name}
description = {description}
long-description = file: README.rst, CHANGELOG.rst
@davidbgk
davidbgk / http_streaming.md
Created Nov 8, 2018 — forked from CMCDragonkai/http_streaming.md
HTTP Streaming (or Chunked vs Store & Forward)
View http_streaming.md

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

@davidbgk
davidbgk / nginx.conf
Created May 3, 2018
nginx conf to proxy carto tiles
View nginx.conf
proxy_cache_path /srv/user/cache levels=1:2 keys_zone=tiles-cache:8m max_size=500000m inactive=1000d;
proxy_temp_path /srv/user/cache/tmp;
upstream openaip_backend {
server 1.tile.maps.openaip.net;
server 2.tile.maps.openaip.net;
server 3.tile.maps.openaip.net;
}
upstream cartodb_backend {
@davidbgk
davidbgk / stimulus.html
Last active Mar 27, 2018
Playing with Stimulus tutorial
View stimulus.html
<!doctype html>
<meta charset=utf-8>
<title>Hello Stimulus</title>
<script src="https://unpkg.com/stimulus/dist/stimulus.umd.js"></script>
<script>
window.addEventListener('DOMContentLoaded', _ => {
const application = Stimulus.Application.start()
application.register('hello', class extends Stimulus.Controller {
static get targets () {
You can’t perform that action at this time.