Skip to content

Instantly share code, notes, and snippets.

Avatar

Bhaktaraz Bhata bhaktaraz

View GitHub Profile
View material-theme.palette.js
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 / MobileNumberClassifier.php
Created Aug 19, 2016
MobileNumberClassifier return the carrier of the phone number. e.g. NTC, NCELL etc. (For Nepal)
View MobileNumberClassifier.php
<?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.
*/
@bhaktaraz
bhaktaraz / PostController.php
Last active Nov 7, 2020
Symfony Event Listener to Increase Post View Count
View PostController.php
<?php
/**
* Created by PhpStorm.
* User: bhaktaraz
* Date: 8/24/15
* Time: 9:51 AM
*/
namespace BRB\Bundle\PostBundle\Controller;
@introwit
introwit / helper.php
Created Oct 28, 2015
Display Greetings (Morning/Evening)
View helper.php
<?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 */
@adhocore
adhocore / expand_array.php
Last active Dec 19, 2019
A helper function expand_array for PHP
View expand_array.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.
@danvbe
danvbe / 1-Explanations.md
Last active Aug 11, 2021
A way to integrate FosUserBundle and HWIOAuthBundle
View 1-Explanations.md

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.