Skip to content

Instantly share code, notes, and snippets.

View arturcarvalho's full-sized avatar

Artur Carvalho arturcarvalho

View GitHub Profile
@arturcarvalho
arturcarvalho / machine.js
Last active February 1, 2022 17:35
Generated by XState Viz: https://xstate.js.org/viz
const ticker = (ctx) => (cb) => {
const interval = setInterval(() => {
cb("TICK");
}, ctx.interval * 1000);
return () => clearInterval(interval);
};
const timerFinished = (ctx) => ctx.remaining === 0;
@arturcarvalho
arturcarvalho / machine.js
Last active January 10, 2022 07:25
Generated by XState Viz: https://xstate.js.org/viz
const timerMachine = Machine({
initial: 'running',
context: {
elapsed: 0,
duration: 5,
interval: 0.1
},
states: {
running: {
const infiniteScrollMachine = Machine(
{
id: 'infiniteScroll',
initial: 'fetchingRowOfData',
context: {
totalEntries: Infinity,
data: [],
@arturcarvalho
arturcarvalho / machine.js
Last active May 18, 2021 17:48
Generated by XState Viz: https://xstate.js.org/viz
const stateMachine = Machine({
id: 'schedules pass',
type: "parallel",
states: {
happy_path: {
initial:"init",
states: {
init: {
on:{
REQUEST_BOOKING:"booking_pending"
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="http://jashkenas.github.io/underscore/underscore-min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
getFloorY = function(item) {
return dims.atticHeight + item.room * dims.roomHeight - dims.floorHeightChars - item.height;
}
if() { // below bsment
} else { // above
if (item.dragged) {
for (var i = 0; i < floors.length; i++) {
//common to client and server
SharedCollection = new Meteor.Collection('shared');
//client from here on out
LocalMirror = new Meteor.Collection(null);
var convertSharedToLocal = function(sharedDoc) {
var localDoc = LocalCollection._deepcopy(sharedDoc); // undocumented API, might change
var listCII
var X
foreach line:
if "C"
listCII.add(X) // only if not null
create new object X
if "I"
put object I in X