Skip to content

Instantly share code, notes, and snippets.

# SETUP #
DOMAIN=example.com
PROJECT_REPO="git@github.com:example.com/app.git"
AMOUNT_KEEP_RELEASES=5
RELEASE_NAME=$(date +%s--%Y_%m_%d--%H_%M_%S)
RELEASES_DIRECTORY=~/$DOMAIN/releases
DEPLOYMENT_DIRECTORY=$RELEASES_DIRECTORY/$RELEASE_NAME
# stop script on error signal (-e) and undefined variables (-u)
@malle-pietje
malle-pietje / demo.php
Created August 30, 2024 10:54 — forked from freekrai/demo.php
PHP session-based rate limiter for APIs
<?php
date_default_timezone_set('America/Los_Angeles');
session_start();
include("ratelimiter.php");
// in this sample, we are using the originating IP, but you can modify to use API keys, or tokens or what-have-you.
$rateLimiter = new RateLimiter($_SERVER["REMOTE_ADDR"]);
$limit = 100; // number of connections to limit user to per $minutes
$minutes = 1; // number of $minutes to check for.
@malle-pietje
malle-pietje / Backpack export operation (excel and csv) .md
Created October 4, 2022 17:58 — forked from AndreiTelteu/Backpack export operation (excel and csv) .md
Export operation for backpack admin panel, that exports the entire database table, not just the entries shown on page
  1. First install maatwebsite/excel package:
composer require maatwebsite/excel
  1. Copy export.blade.php from this gist in resources/views/vendor/backpack/crud/buttons/export.blade.php

  2. Copy ExportOperation.php from this gist in app/Traits/Operations/ExportOperation.php

@malle-pietje
malle-pietje / mongodb_storage_engine.txt
Created December 2, 2020 11:56
Determine MongoDB StorageEngine
$ mongo --port 27117
MongoDB shell version v3.4.14
connecting to: mongodb://127.0.0.1:27117/
MongoDB server version: 3.4.14
Server has startup warnings:
2018-07-17T10:06:31.923+0100 I CONTROL [initandlisten]
2018-07-17T10:06:31.923+0100 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-07-17T10:06:31.923+0100 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-07-17T10:06:31.923+0100 I CONTROL [initandlisten]
> use ace
@malle-pietje
malle-pietje / postal-codes.json
Created October 14, 2019 10:19 — forked from jamesbar2/postal-codes.json
Global postal codes regex formats
[{
"Note": "The first two digits (ranging from 10–43) correspond to the province, while the last two digits correspond either to the city/delivery zone (range 01–50) or to the district/delivery zone (range 51–99). Afghanistan Postal code lookup",
"Country": "Afghanistan",
"ISO": "AF",
"Format": "NNNN",
"Regex": "^\\d{4}$"
}, {
"Note": "With Finland, first two numbers are 22.",
"Country": "Åland Islands",
"ISO": "AX",
@malle-pietje
malle-pietje / dpi_categories.json
Last active October 22, 2018 12:08 — forked from mwegner/categories.json
list of UniFi SDN controller DPI Categories
{
"categories":{
"0":{
"name":"Instant messaging",
"applications":[
1,
2,
3,
4,
5,
@malle-pietje
malle-pietje / AjaxQueue.js
Created February 2, 2018 09:21 — forked from Terrance/AjaxQueue.js
Limit concurrent jQuery ajax requests to at most 3 at a time, and queue the rest.
var ajaxReqs = 0;
var ajaxQueue = [];
var ajaxActive = 0;
var ajaxMaxConc = 3;
function addAjax(obj) {
ajaxReqs++;
var oldSuccess = obj.success;
var oldError = obj.error;
var callback = function() {
ajaxReqs--;
@malle-pietje
malle-pietje / index.html
Last active May 13, 2024 03:02
Redirection to a custom URL from the UniFi controller JSP-based captive portal
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<title><unifi txt="Redirector" /></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="refresh" content="0;url=https://<YOUR CAPTIVE PORTAL URL>/<unifi var="mac" />/<unifi var="ap_mac" />">
</head>
<body>
</body>
</html>