Skip to content

Instantly share code, notes, and snippets.


  • Marseille, France
Block or report user

Report or block cahnory

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
cahnory / WebpackRelayCompilerPlugin.js
Last active Mar 5, 2018
View WebpackRelayCompilerPlugin.js
const childProcess = require('child_process');
function RelayCompilerPlugin(options) {
this.schema = options.schema;
this.src = options.src;
RelayCompilerPlugin.prototype.apply = function(compiler) {
const cmd = `relay-compiler --src ${this.src} --schema ${this.schema}`;
cahnory / UserType.js
Last active Feb 4, 2018
Create relay node field
View UserType.js
import { GraphQLObjectType } from 'graphql';
import { globalIdField } from 'graphql-relay';
import { nodeInterface, defineNodeType } from './node';
import { findById } from '../models/User';
export const UserType = new GraphQLObjectType({
name: 'User',
fields: {
id: globalIdField('User')
cahnory / subscriptionManager.js
Last active Nov 29, 2017
Subscription manager to quickly remove all subs (on componentWillUnmount for eg.)
View subscriptionManager.js
export default createSubscriptionManager = () => {
const subs = []
return {
subscriptions: subs,
interval: attachSubscriptionMethod(subs, interval),
listen: attachSubscriptionMethod(subs, listen),
timeout: attachSubscriptionMethod(subs, timeout),
promise: attachSubscriptionMethod(subs, promise),
cahnory /
Created Jan 27, 2017
Idée vite jetée à propos des bundlers

Utilisation d'une fonction d'import propre au bundler

Aujourd'hui, webpack nous permet d'inclure un asset comme s'il s'agissait d'un fichier javascript :

import style from './style.css'

Mais les avantages de cette approches ne sont ils pas inférieurs aux inconvéniants ?

View gist:6d47f34f1ce37380f45816426f7517ea
View DataSelect.jsx
import React from 'react'
export function DataSelect({
}) {
cahnory / Walker_Nav_Menu_Object.php
Created Feb 18, 2016
Wordpress nav menu object
View Walker_Nav_Menu_Object.php
class Walker_Nav_Menu_Object extends Walker_Nav_Menu
protected $scopes = array();
public function __construct() {
$this->scopes[] = (object)array(
'children' => array(),
'parent' => NULL
cahnory / middleware.js
Created Dec 21, 2015
View middleware.js
import connect from 'koa-connect';
import compose from 'koa-compose';
import webpack from 'webpack';
import webpackDev from 'webpack-dev-middleware';
import webpackHot from 'webpack-hot-middleware';
export default function (config = {}) {
let compiler = webpack(config);
return compose([
cahnory / SassMeister-input.scss
Created Dec 6, 2015
Generated by
View SassMeister-input.scss
// ----
// libsass (v3.2.5)
// ----
@mixin short($map, $prefix: '') {
@each $key, $val in $map {
@if 'map' == type-of($val) {
@include short($val, $prefix+$key+'-');
@else {
cahnory / SassMeister-input-HTML.html
Last active Oct 3, 2015
Generated by
View SassMeister-input-HTML.html
<div class="box"></div>
You can’t perform that action at this time.