Skip to content

Instantly share code, notes, and snippets.

Avatar

Razvan Cojocaru razie

View GitHub Profile
View po.xml
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.allclient</artifactId>
<version>${com.ibm.mq.version}</version>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>jms</artifactId>
View ReplClassLoader.scala
/**
* To run the Scala compiler programatically, we need to provide it with a
* classpath, as we would if we invoked it from the command line. We need
* to introspect our classloader (accounting for differences between execution
* environments like IntelliJ, SBT, or WebStart), and find the paths to JAR
* files on disk.
*/
final class ReplClassloader(parent: ClassLoader) extends ClassLoader(parent) with razie.Logging {
override def getResource(name: String): URL = {
// Rather pass `settings.usejavacp.value = true` (which doesn't work
View sortLatencyByTopic.sh
grep LF.STOP.PAGE logs/log.log | grep -v "/ping" | sed 's/.*LF.STOP.PAGE .* \(.*\) took \([0-9]*\)ms.*/\2 \1/g' | sort -n -r --key=1 | sort -r --key=2 | uniq --skip-fields=1 | sort -b -n -r | head -20
View sampleStream34.scala
object Sample2 {
val notificationStream : Stream[(String,String)] = Stream.empty
object db {
def findOrder(id:String) : Stream[{def accountId:String}] = Stream.empty
def findAccount(id:String) : Stream[{def email:String}] = Stream.empty
def updateAccount(id:Any) : Stream[Boolean] = Stream.empty
def updateOrder(id:Any) : Stream[Boolean] = Stream.empty
}
object email {
def send(id:String,n:String) : Stream[Boolean] = Stream.empty
View SampleActor34.scala
import akka.actor.{Actor, Props}
import play.libs.Akka
object Sample {
case class MsgNotify()
case class MsgFindOrder(orderId: String)
case class MsgOrderFound(order: {def accountId: String})
case class MsgFindAccount(accountId: String)
case class MsgAccountFound(account: {def email:String})
@razie
razie / start.sh
Created Sep 19, 2014
play start/stop
View start.sh
nohup java $* $_JAVA_OPTIONS -Dlogger.file=$APP/dist/conf/logback.prod.xml -Drk.properties=$RKPROPERTIES -cp $classpath play.core.server.NettyServer $DIST &
@razie
razie / testvol.scala
Created May 30, 2014
testvolatile scala
View testvol.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 / testvol.java
Last active Aug 29, 2015
test volatile i++
View testvol.java
package razie.actionables;
/**
* result is false 69978 vs 100000
*
* @author razvanc
*
*/
public class TestVol {
volatile Long i = 0L;
@razie
razie / play-simple-logging.scala
Last active Dec 28, 2015
I do need to cleanup this code, it was written during stressful times...
View play-simple-logging.scala
/** customize some global handling errors */
object Global extends WithFilters(LoggingFilter) {
// EMAIL BACKOFF stuff
val ERR_DELTA1 = 5 * 60 * 1000 // 5 min
val ERR_DELTA2 = 6 * 60 * 60 * 1000 // 6 hours
val ERR_EMAILS = 5 // per DELTA2
var errEmails = 0 // sent per DELTA2
var lastErrorTime = System.currentTimeMillis - ERR_DELTA1 // time last error email went out - just one every 5 min, eh
var firstErrorTime = System.currentTimeMillis - ERR_DELTA2 // time first error email went out - just one every 5 min, eh
var lastErrorCount = 0 // time last error email went out - just one every 5 min, eh
View play-ping-page.scala
def ping-me() = Action { implicit request =>
Ok(osusage)
}
def osusage = {
var s = ""
val osm: OperatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
for (method <- osm.getClass().getDeclaredMethods()) {
method.setAccessible(true);