Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
#BlackLivesMatter

Kyle KyleMit

💭
#BlackLivesMatter
View GitHub Profile
View RebuildDependencies.sql
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 Nov 16, 2014
Conway's Game of Life
View life.rb
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 Aug 29, 2015
Snowflake.svg
View 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 Jan 21, 2015
Validation Attribute for phone numbers that will run on the server and client
View PhoneRegularExpressionAttribute.vb
<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 / CustomLINQtoDataSetMethods.vb
Last active Aug 29, 2015
How to: Implement CopyToDataTable<T> Where the Generic Type T Is Not a DataRow
View CustomLINQtoDataSetMethods.vb
Imports System
Imports System.Data
Imports System.Runtime.CompilerServices
Imports System.Reflection
Imports System.Collections.Generic
''' <summary>
''' How to: Implement CopyToDataTable<T> Where the Generic Type T Is Not a DataRow
''' </summary>
''' <remarks>
@KyleMit
KyleMit / TestT4.cs.t4
Created Jan 25, 2018
Used to help debug input and output for T4 templates and expose values in ModelMetatdata
View TestT4.cs.t4
<#@ 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 Dec 2, 2018
JavaScript Samples with Arrays & Functions
View arraysamples.js
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 / CodeBlocks.md
Last active Dec 31, 2018
Code Blocks & Syntax Highlighting
View CodeBlocks.md
@KyleMit
KyleMit / .bashrc
Created Jan 14, 2019
Custom Bash Prompt
View .bashrc
# 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
View GitLog.md

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'
You can’t perform that action at this time.