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 / 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 / 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 / gist:06e5806ac8b8a3e47520
Created June 19, 2015 17:48
Register thumbnail size only for specific post type (WP)
function set_different_post_type_sizes()
{
if (!empty($_REQUEST['post_id']) && ctype_digit($_REQUEST['post_id'])) {
if ('pedagogues' == get_post_type($_REQUEST['post_id'])) {
add_image_size('pedagogues-normal', 207, 250, true);
}
if ('slider' == get_post_type($_REQUEST['post_id'])) {
add_image_size('slider-normal', 891, 310, true);
}
@probil
probil / gist:b1ee5098493634f5292c
Created June 12, 2015 13:48
convert all pdf files in dir to jpg (imagemagic required)
for i in `ls *.pdf`; do convert "$i" "$i".jpg; done
@probil
probil / send_request.php
Last active October 1, 2015 13:25
Function send POST or GET request with data to any url
/**
* Function send GET request to server
* @param $request_url string Server url
* @param $data_array array Assoc array with data
* @return bool Status
*/
function sendRequest($request_url,$data_array){
// use key 'http' even if you send the request to https://...
$options = array(
@probil
probil / array_diff_assoc_recursive.php
Created March 16, 2015 10:39
Return recursive difference of 2 multidimensional arrays
function array_diff_assoc_recursive($array1, $array2)
{
foreach($array1 as $key => $value) {
if(is_array($value)) {
if(!isset($array2[$key])) {
$difference[$key] = $value;
}
elseif(!is_array($array2[$key])) {
$difference[$key] = $value;
}
@probil
probil / wp-config.php
Created March 11, 2015 08:43
separate local and server WP config
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, and ABSPATH. You can find more information by visiting
* {@link http://codex.wordpress.org/Editing_wp-config.php Editing wp-config.php}
* Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
@probil
probil / AdvancedFormSerialization.js
Last active May 14, 2018 21:52
Usefull function to serialize form inputs including input[type=file]
//USAGE: $("#form").serializefiles();
(function($) {
$.fn.serializefiles = function() {
var obj = $(this);
/* ADD FILE TO PARAM AJAX */
var formData = new FormData();
$.each($(obj).find("input[type='file']"), function(i, tag) {
$.each($(tag)[0].files, function(i, file) {
formData.append(tag.name, file);
});
@probil
probil / gist:70979eefb6c90f349641
Created March 4, 2015 10:54
String formatter with {0}/{1} for js
/** String formatter allows to do like this
/* "{0} is dead, but {1} is alive! {0} {2}".format("ASP", "ASP.NET")
**/
if (!String.prototype.format) {
String.prototype.format = function() {
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined' ? args[number] : match;
});
};
@probil
probil / is_url_exists.php
Last active August 29, 2015 14:16
Is remote url exists function
function is_url_exist($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($code == 200){
$status = true;
}else{
$status = false;