Skip to content

Instantly share code, notes, and snippets.

View hsquareweb's full-sized avatar

Hassan Elhassan hsquareweb

View GitHub Profile
@hsquareweb
hsquareweb / _gradients.css.scss
Last active December 25, 2015 19:49 — forked from thbar/_gradients.css.scss
Gradient Mixin
@mixin gradient($from, $to) {
/* fallback/image non-cover color */
background-color: $from;
/* Firefox 3.6+ */
background-image: -moz-linear-gradient($from, $to);
/* Safari 4+, Chrome 1+ */
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from($from), to($to));
@hsquareweb
hsquareweb / content.php
Created October 15, 2013 16:29
WP: Number of comments
<a href="<?php comments_link(); ?>">+Comments (<?php comments_number('0', '1', '%'); ?>)</a>
@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:6541120
Created September 12, 2013 17:31
WP: Parent Titles
//Pull the section title "parent" except the homepage.
<?php if (!is_front_page()) { ?>
<h1 class="section-title inner">
<?php
if (is_page()) {
$parent_title = get_the_title($post->post_parent);
echo $parent_title;
}
elseif ( (is_singular('latest-news') || is_post_type_archive('latest-news')) ) {
@hsquareweb
hsquareweb / gist:6355447
Created August 27, 2013 15:57
JS: Cookie
// Include script after the jQuery library
// https://github.com/carhartl/jquery-cookie
// <script src="/path/to/jquery.cookie.js"></script>
//set cookies
$("#div").toggle(function() { //create div toggle
$("#div").slideUp("slow"); //create effect
$.cookie('cookie_name', 'value', {expires: 7}); //set cookie expire in 7 days
},
function () { //continue the toggle
@hsquareweb
hsquareweb / gist:5885553
Created June 28, 2013 15:28
WP: Pull Specific Page
<?php $recent = new WP_Query("page_id=87"); while($recent->have_posts()) : $recent->the_post();?>
<?php the_post_thumbnail('full'); ?>
<div>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
</div>
<?php endwhile; ?>
@hsquareweb
hsquareweb / sample.html
Last active August 30, 2016 15:44
JS: Split Lists in Columns
<ul class="split-list">
<li>list Item 1</li>
<li>list Item 2</li>
<li>list Item 3</li>
<li>list Item 4</li>
<li>list Item 5</li>
<li>list Item 6</li>
<li>list Item 7</li>
<li>list Item 8</li>
<li>list Item 9</li>
@hsquareweb
hsquareweb / _variables.scss
Created April 2, 2013 23:40
SASS: YUI Fonts Conversions
/* YUI Fonts Conversions - based on 14px */
$size10: percentage(10px / 14px);
$size11: percentage(11px / 14px);
$size12: percentage(12px / 14px);
$size13: percentage(13px / 14px);
$size14: percentage(14px / 14px);
$size15: percentage(15px / 14px);
$size16: percentage(16px / 14px);
$size17: percentage(17px / 14px);
$size18: percentage(18px / 14px);
@hsquareweb
hsquareweb / redirect.php
Created February 6, 2013 15:10
WP: Redirect To First Child Page
<?php
/*
Template Name: Redirect To First Child Page
*/
$pagekids = get_pages("child_of=".$post->ID."&sort_column=menu_order");
if ($pagekids) {
$firstchild = $pagekids[0];
wp_redirect(get_permalink($firstchild->ID));
} else {
// Do whatever templating you want as a fall-back.
@hsquareweb
hsquareweb / scripts.js
Created December 26, 2012 22:52
JS: Modernizr Box Sizing For IE7
//MODERNIZR BOX SIZING FIX FOR IE7
Modernizr.addTest("boxsizing", function() {
return Modernizr.testAllProps("boxSizing") && (document.documentMode === undefined || document.documentMode > 7);
});
$(function(){
if(!Modernizr.boxsizing){
$('.col1, .col2').each(function(){
var fullW = $(this).outerWidth(),
actualW = $(this).width(),
wDiff = fullW - actualW,