Skip to content

Instantly share code, notes, and snippets.

View JeremySkinner's full-sized avatar

Jeremy Skinner JeremySkinner

View GitHub Profile
<%= Html.ScriptInclude("foo") %>
<% if(false) { %>
<script type="text/javascript" src="/path/to/foo.js"></script>
<% } %>
public class Customer {
public int Id { get; set; } //assumes public property named "Id" is PK
public string Name { get; set; } //all public read/write properties auto-mapped to db cols
}
//config:
ActiveRecordConfiguration.Configure(cfg => {
cfg.ConnectToSqlServer("(local)", "mydb", "user", "pass");
cfg.MapTypesFromAssemblyContaining<Customer>();
//lots of other options...
//Using autofac
[Test]
public void Creates_dependencies() {
var builder = new ContainerBuilder();
builder.RegisterModule(new AppModule());
var container = builder.Build();
var types = from type in typeof(HomeController).Assembly.GetExportedTypes()
where typeof(Controller).IsAssignableFrom(type) && !type.IsAbstract
select type;
//Yuck...
IEnumerable<Func<object, object>> funcs = GetFuncs();
var convertedFuncs = funcs.Select(func => new Func<T, object>(x => func(x))).ToList();
Clone as normal...
git clone git://...url...
Create and check out a local branch that tracks the remote branch
git checkout -b <branch name> --track origin/<remote branch name>
Pull changes into the branch:
git pull origin <remote name>
var cfg = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005
.ProxyFactoryFactory(typeof(ProxyFactoryFactory).AssemblyQualifiedName)
.ConnectionString(conn => conn.FromConnectionStringWithKey("Web"))
).BuildConfiguration();
with FileList():
.Include("src/Phantom/bin/${configuration}/*.{dll,exe}")
.Include("License.html")
.ForEach def(file):
file.CopyToDir("build/${configuration}")
target copyFiles:
FileList.Create def(fl):
fl.Include("src/Phantom/bin/${configuration}/*.{dll,exe}")
fl.Include("License.html")
fl.ForEach def(file):
file.CopyTo("build")
var handlerInterface = typeof(MyHandler).GetInterfaces()[0]; //This implements IHandle<T> (eg IHandle<Foo>)
var commandType = handlerInterface.GetGenericArguments()[0]; //this is the type being handled, eg Foo
var maker = GetType().GetMethod("ResolveHandler", BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance);
var compiledDelegate = (Func<object>)Delegate.CreateDelegate(typeof(Func<object>), maker);
<script type="text/javascript">
var person = { Name: "Jeremy", Id: 1 };
</script>
<input type="text" sys:value="{binding path=Name, source={{person}} }" />