Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Chris Fidao fideloper

🏠
Working from home
View GitHub Profile
@fideloper
fideloper / microsoft_graph_api_php_jwt.md
Last active February 6, 2023 13:20
Microsoft Graph API - oAuth apps with PHP and JWT certification authentication
View microsoft_graph_api_php_jwt.md

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 / stream_file.php
Last active February 2, 2023 19:22
Stream file from S3 to browser, assume Laravel Filesystem usage
View stream_file.php
<?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 / certbot.sh
Last active January 30, 2023 14:09
Certbot on Ubuntu, wildcard subdomains via CloudFlare DNS challenge
View certbot.sh
# 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 / mount_aws_nvme_ephemeral.sh
Last active January 12, 2023 17:06
Find, format, and mount an AWS Ephemeral NVMe disk within ec2 in user data
View mount_aws_nvme_ephemeral.sh
#!/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 / site.backup.sh
Created May 15, 2012 20:14
Backup whm account files and database
View site.backup.sh
#!/bin/bash
#Show instructions
function show_usage {
echo "Backup account and database, assuming /home/USER filesystem setup."
echo "Usage:"
echo " -h Help menu - See this information"
echo " Files: "
echo " -a Account user name, for use in /home/USER backup. If no path is set via -p flag, the /home/USER path will be backed up. "
echo " -f Filepath to Backup "
@fideloper
fideloper / crypt.py
Created June 4, 2015 13:52
Decrypt Laravel-encrypted value
View crypt.py
import os
import base64
import json
from Crypto.Cipher import AES
from phpserialize import loads
def decrypt(payload):
data = json.loads(base64.b64decode(payload))
@fideloper
fideloper / vim_tmux_setup.sh
Last active August 24, 2022 23:31
Setup Vim+Vundle+Solarized+Tmux in a Vagrant Ubuntu box. This goes with my article on Vim+Tmux here: http://fideloper.com/mac-vim-tmux
View vim_tmux_setup.sh
#!/usr/bin/env bash
# Bash script to automate Vim+Tmux install as written about here:
# http://fideloper.com/mac-vim-tmux
# Test if Git is installed.
# Installing Git is not the job of this script
git --version 2>&1 >/dev/null
GIT_IS_INSTALLED=$?
@fideloper
fideloper / sphinx.conf
Created October 3, 2012 01:15
Install Sphinx and php .so in Ubuntu 12.04
View sphinx.conf
#############################################################################
## data source definitions
#############################################################################
source users
{
# data source type. mandatory, no default value
# known types are mysql, pgsql, mssql, xmlpipe, xmlpipe2, odbc
type = mysql
@fideloper
fideloper / vhost.py
Last active March 18, 2022 10:58
Create vHost Ubuntu Lamp-Server (bash and python)
View vhost.py
#! /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
#