This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Available variables: | |
| // - Machine | |
| // - interpret | |
| // - assign | |
| // - send | |
| // - sendParent | |
| // - spawn | |
| // - raise | |
| // - actions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const loginMachine = Machine({ | |
| id: 'login', | |
| initial: 'start', | |
| context: { | |
| retries: 0, | |
| loginDetails: null, | |
| errorMessage: null | |
| }, | |
| states: { | |
| start: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Available variables: | |
| // - Machine | |
| // - interpret | |
| // - assign | |
| // - send | |
| // - sendParent | |
| // - spawn | |
| // - raise | |
| // - actions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule CacheWorker do | |
| require Logger | |
| defmodule State do | |
| @type t :: %__MODULE__{ | |
| hits: integer(), | |
| content: String.t(), | |
| timer: reference() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![allow(dead_code, unused)] | |
| use dgraph::{make_dgraph, Dgraph, Request}; | |
| use serde_derive::{Deserialize, Serialize}; | |
| fn user_type() -> String { "User".to_string() } | |
| #[derive(Debug, Default, Serialize, Deserialize)] | |
| struct User { | |
| uid: Option<String>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::ops::Deref; | |
| use std::rc::Rc; | |
| #[derive(PartialEq, Debug, Clone)] | |
| struct Shoe { | |
| size: u32, | |
| style: String, | |
| } | |
| struct MyBox<T>(T); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::iter::Peekable; | |
| use std::str::Chars; | |
| #[derive(Debug, PartialEq)] | |
| pub enum Token { | |
| Plus, | |
| Minus, | |
| Equal, | |
| Number(i32), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://bodil.lol/parser-combinators/ | |
| #[derive(Debug, Clone, PartialEq, Eq)] | |
| struct Element { | |
| name: String, | |
| attributes: Vec<(String, String)>, | |
| children: Vec<Element>, | |
| } | |
| type ParseResult<'a, Output> = Result<(&'a str, Output), &'a str>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::collections::HashMap; | |
| #[derive(Debug, PartialEq, Clone)] | |
| enum Json { | |
| Null, | |
| Boolean(bool), | |
| Number(f64), | |
| String(String), | |
| Array(Vec<Json>), | |
| Object(Box<HashMap<String, Json>>), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState, useEffect, useMemo, useReducer, useContext, useCallback } from 'react' | |
| import { composeWithDevTools } from 'redux-devtools-extension' | |
| import { createStore } from 'redux' | |
| import { createSelector } from 'reselect' | |
| import { Provider, shallowEqual, useSelector, useDispatch } from 'react-redux' | |
| import { Machine, interpret, assign } from 'xstate' | |
| import ReactDOM from 'react-dom' | |
| const initialState = { |