Skip to content

Instantly share code, notes, and snippets.

View xurizaemon's full-sized avatar
🌻
SPRING

Chris Burgess xurizaemon

🌻
SPRING
View GitHub Profile
? .svn
? activitystream_delicious/.svn
? activitystream_digg/.svn
? activitystream_feed/.svn
? activitystream_flickr/.svn
? activitystream_flickr/PEAR/.svn
? activitystream_flickr/PEAR/DB/.svn
? activitystream_flickr/PEAR/HTTP/.svn
? activitystream_flickr/PEAR/HTTP/Request/.svn
? activitystream_flickr/PEAR/Net/.svn
@xurizaemon
xurizaemon / zipcart.php
Created February 4, 2011 00:43
zipcart debug
dpm($zipfunction, 'zipfunction');
dpm($files, 'files');
if ( !function_exists($zipfunction) ) {
drupal_set_message(t('Function !zipfunction not available - look for an issue at !project_url.', array('!zipfunction' => $zipfunction, '!project_url' => l('the ZipCart project page', 'http://drupal.org/project/zipcart'))), 'error');
return 'Download failed - Zip function not supported.';
}
else {
if ( !$zipfunction($files) ) {
return 'Download failed.' ;
}
@xurizaemon
xurizaemon / zipcart debug .php
Created February 4, 2011 00:49
zipcart debug OO
/**
* Get the files as a zip
*/
function zipcart_get_zip() {
if ( empty( $_SESSION['zipcart']['files'] ) ) {
drupal_set_message('Sorry, there are no files queued for you to download.');
drupal_goto();
}
else {
$files = $_SESSION['zipcart']['files'] ;
@xurizaemon
xurizaemon / more zipcart.php
Created February 4, 2011 00:52
zipcart 37592
/**
* Zip callback: PHP zip extension
*/
function _zipcart_phpzip($files) {
$zip = new ZipArchive;
$filename = file_directory_path() .'/'. variable_get('zipcart_cache','zipcart') .'/'. time() .'.zip' ;
$zip_open = $zip->open($filename, ZIPARCHIVE::CREATE) ;
if ($zip_open === TRUE) {
dpm('zip opened');
// would be nice to handle duplicate filenames here
@xurizaemon
xurizaemon / gist:1338304
Created November 3, 2011 23:57
chef-solo output
root@lucid64:/etc/chef# chef-solo -l debug -c config/solo.rb -j config/chef.json
INFO: *** Chef 0.10.2 ***
DEBUG: Building node object for lucid64
DEBUG: Extracting run list from JSON attributes provided on command line
INFO: Setting the run_list to "test::default" from JSON
DEBUG: Applying attributes from json file
DEBUG: Platform is ubuntu version 10.04
INFO: Run List is [recipe[test::default]]
INFO: Run List expands to [test::default]
INFO: Starting Chef Run for lucid64
dpm($vars['footprints'], 'vars[footprints] at line 453');
foreach ($vars['footprints'] as $k => $footprint) {
dpm($vars['footprints'], 'vars[footprints] at line 455, foreach is at: '. $k);
<pre>
<?php
/*
after using foreach to iterate /by reference/ across an array containing objects,
then on the second foreach of the same array,
the final member of the array gets overwritten by the previous
and c=b
if we don't iterate by reference on the first pass, then it doesn't happen
@xurizaemon
xurizaemon / foreach-wierdness.php
Created February 1, 2012 00:16
Unexpected behaviour when running foreach across an array of objects in PHP
<pre>
<?php
/*
after using foreach to iterate /by reference/ across an array containing objects,
then on the second foreach of the same array,
the final member of the array gets overwritten by the previous
and c=b
if we don't iterate by reference on the first pass, then it doesn't happen
@xurizaemon
xurizaemon / phpinfo.php
Created February 13, 2012 19:34
why? so that they didn't see lots of 404s for favicon.ico?
<?php
if( $_SERVER['REMOTE_ADDR'] == '127.0.0.1' || $_SERVER['REMOTE_ADDR'] == '::1')
{
ob_start();
phpinfo();
$pinfo = ob_get_contents();
ob_end_clean();
echo str_replace( '<head>', '<head><link rel="shortcut icon" href="/misc/favicon.ico" type="image/x-icon" />', $pinfo);
}
@xurizaemon
xurizaemon / restore-files.sh
Created February 24, 2012 03:12
Restoring files which were bulk copied from a complex folder hierarchy to a flat structure in My Pictures
#!/bin/bash
# where the files went missing from
LIBRARY1="/Volumes/Image_Library/Clients"
LIBRARY2='/Volumes/Image_Library/CLIENTNAME'
# where the files ended up
RECOVERED="/Volumes/My Pictures"
# files to output reports to
REPORT_MISSING=report-missing.txt