Skip to content

Instantly share code, notes, and snippets.

@berngp
berngp / MarshallerSpecSupport.groovy
Created April 14, 2011 17:53
Unit Testing Custom Object Marshallers with Spock in Grails
package org.osscripters.grails.common.web.converters.marshaller
import grails.plugin.spock.ControllerSpec
import org.codehaus.groovy.grails.support.MockApplicationContext
import org.codehaus.groovy.grails.web.converters.ConverterUtil
import org.codehaus.groovy.grails.web.converters.configuration.ConvertersConfigurationInitializer
import org.springframework.validation.Errors
import org.springframework.web.context.WebApplicationContext
/**
@oxbowlakes
oxbowlakes / 3nightclubs.scala
Created May 13, 2011 15:14
A Tale of 3 Nightclubs
/**
* Part Zero : 10:15 Saturday Night
*
* (In which we will see how to let the type system help you handle failure)...
*
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0)
*/
import scalaz._
import Scalaz._
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@uarun
uarun / scalac-options.md
Last active December 9, 2015 20:39
Useful scalac options (for scala 2.10)

Useful Scalac Options

-encoding "UTF-8"

-target:jvm-1.6

Uses the ASM Compiler backend to generate bytecode (Scala 2.10)

-deprecation

@quchen
quchen / trolling_haskell
Last active November 12, 2024 00:10
Trolling #haskell
13:15 <xQuasar> | HASKELL IS FOR FUCKIN FAGGOTS. YOU'RE ALL A BUNCH OF
| FUCKIN PUSSIES
13:15 <xQuasar> | JAVASCRIPT FOR LIFE FAGS
13:16 <luite> | hello
13:16 <ChongLi> | somebody has a mental illness!
13:16 <merijn> | Wow...I suddenly see the error of my ways and feel
| compelled to write Node.js!
13:16 <genisage> | hi
13:16 <luite> | you might be pleased to learn that you can compile
| haskell to javascript now
@cvogt
cvogt / gist:9239494
Last active September 9, 2019 01:30
Slick app architecture cheat sheet
// Please comment in case of typos or bugs
import scala.slick.driver.H2Driver._
val db = Database.for...(...)
case class Record( ... )
class Records(tag: Tag) extends Table[Record](tag,"RECORDS"){
...
def * = ... <> (Record.tupled,Record.unapply)
// place additional methods here which return values of type Column
@staltz
staltz / introrx.md
Last active November 17, 2024 01:08
The introduction to Reactive Programming you've been missing
@noelwelsh
noelwelsh / Example.scala
Created February 20, 2015 16:06
Robust Error Handling in Scala
import scalaz.\/
import scalaz.syntax.either._
object Example2 {
// This example simulates error handling for a simple three tier web application
//
// The tiers are:
// - the HTTP service
// - a user authentication layer
// - a database layer
@kailuowang
kailuowang / AvroDeserializationSchema.scala
Last active November 4, 2019 13:55
Avro deserializer for Flink's Data Stream API Kafka Source
import org.apache.avro.io.DatumReader
import org.apache.avro.io.DecoderFactory
import org.apache.avro.specific.SpecificDatumReader
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.api.java.typeutils.TypeExtractor
class AvroDeserializationSchema[T <: SpecificRecordBase: ClassTag](private val baselineMessage: () ⇒ T) extends DeserializationSchema[T] {
override def deserialize(message: Array[Byte]): T = {

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x