Skip to content

Instantly share code, notes, and snippets.

@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');
@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 / 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 / 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 / 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 / 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 / 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.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 / commands.sh
Created October 25, 2011 09:23
GAE I18n
# Creating dir for translation files
mkdir -p /path/to/myapp/conf/locale
cd /path/to/myapp
# Creating language file by scanning app directory for text marked for translation.
# It will appear in /path/to/conf/locale/en/LC_MESSAGES/django.po
# Run command for each needed language
PYTHONPATH=/path/to/googleappengine/lib/django/
/path/to/googleappengine/lib/django/django/bin/make-messages.py -l en
@memphys
memphys / deploy.rb
Created November 8, 2011 13:06
Capistrano config for simple php project
set :application, "application_name"
default_run_options[:pty] = true
set :scm, :git
set :repository, "git@github.com:memphys/application_name.git"
# setting ssh port and option to use ssh-keys stored on local machine
set :ssh_options, {:forward_agent => true, :port => 8822}