Skip to content

Instantly share code, notes, and snippets.

View machine.js
const isGasable = (context) => context.temperature >= 100
const isFreezable = (context) => context.temperature < 0
const isLiquidable = (context) => context.temperature > 0 && context.temperature < 100
const waterMachine = Machine({
id: 'waterMachine',
initial: 'ice',
context: {
temperature: 0
},
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View machine.js
const waterMachine = Machine({
id: 'waterMachine',
initial: 'ice',
states: {
ice: {
on: {
FUSION: 'liquid',
SUBLIMATION: 'gas'
}
},
View machine.js
// Service mocks (you can change it)
function obtainTokenService() {
return new Promise(async (resolve, reject) => {
//reject('oops');
resolve('tokenId');
});
}
const onErrorHandler = {
target: "error",
@lbineau
lbineau / svg-object-fit.html
Last active Jan 4, 2018
If you need to crop and scale an image in Internet Explorer and provide support back to IE9, you can do that by wrapping the image in an <svg>, and using the viewBox and preserveAspectRatio attributes to do what object-fit and object-position do. Snippet from the great Sara Soueidan blog http://www.sarasoueidan.com/blog/svg-object-fit/
View svg-object-fit.html
<svg width="x" height="y"
viewBox="0 0 imgX imgY"
preserveAspectRatio="<align> <meetOrSlice>"
aria-labelledby="title" aria-role="img">
<title id="title"> img alt here &ly;/title>
<image xlink:href="..." width="100%" height="100%">
</image>
@lbineau
lbineau / .html
Last active Jan 6, 2017
Non western languages
View .html
<!DOCTYPE html>
<html lang="zh-Hans">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<a href="http://www.w3schools.com/TAgs/ref_language_codes.asp">See all the possible languages codes</a>
</body>
</html>
View PATHS.md
src
├── layouts
│   └── default.html
├── pages
│   └── index.html
├── data
│   └── i18n
│       ├── cn.json
│       └── template.html