Skip to content

Instantly share code, notes, and snippets.

Avatar
🌜

Jaakko Pallari jkpl

🌜
View GitHub Profile
View toggle_hyperv.ps1
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 / ksql-app.yaml
Created May 7, 2020
Example KSQL app deployment for Kubernetes
View ksql-app.yaml
---
apiVersion: v1
kind: Service
metadata:
name: demo-ksql-server
labels:
app: demo-ksql-server
spec:
ports:
- port: 8088
@jkpl
jkpl / Dockerfile
Last active Dec 15, 2020
saml2aws Docker image
View Dockerfile
FROM debian:stable-slim
RUN apt-get update && \
apt-get install -y ca-certificates curl && \
rm -rf /var/lib/apt/lists/*
ENV SAML2AWS_VERSION=2.16.0
ENV SAML2AWS_DOWNLOAD_URL=https://github.com/Versent/saml2aws/releases/download/v${SAML2AWS_VERSION}/saml2aws_${SAML2AWS_VERSION}_linux_amd64.tar.gz
RUN curl -L "$SAML2AWS_DOWNLOAD_URL" -o saml2aws.tar.gz && \
View deploy.md
#!/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 / Main.scala
Created Jan 8, 2018
Dropwizard Graphite demo for Scala
View Main.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 / article.md
Last active Jul 16, 2020
Error handling pitfalls in Scala
View article.md

Error handling pitfalls in Scala

There are multiple strategies for error handling in Scala.

Errors can be represented as [exceptions][], which is a common way of dealing with errors in languages such as Java. However, exceptions are invisible to the type system, which can make them challenging to deal with. It's easy to leave out the necessary error handling, which can result in unfortunate runtime errors.

@jkpl
jkpl / altfin.keylayout
Created Feb 25, 2017
My old keyboard layout for OS X (Ukelele format)
View altfin.keylayout
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard PUBLIC "" "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<!--Last edited by Ukelele version 2.2.4 on 2013-02-08 at 22:01 (UTC+2.00)-->
<keyboard group="0" id="5591" name="AltFin" maxout="1">
<layouts>
<layout first="0" last="17" modifiers="f4" mapSet="16c"/>
<layout first="18" last="18" modifiers="f4" mapSet="984"/>
<layout first="21" last="23" modifiers="f4" mapSet="984"/>
<layout first="30" last="30" modifiers="f4" mapSet="984"/>
<layout first="194" last="194" modifiers="f4" mapSet="984"/>
@jkpl
jkpl / csv2keepass.py
Created Feb 25, 2017
Convert CSV to KeepassX XML format
View csv2keepass.py
import sys
entry_t = """<entry>
<title>{title}</title>
<username>{username}</username>
<password>{password}</password>
<notes>{info}</notes>
</entry>"""
pwfile_t = """<!DOCTYPE KEEPASSX_DATABASE>
@jkpl
jkpl / check_rules.sh
Created Feb 25, 2017
Check window class and name (rules) in Xorg
View check_rules.sh
#!/bin/sh
xprop |awk '
/^WM_CLASS/{sub(/.* =/, "instance:"); sub(/,/, "\nclass:"); print}
/^WM_NAME/{sub(/.* =/, "title:"); print}'
@jkpl
jkpl / article.md
Last active Mar 18, 2021
HTML search and replace in Clojure
View article.md

HTML search and replace in Clojure

In Clojure, data structures are mostly built from a handful of core data structures such as lists, vectors, maps, and sets. This means that most data structures can leverage all of the generic data transformation and querying functions built for the core data structures instead of having to rebuild the same functionality for each data structure. This feature in combination with Clojure's rich standard library makes Clojure very attractive for solving data munching problems from other domains.

In this article, I'm going to demonstrate these capabilities for solving HTML transformations using Clojure. First, I'm going to describe how HTML can be represented in Clojure. With this representation in mind, I'll demonstrate how we can transform HTML documents in Clojure. Finally, I'll tie the transformations together with the HTML parsing and formatting to produce a complete solution.