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 kotlinx.coroutines.* | |
import kotlinx.coroutines.launch; | |
import kotlinx.coroutines.scheduling.ExperimentalCoroutineDispatcher | |
import kotlinx.coroutines.test.setMain | |
import java.util.concurrent.TimeUnit | |
import kotlin.coroutines.coroutineContext | |
suspend fun log(msg: String) = println("[${Thread.currentThread().name} ${coroutineContext[CoroutineName]}] $msg") | |
fun main(args: Array<String>) = repeat(1) { |
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
/* | |
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license | |
* agreements. See the NOTICE file distributed with this work for additional information regarding | |
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the | |
* "License"); you may not use this file except in compliance with the License. You may obtain a | |
* copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software distributed under the License |
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 org.junit.Before; | |
import org.junit.Test; | |
import java.util.concurrent.Callable; | |
import java.util.concurrent.FutureTask; | |
import java.util.concurrent.TimeUnit; | |
import java.util.concurrent.TimeoutException; | |
public class FutureTest { |
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
; | |
; Clojure Collection Processing In Context: Part I: Eager to Process | |
; © 2017, by Bill Burcham | |
; | |
; Slides at: https://docs.google.com/presentation/d/1wKcTN5-f00ZCKk_LpUG5GIorh89AImmuxvG7MiGiF1c | |
; | |
(ns ccpic.part1) | |
(use 'clojure.repl) |
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
# This docker-compose.yml will run the Hypothes.is annotation server. | |
# (adapted from instructions here https://h.readthedocs.org/en/latest/INSTALL.html) | |
# | |
# Place this file in the working directory (clone of https://github.com/hypothesis/h) | |
# run with docker-compose up -d | |
# | |
# Now browse to Hypothes.is at http://192.168.59.103:8000/ and create an account | |
# You'll see the invitation email in Mailcatcher at http://192.168.59.103:1080/ | |
# Click that invitation link and log in on your local Hypothes.is | |
# And you are ready to annotate! |
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
(ns progress-light.core | |
(:require [clj-progress.core :as progress] | |
[clojure.core.async :as async :refer [>!! timeout chan alt!! thread]]) | |
(:gen-class)) | |
(def tick-ch | |
(chan)) | |
(def done-ch | |
(chan)) |
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 'singleton' | |
# This is a parser pattern based on regexp as lexer. | |
# Express your tokens as parenthesized regexps separated by | |
# alternation (|). Erroneous input causes immediate return. | |
module Parse | |
def parse( s, p, &block) | |
i = 0 | |
while i < s.length do |
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 'singleton' | |
# This is a parser pattern based on regexp as lexer. | |
# Express your tokens as parenthesized regexps separated by | |
# alternation (|). Erroneous input causes immediate return. | |
module Parse | |
def parse( s, p, &block) | |
i = 0 | |
while i < s.length do | |
# could pass i to match and use block form in newer lib |
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
before_filter :set_database_for_cluster_stuff | |
# SourceSpecific and subclasses (Content, Cluster) take up a lot of space so we want them in | |
# their own per-Domain databases. This hook injects the appropriate database connection based | |
# on the Domain gleaned from the request so subsequent access (during this request) | |
# will go to the appropriate database. | |
def set_database_for_cluster_stuff | |
config = ActiveRecord::Base.configurations[RAILS_ENV] | |
# Get the database name from the Domain |
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
# capture a yaml dump of an object like this: | |
# capture { y request } | |
module Kernel | |
def capture # pass a block to capture | |
old_stdout = $stdout | |
out = StringIO.new | |
$stdout = out | |
begin | |
yield | |
ensure |