Skip to content

Instantly share code, notes, and snippets.

View hameedullah's full-sized avatar
😄

Hameedullah Khan hameedullah

😄
View GitHub Profile
@ghoseb
ghoseb / factorial.py
Created November 14, 2008 18:58
The evolution of a Python Programmer
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
#!/bin/bash
#
# git-svn-diff originally by (http://mojodna.net/2009/02/24/my-work-git-workflow.html)
# modified by mike@mikepearce.net
# modified by aconway@[redacted] - handle diffs that introduce new files
# modified by t.broyer@ltgt.net - fixes diffs that introduce new files
# modified by m@rkj.me - fix sed syntax issue in OS X
#
# Generate an SVN-compatible diff against the tip of the tracking branch
@franz-josef-kaiser
franz-josef-kaiser / script_deamon.php
Created June 10, 2011 15:59
WordPress Plugin to check your DataBase for injected links
<?php
/**
Plugin Name: AntiScript deamon
Plugin URI: https://github.com/franz-josef-kaiser
Description: Removes script-links to spam sites from your post content after your site got hacked. Please go to <a href="tools.php?page=script_deamon.php">Tools &rarr; Remove Hack</a>. Thank you. Proudly brought to you by <a href="http://example.com">Franz Josef Kaiser</a>.
Version: 0.1
Author: Franz Josef Kaiser
Author URI: https://github.com/franz-josef-kaiser
License: GPL2
WP-Version: Tested in 2.7.1, 2.9.2, 3.0
@markjaquith
markjaquith / disable-plugins-when-doing-local-dev.php
Created June 24, 2011 10:24
Disables specified WordPress plugins when doing local development
<?php
/*
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
@thefuxia
thefuxia / function.extra_comment_callback.php
Created June 29, 2011 19:43
Sample Comment Walker for WordPress
<?php
/**
* Callback for wp_list_comments()
* @param object $comment
* @param array $args
* @param int $depth
* @return void
*/
function extra_comment_callback( $comment, $args, $depth )
{
@bueltge
bueltge / gist:1119715
Created August 2, 2011 06:51
Shortcode for HTML5 Video Tag in WordPress
function html5_video( $atts, $content = NULL ) {
extract( shortcode_atts( array(
"src" => '',
"width" => '',
"height" => ''
), $atts ) );
return '<video src="' . $src . '" width="' . $width . '" height="' . $height . '" controls autobuffer>';
}
add_shortcode( 'video5', 'html5_video' );
Now you can use the following shortcode in your post:
@bueltge
bueltge / gist:1119722
Created August 2, 2011 07:03
Debug Shortcodes
function fb_show_shortcodes( $atts, $content = NULL ) {
extract( shortcode_atts(
array('linebreak'=>''),
$atts
) );
$brackets = array();
$brackets[0] = "/\[/";
$brackets[1] = "/\]/";
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
sudo apt-get update
sudo apt-get upgrade
@hameedullah
hameedullah / suppress-test.php
Created November 18, 2011 08:24 — forked from mikeschinkel/suppress-test.php
Testing suppression of error using @sign
<?php
/*
TESTING:
http://programmers.stackexchange.com/questions/120378/is-error-suppression-acceptable-in-role-of-logic-mechanism/120386#120386
Elapsed Time[µseconds]
Check, Exists :
50000 - Check, Exists : 94718 (user), 342 (system)
EACH - Check, Exists : 1.89436E-6 (user), 6.84E-9 (system)
@taavi
taavi / gist:2757885
Created May 20, 2012 12:16
Function overloading in Python
#!/usr/bin/python
import inspect
from functools import wraps
from collections import defaultdict
# This time, we'll avoid using a class to hold the namespace. We'll just use
# the class that the functions are being defined in.
# AS A BONUS
# This means that it works for module-level functions, not just methods!