Skip to content

Instantly share code, notes, and snippets.

@memphys
memphys / commands.sh
Created October 20, 2011 19:07
php-memcache with XAMPP on Mac OS X Lion
cd /tmp
pecl download memcache
tar xzf memcache-2.2.6.tar
cd memcache-2.2.6
phpize
MACOSX_DEPLOYMENT_TARGET=10.7 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' ./configure --with-php-config=php-config
make
sudo make install
@memphys
memphys / queries.sql
Created October 19, 2011 09:09
Deleting duplicates in MySQL table
SELECT field, COUNT(field) AS total FROM table GROUP BY field HAVING (COUNT(field) > 1)
DELETE t1 FROM table t1, table t2 WHERE t1.field = t2.field AND t1.id > t2.id
ALTER IGNORE TABLE table ADD UNIQUE INDEX(table)
DELETE t1 FROM table as t1, table as t2 WHERE t1.x = t2.x AND t1.y = t2.y AND t1.id > t2.id
@memphys
memphys / commands
Created October 7, 2011 07:15
import local repo to bitbucket
$ git remote add origin git@bitbucket.org:accountname/project.git
$ git push origin master
@memphys
memphys / git flow
Created October 2, 2011 16:10
Git workflows
$ git flow init
$ git flow feature start login
$ git flow feature finish login
$ git flow release start v0.1.0
@memphys
memphys / fetcher.php
Created April 16, 2011 18:05
fetch some url through tor
<?php
class Fetcher
{
private $_torIp = '127.0.0.1';
private $_torProxyPort = '8118';
protected function _request($url)
@memphys
memphys / Doctrine2.php
Created March 8, 2011 17:25
Doctrine2 auth adapter to use with Zend_Auth
<?php
class My_Auth_Adapter_Doctrine2 implements Zend_Auth_Adapter_Interface
{
/**
* Doctrine Entity Manager
*
* @var \Doctrine\ORM\EntityManager
*/
protected $_em = null;
@memphys
memphys / doctrine
Created March 8, 2011 14:42
Doctrine2 cli in Zend Framework
#!/Applications/XAMPP/xamppfiles/bin/php
<?php
include('doctrine.php');
@memphys
memphys / Bootstrap.php
Created February 27, 2011 21:33
Doctrine2 bootstrap in zf1
<?php
protected function _initDoctrine()
{
$options = $this->getOptions();
$doctrinePath = $options['includePaths']['library'];
require_once $doctrinePath . '/Doctrine/Common/ClassLoader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$doctrineAutoloader = array(new \Doctrine\Common\ClassLoader(), 'loadClass');