Skip to content

Instantly share code, notes, and snippets.

View Fohlen's full-sized avatar

Lennard Berger Fohlen

View GitHub Profile
@Fohlen
Fohlen / fib.js
Created October 28, 2017 13:49
Recursive fibonacci in JS - https://fohlen.lib.id/fib/
const fib = (n) => {
// Returns the n-th element of the fibonacci sequence
if (n == 1) {
return 1;
} else if (n == 2) {
return 1;
} else if (n > 2) {
return (fib(n - 1) + fib(n - 2))
}
}
@Fohlen
Fohlen / vue2-dropzone.min.js
Created November 7, 2017 12:56
A production-ready minified version of dropzone.js to use in fiddle's
webpackJsonp([0],[function(e,t){e.exports=function(e,t,n,r,o){var i,s=e=e||{},a=typeof e.default;"object"!==a&&"function"!==a||(i=e,s=e.default);var l="function"==typeof s?s.options:s;t&&(l.render=t.render,l.staticRenderFns=t.staticRenderFns),r&&(l._scopeId=r);var u;if(o?(u=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),n&&n.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(o)},l._ssrRegister=u):n&&(u=n),u){var d=l.functional,p=d?l.render:l.beforeCreate;d?l.render=function(e,t){return u.call(t),p(e,t)}:l.beforeCreate=p?[].concat(p,u):[u]}return{esModule:i,exports:s,options:l}}},function(e,t){function n(e,t){var n=e[1]||"",o=e[3];if(!o)return n;if(t&&"function"==typeof btoa){var i=r(o);return[n].concat(o.sources.map(function(e){return"/*# sourceURL="+o.sourceRoot+e+" */"})).concat([i]).join("\n")}return[n].join("\n")}function r(e){return"/*# sourceMappingU
@Fohlen
Fohlen / alias-test.json
Last active November 18, 2017 13:54
alias-test
{
"aliases": [{
"alias": "fohlen",
"node": "8af7eff0-cc64-11e7-bb20-85407e92063e.inexortestnetwork.tk."
}]
}
@Fohlen
Fohlen / euclidean.py
Created December 12, 2017 21:16
Euclidean distance in a catchy two liner
def n_dimensional_euclidean_distance(a, b):
"""
Returns the euclidean distance for n>=2 dimensions
:param a: tuple with integers
:param b: tuple with integers
:return: the euclidean distance as an integer
"""
dimension = len(a) # notice, this will definitely throw a IndexError if len(a) != len(b)
return sqrt(reduce(lambda i,j: i + ((a[j] - b[j]) ** 2), range(dimension), 0))
@Fohlen
Fohlen / dns
Created September 25, 2018 15:30
uberspace_inexor
$TTL 86400
@ IN SOA ns1.first-ns.de. postmaster.robot.first-ns.de. (
2018082301 ; serial
14400 ; refresh
1800 ; retry
604800 ; expire
86400 ) ; minimum
@ IN NS ns1.first-ns.de.
@ IN NS robotns2.second-ns.de.
@Fohlen
Fohlen / rules
Created October 13, 2018 09:04
Docker+ufw
# Put in /etc/ufw/after.rules
# Put Docker behind UFW
*filter
:DOCKER-USER - [0:0]
:ufw-user-input - [0:0]
-A DOCKER-USER -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A DOCKER-USER -m conntrack --ctstate INVALID -j DROP
-A DOCKER-USER -i eth0 -j ufw-user-input
@Fohlen
Fohlen / containerfun.cpp
Last active November 22, 2018 16:30
Container fun
#include <algorithm>
#include <list>
#include <string>
#include <iostream>
using namespace std;
template <typename T>
void print_list(list<T> l) {
for (auto e: l)
{
@Fohlen
Fohlen / instructions.sh
Created November 29, 2018 18:09
How to set up matplotlib on OSX with Python2.7
# Setting up Matplotlib with python2.7 can be superb pain to set up but a lot of tutorials still use this especially for scikit
# We assume here that you have installed python2.7 via brew (brew install python2.7)
# This means python2.7 is your brew python while python will be your system python
# Configure backend
echo "backend: WXAgg" >> ~/.matplotlib/matplotlibrc
# Go inside your virtualenv with your project and everything
pip install -U wxPython
# After that you will need to exit your VENV
@Fohlen
Fohlen / server.go
Created December 22, 2018 19:58
Pair with "server"
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"time"
"nanomsg.org/go/mangos/v2"
@Fohlen
Fohlen / logging.fbs
Last active December 25, 2018 21:46
ok?
namespace Inexorgame.Logging;
include "Inexorgame.Plugin"
/// Describes which level of severity you are logging.
enum LogLevel : byte {
/// Disable all logging. You're on your own now.
Off = 127,
/// This is really fine-grained information—finer even than DEBUG.
Trace,