Skip to content

Instantly share code, notes, and snippets.

View solocommand's full-sized avatar

Josh Worden solocommand

  • Parameter1
  • Madison, WI
  • 22:59 (UTC -05:00)
View GitHub Profile
@solocommand
solocommand / gist:5265691
Created March 28, 2013 18:34
Angular service
angular.module('modelService', ['ngResource']).factory('ModelService', function ($resource) {
return $resource(
'/supermodlr/api/:model_name/:action/:pk_id',
{ model_name:'@model_name', action : '@action', pk_id: '@pk_id' },
{
'create': { method: 'POST', params: { action: 'create' } },
'read' : { method: 'GET', params: { action: 'read' }, isArray: false },
'update': { method: 'POST', params: { action: 'update' } },
'delete': { method: 'POST', params: { action: 'delete' } },
'query' : { method: 'GET', params: { action: 'query', q: '@query' }, isArray: true }
@solocommand
solocommand / commit-msg
Last active December 17, 2015 03:19
Hook to force commit messages to start with JIRA issue identifiers
#!/bin/bash
regex='^[A-Z]{2,6}-[0-9]{1,8}\s'
message="$(sed 's/^#.*//' $1 | grep -v '^$')"
if [[ $message =~ $regex ]] ; then
echo -e >&2 "\e[0;32mCommit linked issue\e[m ${BASH_REMATCH[0]}"
else
echo -e >&2 "\e[0;31mCommit failed: Invalid JIRA Key: $message\e[m"
exit 1
fi
@solocommand
solocommand / scrape
Created August 30, 2013 15:46
Battle.net Armory Scraper
function armory_scrape($realm, $character)
{ // Scrape armory url based on provided realm and character information
$realm = sanitize_xml(strtolower($realm));
$character = sanitize_xml(strtolower($character));
$armoryurl = "http://us.battle.net/wow/en/character/$realm/$character/advanced";
$debug = false;
function scrape($armoryurl)
{ // Get Armory Page
@solocommand
solocommand / ScriptHandler.php
Last active January 3, 2016 03:29
Composer script to auto-enable installed bundles in Symfony2 AppKernel
<?php
namespace Cygnus\CoreBundle\Composer;
use Composer\Script\Event;
use Sensio\Bundle\GeneratorBundle\Manipulator\KernelManipulator;
class ScriptHandler
{
@solocommand
solocommand / gist:8479935
Last active January 3, 2016 14:59
Test of ReflectionMethod getStartLine and getEndLine methods
<?php
class TestClass {
public function getSomething()
{
$array = array(
'A',
'B',
);
<?php
namespace Foo\BarBundle\Listener;
use Doctrine\Common\EventSubscriber;
use Doctrine\ODM\MongoDB\Events;
use Doctrine\ODM\MongoDB\Event\LifecycleEventArgs;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadataFactory;
use Doctrine\ODM\MongoDB\Types\Type as MongoType;
@solocommand
solocommand / how2.php
Created March 21, 2014 01:19
PHP OOP Quick How-To
<?php
class MyTestClass
{
private $privateVar = array();
protected $protectedVar;
public $publicVar;
public static $staticVar = 'boom.';
<?php
require 'vendor/autoload.php';
use OpenCloud\OpenStack;
use OpenCloud\Common\Service\CatalogService;
use OpenCloud\Common\Service\Endpoint;
use OpenCloud\Common\Exceptions;
use Guzzle\Http\ClientInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
// Rackspace
<?php
namespace Cygnus\CoreBundle\Loader;
use Symfony\Component\HttpFoundation\RequestStack;
use Cygnus\CMSBundle\API\Resource\AccountResource;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**
* Creates a Doctrine connection from predefined attributes
*/
@solocommand
solocommand / imports
Last active August 29, 2015 14:07
Import Interfaces Outline
<?php
namespace Cygnus\Foo
interface ImportSourceInterface
{
public function loadExternalData();
public function format();