Skip to content

Instantly share code, notes, and snippets.

@uarun
uarun / akka_faq.md
Last active January 3, 2016 11:29
Akka FAQ and notes for myself :)

Akka FAQ

  1. Constructor vs preStart() - Is it ok to create child actors in the constructor vs doing it in preStart() ?

Both the constructor and preStart() are called during a restart. So it's absolutely fine to created child actors in the constructor. (Aside: when using preStart() always call super.preStart() first). If for some reason you don't want to create children during restart then use preStart() for creating and make sure you overrride preRestart()

@uarun
uarun / MethodInjection.scala
Created January 14, 2014 04:45
Type class technique as used in Scalaz 7 for method injection
package org.uarun.typeclasses
object Main extends ToDoubleOps {
def main(args: Array[String]) {
val x = 100
println(s"$x doubled is ${x.doubled}")
}
}
trait DoubleOps[A] {
@uarun
uarun / xsudo.sh
Last active December 17, 2015 11:19
Script to carry X11 Forwarding even after Sudo
#!/bin/sh
user=$1
if [ -z "$user" ]; then
user=liquidnt
fi
displayNum=`echo $DISPLAY | sed -e 's/^.*://' -e 's/\.[0123456789]*//'`
echo "Display # = $displayNum"
cookie=`xauth list | grep ":$displayNum"`
@uarun
uarun / dot_mongorc.js
Created March 25, 2013 02:59
MongoDB - Enable pretty print globally by default
DBQuery.prototype._prettyShell = true
@uarun
uarun / intellij.md
Last active February 26, 2024 06:57
Intellij IDEA - Cheat Sheet (aka useful shortcuts)

Intellij IDEA - Cheat Sheet (aka most useful shortcuts)

Note: Some of these keymapping are specific to IdeaVim plugin. If you don't use IdeaVim (what' wrong with you :)), I've tried to point out where they differ, but I could have missed a few

Coding Session

Parameter documentation for Method Calls

  • Ctrl-P - Popup parameter documentation for method calls
@uarun
uarun / build.gradle
Last active December 11, 2015 08:58 — forked from rodionmoiseev/gist:2484934
Gradle build for Play 2
apply plugin: 'java'
apply plugin: 'scala'
// For those using Eclipse or IntelliJ IDEA
apply plugin: 'eclipse'
apply plugin: 'idea'
def findPlay20(){
def pathEnvName = ['PATH', 'Path'].find{ System.getenv()[it] != null }
for(path in System.getenv()[pathEnvName].split(File.pathSeparator)){
for(playExec in ['play.bat', 'play.sh', 'play']){
@uarun
uarun / version_conflicts_gradle.md
Created December 25, 2012 20:19
Resolving version conflicts in Gradle

Resolving Version Conflicts in Gradle

If one module has a dependency on version 1.1 of library X and another module on version 2.0 of the same library, gradle will use the latest version.

Failing a build on version conflict

To make gradle fail the build on encountering a conflict, we can do the following:

configurations.all {

resolutionStrategy {

@uarun
uarun / scalac-options.md
Last active December 9, 2015 20:39
Useful scalac options (for scala 2.10)

Useful Scalac Options

-encoding "UTF-8"

-target:jvm-1.6

Uses the ASM Compiler backend to generate bytecode (Scala 2.10)

-deprecation

@uarun
uarun / BuildConfig.groovy
Created September 27, 2012 20:52
Accessing authenticated Nexus (from Grails)
import org.apache.ivy.util.url.CredentialsStore
CredentialsStore.INSTANCE.addCredentials(
nexusRealm,
nexusHost,
nexusUserName,
nexusPassword
)
/* Example *
@uarun
uarun / zsh.md
Created August 17, 2012 03:11
Zsh Tips & Tricks

Zsh Tips and Tricks

Argument History

!*        # ... All parameters of the last command
!$        # ... Last parameter of the last command
!^        # ... First parameter of the last command
!:1       # ... First parameter of the last command

!-2:2 # ... Second parameter from 2 commands ago