Skip to content

Instantly share code, notes, and snippets.

View Problematic's full-sized avatar

Derek Stobbe Problematic

View GitHub Profile
@Problematic
Problematic / Screenshake.plugin.js
Created January 17, 2015 04:41
Screenshake plugin for PhaserJS
function Screenshake (game, parent) {
Phaser.Plugin.call(this, game, parent);
this.timer = this.game.time.create(false);
this.timer.start();
this.shakeCount = 0;
this.shakeAmount = 1;
this._initialBounds = this.game.camera.bounds;
@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 / 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 / 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 / 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 / ComboBreaker.js
Created November 9, 2012 21:15
Simple key-combo detector. Uses jQuery
/*jslint browser: true, plusplus: true */
(function ($) {
"use strict";
var ComboBreaker = function (combo, callback, options) {
var index = 0, timeout = null;
if (!(this instanceof ComboBreaker)) { return new ComboBreaker(combo, callback, options); }
this.options = $.extend({}, {