#Create bitbucket branch
##Create local branch
$ git checkout -b sync
Switched to a new branch 'sync'
$ git branch
master
* sync
val pattern = java.util.regex.Pattern.compile ("""(?xs) ("(.*?)"|) ; ("(.*?)"|) (?: \r?\n | \z ) """) | |
val matcher = pattern.matcher (input) | |
while (matcher.find) { | |
val col1 = matcher.group (2) | |
val col2 = matcher.group (4) | |
// ... | |
} |
# E.g. TaskClass = CaseClass('name', 'owner', 'pid') | |
# task1 = TaskClass(name = "hello", owner = "brian", pid = 15) | |
# task2 = TaskClass(name = "world", owner = "brian", pid = 13) | |
# tasks = [task1, task2] | |
# | |
# filter(lambda task: task.where(owner = "brian"), tasks) => [task1, task2] | |
# filter(lambda task: task.where(owner = "brian", pid = 13), tasks) => [task2] | |
# | |
# matcher = TaskClass(pid = 13) | |
# filter(lambda task: task.match(matcher), tasks) => [task2] |
package com.vasilrem.ttt | |
import org.specs._ | |
class GameSpecs extends Specification{ | |
implicit def toOption[A, B](either: Either[A, B]): Option[B] = | |
either.right.toOption | |
"Play a winning game" in { |
#!/bin/sh | |
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the | |
# CREATE block and create them in separate commands _after_ all the INSERTs. | |
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk. | |
# The mysqldump file is traversed only once. | |
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite | |
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite |
package my.collections | |
class CirculrBufferIterator[T](buffer:Array[T], start:Int) extends Iterator[T]{ | |
var idx=0 | |
override def hasNext = idx<buffer.size | |
override def next()={ | |
val i=idx | |
idx=idx+1 | |
buffer(i) | |
} |
#Create bitbucket branch
##Create local branch
$ git checkout -b sync
Switched to a new branch 'sync'
$ git branch
master
* sync
def Secured[A](username: String, password: String)(action: Action[A]) = Action(action.parser) { request => | |
request.headers.get("Authorization").flatMap { authorization => | |
authorization.split(" ").drop(1).headOption.filter { encoded => | |
new String(org.apache.commons.codec.binary.Base64.decodeBase64(encoded.getBytes)).split(":").toList match { | |
case u :: p :: Nil if u == username && password == p => true | |
case _ => false | |
} | |
}.map(_ => action(request)) | |
}.getOrElse { | |
Unauthorized.withHeaders("WWW-Authenticate" -> """Basic realm="Secured"""") |
/* | |
Copyright 2012-2021 Viktor Klang | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
# no 64 bit version of the flash debug player is available, thus we will use the 32 bit version and use nspluginwrapper to make it work | |
sudo killall -9 firefox | |
sudo apt-get remove -y --purge flashplugin-nonfree gnash gnash-common mozilla-plugin-gnash swfdec-mozilla libflashsupport nspluginwrapper | |
sudo rm -f /usr/lib/mozilla/plugins/*flash* | |
sudo rm -f ~/.mozilla/plugins/*flash* | |
sudo rm -f /usr/lib/firefox/plugins/*flash* | |
sudo rm -f /usr/lib/firefox-addons/plugins/*flash* | |
sudo apt-get install ia32-libs nspluginwrapper libcurl3 libnss3-1d libnspr4-0d | |
cd ~ |
package akka.cluster | |
import com.typesafe.config.ConfigFactory | |
import akka.remote.testkit.MultiNodeConfig | |
import akka.remote.testkit.MultiNodeSpec | |
import akka.testkit._ | |
import akka.util.duration._ | |
import akka.cluster.MemberStatus._ | |
object ClusterDemoMultiJvmSpec extends MultiNodeConfig { |