Skip to content

Instantly share code, notes, and snippets.

@nabeelio
nabeelio / amazon php example
Created February 24, 2011 01:55
Amazon PHP API Example
include 'amazon.php';
$amz = new AmazonProductLookup('YOUR AWS KEY', 'YOUR SECRET KEY');
@nabeelio
nabeelio / gist:841608
Created February 24, 2011 02:02
How to install php-fpm against Ubuntu's PHP packages
sudo apt-get install php5-cli php5-cgi php5-common \
php5-curl php5-dev php5-gd php5-mcrypt \
php5-memcache php5-mysql php5-suhosin
# Get from the Debian repo
sudo apt-get build-dep php5-common
sudo apt-get -b source php5-common
# Change this to the PHP version being used!
# Look on http://launchpad.net/php-fpm/master to match it
@nabeelio
nabeelio / gist:841613
Created February 24, 2011 02:06
array as function parameters
<?php
// Setup our options for what we want to pass
$options = array(
'parameter1'=>'apples',
'parameter3'=>'grapes',
);
some_function($options);
function some_function($options)
@nabeelio
nabeelio / gist:905831
Created April 6, 2011 15:15
Partial class, some useful date/time functions
class DateFunctions
{
/**
* Get the months in an array since a start date
*
* @param mixed $start The date to get since
* @return array Returns the list of months
*/
public static function getMonthsSinceDate($start) {
@nabeelio
nabeelio / gist:916762
Created April 13, 2011 00:50
Example of how to use the MySQLDiffTool class
<?php
include 'MySQLDiff.class.php';
$params = ;
try {
$diff = new MySQLDiff(array(
'dbuser' => 'testuser',
'dbpass' => 'test1',
'dbname' => 'testuser',
@nabeelio
nabeelio / spl_classloader.diff
Created July 26, 2012 13:22
spl.SplClassLoader.diff
Index: ext/spl/spl_classloader.c
===================================================================
--- ext/spl/spl_classloader.c (revision 0)
+++ ext/spl/spl_classloader.c (revision 0)
@@ -0,0 +1,464 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2009 The PHP Group |
@nabeelio
nabeelio / 0_reuse_code.js
Last active August 29, 2015 14:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@nabeelio
nabeelio / mt.sh
Last active August 29, 2015 14:24
multitail
#!/usr/bin/env python
import sys
import random
import argparse
from fabric.operations import local
COLORS = ['green', 'blue', 'yellow', 'red']
CMD = ['multitail -mb 10MB --follow-all -n 100']
@nabeelio
nabeelio / download.py
Last active July 2, 2016 18:26
quick script for a friend to write out a reddit thread
# do a "pip install praw" on the command line
import sys
import praw
import textwrap
def print_thread(comment, indent=0):
"""
write out this comment, and then check if there are replies
and if there are replies, we call this recursively, adding another
@nabeelio
nabeelio / base.py
Last active July 10, 2016 14:55
Create properties dynamically without having to create explicit setters and getters
#
# Instead of doing of this for tons of properties:
#
# @property
# def prop(self):
# return self._fields.get('prop')
#
# @prop.setter
# def prop(self, value):
# self._fields['prop'] = value