Skip to content

Instantly share code, notes, and snippets.

View korny's full-sized avatar

Kornelius Kalnbach korny

View GitHub Profile
@korny
korny / git-restore
Created January 8, 2015 10:03
Copy a file's master version to your working directory (prefixed with old_)
#!/usr/bin/env ruby
source = ARGV.first or raise 'need a file name'
basename = File.basename(source)
target = File.join File.dirname(source), (basename[/^_/] ? '_old' : 'old_') + basename
exec "git show master:#{source} > #{target}"
@korny
korny / markdown-parser.rb
Last active August 29, 2015 14:26
Super Markdown Parser (Ruby flavored)
def markdown_h(input)
input.gsub(/^(?'hashtag'#+) (?'title'.*)/) do
level = [$~[:hashtag].size, 6].min
"<h#{level}>#{$~[:title]}</h#{level}>"
end
end
def markdown_em(input)
input.gsub(/\*(?'text'\S+)\*/) do
"<em>#{$~[:text]}</em>"
@korny
korny / overviewer_config.py
Last active September 26, 2015 17:14
Minecraft Overviewer config file (N/W/S/E+Nether, Markers for Signs, Players, and Chests with Iron or Diamonds)
# coding=utf-8
worlds['Beteigeuze'] = "~/minecraft-saves/Beteigeuze"
outputdir = "/var/www/Kornelius-Kalnbach/minecraft.murfy.de/Beteigeuze"
rendermode = "smooth_lighting"
def signFilter(poi):
if poi['id'] == 'Sign':
return "\n".join([poi['Text1'], poi['Text2'], poi['Text3'], poi['Text4']])
@korny
korny / sphinx.rb
Created June 13, 2018 23:21
Sphinx Homebrew formula for MySQL 5.7
class Sphinx < Formula
desc "Full-text search engine"
homepage "http://www.sphinxsearch.com"
url "http://sphinxsearch.com/files/sphinx-2.2.11-release.tar.gz"
sha256 "6662039f093314f896950519fa781bc87610f926f64b3d349229002f06ac41a9"
head "https://github.com/sphinxsearch/sphinx.git"
bottle do
sha256 "b890cf523db9777c7d125842fd6b0a53fe9a7a5a4cb816389ba6f5ee6483c78d" => :high_sierra
sha256 "55ce34bdedf13946fa614bde50839d93135eae720f1021e2c87807d04515ab18" => :sierra
@korny
korny / git-publish-branch
Created January 21, 2019 13:33
git-publish-branch
#!/usr/bin/env ruby
## git-publish-branch: a simple script to ease the unnecessarily complex
## task of "publishing" a branch, i.e., taking a local branch, creating a
## reference to it on a remote repo, and setting up the local branch to
## track the remote one, all in one go. you can even delete that remote
## reference.
##
## Usage: git publish-branch [-d] <branch> [repository]
##