Skip to content

Instantly share code, notes, and snippets.

View maxired's full-sized avatar

Maxence Dalmais maxired

View GitHub Profile
@maxired
maxired / blob.svg
Last active June 11, 2021 07:04
blbok
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maxired
maxired / config-environments-development-middleware.json
Last active March 3, 2020 21:38
Strapi 3 custom middleware for partial content
{
"partial": {
"enabled": true
}
}
@maxired
maxired / index.js
Created January 22, 2019 15:00
Set if needed
export const setPath = ([key, ...next], value, obj) => {
if (next.length === 0) {
return {...obj, [key]: value };
}
return {...obj, [key]: setPath(next, value, obj[key]) };
};
export const getPath = ([key, ...next], obj) => {
if (next.length === 0) {
return obj[key];
04094e7973e1f2a7a4a27e89eaca885cf05163ae129f6e5d8246e98e405110fcb47a47a4584ff05f25434344e126c2a4c95755f50206545366e9ccb4bdbef2dab5;yddmat
@maxired
maxired / minimal-set.js
Created August 9, 2017 20:53
Minimal implementation of an immutable set
const setPath = ([key, ...next], value, obj) => {
if (next.length === 0) {
return {...obj, [key]: value };
}
return {...obj, [key]: setPath(next, value, obj[key]) };
};
const set = (path, value, obj) => setPath(path.split('.'), value, obj);
const store = createStore((state = {repoIds, reposById}, action) => {
switch (action.type) {
case UPDATE_TAG:
return set('reposById.1.tags[0]', {id: 213, text: 'Node.js'}, state);
default:
return state;
}
});
@maxired
maxired / index.es6
Last active August 5, 2017 11:21
immutable reducer
switch (action.type) {
case ADD_NEW_AVAILABLE_COLOR_TO_CAR:{
const { color, model, manufacturer } = action.payload
return {...state, manufacturer: {
...state.manufacturer, [manufacturer]:
{...state.manufacturers[manufacturers], models:
{...state.manufacturers[manufacturers].models, [model]:
{...state.manufacturers[manufacturers].models[model], options:
{...state.manufacturers[manufacturers].models[model].options, colors:
{...state.manufacturers[manufacturers].models[model].options.colors, [color]: true}
@maxired
maxired / file
Last active February 24, 2017 10:47
freedom_public
{"0.27085951778223727":"-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nCharset: UTF-8\r\n\r\nxv8AAABSBAAAAAATCCqGSM49AwEHAgMET1vd4wcA3BDWgpWzQnxgJYV7pqecj0O1\r\n+Or3gkb1UKSeX8gI04Z4W6XJKLn5X6/afVSUgo4mCYIYJeNNnPuFLs3/AAAACDxn\r\naXRodWI+wv8AAACOBBATCABA/wAAAAWCWKttnv8AAAACiwn/AAAACZDclQAL3ikz\r\nyf8AAAAFlQgJCgv/AAAABJYDAQL/AAAAApsD/wAAAAKeAQAAoAQBANlN8cdgQHVP\r\n/3nQMP+k9ax4LooGOe4yy6vFuoEiO2sFAP9tSsauQHFvFbgMBan0H9Pfqfuj0Hrx\r\nIEki7kW9ZSUaLs7/AAAAVgQAAAAAEggqhkjOPQMBBwIDBJ5TILIe2BxFLfVqvWp1\r\nBokm91bvCHoHbuxF2VHwhc1FmR24pA4ATb/ZNyX3s8dlub/F3akSSKDF84JPv6Fo\r\nvPQDAQgHwv8AAABtBBgTCAAf/wAAAAWCWKttnv8AAAAJkNyVAAveKTPJ/wAAAAKb\r\nDAAAIVcBAMw/hZEgmNuulKyYZpYMn4+I1wfexW0c2EKSLs+rB0uOAQC1kRjqCbZr\r\n8Pr8uRBvpIR0HZsI2eRoOdcE8odRdiyzvg==\r\n=3pfu\r\n-----END PGP PUBLIC KEY BLOCK-----\r\n","0.1981995427184038":"-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nCharset: UTF-8\r\n\r\nxv8AAABSBAAAAAATCCqGSM49AwEHAgMET1vd4wcA3BDWgpWzQnxgJYV7pqecj0O1\r\n+Or3gkb1UKSeX8gI04Z4W6XJKLn5X6/afVSUgo4mCYIYJeNNnPuFLs3/AAAACDxn\r\naXRodWI+wv8AAACOB
@maxired
maxired / index.js
Created October 15, 2015 15:13
Sample for senecajs/senecajs.org/#74
// require seneca
var seneca = require('seneca')
// create the seneca instance
var si = seneca({log: 'silent'})
// add a worker to parse string
.add('command:parse,type:string', function (args, done) {
done(null, JSON.parse(args.value))
})