Skip to content

Instantly share code, notes, and snippets.

@uarun
uarun / babun_tab_completion.md
Created September 3, 2018 23:20
Fix for Babun Tab completion

Babun Tab Completion

If babun tab completion stops working, then do the following:

$ cd
$ compinit
$ cp .zcompdump .zcompdump-$HOSTNAME-$ZSH_VERSION
@LukaJCB
LukaJCB / Algebra.purs
Last active September 22, 2019 13:01
Alternative Tagless Final encoding in PureScript
module Algebra where
import Prelude
import Control.Monad.Eff (Eff)
import Data.Maybe (Maybe(..))
newtype ConsoleAlg f = ConsoleAlg
{ printLn :: String -> f Unit
, readLn :: f String

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
@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 = {
@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
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@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
@quchen
quchen / trolling_haskell
Last active February 24, 2024 01:30
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
@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

@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