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
@probil
probil / gist:312cde6a1ed36e76a9d8
Created June 23, 2015 11:27
upload load file.sql to remote mysql server
mysql -h host -u user_name -pPassword database < file.sql > output.log
@probil
probil / timer.js
Created July 4, 2015 14:04
Simple timer on JS
"use strict";
var Timer = function () {
var _time = 0;
var _interval = {};
return {
/**
* Starts timer
*/
start: function () {
@probil
probil / image_preloader.js
Created July 9, 2015 11:29
Simple image preloader
/**
* Preload images
*
* @param {Array} images
*/
window.preload_images = function (images) {
$(document).ready(function () {
$.each(images, function (index, image_url) {
var image = new Image();
image.src = image_url;
/**
* Hack to show placeholder image if original
* does not exist
* @example
* <img src="<here>" onerror="onImgError(this)"/>
* @param source
* @returns {boolean}
*/
function onImgError(source)
{
@probil
probil / normalize.sh
Created September 7, 2015 13:23
Normalize audio files in dir and subdir
#!/usr/bin/env bash
cd $1
find . type f | grep mp3$ > mp3-files.txt
readarray -t files < mp3-files.txt
INDEX=0
LENGTH=${#files[@]}
@probil
probil / functions.php
Created September 14, 2015 14:28
Timber theme functions.php boilerplate file
<?php
/**
* This theme using Timber as html-template engine
* See more https://github.com/jarednova/timber
*
*/
if (!class_exists('Timber')){
add_action( 'admin_notices', function(){
echo '<div class="error"><p>Timber not activated. Make sure you activate the plugin in <a href="' . admin_url('plugins.php#timber') . '">' . admin_url('plugins.php') . '</a></p></div>';
@probil
probil / make_random_str.js
Created September 25, 2015 17:58
Elegant way to make random string in javascript (1 line of code)
Math.random().toString(36).substring(7);
@probil
probil / testproxy.sh
Created November 16, 2015 12:14
Quick proxy test
wget http://google.com.ua -e use_proxy=yes -e http_proxy=173.234.248.111:3128
@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
#!/bin/bash
# This script will find all *.gif in current directory
# and convert in to max height with aspect ratio and
# apply maximum optimization.
# ============================
# You need to install `gifsicle` first
# Create dir if not exists