Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Farzad Yousefzadeh farskid

🎯
Focusing
View GitHub Profile
@farskid
farskid / TreeIterator.js
Created Jun 10, 2022 — forked from sonyseng/TreeIterator.js
Playing around with the Iterators from ES6 to walk a tree non-recursively (babeljs)
View TreeIterator.js
// Test tree with contrived data
let testTree = {
value: 1,
child: [
{value: 2, child: [
{value: 7, child: []},
{value: 8, child: []},
{value: 9, child: []},
]},
{value: 3, child: []},
@farskid
farskid / stepForm.js
Last active Sep 30, 2021 — forked from waldothedeveloper/stepForm.js
Step Online Form
View stepForm.js
import { createMachine, assign } from "xstate"
import {
zipCodeRegex,
verifyZipcode,
formatPhoneNumber,
validatePhoneNumber,
} from "../../utils/quiz_form_validation"
//
export const stepMachine = createMachine(
View machine.js
Machine({
initial: 'a',
// leaving a syntax error deliberately here
states:
a: {}
}
})
View machine.js
const fileMachine = Machine({
id: "file",
type: "parallel",
states: {
upload: {
initial: "idle",
states: {
idle: {
View machine.js
const fileMachine = Machine({
id: "file",
type: "parallel",
states: {
upload: {
initial: "idle",
states: {
idle: {
View machine.js
const editorPanelMachine = Machine({
context: {immediateUpdate: true},
initial: 'booting',
states: {
booting: {},
active: {},
updating: {
entry: send('UPDATE_MACHINE_PRESSED'),
always: 'active',
},
View machine.js
Machine({
initial: 'a',
context: {}, // enable this for the machine to work
states: {
a: {
entry: assign({id: 1}),
on: {
'': [
{target: 'with_id', cond: ctx => !!ctx.id},
'no_id'
View machine.js
Machine({
id: 'a',
initial: 'checking_url',
context: {gistID: null, gistRawContent: null},
states: {
checking_url: {
entry: 'parseQueries',
always: [
{ target: 'with_gist', cond: 'isGistIDAvailable' },
{ target: 'no_gist' }
View machine.js
Machine({
id: 'test',
initial: 'a',
states: {a: {
entry: ['t']
}}
}, {
actions: {
t: () => console.log('hello')
}
@farskid
farskid / gitzip.sh
Created Jun 1, 2021 — forked from LeonardoCardoso/gitzip.sh
Zip folder ignoring files listed on .gitignore
View gitzip.sh
#...
function gitzip() {
git archive -o $@.zip HEAD
}
#... gitzip ZIPPED_FILE_NAME