Skip to content

Instantly share code, notes, and snippets.

View lancearlaus's full-sized avatar

Lance Arlaus lancearlaus

View GitHub Profile
@lancearlaus
lancearlaus / merkle.groovy
Last active September 9, 2017 02:55
Demonstrate Merkle trees by "Merklizing" the words of a sentence supplied as command line arguments
#!/usr/local/bin/groovy
/*
* Demonstrate Merkle trees by "Merklizing" the words of a sentence supplied as command line arguments
* Example: merkle The dog jumped over the moon
*/
HASHPREFIXLEN = 8
static byte[] hash(List<byte[]> input) {
@lancearlaus
lancearlaus / JIRA-XMind-BulkCreate-configuration.txt
Last active June 10, 2017 14:37
XMind to JIRA CSV Import Mapping Utility
{
"config.version" : "2.0",
"config.project.from.csv" : "false",
"config.encoding" : "UTF-8",
"config.file.id" : "0255121b-e22c-4833-8f8f-6cdfade1c986",
"config.email.suffix" : "@",
"config.file.name" : "XMind.csv",
"config.field.mappings" : {
"Issue Type" : {
"jira.field" : "issuetype",
@lancearlaus
lancearlaus / parse_sort_filenames.sh
Last active May 21, 2016 20:30
Parse and sort file names using awk
# Given the following list of files, sort by numeric index
# ls
# V10__allocate_utxo_function.sql
# V11__change_asset_ledger_id.sql
# V12__add_quantity_to_obligation.sql
# V13__allocate_sufficient_utxos_function.sql
# V14__add_spender_to_utxo.sql
# V15__drop_account_lookahead.sql
# V16__create_keychain.sql
# V1__create_asset_table.sql
@lancearlaus
lancearlaus / windowed-max-sample.scala
Last active January 13, 2016 15:50
Sample code to find the windowed max in a series of numbers
import org.scalatest.{Matchers, WordSpec}
object SeqOps {
// Adds windowing operations to sequences
implicit class WindowOps[A](val seq: Seq[A]) extends AnyVal {
def windowedMax[T, X](window: T)(t: A => T, x: A => X)(implicit numeric: Numeric[T], ordering: Ordering[X]): Seq[A] =
seq.tail.scanLeft(Seq(seq.head)) { case (s, cur) =>
@lancearlaus
lancearlaus / akka-user-stream-ack.scala
Last active September 22, 2015 15:19
Akka user list examples
#!/usr/bin/env scalas
// NOTE: This is a self-encapsulated Scala script meant to be run with scalas
// See http://www.scala-sbt.org/0.13/docs/Scripts.html
/***
scalaVersion := "2.11.6"
resolvers += Resolver.url("typesafe-ivy-repo", url("http://typesafe.artifactoryonline.com/typesafe/releases"))(Resolver.ivyStylePatterns)
#!/usr/bin/env scalas
// NOTE: This is a self-encapsulated Scala script meant to be run with scalas
// See http://www.scala-sbt.org/0.13/docs/Scripts.html
/***
scalaVersion := "2.11.6"
resolvers += Resolver.url("typesafe-ivy-repo", url("http://typesafe.artifactoryonline.com/typesafe/releases"))(Resolver.ivyStylePatterns)
#!/usr/bin/env scalas
// NOTE: This is a self-encapsulated Scala script meant to be run with scalas
// See http://www.scala-sbt.org/0.13/docs/Scripts.html
/***
scalaVersion := "2.11.6"
resolvers += Resolver.url("typesafe-ivy-repo", url("http://typesafe.artifactoryonline.com/typesafe/releases"))(Resolver.ivyStylePatterns)
@lancearlaus
lancearlaus / Beyond-the-Pipe.scala
Last active August 29, 2015 14:21
Blog code snippets
#!/usr/bin/env scalas
// NOTE: This is a self-encapsulated Scala script meant to be run with scalas
// See http://www.scala-sbt.org/0.13/docs/Scripts.html
/***
scalaVersion := "2.11.6"
resolvers += Resolver.url("typesafe-ivy-repo", url("http://typesafe.artifactoryonline.com/typesafe/releases"))(Resolver.ivyStylePatterns)
@lancearlaus
lancearlaus / ssoadm_commands.groovy
Last active August 29, 2015 14:20
OpenAM ssoadm commands meta-data extraction
@GrabResolver(name='maven.forgerock.org-releases', root='http://maven.forgerock.org/repo/releases')
@GrabResolver(name='maven.forgerock.org-dependencies', root='http://maven.forgerock.org/repo/openam-dependencies')
@Grapes([
@Grab(group='org.yaml', module='snakeyaml', version='1.15'),
@Grab('org.forgerock.openam:openam-cli-definitions:11.0.0'),
//@Grab('org.forgerock.openam:openam-cli-impl:11.0.0'), // Uncomment to gain access to implementation class (implClassName)
])
import org.yaml.snakeyaml.Yaml
import com.sun.identity.cli.annotation.SubCommandInfo
import com.sun.identity.cli.definition.AccessManager
@lancearlaus
lancearlaus / Ordered.scala
Last active August 29, 2015 14:20
Akka streams PushStage that enforces element ordering
/**
* Enforces ordering on a stream, supporting ascending/descending and strict/non-strict options.
*
* This push stage accepts elements of type `T` and emits elements of type `Either[T, T]`.
* Emitted elements will be of type `Right` if properly ordered or of type `Left` otherwise.
* The stream of Right elements is guaranteed to have proper ordering semantics.
*
* For example, given ascending strict ordering, this stage will emit the following sequence of elements for the given stream.
* Note that the second C element is rejected since ordering only considers valid elements, not invalid intermediate elements.
*