Skip to content

Instantly share code, notes, and snippets.

//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;
//TestStack.java
//Michael Crumm 2010-10-04
import java.io.*;
import java.util.Scanner;
import stack.*;
public class TestStack
{
@mcrumm
mcrumm / Gemfile
Last active August 29, 2015 14:19
sloth: gentle load testing
source 'https://rubygems.org'
gem 'httparty'
@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 /
@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;
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

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.
@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 }
...
<?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 / SocketClientCompatibilityTable.md
Last active March 8, 2016 05:38
ReactPHP socket-client version compatibility chart

These results are based on test connections to the Slack Realtime Messaging API, using PHP versions compiled from source on Mac OSX 10.11.2.

PHP Version wrapSecure ON wrapSecure OFF
5.5.0 👍 SSL Buffer Bug
5.5.19 👍 👍
5.5.23 😬 No connection! 😬 No connection!
5.5.25 👍 👍
5.5.30 👍 👍
5.6.3 👍 SSL Buffer Bug