Skip to content

Instantly share code, notes, and snippets.

View jpogran's full-sized avatar
📙
Intersection of prose and technology

James Pogran jpogran

📙
Intersection of prose and technology
View GitHub Profile
@jpogran
jpogran / gist:872525
Created March 16, 2011 13:54
aspnet mvc html5 jquery mobile tip
//http://fullsaas.blogspot.com/2011/02/tip-for-aspnet-mvc-3-in-jquery-mobile.html
//entering the following:
@Html.ActionLink("My team", "UsersList", "Home", null,
new { data_theme = "b", data_transition = "fade",
data_icon = "star" })
//#shows
<a data-icon="star" data-theme="b" data-transition="fade"
@jpogran
jpogran / gist:872528
Created March 16, 2011 13:57
aspnet mvc pass enum flag to action as parameter
//http://john.katsiotis.com/blog/asp.net-mvc---passing-a-flag-enum-to-an-action-as-parameter
[Flags]
public enum enDays
{
None = 0,
Monday = 1,
Tuesday = 2,
Wednesday = 4,
Thursday = 8,
@jpogran
jpogran / gist:872536
Created March 16, 2011 14:00
EF 4.1 create database script from metadata
var script = ((IObjectContextAdapter)context).ObjectContext.CreateDatabaseScript();
@jpogran
jpogran / gist:881230
Created March 22, 2011 13:50
friendly name for user in view
def full_name
"#{first_name} #{last_name}".trim
end
def friendly_name
return full_name unless full_name.blank?
email
end
@jpogran
jpogran / gist:887070
Created March 25, 2011 15:53
import svn sub project repo into git and maintain history
//dump repo from svn
svnadmin dump foo > foo_full.dmp
//filter by project
svndumpfilter include --drop-empty-revs --renumber-revs --skip-missing-merge-sources FooBarCom < foo_full.dmp > foo_root_dir.dmp
//edit dmp files using text editor
//(suggest vim to not munge text and automatically convert end-of-line characters to the native format)
//...
//load dmp back into seperate repo
@jpogran
jpogran / gist:942210
Created April 26, 2011 12:56
decimal model binder asp.net mvc
//http://haacked.com/archive/2011/03/19/fixing-binding-to-decimals.aspx
//protected void Application_Start() {
//ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder());
// Your other stuff goes here.
//}
public class DecimalModelBinder : IModelBinder {
public object BindModel(ControllerContext controllerContext,
ModelBindingContext bindingContext) {
@jpogran
jpogran / gist:942222
Created April 26, 2011 13:06
data annotations date format string
[DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
@jpogran
jpogran / gist:944187
Created April 27, 2011 12:46
parse arbitrary text
#parse a newline deliminated document that has an uppercase
#primary 'header' and several lines of secondary 'items'
Function Parse-Document{
param([string]$path)
$text = gc $path
foreach($line in $text){
if(IsUpperCase $line){
#"Primary: $line";
$spec = new-object PSObject -property @{ Primary = $line; Secondary = @() }
[void]$foreach.MoveNext();
@jpogran
jpogran / gist:963091
Created May 9, 2011 18:43
ef code first db creation methods
public static class EFCodeFirstMethods
{
public static void DumpDbCreationScriptToFile(DbContext context)
{
var script = CreateDbScript(context);
// C:\Users\james\code\work\impact\phyweb\src\IRX.Web.UI\
var appDomainPath = AppDomain.CurrentDomain.BaseDirectory;
var scriptPath = GetScriptsDirectory(appDomainPath);
@jpogran
jpogran / gist:1000496
Created May 31, 2011 13:26
ASP.NET MVC Data Validation Field is Good
.input-validation-valid { border: 1px solid green; background-color: #CCFFCC; }