Skip to content

Instantly share code, notes, and snippets.

View hsquareweb's full-sized avatar

Hassan Elhassan hsquareweb

View GitHub Profile
@hsquareweb
hsquareweb / header.html
Created March 26, 2012 22:03
Apple Touch Icons, Windows Icons, and Splash Screens
<link rel="shortcut icon" href="/images/favicon.ico"/>
<!-- Apple Touch Icons -->
<link rel="apple-touch-icon" href="/images/touch-icon-57.png" sizes="57x57"/>
<link rel="apple-touch-icon" href="/images/touch-icon-72.png" sizes="72x72"/>
<link rel="apple-touch-icon" href="/images/touch-icon-76.png" sizes="76x76"/>
<link rel="apple-touch-icon" href="/images/touch-icon-114.png" sizes="114x114"/>
<link rel="apple-touch-icon" href="/images/touch-icon-120.png" sizes="120x120"/>
<link rel="apple-touch-icon" href="/images/touch-icon-144.png" sizes="144x144"/>
<link rel="apple-touch-icon" href="/images/touch-icon-152.png" sizes="152x152"/>
@hsquareweb
hsquareweb / script.js
Created August 14, 2012 17:33
jQuery: Remove Empty "p" Tags
//remove empty p tags
$("p").filter(function () {
return $.trim($(this).html()) == '';
}).remove();
@hsquareweb
hsquareweb / side-nav.php
Created June 5, 2012 21:51
WP: Display children of parent page
<div class="side-nav">
<?php
if($post->post_parent) {
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
} else {
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
}
if ($children) { ?>
<ul>
<?php echo $children; ?>
@hsquareweb
hsquareweb / gist:6705149
Created September 25, 2013 19:56
JS: GA Event Tracking
//GOOGLE EVENTS TRACKING
var track = function(category, name, value) {
// console.log(category);
// console.log(name);
// console.log(value);
// return;
if (window._gaq) {
window._gaq.push(["_trackEvent", category, name, value]);
}
};
@hsquareweb
hsquareweb / gist:4111243
Created November 19, 2012 15:23
WP: Facebook Open Graph Sharing
<!-- Make the content easily recognizable by social networks, we can use the Open Graph (http://ogp.me) spesification so when somebody shares our content, the social network can show accurate information about the page that is shared. -->
<!-- Add to functions.php -->
function opengraph_for_posts() {
if ( is_singular() ) {
global $post;
setup_postdata( $post );
$og_type = '<meta property="og:type" content="article" />' . "\n";
$og_title = '<meta property="og:title" content="' . esc_attr( get_the_title() ) . '" />' . "\n";
$og_url = '<meta property="og:url" content="' . get_permalink() . '" />' . "\n";
@hsquareweb
hsquareweb / index.html
Created December 12, 2013 00:13
Collapsable/Toggle Links
<ul class="collapse_list">
<li><a href="#" data-toggle="collapse" data-target="#one">One</a></li>
<li><a href="#" data-toggle="collapse" data-target="#two">Two</a></li>
</ul>
<div class="collapse_content">
<div id="one">
<p>Content for div one</p>
</div>
@hsquareweb
hsquareweb / functions.php
Last active November 13, 2017 11:21
Defer parsing of JS to speed up WordPress site.
<?php
//Defer parsing of JS to speed up loading pages
if (!(is_admin() )) {
function defer_parsing_of_js ( $url ) {
if ( FALSE === strpos( $url, '.js' ) ) return $url;
if ( strpos( $url, 'jquery.js' ) ) return $url; //excluding js file
return "$url' defer='defer";
}
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
}
@hsquareweb
hsquareweb / terminal.txt
Created July 25, 2017 18:51
Mac Terminal Tricks
//Autohide Dock Speed
$ defaults write com.apple.dock autohide-delay -float 0; defaults write com.apple.dock autohide-time-modifier -float 0.5
$ killall Dock
//Add spacers to your Dock
$ defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
$ killall Dock
//Changing screenshots from the default png to jpg format
$ defaults write com.apple.screencapture type jpg
@hsquareweb
hsquareweb / .htaccess
Last active June 7, 2017 20:26
.htaccess - WP Performance Score Booster Plugin Settings
## BEGIN GZIP Compression ##
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
@hsquareweb
hsquareweb / .htaccess
Last active April 29, 2017 07:58
Cache-Control - HTTP headers for static resources. Read more at https://varvy.com/pagespeed/cache-control.html
# Cache-Control - HTTP headers for static resources
<IfModule mod_headers.c>
# One year for image and video files
<filesMatch ".(jpg|jpeg|png|gif|ico|mp4|webm)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
# One month for css and js
<filesMatch ".(css|js)$">
Header set Cache-Control "max-age=2628000, public"