This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/node | |
// via http://starwing.net/suddenly_death.html | |
function getByteLength (string) { | |
var r = 0; | |
for (var i = 0; i < string.length; i++) { | |
var c = string.charCodeAt(i); | |
// Shift_JIS: 0x0 ~ 0x80, 0xa0 , 0xa1 ~ 0xdf , 0xfd ~ 0xff | |
// Unicode : 0x0 ~ 0x80, 0xf8f0, 0xff61 ~ 0xff9f, 0xf8f1 ~ 0xf8f3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# to use, save this file as .git/hooks/pre-commit in your git repo | |
# make sure to add execute permissions using: chmod +x .git/hooks/pre-commit | |
command -v imgo >/dev/null 2>&1 || { | |
echo "\033[1mPlease install imgo to reduce images size before commit\033[0m" | |
echo "Install imgo with the following:" | |
echo "\t \033[1mnpm install -g imgo\033[0m" | |
exit 1; | |
} |