Skip to content

Instantly share code, notes, and snippets.

View ahmu83's full-sized avatar
🎯
Focusing

Ahmad Karim ahmu83

🎯
Focusing
View GitHub Profile
@ahmu83
ahmu83 / jQuery: add ie version number to HTML class attribute
Created April 22, 2014 14:22
jQuery: add ie version number to HTML class attribute
if(jQuery.browser.msie){
var version = jQuery.browser.version;
switch(version){
case "6.0":
jQuery("html").addClass("ie ie6 lte10 lte9 lte8 lte7");
break;
case "7.0":
jQuery("html").addClass("ie ie7 lte10 lte9 lte8 lte7");
break;
case "8.0":
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@ahmu83
ahmu83 / jQuery: preload an image
Created May 13, 2014 19:33
jQuery: preload an image
var src = "http://placekitten.com/500/500",
img = $("<img />");
img.hide().attr("src", src);
img.load(function() {
// Image is loaded
});
$.ajax({
url: '/URL/',
type: 'POST', /* POST/GET */
dataType: 'json', /* xml/html/script/json/jsonp */
data: form_data,
crossDomain: true,
success: function(data, textStatus, xhr) {
/* success */
},
error: function(xhr, textStatus, errorThrown) {
@ahmu83
ahmu83 / print_are.php
Last active May 13, 2021 19:49
Pretty Version of PHP's print_r Function
<?php
/**
* A pretty version of "print_r" function
*
* @param Array|stdClass $obj
* @param string $title Optional.
* @param bool $collapse Optional.
* @return string Type returned.
*/
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==">
@ahmu83
ahmu83 / US_States_and_Cities.json
Created July 20, 2016 16:50
List of US States and Cities in JSON format.
{
"New York": [
"New York",
"Buffalo",
"Rochester",
"Yonkers",
"Syracuse",
"Albany",
"New Rochelle",
"Mount Vernon",
@ahmu83
ahmu83 / send-woocommerce-order-emails.php
Last active October 24, 2017 17:45
Send WooCommerce Order Emails Against an order id and email id
<?php
/**
* Send WooCommerce order email(s)
*
* @param integer $order_id WooCommerce order id.
* @param string|array $email_id The id of the email or an array of the email ids that need to send.
* @return bool Type returned Will return true if the email id provided is sent successfully.
*/
function send_wc_order_email($order_id, $email_id) {
@ahmu83
ahmu83 / LocalValetDriver.php
Last active February 16, 2019 17:20
This is a valet driver which changes the root directory of a valet site using a file .rootdir which contains the directory and the entry file. i.e, /www/home.php
<?php
class LocalValetDriver extends LaravelValetDriver {
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
@ahmu83
ahmu83 / wp-env.php
Last active October 30, 2019 19:34
LOCAL & PRODUCTION specific variables for a wordpress instance
<?php
/**
* @author Ahmad Karim <hello@ahmadkarim.com>
*
* DEV & PROD specific variables
* for WordPress when working with
* LOCAL & LIVE instances at the same time
*/
$localhosts = array('127.0.0.1', '::1');