Skip to content

Instantly share code, notes, and snippets.

View jkpl's full-sized avatar

Jaakko Pallari jkpl

View GitHub Profile
@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 / Main.scala
Created January 8, 2018 15:43
Dropwizard Graphite demo for Scala
package dwgraphitedemo
import java.lang.management.ManagementFactory
import java.util.concurrent.TimeUnit
import com.codahale.metrics.graphite.{Graphite, GraphiteReporter}
import com.codahale.metrics.SharedMetricRegistries
import com.codahale.metrics.jvm._
import com.twitter.finagle.http.{Request, Response, Status}
import com.twitter.finagle.{Http, Service}
@jkpl
jkpl / keybase.md
Last active April 1, 2019 18:12
keybase.md

Keybase proof

I hereby claim:

  • I am jkpl on github.
  • I am jkpl (https://keybase.io/jkpl) on keybase.
  • I have a public key ASA3n-ICY3CrHvBEUoW3UG4vA3md_9RKyDFL3AT30KJAswo

To claim this, I am signing this object:

@jkpl
jkpl / freefrp.js
Last active May 7, 2020 07:27
Free monad based thread simulation and FRP constructs written in JavaScript. http://stuff.lepovirta.org/r/freefrp/
// Free monad based thread simulation and FRP constructs written in JavaScript
// First, we need some way to express lazy values and actions.
// We can use zero-argument functions for this purpose: call the function and
// you get the value. We also need to compose lazy values/actions. For that
// we have bindLazy function. Lazy values are not expected to be pure
// in this program: evaluating a lazy value/action at different times can produce
// a different value.
@jkpl
jkpl / ResponseCollector.scala
Last active October 20, 2020 10:13
Reusable response collector in Akka
package collector
import akka.actor._
import akka.util.Timeout
import scala.concurrent.duration._
import scala.concurrent.{Future, Promise}
trait ResponseTracker[T] {
def addResponse(response: T): ResponseTracker[T]
def isDone: Boolean
@jkpl
jkpl / eap-ttls-pap
Created February 1, 2013 18:46
Wicd template for Eduroam networks (this should work on Univesity of Jyväskylä's jyu-student and jyu-staff networks).
name = EAP-TTLS-PAP
author = jkpl
version = 1
require identity *Identity password *Password
optional ca_cert *Path_to_CA_cert anon_identity *Anonymous_Identity
protected password *Password
-----
ctrl_interface=/var/run/wpa_supplicant
network={
ssid="$_ESSID"
param (
[Parameter(Mandatory=$false)]
[switch]$Disable
)
$script:regKeyPath = "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity"
If ($Disable) {
Write-Host "Disabling HyperV"
bcdedit /set hypervisorlaunchtype off
@jkpl
jkpl / U.S. International wo dead keys.keylayout
Created March 9, 2022 07:00
U.S. International w/o dead keys keyboard layout for Mac
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard PUBLIC "" "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<!--Last edited by Ukelele version 2.0.1 on 2010-08-26 at 17:40 (GMT+02:00)-->
<keyboard group="0" id="2" name="U.S. International w/o dead keys" maxout="1">
<layouts>
<layout first="0" last="17" modifiers="f4" mapSet="16c"/>
<layout first="18" last="18" modifiers="f4" mapSet="994"/>
<layout first="21" last="23" modifiers="f4" mapSet="994"/>
<layout first="30" last="30" modifiers="f4" mapSet="994"/>
<layout first="194" last="194" modifiers="f4" mapSet="994"/>
#!/bin/sh
#
# This script deploys the given manifest,
# tracks the deployment, and rolls back on failure.
#
# First execute this with "myapp.yaml" and then try it with "myapp.failing.yaml"
#
MANIFEST_PATH=$1
DEPLOYMENT_NAME=myapp
@jkpl
jkpl / article.org
Last active November 9, 2022 18:46
Enforcing invariants in Scala datatypes

Enforcing invariants in Scala datatypes

Scala provides many tools to help us build programs with less runtime errors. Instead of relying on nulls, the recommended practice is to use the Option type. Instead of throwing exceptions, Try and Either types are used for representing potential error scenarios. What’s common with these features is that they’re used for capturing runtime features in the type system, thus lifting the runtime scenario handling to the compilation phase: your program doesn’t compile until you’ve explicitly handled nulls, exceptions, and other runtime features in your code.

In his “Strategic Scala Style” blog post series,