Skip to content

Instantly share code, notes, and snippets.

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

Chris Fidao fideloper

🏠
Working from home
View GitHub Profile
@fideloper
fideloper / mount_aws_nvme_ephemeral.sh
Last active April 25, 2024 12:31
Find, format, and mount an AWS Ephemeral NVMe disk within ec2 in user data
#!/usr/bin/env bash
###
## This mounts a (single) ephemral NVMe drive in an EC2 server.
## It's meant to be run once, within user-data
## For EBS drives (non-ephemeral storage), see: https://gist.github.com/jalaziz/c22c8464cb602bc2b8d0a339b013a9c4
#
@fideloper
fideloper / certbot.sh
Last active April 18, 2024 14:43
Certbot on Ubuntu, wildcard subdomains via CloudFlare DNS challenge
# Used on Ubuntu 18.04 and 20.04
# Find instructions for other OSes here: https://certbot.eff.org/instructions
# Install Certbot via Snaps
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
# Install DNS CloudFlare plugin
sudo snap set certbot trust-plugin-with-root=ok
@fideloper
fideloper / microsoft_graph_api_php_jwt.md
Last active February 19, 2024 18:09
Microsoft Graph API - oAuth apps with PHP and JWT certification authentication

Microsoft Graph API - oAuth apps with PHP and JWT certification authentication

If you've ever wanted to create an oAuth style application with Microsoft, you might have felt this pain before.

In true Enterprise Microsoft Fashion™, there's a lot going on.

This will be a bit long because of that. I hope I haven't missed anything (but I'm sure I have)!

We'll be using PHP (Laravel in my case).

@fideloper
fideloper / SlackActionController.php
Created February 6, 2024 15:01
Verify Slack webhooks in Laravel
<?php
namespace App\Http\Controllers\Slack;
use App\Slack\Webhook;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
@fideloper
fideloper / vhost.py
Last active January 25, 2024 23:37
Create vHost Ubuntu Lamp-Server (bash and python)
#! /usr/bin/python
from sys import argv
from os.path import exists
from os import makedirs
from os import symlink
from os import system
import getopt
#
@fideloper
fideloper / stream_file.php
Last active January 17, 2024 18:41
Stream file from S3 to browser, assume Laravel Filesystem usage
<?php
/*************************************************************************
* Get File Information
*/
// Assuming these come from some data source in your app
$s3FileKey = 's3/key/path/to/file.ext';
$fileName = 'file.ext';
@fideloper
fideloper / update_curl.sh
Last active January 11, 2024 15:23
Update curl on Ubuntu 14.04
#! /usr/bin/env bash
# Install any build dependencies needed for curl
sudo apt-get build-dep curl
# Get latest (as of Feb 25, 2016) libcurl
mkdir ~/curl
cd ~/curl
wget http://curl.haxx.se/download/curl-7.50.2.tar.bz2
tar -xvjf curl-7.50.2.tar.bz2
@fideloper
fideloper / crypt.py
Created June 4, 2015 13:52
Decrypt Laravel-encrypted value
import os
import base64
import json
from Crypto.Cipher import AES
from phpserialize import loads
def decrypt(payload):
data = json.loads(base64.b64decode(payload))
server {
# Redirect any subdomain to the root domain
# to be captured by next server block
server_name *.example.com;
return 301 $scheme://example.com$request_uri;
}
server {
root /var/www;
index index.html index.htm;
@fideloper
fideloper / install.sh
Last active October 30, 2023 20:03
Vagrant Provisioning Script for PHP applications. This installs a LAMP stack.
#!/usr/bin/env bash
echo ">>> Starting Install Script"
# Update
sudo apt-get update
# Install MySQL without prompt
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'