Skip to content

Instantly share code, notes, and snippets.

timw4mail / README
Created May 19, 2011
CSV Generating Class
A simple class for exporting data from a database into a CSV file.
If you want to directly output the CSV, simply call
CSV::export($field_names, $data, $filename);
$field_names is an array, either associative, with the keys of the array being the column headers, or a traditional array, with the values of the array being the column headers of the csv in the order you want them.
$data is either an array or object of arrays or objects containing your data in the same order as in the $field_names array
timw4mail / index.php
Created Aug 18, 2011
PHP Kana transliterator
View index.php
if(isset($_GET['in']) && isset($_GET['action']))
$in = $_GET['in'];
if($_GET['action'] == "to_hira")
$out = Kana::to_hiragana($in);
timw4mail / prime.html
Created Oct 18, 2011
Javascript prime number generator
View prime.html
<!DOCTYPE html>
<title>JS Prime Generator</title>
<div id="res"></div>
<button id="generate">Generate more primes!</button>
<script type="text/javascript">
timw4mail / prime.php
Created Oct 19, 2011
PHP prime number generator
View prime.php
<!DOCTYPE html>
<title>Prime Number Generator</title>
<body onload="location.href='#bottom'">
$start = microtime(TRUE);
timw4mail / kana.js
Created Oct 20, 2011
Javascript Kana transliterator
View kana.js
document.getElementById('sub').addEventListener('click', transliterate, false);
function transliterate()
var input = document.getElementById('in').value;
var action = document.getElementById('action').value;
var output;
timw4mail / curl.php
Created Oct 26, 2011
Simple Curl function for retrieving a remote url
View curl.php
function do_curl($url, $options=array())
$cookie = tempnam ("/tmp", "CURLCOOKIE");
$ch = curl_init($url);
//Use the user's User Agent and Cookies
$opts= array(
View backup.php
function Zip($source, $destination)
if (extension_loaded('zip') === true)
if (file_exists($source) === true)
$zip = new ZipArchive();
timw4mail / minify.php
Created Nov 3, 2011
HTML Minification
View minify.php
define('SAFE', 1);
define('EXTREME', 2);
define('EXTREME_SAVE_PRE', 3);
function minify($html, $level=2)
timw4mail / JSObject.php
Created Nov 30, 2011
PHP Class for javascript-like objects
View JSObject.php
* JSObject
* Class for creating object-literal-like contstructs in PHP
class JSObject {
timw4mail / magic.php
Created Dec 7, 2011
PHP Magic methods
View magic.php
* Magic constants
// Current line number of the php file
$current_line_number = __LINE__;
// Current PHP file