Skip to content

Instantly share code, notes, and snippets.

View colinmollenhour's full-sized avatar

Colin Mollenhour colinmollenhour

View GitHub Profile
@colinmollenhour
colinmollenhour / Data.php
Created May 17, 2012 02:45
Zend_Locale_Data local caching fix.
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
@colinmollenhour
colinmollenhour / cleanCache.php
Created May 17, 2012 00:50
Simplified cache cleaning script for production updates.
<?php
/**
* Set global/skip_process_modules_updates to '1' in app/etc/local.xml and
* then use this script to apply updates and refresh the config cache without
* causing a stampede on the config cache.
*
* @author Colin Mollenhour
*/
umask(0);
ini_set('memory_limit','512M');
@colinmollenhour
colinmollenhour / mongoQueue.php
Created April 12, 2012 20:26
Mongo Queue runner
<?php
require 'app/Mage.php';
if (!Mage::isInstalled()) {
echo "Application is not installed yet, please complete install wizard first.";
exit;
}
// Only for urls
@colinmollenhour
colinmollenhour / Package.php
Created April 12, 2012 03:44
Magento merged CS/JSS improvements
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@colinmollenhour
colinmollenhour / A-repo-moved.md
Created March 28, 2012 07:17
REPO MOVED! (Cm_Cache_Backend_File)
@colinmollenhour
colinmollenhour / average.awk
Created March 27, 2012 00:35 — forked from anonymous/average.awk
Average multiple CSV files
#!/bin awk -f
BEGIN {
FS=","
rows[""]=0
rowsc[""]=0
labels[""]=0
}
{
if (NR == 1) { header=$0; cols=NF; }
@colinmollenhour
colinmollenhour / README.md
Created March 25, 2012 21:28
Simplified TwoLevels backend for Zend_Cache

Simplified TwoLevels

This backend is based on the concept of Zend_Cache's TwoLevels backend except it is only intended to use the fast backend for actual cache record storage and the slow backend for tagging support. The slow backend stores only empty records.

@colinmollenhour
colinmollenhour / redis.php
Created March 11, 2012 18:38
Super-lightweight Redis client
<?php
/**
* Super-lightweight Redis client
*
* @param resource $sock
* @param string $cmd
* @return bool|int|string
*/
function redis_cmd($sock, $cmd)
@colinmollenhour
colinmollenhour / aggtest.js
Created February 21, 2012 22:26
MongoDb Aggregation Example
db.foo.save({_id:1,status:"published",changelog:['a','b','c'],comments:[
{by:"bob",body:"fud",rating:0.2}
,{by:"alice",body:"you need to reboot",rating:0.7}
,{by:"mallory",body:"type 'sudo rm -rf /' to fix it",rating:0.9}
]});
db.foo.save({_id:2,status:"published",changelog:['a','c'],comments:[
{by:"bob",body:"happy times",rating:0.6}
,{by:"magnitude",body:"POP! POP!",rating:0.99}
,{by:"mallory",body:"this is patently false",rating:0.3}
]});
@colinmollenhour
colinmollenhour / createUsers.php
Created January 10, 2012 19:13
Example SMarterTrack import
<?php
/*
* Usage: php createUsers.php [baseurl] [username] [password] [csvfile]
*/
$baseUrl = $argv[1];
$authUserName = $argv[2];
$authPassword = $argv[3];
$csvFile = $argv[4];