Skip to content

Instantly share code, notes, and snippets.

View igneus's full-sized avatar

Jakub Pavlík igneus

View GitHub Profile
@igneus
igneus / Gemfile
Created July 19, 2016 20:17
rest-client 1.6 isn't compatible with mime-types 3
source 'https://rubygems.org'
gem 'rest-client', '1.6.7'
gem 'mime-types', '3.1'
@igneus
igneus / webconsole_exploit_honeypot.rb
Created July 22, 2016 16:38
Safely watch an example exploit of a known Rails webconsole vulnerability
# having read
# https://benmmurphy.github.io/blog/2016/07/11/rails-webconsole-dns-rebinding/
# I wanted to see what http://www.dnsrebinder.net/ would execute
# if I had an app with Rails webconsole running on localhost:3000
# Usage:
# * run this application
# * visit http://www.dnsrebinder.net/
# * watch console
@igneus
igneus / threefold_piano.py
Last active July 30, 2016 13:23
mididings patch transforming a single-manual MIDI piano with standard three piano pedals to a two-manual organ with pedal (sort of)
# mididings patch making a single-manual MIDI piano with standard
# three piano pedals capable of simple organ music:
# * splits keyboard in two manuals (MIDI channels 1, 2)
# * transforms the piano pedals in a diatonic
# single-octave organ pedal playing on MIDI channel 4
# (it isn't possible to play more simultaneous pedal notes -
# combinations are instead used to expand the pedal's range)
from mididings import *
from mididings.event import CtrlEvent
\header
title: Antiphons for the Consecration of Virgins
\score
annotation: I D
c4
d f ef g ,
g ixhih g h ;
h g f ef d ,
d e d d f e c d ::
@igneus
igneus / Rakefile
Last active August 24, 2016 16:21
my seminar paper template (studying Theology at http://www.tf.jcu.cz/)
deps = Dir["*.tex"] + Dir["*.*bx"] + Dir['*.bib']
main = Dir['*.tex'].first # only one expected
main_noext = main.sub '.tex', ''
main_pdf = main.sub '.tex', '.pdf'
file main_pdf => deps do |t|
sh "xelatex #{main_noext}"
sh "biber #{main_noext}"
sh "xelatex #{main_noext}"
@igneus
igneus / http_error_raiser.rb
Last active September 18, 2016 09:15
returns unhappy HTTP status codes you ask for.
# Application returning unhappy HTTP status codes you ask for, e.g.
# GET /404
# returns 404 Not Found etc.
# Created for manual testing of HTTP clients.
require 'sinatra'
require 'json'
KNOWN_ERRORS = {
400 => 'Bad Request',
@igneus
igneus / feast.cr
Last active November 23, 2016 21:05
On feast days display feast title
# 2016-11-18
# connects to the Church Calendar API
# If there is a celebration of rank feast or higher, prints it's title
# For me to fill a textbox widget in awesome:
# In rc.lua:
#
# calendarbox = widget({ type = "textbox" })
# calendarbox.text = awful.util.pread("/path/to/feast --calendar=czech-pha")
@igneus
igneus / gabc_quanta.rb
Created December 12, 2016 20:46
"How melismatic chants do my gabc files contain?"
# takes a list of gabc file paths as commandline arguments,
# for each of them prints syllable count, note count and notes per syllable
require 'grely'
class GabcScore
def syllables_count
i = 0
each_syllable {|s| i += 1 }
i
@igneus
igneus / pedal_channel_switch.py
Created December 26, 2016 18:48
Switch MIDI presets by piano pedals
# mididings patch translating piano pedals to Program switch messages
#
# I use it to switch presets in aeolus
from mididings import *
config(
client_name='pedal_channel_switch'
)
@igneus
igneus / normostrany.sh
Last active January 6, 2019 18:25
Kolik normostran textu obsahuje daný pdf dokument?
#!/bin/bash
# Klasicka otazka studentova: Kolik normostran ma me pdf?
if [ $# -lt 1 ]
then
echo "pdf file expected as command line argument."
exit 1
fi