Skip to content

Instantly share code, notes, and snippets.

View justclint's full-sized avatar

justclint justclint

View GitHub Profile
function getUserIP()
{
// Get real visitor IP behind CloudFlare network
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
$_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
// -nm = no mangle
// -o = output filename
uglifyjs -nmo script.min.js script.js
function screen_size() {
if (window.matchMedia('(max-width: 991px)').matches) {
$('body').removeClass('view-desktop');
$('body').addClass('view-mobile');
} else {
$('body').removeClass('view-mobile');
$('body').addClass('view-desktop');
}
}
function clean_url($string) {
// Make lower case.
$string = strtolower( $string) ;
// Make alphanumeric. Remove all characters.
$string = preg_replace("/[^a-z0-9_\s-]/", "", $string);
// Clean multiple dashes and whitespace.
$string = preg_replace("/[\s-]+/", " ", $string);
//Convert whitespaces and underscore to dash.
$string = preg_replace("/[\s_]/", "-", $string);
return $string;
%windir%\system32\bash.exe -cur_console:p
$args = array(
'headers' => array(
'Authorization' => 'Basic ' . base64_encode( YOUR_USERNAME . ':' . YOUR_PASSWORD )
)
);
wp_remote_request( $url, $args );
// download min from http://detectmobilebrowsers.com/
// use like
if(jQuery.browser.mobile) {
$("body").addClass("screen-mobile");
}
else {
$("body").addClass("screen-desktop");
}
git fetch, git checkout develop, git pull origin develop, git checkout your-feature, git merge develop
@justclint
justclint / convert files dos to unix
Last active June 14, 2016 17:59
convert dos to unix files recursively
#fromdos -- install tofrodos
find . -type f -exec fromdos {} \;
#dos2unix
find . -type f -exec dos2unix {} \;
// show php errors
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
// var dump
print '<pre>';
var_dump(get_defined_vars());
print '</pre>';