Skip to content

Instantly share code, notes, and snippets.

View matteodelabre's full-sized avatar

Mattéo Delabre matteodelabre

View GitHub Profile
@matteodelabre
matteodelabre / jquery.smooth-hash.md
Last active November 21, 2022 12:31
jQuery plugin that adds transition on anchor click

Smooth hash

jQuery plugin that adds scrolling transition on click on anchor link.

How to use:

$(document).smoothHash();
@matteodelabre
matteodelabre / debounce.js
Last active August 29, 2015 14:00
AMD module that enables to debounce functions, i.e to limit them to be called once every X seconds
/*globals define */
define(function () {
'use strict';
/**
* debounce module
* This module is freely usable, without any license
* Based on John Resig's work
*
@matteodelabre
matteodelabre / jquery.tagger.md
Last active August 29, 2015 14:04
jQuery plugin that enables to easily add tags into an input

Tagger

jQuery plugin that enables to easily add tags into an input, graciously degrading when JS is disabled.
Can filter tags content but still need server-side check.

NOTE: you need to add a js class to the body element when JS is enabled for this plugin to work.

How to use:

@matteodelabre
matteodelabre / jquery.crossfade.md
Last active August 29, 2015 14:04
jQuery plugin that permits elements crossfading

Crossfade

jQuery plugin that permits crossfading between HTML elements. Mostly for images but can also work for other types, such as divs that contain images in background or in subtree.

How to use:

$('.element-containing-elements-to-crossfade').crossfade();
@matteodelabre
matteodelabre / smtp-client-1.txt
Last active October 27, 2015 11:19
Exchange between email client and email server using SMTP
-- Connecté à exemple.fr:25
S: 220 exemple.fr ESMTP Postfix (Debian/GNU)
C: HELO exemple.fr
S: 250-exemple.fr
C: MAIL FROM: moi@exemple.fr
S: 250 2.1.0 Ok
C: RCPT TO: jean.dupont@test.net
S: 250 2.1.5 Ok
C: DATA
S: 354 End data with <CR><LF>.<CR><LF>
@matteodelabre
matteodelabre / kleene.js
Last active May 2, 2019 16:00
Fixed point in JavaScript
// s-m-n
const s = "(f, x) => `y => (${f})(${x}, y)`";
// fixed point
const e = q => {
const n = `(x, y) => (${q})((${s})(x, x), y)`;
const p = eval(`(${s})(n, n)`);
return `(${p})(0)`;
};
@matteodelabre
matteodelabre / remarkable-qemu-vm.md
Last active December 14, 2023 09:33
reMarkable QEMU VM
  • Build Linux (I used 5.4.161) with imx_v6_v7 config
apt install bison bc lzop libssl-dev
make O=imx7 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- imx_v6_v7_defconfig
make O=imx7 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
  • Download rM update file (I used 2.10.0.295)
  • Create qcow2 disk
@matteodelabre
matteodelabre / 1-monitor_wlan0_ip.sh
Last active December 3, 2021 03:30
Display wlan0 IP address on screen on reMarkable
#!/usr/bin/env bash
# /home/root/monitor_wlan0_ip.sh
iface=wlan0
get_dbus_iface() {
dbus-send --system --dest=fi.w1.wpa_supplicant1 --print-reply=literal \
/fi/w1/wpa_supplicant1 \
fi.w1.wpa_supplicant1.GetInterface \
"string:$iface" \
| sed 's/^ *//g'
@matteodelabre
matteodelabre / xpathselect.js
Created January 13, 2023 04:26
XPath select
const xpathSelect = (expr) => {
const iterator = document.evaluate(expr, document);
const result = [];
let current = iterator.iterateNext();
while (current) {
result.push(current);
current = iterator.iterateNext();
}
import random
from itertools import product
from collections import Counter
suits = ["♡", "♣", "♢", "♠"]
values = ["5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"]
def deal():
hands = list(product(suits, values))
random.shuffle(hands)