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 / jsbin.yemiwo.css
Created April 13, 2014 12:33
Simple method to create row with description that slide out when you click on it.
.desc-row td{
margin: 0 !important;
padding: 0 !important;
border: 0 !important;
}
.description{
padding: 5px 8px;
border-bottom: 1px solid #ddd;
}
.table-row{
@probil
probil / bg-to-full-height.css
Last active August 29, 2015 14:05
Simple code to position your background to true bottom of page (without it browser place your background to bottom of screen)
html {
min-height: 100%;
height: auto;
}
body{
background: url("../img/bg-top.png"), url("../img/bg-middle.png"), url("../img/bg-bottom.png");
background-repeat: no-repeat,no-repeat, no-repeat;
background-position: top center, center center, bottom center;
}
@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;
@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 / 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 / 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 / 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 / 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 / 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 / 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);
}