Skip to content

Instantly share code, notes, and snippets.

View jetstreamin's full-sized avatar
:octocat:
chillin' like the vanilla shake that I am

Mike Mahon jetstreamin

:octocat:
chillin' like the vanilla shake that I am
View GitHub Profile
@jetstreamin
jetstreamin / System Design.md
Created May 17, 2020 10:14 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@jetstreamin
jetstreamin / WeightedRandomSelection.cs
Created April 7, 2020 16:34 — forked from develohpanda/WeightedRandomSelection.cs
Weighted Random Selection - a simplified implementation of the solution found at http://programmers.stackexchange.com/a/150642/244423
/// <summary>
/// Selects a random element from input list using the weights on T to sway selection.
/// T must have a Weight property on it.
/// </summary>
public T SelectRandom<T>(List<T> objects)
{
int totalWeight = 0;
T selected = default(T);
foreach (T obj in objects)
{
@jetstreamin
jetstreamin / WeightedRandomSelectionWithLimitedAllocations.cs
Created April 7, 2020 16:33 — forked from develohpanda/WeightedRandomSelectionWithLimitedAllocations.cs
Weighted Random Selection With Limited Allocations - a modified implementation of the solution found at http://programmers.stackexchange.com/a/150642/244423
/// <summary>
/// Selects a random element from input list using the allocations remaining to sway selection
/// T must have AllocationRemaining, Weight and Id properties on it.
/// </summary>
public T SelectRandom<T>(List<T> objects)
{
int totalWeight = 0;
T selected = default(T);
foreach (T obj in objects)
{
@jetstreamin
jetstreamin / delete-sql.ps1
Last active April 7, 2020 16:28 — forked from develohpanda/delete-sql.ps1
Drop SQL database from Powershell
function Delete-SqlDatabase($serverName, $databaseName) {
Import-Module SQLPS
$server = New-Object Microsoft.SqlServer.Management.Smo.Server($serverName)
$db = $server.databases[$databaseName]
if ($db) {
$server.KillAllprocesses($databaseName)
$db.Drop()
}
}
@jetstreamin
jetstreamin / README.md
Created October 6, 2019 23:14 — forked from jwill9999/README.md
ASP.NET Razor Cheat Sheet
function Lookup-Clsid
{
Param([string]$clsid)
$CLSID_KEY = 'HKLM:\SOFTWARE\Classes\CLSID'
If ( Test-Path $CLSID_KEY\$clsid) {
$name = (Get-ItemProperty -Path $CLSID_KEY\$clsid).'(default)'
$dll = (Get-ItemProperty -Path $CLSID_KEY\$clsid\InProcServer32).'(default)'
}
$name, $dll
@jetstreamin
jetstreamin / gist:d50e8782c370f4b44b24b38425de5a0a
Created September 24, 2019 17:40 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@jetstreamin
jetstreamin / forLoop.bat
Created September 19, 2019 12:04 — forked from jarek-przygodzki/forLoop.bat
Batch script for loop
for /l %x in (1, 1, 100) do <cmd>
# two %s if it's in a batch file
for /l %%x in (1, 1, 100) do <cmd>
# ultiple commands for each iteration
for /l %x in (1, 1, 100) do (
echo %x
copy %x.txt z:\whatever\etc
@jetstreamin
jetstreamin / ExportSchema.ps1
Created August 10, 2019 23:35 — forked from cheynewallace/ExportSchema.ps1
Export MSSQL schema with PowerShell. This script will export your schema definitions for tables, stored procs, triggers, functions and views to .sql files
# Usage: powershell ExportSchema.ps1 "SERVERNAME" "DATABASE" "C:\<YourOutputPath>"
# Start Script
Set-ExecutionPolicy RemoteSigned
# Set-ExecutionPolicy -ExecutionPolicy:Unrestricted -Scope:LocalMachine
function GenerateDBScript([string]$serverName, [string]$dbname, [string]$scriptpath)
{
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null