Skip to content

Instantly share code, notes, and snippets.

View thomastheyoung's full-sized avatar

Thomas LE JEUNE thomastheyoung

  • San Francisco, California
View GitHub Profile
/**
* Generates a non-cryptographic hash from a string using the FNV-1a algorithm.
* Returns the hash as a hexadecimal string.
* Note: This is for non-cryptographic purposes only.
*/
export function FNVHash(input: string): string {
let hash = 2166136261; // FNV offset basis
for (let i = 0; i < input.length; i++) {
hash ^= input.charCodeAt(i);
// Math.imul performs 32-bit multiplication which is critical for FNV-1a
@thomastheyoung
thomastheyoung / countries_with_vat.txt
Created March 15, 2016 14:58
Countries with a VAT system
1 Austria AT
2 Belgium BE
3 Brazil BR
4 Bulgaria BG
5 Croatia HR
6 Cyprus CY
7 Czech Republic CZ
8 Denmark DK
9 Estonia EE
10 Finland FI
@thomastheyoung
thomastheyoung / update_git_index.sh
Created November 11, 2015 02:04
When your git is stubborn and stuck with files that don't disappear (even with reset --hard), so you can't change branch: update git indexes so git knows those files didn't change
git ls-files -m | xargs -I {} git update-index --assume-unchanged {}
@thomastheyoung
thomastheyoung / remove_files_pattern.sh
Created March 25, 2015 09:46
remove files matching a certain pattern
find . -type f -name "*conflicted copy*" -delete
@thomastheyoung
thomastheyoung / thumbnails.md
Created September 9, 2014 01:00
Thumbnail calculations

Mobile Web Devices Usage

TL;DR: The final most common thumbnail sizes

133x74 (2.7%)

Samsung GT-S5360 Galaxy Y, Samsung GT-S5830i Galaxy Ace

200x112 (8.6%)

Samsung GT-18190 Galaxy S3 Mini, Nokia Lumia 520, Samsung GT-S7562 Galaxy S Duos, Samsung GT-S7582 Galaxy S Duos 2, Samsung GT-I8262 Galaxy Duos, Samsung GT-S7262 Galaxy Star S7262, Samsung GT-19100 Galaxy S2, Samsung GT-I9082 Galaxy Grand Duos

@thomastheyoung
thomastheyoung / feops 2014.md
Last active October 28, 2015 05:27
Front-End Ops 2014 sum up !
ifconfig | grep -E '([0-9]{1,3}\.){3}[0-9]{1,3}'
@thomastheyoung
thomastheyoung / add_ssh_id_dsa.md
Last active December 25, 2015 20:09
Issue: git ask for password while gitconfig is correctly set Solution: add your private ssh key

Issue

git ask for password while gitconfig is correctly set

Test

$ ssh-add -L
The agent has no identities.

Solution

add your private ssh key

@thomastheyoung
thomastheyoung / review.md
Last active December 5, 2016 23:36
Javascript Templates Comparison: Hogan, dust, doT, underscore

JavaScript Templates Engines

A quick comparison/ benchmark between Hogan, Dust, doT and underscore

Presentation and Readability

Hogan.js

Developed by Twitter (same team as Bootstrap), use exactly the same syntax as Mustache, but more performant and more stuff available server side.

My name is {{ name }}

@thomastheyoung
thomastheyoung / pretty-print-json.sh
Created June 17, 2013 11:51
Pretty-printing JSON and XML on Mac OSX
# Pretty-printing JSON and XML on Mac OSX
python -m json.tool < unformatted.json | less