Skip to content

Instantly share code, notes, and snippets.

View 2called-chaos's full-sized avatar
😐
perpetually bored

Sven Pachnit 2called-chaos

😐
perpetually bored
View GitHub Profile
in your ~/.profile
alias restartmc='ssh geekyamc@hugo.breitzeit.de "cd _terra && chruby-exec 1.9 -- mcir restart"'
@2called-chaos
2called-chaos / faith.sh
Created October 4, 2014 23:09
Bash function if you trust your skills
function with_faith { $@ &> /dev/null; }
@2called-chaos
2called-chaos / irc.md
Last active August 29, 2015 14:06
Essential IRC rules (to be continued)

IRC – that's how it works!

These "rules" are especially true for big channels with dozens and hundreds of users.

1. Don't ask to ask

Most channels insist on this rule. Don't ask if someone may help or is "there". Just ask your question (a greeting isn't wrong though) and be patient.

2. Highlighting

A very important one! If you ask a question you might get responses which are prefixed with your name:

@2called-chaos
2called-chaos / string_expand_ranges.rb
Last active August 29, 2015 14:05
Expand range like strings into lists/arrays with ruby, example at the bottom
#---
# Copyright (c) 2013, Sven Pachnit
# Published under the MIT license
#
# I wrote this in 15 minutes, I have no idea about performance.
# CPAN's String::Range::Expand is the only thing I was able to
# find and Perl is not good for my Ruby eyes ;)
#---
# result of me being lazy :)
@2called-chaos
2called-chaos / gist:4eacb303b9491d1e374c
Last active April 6, 2024 23:58
My nginx config for dynmap (on port 8123, that's the dynmap bound to localhost so no direct call possible)
server {
listen 80;
server_name map.geekya.com;
# I normally wouldn't disable the access log but here I see no problem with it
access_log off;
error_log /var/log/nginx/com.geekya.map.error.log;
# custom error page when map isn't available
error_page 502 503 504 =503 /503_map.html;
@2called-chaos
2called-chaos / punch_list.pain
Created July 3, 2014 09:29
Punch in the face list
This is a list of people (or - in most cases - companies as I don't have an individual to blame) whom I would like to make a fist gift.
###############################################################################################################
Skype - for having the shittiest chat application ever and refuse to open the chat API so that I don't have to install this shit (I don't want to use it but a lot of people use Skype exclusively for whatever reason)
Apple - for having the shittiest app store I can imagine (it was okay for iOS but the OS X implementation is just a piece of crap). It's not that you can break it really easily (so that you can't download/update anymore) but there is no archive for older versions (how often did I update to get a broken application (good to have TimeMachine) and how often did I bought an application which was broken (bad luck, an update is usually not far away but why can't I just USE THE PREVIOUS VERSION?!?!?!?!?) and how often did I pray for a download function (like
@2called-chaos
2called-chaos / nginx_htpasswd
Last active August 29, 2015 14:01
nginx htpasswd add user (perl script)
#!/usr/bin/perl
# Script origin: http://wiki.nginx.org/Faq#How_do_I_generate_an_.htpasswd_file_without_having_Apache_tools_installed.3F
# Install:
# aptitude install -y curl \
# && curl -o /usr/local/bin/nginx_htpasswd \
# https://gist.githubusercontent.com/2called-chaos/286965e2a4b5c1aaf056/raw/nginx_htpasswd \
# && chmod +x /usr/local/bin/nginx_htpasswd
use strict;
chomp(my $filename=$ARGV[0]);
@2called-chaos
2called-chaos / kernel.rb
Created March 10, 2014 14:58
Call ruby method or lambda like a proc. Calls a method with the maximum possible amount of arguments. Ruby's arity telling is too inaccurate so we just try to call the method with everything we have and if this raises an ArgumentError we examine the maximum allowed amount of arguments and pass those.
module Banana
# Provides low level support functionalities.
module Kernel
# Calls a method with the maximum possible amount of arguments.
#
# Ruby's arity telling is too inaccurate so we just try to call the method
# with everything we have and if this raises an ArgumentError we examine the
# maximum allowed amount of arguments and pass those.
#
# Dont believe me?
module Banana
# Provides low level support functionalities.
module Kernel
# Calls a method with the maximum possible amount of arguments.
#
# Ruby's arity telling is too inaccurate so we just try to call the method
# with everything we have and if this raises an ArgumentError we examine the
# maximum allowed amount of arguments and pass those.
#
# Dont believe me?
# create a custom renderer that allows highlighting of code blocks
class HTMLwithPygments < Redcarpet::Render::HTML
def block_code(code, language)
if language.to_s.end_with?("CHL")
language = language[0...-3]
code = Pygments.highlight(code, lexer: language, options: { linespans: Digest::SHA1.base64digest(code) })
code = code.gsub(/<span class="(?:[a-z]+)">==<\/span>(.*?)<span class="(?:[a-z]+)">==<\/span>/, %{<span class="highlight">\\1</span>}.html_safe)
else
Pygments.highlight(code, lexer: language, options: { linespans: Digest::SHA1.base64digest(code) })
end