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 / category_aware_next_generator.rb
Created Nov 15, 2012
Category aware next attribute for a Jekyll post
View category_aware_next_generator.rb
module Jekyll
class CategoryAwareNextGenerator < Generator
safe true
priority :high
def generate(site)
site.categories.each_pair do |category_name, posts|
posts.sort! { |a, b| b <=> a }
@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
@stravid
stravid / example.js
Last active Jun 2, 2018
A simple way to track how far users are scrolling. Assumes you are using Mixpanel and jQuery. Copyright © 2013 David Strauß MIT License
View example.js
new MixpanelScrollTracker({
attribute: 'section',
event: 'Scrolled to',
markers: [
{ position: 500, value: 'Services' },
{ position: 700, value: 'About Us' },
{ position: 900, value: 'Contact Form' }
]
});
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
@stravid
stravid / task.thor
Created Nov 13, 2012
Thor FTP deploy task
View task.thor
desc "deploy", "deploys the site via LFTP to the location specified in the environment"
def deploy
load_ftp_configuration
start_timestamp = Time.now.to_i
if system("lftp -e 'mirror -R -v #{ENV['PUBLIC_DIRECTORY']} #{ENV['FTP_TARGET_DIRECTORY']}; bye' -u #{ENV['FTP_USER']},#{ENV['FTP_PASSWORD']} #{ENV['FTP_SERVER']}")
puts "Deploy finished. (Duration: #{Time.now.to_i - start_timestamp} seconds)"
else
puts 'Deploy aborted, something went wrong.'
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
You can’t perform that action at this time.