Skip to content

Instantly share code, notes, and snippets.

@acmcelwee
acmcelwee / circle-lock.sh
Last active April 9, 2020 16:01
Workflows-friendly adaptation of CircleCI's build locking https://github.com/bellkev/circle-lock-test
#!/usr/bin/env bash
set -o xtrace -o errexit -o pipefail -o nounset
########################################################################################
# CircleCI's current recommendation for roughly serializing a subset
# of build commands for a given branch
#
# circle discussion thread - https://discuss.circleci.com/t/serializing-deployments/153
# Code from - https://github.com/bellkev/circle-lock-test
scala> Await.result(OptionTimeoutFuture { Thread.sleep(3000); 1 }, Duration(2, SECONDS))
res22: Option[Int] = None
scala> Await.result(OptionTimeoutFuture { Thread.sleep(5000); 1 }, Duration(1, SECONDS))
res23: Option[Int] = None
scala> Await.result(OptionTimeoutFuture { Thread.sleep(5000); 1 }, Duration(1, SECONDS))
java.util.concurrent.TimeoutException: Futures timed out after [1 second]
at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:96)
at scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:100)
@acmcelwee
acmcelwee / gist:5673931
Last active December 17, 2015 21:19
Using Firmata 2.2 on Arduino Uno
#!/bin/bash
wget http://at.or.at/hans/pd/Firmata-2.2.zip
unzip Firmata-2.2.zip
mv Firmata-2.2/Firmata /Applications/Arduino.app/Contents/Resources/Java/libraries/Firmata_2_2
rm -rf Firmata-2.2
rm Firmata-2.2.zip
# Start your Arduino IDE.
# Navigate to File -> Examples -> Firmata_2_2 -> StandardFirmata
@acmcelwee
acmcelwee / gist:5625294
Created May 22, 2013 04:43
Event trigger (this works with document.addEventListener)
function triggerEvent(element, eventType) {
var e;
if (document.createEventObject) {
//ie
e = document.createEventObject();
element.fireEvent(eventType, e);
} else {
//others
e = document.createEvent('HTMLEvents');