Skip to content

Instantly share code, notes, and snippets.

View mikaelweave's full-sized avatar
🔥

Mikael Weaver mikaelweave

🔥
View GitHub Profile
@mikaelweave
mikaelweave / Replace Connection.ps1
Created August 30, 2017 16:25
Replace Connection Strings
param([string]$oc,[string]$nc)
Write-Host "Searching for: "$oc
Get-ChildItem test.config -recurse |
Foreach-Object {
$c = ($_ | Get-Content)
$n = $c -replace [RegEx]::Escape($oc), $nc
if($c -ne $n) {
Write-Host $_.FullName
if($nc -ne $NULL) {
(new System.Xml.Serialization.XmlSerializer(obj.GetType())).Serialize(new System.IO.StreamWriter(@"c:\temp\text.xml"), obj)
# read in the certificate from a pre-existing PFX file
$cert = Get-PfxCertificate -FilePath "$env:temp\codeSignCert.pfx"
# find all scripts in your user profile...
Get-ChildItem -Path $home\Documents -Filter *.ps1 -Include *.ps1 -Recurse -ErrorAction SilentlyContinue |
# ...that do not have a signature yet...
Where-Object {
($_ | Get-AuthenticodeSignature).Status -eq 'NotSigned'
} |
# and apply one
SELECT DISTINCT
o.name AS Object_Name,
o.type_desc
FROM sys.sql_modules m
INNER JOIN
sys.objects o
ON m.object_id = o.object_id
WHERE m.definition Like '%ABD%';
IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'IF' AND object_id = object_id('dbo.ParseFilePath'))
EXEC ('CREATE FUNCTION dbo.ParseFilePath() RETURNS TABLE AS RETURN SELECT Result = ''This is a stub'';' )
GO
ALTER FUNCTION dbo.ParseFilePath (@FilePath nvarchar(300))
RETURNS TABLE
/*************************************************************************************************
AUTHOR: Andy Mallon
CREATED: 20180114
Install-Module -Name Posh-SSH -Scope CurrentUser
Get-Command -Module Posh-SSH
#view if readonly
gci -Include *.cshtml -Recurse -Path $pwd | select fullname,isreadonly
#remove read only
gci -Include *.cshtml -Recurse | % { if($_.IsReadOnly){$_.IsReadOnly= $false} }
@mikaelweave
mikaelweave / get_random_subset_of_files
Created July 20, 2018 21:51
Taken files in a directory, get a random subset of them
import os, random
#Where the image folders live
hardshell_path = "gear_images/hardshell_jackets/"
insulated_path = "gear_images/insulated_jackets/"
#Play around with ratio training to run
train_ratio = 0.5
set_hardshell = set(os.listdir(hardshell_path))
## REMOVE CRAP
Get-AppxPackage -AllUsers | Remove-AppxPackage
## INSTALL PACKAGE MANAGERS
Write-Host "Installing Scoop and Choco..."
Set-ExecutionPolicy Bypass -Scope Process -Force; iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
## INSTALL APPS THROUGH SCOOP
Write-Host "Installing apps through scoop (cmder, curl, docker)..."
@mikaelweave
mikaelweave / reclaimWindows10.ps1
Created August 8, 2018 21:37 — forked from alirobe/reclaimWindows10.ps1
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
##########
# Tweaked Win10 Initial Setup Script
# Primary Author: Disassembler <[email protected]>
# Modified by: alirobe <[email protected]> based on my personal preferences.
# Version: 2.20.1, 2018-07-23
# Primary Author Source: https://github.com/Disassembler0/Win10-Initial-Setup-Script
# Tweaked Source: https://gist.github.com/alirobe/7f3b34ad89a159e6daa1/
# Tweak difference:
#
# @alirobe's version is a subset focused on safely disabling telemetry, some 'smart' features and 3rd party bloat ...