Skip to content

Instantly share code, notes, and snippets.

View Problematic's full-sized avatar

Derek Stobbe Problematic

View GitHub Profile
@Problematic
Problematic / SocialBase.php
Created May 20, 2011 23:05
Working example of Symfony2 entities with Class Table Inheritance
<?php
namespace UP\SocialBundle\Entity;
/**
* UP\SocialBundle\Entity\SocialBase
* @orm:Entity
* @orm:HasLifecycleCallbacks
* @orm:InheritanceType("JOINED")
* @orm:DiscriminatorColumn(name="class_name", type="string")
@Problematic
Problematic / gist:990005
Created May 24, 2011 23:44
Function to zipper two arrays together. Preserves keys, appending unique value if duplicated.
<?php
/**
* zippers two arrays together, alternating values from each array
*
* @param array $array1
* @param array $array2
* @return array
*/
function zipperArrays(array $array1, array $array2) {
@Problematic
Problematic / RegistrationController.php
Created May 26, 2011 16:21
Symfony2 user registration mockup
<?php
namespace Problematic\UserBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Problematic\UserBundle\Entity\User;
class RegistrationController extends Controller
{
@Problematic
Problematic / ec2script.sh
Created September 9, 2011 16:03
Amazon EC2 Setup Script
#!/bin/bash
# Script for quick configuration of an EC2 Server
# Installs the necessaries for most PHP Jobs
# Run as Root or suffer the consequences of stuff telling you it can't get a lock and whatnot
ln -sf /usr/share/zoneinfo/America/Denver /etc/localtime
cd /etc/yum.repos.d
<?php
public function create(VoteInterface $vote, VotableCommentInterface $comment)
{
$this->voteBlamer->blame($vote);
if (!$this->validator->validate($vote)) {
return false;
}
@Problematic
Problematic / deploy.sh
Created September 15, 2011 00:06
Symfony2 deployment script
#!/bin/bash
php bin/vendors install
php app/console doctrine:database:create
php app/console doctrine:schema:create
echo -n "Initialize ACLs (y/n)? "
read initACL
[ "$initACL" == "y" ] && php app/console init:acl
@Problematic
Problematic / UserFactory.php
Created September 16, 2011 16:00
Symfony2 User Factory
<?php
namespace Acme\UserBundle\Model;
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
use Symfony\Component\Security\Core\User\UserInterface;
class UserFactory
{
@Problematic
Problematic / runtests.sh
Created January 10, 2012 02:19
Symfony2 runtests script
#!/bin/bash
echo "Truncating ACL class tables..."
php app/console doctrine:query:sql "TRUNCATE acl_classes"
php app/console doctrine:query:sql "TRUNCATE acl_entries"
php app/console doctrine:query:sql "TRUNCATE acl_object_identities"
php app/console doctrine:query:sql "TRUNCATE acl_object_identity_ancestors"
php app/console doctrine:query:sql "TRUNCATE acl_security_identities"
echo "Loading data fixtures..."
@Problematic
Problematic / testbang.php
Created January 16, 2012 20:36
hashbang example script
#!/usr/bin/env php
<?php
require 'hashbang.php';
$app = new HashBang(function($firstname, $lastname, $options) {
$output = "Hello, {$firstname}";
if ($lastname) {
$output .= " {$lastname}";
}
@Problematic
Problematic / install_pygit.sh
Created February 10, 2012 23:56
Installing pygit2 on Ubuntu 11.10
# this will install everything as root, so take that into account before you run it
# need cmake, python development headers, ZLib and OpenSSL
sudo apt-get install cmake python2.7-dev zlib1g-dev libssl-dev
mkdir libgit && cd libgit
git clone git://github.com/libgit2/libgit2.git
cd libgit2