Skip to content

Instantly share code, notes, and snippets.

@oneillci
oneillci / gist:3205384
Created July 30, 2012 06:45
Using EF Include() with generic repository
public IQueryable<T> FindBy(Expression<Func<T, bool>> predicate, params Expression<Func<T, object>>[] includes)
{
var query = GetAll().Where(predicate);
return includes.Aggregate(query, (current, includeProperty) => current.Include(includeProperty));
}
// Sample usage
userRepository.FindBy(x => x.Username == username, x.Roles)
@oneillci
oneillci / gist:de56e16011dbb736697e
Created January 19, 2015 05:49
Powershell command to count lines of code (terrible metric, but anyway....)
(dir -include *.cs,*.xaml -recurse | select-string .).Count
module Functional_Kats_Kata =
type PatternType =
| Asterisk
| Question
| None
let findPattern (input:string) (pattern:string) patternType =
match patternType with
| Asterisk ->
@oneillci
oneillci / app.html
Last active March 15, 2016 12:11
ie enhance problem
<template>
<require from='./grid-view'></require>
Aurelia app ${message}
<!--<click-to-edit display-value="some display value">
<template replace-part='content-template'>
<input type='text' value='yoyo' />
</template>
</click-to-edit>-->
@oneillci
oneillci / app.html
Created March 16, 2016 13:49 — forked from opcodewriter/app.html
Aurelia If Bind test on template part
<template>
<require from="./click-to-edit"></require>
<click-to-edit>
<template replace-part='item-template'>
This text node is in DOM only after click
</template>
</click-to-edit>
</template>
@oneillci
oneillci / app.html
Created August 25, 2016 22:52
DI inheritance
<template>
<h1>${message}</h1>
</template>
const curry = (fun, arg) => (...args) => fun(...[arg, ...args]);
@oneillci
oneillci / TreeViewCustomAttribute.ts
Created March 22, 2017 21:13 — forked from seesharper/TreeViewCustomAttribute.ts
An Aurelia TreeView Custom Attribute Wrapper
import {inject, customAttribute, bindable} from 'aurelia-framework';
import 'jquery';
import 'npm:bootstrap-treeview@1.2.0/dist/bootstrap-treeview.min.js';
import {Test} from './treenode';
@customAttribute('treeview')
@inject(Element)
export class TreeViewCustomAttribute {
element: Element;
type Shape =
{ kind: "circle", radius: number} |
{ kind: "rectangle", w: number, h: number} |
{ kind: "square", size: number}
function assertNever(obj: never) {
throw new Error("unexpected object");
}
function getArea(shape: Shape) {
@oneillci
oneillci / gist:99cd063e4c2df8ebd635fdb3f903ba4c
Last active February 22, 2018 03:27
Powershell find in files, count of lines in files
Get-ChildItem -Recurse -Include *.* | Select-String "column-flex-container"
// Get could of lines in files of type
(dir -include *.scss -recurse | select-string .).Count
or
Get-ChildItem -Filter "*.cs" -Recurse | Get-Content | Measure-Object -line
// Get count of files of type
(dir -include *.ts -recurse).Count
or