Skip to content

Instantly share code, notes, and snippets.

View dasch's full-sized avatar
💭
LOOKING INTENTLY INTO THE VOID

Daniel Schierbeck dasch

💭
LOOKING INTENTLY INTO THE VOID
View GitHub Profile
@dasch
dasch / Tasks.txt
Last active June 8, 2024 14:29
Elm / Roc like language; pure, functional, statically typed, lazy
# Perform the list of tasks in parallel, returning a list of the resulting values.
# If any of the tasks fail, the entire sequence will fail.
Task.parallel : List (Task a err) -> Task (List a) err
# Perform the list of tasks sequentially, returning a list of the resulting values.
# If any of the tasks fail, the entire sequence will fail.
Task.sequential : List (Task a err) -> Task (List a) err
@dasch
dasch / workflow.yml
Created September 27, 2023 09:16
Idea for Kubernetes Workflow API
# Will execute the workflow on submission
kind: Workflow
apiVersion: foo
metadata:
generateName: yolo-
spec:
template:
metadata:
labels:
foo: bar
import Sql
import Sql.Param
findArticleById : Int -> Result Sql.Error Article
findArticleById id =
let
query =
"SELECT articles.id, articles.title, article.body WHERE articles.id = :id LIMIT 1"
in
Sql.queryWithParams query [ ("id", Sql.Param.int id) ]
require 'redis'
# Search query autocompletion based on http://oldblog.antirez.com/post/autocomplete-with-redis.html
class Autocomplete
# Expire the completion database for a scope after 30 days with no new data.
TTL = 60 * 60 * 24 * 30
def initialize(redis = Redis.new)
@redis = redis
end
module SqlSchema exposing (..)
type SqlType
= SqlInt
| SqlString
type Table =
Table { name : String, fields : List FieldSpec }
type FieldSpec =
@dasch
dasch / Bencode.Parse.elm
Last active November 21, 2018 14:42
Monad syntax in Elm
module Bencode.Parse exposing (parseString, Value)
import Parser exposing (Parser)
import Dict exposing (Dict)
type Value
= BencString String
| BencInt Int
| BencList (List Value)
| BencDict (Dict String Value)
# Distributed build system using Makefile-esque syntax.
base:
FROM ruby:2.4.1
bundle: base
ADD Gemfile Gemfile.lock vendor/
RUN bundle install
assets: base
@dasch
dasch / Monoids.elm
Last active October 28, 2017 22:09
type Product = Product Integer
instance Monoid Product where
empty : Product
empty = Product 1
add : Product -> Product -> Product
add (Product x) (Product y) = Product (x * y)
module EventLog
AVRO = AvroTurf.new(schemas_path: "app/schemas/")
def self.publish(event_name, payload = {})
data = AVRO.encode(payload, schema_name: event_name)
DeliveryBoy.deliver(data, topic: event_name)
end
end
# app/controllers/posts_controller.rb
class PostsController < ApplicationController
def show
@post = Post.find(params[:id])
event = {
post_id: @post.id,
ip_address: request.remote_ip,
timestamp: Time.now,
}