Skip to content

Instantly share code, notes, and snippets.

View jirutka's full-sized avatar
🇺🇦
Слава Україні!

Jakub Jirutka jirutka

🇺🇦
Слава Україні!
View GitHub Profile
@jirutka
jirutka / with.rs
Last active January 15, 2023 12:00
Rust with! macro, aka tap, methods cascade, method chaining…
// Sources:
// * https://internals.rust-lang.org/t/method-chaining-special-form/342
// * https://github.com/rust-lang/rust/issues/6679
// * https://gist.github.com/huonw/2812cd9433dc5f0cf7f2
// * https://www.reddit.com/r/rust/comments/2wssch/function_chaining/
//
// TODO:
// * How to correctly process generic methods (e.g. collect::<Vec<_>>() ?)
macro_rules! with {
@jirutka
jirutka / sentry-add-user.py
Last active February 15, 2018 17:40
Simple script for creating users in Sentry 8 from LDAP and/or adding them to organizations. It requires plugin https://github.com/Banno/getsentry-ldap-auth.
#!/usr/bin/env python
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
from __future__ import print_function
@jirutka
jirutka / README.adoc
Created March 9, 2016 14:30
Twitter statistics and archive for #InstallFest 2016

Twitter statistics for #InstallFest 2016

Tweets between 2016-03-04 and 2016-03-07

  • Number of tweets (excluding RTs): 143

  • Number of favourites: 440

  • Number of retweets: 153

  • Number of tweeting users: 53

@jirutka
jirutka / check_openrc
Last active March 2, 2016 18:20
Very simple NRPE (nagios) module to check crashed services via OpenRC.
#!/bin/sh
# vim: set ts=4:
crashed=$(sudo rc-status --crashed)
if [ -n "$crashed" ]; then
echo "CRITICAL - crashed services: ${crashed//$'\n'/, }"
exit 2
else
echo 'OK'
@jirutka
jirutka / ldap.conf
Last active July 17, 2024 10:40
Simple script for OpenSSH server to load authorization keys from LDAP. It requires just POSIX shell and ldapsearch utility. To manage keys in LDAP, use https://github.com/jirutka/ssh-ldap-pubkey.
# /etc/ssh/ldap.conf
# See ldap.conf(5) for details
# This file should be world readable but not world writable.
BASE ou=People,dc=example,dc=org
URI ldap://localhost
@jirutka
jirutka / -README.adoc
Last active January 13, 2016 22:36
Benchmark various JavaScript libs for recursive conversion of object keys from underscore_case to camelCase.

Benchmark

Results

humps x 3,050 ops/sec ±2.32% (76 runs sampled)
camelcase-keys-recursive x 2,194 ops/sec ±3.16% (65 runs sampled)
camelify-recursive x 1,491 ops/sec ±2.64% (74 runs sampled)
camelize x 3,481 ops/sec ±2.27% (75 runs sampled)
camelscore x 3,280 ops/sec ±2.66% (68 runs sampled)
@jirutka
jirutka / format-toggle-csv.rb
Last active December 1, 2015 17:36
Quick & dirty script for conversion of CSV export from Toggle to a readable textual table. It also deduplicates entries and groups entries without a description or duration less than 0.5 hours under one entry “Others”.
#!/usr/bin/env ruby
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
require 'csv'
@jirutka
jirutka / apairs.lua
Created November 24, 2015 00:33
Implementation of Lua iterator “apairs”, a function that behaves opposite to “ipairs.”
--- Returns an iterator that behaves opposite to @{ipairs}, i.e. it iterates
-- over all key-value pairs that @{ipairs} does not. In other words, it skips
-- integer keys from 1 up to the first integer key absent from the table. The
-- order in which the keys are enumerated is not specified!
--
-- @tparam table tab The table to iterate.
-- @treturn function func An iterator.
-- @treturn table The given table.
local function apairs (tab)
-- #tab lies, so we must count it ourself...
@jirutka
jirutka / fix-rjava.sh
Last active November 15, 2015 17:40
Hack to force rJava to use specific Java VM, i.e. get rid of “Unsupported major.minor version 52.0!”
#!/bin/bash
# vim: set ts=4:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
@jirutka
jirutka / tydenvedy-2015-praha.csv
Last active November 5, 2015 14:04
Týden vědy 2015 Praha v CSV
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 4.
"title","date","location","types","topics","booking","location_url","info_url"
"Knihovna snů aneb Oheň pekelný v Knihovně AV ČR","31. 10., 9:00–00:00","KNIHOVNA AV ČR, v. v. i., Národní 3, Praha 1","výstava","svět vědy","false","http://mapy.cz/zakladni?x=14.4145231&y=50.0813565&z=17&source=addr&id=8940048","http://www.tydenvedy.cz/sd/udalosti/kalendar/vystavy/1031-KAV-knihovna-snu-aneb-ohen-pekelny-v-knihovne-av-cr.html"
"Nepál 2015 – co především škody způsobilo a co zabránilo škodám ještě větším","31. 10., 15:00","Knihovna AV ČR, v. v. i., Národní 3, Praha 1","přednáška","svět vědy","false","http://mapy.cz/zakladni?x=14.4145231&y=50.0813565&z=17&source=addr&id=8940048&q=N%C3%A1rodn%C3%AD%203%2C%20Praha%201","http://www.tydenvedy.cz/sd/udalosti/kalendar/prednasky__PRAHA/1031-KNAV-nepal-2015-co-predevsim-skody-zpusobilo-a-co-zabranilo-skodam-jeste-vetsim.html"
"Oheň – dobrý sluha, ale zlý pán aneb Popáleniny očima fyzioterapeuta","31. 10., 17:30","Knihovna AV ČR, v. v. i., Národní 3, Praha 1","přednáška","med