Skip to content

Instantly share code, notes, and snippets.

@lbineau
lbineau / machine.js
Created December 4, 2020 14:30
Generated by XState Viz: https://xstate.js.org/viz
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
},
@lbineau
lbineau / machine.js
Last active November 18, 2020 11:36
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@lbineau
lbineau / machine.js
Last active December 4, 2020 14:11
Generated by XState Viz: https://xstate.js.org/viz
const waterMachine = Machine({
id: 'waterMachine',
initial: 'ice',
states: {
ice: {
on: {
FUSION: 'liquid',
SUBLIMATION: 'gas'
}
},
@lbineau
lbineau / machine.js
Last active November 17, 2020 14:51
Generated by XState Viz: https://xstate.js.org/viz
// 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 January 4, 2018 09:14
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/
<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 January 6, 2017 13:42
Non western languages
<!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>
src
├── layouts
│   └── default.html
├── pages
│   └── index.html
├── data
│   └── i18n
│       ├── cn.json
│ └── template.html