Skip to content

Instantly share code, notes, and snippets.

David Strauß stravid

Block or report user

Report or block stravid

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
stravid / child-machine.js
Last active Aug 12, 2019
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
start match -> Match
Starting Order*
play -> Game
another dart can be thrown? -> During
no dart can be thrown? -> After
View web.rb
class Web < Roda
def initialize(database_url:)
@database_url = database_url
route do |r|
r.root do
"Configured database URL: #{@database_url}"
View projection_pool_demo.rb
require "rubygems"
require "bundler/setup"
require "concurrent"
tasks = do |s| 1) do
sleep s
puts "s: #{s}\n"
View client.rb
require "socket"
server_ip = ""
client_ip = ""
server_port = 22040
server_socket =
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)
def build(data)
result =
if result.success?
stravid /
Last active Jun 21, 2016
Ruby JSON API Stack

Ruby JSON API Stack

What is this? I'm a little bugged out by all current approaches that are available to build JSON API APIs. I'm writing all this down to help me figure out what I want and how to accomplish it.

There are basically two sides, reading data and writing data. There are also a few parts of the stack that can be generalized. On the other side there are also parts where I think generalization is harmful.

Things like transforming parameters from dasherized to snake case, and serializing an object graph to JSON can be kept pretty generic. The thing I'm not so sure about on the read side is handling query parameters like included, fields, sort, filter, page and so on. For example using JSONAPI::Resources gives you the query parameter handling out of the box. On the other side I think it's impossible to deal with associations if you don't use the Active Record pattern and/or have 1:1 mapping between API resources and models.

On the write

stravid / application.controller.js
Last active Dec 20, 2015
Ember Data Auto-Update Test Case
View application.controller.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
stravid / cURL request
Last active Oct 16, 2015
Lotus JSON Body Parsing
View cURL request
curl 'http://localhost:2300/api/players' --data-binary '{"data":{"attributes":{"name":"David"},"type":"players"}}' --compressed
You can’t perform that action at this time.