Skip to content

Instantly share code, notes, and snippets.

View bhaktaraz's full-sized avatar

Bhaktaraz Bhata bhaktaraz

View GitHub Profile
@danvbe
danvbe / 1-Explanations.md
Last active April 21, 2023 15:39
A way to integrate FosUserBundle and HWIOAuthBundle

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.
@introwit
introwit / helper.php
Created October 28, 2015 10:56
Display Greetings (Morning/Evening)
<?php
/* This sets the $time variable to the current hour in the 24 hour clock format */
$time = date("H");
/* Set the $timezone variable to become the current timezone */
$timezone = date("e");
/* If the time is less than 1200 hours, show good morning */
if ($time < "12") {
echo "Good morning";
} else
/* If the time is grater than or equal to 1200 hours, but less than 1700 hours, so good afternoon */
angular.module('material.core.theming.palette', [])
.constant('$mdColorPalette', {
'red': {
'50': '#ffebee',
'100': '#ffcdd2',
'200': '#ef9a9a',
'300': '#e57373',
'400': '#ef5350',
'500': '#f44336',
'600': '#e53935',
@bhaktaraz
bhaktaraz / PostController.php
Last active November 7, 2020 15:16
Symfony Event Listener to Increase Post View Count
<?php
/**
* Created by PhpStorm.
* User: bhaktaraz
* Date: 8/24/15
* Time: 9:51 AM
*/
namespace BRB\Bundle\PostBundle\Controller;
@adhocore
adhocore / expand_array.php
Last active December 19, 2019 04:05
A helper function expand_array for PHP
<?php
/**
* A helper function expand_array for PHP
*
* This is actually developed during the real need to develop JSON api
* I wanted to have JSON api response spitted properly expanded (with semantic nodes)
* But didnot want to do it by playing with arrays (looping, merging n' what not) time and again.
* So, After fetching single dimensional array data from database, with keys having
* some specific delimeter, this helper would do for me what i want to.
@bhaktaraz
bhaktaraz / MobileNumberClassifier.php
Created August 19, 2016 17:29
MobileNumberClassifier return the carrier of the phone number. e.g. NTC, NCELL etc. (For Nepal)
<?php
/**
* @Author Bhaktaraz Bhatta <bhattabhakta@gmail.com>
*/
namespace SMS\Bundle\MainBundle\Services;
/**
* MobileNumberClassifier return the carrier of the phone number. e.g. NTC, NCELL etc.
*/