Skip to content

Instantly share code, notes, and snippets.

View jcefoli's full-sized avatar

Joe Cefoli jcefoli

View GitHub Profile
@jcefoli
jcefoli / iptables_chain.sh
Created January 13, 2016 15:12
IPTables Chaining Example
#!/bin/bash
iptables -F #Warning. Removes all rules
iptables --delete-chain trustedIPs
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
iptables -N trustedIPs
iptables -A trustedIPs --src 1.1.1.1/32 -j ACCEPT #CIDR example
iptables -A trustedIPs --src 2.2.2.2 -j ACCEPT #Single IP Example
iptables -A INPUT -j DROP
@jcefoli
jcefoli / wattMeter.py
Created January 18, 2016 20:53
Connects to DLink DSP-215 to print out realtime wattage used
#!/usr/bin/python
# Modified from https://github.com/fake-name/DSP-W215-Poller
import time
import urllib.parse
import urllib.request
import random
DSP_OUTLET_IP = '192.168.1.2'
UPDATE_INTERVAL = 2
@jcefoli
jcefoli / mongocollectioncounteremail.sh
Created January 26, 2016 22:42
Sends An Email With the Number of Documents in a MongoDB Collection
#!/bin/bash
myCollectionCount=`mongo -u user -p password database_name --quiet --eval 'db.getCollection("my_collection").count()'`
echo "my_collection Count: $myCollectionCount > disk.txt
echo >> disk.txt
df /dev/mapper/volume-group >> disk.txt
cat disk.txt | mail -S smtp="smtp.relay.tld:25" -r "From Name<fromemail@my.tld>" -s "Email Subject" -v "recipient1@my.tld"
rm disk.txt
@jcefoli
jcefoli / userDefineLang.xml
Created January 28, 2016 16:09
NotePad++ User Defined Parsing for: nginx, golang and puppet manifest files
<NotepadPlus>
<UserLang name="go" ext="go">
<Settings>
<Global caseIgnored="no" />
<TreatAsSymbol comment="no" commentLine="no" />
<Prefix words1="no" words2="no" words3="no" words4="no" />
</Settings>
<KeywordLists>
<Keywords name="Delimiters">&quot;&apos;0&quot;&apos;0</Keywords>
<Keywords name="Folder+" />
@jcefoli
jcefoli / flush_dotnet_temp.cmd
Created February 19, 2016 14:14
Flush .NET Cache
@ECHO OFF
iisreset /stop
ECHO Deleting x86 Temporary ASP.NET Files...
for /d %%i in ("%systemroot%\Microsoft.Net\Framework\v*") do for /d %%f in ("%%i\Temporary ASP.NET Files\*") do RD /q/s "%%f"
ECHO Deleting x64 Temporary ASP.NET Files
for /d %%i in ("%systemroot%\Microsoft.Net\Framework64\v*") do for /d %%f in ("%%i\Temporary ASP.NET Files\*") do RD /q/s "%%f"
@jcefoli
jcefoli / echotable.bat
Created May 8, 2016 07:14
Prints text within a table in a batch file
@ECHO OFF
ECHO ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO ³ Title Here ³
ECHO ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
ECHO ³ Put all of your text here. It will be shown ³
ECHO ³ in a nice table. ³
ECHO ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ECHO.
@jcefoli
jcefoli / check_unsigned.ps1
Created July 25, 2016 14:47
Check if Powershell Script is Unsigned, Set it, and Terminate the Script
$Policy = "Unrestricted"
If ((get-ExecutionPolicy) -ne $Policy) {
Write-Host "Script Execution is disabled. Enabling it now"
Set-ExecutionPolicy $Policy -Force
Write-Host "Please Re-Run this script in a new powershell enviroment"
Exit
}
@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 / makewebm.ps1
Created December 22, 2015 18:23
Generate a WebM Video in PowerShell using open source tools
<#
Name: makewebm.ps1
Version: 1.0
Description: This script will take all image files in a folder and automagically generate a webm video file using some open source tools.
Usage:
powershell "& "C:\Scripts\makewebm.ps1"
Required Binaries:
- vpxenc.exe: https://github.com/balistof/NVP8/tree/master/vpx-vp8-debug-src-x86-win32mt-vs9-v1.0.0/bin/Win32