This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| class A | |
| class A2 extends A | |
| class B | |
| trait M[X] | |
| // | |
| // Upper Type Bound | |
| // | |
| def upperTypeBound[AA <: A](x: AA): A = x |
| /** | |
| * 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._ |
| 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() |
| 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) |
| #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" | | |
| +--------+----------+-----------+----------------+ |
| # 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 |
| 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") |
| #monitor the hard disk utilization | |
| iostat -xm 1 | |
| #monitor the cpu usage | |
| sar -P ALL 1 | |
| #show disk usage | |
| df -h |