Skip to content

Instantly share code, notes, and snippets.

View jcefoli's full-sized avatar

Joe Cefoli jcefoli

View GitHub Profile
@jcefoli
jcefoli / copytosubdirectories.bat
Created January 28, 2015 03:00
This script takes the contents of one directory and copies them into a newly created folder in all existing subdirectories of the destination directory.
@ECHO OFF
REM | This script will take all files and subdirectories in
REM | C:\Source and copy them into a new folder called "Config" in
REM | all subdirectories of C:\Dest. If there are no subdirectories,
REM | nothing will happen
REM |
REM | ie - C:\Source\*.* will be copied to C:\Dest\Folder\Config\*.*
REM | assuming "Folder" was a preexisting subdirectory
REM :: Define Variables Here ::
@jcefoli
jcefoli / datetimestamp.bat
Created February 18, 2015 07:34
Set Date/Timestamp in Batch File Via Powershell
@ECHO OFF
for /f "usebackq" %%x in (`powershell "get-date -f yyyy-MM-dd_HH:mm:ss"`) do set datetimestamp=%%x
echo %datetimestamp%
pause
@jcefoli
jcefoli / newvm.ps1
Created February 19, 2015 18:22
Hyper-V: This script takes a vhdx file and automatically creates a new VM based off it. All permissions are fixed after the VHDX gets copied.
<#
Script: newvm.ps1
Description: Script to automagically create new VM from a template VM
Usage from CMD: powershell -noexit "& "newvm.ps1"
#>
## Configure Variables Here ##
[String]$templateVMName = "Template.vhdx"
[String]$templateVMPath = "D:\Hyper-V\VHD\"
[String]$setNIC = "Broadcom Netxtreme 57xx Gigabit Controller - Virtual Switch"
@jcefoli
jcefoli / gist:e8a133639e5ff5fa5156
Created September 22, 2015 20:19
Convert PFX Windows Cert to Linux Public/Private Key and Chain
openssl pkcs12 -in ./cert.pfx -clcerts -nokeys -out public.crt
openssl pkcs12 -in ./cert.pfx -nocerts -nodes -out private.rsa
cat public.crt ca-bundle.crt >> bundle.crt
@jcefoli
jcefoli / stopredis.sh
Created November 2, 2015 20:37
Stop Multiple Instances of Redis Server and Sentinel if they're Running on One Server
for f in /etc/init.d/redis*; do $f status; done
@jcefoli
jcefoli / iischeatsheet.bat
Last active January 20, 2023 18:25
IIS Websites and Apppools Delete/Import/Export Cheat Sheet
REM Delete all Websites
%windir%\system32\inetsrv\appcmd list site /xml | %windir%\system32\inetsrv\appcmd delete site /in
REM Delete all App Pools
%windir%\system32\inetsrv\appcmd list apppool /xml | %windir%\system32\inetsrv\appcmd delete apppool /in
REM Export all the Application Pools:
%windir%\system32\inetsrv\appcmd list apppool /config /xml > C:\apppools.xml
REM Import all the Application Pools:
@jcefoli
jcefoli / gist:867db8bef87442744092
Created December 3, 2015 18:54
Tar and gzip a directory's files and subfolders only (without storing the full path to the files in the archive)
tar -cvzf filename.tar.gz -C /path/to/archive .
@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
@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