Skip to content

Instantly share code, notes, and snippets.

View KyleMit's full-sized avatar

Kyle Mitofsky KyleMit

View GitHub Profile
DECLARE @str NVARCHAR(MAX) SELECT @str = N''
SELECT @str = @str + 'exec sp_refreshsqlmodule '''
+ SCHEMA_NAME([schema_id]) + '.' + OBJECT_NAME([object_id])
+ '''' + CHAR(13) + CHAR(10)
FROM sys.objects o
WHERE [type] IN ('FN', 'IF', 'P', 'TF', 'V')
AND is_ms_shipped = 0
AND NOT EXISTS (SELECT 1 FROM sys.sql_modules m
WHERE m.[object_id] = o.[object_id]
@KyleMit
KyleMit / life.rb
Created November 16, 2014 09:52
Conway's Game of Life
module Life
def self.next_grid live_cells_in_grid
new_grid = Set.new
potential_cells(live_cells_in_grid).each do |cell|
alive = live_cells_in_grid.include?(cell)
neighbors = live_neighbors_count(live_cells_in_grid, cell)
if next_state_alive(alive, neighbors)
new_grid << cell
end
@KyleMit
KyleMit / Snowflake.svg
Last active August 29, 2015 14:11
Snowflake.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@KyleMit
KyleMit / PhoneRegularExpressionAttribute.vb
Created January 21, 2015 01:43
Validation Attribute for phone numbers that will run on the server and client
<AttributeUsage(AttributeTargets.Field Or AttributeTargets.Property, AllowMultiple:=False)>
Public Class PhoneAttribute : Inherits RegularExpressionAttribute
Private Const _pattern As String = "^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$"
Private Const _msg As String = "Format for {0} must be (888)-888-8888."
Public Sub New()
MyBase.New(_pattern)
Me.ErrorMessage = _msg
DataAnnotationsModelValidatorProvider.RegisterAdapter(
@KyleMit
KyleMit / TestT4.cs.t4
Created January 25, 2018 03:29
Used to help debug input and output for T4 templates and expose values in ModelMetatdata
<#@ template language="C#" HostSpecific="True" #>
<#@ output extension=".txt" #>
<#@ include file="Imports.include.t4" #>
<#@ include file="ModelMetadataFunctions.cs.include.t4" #>
T4 Info Dump
ViewName: <#= ViewName #>
ViewDataTypeName: <#= ViewDataTypeName #>
IsPartialView: <#= IsPartialView #>
IsLayoutPageSelected: <#= IsLayoutPageSelected #>
@KyleMit
KyleMit / arraysamples.js
Created December 2, 2018 20:41
JavaScript Samples with Arrays & Functions
var consoleHeader = "color: rebeccapurple; font-size: large";
console.header = function(text) {console.log(`%c${text}`,consoleHeader)}
console.header("Array of Objects");
// delcare array of objects
var links = [
{ title: "first item", address: "/project"},
@KyleMit
KyleMit / .bashrc
Created January 14, 2019 00:30
Custom Bash Prompt
# PS1 special characters
UserName="\u" # the username of the current user
HostShort="\h" # the hostname up to the first `.'
WorkingDirectory="\w" # the current working directory
HostFull="\H" # the hostname
JobCount="\j" # the number of jobs currently managed by the shell
DeviceName="\l" # the basename of the shell's terminal device name
NewLine="\n" # newline
Return="\r" # carriage return
@KyleMit
KyleMit / GitLog.md
Created January 28, 2019 14:09
Fun Git Logs

Color Formatted:

$ git log --no-merges --shortstat --author="Kyle Mitofsky" --date=format:'%m/%d %I:%M %p' --pretty="@%C(yellow)%h %C(green)%cn %C(cyan)%cd %C(reset)- %<(50,trunc)%s"

One Line:

$ git log --no-merges --shortstat --author="Kyle Mitofsky" --date=format:'%m/%d %I:%M %p' --pretty="@%C(yellow)%h %C(green)%cn %C(cyan)%cd %C(reset)- %<(50,trunc)%s" | tr "\n" " "  |  tr "@" "\n" |  sed -r 's/ insertions?| deletions?|[0-9]* files? changed,//g'
@KyleMit
KyleMit / Array without IndexOf.js
Last active April 6, 2019 02:37
String Characters - Group & Count
var myString = "aaAbbcdeffff".toUpperCase()
// potential bucket for one of every letter
var letters = [] // ex. ["a", "b", "c", "d"]
var counts = [] // ex. [3, 2, 1, 1]
// loop through every letter in string
for (i=0; i < myString.length; i++) {
var char = myString[i]
@KyleMit
KyleMit / GitPair.md
Last active June 13, 2019 17:09
Git Pair Alias

Git Pair Alias

Pair Programming is great - here's a way to make it greater with easy way to toggle on mutliple attribution for each a commit.

Add this alias to your global .gitconfig file (git config --global --edit)

[alias]
    pair = "!f() {                                                           \
                local name=$1;                                               \