Skip to content

Instantly share code, notes, and snippets.

View fahdi's full-sized avatar

Fahad Murtaza fahdi

View GitHub Profile
@fahdi
fahdi / date_arithmetic.php
Created July 18, 2014 00:43
Some date arithmetic code I wrote nearly a decade ago. Use at your own risk!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
echo date("M-d-Y", mktime(0, 0, 0, 12, 32, 1997))."<br/>";
@fahdi
fahdi / frontpage.php
Created July 28, 2014 09:48
Advanced custom fields sorting
<?php
if ( have_rows( 'repeater_field', $order_id ) ) :
while ( have_rows( 'repeater_field', $order_id ) ) : the_row();
$type = get_sub_field( 'type', $order_id );
if( $type === 'tekst' ): ?>
<div id="customerMessageTxt">
<?php the_sub_field($type, $order_id); ?>
</div>
<?php
$terms = get_terms('focus15', array(
'exclude' => array(16, 20, 22, 25, 27, 28, 30, 4, 33 ), //* Enter ID's of parent categories to exclude from list
'hide_empty' => 0 ) );
if($terms)
{
echo '<ul>';
foreach($terms as $term)
{
ps xmo rss=,pmem=,comm= | while read rss pmem comm; ((n++<5)); do
size="$[rss/1024]";
short=$[4-${#size}];
size="(${size}M)";
i=0;
while ((i++ < short)); do size=" $size"; done;
pmem="${pmem%%.*}"
if (($pmem >= 20)); then color=$'\e[31m';
@fahdi
fahdi / index.php
Created January 6, 2015 13:17
Error reporting: Optionally, when using Apache, you can use the APPLICATION_ENV setting in your VirtualHost to let PHP output all its errors to the browser. This can be useful during the development of your application. Edit index.php from the zf2-tutorial/public/ directory and change it to the following:
<?php
/**
* Display all errors when APPLICATION_ENV is development.
*/
if ($_SERVER['APPLICATION_ENV'] == 'development') { error_reporting(E_ALL); ini_set("display_errors", 1);
/**
* This makes our life easier when dealing with paths. Everything is relative
* to the application root now.
*/
chdir(dirname(__DIR__));
@fahdi
fahdi / custom_posts_in_custom_page_template.php
Created February 1, 2015 19:58
Wordpress Custom Post types Paging in Custom Page templates
<?php
/*
*Template Name: Specials and Events
*/
get_header();
?>
<div class="blog-list">
<div class="container">
<div class="row">
<div class="col-md-9">
<?php
add_action('nav_menu_css_class', 'add_current_nav_class', 10, 2 );
function add_current_nav_class($classes, $item) {
// Getting the current post details
global $post;
// Getting the post type of the current post
@fahdi
fahdi / table.cpp
Created February 18, 2015 08:53
Table Printing
#include<iostream>
using namespace std;
int main(void)
{
cout << "A multiplication table:" << endl
<< " 1\t2\t3\t4\t5\t6\t7\t8\t9" << endl
<< "" << endl;
for(int c = 1; c < 10; c++)
{
@fahdi
fahdi / xml-feed-datatable.js
Last active August 29, 2015 14:17
XML feeds datatable
// XML feeds table
if($('#feed-list-table').length) {
var pfDataTableDefaults = $.extend({}, pfDataTableDefaults, {
"columns": [
{"data": "id"},
{"data": "broker_name"},
{"data": "last_check"},
{"data": "last_change"},
{"data": "feed_url"},
{"data": "validation"},
@fahdi
fahdi / ten-columns.less
Created March 18, 2015 09:06
Create 10 column layout with bootstrap
/*
* Special grid for ten columns,
* using its own scope
* so it does not interfere with the rest of the code
*
* Just update the path for variables.less and mixons.less files and compile the less file
*/
& {
@import (multiple) "../../vendor/bootstrap/less/variables.less";