This file contains hidden or 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
// Create BUILD_INFO file showing status about the build in question | |
unmanagedResources in Compile <++= baseDirectory.map { base => | |
val dir = java.nio.file.Files.createTempDirectory("sbt_build_info_").toFile | |
val buildFile = java.io.File.create(dir, "BUILD_INFO") | |
buildFile.deleteOnExit | |
dir.deleteOnExit | |
val fw = new java.io.FileWriter(buildFile) | |
fw.write( | |
s"""|Built by ${System.getProperty("user.name")} @ ${java.net.InetAddress.getLocalHost.getHostName} on ${new java.util.Date} | |
|=== |
This file contains hidden or 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
#!/bin/bash | |
exec scala -savecompiled "$0" "$@" | |
!# | |
// Given all torrents are paused, this script starts the first one | |
import sys.process._ | |
val host = "127.0.0.1:9091" | |
val auth = "myuser:mypassword" |
This file contains hidden or 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
implicit val SetOfStrings = MappedColumnType.base[Set[String], Option[String]] ( | |
values => values match { | |
case values if values.nonEmpty => Some(values.toSeq.sorted.mkString("\n")) | |
case _ => None | |
}, | |
str => str.map(_.split('\n').toSet).getOrElse(Set.empty) | |
) | |
// could not find implicit value for evidence parameter of type SchemaBase.this.driver.BaseColumnType[Option[String]] |
This file contains hidden or 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
import scala.concurrent.{ExecutionContext, Future} | |
import scala.util.{Failure, Success} | |
object CachedFuture { | |
/** | |
* Returns a function which returns previously calculated Future (if one exists, and hasn't expired) | |
* - If result does not exist (or has expired), we share a common `pendingResult` | |
* to prevent same calculation being repeated. | |
*/ |
This file contains hidden or 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
add_to_path() { | |
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then | |
export PATH="$1:$PATH" | |
fi | |
} | |
add_to_path $HOME/apps/foobar | |
findFromHistory() { | |
history | cut -c 8-|awk '!x[$0]++'|grep $1 | |
} |
This file contains hidden or 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
import scala.concurrent.{ExecutionContext, Future} | |
import scala.util.{Failure, Success} | |
object FutureCache { | |
/** | |
* Returns a function which returns previously calculated Future (if one exists, and hasn't been expired) | |
* - If result does not exist (or has expired), we share a common `pendingFuture` | |
* to prevent same calculation being repeated | |
*/ |
This file contains hidden or 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
plz-sudo() { | |
local pass=`gimme-passwd` | |
echo $pass | sudo -S "$@" | |
} | |
gimme-passwd() { | |
local GPG_PASS_FILE="/home/pyppe/password.txt.gpg" | |
read -sp "Enter passphrase: " gpgpass | |
echo "${gpgpass}" | gpg --yes --no-tty --batch --passphrase-fd 0 -o- $GPG_PASS_FILE | |
} |
This file contains hidden or 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
curl -XPOST http://localhost:9200/_optimize | |
curl -XPOST http://localhost:9200/_flush | |
curl -XPOST http://localhost:9200/_all/_close | |
# DO THE BACKUP | |
curl -XPOST http://localhost:9200/_all/_open |
This file contains hidden or 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
(function() { | |
var ISO_DAY = 'YYYY-MM-DD'; | |
var FIN_DAY = 'D.M.YYYY'; | |
function showExport(data) { | |
$('#polar-flow-export').remove(); | |
var $el = $('<div id="polar-flow-export"></div>'); | |
$el. | |
css({ |
This file contains hidden or 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 { | |
import play.api.libs.json._ | |
import play.api.libs.json.Reads._ | |
val json = Json.obj( | |
"foo" -> "bar", | |
"user" -> Json.obj( | |
"name" -> "Mike", | |
"age" -> 45, | |
"food" -> "pizza" |