Skip to content

Instantly share code, notes, and snippets.

View ikhoon's full-sized avatar
🐱
Working from home

Ikhun Um ikhoon

🐱
Working from home
View GitHub Profile
@oinume
oinume / connect.rb
Created April 1, 2013 10:29
Connecting to MySQL with JRuby and JDBC.
require 'java'
require 'rubygems'
require 'dbi'
require 'dbd/Jdbc'
require 'jdbc/mysql'
Jdbc::MySQL.load_driver
DBI.connect(
'DBI:Jdbc:mysql://localhost/test',
@milessabin
milessabin / gist:25b7b669b5a9ac051a71
Created June 5, 2015 14:32
A safe ADT+shapeless drop-in replacement for the unsafe standard Scala Enumeration ...
// An ADT+shapeless as a drop-in replacement for a standard Scala Enumeration.
//
// First the unsafe standard Scala Enumeration ...
//
object ScalaEnumDemo extends App {
// Example from scala.Enumeration scaladoc. Terse ...
object WeekDay extends Enumeration {
type WeekDay = Value
val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value
}
@pchiusano
pchiusano / fs2-0.9-release-announcement.markdown
Last active September 20, 2016 12:46
FS2: Functional Streams for Scala 0.9 Official Release Announcement

Hi all!

After a very lengthy period of development and testing, FS2 (formerly scalaz-stream) version 0.9 is finally out! Here's how to get it.

For this release, the library has undergone a major redesign. Check out the migration guide for more info, and also the shiny new user guide. Going forward, we expect the API of the library will be quite stable and hope it becomes one of the bedrock libraries of the Scala ecosystem. The 0.9 series has already seen production use as well as a huge amount of testing during the development process; we feel very good about recommending people upgrade.

@ayosec
ayosec / 0README.md
Last active February 10, 2017 00:52
Spray: example with a router based on actors

Test with

$ sbt run

And then,

$ curl localhost:8080/mars/hi

$ curl localhost:8080/jupiter/hi

@milessabin
milessabin / gist:081dcf2807f9563052ce
Created December 19, 2014 07:58
whitebox/blackbox abort behaviour difference.
import scala.language.experimental.macros
import scala.reflect.macros.whitebox
trait Foo[T]
object Foo {
implicit def mkFoo[T]: Foo[T] = macro FooMacros.mkFooImpl[T]
}
@milessabin
milessabin / gist:aae285025a32fac0f5c1
Last active August 26, 2017 10:28
Trivial type safe heterogenous map using only dependent method types, singleton-typed String literal keys and implicits.
scala> trait Assoc[K] { type V ; val value: V }
defined trait Assoc
scala> def mkAssoc[V0](k: String, v: V0): Assoc[k.type] { type V = V0 } =
| new Assoc[k.type] { type V = V0 ; val value = v }
mkAssoc: [V0](k: String, v: V0)Assoc[k.type]{type V = V0}
scala> implicit def nameAssoc = mkAssoc("Name", "Mary")
nameAssoc: Assoc[String("Name")]{type V = String}
@kevinwright
kevinwright / scaladays2014.md
Last active March 8, 2018 20:25
Scaladays 2014 slides

As compiled by Kevin Wright a.k.a @thecoda

(executive producer of the movie, and I didn't even know it... clever huh?)

please, please, please - If you know of any slides/code/whatever not on here, then ping me on twitter or comment this Gist!

This gist will be updated as and when I find new information. So it's probably best not to fork it, or you'll miss the updates!

Monday June 16th

@milessabin
milessabin / gist:6256495
Last active March 10, 2018 02:26
Path dependent types with an implicit prefix. We can infer the singleton type prefix of a path dependent type and then implicitly summon the unique value of that singleton type.
Welcome to Scala version 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_21).
Type in expressions to have them evaluated.
Type :help for more information.
scala> class Prefix { class Dep { type P = Prefix.this.type } }
defined class Prefix
scala> val (p1, p2) = (new Prefix, new Prefix)
p1: Prefix = Prefix@2212c414
p2: Prefix = Prefix@7e070e85
@alexandru
alexandru / task-proposal.md
Last active April 1, 2018 14:57
Task: A diverging design from Future and Scalaz Task
@milessabin
milessabin / gist:8833a1dbf7e8245b30f8
Last active April 16, 2018 02:39
Now in shapeless 2.1.0-SNAPSHOT: "shapeless.the" an enhanced alternative to "Predef.implicitly".
// Used as a term `the[T]` yields the unique implicit value of type `T` in the current
// implicit scope, if any. It is a compile time error if there is no such value. Its
// primary advantage over `Predef.implicitly` is that it will preserve any refinement that
// the implicit definition has, resulting in more precisely typed, and hence often more
// useful, values,
scala> trait Foo { type T ; val t: T }
defined trait Foo
scala> implicit val intFoo: Foo { type T = Int } = new Foo { type T = Int ; val t = 23 }