Skip to content

Instantly share code, notes, and snippets.

View razie's full-sized avatar

Razvan Cojocaru razie

View GitHub Profile
<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>
/**
* 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
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
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
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 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 &
@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 / 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 / play-simple-logging.scala
Last active December 28, 2015 06:09
I do need to cleanup this code, it was written during stressful times...
/** 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
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);