Skip to content

Instantly share code, notes, and snippets.

View hanigamal's full-sized avatar
🎯
Focusing at office

Hani Gamal hanigamal

🎯
Focusing at office
View GitHub Profile
@hanigamal
hanigamal / gist:5788033
Created June 15, 2013 12:52
Pure JS undo
/*
/**
* @constructor
*/
Commands = function() {
this.undoStack = [];
this.redoStack = [];
};
/**
@hanigamal
hanigamal / rmDuplicates.func.js
Created June 15, 2013 12:54
// Remove duplicates from DOM (not done yet)
// Remove duplicates from DOM (not done yet)
function remDuplicates() {
var seen = {};
$('td.group').each(function() {
var txt = $(this).text();
if (seen[txt])
$(this).empty();
else
seen[txt] = true;
});
<?php
//Basic True / False Declaration
$is_admin = ($user['permissions'] == 'admin' ? true : false);
//Conditional Welcome Message
echo 'Welcome '.($user['is_logged_in'] ? $user['first_name'] : 'Guest').'!';
//Conditional Items Message
echo 'Your cart contains '.$num_items.' item'.($num_items != 1 ? 's' : '').'.';
//Conditional Error Reporting Level
error_reporting($WEBSITE_IS_LIVE ? 0 : E_STRICT);
//Conditional Basepath
function get_day_name($timestamp) {
$date = date('d/m/Y', $timestamp);
if($date == date('d/m/Y')) {
$day_name = 'Today';
} else if($date == date('d/m/Y',now() - (24 * 60 * 60))) {
$day_name = 'Yesterday';
}
return $date;
}
print date('G:i:s', $last_access).' '.get_day_name($last_access);
<?php
$path = '/home/someuser/products/data.tar.gz'; // the file made available for download via this PHP file
$mm_type="application/octet-stream"; // modify accordingly to the file type of $path, but in most cases no need to do so
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: " . $mm_type);
#!/bin/sh
SHORTCUT="[Desktop Entry]
Name=Sublime Text 2
Comment=Edit text files
Exec=/usr/local/sublime-text-2/sublime_text
Icon=/usr/local/sublime-text-2/Icon/128x128/sublime_text.png
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Utility;TextEditor;"
@hanigamal
hanigamal / wp-query-ref.php
Created August 14, 2013 02:13
WordPress Query Comprehensive Reference
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/query.php
*/
$args = array(
@hanigamal
hanigamal / wp-install.sh
Created August 14, 2013 02:15
WordPress Commandline Local Install
#!/bin/bash
#
# WP Commandline Local Install, by Brian Richards (@rzen)
#
# Creates a new directory, downloads WordPress, creates a database, sets up wp-config,
# optionally empties wp-content, and deletes other misc files. This compliments my local
# dev setup, outlined here: http://rzen.net/development/local-develoment-in-osx/
#
# Credit:
# Based on WPBuildr (https://github.com/AaronHolbrook/wpbuildr/). Props to Aaron Holbrook
@hanigamal
hanigamal / Google-search-url-cleaner.js
Created August 20, 2013 01:46
Google search URL cleaner ;)
javascript:(function(){
var links=document.querySelectorAll('a.l'),
count=links.length;
while(count--){
links[count].onmousedown=null;
if((/url=/i).test(links[count].href)){
links[count].href=decodeURIComponent(links[count].href.match(/url=([a-z0-9\-+%._]+)&/i)[1].replace(/\+/g, ' '));
}
};
})()
/* --CSS Reseter-- */
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, dialog, figure, header, footer, hgroup, menu, nav, section, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-weight: inherit;
font-style: inherit;