Skip to content

Instantly share code, notes, and snippets.

View saltybeagle's full-sized avatar

Brett Bieber saltybeagle

View GitHub Profile
@saltybeagle
saltybeagle / php recursive delete with closure
Created January 29, 2010 16:32
PHP recursive delete with closure
<?php
// recursive delete function
$unlink = function($path) use (&$unlink) {
if (is_file($path)){
return unlink($path);
}
if (is_dir($path)) {
var searching = false;
var search_string = '';
$('#courseSearch').keyup(
function(){
if (this.value.length > 2) {
if (search_string != this.value) {
search_string = this.value;
clearTimeout(searching);
WDN.jQuery('#courseSearchResults').html('<img src="/wdn/templates_3.0/css/header/images/colorbox/loading.gif" alt="Loading search results" />');
// XMLHTTP JS class is is developed by Alex Serebryakov (#0.9.1)
// For more information, consult www.ajaxextended.com
// What's new in 0.9.1:
// - fixed the _createQuery function (used to force multipart requests)
// - fixed the getResponseHeader function (incorrect search)
// - fixed the _parseXML function (bug in the ActiveX parsing section)
// - fixed the _destroyScripts function (DOM errors reported)
proxy_xmlhttp = function() {
<?xml version="1.0" encoding="UTF-8" ?>
<p xmlns="http://pear.php.net/dtd/rest.package" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://pear.php.net/dtd/rest.package http://pear.php.net/dtd/rest.package.xsd">
<n>ConsoleTools</n>
<c>components.ez.no</c>
<ca xlink:href="/Chiara_PEAR_Server_REST/c/Commandline">Commandline</ca>
<l>New BSD</l>
<s>A set of classes to do different actions with the console.</s>
<d>A set of classes to do different actions with the console (also called shell).
@saltybeagle
saltybeagle / gitpull.sh
Created May 20, 2011 14:02
Pull all git repositories in ~/workspace/
g=`find ~/workspace/ -name .git -maxdepth 2`
for repo in ${g[@]}
do
cd ${repo}
cd ..
echo `pwd`
git pull
done
@saltybeagle
saltybeagle / storydelete.php
Created June 10, 2011 00:24
Story deletion procedure with error
<?php
if (!isset($_POST['delete'])) {
return false;
}
if (UNL_ENews_Controller::getUser()->uid !== $story->uid_created) {
throw new Exception('You did not create that story - you can not delete it', 403);
}
@saltybeagle
saltybeagle / svnswitchall.sh
Created June 17, 2011 13:46
Script to switch all svn.php.net checkouts from http to https
for dir in `ls -1 */.svn/entries | xargs grep -H -l svn.php.net | grep -E -o "^[^\/]+"`; do
svn switch --relocate `svn info $dir | grep ^Repository\ Root | cut -f 3 -d ' '` `svn info $dir | grep ^Repository\ Root | cut -f 3 -d ' ' | sed 's/http:/https:/'` $dir
done
@saltybeagle
saltybeagle / autoload.php
Created July 8, 2011 14:45
Sample autoload file for developing pyrus
<?php
require_once __DIR__ . '/vendor/php/PEAR2/Autoload.php';
// Setup the local source dir
PEAR2\Autoload::initialize(__DIR__ . '/src');
// Setup the Pyrus_Developer checkout
PEAR2\Autoload::initialize(__DIR__ . '/../Pyrus_Developer/src');
@saltybeagle
saltybeagle / Router.php
Created July 13, 2011 20:33
Simple router idea, uses array of routes
<?php
class Router
{
protected static $routes = array();
public static function route($requestURI, $options = array())
{
if (!empty($_SERVER['QUERY_STRING'])) {
$requestURI = substr($requestURI, 0, -strlen(urldecode($_SERVER['QUERY_STRING'])) - 1);
@saltybeagle
saltybeagle / __email__
Created July 30, 2011 13:15
pear to git move discussion
The following is an email I sent to the PEAR Group on March 18th 2011.
Today I floated the idea of migrating PEAR(1) packages to git after hearing about more and more projects that have seen an increase in contributions once moving their code to a more social environment (github).
Right now we have three accounts, http://github.com/pear, http://github.com/pear2, and http://github.com/pyrus — each are organizations which can have teams of developers with push access to repositories (see how PEAR2 is configured if you're interested in checking it out).
I would like to first endorse migrating to github as an option for pear packages. Then after some feedback from more developers perhaps migrate more packages.
Below are the details on how I moved all of the PEAR2 base components to github. This process is something that can be scripted if necessary.