Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@gadhra
gadhra / generate_resume.php
Created April 14, 2011 20:26
I got sick of having to maintain my resume in multiple formats in multiple areas online, so I whipped this together to pull from my Google Docs acct. and save local copies so I can do various things with them (embed html, link to a pdf, etc.)
<?php
/**
* Warning: I'm using the v3.0 Protocol here, which hasn't "graduated" yet.
**/
/** basic setup **/
$ch=curl_init();
$h_auth=array();
$h_docs=array();
$save_dir = '/dir/to/save/your/file';
@gadhra
gadhra / Session.5.class.php
Created April 14, 2011 20:35
A PHP5 Session handler
<?php
/***
* @note session handler::PHP5::session-class-php
* @author Stefan Antonowicz
* @link http://us2.php.net/manual/en/function.session-set-save-handler.php
*
* Database session handler
*
* This class overwrites the default session save functions for PHP, so we
* can write to the database rather than the filesystem
@gadhra
gadhra / python_pinger.py
Created April 14, 2011 20:37
We used this guy to ensure that our webservers and databases were running,and if things were replicating as they should. In case of an "event", the script would email everyone and throw up a maintenance page until it was fixed.
#!/usr/bin/python
#@note python pinger::Python::python-pinger
import os
import sys
import re
import smtplib
import MySQLdb
from email.MIMEText import MIMEText
webservers = ["192.168.0.1", "192.168.0.2"]
@gadhra
gadhra / MySQL.5.class.php
Created April 14, 2011 20:33
A MySQL PHP5 class
<?php
/**
* @note MySQL class::PHP5::php-mysql-class
* @author Stefan Antonowicz
*/
class MySQL {
private static $db = '';
/**
* Acceptable connection options - only static and persistent in this case
* @access private
@gadhra
gadhra / make_thumbs.py
Created April 14, 2011 20:53
We had a form that allowed people to update their profile with a link to an image. This image was of various sizes and in various formats. We used a derivation of this script to make thumbnails of the image and save them locally.
#!/usr/bin/python
"""
This file takes a url of an image, resizes it, and SFTPs the new
image to a new location. The image URLs are stored in a MySQL db in
my case, but YMMV
"""
import urllib2
import Image as pil
import paramiko as ssh_c
import os
@gadhra
gadhra / functions.inc.php
Created April 21, 2011 19:03
This is my general functions file. Lots of them aren't mine - I've indicated where I've found them where appropriate
<?php
/**
* Rich Text cleaner
*
* This function pulls out rich text quotes and dashes, usually from Word or other rich text editors
*
* @author Mango
* @link http://www.toao.net/48-replacing-smart-quotes-and-em-dashes-in-mysql
* @param string $text text to clean up
* @return string

Keybase proof

I hereby claim:

  • I am gadhra on github.
  • I am gadhra (https://keybase.io/gadhra) on keybase.
  • I have a public key ASDRwV4s21uAk065SijxZa00T1EKr6oX2SPL02-BX74UOAo

To claim this, I am signing this object:

@gadhra
gadhra / qmail_popper.php
Created April 14, 2011 20:40
This file, written in PHP 4, parsed qmail messages piped to it via a procmail rule (if I remember correctly). The script will parse anything sent to it via stdin.
<?php
/**
* @note Qmail popper::PHP4::qmail-popper-php
* @author Stefan Antonowicz
*
* This file parses out the mails sent to qmail via stdin.
*
* @author Stefan Antonowicz
*/
@gadhra
gadhra / interview-questions.php
Created April 22, 2011 18:56
Some answers to some interview questions I've had
<?php
/** This may be one of the most useless files in the world, but it essentially encapsulates
* the answers to as many interview questions as I can remember over the years. Written in PHP
* because ... just because.
**/
/**
* Write me a program that can determine if something is a palindrome
* ex. A man, a plan, a canal - Panama! should count