Skip to content

Instantly share code, notes, and snippets.

View ashawley's full-sized avatar
✍️
Artwork by Arthur Baelde, Wikimedia Commons

Aaron S. Hawley ashawley

✍️
Artwork by Arthur Baelde, Wikimedia Commons
View GitHub Profile
@ashawley
ashawley / ListSizeSpec.scala
Created June 30, 2019 12:35
Question about org.scalacheck.Gen
import org.scalacheck.Gen
import org.scalacheck.Arbitrary
import org.scalacheck.Prop
import org.scalacheck.Prop.AnyOperators
import org.scalacheck.Properties
class ListSizeSpec extends Properties("ListSize") {
property("sublists") = {
val gen: Gen[(List[Int], List[Int])] = {
sealed abstract class Tree {
def v: Int
}
case class Leaf(v: Int) extends Tree
case class Node(left: Tree, right: Tree, v: Int) extends Tree
val genLeaf = for {
v <- Arbitrary.arbitrary[Int]
} yield {
Leaf(v)
@ashawley
ashawley / .circleci-config.yml
Created March 5, 2019 02:07
CircleCI 2.1 configuration for Scala cross-building
version: 2.1
executors:
scala_jdk_executor:
docker:
- image: circleci/openjdk:8-jdk
commands:
sbt_cmd:
description: "Build with sbt"
@ashawley
ashawley / UtilityTest.sjsir
Last active February 1, 2018 13:52
xmlJS/test:scalajsp scala/xml/UtilityTest.sjsir
class s_xml_UtilityTest extends O {
def isNameStart__V() {
mod:Lorg_junit_Assert$.assertTrue__Z__V(mod:s_xml_Utility$.isNameStart__C__Z(98));
mod:Lorg_junit_Assert$.assertTrue__Z__V(mod:s_xml_Utility$.isNameStart__C__Z(58))
}
def trim__V() {
val x: s_xml_Elem = new s_xml_Elem().init___T__T__s_xml_MetaData__s_xml_NamespaceBinding__Z__sc_Seq(null, "foo", mod:s_xml_Null$, mod:s_xml_TopScope$, false, {
val $$buf: s_xml_NodeBuffer = new s_xml_NodeBuffer().init___();
$$buf.$$amp$plus__O__s_xml_NodeBuffer(new s_xml_Text().init___T("\n "));
$$buf.$$amp$plus__O__s_xml_NodeBuffer(new s_xml_Elem().init___T__T__s_xml_MetaData__s_xml_NamespaceBinding__Z__sc_Seq(null, "toomuchws", mod:s_xml_Null$, mod:s_xml_TopScope$, true, new sjs_js_WrappedArray().init___sjs_js_Array([])));
/** fizzbuzz.c */
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
#include "fizzbuzz.h"
const char* fizzbuzz(signed long n)
;; Disable `M-p' and `M-n; in Ensime minor mode
(eval-after-load "ensime-mode"
'(progn
(define-key ensime-mode-map (kbd "M-n") nil)
(define-key ensime-mode-map (kbd "M-p") nil)))
/**
* Based on Java listings by Bruce Eckel
* Dining Philosophers in Java 8, Dec-29 2016
* http://bruceeckel.github.io/2016/12/29/dining-philosophers-in-java-8/
*/
package concurrent
// concurrent/StickHolder.scala
// Based on the following Usenet posting
// as seen on "Scala: The First Ten Years", Scala Days Berlin, 2014
// From: Miles Sabin
// Date: 2004-04-04 10:24:54 GMT
// Subject: Member types in Scala
// Newgroup: comp.lang.scala
package com.milessabin.example
@ashawley
ashawley / Main.scala
Created October 25, 2016 02:14
Puzzle.scala
package org.npr.weekendedition.sunday.puzzle.people.will.shortz
/**
* Find all the permutations of numbers and ops
* Build infix expresions
* Find all expressions that evaluate within interval (e.g. 1 to 40)
*
*/
object Main extends App {
import java.lang._
import scala._
import scala.Predef._
import scala.concurrent.Future
import scala.concurrent.Await
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
object ComposeFutures extends App {