This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------------------------ | |
# Desigining "trending topics in 24 hours sliding window" with Redis | |
# ------------------------------------------------------------------ | |
redis-cli del tophashes:2010-12-07-08-00 | |
redis-cli del tophashes:2010-12-07-09-00 | |
redis-cli del tophashes:current | |
echo '=== 8:00 AM ===' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: | |
// p(instance)('privateMethod)(arg1, arg2, arg3) | |
class PrivateMethodCaller(x: AnyRef, methodName: String) { | |
def apply(_args: Any*): Any = { | |
val args = _args.map(_.asInstanceOf[AnyRef]) | |
def _parents: Stream[Class[_]] = Stream(x.getClass) #::: _parents.map(_.getSuperclass) | |
val parents = _parents.takeWhile(_ != null).toList | |
val methods = parents.flatMap(_.getDeclaredMethods) | |
val method = methods.find(_.getName == methodName).getOrElse(throw new IllegalArgumentException("Method " + methodName + " not found")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rsync -avz /path/to/local/sync/folder -e "ssh -i /path/to/ssh/key" ubuntu@ec2instance:/path/to/remote/sync/folder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An example of using ngram analysis in ElasticSearch with the Tire rubygem | |
# ========================================================================== | |
# The original, raw example: https://gist.github.com/988923 | |
require 'rubygems' | |
require 'tire' | |
require 'yajl/json_gem' | |
class URL | |
def initialize(attributes={}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Main extends App { | |
AvoidLosingGenericType.run() | |
AvoidMatchingOnGenericTypeParams.run() | |
TypeableExample.run() | |
TypeTagExample.run() | |
} | |
class Funky[A, B](val foo: A, val bar: B) { | |
override def toString: String = s"Funky($foo, $bar)" | |
} |