Skip to content

Instantly share code, notes, and snippets.

View jdforsythe's full-sized avatar

Jeremy Forsythe jdforsythe

View GitHub Profile
@jdforsythe
jdforsythe / ProcessQueueAndExit.php
Created May 5, 2016 17:56
Laravel 5 Artisan Process Entire Queue and Exit Command
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Carbon\Carbon;
use Illuminate\Queue\Worker;
use Illuminate\Contracts\Queue\Job;
use Symfony\Component\Console\Input\InputOption;
@jdforsythe
jdforsythe / test_laravel_crypt_lengths.php
Created April 14, 2016 17:37
Test Laravel Crypt::encrypt() result lengths
<?php
function random_bytes($bytes) {
$secure = true;
$buf = openssl_random_pseudo_bytes($bytes, $secure);
if ($buf !== false && $secure && strlen($buf) === $bytes) {
return $buf;
}
}
@jdforsythe
jdforsythe / create-ca.sh
Created April 11, 2016 12:42
Create Certificate Authority
#!/bin/bash
# generate root CA key
echo "Generating root CA key"
openssl genrsa -aes256 -out rootca.key 2048
# generate root CA certificate (20 years)
echo "Generating root CA certificate"
openssl req -new -x509 -key rootca.key -days 7304 -sha256
@jdforsythe
jdforsythe / find_nuget_refs.sh
Created March 23, 2016 14:47
Find all VS projects that reference a Nuget Package as a dependency from a top-level dev folder
#!/bin/bash
DEFAULT_VS_PROJECT_TOP_LEVEL_FOLDER="/e/dev/internal-apps"
echo "Finding all projects using NuGet package for ${1}"
# find all nested folders with a packages.config file (where the NuGet package references are stored)
# loop through the results
find ${2:-"${DEFAULT_VS_PROJECT_TOP_LEVEL_FOLDER}"} -name "packages.config" -exec grep -l "${1}" {} \; | while read -r filename ; do
echo $(basename "$(dirname "$filename")")
@jdforsythe
jdforsythe / find_nuget_deps.sh
Created March 23, 2016 14:24
List all VS projects with their NuGet dependencies from a top-level dev folder
#!/bin/bash
DEFAULT_VS_PROJECT_TOP_LEVEL_FOLDER="/e/dev/internal-apps"
# find all nested folders with a packages.config file (where the NuGet package references are stored)
# loop through the results
find ${1:-"${DEFAULT_VS_PROJECT_TOP_LEVEL_FOLDER}"} -name "packages.config" | while read -r filename ; do
echo
echo $(basename "$(dirname "$filename")")
cat "$filename" | grep "<package " | sed -n 's/.*id="\([^"]*\).*version="\([^"]*\).*/\1@\2/p' | sed 's/^/ |-/'
@jdforsythe
jdforsythe / ExecutePowershellCmdlet.cs
Created February 16, 2016 20:28
Execute Powershell Cmdlet in C#
using System.Management.Automation;
namespace ExecutePowershellCmdlet {
class Program {
using (PowerShell pshell = PowerShell.Create()) {
DateTime yesterday = DateTime.Today.AddDays(-1);
string date_string = "\"" + yesterday.ToString("MM"_ + "/" + yesterday.ToString("dd") + "/" + yesterday.ToString("yyyy") + "\""; // "MM/dd/yyyy"
@jdforsythe
jdforsythe / .bashrc
Last active May 3, 2017 14:50
.bashrc Aliases
# .bashrc
# alias for "d2u <filename>" which converts line endings from dos to unix using sed
alias d2u='function _d2u(){ echo "Converting line endings from Dos2Unix."; sed -i "s/\r$//" "$1"; };_d2u'
# alias for "untar" which executes "tar -xvf" to extract a tarball
alias untar='tar -xvf'
# alias for "tarball" which executes "tar cvzf" to create a tarball
alias targz='tar cvzf'
@jdforsythe
jdforsythe / get-package-json-version.sh
Created December 12, 2015 13:12
Gets the version value from a package.json file
grep -Po '"'"version"'"\s*:\s*"\K([^"]*)' package.json
@jdforsythe
jdforsythe / Module_Delete.vba
Created November 12, 2015 15:10
Excel VBA Macros
Sub DeleteRowByColumnValue()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
@jdforsythe
jdforsythe / ConvertTwoSpacesToFour.sublime-macro
Created August 18, 2015 12:25
ST2 or ST3 macro to convert 4-space indentation to 2-space indentation
[
{
"args": null,
"command": "select_all"
},
{
"args": {
"setting": "tab_size",
"value": 4
},