Skip to content

Instantly share code, notes, and snippets.

View jestan's full-sized avatar

Jestan Nirojan jestan

View GitHub Profile
@jestan
jestan / about.md
Created May 2, 2012 16:57 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@jestan
jestan / type-bounds.scala
Created April 19, 2012 16:00 — forked from retronym/type-bounds.scala
Tour of Scala Type Bounds
class A
class A2 extends A
class B
trait M[X]
//
// Upper Type Bound
//
def upperTypeBound[AA <: A](x: AA): A = x
@jestan
jestan / 3nightclubs.scala
Created February 25, 2012 08:21 — forked from oxbowlakes/3nightclubs.scala
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._
@jestan
jestan / ScalaEnum.scala
Created February 10, 2012 05:53 — forked from dadrox/ScalaEnum.scala
DIY Scala Enums (with optional exhaustiveness checking, name introspection, and boilerplate reverse lookup)
trait Enum { //DIY enum type
import java.util.concurrent.atomic.AtomicReference //Concurrency paranoia
type EnumVal <: Value //This is a type that needs to be found in the implementing class
def withName(name: String): Option[EnumVal] = values.find(_.name == name)
def withNameIgnoringCase(name: String): Option[EnumVal] = values.find(_.name.equalsIgnoreCase(name))
private def lazyName(requestingInstance: EnumVal): String = {
getClass().getMethods()
@jestan
jestan / gist:1646879
Created January 20, 2012 11:29
squeryl extended types jdbc error
Caused by: org.h2.jdbc.JdbcSQLException: Invalid value "16" for parameter "scale (precision = -1)"; SQL statement:
create table agent_account (
agent_id bigint not null,
occ_version_number int not null,
state int not null,
balance decimal(-1,16) not null,
account_id bigint not null primary key auto_increment,
currency varchar(128) not null
) [90008-163]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
@jestan
jestan / gist:1622552
Created January 16, 2012 19:37
mount shared dir in vbox guest solaris
#install vbox additions and create a shared dir called Shared in host OS
#switch to root and
mount -F vboxfs Shared <path to the local mount dir>
# Fixed header - size 6 byes
# variable length content
|--------- Header --------------| ----- content--|
+--------+----------+-----------+----------------+
| Tag | Seq No | Length | Content |
| 0xCAFE | 0x0001 | 0x000C | "HELLO, WORLD" |
+--------+----------+-----------+----------------+
@jestan
jestan / gist:1554191
Created January 3, 2012 09:07
Linux TCP Stack Params
# sudo sysctl -a | grep tcp
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_retrans_collapse = 1
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_synack_retries = 5
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_tw_buckets = 262144
@jestan
jestan / MyBuild.scala
Created December 30, 2011 09:36
SBT Project with Scala Continuations
import sbt._
import Keys._
object MyBuild extends Build {
val ProjectVersion = "1.0"
val Organization = "org.yit"
val ScalaVersion = "2.9.1"
val repositories = Seq("scala-tools.org" at "http://scala-tools.org/repo-releases")
@jestan
jestan / gist:1526653
Created December 28, 2011 06:11
Linux System Monitoring Commands
#monitor the hard disk utilization
iostat -xm 1
#monitor the cpu usage
sar -P ALL 1
#show disk usage
df -h