Skip to content

Instantly share code, notes, and snippets.

View andreubotella's full-sized avatar

Andreu Botella andreubotella

View GitHub Profile
@andreubotella
andreubotella / weird_filenames_writer.py
Last active March 4, 2021 22:27
Writer of files with weird filenames
#!/usr/bin/env python3
# Replace this
BASE_PATH = "/home/abotella/filenames_test/".encode("utf-8")
FILENAMES = [
# Basic UTF-8 test (useless on its own, meant to check that multiple files
# work together)
"ûtf-∞".encode("utf-8"),
# UTF-8 starting with BOM
@andreubotella
andreubotella / bbContextMenuDetails.js
Last active January 27, 2022 13:44
bbContextMenu details
// If a text field or textarea's contents are selected, Chromium treats the
// document's selection as if it was a caret selection immediately before the
// text field. This function detects that and returns the text field.
function followedByTextField(range) {
if (!range.collapsed) return null;
const node = range.startContainer.childNodes[range.startOffset];
// Only input and textarea elements have the selectionStart property, and it's
// only non-null for text fields.
// Double-equals to match null or undefined.
if (node?.selectionStart == null) {
@andreubotella
andreubotella / activate.sh
Created February 19, 2022 20:17
My Chromium virtualenv (note: needs goma)
#!/bin/bash
# If this file isn't being run as a source, source it.
if (return 0 2>/dev/null); then
deactivate () {
goma_ctl ensure_stop
export PATH="$OLD_PATH"
unset OLD_PATH
#include <iostream>
#include <wordexp.h>
using namespace std;
char hexDigit(int digit) {
if (digit >= 0 && digit <= 9) {
return '0' + digit;
} else if (digit >= 10 && digit <= 15) {
return 'A' + digit - 10;