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
@oscarrenalias
oscarrenalias / ehcache.xml
Created March 1, 2013 08:28
A better ehcache.xml configuration file for the Play Framework, which out of the box limits the size of the cache based on the number of objects you put in it rather than the number of bytes. I personally think that's not a very smart choice. Also see http://ehcache.org/documentation/2.5/configuration/cache-size#cache-configuration-sizing-attribโ€ฆ
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../config/ehcache.xsd" updateCheck="false">
<!-- This is a default configuration for 256Mb of cached data using the JVM's heap, but it must be adjusted
according to specific requirement and heap sizes -->
<defaultCache
maxBytesLocalHeap="256000000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
@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: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
anonymous
anonymous / Haskell
Created October 7, 2013 19:22
Comparison of the straightforward embedding of a basic tenet of category theory in Scala vs Haskell.
yonedaLemma = Iso (flip fmap) ($ id)
@nacyot
nacyot / 2013-03-04-ruby-trivias-you-should-know-4.md
Last active April 23, 2025 00:36
์•Œ์•„๋‘๋ฉด ๋„์›€์ด ๋˜๋Š” 55๊ฐ€์ง€ ๋ฃจ๋น„ ๊ธฐ๋ฒ•

์•Œ์•„๋‘๋ฉด ๋„์›€์ด ๋˜๋Š” 55๊ฐ€์ง€ ๋ฃจ๋น„ ๊ธฐ๋ฒ•

Ruby๋Š” ์ฆ๊ฑฐ์šด ์–ธ์–ด์ž…๋‹ˆ๋‹ค. Ruby๋ฅผ ์‚ฌ์šฉํ•˜๋‹ค๋ณด๋ฉด ๋งค๋‰ด์–ผ์—๋„ ๋‚˜์™€์žˆ์ง€ ์•Š์€ '์ž‘์€ ๋ฐœ๊ฒฌ'์„ ๋งŒ๋‚˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ '๋ฐœ๊ฒฌ'์€ ํ”„๋กœ๊ทธ๋žจ์˜ ์งˆ์ด๋‚˜

@cvogt
cvogt / gist:9193220
Last active February 13, 2022 13:50 — forked from ruescasd/gist:7911033
Slick: Dynamic query conditions using the **MaybeFilter** (Updated to support nullable columns)
import scala.slick.lifted.CanBeQueryCondition
// optionally filter on a column with a supplied predicate
case class MaybeFilter[X, Y](val query: scala.slick.lifted.Query[X, Y]) {
def filter[T,R:CanBeQueryCondition](data: Option[T])(f: T => X => R) = {
data.map(v => MaybeFilter(query.filter(f(v)))).getOrElse(this)
}
}
// example use case
import java.sql.Date
@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}
@runarorama
runarorama / gist:a8fab38e473fafa0921d
Last active April 13, 2021 22:28
Compositional application architecture with reasonably priced monads
sealed trait Interact[A]
case class Ask(prompt: String)
extends Interact[String]
case class Tell(msg: String)
extends Interact[Unit]
trait Monad[M[_]] {
def pure[A](a: A): M[A]
@kevinwright
kevinwright / scaladays2014.md
Last active November 16, 2024 17:40
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

@staltz
staltz / introrx.md
Last active July 31, 2025 06:33
The introduction to Reactive Programming you've been missing