Skip to content

Instantly share code, notes, and snippets.

View jmather's full-sized avatar

Jacob Mather jmather

View GitHub Profile
@jmather
jmather / deploy.rb
Created September 13, 2012 16:25
Spiffy capistrano config for composer based projects
after "deploy", "deploy:cleanup"
after "deploy:update_code", "composer:install"
before "composer:install", "composer:copy_vendors"
after "composer:install", "phpunit:run_tests"
namespace :composer do
desc "Copy vendors from previous release"
task :copy_vendors, :except => { :no_release => true } do
run "if [ -d #{previous_release}/vendor ]; then cp -a #{previous_release}/vendor #{latest_release}/vendor; fi"
end
@jmather
jmather / LoadUserData.php
Last active June 15, 2021 18:26
How to load users in a fixture
<?php
namespace Application\Sonata\UserBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Application\Sonata\UserBundle\Entity\User;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
@jmather
jmather / Sentry_Exception.cls
Created August 8, 2019 23:37
Custom Apex Exceptions with stack traces!
/**
* Created by Jacob Mather <jmather@jmather.com> on 2019-06-25.
*/
global with sharing class Sentry_Exception extends Exception {
global Map<String, Object> context = new Map<String, Object>();
private List<String> stackTrace;
global void setStackTrace(List<String> lines) {
stackTrace = lines;
@jmather
jmather / deploy.rb
Created August 30, 2012 05:51
Remove dev only files in production via capifony
set :dev_only_files, [web_path + "/app_dev.php", web_path + "/check.php", web_path + "/config.php"]
set :production, true
after 'symfony:cache:warmup', 'pff:productify'
namespace :pff do
desc "Remove app_dev.php, check.php and config.php from production deployment"
task :productify, :except => { :production => false } do
if dev_only_files
pretty_print "--> Removing app_dev.php, config.php, and check.php from web"
@jmather
jmather / .vagrant.init.sh
Last active May 6, 2018 12:54
This is in my project's bin/.vagrant.init.sh which is looked for (and ran) by my custom vagrant provision.sh
#!/bin/sh
cp -f app/config/parameters.dist.yml app/config/parameters.yml
rm -rf app/cache/*
php app/console doctrine:database:create
php app/console doctrine:migrations:migrate --no-interaction
yes | php app/console doctrine:fixtures:load
php app/console cache:clear
php app/console assetic:dump
php app/console assets:install --symlink
@jmather
jmather / User.orm.xml
Created September 17, 2012 18:41
How to extend the Sonata User Bundle's User
<!-- Application/Sonata/UserBundle/Resources/config/doctrine/User.orm.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Application\Sonata\UserBundle\Entity\User" table="fos_user_user">
<id name="id" column="id" type="integer">
import jenkins.model.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import hudson.plugins.sshslaves.*;
domain = Domain.global()
store = Jenkins.instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')[0].getStore()
@jmather
jmather / AcceptHeaderKernelListener.php
Created September 29, 2012 22:48
RESTful Versioned API with Silex using Accept header
<?php
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class AcceptHeaderKernelListener implements EventSubscriberInterface
{
@jmather
jmather / composer.json
Last active December 26, 2015 01:39
Example composer.json with satis repo and packagist disabled.
{
"repositories": [
{
"type": "composer",
"url": "https://s3.amazonaws.com/my_satis_repo/"
},
{
"packagist": false
}
],
@jmather
jmather / .bashrc
Last active December 24, 2015 01:19
My work in progress bash profile to make the git repos nicer to work with...
if tput setaf 1 &> /dev/null; then
tput sgr0
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
MAGENTA=$(tput setaf 9)
ORANGE=$(tput setaf 172)
GREEN=$(tput setaf 190)
PURPLE=$(tput setaf 141)
WHITE=$(tput setaf 256)
else
MAGENTA=$(tput setaf 5)