Skip to content

Instantly share code, notes, and snippets.

@laurent22
laurent22 / javascript_warnings.md
Last active Mar 19, 2021
How many warnings should your JavaScript app have?
View javascript_warnings.md

How many warnings should your JavaScript app have?

JavaScript warnings are these messages being displayed in yellow or red in your JavaScript console or terminal. They make no sense at all in general but they are a good indication of the health of your app. The points below will give you a general idea of how many warnings you should expect in your app:

  • 0 warnings: the app is not working at all

  • 5 warnings: app is probably starting but crashing soon after - try to find why it crashes. You'd think you could read the warnings to learn why it doesn't work, but that's not what warnings are for.

  • 50 warnings: That's the soft spot - most likely everything's running smoothly

View gendata.js
const daysPerMonth = [
31,
28,
31,
30,
31,
30,
31,
31,
30,
@laurent22
laurent22 / strange regex
Last active Mar 19, 2018
strange regex
View 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ÈÉẺẼẸÊỀẾỂỄỆËĚĒĘ]
View 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 / levenshteinDistance.go
Last active Nov 22, 2018
Golang function to calculate Levenshtein distance between two strings. Adapted from Wikipedia article.
View levenshteinDistance.go
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 / extractBaseUrl
Created Jul 15, 2013
Extracts base URL from location of current document.
View extractBaseUrl
// 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 Dec 15, 2015
Fake Javascript console to avoid errors in browsers that don't support the feature.
View dummyconsole.js
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(){};
}
View Default (Linux).sublime-keymap
[
{ "keys": ["ctrl+shift+x"], "command": "tidy_xml" },
{ "keys": ["ctrl+shift+j"], "command": "prettify_json" }
]