Skip to content

Instantly share code, notes, and snippets.

View MatteoOreficeIT's full-sized avatar

Matteo Orefice MatteoOreficeIT

View GitHub Profile
@MatteoOreficeIT
MatteoOreficeIT / laravel-ioc-makeWith-pseudosample.php
Created April 4, 2017 09:31
A pseudo-code example of using laravel IoC recursive dependency resolution with parameters (Container::makeWith)
<?php
use Illuminate\Support\Facades\App;
use Illuminate\Database\Eloquent\Model;
class Capacity extends Model {
// ...
}
class Supplier {
public $capacity;
/**
* Supplier constructor.
@MatteoOreficeIT
MatteoOreficeIT / undocumented-laravel-route-setup.php
Last active April 5, 2017 08:34
Undocumented way to setup route in laravel 5.4 ?
<?php
Route::get('/params/{name}', [
'middleware' => 'App\Http\Middleware\DumpMiddleware',
function () {
return view('welcome');
}]);
namespace Illuminate\Routing;
@MatteoOreficeIT
MatteoOreficeIT / route-actions-member-allowed-keys.php
Last active April 5, 2017 08:40
Which keys Laravel \Illuminate\Routing\Route::$action array could contains ( undocumented - inferred from source )
<?php
namespace Illuminate\Routing;
class Route
{
/**
* The route action array.
*
@MatteoOreficeIT
MatteoOreficeIT / treelist-problem-restoring-deleted-node.html
Last active November 23, 2017 12:01
Kendo TreeList cannot restore deleted node's children upon dataSource errors
<!DOCTYPE html>
<html>
<head>
<base href="http://demos.telerik.com/kendo-ui/treelist/editing">
<style>
html {
font-size: 14px;
font-family: Arial, Helvetica, sans-serif;
}
@MatteoOreficeIT
MatteoOreficeIT / namespacer.js
Last active November 30, 2017 10:47
Short function to create namespaces in Javascript for recent browsers ( depends on jQuery and Array.prototype.reduce )
$.each([
'author.package1',
'author.package2.subpackage1',
'author.package3.subpackage4',
'author.package3.subpackage4.subpackage5',
],function(i,f){f.split('.').reduce(function(n,c){return n[c]||(n[c]={});},g)});
@MatteoOreficeIT
MatteoOreficeIT / laravel-set-fetch-mode.php
Created December 14, 2017 17:07
Laravel change PDO setFetchMode
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
@MatteoOreficeIT
MatteoOreficeIT / How to store GIT credentials on Azure Kudu environement.md
Last active January 25, 2018 16:47
How to store GIT credentials on Azure (Kudu) environment for external private git repositories authentication

Global GIT Config File

Original problem

  • We need to authenticate to multiple private external repositories using credentials stored in a file
  • We don't want use private/public RSA keys with ssh

Investigating how to load user defined .gitconfig

@MatteoOreficeIT
MatteoOreficeIT / checkbox grid sync mvvm.js
Created May 29, 2018 11:12
Telerik Kendo grid checkbox mvvm binding to model
/**
* La variabile $checkedField che vedi riferita arriva da una variabile lato server che contiene
* il nome della colonna da utilizzarsi per settare in automatico il campo del model sul checkbox click
*
* Puo anche valere null o false, in quel caso il valore Javascript deve corrispondere a null o false, per
* fare questo in php si usa il metodo json_encode
*/
/**
* Determina quale e' la colonna tenuta in sync con la checkbox
@MatteoOreficeIT
MatteoOreficeIT / execute-seamlessly-mysql-lock-tables-statement.php
Last active September 19, 2018 13:22
How to seamlessly execute MySQL LOCK TABLE statements in Laravel:5.4.* Query Builder ( also PHP PDO )
<?php
// THIS causes a [Illuminate\Database\QueryException] exception :
// SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active.
// Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against
// mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.
// (SQL: LOCK TABLES imports WRITE)
// see: https://stackoverflow.com/questions/31582445/table-locking-issues-with-laravel-5-1
\DB::statement('LOCK TABLES mytable WRITE');
@MatteoOreficeIT
MatteoOreficeIT / kendo.core.class.js
Last active March 21, 2019 13:54
kendo.Class.extend OO inheritance facility explained
// var ClasseFiglia = Class.extend(...);
// oppure
// var ClasseFiglia = ClassePadre.extend(...);
// crea una funzione costruttore ClasseFiglia ( detta classe in OOP )
// che si comporta secondo i meccanismi dell ereditarieta'
// Object Oriented, tale costruttore/funzione si puo usare come :
// var instance = new ClasseFiglia({...})
// e generare istanze di quella classe
// Si puo legare su proto.init un costruttore oltre
// alla dichiarazione di proprieta ( condivise ) e metodi che appunto finiranno sul prototype