Skip to content

Instantly share code, notes, and snippets.

View rcshubhadeep's full-sized avatar
💭
Creating the future

Shubhadeep Roychowdhury rcshubhadeep

💭
Creating the future
  • Goa
View GitHub Profile
@rcshubhadeep
rcshubhadeep / golang_job_queue.md
Created September 30, 2016 14:04 — forked from harlow/golang_job_queue.md
Job queues in Golang
@rcshubhadeep
rcshubhadeep / trie.py
Last active June 11, 2022 01:23
trie implementation in Python3
from typing import Tuple
class TrieNode(object):
"""
Our trie node implementation. Very basic. but does the job
"""
def __init__(self, char: str):
self.char = char
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rcshubhadeep
rcshubhadeep / main.go
Created July 21, 2021 15:01
FSM Go Imports
package main
import (
"errors"
"fmt"
"strconv"
"gonum.org/v1/gonum/graph"
"gonum.org/v1/gonum/graph/multi"
)
@rcshubhadeep
rcshubhadeep / main.go
Last active July 21, 2021 17:45
FSM Go Graph Definition
type State struct {
Id int64
Value interface{}
}
type Link struct {
Id int64
T, F graph.Node
Rules map[Operator]Event
}
@rcshubhadeep
rcshubhadeep / main.go
Created July 21, 2021 17:00
StateMachine definiton
type Event string
type Operator string
var NodeIDCntr = 0
var LineIdCntr = 1
type StateMachine struct {
PresentState State
g *multi.DirectedGraph
}
@rcshubhadeep
rcshubhadeep / main.go
Created July 21, 2021 17:03
New StateMachine
func New() *StateMachine {
s := &StateMachine{}
s.g = multi.NewDirectedGraph()
return s
}
@rcshubhadeep
rcshubhadeep / main.go
Created July 21, 2021 17:09
Init, Add State, Link State
func (s *StateMachine) Init(initStateValue interface{}) State {
s.PresentState = State{Id: int64(NodeIDCntr), Value: initStateValue}
s.g.AddNode(s.PresentState)
NodeIDCntr++
return s.PresentState
}
func (s *StateMachine) NewState(stateValue interface{}) State {
state := State{Id: int64(NodeIDCntr), Value: stateValue}
s.g.AddNode(state)
@rcshubhadeep
rcshubhadeep / main.go
Created July 21, 2021 17:13
Create New Rule
func NewRule(triggerConditionOperator Operator, comparisonValue Event) map[Operator]Event {
return map[Operator]Event{triggerConditionOperator: comparisonValue}
}