This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`timescale 1ns / 1ps | |
//////////////////////////////////////////////////////////////////////////////// | |
// Company: Carrier Frequency, Inc. | |
// Engineer: Jon Carrier | |
// | |
// Create Date: 21:33:11 01/26/2012 | |
// Design Name: | |
// Module Name: FPGA_2_ShiftReg | |
// Project Name: | |
// Target Devices: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Secured[A](username: String, password: String)(action: Action[A]) = Action(action.parser) { request => | |
request.headers.get("Authorization").flatMap { authorization => | |
authorization.split(" ").drop(1).headOption.filter { encoded => | |
new String(org.apache.commons.codec.binary.Base64.decodeBase64(encoded.getBytes)).split(":").toList match { | |
case u :: p :: Nil if u == username && password == p => true | |
case _ => false | |
} | |
}.map(_ => action(request)) | |
}.getOrElse { | |
Unauthorized.withHeaders("WWW-Authenticate" -> """Basic realm="Secured"""") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Please help compile a list of all Scala-related IRC rooms. | |
All of these channels are on Freenode. | |
#akka | concurrency & distribution framework | |
#argonaut | json library | |
#fp-in-scala | the book Functional Programming in Scala | |
#geotrellis | geoprocessing library | |
#indyscala | regional scala group | |
#json4s | json library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello scala, my old friend | |
I've come to take you home again | |
Because a feature slowly creeping | |
left me plagued with doubts and weeping | |
and the version that was tagged in the repo | |
just has to go | |
it lacks the signs of soundness | |
On sleepless nights I hacked alone | |
applying ant and other tools of stone |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.nicta | |
package rng | |
import scalaz._, Scalaz._, effect._ | |
// A data type representing a person. | |
// We are going to produce random instances. | |
// Note that this data type is recursive. | |
// The `children` field holds 0 or many Person instances. | |
case class Person(name: String, age: Int, surname: Option[String], children: List[Person]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- use postgresql "upsert" using writable CTE (psql 9.1 feature) | |
local sql = [[ | |
WITH new_values (rss_feed, guid, title, url, pubDate, content) AS ( | |
VALUES | |
]]..sprintf('(%s, %s, %s, %s, %s::timestamp, %s)', rss_feed, quote(guid), quote(e.title), quote(e.link), quote(e.updated), quote(content))..[[ | |
), | |
upsert as | |
( | |
UPDATE rss_item m | |
SET rss_feed = nv.rss_feed, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The z in scalaz means this: it was early 2008 and I was working for a Java consultancy and so of course, I used the most appropriate tool for the job: scala. But it had *terrible* libraries, so I offered to fix those while also meeting my other objectives. Turns out that the Scala guys were extremely hostile to even half-decent libraries (and still are to this day). I still struggle to wrap my head around this sometimes. | |
Anyway, so I thought, well fuck it, I will just keep them to myself for now. My (awesome) employer had already agreed that we'd probably open-source such a thing, but I was concerned most about my primary goal. So then it came time to "name" this library. I had named it "scalax" simply so that I did not have the inclination to think of a proper name. Then I found out that such a library was being developed and with my internal name! Whatever, I thought. | |
So I looked at this scalax library, hoping that I could just abandon my efforts and jump on board with everyone else -- they too had figure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import annotation._ | |
case class Pronunciation(pronounce: String) extends StaticAnnotation | |
case class Law(name: String, denotation: String) extends StaticAnnotation | |
trait ~>[F[_], G[_]] { | |
def apply[A]: F[A] => G[A] | |
} | |
case class Id[A](x: A) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> case class Bad(a: Int) { override def equals(a:Any) = true } | |
scala> val f = (n:Int) => Bad(n) | |
scala> val g = (b:Bad) => b.a | |
... | |
scala> Set(1,2,3).map(f andThen g) | |
res2: scala.collection.immutable.Set[Int] = Set(1, 2, 3) | |
scala> Set(1,2,3).map(f).map(g) |
OlderNewer