Skip to content

Instantly share code, notes, and snippets.

View mikaelweave's full-sized avatar
🔥

Mikael Weaver mikaelweave

🔥
View GitHub Profile
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%';
# 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
(new System.Xml.Serialization.XmlSerializer(obj.GetType())).Serialize(new System.IO.StreamWriter(@"c:\temp\text.xml"), obj)
@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) {
@mikaelweave
mikaelweave / Default AJAX Get
Last active November 9, 2017 16:49
Default Ajax
$.ajax({
contentType: 'application/json',
dataType: 'html',
type: 'GET',
async: true,
cache: false,
url: url,
success: function(result) {
},
error: function() {
@mikaelweave
mikaelweave / DropDownListFor Enum
Last active November 9, 2017 16:49
Drop Down List Split Enums
@Html.DropDownListFor(model => model.Status, Status.GetValues(typeof(Status)).Cast<Status>().Select(v => new SelectListItem
{
Text = WebAdministration.Classes.Helpers.SplitCamelCase(v.ToString()),
Value = ((int)v).ToString()
}).ToList(), new { @class = "form-control" })
/// <summary>
/// Takes a camel case string and splits it
/// </summary>
@mikaelweave
mikaelweave / reinstall-package
Created June 29, 2017 19:51
nuget commands
update-package Newtonsoft.Json -reinstall
@mikaelweave
mikaelweave / lowercase_guids
Created June 10, 2016 14:49
Sublime Text Search/Replace Hacks
find:
({........-....-....-....-............})
replace:
\L$1
@mikaelweave
mikaelweave / row_rank_sql_example.sql
Last active March 15, 2016 17:18
Examples on how to use row_number and rank
SELECT
ROW_NUMBER() OVER (ORDER BY ct_id) AS row_num,
ROW_NUMBER() OVER (PARTITION BY source_id ORDER BY ct_id) AS partitioned_row_num,
RANK() OVER (ORDER BY ct_id) AS row_num,
RANK() OVER (PARTITION BY source_id ORDER BY ct_id) AS partitioned_row_num
FROM
ct_pstor
@mikaelweave
mikaelweave / connect_to_databaseps1.ps1
Created February 1, 2016 16:54
Database Connection Powershell snippits
function Invoke-SQL {
param(
[string] $dataSource = $(throw "Please specify a datasource."),
[string] $database = $(throw "Please specify a database."),
[string] $sqlCommand = $(throw "Please specify a query.")
)
$connectionString = "Data Source=$dataSource; " +
"Integrated Security=SSPI; " +
"Initial Catalog=$database"