Skip to content

Instantly share code, notes, and snippets.

View hsquareweb's full-sized avatar

Hassan Elhassan hsquareweb

View GitHub Profile
@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 / 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 / .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"
@hsquareweb
hsquareweb / gravity-forms-email-validator.php
Last active March 8, 2017 15:11
Gravity Forms: Email Domain Validator. This snippets allows you to exclude a list of invalid domains or include a list of valid domains for your Gravity Form Email fields. Include inside functions.php file. Read more at https://gravitywiz.com/banlimit-email-domains-for-gravity-form-email-fields/
<?php
/**
* Gravity Wiz // Gravity Forms // Email Domain Validator
*
* This snippets allows you to exclude a list of invalid domains or include a list of valid domains for your Gravity Form Email fields.
*
* @version 1.4
* @author David Smith <david@gravitywiz.com>
* @license GPL-2.0+
* @link http://gravitywiz.com/banlimit-email-domains-for-gravity-form-email-fields/
<?php
function custom_facetwp_pager( $output, $params ) {
$output = '';
$page = (int) $params['page'];
$total_pages = (int) $params['total_pages'];
// Only show pagination when > 1 page
if ( 1 < $total_pages ) {
@hsquareweb
hsquareweb / extras.php
Created January 13, 2017 23:05
Adding page and ancestor slugs to body class
//Page Slug Body Class
function add_slug_body_class( $classes ) {
global $post;
#Post
if ( isset( $post ) ) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
#Ancestors
@hsquareweb
hsquareweb / credits.txt
Last active December 14, 2016 15:38
Tabs
How tabs should work by
https://remysharp.com/2016/12/11/how-tabs-should-work
- Navigable available without JavaScript
- Anchor links that are, clickable, have block layout, have their href pointing to the id of the panel element, uses correct cursor (ie. cursor: pointer).
- Since tabs are clickable, the user can open in a new tab/window and the page correctly loads with the right tab open.
- Right clicking (and shift-clicking) doesn't cause the tab to be selected.
- Browser native back/forward button correctly changes the state of the selected tab (think - about it working exactly as if there was no JavaScript in place).
Final version: http://output.jsbin.com/lorovu/
@hsquareweb
hsquareweb / test.js
Last active December 12, 2016 20:26
FacetWP - Change arrows for FacetWP pagination
(function($) {
$(document).on('facetwp-loaded', function() {
$('.facetwp-page.first-page').html('First');
$('.facetwp-page.last-page').html('Last');
});
})(jQuery);
@hsquareweb
hsquareweb / gulpfile.js
Created November 16, 2015 20:13 — forked from torgeir/gulpfile.js
Example gulpfile.js
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),