Skip to content

Instantly share code, notes, and snippets.

@mcrumm
mcrumm / Gemfile
Last active August 29, 2015 14:19
sloth: gentle load testing
source 'https://rubygems.org'
gem 'httparty'
//TestStack.java
//Michael Crumm 2010-10-04
import java.io.*;
import java.util.Scanner;
import stack.*;
public class TestStack
{
//stack.ArrayStack
//Michael Crumm 2010-10-04
package stack;
//An ArrayStack uses an internal Object array to store elements.
public class ArrayStack implements Stack
{
private int size = 0;
private Object[] element;
<?php
/**
* Generate a short URL based on an ID
*
* This function was lifted from: https://github.com/briancray/PHP-URL-Shortener
*
* @param integer $integer The ID from which to generate the short URL
* @param string $base A string containing the set of characters used to construct the short URL
*
@mcrumm
mcrumm / config.yml
Last active December 22, 2015 07:39
Symfony2 configuration for Engine Yard environment variables.
# app/config/config.yml
imports:
- { resource: parameters.yml }
- { resource: engineyard.php }
- { resource: security.yml }
...

I have managed to install this… and make it work. I implemented it for Facebook and Google, but you can extend it. My solution it is mostly as described in #116, with a bit of more code presented. The key aspects that lack in the #116 presentation (IMO) are:

  • the registration as service of your custom FOSUBUserProvider (with the necessary parameters)
  • set the service for oauth_user_provider in the security.yml with your custom created service

Here are the steps:

  1. Routing. In routing.yml I have added all the routes for both bundles.
  2. Configuration. I have set the config.yml mostly as it is presented in the HWIOAuthBundle.
  3. Security. I have set the security.yml mostly as it is presented in the HWIOAuthBundle (though my routes are using /login pattern, not /connect). Also, the oauth_user_provider is set for my custom service.
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
@mcrumm
mcrumm / PhinxConfig.php
Last active December 10, 2015 22:08
A glue object for exposing Phinx's environment-specific db connection settings. I use it to keep from duplicating my db connection settings in Phinx and Idiorm/Paris.
<?php
use Symfony\Component\Yaml\Parser;
class PhinxConfig implements ArrayAccess
{
protected $environment;
protected $path;
@mcrumm
mcrumm / .htaccess
Created January 10, 2013 01:36
I feel like there has to be a better way to deal with these requests... New project, AngularJS client-side, Slim (or Silex, I'm playing with both) server-side. Every request from AngularJS attempts an OPTIONS request first, which isn't a valid route. I'd MUCH rather proxy the requests to a single method via application middleware, but the sheer …
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "X-Requested-With"
Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /