Skip to content

Instantly share code, notes, and snippets.

View gte445e's full-sized avatar
:octocat:
loading...

Justin Steele gte445e

:octocat:
loading...
View GitHub Profile
@gte445e
gte445e / cloud-init.yml
Created December 11, 2022 05:12
cloud-init with nginx
#cloud-config
package_upgrade: true
packages:
- nginx
@gte445e
gte445e / primarykey.sql
Last active January 6, 2021 14:56
Sql Primary Key Checks
select
'exec sp_rename @objtype = ''INDEX'', @objname = ''' + quotename(s.name) + '.' + quotename(t.name) + '.' + quotename(pk.name) + ''', @newname = ''' + 'PK_' + t.name + '''' as RenameScript
from
sys.schemas s
inner join
sys.tables t
on s.schema_id = t.schema_id
inner join sys.key_constraints pk
on t.object_id = pk.parent_object_id
where
@gte445e
gte445e / Default Constraints.sql
Created August 21, 2019 20:31
Sql Default Constraints Checks
--
-- Default Constraint name should match table and column name
--
select
'ALTER TABLE ' + quotename(s.name) + '.' + quotename(t.name) + ' DROP CONSTRAINT ' + quotename(dc.name) as DropStatement,
'ALTER TABLE ' + quotename(s.name) + '.' + quotename(t.name) + ' ADD CONSTRAINT ' + quotename('DF_' + t.name + '_' + c.name) + ' DEFAULT ' + dc.definition + ' FOR ' + quotename(c.name) as CreateStatement
from
sys.default_constraints dc
inner join sys.schemas s
on dc.schema_id = s.schema_id
@gte445e
gte445e / git.sh
Last active August 2, 2018 19:55
Apply commit from another repository
# Is it possible to cherry-pick a commit from another git repository?
# https://stackoverflow.com/questions/5120038/is-it-possible-to-cherry-pick-a-commit-from-another-git-repository
git --git-dir=../<some_other_repo>/.git \
format-patch -k -1 --stdout <commit SHA> | \
git am --no-3way -k
@gte445e
gte445e / inner-trim.cs
Created May 4, 2018 19:57
Trim multiple spaces
RegexOptions options = RegexOptions.None;
Regex regex = new Regex(@"[ ]{ 2,}", options);
string input = " 1 2 3 4 5 ";
string result = regex.Replace(input, " ");
Console.WriteLine("<begin>" + result + "<end>");
@gte445e
gte445e / js-review.js
Created April 28, 2018 14:35
Node script beautify and hint every js file
'use strict';
const glob = require("glob");
const { exec } = require('child_process');
glob("Pages//**//*.js", function (er, files) {
files.forEach(function (cmd) {
const jsBeautifyCmd = 'js-beautify ' + cmd + ' -r';
@gte445e
gte445e / StringExtensions.cs
Created April 8, 2018 17:24
Title Case String extension
using System.Globalization;
using System.Threading;
namespace System
{
public static class StringExtensions
{
public static string ToTitleCase(this string value)
{
if (value == null) return null;
@gte445e
gte445e / IEnumerableExtensions.cs
Created April 8, 2018 17:22
LINQ Full Outer Join extension
using System;
using System.Collections.Generic;
using System.Linq;
namespace System.Collections.Generic
{
public static class IEnumerableExtensions
{
public static IEnumerable<(T1 Left, T2 Right)> FullOuterJoin<T1, T2>(this IEnumerable<T1> left, IEnumerable<T2> right, Func<T1, T2, bool> match)
{
@gte445e
gte445e / docker-pull-all-images.ps1
Created May 28, 2017 19:07
Docker Pull/Update Images using PowerShell
# Pull all images
docker images --format "{{.Repository}}" | %{docker pull $_}