Skip to content

Instantly share code, notes, and snippets.

const daysPerMonth = [
31,
28,
31,
30,
31,
30,
31,
31,
30,
@laurent22
laurent22 / levenshteinDistance.go
Last active November 22, 2018 16:06
Golang function to calculate Levenshtein distance between two strings. Adapted from Wikipedia article.
import (
"math"
"strings"
)
func levenshteinDistance(s string, t string) int {
// degenerate cases
s = strings.ToLower(s)
t = strings.ToLower(t)
if (s == t) { return 0 }
@laurent22
laurent22 / strange regex
Last active March 19, 2018 12:17
strange regex
()([t[lÅ[eèéẻẽẹêềếểễệëěēęEÈÉẺẼẸÊỀẾỂỄỆËĚĒĘ]
LÅ[eèéẻẽẹêềếểễệëěēęEÈÉẺẼẸÊỀẾỂỄỆËĚĒĘ]
][a[eèéẻẽẹêềếểễệëěēęEÈÉẺẼẸÊỀẾỂỄỆËĚĒĘ]
[\s]+[eèéẻẽẹêềếểễệëěēęEÈÉẺẼẸÊỀẾỂỄỆËĚĒĘ]
¡[eèéẻẽẹêềếểễệëěēęEÈÉẺẼẸÊỀẾỂỄỆËĚĒĘ]
[eèéẻẽẹêềếểễệëěēęEÈÉẺẼẸÊỀẾỂỄỆËĚĒĘ]
£[eèéẻẽẹêềếểễệëěēęEÈÉẺẼẸÊỀẾỂỄỆËĚĒĘ]
£[eèéẻẽẹêềếểễệëěēęEÈÉẺẼẸÊỀẾỂỄỆËĚĒĘ]
[eèéẻẽẹêềếểễệëěēęEÈÉẺẼẸÊỀẾỂỄỆËĚĒĘ]
¡[eèéẻẽẹêềếểễệëěēęEÈÉẺẼẸÊỀẾỂỄỆËĚĒĘ]
@laurent22
laurent22 / LABY2.BAS
Created October 13, 2017 10:33
LABY2.BAS
80 Position:
'Dessin du premier plan
IF dir = 1 THEN pos$ = LEFT$(piece$, 3)
IF dir = 2 THEN pos$ = RIGHT$(piece$, 3)
IF dir = 3 THEN pos$ = RIGHT$(piece$, 2) + LEFT$(piece$, 1)
IF dir = 4 THEN pos$ = RIGHT$(piece$, 1) + LEFT$(piece$, 2)
IF LEFT$(pos$, 1) = "1" THEN
LINE (10, 10)-(134, 76)
LINE -(134, 274)
LINE -(10, 340)
@laurent22
laurent22 / extractBaseUrl
Created July 15, 2013 11:30
Extracts base URL from location of current document.
// Extracts base URL from location of current document.
function extractBaseUrl() {
// Get URL without query path
var url = [location.protocol, '//', location.host, location.pathname].join('');
// Remove filename if present
var f = url.substr(url.lastIndexOf("/") + 1).toLowerCase();
if (f.indexOf('.html') >= 0 || f.indexOf('.htm') >= 0 || f.indexOf('.php')) {
url = url.substr(0, url.length - f.length);
}
// Add last slash if missing
@laurent22
laurent22 / dummyconsole.js
Last active December 15, 2015 01:29
Fake Javascript console to avoid errors in browsers that don't support the feature.
if (typeof(console) === 'undefined') {
var functionNames = ['info', 'error', 'warn', 'dir', 'trace', 'log', 'assert'];
console = {};
for (var i = 0; i < functionNames.length; i++) console[functionNames[i]] = function(){};
}
[
{ "keys": ["ctrl+shift+x"], "command": "tidy_xml" },
{ "keys": ["ctrl+shift+j"], "command": "prettify_json" }
]