This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Will execute the workflow on submission | |
kind: Workflow | |
apiVersion: foo | |
metadata: | |
generateName: yolo- | |
spec: | |
template: | |
metadata: | |
labels: | |
foo: bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SqlSchema exposing (..) | |
type SqlType | |
= SqlInt | |
| SqlString | |
type Table = | |
Table { name : String, fields : List FieldSpec } | |
type FieldSpec = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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, | |
} |
NewerOlder