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 / 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 / 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 / empty.ll
Created April 22, 2018 13:10
[Crystal] LLVM module validation failed: Both operands to a binary operator are not of the same type!
This file has been truncated, but you can view the full file.
; ModuleID = 'main_module'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%String = type { i32, i32, i32, i8 }
%"Slice(UInt8)" = type { i32, i1, i8* }
%"Array(String)" = type { i32, i32, i32, %String** }
%"->" = type { i8*, i8* }
%"Array(Pointer(Void))" = type { i32, i32, i32, i8** }
%Fiber = type { i32, i8*, %"(Event::Event | Nil)", i8*, i8*, %Fiber*, %Fiber*, %String*, %"(Proc(Nil) | Proc(Void))" }
@straight-shoota
straight-shoota / Vagrantfile
Created November 13, 2018 15:40
Crystal Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
clone_crystal_from_vagrant = lambda do |config|
config.vm.provision :shell, privileged: false, inline: %(
# Checkout crystal repository
git clone /vagrant crystal
)
end
@straight-shoota
straight-shoota / pre-commit
Last active April 4, 2019 10:26
Git pre-commit hook for `crystal tool format`
#!/bin/sh
#
# This script ensures Crystal code is correctly formatted before committing it.
# It won't apply any format changes automatically.
#
# Only staged files (the ones to be committed) are being processed, but each file is checked
# entirely as it is stored on disc, even parts that are not staged.
#
# To use this script, it needs to be installed in the local git repository. For example by running
# curl https://gist.githubusercontent.com/straight-shoota/fdaf4cf1954e084cd5abccf8f77975f6/raw/pre-commit > .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit