Skip to content

Instantly share code, notes, and snippets.

View Bill's full-sized avatar

Bill Burcham Bill

View GitHub Profile
@Bill
Bill / Foo.kt
Created January 10, 2019 22:52
Little dispatcher exerciser
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) {
@Bill
Bill / MonitorQueryUnderContentionBenchmark.java
Last active October 30, 2018 21:54
This benchmark works against the latest Apache Geode develop branch
/*
* 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
@Bill
Bill / FutureTest.java
Created October 17, 2018 17:39
Java Future Test
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 {
@Bill
Bill / part1.clj
Last active March 3, 2017 18:12
Clojure Collection Processing In Context: Part I: Eager to Process
;
; 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)
@Bill
Bill / docker-compose.yml
Last active July 8, 2022 07:10
Run a local Hypothes.is annotation server (and the services it needs) via docker-compose
# 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!
(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))
@Bill
Bill / morse_fsa.rb
Created May 4, 2012 01:32
Solution to http://www.therubygame.com/challenges/6 that creates its own FSA
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
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
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
# 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