Skip to content

Instantly share code, notes, and snippets.

View vbjay's full-sized avatar

Jay Asbury vbjay

  • Blue Rhino
  • Winston-Salem, NC
View GitHub Profile
@vbjay
vbjay / EF MetaData Classes
Created August 3, 2016 19:00
Add to ef 6 model.tt to generate metadata class templates
<#
fileManager.StartNewFile(entity.Name & "MetaData" & ".vb")
BeginNamespace(code)
#>
' Copy this class to a partial file to get started on adding metadata to <#=entity.name#> class
<#=codeStringGenerator.EnityClassMetaDataOpening(entity)#>
<#
If simpleProperties.Any() Then
For Each edmProperty As EdmProperty In simpleProperties
#>
@vbjay
vbjay / AttributeExtensions.vb
Last active November 19, 2015 06:38
Get attribute from a MemberInfo or MetadataType class used for the class the MemberInfo is defined in. This is usefull for Entity Framework Model classes and being able to pull out attributes.
Imports System.ComponentModel.DataAnnotations
Imports System.Reflection
Imports System.Runtime.CompilerServices
Module Extensions
<Extension>
Public Function GetAttribute(Of T As Type)(MI As MemberInfo, AttType As T, Optional Inherit As Boolean = True) As Attribute
Dim Attrs As Attribute() = MI.GetCustomAttributes(AttType, Inherit)
@vbjay
vbjay / updaterepos.sh
Created October 12, 2015 05:08
gc and update all git repos located in current folder and subfolders.
#!/bin/bash
function procgit {
git count-objects -vH;
echo
git fetch --all
echo
git gc
git count-objects -vH
echo
@vbjay
vbjay / MVC5 VBDateEditor
Created June 1, 2015 15:13
mvc 5 Date EditorTemplate View
Modeltype Date?
@code Dim dt As Date = Now
If Model.HasValue Then dt = Model
@Html.TextBox("", String.Format("{0:d}", dt.ToShortDateString()), New With {.Value = dt.ToString("yyyy-MM-dd"), .class = "form-control datecontrol datepicker", .Type = "date"})
End code
@vbjay
vbjay / Merging.vb
Created May 12, 2015 02:45
Custom Merging
Imports System.Runtime.CompilerServices
Public Interface IMerge(Of T)
Function Matched() As IEnumerable(Of IMergeMatched(Of T))
Function Matched(predicate As Func(Of T, T, Boolean)) As IEnumerable(Of IMergeMatched(Of T))
Function NotMatchedBySource() As IEnumerable(Of T)
Function NotMatchedBySource(predicate As Func(Of T, Boolean)) As IEnumerable(Of T)
#!/bin/bash
# hosted at https://gist.github.com/Mark-Booth/5058384
# forked from https://gist.github.com/lth2h/4177524 @ ae184f1 by mark.booth
# forked from https://gist.github.com/jehiah/1288596 @ e357c1e by lth2h
# ideas from https://github.com/kortina/bakpak/blob/master/bin/git-branches-vs-origin-master
# this prints out some branch status
# (similar to the '... ahead' info you get from git status)
# example:
@vbjay
vbjay / GitAlias
Last active December 15, 2015 01:59
Git Aliases
[alias]
amend = commit --amend
br = branch
co = checkout
cob = checkout -b
ds = diff --staged
dc = diff --cached
di = diff
dis = diff --stat
cfg = config