Skip to content

Instantly share code, notes, and snippets.

View Fohlen's full-sized avatar

Lennard Berger Fohlen

View GitHub Profile
@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 / 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 / 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 / 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 / Modal.vue
Created September 27, 2017 09:47
A bootstrap modal component via Vue.js
<template>
<div class="modal fade" v-bind:id="id" tabindex="-1" role="dialog" aria-labelledby="Vorschau">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Schließen"><span aria-hidden="true">&times;</span></button>
<slot name="subject"><h4 class="modal-title" id="Vorschau">Titel</h4></slot>
</div>
<div class="modal-body content">
<slot name="body">Inhalt der Nachricht</slot>
@Fohlen
Fohlen / factorial.py
Last active August 1, 2017 21:05
Some recursive algorithms in python
def factorial(n):
if n == 1:
return 1
elif n > 1:
return n * factorial(n - 1)
@Fohlen
Fohlen / dropzone-german-dict.js
Created July 7, 2017 10:59
Dropzone.js german localization
export default {
'dictDefaultMessage': 'Legen Sie Dateien hier ab um Sie hochzuladen',
'dictFallbackMessage': 'Ihr Browser unterstützt Drag&Drop Dateiuploads nicht',
'dictFallbackText': 'Benutzen Sie das Formular um Ihre Dateien hochzuladen',
'dictFileTooBig': 'Die Datei ist zu groß. Die maximale Dateigröße beträgt {{maxFileSize}}MB',
'dictInvalidFileType': 'Eine Datei dieses Typs kann nicht hochgeladen werden',
'dictResponseError': 'Der Server hat ihre Anfrage mit Status {{statusCode}} abgelehnt',
'dictCancelUpload': 'Hochladen abbrechen',
'dictCancelUploadConfirmation': null,
'dictRemoveFile': 'Datei entfernen',
@Fohlen
Fohlen / gcd.js
Created December 5, 2016 20:48
Greatest common divisor
/**
* Returns the greatest common divisor of a and b
* @param {number} a
* @param {number} b
* @returns {number}
*/
function gcd(a, b) {
if (b == 0) {
return a;
} else {
@Fohlen
Fohlen / sequence2D.js
Created May 19, 2016 12:07
Calculate the amount of rows in a borderless square (x/y angles) to draw a triangle
function sequence2D(n) {
if (n > 1) {
return this.sequence2D(n - 1) + (n + 1);
} else if (n == 1) {
return 3;
} else {
throw new RangeError("A sequence operates on real numbers.");
}
}
@Fohlen
Fohlen / httpd.conf
Created December 9, 2015 16:01
Inexor's Lets Encrypt SSL configuration for nginx
# A server block that will by default redirect all traffic HTTPS
server {
listen 80 default_server;
return 301 https://$host$request_uri;
}
##
# Global SSL configuration