Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View lanceon's full-sized avatar

Oleksiy lanceon

View GitHub Profile
@lanceon
lanceon / jqtree.js
Created May 1, 2014 18:59
jqTree - collapse/expand tree
var $tree = $('#tree1');
$('#collapse').click(function() {
var tree = $tree.tree('getTree');
tree.iterate(function(node) {
if (node.hasChildren()) {
$tree.tree('closeNode', node, true);
}
return true;
});
@lanceon
lanceon / start.cmd
Created May 30, 2014 15:31
Apache Directory Studio with JVM6
"Apache Directory Studio.exe" -vm "C:\Program Files (x86)\Java\jre7\bin\java.exe"
@lanceon
lanceon / Tailrec.scala
Last active August 29, 2015 14:06
Compiled and decompiled scala recursive methods with and without @tailrec annotation
package main
import scala.annotation.tailrec
class Tailrec {
def tail1(i: Int): Int = {
if (i >= 10) i
else tail1(i+1)
}
@lanceon
lanceon / Projections.scala
Last active August 29, 2015 14:06
Slick projections/mappings
case class Emp(id: Long,
firstName: Option[String],
lastName: Option[String])
case class EmpProj(id: Column[Long],
firstName: Column[Option[String]],
lastName: Column[Option[String]])
implicit object EmpShape extends CaseClassShape(EmpProj.tupled, Emp.tupled)
@lanceon
lanceon / version.cmd
Created September 17, 2014 17:14
Target JVM version from compiled Java class
javap -verbose MyClass | findstr "major"
Always specify an Expires header. It will normally be set to -1 for immediate expiration of HTML pages or a date well into the future for other resources such as images, CSS and Javascript.
In practice, caching ‘forever’ typically means setting an Expires header value of Sun, 17-Jan-2038 19:14:07 GMT since that’s the maximum value supported by the 32 bit Unix time/date format. If you’re using IIS6 you’ll find that the UI won’t allow anything beyond 31-Dec-2035.
Use Cache-Control: no-cache for dynamic HTML pages
Use the Last-Modified header with the current file time for static HTML
For all other file types set an Expires header to the maximum future date your web server will allow
"All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT), without exception."
@lanceon
lanceon / FuncMemo.scala
Created October 30, 2014 16:40
Memoizes function return value and returns it when called again
class Memoize1[-T, +R](f: T => R) extends (T => R) {
import scala.collection.mutable
private[this] val vals = mutable.Map.empty[T, R]
def apply(x: T): R = {
if (vals.contains(x)) {
vals(x)
}
else {
@lanceon
lanceon / Override.scala
Created November 21, 2014 13:15
Scala objects construction order
trait A {
println("constructing A")
val a = {
val x = value
println(s"calculating A.a = $x")
x
}
def value = {
println("A.value called")
0
@lanceon
lanceon / Main.scala
Last active August 29, 2015 14:10 — forked from xuwei-k/Main.scala
package scalaz_memo_example
import scala.util.control.Exception.allCatch
import scalaz._
import Scalaz._
object Main{
def timer[T](f : => T):T = {
val start = System.currentTimeMillis
-Dscalac.patmat.analysisBudget=off -Duser.timezone=UTC -Xmx2g -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=512m -Xss2m -noverify -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5007