Skip to content

Instantly share code, notes, and snippets.

View fenos's full-sized avatar
😎
Coding Goodies

Fabrizio fenos

😎
Coding Goodies
View GitHub Profile
@fenos
fenos / merge.go
Created April 25, 2019 10:15
Merge 2 generic structs values
package structs
import "reflect"
// obj1 := struct{ ID string Name string }
// obj2 := struct{ ID string Name string }{ ID: "1", Name: "Jhon" }
//
// merged := merge.Structs(obj1, obj2)
//
// merge => struct{ ID string Name string }{ ID: "1", Name: "Jhon" }
<?php
class AppCacheServiceProvider extends ServiceProvider {
public function register()
{
$this->app->extend('cache', function($original, $app) {
return new AppCacheManager($app);
});
}
<?php
use Gousto\Replay\Replay;
use Gousto\Replay\RetryLogicException;
class AppCacheManager extends CacheManager {
public function store($name = null)
{
try {
@fenos
fenos / nested-relations.php
Created February 24, 2017 16:39
nested relations
/**
* Get includes that are valid relations
* on models, it can go deep as much as we need
* it will also cut off the not existing relations
*
* @param array $relations
* @return array|bool
*/
public function validateRelations(array $relations = [])
{
{
module: {
loaders: [{
test: /\.(js|jsx)$/,
loader: 'happypack/loader?id=loader0',
exclude: [/\/node_modules\//]
},
{
test: /\.css$/,
exclude: [/\/node_modules\//],
const { group } = require('@webpack-blocks/core')
const HappyPack = require('happypack');
module.exports = happypack
function happypack (blocks) {
return group(blocks.map(happyfyBlock))
}
/**
const HappyPack = require('happypack')
module.exports = happyPack
function happyPack (blocks = [], options = {}) {
const happyThreadPool = HappyPack.ThreadPool({ size: options.size || 5 })
return (context, webpackConfig) => {
@fenos
fenos / Example.js
Last active June 26, 2019 10:15
Dataloader and GraphQL passing arguments
// GraphQL query that i'm trying to resolve with Dataloader but i can't find a way to pass argument to the
// loader function.
// The following GraphQL query should invoke the following DB round trips
// 1 - Posts *
// 2 - Tags limit 10 where post_id = ?
// 3 - Tags limit 20 where post_id = ?
query limitTagsOfThePost {
posts {
name
@fenos
fenos / FilterableInterface.php
Last active October 15, 2018 20:04
Custom Implementation of an Abstract RESTfull Repositories with Laravel.
<?php
interface FilterableInterface {
}
@fenos
fenos / CacheMeRemainder
Last active August 29, 2015 14:05
Cache Helper
<?php namespace Core\Cache;
/**
* Class CacheMeRemainder
*
* @package Core\Cache
*/
class CacheMeRemainder {
/**