Skip to content

Instantly share code, notes, and snippets.

@kubek2k
kubek2k / stupid-payment-system.hs
Created July 8, 2018 21:16
Some XML parsing exercise for my dad
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Prelude hiding (readFile)
import Text.XML
import Text.XML.Cursor
import Text.XML.Cursor (node)
import qualified Data.Text as T
import qualified Data.Text.IO as TIO
import Data.Map ((!))
@kubek2k
kubek2k / process.xslt
Last active July 23, 2018 19:43
The XSLT template to deal with some weird data output from some accountants program.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:x="http://www.insert.com.pl/GTSchemas/ListaPlac.xsd"
xmlns:gttns="http://www.insert.com.pl/GTSchemas/Typy.xsd">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<ListyPlac>
<xsl:apply-templates select="x:ListyPlac/x:ListaPlac" />
aws rds describe-db-instances | jq '.DBInstances[] | "" + .DBInstanceIdentifier + " " + .MasterUsername + " " + .Endpoint.Address' -r | grep pro > hosts
@kubek2k
kubek2k / upload-custom-vcl-and-activate.sh
Last active August 30, 2018 12:46
Upload custom vcl to fastly and activate it after successful validation
set -e
function callFastly() {
endpoint="$1"
shift
curl -f -s -H "Fastly-Key: ${FASTLY_TOKEN}" -H "Accept: application/json" "https://api.fastly.com$endpoint" $*
}
function getCurrentVersion() {
callFastly "/service/$SERVICE_ID/version" | jq '.[0].number'
@kubek2k
kubek2k / simple-binary-lambda-tutorial.md
Created December 1, 2018 22:50
Short tutorial on how to run any statically linked binary on lambda

Preamble

The introduction of Custom Runtimes has opened up new possibilities when it comes to the spectrum of languages that can be used in Amazon Lambda. This short document will show how to run virtually any statically linked binary on it. The example will cover a stack built Haskell project.

Preparations

for a in `heroku list -t omni | tail -n +2 | awk '{ print $1 }'`; do
count=`heroku ps -a $a --json | jq '[.[] | select(.type == "web")] | length' | tr -d '\n'`
if [ "$count" == "1" ]; then
heroku features:enable preboot -a $a
fi
done
#!/usr/bin/env bash
"exec" "clojure" "-Sdeps" "{:deps
{clj-http {:mvn/version \"3.9.1\"}
org.seleniumhq.selenium/htmlunit-driver {:mvn/version \"2.34.0\"}}}" "$0" "$@"
;; usage
;; update/install clojure: brew install clojure
;; make the file executable: chmod +x
;; fill in below config values
;; run the file whenever you want
2 2016-11-08
12 2016-11-10
2 2016-11-21
2 2016-11-23
20 2016-11-24
10 2016-11-28
7 2016-11-29
1 2017-01-03
20 2017-01-23
8 2017-02-07