Skip to content

Instantly share code, notes, and snippets.

@jmoz
jmoz / README.md
Created November 8, 2012 18:26
test

readme

@jmoz
jmoz / redis-pipe-test.py
Created August 28, 2012 14:40
redis-pipe-test.py
import redis
import timeit
NUM_OF_USERS = 10000
KEY_USERS = 'test:users'
KEY_USER = 'test:user:%s'
REPEAT = (7, 1)
print "* working with %s items" % NUM_OF_USERS
@jmoz
jmoz / python string interpolation.py
Last active October 7, 2015 02:28
python string interpolation
print 'interpolate the %s out of me' % 'heck'
@jmoz
jmoz / php string interpolation.php
Last active October 7, 2015 02:28
php string interpolation
echo sprintf('interpolate the %s out of me', 'heck');
@jmoz
jmoz / silex-install.sh
Created July 4, 2012 16:52
Silex install script
#!/bin/bash
cd `dirname $0`
curl -s http://getcomposer.org/installer | php
php composer.phar install
@jmoz
jmoz / hookspost-receive
Created July 4, 2012 16:48
Git hooks post-receive
# crucial to allow the install.sh script to update Silex
unset GIT_DIR
GIT_WORK_TREE=/home/myuser/mysilexapp.git git checkout -f
# I like to do a sanity check of the files as there's no output from git checkout
ls -la /home/myuser/mysilexapp/
# execute an install script seperating project logic from git
/home/myuser/mysilexapp/install.sh
@jmoz
jmoz / DomXpath.php
Created June 26, 2012 14:49
DomXpath example
<?php
/**
* @author James Morris <james@jmoz.co.uk>
*/
$html = <<<'EOF'
<html>
<body>
<h1>Foo</h1>
<div id="content">
@jmoz
jmoz / config.yml
Created December 7, 2011 18:05
config.yml
jms_security_extra:
expressions: true
method_access_control:
'^TimeOutTaxonomyAdminBundle:Default:.*': 'hasRole("ROLE_TAXONOMY_VIEW")'
@jmoz
jmoz / LoadSecurityData.php
Created December 2, 2011 16:24
LoadSecurityData
<?php
namespace TimeOut\Bundle\SecurityBundle\DataFixtures;
use Doctrine\Common\DataFixtures\FixtureInterface;
use TimeOut\Bundle\SecurityBundle\Entity\User;
use TimeOut\Bundle\SecurityBundle\Entity\Role;
/**
* Load test users.
@jmoz
jmoz / User.php
Created December 2, 2011 16:04
User
<?php
namespace JMOZ\Bundle\SecurityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use FOS\UserBundle\Model\User as BaseUser;
/**