Skip to content

Instantly share code, notes, and snippets.

View straight-shoota's full-sized avatar

Johannes Müller straight-shoota

View GitHub Profile
@straight-shoota
straight-shoota / export.coffee
Created November 3, 2014 17:11
Export Parish data from Bistum Fulda Pfarreie (bistum-fulda.de)
# exports data from http://bistum-fulda.de/bistum_fulda/bistum/pfarreien/pfarreiliste/pfarreienbistumfulda.php?navid=708113708113
(String.prototype.strip = -> @replace(/^\s+|\s+$/g, "")) unless typeof "".strip == "function"
data = (for row in $('.pfarreilistdata tr[class]')
continue if Number.isNaN(i)
try
url = row.children[2].querySelector('a.pfarreiurl')
mail = row.children[2].querySelector('a[href]:not(.pfarreiurl)')
name: row.children[0].childNodes[0].innerText.strip()
@straight-shoota
straight-shoota / export bistum augsburg.coffee
Created November 3, 2014 18:43
Export Parish data from Bistum Augsburg (bistum-augsburg.de)
(String.prototype.strip = -> @replace(/^\s+|\s+$/g, "")) unless typeof "".strip == "function"
data = []
#document.querySelectorAll('.full_view_standard a.alphabet')
single_urls = ["http://www.bistum-augsburg.de/index.php/bistum/Pfarreien/Maria-Schnee-_Aach"]
for url in single_urls
@straight-shoota
straight-shoota / README.md
Created February 29, 2016 23:53
Unlink unused config files in sites-enabled with Ansible

This task cleans sites-enabled dir from config files that should not be enabled anymore Its quite easy to use a list of enabled sites to link their config files to sites-enabled, as shown in the last entry. There will still be links to the config files of sites that had been enabled in the previous ansible run, they need to be removed explicitly. The simple way would be to remove the sites-enablied directory alltogether. But this would allways require to create new links to the config files for enabled sites. Thus it would force a server restart even if there had really no changes at all. Defining a var disabled_sites is not quite a good idea since you would probably forget to add or remove items from that list at one time. So my solution is to list all config files that do not correspond to enabled sites and in a second step remove those.

I use it with nginx, but it should also work with apache/httpd or other configurations with a similar concept.

It would be easier to use just rm with an extended gl

@straight-shoota
straight-shoota / panzoom.jsx
Last active May 21, 2017 16:48
Create Slideshow with Panzoom Effect in Adobe After Effects
//
// Copyright 2017 Johannes Müller <straightshoota@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@straight-shoota
straight-shoota / memoize.cr
Created June 7, 2017 21:30
Memoize in Crystal
macro memoize(type_decl, &block)
@{{type_decl.var}} : {{ type_decl.type }} | UninitializedMemo = UninitializedMemo::INSTANCE
def {{type_decl.var}}
if (value = @{{type_decl.var}}).is_a?(UninitializedMemo)
@{{type_decl.var}} = begin
{{block.body}}
end
else
value
@straight-shoota
straight-shoota / date.cr
Last active June 20, 2017 23:04
Example Date Class for Crystal
struct Date
include Comparable(self)
getter year : Int32
getter month : Int16
getter day : Int16
def initialize(year, month, day)
Calendar.validate!(year, month, day)
@straight-shoota
straight-shoota / result.txt
Last active June 28, 2017 17:53 — forked from lbguilherme/result.txt
Benchmark large NamedTuple check-every-key-lookup vs. trie lookup vs. hash conversion
check every key 3.0 (333.07ms) (±21.04%) 20.38× slower
trie lookup 33.95 ( 29.46ms) (±11.63%) 1.80× slower
hash 61.19 ( 16.34ms) (±17.27%) fastest
@straight-shoota
straight-shoota / Makefile
Last active July 31, 2017 18:48
Faster Command Line Tools in Crystal
data: ngrams.tsv
ngrams.tsv:
curl https://storage.googleapis.com/books/ngrams/books/googlebooks-eng-all-1gram-20120701-0.gz | gunzip > ngrams.tsv
benchmark: data
crystal cli_bench.cr --release --no-debug -- ngrams.tsv 1 2
build: bin/crystal_nuts bin/crystal_int bin/crystal_array_with_backup bin/crystal_bench
@straight-shoota
straight-shoota / crystal-windows.sh
Last active March 9, 2024 17:57
Crystal compiler wrapper for Windows Subsystem for Linux
#!/usr/bin/env bash
# MSVC 2017
# MSVC_BUILD_TOOLS="C:\\Program^ Files^ ^(x86^)\\Microsoft^ Visual^ Studio\\2017\\BuildTools\\VC\\Auxiliary\\Build\\vcvarsall.bat"
# MSVC 2015
MSVC_BUILD_TOOLS="C:\\Program^ Files^ ^(x86^)\\Microsoft^ Visual^ C++^ Build^ Tools\\vcbuildtools.bat"
set -euo pipefail