Skip to content

Instantly share code, notes, and snippets.

View Caffe1neAdd1ct's full-sized avatar
💻
Working on multiple projects

Kevin Andrews Caffe1neAdd1ct

💻
Working on multiple projects
View GitHub Profile
@Caffe1neAdd1ct
Caffe1neAdd1ct / template.sh
Created October 21, 2021 09:01 — forked from warlord0/template.sh
Bash Script Template
#!/bin/bash
EXAMPLE="example default"
# Plugin variable description
PROGNAME=$(basename $0)
RELEASE="Revision 1.0.0"
AUTHOR="(c) 2020 Warlord0"
# Functions plugin usage
@Caffe1neAdd1ct
Caffe1neAdd1ct / gist:cf9f600bfe77d5a6edf4c4c495740fcb
Created August 17, 2021 20:56
Apache Reverse Proxy to PHP InBuilt Webserver with SSL
<VirtualHost *:443>
ServerName app.host.local
ServerAdmin root@localhost
DocumentRoot "/srv/http/"
<Directory "/srv/http/">
Options -Indexes -FollowSymLinks -MultiViews
AllowOverride All
@Caffe1neAdd1ct
Caffe1neAdd1ct / alert.sh
Created March 15, 2021 23:53
Colourful Slack Notification In Bash
#!/bin/bash
## Slack Alert Helper
function send_slack_message() {
action="$1"
status=$2
message="$3"
case "$status" in
success ) color="#44d058";;
@Caffe1neAdd1ct
Caffe1neAdd1ct / php-mysqlnd-fix-add.patch
Created November 9, 2020 19:04
PHP 5.6 Patches for aur build mysqlnd bug
diff --git a/php-mysqlnd-fix.patch b/php-mysqlnd-fix.patch
new file mode 100644
index 0000000..1cadcb3
--- /dev/null
+++ b/php-mysqlnd-fix.patch
@@ -0,0 +1,22 @@
+--- a/ext/mysqlnd/mysqlnd_ps_codec.c 2019-01-09 09:54:13.000000000 +0000
++++ b/ext/mysqlnd/mysqlnd_ps_codec.c 2020-11-05 15:21:00.238585270 +0000
+@@ -911,7 +911,7 @@
+ zend_uchar *p = stmt->execute_cmd_buffer.buffer,
@Caffe1neAdd1ct
Caffe1neAdd1ct / huion.sh
Created July 8, 2020 22:32
HUION INSPIROY Q11K V2 startup script
#!/bin/sh
#Set to specific monitor name, based on the output from command: xrandr
MONITOR="DP-1"
PAD_NAME='HUION Huion Tablet Pad pad'
STYLUS_NAME='HUION Huion Tablet Pen stylus'
# Get all device IDs for the PAD_NAME - in case multiples are present for wired and wireless connections
padIDs=$(xinput --list | awk -v search="$PAD_NAME" \
'$0 ~ search {match($0, /id=[0-9]+/);\
@Caffe1neAdd1ct
Caffe1neAdd1ct / image.py
Created July 3, 2020 22:22
Counts background pixels in an image
#!/usr/bin/env python
from PIL import Image
image = Image.open("image.jpg")
bg = image.getpixel((0,0))
width, height = image.size
bg_count = next(n for n,c in image.getcolors(width*height) if c==bg)
img_count = width*height - bg_count
img_percent = img_count*100.0/width/height
print(img_percent)
@Caffe1neAdd1ct
Caffe1neAdd1ct / ComposerIdeHelperNetbeans.php
Last active June 25, 2020 10:57
Laravel IDE Helper Netbeans
<?php
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem as File;
/**
* Modify Generated IDE Helper Files for compatibility with NetBeans
*/
class ComposerIdeHelperNetbeans extends Command
{
@Caffe1neAdd1ct
Caffe1neAdd1ct / TestController.php
Created February 18, 2020 22:44
Laravel 4.2 CSRF with regenerated unique per request tokens
<?php
class TestController extends Controller
{
public function __construct()
{
$this->beforeFilter('csrf', ['only' => ['postTest']]);
}
@Caffe1neAdd1ct
Caffe1neAdd1ct / .bash_profile
Last active January 30, 2020 13:50
Alerts on SSH Login
## Email Alert - make sure xmail is installed and replace email address below
echo 'ALERT - $HOSTNAME - Root Shell Access on:' `date` `who` | mail -s "Alert: Root Access at $HOSTNAME from `who | awk '{print $6}'`" you@email.here & disown > /dev/null 2>&1
## Register a webhook on slack "Incoming WebHooks" in the services section and replace hook url below
curl -X POST --silent --output /dev/null \
-H 'Content-type: application/json' \
-H "Accept: application/json" \
--data @<(cat <<EOF
{
"text": "ALERT - $HOSTNAME - $USER Shell Access on:' `date` `who`",
@Caffe1neAdd1ct
Caffe1neAdd1ct / table-indexes.sql
Created November 28, 2019 11:11
Find all indexes in a database to compare environments
select index_schema,
index_name,
group_concat(column_name order by seq_in_index) as index_columns,
index_type,
case non_unique
when 1 then 'Not Unique'
else 'Unique'
end as is_unique,
table_name
from information_schema.statistics