Skip to content

Instantly share code, notes, and snippets.

View brabeji's full-sized avatar
🏠
Working from home

Jiří Brabec brabeji

🏠
Working from home
  • Recombee
  • Petříkov
View GitHub Profile
import ArraySchema from 'normalizr/lib/IterableSchema';
import { arrayOf } from 'normalizr';
export default function getTrimmedSchema(sourceSchema, maxDepth) {
const resultSchema = new sourceSchema.constructor(sourceSchema._key, {idAttribute: sourceSchema._idAttribute});
defineAssocs(resultSchema, sourceSchema, maxDepth, 1);
return resultSchema;
}
function defineAssocs(targetSchema, sourceSchema, maxDepth, currentDepth) {
@brabeji
brabeji / gist:db863b838248fb46b3a9
Created April 11, 2015 12:43
CakePHP 3.0 question - Creating association by assigning entity

Assuming Posts belongsTo Category is it possible to patchEntity of existing Post with this:

{
  "title": "foo",
  "category": {
    "id": 2,
    "title": "new title for category 2"
  }
}
@brabeji
brabeji / 0_reuse_code.js
Last active August 29, 2015 14:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console