Skip to content

Instantly share code, notes, and snippets.

View jkpl's full-sized avatar

Jaakko Pallari jkpl

View GitHub Profile
@jkpl
jkpl / ActorSequence.scala
Created August 6, 2015 08:22
Sequence of Akka actors
package shardaus
import akka.actor._
import scalaz._
import Scalaz._
object ActorSequence {
type SequenceProp = ActorRef => Props
@jkpl
jkpl / Striimaus.scala
Created August 12, 2015 10:24
Shoddy Akka Kafka example
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 September 10, 2015 10:11
At least once delivery with async persistence
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 September 10, 2015 10:11
Async stream decoding using scodec
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 September 12, 2015 18:33
Script for showing/hiding KeepassX window. Bind to a global shortcut for max power.
#!/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 September 13, 2015 12:48
Batch convert OpenDocument spreadsheets to CSV using LibreOffice
#!/bin/sh -e
LO_PROFILE_DIR="/tmp/LO_conversions"
libreoffice \
"-env:UserInstallation=file://$LO_PROFILE_DIR" \
--headless --invisible \
--convert-to csv *.ods \
--outdir csv
@jkpl
jkpl / bootstrap.sh
Last active November 29, 2017 22:04
Fedora bootstrap
#!/bin/bash
dnf --refresh upgrade
dnf install --nogpgcheck \
http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \
http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
dnf --refresh groupinstall "Development Tools"
dnf install $(grep fedora_packages.txt -v -e '^#' -e '^$' | tr '\n' ' ')
@jkpl
jkpl / path.sh
Created September 27, 2015 10:01
Path management for Bash
function join {
local IFS="$1"
shift
echo "$*"
}
export CUSTOM_PATHS=(
"$HOME/Apps/myapp"
"$HOME/Apps/myapp2/bin"
)
@jkpl
jkpl / sharescrot.sh
Last active January 9, 2016 19:36
Share screenhots using generic web host
#!/bin/sh
remote_path="myhost:path/to/screenshots/"
seconds=$(date +%s)
filename="${seconds}.png"
tmpdir="/tmp"
tmpfile="$tmpdir/$filename"
public_base_path="https://example.org/screenshots"
public_path="$public_base_path/$filename"
@jkpl
jkpl / ghwh.php
Created February 16, 2016 19:00
Basic Github webhook
<?php
// Conf
$secret = 'mysecret';
$command = '/path/to/script.sh';
function fail($msg) {
http_response_code(400);
echo $msg;
exit(1);