Skip to content

Instantly share code, notes, and snippets.

View targeter's full-sized avatar

Sietse de Kaper targeter

View GitHub Profile
@targeter
targeter / gist:2e908adaa12b070611c139ea587084e2
Created September 2, 2020 06:56 — forked from 2shortplanks/gist:6b851763a063cc6bc08047a5408387e2
Configure Karabiner Elements to control itunes volume / pause itunes. Install Karabiner-Elements from https://github.com/tekezo/Karabiner-Elements. Download this gist and put in `~/.config/karabiner/assets/complex_modifications`, then go to "Complex Modifications" tab, press "+ Add Rule" and then click Enable next to the rules
{
"title" : "iTunes direct",
"rules" : [
{
"manipulators" : [
{
"from" : {
"modifiers" : {
"mandatory" : [
"fn",
; Logitech Harmony Remote / Pivos XIOS DS Media Player remote
; for ENY M8 Android TV Box
;
; Author: Johan van Zoomeren
; Date : June 28th 2014
;
; Original M8 remote is not available in the Logitech Database. Pivos XIOS DS is
; available in the Logitech database and is sending IR codes using required NEC
; protocol. Though physically this remote does not have a lot buttons, the
; Logitech database provides more. All of which are mapped below.
case class FormUser(name: String, email:String)
case class DbUser(id: Option[Long], name: String)
case class DbEmail(id: Option[Long], email: String, relation:Long)
def action = {
userFromForm: FormUser = bindFromForm()
val newDbUser = db.insert(DbUser(None, userFromForm.name))
val newDbEmail = db.insert(DbEmail(None, userFromForm.email, newDbUser.id.get))
}
### Keybase proof
I hereby claim:
* I am targeter on github.
* I am targeter (https://keybase.io/targeter) on keybase.
* I have a public key whose fingerprint is 2E8E 2E0E 7232 C489 15C9 EADB F128 8EA6 E0CD 3CB8
To claim this, I am signing this object:
@targeter
targeter / gist:10641566
Created April 14, 2014 12:02
Streaming XML from Mongo GridFS
def processDocument(documentKey: String): Future[Option[Elem]] = {
val inputStream = new PipedInputStream(8192)
val outputStream = new PipedOutputStream(inputStream)
Mongo.getDocument(documentKey).map(_.map(readFile =>
{
val write = Mongo.gridFs.readToOutputStream(readFile, outputStream).onComplete {
case _ => outputStream.close()
}
XML.load(inputStream)
}
@targeter
targeter / gist:10235472
Last active August 29, 2015 13:58
Going from Option[Future[A]] to Future[Option[A]]
val ofi:Option[Future[Int]] = Some(future(1))
val foi:Future[Option[Int]] = ofi.fold(future(None: Option[Int]))(_.map {i: Int => Some(i)} )
@targeter
targeter / ehcache.xml
Created July 4, 2013 07:28
This ehcache will make the Play cache persisted
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../config/ehcache.xsd" updateCheck="false">
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="false"
maxElementsOnDisk="10000000"
diskPersistent="true"
@targeter
targeter / alerts.scala.html
Created January 24, 2013 16:01
Scala templates Bootstrap-style alerts from flash
@Array("error", "warning", "success", "info").map { level =>
@if(flash.contains(level)) {
<div class="alert alert-@level">
<button type="button" class="close" data-dismiss="alert">&times;</button>
@flash.get(level)
</div>
}
}
13:26:26,627 ERROR ~
@6b8i881bh
Internal Server Error (500) for request POST /relations/dosendmessage
Execution exception (In /app/controllers/Relations.java around line 787)
IllegalArgumentException occured : org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [select generatedAlias0 from models.Relation as generatedAlias0 where generatedAlias0.id in ()]
play.exceptions.JavaExecutionException: org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [select generatedAlias0 from models.Relation as generatedAlias0 where generatedAlias0.id in ()]
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)
@(productForm: Form[Product])
@import helper._
@import helper.twitterBootstrap._
@main("Product form") {
<h1>Product form</h1>
@helper.form(action = routes.Products.save()) {
<fieldset>
<legend>Product @productForm("name").valueOr("(new)")</legend>
@helper.inputText(productForm("ean"))
@helper.inputText(productForm("name"))