Skip to content

Instantly share code, notes, and snippets.

View nitschmann's full-sized avatar

Florian Nitschmann nitschmann

  • solarisBank AG
  • Germany
View GitHub Profile
@nitschmann
nitschmann / ssl_key_pairs.rb
Created August 17, 2017 13:25
Ruby script to generate OpenSSL Key-Pairs
require "openssl"
# could also be different
key_length = 4096
new_key = OpenSSL::PKey::RSA.generate(key_length)
public_key = new_key.public_key
public_key_string = public_key.to_s
@nitschmann
nitschmann / uuid_as_primary_key.rb
Created August 13, 2017 12:34
uuid as primary key
module UuidAsPrimaryKey
extend ActiveSupport::Concern
included do
before_create :assign_uuid
end
protected
def assign_uuid

Keybase proof

I hereby claim:

  • I am fnitschmann on github.
  • I am fnitschmann (https://keybase.io/fnitschmann) on keybase.
  • I have a public key whose fingerprint is F6F8 4EB1 FD20 30EA EF23 EF93 FC33 7F44 5276 D063

To claim this, I am signing this object:

@nitschmann
nitschmann / easter_day.rb
Last active March 15, 2016 13:45
Ruby implementation to find out the easter day date for a specific year (based on Anonymous Gregorian algorithm)
require "date"
# anonymous gregorian algorithm (http://en.wikipedia.org/wiki/Computus#Anonymous_Gregorian_algorithm)
def easter_day(year)
if year.is_a?(Integer)
y = year
# calculation
a = y % 19
b = y / 100
c = y % 100
@nitschmann
nitschmann / uninstall_homebrew.sh
Created December 10, 2013 09:17
Uninstaller for HomeBrew
#!/bin/sh
# This script uninstalls HomeBrew from your Mac completly
# Just copy and paste the lines below (all at once, it won't work line by line!)
function abort {
echo "$1"
exit 1
}
set -e
@nitschmann
nitschmann / green_console_matrix.rb
Created October 17, 2013 09:19
This is a sample for an endless matrix output in green for your console in Ruby
class String
# Print a String in a specfic color
def colorize(text, color_code)
"#{color_code}#{text}\e[0m"
end
# Green String
def green
colorize(self, "\e[1m\e[32m")
end
end
@nitschmann
nitschmann / spec_helper_gemified_rails_plugins.rb
Last active December 25, 2015 07:48
This is a sample config for a rspec spec_helper.rb file with the Spork Gem inside gemified Ruby on Rails plugins
ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require "rubygems"
require "spork"
require "rspec/rails"
require "rspec/autorun"
Spork.prefork do
@nitschmann
nitschmann / sublime_text_commandline.sh
Last active December 22, 2015 15:29
Script to install Sublime Text 2 'subl' command for your terminal on Mac OS X
# !/bin/sh
user="$(whoami)"
bin_dir="/Users/$user/bin"
if [ ! -d "$bin_dir" ]
then
echo "Create directory $bin_dir\n"
mkdir "$bin_dir"
fi
command_line="/Applications/Sublime Text 2.app/Contents/SharedSupport/bin"
@nitschmann
nitschmann / potenz.java
Last active December 17, 2015 19:49
Simple recursive function for potency in Java
int potency(int basis, int exponent) {
if(exponent == 1) return basis;
else return this.potenz(basis, exponent-1)*basis;
}
@nitschmann
nitschmann / ArrayMultiUnique.php
Created October 23, 2012 09:54
PHP function to clean double entries multidimensional arrays
public function array_multi_unique($multiArray){
$uniqueArray = array();
foreach($multiArray as $subArray) {
if(!in_array($subArray, $uniqueArray)) {
$uniqueArray[] = $subArray;
}
}
return $uniqueArray;
}