Skip to content

Instantly share code, notes, and snippets.

View ilario-pierbattista's full-sized avatar
🏠
Working from home

Ilario Pierbattista ilario-pierbattista

🏠
Working from home
View GitHub Profile
<?php
class JsonDecoder implements DecoderInterface {
public function decode( $data )
{
$decoded = @json_decode( $data, true );
$decoded = $this->removeBooleans( $decoded );
@bripkens
bripkens / gist:3769436
Created September 23, 2012 09:10
DOT file for finite state machine diagrams.
digraph finite_state_machine {
rankdir=LR;
node [shape = doublecircle]; 1;
node [shape = circle] 0;
node [shape = plaintext, label = ""]; start;
start -> 0 [ label = "start"];
0 -> 1 [ label = "[1-9]" ];
1 -> 1 [ label = "[0-9]" ];
@danvbe
danvbe / 1-Explanations.md
Last active February 20, 2025 12:31
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.
@koenpunt
koenpunt / chosen-bootstrap.css
Last active March 11, 2023 01:01
Bootstrap 3.0 theme for Chosen
select.form-control + .chosen-container.chosen-container-single .chosen-single {
display: block;
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.428571429;
color: #555;
vertical-align: middle;
background-color: #fff;
@tjamps
tjamps / README.md
Last active March 19, 2025 00:30
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 :

@carlessanagustin
carlessanagustin / Nginx_Cheat_Sheet.md
Last active April 21, 2025 02:32
Nginx Cheat Sheet
@petrkotek
petrkotek / recursive-generator-php70.php
Created September 19, 2016 08:38
Demonstrates how to implement recursive generators in PHP 7.0+
<?php
function walkTree($tree, $depth = 0) {
foreach ($tree as $key => $value) {
yield ['depth' => $depth, 'name' => $key];
if (is_array($value)) {
yield from walkTree($value, $depth + 1);
}
}
}
$tree = [
@cryzed
cryzed / fix-infinality.md
Last active March 20, 2025 13:16
A set of instructions on how to fix the harfbuzz + Infinality issue and restoring good-looking, Infinality-like font rendering.

Disclaimer: Please follow this guide being aware of the fact that I'm not an expert regarding the things outlined below, however I made my best attempt. A few people in IRC confirmed it worked for them and the results looked acceptable.

Attention: After following all the steps run gdk-pixbuf-query-loaders --update-cache as root, this prevents various gdk-related bugs that have been reported in the last few hours. Symptoms are varied, and for Cinnamon the DE fails to start entirely while for XFCE the icon theme seemingly can't be changed anymore etc.

Check the gist's comments for any further tips and instructions, especially if you are running into problems!

Screenshots

Results after following the guide as of 11.01.2017 13:08:

@masbog
masbog / VMware-Player-12.5.2-4638234_Linux-4.9_patch.sh
Created March 10, 2017 07:23
fix too few arguments to function "get_user_pages_remote" on Fedora 25 kernel 4.9.13-200
#!/bin/bash
cp -n /usr/lib/vmware/modules/source/vmmon.tar /usr/lib/vmware/modules/source/vmmon.tar_bak
cp /usr/lib/vmware/modules/source/vmmon.tar .
tar xf vmmon.tar
patch -p0 << "EOF"
--- vmmon-only/linux/hostif.c
+++ vmmon-only/linux/hostif.c
@@ -1162,7 +1162,9 @@
int retval;
@mohanpedala
mohanpedala / bash_strict_mode.md
Last active April 30, 2025 16:54
set -e, -u, -o, -x pipefail explanation