Skip to content

Instantly share code, notes, and snippets.

View rthor's full-sized avatar

Ragnar Þór Valgeirsson rthor

View GitHub Profile
import { createMachine, actions, assign } from "xstate";
const { raise } = actions;
const stubbornMachine = createMachine({
id: "number",
context: {
numb: 0,
},
on: {
"number.reset": {
@rthor
rthor / machine.js
Last active September 24, 2019 10:32
Generated by XState Viz: https://xstate.js.org/viz
const activeTripMachine = Machine(
{
id: 'activeTrip',
initial: 'inactive',
context: {
trip: null,
errorCode: null,
},
states: {
@rthor
rthor / machine.js
Last active September 23, 2019 12:47
Generated by XState Viz: https://xstate.js.org/viz
const activeTripMachine = Machine(
{
id: 'activeTrip',
initial: 'inactive',
context: {
trip: null,
},
states: {
inactive: {
invoke: {
@rthor
rthor / machine.js
Created September 21, 2019 23:42
Generated by XState Viz: https://xstate.js.org/viz
const activeTripMachine = Machine({
id: 'activeTrip',
initial: 'init',
context: {
trip: null,
lastTrip: null,
pollInterval: 15000,
},
states: {
init: {
@rthor
rthor / machine.js
Created September 21, 2019 13:52
Generated by XState Viz: https://xstate.js.org/viz
const activeTripMachine = Machine({
id: 'activeTrip',
initial: 'init',
context: {
tripId: null,
pollInterval: 30000,
},
states: {
init: {
exit: ['hasActiveTrip'],
@rthor
rthor / gist:2323146
Created April 6, 2012 21:39
jQuery: Import jQuery
<!-- jQuery 1.7.0 min -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
@rthor
rthor / README.md
Last active November 15, 2018 13:15
git hook for adding a jira ticket number to relevant commits.

git hook for adding a jira ticket number to relevant commits.

Note: It expects relevant branches to have this naming pattern: PREFIX/USER_NAME/JIRA-TICKET

Steps to include:

> cd PROJECT_ROOT/.git/hooks/

Keybase proof

I hereby claim:

  • I am rthor on github.
  • I am rthor (https://keybase.io/rthor) on keybase.
  • I have a public key ASD-n4k766qUgJmQsMzXa7lsBS-CzgFxzaf85R6b3a5MmAo

To claim this, I am signing this object:

@rthor
rthor / README.md
Last active April 26, 2017 08:59
Sort algorithm for Icelandic characters and other special characters.

Usage

Create some array:

var names = [
  'Jón Margeir Jónson',
  'Fríður',
  'Ægir',
  'Friðgeir',