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)
@AndreiTelteu
AndreiTelteu / Backpack export operation (excel and csv) .md
Last active October 4, 2022 17:58
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

@sebastiaanfranken
sebastiaanfranken / kvm-backup.sh
Last active September 9, 2024 12:59
Backup all VM's in KVM
#!/bin/bash
# This script creates a backup for all running libvirtd domains on the host it's
# run on.
#
# I created this script because I needed a lightweight backup solution for a pure libvirtd
# virtual machine host.
#
# You can use / modify this script however you like. All I ask is that if you find a bug or something
# very wrong (or if you find a massive upgrade point) is that you let me know!
@bsodmike
bsodmike / letsencrypt-unifi.sh
Created July 12, 2017 21:53
Using LetsEncrypt With The Unifi Controller
#!/usr/bin/env bash
# Ref: https://www.reddit.com/r/Ubiquiti/comments/43v23u/using_letsencrypt_with_the_unifi_controller/
# Original: https://source.sosdg.org/brielle/lets-encrypt-scripts/raw/master/gen-unifi-cert.sh
# ---
# Modified script from here: https://github.com/FarsetLabs/letsencrypt-helper-scripts/blob/master/letsencrypt-unifi.sh
# Modified by: Brielle Bruns <bruns@2mbit.com>
# Download URL: https://source.sosdg.org/brielle/lets-encrypt-scripts
# Version: 1.3
# Last Changed: 03/21/2017
# 02/02/2016: Fixed some errors with key export/import, removed lame docker requirements
@freekrai
freekrai / demo.php
Last active September 2, 2024 14:11
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.
@stevejenkins
stevejenkins / unifi_ssl_import.sh
Last active August 30, 2021 03:57
Import and use SSL certificates (including Let's Encrypt) with the Ubiquiti UniFi Controller on Unix/Linux Systems
# MOVED TO https://github.com/stevejenkins/unifi-linux-utils
@Terrance
Terrance / AjaxQueue.js
Created April 10, 2016 14:37
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--;
@fullybaked
fullybaked / usort.php
Created September 1, 2015 12:05
Usort with PHP7 Spaceship vs PHP5.6
<?php
// PHP 5.6
usort($array, function($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
});
@MikeRogers0
MikeRogers0 / validate-email.php
Created June 16, 2012 17:09
How to validate an email address with PHP
<?php
function validEmail($email){
// Check the formatting is correct
if(filter_var($email, FILTER_VALIDATE_EMAIL) === false){
return FALSE;
}
// Next check the domain is real.
$domain = explode("@", $email, 2);
return checkdnsrr($domain[1]); // returns TRUE/FALSE;
@xhezairbey
xhezairbey / bitly_api_v3_shorten.php
Created October 27, 2011 23:42
BitLy API v3 Shorten PHP
<?php
function bitly_shorten($url) {
$login = "bitly_login";
$apikey = "bitly_apikey";
$format = "json";
$query = array("login" => $login,
"apiKey" => $apikey,
"longUrl" => urlencode($url),
"format" => $format);