Skip to content

Instantly share code, notes, and snippets.

View yngvebn's full-sized avatar

Yngve Bakken Nilsen yngvebn

View GitHub Profile
private IEnumerable<INamedTypeSymbol> FindMessageHandlersFor(INamedTypeSymbol message, IEnumerable<INamedTypeSymbol> messageHandlers)
{
foreach (INamedTypeSymbol handler in messageHandlers)
{
foreach(var iface in handler.AllInterfaces)
{
foreach(var typeArgument in iface.TypeArguments)
{
if (typeArgument.Equals(message))
{
@yngvebn
yngvebn / gist:7265094
Last active December 27, 2015 04:09
Democode
[RoutePrefix("api")]
public class PeopleController : ApiController
{
private readonly DbContext _context;
public PeopleController(DbContext context)
{
_context = context;
}
@yngvebn
yngvebn / gist:8347809
Created January 10, 2014 06:31
Workaround for invalid Media Query minification (WebGrease and System.Web.Optimization)
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
var siteCssBundle = new StyleBundle("~/css/site").IncludeDirectory("~/public/css", "*.css");
siteCssBundle.Transforms.Clear();
siteCssBundle.Transforms.Add(new CustomCssMinify());
bundles.Add(siteCssBundle);
}
}
// 1. Breaks with minifiers - no-go
angular.module('myModule').controller('HomeCtrl', function($scope){
});
// 2. My preferred method
angular.module('myModule').controller('HomeCtrl', ['$scope', function($scope){
}]);
angular.module('app').controller('HomeCtrl', [function(){
this.name = 'Yngve';
});
// html:
<div ng-controller="HomeCtrl as home">
{{home.name}}
</div>
function MyDirectiveController($scope){
var vm = this;
// bind in GUI
vm.value = $scope.ngModel.value;
}
function MyDirective(){
return {
templateUrl: '/my/template.html',
scope: {
@yngvebn
yngvebn / providers
Last active September 17, 2015 06:42
angular.controller('Test', function(MyProvider, MyService, MyFactory){
// returnerer akkurat det samme:
MyProvider.sayHello();
MyService.sayHello();
MyFactory.sayHello();
MyProvider.saySomethingElse(); // 'I might be a string from some configuration or whatevs'
});
angular.module('app', []);