Skip to content

Instantly share code, notes, and snippets.

Avatar
🌜

Jaakko Pallari jkpl

🌜
View GitHub Profile
@jkpl
jkpl / macros.py
Created May 12, 2015
Macros for Poole
View macros.py
import os
import json
import iso8601
from datetime import datetime
from lesscss import LessCSS
# Defaults
page = {}
pages = []
@jkpl
jkpl / spotify.py
Created May 30, 2015
Spotify lookup in command line
View spotify.py
#!/usr/bin/python
import urllib
import sys
import json
import re
SP_REGEX = re.compile('^http://[\S]+/track/([\S]+)')
SP_LOOKUP_BASEURL = 'http://ws.spotify.com/lookup/1/.json?uri=spotify:track:%s'
@jkpl
jkpl / spotifyctrl.sh
Created May 30, 2015
Spotify app controls in command line
View spotifyctrl.sh
#!/bin/bash
SPOTIFYCMD="dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player."
function spotify_oper {
${SPOTIFYCMD}$1
}
case $1 in
"play")
@jkpl
jkpl / box.js
Created Jul 28, 2015
Promise based queue
View box.js
function mkBox() {
var box = {values: [], reads: []};
box.enq = function(value) {
box.values.push(value);
if (box.reads.length > 0) {
box.reads.shift().resolve(box.values.shift());
}
return box;
};
@jkpl
jkpl / ActorSequence.scala
Created Aug 6, 2015
Sequence of Akka actors
View ActorSequence.scala
package shardaus
import akka.actor._
import scalaz._
import Scalaz._
object ActorSequence {
type SequenceProp = ActorRef => Props
@jkpl
jkpl / Striimaus.scala
Created Aug 12, 2015
Shoddy Akka Kafka example
View Striimaus.scala
package striimaus
import java.util.Properties
import akka.actor._
import akka.persistence.{Persistence, PersistentActor, PersistentView}
import com.typesafe.config.{Config, ConfigFactory}
import kafka.consumer._
import kafka.producer.{KeyedMessage, Producer, ProducerConfig}
import kafka.serializer.StringDecoder
@jkpl
jkpl / AinakinKerran.scala
Last active Sep 10, 2015
At least once delivery with async persistence
View AinakinKerran.scala
package ainakin.kerran
import akka.actor._
import akka.persistence.{AtLeastOnceDelivery, PersistentActor}
import com.typesafe.config.ConfigFactory
import scala.concurrent.duration._
object AinakinKerran {
def start(): Unit = {
val as = ActorSystem("AinakinKerran", ConfigFactory.load("common"))
@jkpl
jkpl / VirtaDekoodaus.scala
Last active Sep 10, 2015
Async stream decoding using scodec
View VirtaDekoodaus.scala
package virta.dekoodaus
import java.nio.charset.Charset
import java.util.concurrent.Executors
import scodec.Codec
import scodec.bits.BitVector
import scodec.codecs._
import scodec.stream._
import scodec.stream.decode.StreamDecoder
@jkpl
jkpl / showkeepassx.sh
Created Sep 12, 2015
Script for showing/hiding KeepassX window. Bind to a global shortcut for max power.
View showkeepassx.sh
#!/bin/sh -e
function xdokeepassx {
xdotool search --maxdepth 3 --classname keepassx $@
}
function show_keepassx {
local desktop="`xdotool get_desktop`"
xdokeepassx \
set_desktop_for_window %@ $desktop \
@jkpl
jkpl / to_csv.sh
Created Sep 13, 2015
Batch convert OpenDocument spreadsheets to CSV using LibreOffice
View to_csv.sh
#!/bin/sh -e
LO_PROFILE_DIR="/tmp/LO_conversions"
libreoffice \
"-env:UserInstallation=file://$LO_PROFILE_DIR" \
--headless --invisible \
--convert-to csv *.ods \
--outdir csv