Skip to content

Instantly share code, notes, and snippets.

View thannaske's full-sized avatar
🏠
Working from home

Tobias thannaske

🏠
Working from home
View GitHub Profile
frontend app
bind :80
stick-table type ipv6 size 100k expire 30s store http_req_rate(10s)
http-request track-sc0 src
http-request deny deny_status 429 if { sc_http_req_rate(0) gt 20 }
default_backend laravel
backend laravel
timeout queue 10s
server app-1 10.10.100.101:8080 check maxconn 30
server app-2 10.10.100.102:8080 check maxconn 30
server app-3 10.10.100.103:8080 check maxconn 30
<?php
// Allow up to 60 requests in 1 minute for that route (= 1 req/s)
Route::get('api/v1/user', 'Api\UserController@index')->middleware('throttle:60,1');
// Allow up to 60 requests in 60 minutes for that route (= 1 req/m)
Route::post('api/v1/user', 'Api\UserController@store')->middleware('throttle:60,60');
// Rate Limiting for a whole group of routes
Route::group(['middleware' => 'throttle:60,1'], function () {
@thannaske
thannaske / applepay-germany.py
Created September 18, 2018 09:19
Check whether ApplePay ist available in Germany or not
import urllib.request
import json
r = urllib.request.urlopen("https://smp-device-content.apple.com/static/region/v2/config.json").read()
content = json.loads(r.decode('utf-8'))
if "DE" in content['SupportedRegions'].keys():
print("ApplePay is available in DE.")
else:
print("ApplePay is not available in DE, yet.")
<?php
// [...]
protected $user;
/**
* Create a new message instance.
*
* @return void
<?php
namespace App\Listeners;
use Illuminate\Support\Facades\Mail;
use Illuminate\Auth\Events\Registered;
class UserRegistered
{
<?php
// [...]
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
<?php
// [...]
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
<?php
// [...]
Route::get('users/{user}/{token}/confirm', 'Auth\\RegisterController@confirm')->name('confirm');
// [...]
<?php
// [...]
/**
* Perform the confirmation of the user's e-mail address.
*
* @param User $user The provided user instance
* @param $token string The provided confirmation token
* @return mixed