Skip to content

Instantly share code, notes, and snippets.

View karlcow's full-sized avatar
⛩️
Working from … anywhere

Karl Dubost karlcow

⛩️
Working from … anywhere
View GitHub Profile
@karlcow
karlcow / recover-deleted-branch.sh
Created May 13, 2024 12:11 — forked from umayr/recover-deleted-branch.sh
How to recover a deleted branch
## Pre-requisite: You have to know your last commit message from your deleted branch.
git reflog
# Search for message in the list
# a901eda HEAD@{18}: commit: <last commit message>
# Now you have two options, either checkout revision or HEAD
git checkout a901eda
# Or
git checkout HEAD@{18}
@karlcow
karlcow / debugger-icons.md
Last active April 21, 2022 03:56
Comparison of debuggers icons for steps debugging
@karlcow
karlcow / code.mmd
Last active October 6, 2021 08:28
Webcompat Flowchart
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@karlcow
karlcow / use-case-UA-detection.md
Last active July 16, 2021 21:33
Compiling use case detections

Draft for Issue 152

User Agent Detection Use Cases

Before being able to freeze and reduce parts of the browser User Agent string, we need to clearly lay down the different ways the user agent strings is being used on the Web by users and developers.

The User Agent String detection is the mechanism by which a piece of software will change its behavior according to the interpretation of the value of the User Agent String.

User Agent Strings Scope

@karlcow
karlcow / weekly.js
Last active April 7, 2021 06:40
code JS demo pour présentation de données. utilisant https://www.chartjs.org/
// convert from date string to date object
function convert_to_date(date_str) {
var timestamp = Date.parse(date_str);
var date_obj = new Date(timestamp);
return date_obj;
}
// Create a label string of two dates for each week starting with the beginning date.
function make_labels(date_start) {
var date_obj = date_start.timestamp;
date_str_start = date_obj.toLocaleDateString("en-US", date_options);
(function (containerId, opts) {
if (!('querySelector' in document)) return;
var container = document.getElementById(containerId);
var nameSpace = opts.namespace || '';
var onResize = throttle(update, 200);
var waiting = !!window.IntersectionObserver;
var observer;
update();
document.addEventListener('DOMContentLoaded', update);
products = """A,10,20
B,50,30
C,10,10
D,50,40
E,60,10"""
product_lines = [product.split(',') for product in products.splitlines()]
# sorting by INCREASING price
per_price = sorted(product_lines, key = lambda product: product[2])
# [['C', '10', '10'], ['E', '60', '10'], ['A', '10', '20'], ['B', '50', '30'], ['D', '50', '40']]
@karlcow
karlcow / error.md
Created February 10, 2021 13:50
lxml.etree.XMLSyntaxError: Char 0x0 out of allowed range

With lxml 4.5.0

❯ python
Python 3.9.1 (default, Feb  5 2021, 17:04:50) 
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
>>> from io import StringIO
>>> etree.parse(StringIO('<h2>👺</h2>'))
<div class="news-entry__item-content"><p><span class="word trans-in onscreen" style="transition-delay: 0.03s;">Waste</span> <span class="word trans-in onscreen" style="transition-delay: 0.06s;">continues</span> <span class="word trans-in onscreen" style="transition-delay: 0.09s;">to</span> <span class="word trans-in onscreen" style="transition-delay: 0.12s;">be</span> <span class="word trans-in onscreen" style="transition-delay: 0.15s;">high</span> <span class="word trans-in onscreen" style="transition-delay: 0.18s;">on</span> <span class="word trans-in onscreen" style="transition-delay: 0.21s;">the</span> <span class="word trans-in onscreen" style="transition-delay: 0.24s;">agenda</span> <span class="word trans-in onscreen" style="transition-delay: 0.27s;">for</span> <span class="word trans-in onscreen" style="transition-delay: 0.3s;">Asda</span> <span class="word trans-in onscreen" style="transition-delay: 0.33s;">particularly</span> <span class="word trans-in onscreen" style="transition-delay: 0.36s;">with
@karlcow
karlcow / make-post.py
Last active May 1, 2020 14:44
pre-html pour ymir
from datetime import datetime
from glob import glob
import locale
import re
from textwrap import dedent
import mistune
from PIL import Image