Skip to content

Instantly share code, notes, and snippets.

View maxchene's full-sized avatar
🐼
Focusing

Maxime CHÊNE maxchene

🐼
Focusing
View GitHub Profile
<?php
App::uses('AppHelper', 'View/Helper');
App::uses('CakeResponse', 'Network');
class NestableHelper extends AppHelper {
public function generate($categories, $options = array()){
$this->__options = array_merge(
array(
@maxchene
maxchene / JSON_Array_To_Flatten
Created April 17, 2014 12:25
json array to flatten tree for database
public $actsAs = array('Tree');
public function flattenJsonTree($JSON_array, $iParentId = null, $iLevel = null)
{
$aRetval = array();
$iPosition = 1;
foreach ($JSON_array as $aChilds) {
$aDescendents = array();
if (isset($aChilds['children'])) {
$aDescendents = $this->flattenJsonTree(
@maxchene
maxchene / functions.php
Created August 27, 2015 08:52
Allow Inline SVG in wordpress editor
/**
* functions.php
* add the svg tags you needs
* to the $opts array
**/
function override_mce_options($initArray) {
$opts = ['svg','g','path'];
$initArray['extended_valid_elements'] = $opts;
return $initArray;
@maxchene
maxchene / Application.php
Last active February 18, 2020 10:59
Cake 4.0.x redirect and flash with Authorization
<?php
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
{
$authentication = new AuthenticationMiddleware($this);
$middlewareQueue
// Catch any exceptions in the lower layers,
// and make an error page/response
->add(new ErrorHandlerMiddleware(Configure::read('Error')))
@maxchene
maxchene / wallpaper.sh
Created September 6, 2021 14:47
KISS gnome wallpaper from unsplash API
#!/bin/bash
wget https://source.unsplash.com/5120x1440/?wallpaper -O ~/Images/wallpaper.jpg
gsettings set org.gnome.desktop.background picture-uri file:///home/$USER/Images/wallpaper.jpg
@maxchene
maxchene / gist:8e3ae200defd4265714b5de9502978e4
Last active January 3, 2023 10:36
angular generate module with component and add lazy route to parent routing module
// The above command will generate about module with about component and add lazy load route at app module for routing about route.
ng g m about --module app --route about