Skip to content

Instantly share code, notes, and snippets.

View ktoso's full-sized avatar
🗻
Life is Study!

Konrad `ktoso` Malawski ktoso

🗻
Life is Study!
View GitHub Profile
apply plugin: 'groovy'
sourceCompatibility = 1.5
version = '0.1-SNAPSHOT'
repositories {
mavenRepo(urls: 'http://repository.codehaus.org/')
mavenCentral()
}
@dt
dt / install_flatmap_reminder.sh
Created July 18, 2011 21:58
In case you occasionally forget to flatMap that shit
brew install growlnotify
cat >> ~/.bashrc <<EOF
#flatMapThatShit reminder
if [ -f /tmp/flatMapThatShit ]; then
kill \`cat /tmp/flatMapThatShit\`
fi
while true; do if [[ \$RANDOM%12 -eq 0 ]]; then growlnotify -a TextEdit "Is that scala?" -m "flatMap that shit"; fi; sleep 300; done &
@schmmd
schmmd / binary.scala
Created October 8, 2011 04:57
scala binary tree
/* contravariance required so Empty can be used with Nodes ( Nothing <: T ) */
class Tree[+T]
case object Empty extends Tree[Nothing]
case class Node[T](val elem: T, val left: Tree[T], val right: Tree[T]) extends Tree[T]
def inOrder[T](t: Tree[T]): List[T] = t match {
case Empty => Nil
case Node(e, left, right) => inOrder(left) ::: List(e) ::: inOrder(right)
}
val query = ScalasticSearch.boolQuery(
cond (
must(
'nickname -> "Superman", // is equivalent to...
term('nickname -> "Superman"), // this
term("nickname" -> "Superman") // or this
),
should(
'nickname -> "Superman", // is equivalent to...
term('nickname -> "Superman"), // this
anonymous
anonymous / Keys.scala
Created December 18, 2012 10:30
Generate a file containing sbt version information during the build. Using this, you can achieve a very simple version of ktoso/git-commit-id-maven-plugin
val genVersionFile = TaskKey[Unit](
"gen-version-file",
"Generates a file in target containing the apps version"
)
system ~/projects/rubyflux $ cat blah.rb
def method_missing(name, args)
puts name
end
foo
bar
baz
system ~/projects/rubyflux $ rake run[blah.rb]
/**
* "Select" off the first future to be satisfied. Return this as a
* result, with the remainder of the Futures as a sequence.
*
* @param fs a scala.collection.Seq
*/
def select[A](fs: Seq[Future[A]])(implicit ec: ExecutionContext): Future[(Try[A], Seq[Future[A]])] = {
@tailrec
def stripe(p: Promise[(Try[A], Seq[Future[A]])],
heads: Seq[Future[A]],
@ktoso
ktoso / output.bash
Last active June 12, 2016 17:20
An proof of concept implementation to Adam's "what if we just used the types" blog post http://www.warski.org/blog/2013/01/dry-parameter-names/
ktoso@moon /Users/ktoso
$ scalac vals_by_types.scala
warning: there were 2 deprecation warnings; re-run with -deprecation for details
one warning found
ktoso@moon /Users/ktoso
$ scala Main
The combined names are: UserFinder and UserStatusReader
// or even more plain:
testCases.foreach((case) -> {
// given
Object given = case.given;
Object expected = case.expected;
it.should("return [%s] when applied to [%s]", given, expected, system -> {
// when
Object got = system.doThing(given);
@krasserm
krasserm / akka-persistence-plugins.md
Last active March 27, 2017 10:13
Akka Persistence Plugins