Skip to content

Instantly share code, notes, and snippets.

View gaspard's full-sized avatar

Gaspard Bucher gaspard

View GitHub Profile
{
"_id": "@cerebral/useragent",
"_rev": "14-6667b038dc0504d85b2e55f833468eef",
"name": "@cerebral/useragent",
"description": "Adds useragent specs to your cerebral state model",
"dist-tags": {
"latest": "1.0.0",
"beta": "0.0.0-beta.3",
"next": "1.0.1-1502489943822"
},
{
"_id": "@repo-cooker-test/commis",
"_rev": "8-9d9955e22534c33863efe63cc875cedb",
"name": "@repo-cooker-test/commis",
"description": "I made a big mistake.",
"dist-tags": {
"latest": "1.0.0",
"next": "2.0.0-1502373638156"
},
"versions": {
@gaspard
gaspard / webpack.config.js
Created May 11, 2017 14:20
webpack + typescript + react
const path = require ( 'path' )
// in app/index.html
// you need to <script type='text/javascript' src='build/app.js'></script>
module.exports =
{ entry: './src/boot.tsx'
, node:
{ __dirname: false
}
, output:
@gaspard
gaspard / TwoDark.tmTheme
Created April 19, 2017 15:36
OneDark theme with Markdown support
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>azemoh</string>
<key>name</key>
<string>Two Dark Theme</string>
<key>settings</key>
<array>
// Original signal definition layout by Christian
[
dispatch(AUTHENTICATING),
authenticateUser, {
error: [
dispatch(AUTHENTICATED_ERROR)
],
success: [
dispatch(AUTHENTICATED_SUCCESS),
dispatch(ASSIGNMENTS_LOADING),
@gaspard
gaspard / Component.ts
Created June 23, 2016 12:58
A custom jsx parser for snabbdom and cerebral.js
import { Component as CComp, render as Crender } from 'cerebral-view-snabbdom'
import { ContextType } from '../modules/context.type'
const SVGNS = 'http://www.w3.org/2000/svg'
const modulesNS = [ 'hook', 'on', 'style', 'class', 'props', 'attrs' ]
const slice = Array.prototype.slice
interface SubComponent {
( props: any, children: VNode[] )
}
// A way to express the full workflow of an edit in a single file
// inspired by Christian Alfoni's thoughts on rxjs-app.
// In Cerebral.js, an Operation could be a signal with a single action filtering on input.operation.
// The emit function would be a wrapper around this signal, passing required context.
// The only new element is the 'emit' function passed through the actions and "binding" them together.
export const editSingleProp = Operation
( { start: ( { input, services: { auth }, emit } ) => {
if ( auth.editAllowed ( input.path ) ) {
emit ( 'editAllowed' )
}
import { Context, Renderable, RenderText } from '../types'
export const render = function
( ctx : Context
, sub1 : Renderable<RenderText>
, sub2 : Renderable<RenderText>
) : RenderText {
const res1 = sub1 ( ctx ).text
const res2 = sub2 ( ctx ).text
import { Context } from './types'
import * as dummy from './dummy'
import * as g1 from './graph/Hello'
import * as g2 from './graph/Lucy'
import * as g3 from './graph/Mix'
import * as g4 from './graph/Stereo'
import * as g5 from './graph/Reverse'
import * as g0 from './main'
const dg1 = { render: g1.render }
const fg1 = function ( ctx : Context ) {
{-
Rendering this:
+------+
| main |
+------+
|
+-------------+
| a. Anaglyph |