Skip to content

Instantly share code, notes, and snippets.

Avatar
⛩️
Working from … anywhere

Karl Dubost karlcow

⛩️
Working from … anywhere
View GitHub Profile
@karlcow
karlcow / code.mmd
Last active Oct 6, 2021
Webcompat Flowchart
View code.mmd
flowchart LR
webc(webcompat.com) --> ano{isAnonymous?};
ano -- YES --> placeholder("we are checking…");
ano -- NO --> legalwebb;
webbp --> valid{"isValid? (Bugbug)"};
valid -- YES --> legal{"isLegal? (Human)"};
valid -- NO --> invalid(CLOSED. Invalid);
legal -- YES --> legalwebb("web-bugs");
legalwebb --> repro("isReproducible? (Human)");
repro -- YES --> etp(isETP?);
@karlcow
karlcow / use-case-UA-detection.md
Last active Jul 16, 2021
Compiling use case detections
View use-case-UA-detection.md

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 Apr 7, 2021
code JS demo pour présentation de données. utilisant https://www.chartjs.org/
View weekly.js
// 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);
View nyt.js
(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);
View doublesorting.py
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 Feb 10, 2021
lxml.etree.XMLSyntaxError: Char 0x0 out of allowed range
View error.md

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>'))
View transition.html
<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
pre-html pour ymir
View make-post.py
from datetime import datetime
from glob import glob
import locale
import re
from textwrap import dedent
import mistune
from PIL import Image
View foo.txt
./mach build
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 147, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hashlib.py", line 97, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
@karlcow
karlcow / webcompat-meta-explore.md
Created Jan 15, 2020
Exploration of metadata on webcompat.
View webcompat-meta-explore.md

A current report on webcompat.com

<!-- @browser: Firefox Mobile 68.0 -->
<!-- @ua_header: Mozilla/5.0 (Android 9; Mobile; rv:68.0) Gecko/68.0 Firefox/68.0 -->
<!-- @reported_with: mobile-reporter -->

**URL**: https://www.reddit.com/r/RetroPie/comments/cjcrnk/pi4_overclock_vs_stock_dreamcast/

**Browser / Version**: Firefox Mobile 68.0