Skip to content

Instantly share code, notes, and snippets.

View alexbonhomme's full-sized avatar

Alexandre Bonhomme alexbonhomme

View GitHub Profile
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@tjamps
tjamps / README.md
Last active February 29, 2024 14:57
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authentication
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 2 framework. The following SF2 bundles are used :

@kogakure
kogakure / .gitignore
Last active December 17, 2023 08:21
Git: .gitignore file for LaTeX projects
*.acn
*.acr
*.alg
*.aux
*.bak
*.bbl
*.bcf
*.blg
*.brf
*.bst
@penguinboy
penguinboy / Object Flatten
Created January 2, 2011 01:55
Flatten javascript objects into a single-depth object
var flattenObject = function(ob) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if ((typeof ob[i]) == 'object') {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
@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.
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory 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!"
@simlun
simlun / raspi-monitor
Last active September 14, 2021 14:36
Script to enable and disable the HDMI signal of the Raspberry PI
#!/bin/bash -e
# /usr/local/sbin/raspi-monitor
# Script to enable and disable the HDMI signal of the Raspberry PI
# Inspiration: http://www.raspberrypi.org/forums/viewtopic.php?t=16472&p=176258
CMD="$1"
function on {
/opt/vc/bin/tvservice --preferred
@jdelibas
jdelibas / index.html
Last active September 5, 2021 17:32
TouchSpin directive for Angular.js
<html>
<body>
//Note the value attribute rather than ng-model
<spin value="someScopeValue" min="1" max="{{someOtherScopeValue}}" step="2" />
$scope.someScopeValue = 2;
$scope.someOtherScopeValue = 20;
</body>
@SteveKennedy
SteveKennedy / removeAdFramework.js
Last active August 1, 2021 13:35
Cordova Hook - Removes Ad Framework From Plugin.XML
// This Cordova Hook (script) removes "AdSupport.framework" and "libAdIdAccess" references
// from the cordova-plugin-google-analytics plugin, as well as removes it from
// references found in the corresponding node_module and .project.pbxproj.
// The authoritive source is found at: https://gist.github.com/SteveKennedy
module.exports = function (ctx) {
console.log("Attempting To Remove Ad (IDFA) References from project....")
var pluginName = 'cordova-plugin-google-analytics';
@alexbonhomme
alexbonhomme / 99-proxy
Last active May 17, 2021 08:47
Ce script permet d'activer/désactiver le proxy de Lille 1 dans l'env (.bashrc) et sur les applications suivantes : Git, Maven, Network Manager, Eclipse. !! Attention !! Vous devez avoir configuré le proxy sur vos applications au préalable. Ce script n'est qu'un simple 'toggle'. Vous devez aussi éditer les variables de configurations si vous n'ut…
#!/bin/sh
USER=alex # <--- Put your username here
SSID=LILLE1
INTERFACE=$1
STATUS=$2
case $INTERFACE in
wlan0)
case $STATUS in