inline svgs seem to have issues when using JSX syntax, so this is a possible workaround:
h('div.container', [ | |
h('label.nameLabel', 'Name:'), | |
h('input.myinput', {attributes: {type: 'text'}}), | |
h('hr'), | |
h('h1.greeting', `Hello ${name}`) | |
]) | |
// or | |
div('.container', [ |
// `unit` is `return` from Haskell | |
// `bind` is `>>=` from Haskell, or `flatMap` from Scala | |
var None = { | |
bind: function (fn) { return this; }, | |
unit: function (v) { return Option(v); }, | |
getOrElse: function (elseValue) { return elseValue; } | |
}; | |
var Some = function (value) { |
// ==UserScript== | |
// @name Toggl on Trello | |
// @namespace http://tampermonkey.net/ | |
// @version 0.4 | |
// @description Shows toggl entries that match C### where ### is the card number. | |
// @author sdebaun@sparks.network | |
// @match https://trello.com/c/*/* | |
// @match https://trello.com/b/*/* | |
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js | |
// @grant GM_setValue |
The desire to create a new language has come from my own experiences in programming in a framework I’ve built, Motorcycle.js and the language TypeScript. Motorcycle is very similar to the more popular project Cycle.js. In my current place of employment we are building a rather large and complex application and we have felt the language barriers of ECMAScript and TypeScript much more than we have the programming patterns we have come to use.
This is, currently, a very informal and non-exhaustive list of things I wish a single programming language would have. This language would likely to be very opinionated, and geared towards functional and reactive web applications. In many ways, but not all, I’d like to see a language designed around the programming patterns of Cycle and Motorcycle.
I hope to develop this language in the future, unless someone else beats me to it! Following this is a
// @flow | |
import { curry2, curry3 } from '@most/prelude' | |
export type Except<E, A> = Exception<E, A> | Result<E, A> | |
export const result = <E, A> (a: A): Except<E, A> => | |
new Result(a) | |
export const throwError = <E, A> (e: E): Except<E, A> => | |
new Exception(e) |
// Pair helpers | |
// Map the first element of a pair | |
const first = <A, B, C> (f: A => B, [a, c]: [A, C]): [B, C] => | |
[f(a), c] | |
// Map the second element of a pair | |
const second = <A, B, C> (f: B => C, [a, b]: [A, B]): [A, C] => | |
[a, f(b)] |
Simple state management with xstream
and ramda
, in more transparent fashion than onionify
import * as R from 'ramda'
// first we create factory for making special state stream
// that will hold our stream value and will be modified with supplied streams of reducers
type StateReducer<T> = (state: T) => T
/* | |
Convert svg files to virtual-dom's VTree | |
To use the resulting tree | |
import svg from 'virtual-dom/virtual-hyperscript/svg' | |
if you use Cycle.js: | |
import {svg} from '@cycle/dom'; | |
*/ | |
import fs from 'fs'; |
/** | |
* Fix for vw, vh, vmin, vmax on iOS 7. | |
* http://caniuse.com/#feat=viewport-units | |
* | |
* This fix works by replacing viewport units with px values on known screen sizes. | |
* | |
* iPhone 6 and 6 Plus cannot run iOS 7, so are not targeted by this fix. | |
* Target devices running iOS 8+ will incidentally execute the media query, | |
* but this will still produce the expected result; so this is not a problem. |