Skip to content

Instantly share code, notes, and snippets.

View probil's full-sized avatar
:shipit:
Exploring

Max Liashuk probil

:shipit:
Exploring
View GitHub Profile
@addyosmani
addyosmani / minify-detect.js
Created August 15, 2017 00:20
Detecting unminified code
// https://hg.mozilla.org/mozilla-central/rev/2f9043292e63
// Used to detect minification for automatic pretty printing
const SAMPLE_SIZE = 30; // no of lines
const INDENT_COUNT_THRESHOLD = 20; // percentage
function isMinified (str) {
let isMinified;
let lineEndIndex = 0;
let lineStartIndex = 0;
let lines = 0;
@probil
probil / imprort_db.sh
Last active June 30, 2023 09:44
Import mysql database with progress bar and log on error
# import (with pv)
pv db_dump.sql | mysql -u <user> -p'<password>' <database> > error.log
# import (without pv)
mysql -u <user> -p'<password>' <database> < db_dump.sql > error.log
# export
mysqldump -u <user> -h <host> -p'<password>' <database> | pv > db_dump.sql
# export with progress
@daniellmb
daniellmb / onerror.js
Last active July 12, 2020 13:30
Automagically look up JavaScript errors on Stack Overflow ;-)
window.onerror = function(message) {
top.location.href = 'http://stackoverflow.com/search?q=' +
encodeURIComponent(message + ' [js]');
};
@kentliau
kentliau / JSONView.css
Last active July 6, 2019 21:31
JSONView dark theme (Google Chrome Extension)
body {
white-space: pre;
font-family: 'Ubuntu Mono';
font-size: 16px;
line-height:20px;
color: white;
background-color: #2B2A27;
}
.property {
@thomasfr
thomasfr / Git push deployment in 7 easy steps.md
Last active July 3, 2024 02:22
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
@GianlucaGuarini
GianlucaGuarini / post-merge
Last active August 22, 2023 20:54 — forked from sindresorhus/post-merge
Git hook that gets triggered after any 'git pull' whenever one of the files specified has changed. Useful to update any web application dependency using bower npm or composer
#/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# forked by Gianluca Guarini
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep -E --quiet "$1" && eval "$2"
}
@sindresorhus
sindresorhus / post-merge
Last active May 2, 2024 03:18
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"