Skip to content

Instantly share code, notes, and snippets.

View alexkli's full-sized avatar

Alexander Klimetschek alexkli

View GitHub Profile
@alexkli
alexkli / README.md
Last active December 15, 2015 17:29
Line number support for REXML documents parsed from files

Line number support for REXML documents

The Ruby REXML library unfortunately has no built-in support to retrieve line numbers of elements when using Documents (DOM).

This little extension fixes this and gives you Element.start_line ("<" location) and Element.end_line ("/>" location), also for other XML items such as Entities, Decl, etc., just not individual attributes.

Use with doc = XML::parse_xml(file) as replacement for the usual doc = REXML::Document.new(file).

Update: this change makes parsing of certain xml files fail, due to a broken REXML::IOSource#current_line implementation that resets the stream to the wrong location.

#!/usr/bin/python
# CLI program to control the mediakeys on OS X. Used to emulate the mediakey on a keyboard with no such keys.
# Easiest used in combination with a launcher/trigger software such as Quicksilver.
# Main part taken from http://stackoverflow.com/questions/11045814/emulate-media-key-press-on-mac
# Glue to make it into cli program by Fredrik Wallner http://www.wallner.nu/fredrik/
import Quartz
import sys
@alexkli
alexkli / keybase.md
Created February 13, 2016 02:28
keybase.md

Keybase proof

I hereby claim:

  • I am alexkli on github.
  • I am alexkli (https://keybase.io/alexkli) on keybase.
  • I have a public key whose fingerprint is 9513 7F5C 6E62 56D8 9FE9 E2F1 804F 627B 2D1B D1A0

To claim this, I am signing this object:

import org.apache.jackrabbit.oak.spi.commit.CommitInfo
import org.apache.jackrabbit.oak.spi.commit.EmptyHook
import org.apache.jackrabbit.oak.spi.state.NodeStore
import org.apache.jackrabbit.oak.commons.PathUtils
def removeNodes(def session, String fileWithPaths) {
println "Reading paths from ${fileWithPaths}..."
new File(fileWithPaths).eachLine { path ->
println "Removing node ${path}"
@alexkli
alexkli / serverless-webpack-auto.js
Last active May 23, 2018 18:25
serverless-webpack automatic config and externals prototype https://github.com/serverless-heaven/serverless-webpack/issues/399
// prototype for https://github.com/serverless-heaven/serverless-webpack/issues/399
'use strict';
const fs = require('fs');
const webpackConfigFile = "webpack.config.js";
class OpenWhiskExtServerlessPlugin {
@alexkli
alexkli / invokelocal.js
Last active August 11, 2018 01:04
serverless-openwhisk invoke local using docker for https://github.com/serverless/serverless-openwhisk/issues/119
'use strict';
const fs = require('fs');
const rw = require('rw');
const { spawn, execSync } = require('child_process');
const request = require('requestretry');
const OPENWHISK_DEFAULTS = {
// https://github.com/apache/incubator-openwhisk/blob/master/docs/reference.md#system-limits
@alexkli
alexkli / parse-replication-publish.sh
Last active July 29, 2021 09:16
Retrieving replication actions from AEM error.log
#!/bin/sh
# parses replication receive events from an AEM publish error.log or
# replication.log and outputs them in the format <action>,<path>
#
# example output:
# ACTIVATE,/content/dam/assets/foo
# DEACTIVATE,/content/some/page
grep -oh "/bin/receive.*Processed replication action.*" "$1" \
@alexkli
alexkli / oak-browse-tree.groovy
Last active March 12, 2022 15:42
Groovy script for displaying hidden Oak content structures
// --------------------------------------------------------------
// change these input values
// path: what oak path to show
def path = "/oak:index/nodetype/:index";
// depth: how deep the tree structure should be rendered
def depth = 2;
// --------------------------------------------------------------
@alexkli
alexkli / circleci-vars.md
Last active September 10, 2022 00:29
How to safely export CircleCI environment variables

How to safely export CircleCI environment variables

Steps with SSH

Connect to the job with ssh (use Rerun job with SSH) and then simply run env and copy&paste the vars.

Note: make sure you have a ssh key in your Github settings. If it's missing, CircleCI will silently fail to show the "Enable SSH" setting in the re-run.


@alexkli
alexkli / trello-collapsible-list.md
Last active March 24, 2023 19:16
Trello collapsible list userscript (tested with Safari)

Trello does not support collapsing lists out of the box. There are different solutions such as an extension for Chrome. But nothing that works in Safari any more, as of March 2023, so I wrote my own user script.

Use this with the Userscripts extension for Safari.

It looks like this:

trello-collapsible-list-screenshot

Click on the ▼ icon to toggle the list.