Skip to content

Instantly share code, notes, and snippets.

const admin = require('./node_modules/firebase-admin');
const serviceAccount = require("./service-key.json");
const data = require("./data.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://YOUR_DB.firebaseio.com"
});
@slam310
slam310 / Common-Currency.json
Created September 15, 2017 13:08 — forked from ksafranski/Common-Currency.json
Common Currency Codes in JSON
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
@slam310
slam310 / rate_limit.js
Created August 16, 2017 13:51 — forked from udnisap/rate_limit.js
This will make sure(most of the times) the concurrent invocation is handled
/* Extend the Underscore object with the following methods */
// Rate limit ensures a function is never called more than every [rate]ms
// Unlike underscore's _.throttle function, function calls are queued so that
// requests are never lost and simply deferred until some other time
//
// Parameters
// * func - function to rate limit
// * rate - minimum time to wait between function calls
// * async - if async is true, we won't wait (rate) for the function to complete before queueing the next request
@slam310
slam310 / tapi18n-default-lanuage.js
Created October 4, 2016 16:51 — forked from frozeman/tapi18n-default-lanuage.js
TAPi18n set default language
// SET default language
if(Cookie.get('TAPi18next')) {
TAPi18n.setLanguage(Cookie.get('TAPi18next'));
} else {
var userLang = navigator.language || navigator.userLanguage,
availLang = TAPi18n.getLanguages();
// set default language
if (_.isObject(availLang) && availLang[userLang]) {
TAPi18n.setLanguage(userLang);
@slam310
slam310 / client_main.js
Created April 5, 2016 20:02 — forked from Whoaa512/client_main.js
Meteor code to display user's facebook picture
Meteor.startup(function() {
Template.fb_pic.pic = function() {// helper function to display the pic on the page
var userProfile;
userProfile = Meteor.user().profile;
if(userProfile) { // logic to handle logged out state
return userProfile.picture;
}
};
});
@slam310
slam310 / nationalities.sql
Created January 23, 2016 20:51 — forked from Almarchal/nationalities.sql
French/English SQL Table of the main nationalities currently used in the world (up to date 09/09/2015) / Table SQL des nationalités principales utilisées dans le monde (à jour le 09/09/2015)
CREATE TABLE `Nationality` (
`id` int(11) NOT NULL,
`name_en` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`name_fr` varchar(50) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=197 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `Nationality` (`id`, `name_en`, `name_fr`) VALUES
(1, 'Afghan', 'Afghane'),
(2, 'Albanian', 'Albanaise'),
(3, 'Algerian', 'Algérienne'),
# Based on https://github.com/sass/libsass/wiki/Building-with-autotools
# Install dependencies
apt-get install automake libtool
# Fetch sources
git clone https://github.com/sass/libsass.git
git clone https://github.com/sass/sassc.git libsass/sassc
# Create configure script
#
# FS Collection
#
profileThumbsStore = new FS.Store.S3('thumb',
accessKeyId : 'XXXXXXXXXXXXXXXXXX'
secretAccessKey : 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
bucket : 'my-bucket-name'
folder : 'thumb'
transformWrite : (fileObj, readStream, writeStream) ->
gm(readStream, fileObj.name()).resize("100", "100").stream().pipe writeStream

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.
<?php
namespace Acme\HelloBundle\Menu;
use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
class MenuBuilder extends ContainerAware
{
public function mainMenu(FactoryInterface $factory, array $options)