Skip to content

Instantly share code, notes, and snippets.

View oranj's full-sized avatar
👁️‍🗨️
Observing

Raymond Roeming oranj

👁️‍🗨️
Observing
View GitHub Profile
@oranj
oranj / apache_fetch.php
Created May 15, 2012 19:46
Apache Open Directory Fetch
#!/usr/bin/php
<?php
if (! isset($argv[1])) {
fputs(STDERR, "Please provide a URL to crawl\n");
die(1);
}
if (! isset($argv[2])) {
fputs(STDERR, "Please provide an output filename\n");
@oranj
oranj / url2ascii.php
Created May 10, 2012 20:32
Ascii art generator w/ color
#!/usr/bin/php
<?php
$yscale = 11;
$xscale = 5;
$target_width = get_tty_width();
$inverted = false;
$flags = Array();
$flag_parameters = Array();
@oranj
oranj / myon_decode.php
Created April 20, 2012 20:04
Command line decode
#!/usr/bin/php
<?php
class ColorCLI {
static $foreground_colors = array(
'black' => '0;30', 'dark_gray' => '1;30',
'blue' => '0;34', 'light_blue' => '1;34',
'green' => '0;32', 'light_green' => '1;32',
@oranj
oranj / stream.php
Created April 11, 2012 17:00
Stream Class
<?php
class Stream {
private static $stdin_handle = false;
private static $stdout_handle = false;
static function in() {
if (self::$stdin_handle === false && PHP_SAPI === 'cli') {
self::$stdin_handle = fopen("php://stdin", "r");
@oranj
oranj / class.page.php
Created February 16, 2012 05:42
Templating system for upcoming CMS-
<?php
class CN_Page {
private $page_regions = Array();
private $page_region_data = Array();
private $page_region_count = Array();
const dynamic_key = 'dynamic';
const html_key = 'html';
@oranj
oranj / class.db.php
Created February 16, 2012 05:41
Database
<?php
/**
* Wrapper class for database access
*
* Simple database wrapper. While it handles some
* stuff pretty okay at the moment. The big draws are the
* update_records, insert_record, insert_records, get_records,
* and get_record. Other than that, it can also wrap query calls, etc.
*
@oranj
oranj / array_map_r.php
Created January 3, 2012 19:31
Array Map Recursive
function array_map_r($callback, $input) {
$output= Array();
foreach ($input as $key => $data) {
if (is_array($data)) {
$output[$key] = array_map_r($callback, $data);
} else {
$output[$key] = $callback($data);
}
}
return $output;
@oranj
oranj / rm_thumb.php
Created December 24, 2011 00:39
Thumbnailer w/ auto crop
<?php
error_reporting(E_ALL);
function getExtension($filename, &$base = NULL) {
$a = split('\.', $filename);
$ext = array_pop($a);
$base = join('.', $a);
return strtolower($ext);
}
@oranj
oranj / paramatron.php
Created December 9, 2011 21:05
Regex and harvesting of GET parameters
function get_params($url) {
$param_regex = "/[\?\&]{1}([^=]+)(\=([^\&\=]*))?/";
preg_match_all($param_regex, $url, $matches);
$params = Array();
foreach ($matches[1] as $index => $key) {
$params[$key] = ($matches[2][$index]?$matches[3][$index]:null);
}
return $params;
}
@oranj
oranj / lameroll.js
Created November 14, 2011 14:14
easy banner roller. Pass in a UL.
(function($) {
$.fn.lameroll = function(data) {
this.prefs = $.extend($.fn.lameroll.defaults, data);
this.css({
"width":this.prefs.width,
"height":this.prefs.height,
"list-style-type":"none",
"display":"block",