Skip to content

Instantly share code, notes, and snippets.

@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

@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
@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);