Skip to content

Instantly share code, notes, and snippets.

Avatar

David Strauß stravid

View GitHub Profile
View machine.js
const Soll = Machine({
id: 'Soll Stand',
initial: 'AngeforderterPosten',
states: {
AngeforderterPosten: {
on: {
stellen: 'GestellterPosten',
abbrechen: 'AbgebrochenerPosten',
}
},
View machine.js
const Soll = Machine({
id: 'Soll Stand',
initial: 'Leer',
states: {
Leer: {
on: {
anfrageErhalten: 'Anfrage',
angebotAngefragt: 'AngefordertesAngebot'
},
},
View machine.js
const Ist = Machine({
id: 'Ist Stand',
initial: 'Leer',
states: {
Leer: {
on: {
anfrageErhalten: 'Anfrage',
angebotAngefragt: 'AngefordertesAngebot'
},
},
@stravid
stravid / child-machine.js
Last active Mar 23, 2020
Statechart Parent Child Activity Example
View child-machine.js
const { Machine } = XState;
export default Machine({
id: 'child',
initial: 'present',
context: {
name: undefined
},
states: {
present: {
View SketchSystems.spec
Pre-Match*
start match -> Match
Match
Starting Order*
play -> Game
Game
Running?*
another dart can be thrown? -> During
no dart can be thrown? -> After
During
View web.rb
class Web < Roda
def initialize(database_url:)
@database_url = database_url
end
route do |r|
r.root do
"Configured database URL: #{@database_url}"
end
end
View projection_pool_demo.rb
require "rubygems"
require "bundler/setup"
require "concurrent"
tasks = 10.times.map do |s|
Concurrent::TimerTask.new(execution_interval: 1) do
sleep s
puts "s: #{s}\n"
end
end
View client.rb
require "socket"
server_ip = "192.168.1.14"
client_ip = "192.168.1.5"
server_port = 22040
server_socket = UDPSocket.new
server_socket.connect(server_ip, server_port)
name = "Schorsch-Klaus-David-#{rand}"
View gist:6ae2a13b8c1edd2527169ebe0b14bf45
Possible tasks I have a hard time mapping to resources.
- Issuing an invoice
- Completing some kind of sports match
- Advancing an item in a defined process
- Lock/Release an item (to prevent tampering by others)
- Move an upload from temporary to permanent storage
View example.rb
module BaseCommand
module ClassMethods
def schema(&block)
@schema = Dry::Validation.Form(&block)
end
def build(data)
result = schema.call(data)
if result.success?
You can’t perform that action at this time.