Skip to content

Instantly share code, notes, and snippets.

@thinkt4nk
thinkt4nk / EIterativeActiveRecord.php
Created August 10, 2011 18:37
POC for a iterative model retrieval method for Yii
<?php
class EIterableActiveRecord extends CActiveRecord
{
public function getIter($buffer_size)
{
return new ActiveRecordIterator($this,$buffer_size);
}
}
class ActiveRecordIterator implements Iterator
@thinkt4nk
thinkt4nk / DirectoryEnumerator.php
Created August 17, 2011 15:53
Directory Enumerator
<?php
/*
* Directory enumeration and presentation for jQuery TreeView Widget
* Author: Ryan Bales, 2011
*/
class DirectoryEnumerator
{
private $enumeration_list = array();
private $directory;
private $public_directory;
@thinkt4nk
thinkt4nk / DbMigrateCommand.php
Created September 10, 2011 06:27
DB Migrations for Yii
<?php
/*
* Manages migrations for Yii database
*
* Author: Ryan Bales <thinkt4nk@gmail.com>, 2011
*/
class DbMigrateCommand extends CConsoleCommand
{
const MIGRATION_TABLE = 'Migration';
@thinkt4nk
thinkt4nk / jquery.utils.js
Created September 13, 2011 15:48
jQuery Utils
(function($) {
var serialize = function(type,form) {
var data = {};
var first_run_ignore_types = ['submit','checkbox'];
form.find('input, select').each(function() {
var input_type = $(this).attr('type');
var input_name = $(this).attr('name');
if (first_run_ignore_types.indexOf(input_type) === -1) {
// process and push to data
@thinkt4nk
thinkt4nk / EventEmitter.js
Created October 21, 2011 15:16
Event Emitter With jQuery 1.7's $.Callbacks()
/**
* EventEmitter with jQuery 1.7's $.Callbacks().
*/
function EventEmitter() {
this.topics = {};
}
/**
* Listen on the given `topic` event with `fn`.
@thinkt4nk
thinkt4nk / pre-commit.py
Created November 30, 2011 21:43
git hook for resetting files before commit
#!/usr/bin/python
import os
import sys
ignore_paths = ['apps/ppc/templates/_scripts.php']
# chdir to project root
os.chdir(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..','..'))
# for each path, reset and re-checkout before commit
for path in ignore_paths:
ignore_file = os.path.join(os.getcwd(),path)
@thinkt4nk
thinkt4nk / confirm_code.php
Last active August 29, 2015 13:57
Random Confirm Code Generator
<?
class confirm_code
{
protected static function generate_random_bytes($length=16){
if(function_exists('openssl_random_pseudo_bytes')) {
$rnd = openssl_random_pseudo_bytes($length, $strong);
if ($strong === TRUE)
return $rnd;
}
@thinkt4nk
thinkt4nk / apache-execution-time.js
Created June 23, 2014 17:44
Parse Log Files - Execution Time
#!/usr/bin/env node
var fs = require('fs');
var moment = require('moment');
if (!!~process.argv.indexOf('-p') && process.argv.length === 4)
parseLog(process.argv[3]);
else if (!!~process.argv.indexOf('-d')) {
var infile = (process.argv.length > 3) ? process.argv[3] : null;
dailyAverages(infile);
}
@thinkt4nk
thinkt4nk / even-width.js
Last active August 29, 2015 14:05
Even, whole element width with even, whole margin
var fullWidth = 290
var numberOfElements = 7
var positionOffset = 0
process.argv.forEach(function(arg) {
var offsetRegexp = /--offset=(\d+)/
if (offsetRegexp.test(arg))
positionOffset = parseInt(arg.replace(offsetRegexp, '$1'))
})
01. Die Krupps - Robosapien
02. KMFDM - Lust
03. Ministry - We Believe
04. Decoded Feedback - Breathe
05. Front 242 - Red Team
06. SA42 - Race of the Human Race
07. Portion Control - Swerve
08. Noise Unit - Firing Line
09. Autodafeh - Treasure Hunt
10. Orange Sector - Sturm (Martin Bodewell Remix)