Skip to content

Instantly share code, notes, and snippets.

View razie's full-sized avatar

Razvan Cojocaru razie

View GitHub Profile
@razie
razie / testvol.java
Last active August 29, 2015 14:02
test volatile i++
package razie.actionables;
/**
* result is false 69978 vs 100000
*
* @author razvanc
*
*/
public class TestVol {
volatile Long i = 0L;
@razie
razie / testvol.scala
Created May 30, 2014 17:31
testvolatile scala
@volatile var x = 5
(0 to 10 toList).par foreach { t =>
var i:Int = 0; while (i < 100) {
x += 1
i += 1
}
}
x
@razie
razie / start.sh
Created September 19, 2014 18:04
play start/stop
nohup java $* $_JAVA_OPTIONS -Dlogger.file=$APP/dist/conf/logback.prod.xml -Drk.properties=$RKPROPERTIES -cp $classpath play.core.server.NettyServer $DIST &
def f(x:Int)=1+2
/**
* minimal script interface
*
* TODO use JSR 264 or whatever the thing is and ditch custom code...
*
* @author razvanc
*/
trait RazScript {
import RazScript._
trait InterpolationContext {
implicit def str2interp(s: String) = new InterpolatedString(s)
class InterpolatedString(val s: String) {
def / = interpolate(s)
def identifier = s.substring(2, s.length - 1)
}
object Tokenizer {
def unapply(s: String): Option[Iterator[String]] = {
class Interpreter(val settings: Settings, out: PrintWriter) {
repl =>
// 1. Request is private. I need: dependencies (usedNames?) newly defined values (boundNames?)
// the resulting value and the error message(s) if any
case class PublicRequest (usedNames : List[String], valueNames:List[String], extractionValue:Option[Any])
// 2. Can't get the last request
wif (_ == 1) {
inc + log ($0)
} welse {
inc + inc + log ($0)
}
par {
seq {
inc
log($0)
}
seq {
inc
log($0)
}
}
v(c) (c ? P | c ! Q)