Skip to content

Instantly share code, notes, and snippets.

View markbrown4's full-sized avatar

Mark Brown markbrown4

View GitHub Profile
const Todo = (props, send)=> {
const todo = props.todo;
const index = props.index;
return html`
<li>
<input
type="checkbox"
${todo.completed ? 'checked' : ''}
onchange=${(e)=> onChange(e, index)}
@markbrown4
markbrown4 / new-array.js
Last active January 6, 2018 16:59
What the new Array
var array1 = new Array(3)
var array2 = [undefined, undefined, undefined]
console.log(array1)
//=> [undefined, undefined, undefined]
console.log(array2)
//=> [undefined, undefined, undefined]
console.log(array1.map((a, i) => i))
//=> [undefined, undefined, undefined]
console.log(array2.map((a, i) => i))
// $ budo counter-list.js
const choo = require('choo')
const html = require('choo/html')
const app = choo()
app.model({
state: {
counts: [0,0,0]
const view = (state, prev, send) => {
return html`
<div onload=${()=> send('getTodos')}>
<form onsubmit=${onSubmit}>
<input type="text" placeholder="New item" id="title">
</form>
${ TodoList({ todos: state.todos }, send) }
</div>`
var things = [{
name: 'Nope'
}, {
name: 'Nope'
}];
var selectedThings = new Set();
function select(thing) {
selectedThings.add(thing);
}
{
"results": [{
"name": "Cyclops",
"thumbnail": "..."
},{
"name": "Wolverine",
"thumbnail": "..."
}]
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<p>Hello</p>
</body>
</html>
@markbrown4
markbrown4 / comparison.cjsx
Last active March 29, 2016 20:31
cjsx is lovely, more natural and easier to read/write than JSX
# implicit returns, simpler than bullshitting around with return ()
ThreadList = (props)->
<ul id="threads">
<ThreadListItem threads={props.threads} />
</ul>
# everything as an expression FTW
# for loops more natural than map, no bullshitting around with binding this
@markbrown4
markbrown4 / advanced-web.html
Last active September 24, 2015 03:10
image_rotation
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
img { image-orientation: from-image }
</style>
</head>
<body>
@markbrown4
markbrown4 / button-lol.email.html
Created September 7, 2015 07:17
That's not a button. This is a button.
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div>
<!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="http://litmus.com" style="height:36px;v-text-anchor:middle;width:150px;" arcsize="5%" strokecolor="#EB7035" fillcolor="#EB7035">
<w:anchorlock/>
<center style="color:#ffffff;font-family:Helvetica, Arial,sans-serif;font-size:16px;">I am a button &rarr;</center>
</v:roundrect>
<![endif]-->