Skip to content

Instantly share code, notes, and snippets.

View developit's full-sized avatar
🦊
write, the codes

Jason Miller developit

🦊
write, the codes
View GitHub Profile
@developit
developit / autocomplete.js
Last active August 29, 2015 14:23 — forked from pk11/reactjs.js
/**
* Our component structure will look like the following:
* - WikiBox
* -- AutoCompleteBox
* --- AutoComplete
*/
/** Renders a single entity coming from wikipedia */
class AutoComplete extends React.Component {
render() {
@developit
developit / es-component.js
Created June 17, 2015 20:01
React ES6 Components
import React from 'react';
export class Component extends React.Component {
constructor(...args) {
super(...args);
this.generateBindings();
if (typeof this.init==='function') {
this.init();
}
}
/**
* var jpr = new JSONPRequest();
* jpr.onload = (...data) => {
* console.log(data);
* };
* jpr.open('GET', 'some-url?callback={{callback}}');
* jpr.send();
*/
@developit
developit / Mithril.js for React People.md
Last active August 13, 2018 09:52
Mithril.js for React People

Mithril.js for React People

This is a really basic "todo list" demo built with Mithril.

It's largely an ES6/ES2015 port of the Mithril's Getting Started guide, with a bit of sugar and opinion thrown in to make it look and feel a lot like React.

In this case we're using Babel's JSX transform to convert inline XML into hyperscript (just nested calls to Mithral's m() function).

A Pen by Jason Miller on CodePen.

@developit
developit / WTF IS JSX.md
Last active June 27, 2020 14:49
WTF IS JSX

Moved to my new blog: jasonformat.com/wtf-is-jsx

It's actually really straightforward. Take 1 minute and read this.

Pragma

You declare this per-file or per-function to tell your transpiler (eg: Babel) the name of a function that should be called (at runtime) for each node.

@developit
developit / dom-recycler.js
Last active April 16, 2016 21:42
dom-recycler.js
/** Typed DOM node factory with reclaimation */
let recycler = {
collect(node) {
recycler.clean(node);
let name = node.nodeName,
list = recycler.nodes[name];
if (list) list.push(node);
else recycler.nodes[name] = [node];
},
create(nodeName) {
@developit
developit / bind-decorator.js
Created August 10, 2015 14:06
bind-decorator.js
/** Bind a method to lexical scope.
* @example
* class Foo {
* @bind
* bar() {
* assert.ok( this instanceof Foo );
* }
* }
*/
export default (target, key, { value: fn }) => ({
let behaviorA = {
greet(greeting) {
return greeting;
}
};
@mixes(behaviorA)
class Foo {
@developit
developit / firebase.json
Created October 29, 2015 02:53
just replace your app name and go.
{
"firebase": "your-app-name-here",
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{