Skip to content

Instantly share code, notes, and snippets.

View nerdinand's full-sized avatar
💭
wat

Ferdinand Niedermann nerdinand

💭
wat
View GitHub Profile
@nerdinand
nerdinand / read-env.py
Created March 16, 2023 14:19
Quick and dirty env.sh file reading and applying in Python (useful for example in a Jupyter Notebook)
import re
import os
for m in re.finditer(r'export (.*)=([^ \n]+)', open('../env.sh').read()):
os.environ[m[1]] = m[2]
@nerdinand
nerdinand / Dockerfile
Created January 29, 2022 22:32
Podman setup for Rails 7 (without compose or database)
FROM ruby:3.1
# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
WORKDIR /usr/src/app
COPY Gemfile Gemfile.lock ./
RUN bundle install
import turicreate as tc
import pandas as pd
def print_human_confusion_matrix(actual, predicted):
cf_matrix = tc.evaluation.confusion_matrix(actual, predicted)
labels = list(set(cf_matrix['predicted_label'].append(cf_matrix['target_label'])))
matrix = []
@nerdinand
nerdinand / caesar.rb
Created June 11, 2018 06:34
Caesar encryption in Ruby
ALPHABET = /^[A-Z]+$/
COMMANDS = ['encrypt', 'decrypt']
command = ARGV[0]
key = ARGV[1].to_i
text = ARGV[2]
if COMMANDS.include? command
if ALPHABET =~ text
encrypted = text.chars.map do |character|
@nerdinand
nerdinand / aes_decrypt.rb
Created June 9, 2018 14:04
AES encryption showcase using OpenSSL in Ruby
require 'openssl'
ALGORITHM = 'AES-256-CBC'
puts 'Enter key to decrypt with (in hexadecimal):'
hex_key = gets.chomp
puts 'Enter message to decrypt (in hexadecimal):'
hex_message = gets.chomp
@nerdinand
nerdinand / fixtures.rb
Last active April 18, 2019 06:10
Poor man's fixtures for hanami
#
# A quick and dirty fixture implementation for use with Hanami, RSpec and PostgreSQL.
# Fixtures will be loaded when the suite starts and will be reset using transactions
# to the same state after each test case.
#
# Supports associations like so (author has many books):
#
# # authors.yml
# rowling:
# name: J.K. Rowling
@nerdinand
nerdinand / Gemfile.lock
Created August 3, 2017 13:21
undefined local variable or method `haml_buffer' when using haml templates (the second)
GIT
remote: git://github.com/hanami/view.git
revision: 1d2cc445ef96b5a58c61d8f7e6d5dfa44c917b5a
branch: 1d2cc445ef96b5a58c61d8f7e6d5dfa44c917b5a
specs:
hanami-view (1.0.0)
hanami-utils (~> 1.0)
tilt (~> 2.0, >= 2.0.1)
GEM
@nerdinand
nerdinand / Gemfile.lock
Last active July 31, 2017 11:59
undefined local variable or method `haml_buffer' when using haml templates
GEM
remote: https://rubygems.org/
specs:
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
capybara (2.14.4)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
@nerdinand
nerdinand / spinner.rb
Created February 21, 2017 12:25
ASCII art indeterminate loading spinner
a = ['-', '/', '|', '\\']
loop do
print "\r#{a.rotate!.first}"
sleep 0.1
end
javascript:
function isJiraPage() {
return window.location.href.indexOf("jira") > -1;
};
function isJiraSprintPage() {
return window.location.href.indexOf("selectedIssue") > -1;
};
function isBasecampPage() {