Skip to content

Instantly share code, notes, and snippets.

View andy1138's full-sized avatar

Andy Hicks andy1138

View GitHub Profile
@andy1138
andy1138 / king-list.csv
Last active July 12, 2017 13:38
List of pharaonic kings of Egypt
Kingdom Dynasty DurIndex Name StartDate EndDate Duration
Pre Dynastic Lower Egypt 1 Hsekiu|Seka 0 0 0
Pre Dynastic Lower Egypt 2 Khayu 0 0 0
Pre Dynastic Lower Egypt 3 Tiu (pharaoh)|Tiu|Teyew 0 0 0
Pre Dynastic Lower Egypt 4 Thesh|Tjesh 0 0 0
Pre Dynastic Lower Egypt 5 Neheb 0 0 0
Pre Dynastic Lower Egypt 6 Wazner 0 0 0
Pre Dynastic Lower Egypt 7 Mekh 0 0 0
Pre Dynastic Lower Egypt 8 (destroyed) 0 0 0
Pre Dynastic Lower Egypt 9 Double Falcon 0 0 0
@andy1138
andy1138 / scala2javadoc
Created July 2, 2014 13:21
scaladoc link to javadoc
package scala.swing
import javax.swing._
object Button {
def apply(text0: String)(op: => Unit) = new Button(Action(text0)(op))
}
/**
* A button that can be clicked, usually to perform some action.
package org.lsug.csvswing
import swing._
import Swing._
import scala.swing.event.ButtonClicked
import java.io.File
import scala.util.{Failure, Success, Try}
import javax.swing.UIManager
object CSVSwing extends SimpleSwingApplication {
package lsug
import java.security.MessageDigest
import java.io.{BufferedInputStream, FileInputStream}
object SchemaString extends App {
implicit class SchemaHelper(val sc: StringContext) extends AnyVal {
def schema(a: Any*): String = sc.parts.head.split('\n').map( _.trim).mkString("\n")
@andy1138
andy1138 / lsug-dojo-feb13
Created February 21, 2013 21:12
LSUG Macro from Feb'13 dojo
package lsug
import scala.language.experimental.macros
import scala.reflect.macros.Context
object Debug {
def error(s:String) = macro error_impl
def error_impl(c: Context)(s: c.Expr[String]): c.Expr[Unit] = {
@andy1138
andy1138 / gist:3755454
Created September 20, 2012 11:46
ProgFun Week1
Call-by-name vs call-by-value
1) Write a timer function, so this will work
scala> def sleep( n:Int) { Thread.sleep(n) }
scala> timer( sleep(5000) )
scala> Time 5 secs
2) Given
scala> def dTrue = { Thread.sleep(5000); true }
scala> def dFalse = { Thread.sleep(3000); false }
@andy1138
andy1138 / Macros.scala
Created July 3, 2012 13:01
Scala Dojo - Macro
/*
* scalac -language:experimental.macros Macros2.scala
* scalac -language:experimental.macros Test.scala
* scala Test
*/
import scala.reflect.makro.Context
import language.experimental.macros
@andy1138
andy1138 / gist:1648221
Created January 20, 2012 16:24
Code Kata
http://codekata.pragprog.com/2007/01/kata_four_data_.html
Part One: Weather Data
scala> Source.fromFile("weather.dat").getLines.map( """\s+([0-9]+)""".r.findAllIn(_).toList).filter( _.length > 3 ).map( x => ( x(0).trim.toInt, x(1).trim.toInt - x(2).trim.toInt)).toList.sortBy( _._2 ).last
res51: (Int, Int) = (9,54)