Skip to content

Instantly share code, notes, and snippets.

View jcefoli's full-sized avatar

Joe Cefoli jcefoli

View GitHub Profile
@jcefoli
jcefoli / cleanup.sh
Last active August 23, 2016 06:29
Clean up Unused Let's Encrypt Certs
rm -rf /etc/letsencrypt/live/${DOMAIN}
rm /etc/letsencrypt/renewal/${DOMAIN}.conf
@jcefoli
jcefoli / nginx-readme.md
Last active August 23, 2016 07:00
Preferred nginx Config for Multiple Sites, Using Let's Encrypt for SSL

My Preferred nginx Config For Multiple Sites

Goals

  • Host multiple sites on a single server
  • Use Let's Encrypt and force SSL on all subdomains
  • Create an area for Let's Encrypt's ACME verification, but restrict this to specific host headers
    • This is so we can auto-renew certs but prevent my server from responding to someone else's bogus enrollment request if they point DNS at my server and it responds to the validation
  • Create an https default_server fallback, so my sites are isolated if tou type the ipv6only
  • Top security practices, with an A+ rating on SSLLabs.com scan
@jcefoli
jcefoli / letsencrypt_2018.md
Last active March 14, 2018 05:20 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two modes when you don't want Certbot to edit your configuration:

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80) to renew certificates.

In the following, we're setting up mydomain.com to be served from /var/www/mydomain, and challenges will be served from /var/www/letsencrypt.

@jcefoli
jcefoli / clearbash.sh
Created January 10, 2017 18:20
Clear bash history
cat /dev/null > ~/.bash_history && history -c && exit
@jcefoli
jcefoli / addtopath.ps1
Created March 1, 2017 15:09
Permanently Add Directory to User Path ($env:path)
#In this example, we're adding C:\bin. I hard coded the path to make it a powershell one liner
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\bin", [EnvironmentVariableTarget]::User)
@jcefoli
jcefoli / Run_SQL.ps1
Last active January 9, 2024 01:37
Loop Through Folder and Run all .sql Scripts Against a MSSQL Database
<#
.SYNOPSIS
Powershell Script that will loop through a folder and run SQL scripts against a database
.Description
This script was developed to be used with VSTS. It must accept parameters, since VSTS variables cannot be used within scripts. Developers can specify a different SQL folder with each build
.NOTES
Version: 1.0.1
Author: jcefoli
@jcefoli
jcefoli / hg-to-git.md
Last active April 19, 2018 14:32
Convert Mercurial (HG) Repositories to Git

Prereqs

Must have mercurial, the hg-git mercurial extension, and git installed

Initiate bare Git repository

git init --bare /path/to/git/repo.git

Push HG dir to Git using hggit extension

cd /path/to/hg/repo

hg bookmark -r default master

@jcefoli
jcefoli / checkforroot.sh
Last active March 12, 2020 15:46
Check for Root
#!/usr/bin/env bash
if [ "$(whoami)" != "root" ]; then
echo -e "Sorry, you are not running as root.\nPlease run this script as root.\n\nExiting...";
exit 1
fi
@jcefoli
jcefoli / call_powershell_with_parameters.bat
Created May 8, 2017 19:31
Call Powershell Script With Parameters from Batch File
powershell.exe -ExecutionPolicy Bypass -Command "& {C:\YourScript.ps1 -Parameter 'Value'}"
@jcefoli
jcefoli / install_ruby.sh
Last active December 17, 2018 19:43
Install Ruby Using rbenv on Windows 10 Ubuntu 18.04 Emulation
#!/bin/bash
## This will install Ruby using rbenv on the Windows 10 Ubuntu Subsystem
## The travis gem did not compile correctly when I installed via 'apt-get install ruby' but worked using this method
sudo apt-get -y install build-essential libreadline-dev zlib1g-dev
cd ~
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc