Skip to content

Instantly share code, notes, and snippets.

View Fohlen's full-sized avatar

Lennard Berger Fohlen

View GitHub Profile
@Fohlen
Fohlen / proxy
Last active August 29, 2015 14:12
How to mirror proxy requests with nginx
server {
listen ip;
server_name proxyhost;
location / {
proxy_pass http://some.source/folder/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@Fohlen
Fohlen / bugsubmit.php
Created March 31, 2015 12:44
Spacious Page Template to submit bugs via https://wordpress.org/plugins/bug-library/
<?php
/**
* Template Name: Bug Submit Page Template
*
* Displays the Bug Library Bug Submit Template.
*
* @package ThemeGrill
* @subpackage Spacious
* @since Spacious 1.0
*/
@Fohlen
Fohlen / index.php
Created April 2, 2015 10:30
Global database object with configuration in F3
<?php
// Load configuration
$f3->config('config.ini');
// Prepare the database
$dbConfig = $f3->get('database');
if (!isset($dbConfig['port']))
$dbConfig['port'] = 3306;
$f3->set('DB', new DB\SQL(
@Fohlen
Fohlen / requath.py
Created May 5, 2015 17:55
A really simple thing to generate auth requests with pycube2crypto
#!/usr/bin/env python
import sys, cube2crypto
def main():
if sys.argv.__len__() == 2:
try:
challenge, answer = cube2crypto.generate_challenge(sys.argv[1])
print (str(challenge) + '\n' + str(answer))
except Exception:
@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
@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 / 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 / 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 / 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 / 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>