Skip to content

Instantly share code, notes, and snippets.

View bzitzow's full-sized avatar

Brian Zitzow bzitzow

  • BRIAN ZITZOW
  • Roseville, California
View GitHub Profile
@bzitzow
bzitzow / gist:8343680
Last active January 2, 2016 18:29 — forked from Mithrandir0x/gist:3639232
Differences between Factories, Services and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@bzitzow
bzitzow / gist:7652035
Created November 26, 2013 01:32
Android DPI Calculator # Source: http://coh.io/adpi/
<script>
$( function() {
function applyToInputSet( id ) {
var dpis = [ 320, 240, 160, 120, 212.8 ];
var labels = [ 'xhdpi', 'hdpi', 'mdpi', 'ldpi', 'tvdpi' ];
var inputs = $(id+' input');
inputs.each( function(i) {
if( this.value == '' ) {
this.value = '';
}
11-21 13:22:49.850: ERROR/Web Console(7957): Error: [$rootScope:inprog] $apply already in progress
http://errors.angularjs.org/1.2.0-rc.3/$rootScope/inprog?p0=%24apply
at file:///android_asset/www/app/lib/angular/angular.js:78:12
at beginPhase (file:///android_asset/www/app/lib/angular/angular.js:10995:15)
at Scope.$apply (file:///android_asset/www/app/lib/angular/angular.js:10795:11)
at HTMLDocument.<anonymous> (file:///android_asset/www/app/js/app.js:65:32)
at Object.cordova.fireDocumentEvent (file:///android_asset/www/cordova.js:224:22)
at file:///android_asset/www/plugins/org.apache.cordova.network-information/www/network.js:71:21
at Object.cordova.callbackFromNative (file:///android_asset/www/cordova.js:289:54)
at processMessage (file:///android_asset/www/cordova.js:1026:21)
,-~ _ ^^~-.,
,^ -,____ ^, ,/\/\/\,
/ (____) | S~ ~7
; .---._ | | || _| S I AM THE Z
| | ~-.,\ | |!/ | /_ LAW! _\
( | ~<-.,_^\|_7^ ,| _//_ _\
| | ", 77> (T/| _/' \/\/\/
| \_ )/<,/^\)i(|
( ^~-, |________||
^!,_ / /, ,'^~^',!!_,..---.
class CategoriesUnitsTable < ActiveRecord::Migration
def self.up
create_table :categories_units, :id => false do |t|
t.references :category
t.references :unit
end
add_index :categories_units, [:category_id, :unit_id]
end
def self.down

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.
Background:
Given I authenticate with the following user:
| user | license | type |
| test | 12354 | developer |
When I send a "POST" request to "/impressions/create?genre=male&glances=2"
Then the response should be JSON
And the response should contain "true"