Skip to content

Instantly share code, notes, and snippets.

View happygrizzly's full-sized avatar
🐻

Aleksey Filippov happygrizzly

🐻
View GitHub Profile
protected override void Seed(AppDbContext context) {
// define roles
var role = new Role("SimpleUser");
var roleAdvanced = new Role("AdvancedUser");
// define activities
var readActivity = new Activity("Read");
var updateActivity = new Activity("Update");
var deleteActivity = new Activity("Delete");
var manageActivity = new Activity("Manage");
public class RoleResourceActivity {
public Int32 ResourceId { get; set; }
public virtual Resource Resource { get; set; }
public Int32 ActivityId { get; set; }
public virtual Activity Activity { get; set; }
public Int32 RoleId { get; set; }
public Role Role { get; set; }
}
// User-Role relationship cardinality is many to many:
using System;
using System.Threading.Tasks;
namespace Life
{
public class LifeSimulation
{
private bool[,] world;
private bool[,] nextGeneration;
private Task processTask;

Owin Authentication with Web API 2

Using Microsoft.Owin.Security along with .NET Web API 2 for authentication on Single Page Applications.

My example is split up into 2 different projects, API which is WebAPI2 project and MyProj which is a basic MVC that contains primarily only JavaScript/CSS/etc and the startup classes.

API > AccountController.cs

namespace API

{

@happygrizzly
happygrizzly / gist:ba6d197ee096a1e0f6b5
Last active September 2, 2015 08:04 — forked from alexbeletsky/gist:1325577
ASP.NET MVC2 Views web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<!--
Enabling request validation in view pages would cause validation to occur
@happygrizzly
happygrizzly / ng-prism.js
Last active September 11, 2015 06:21 — forked from mikomatic/ng-prism.js
Angularjs directive with prism code highlight
/**
* Usage
*
* <ng-prism class="language-css">
* body {
* color: red;
* }
* </ng-prism>
*
* the files prismjs and prism css must be included in HTML, use class "language-XXX" to specify language
@happygrizzly
happygrizzly / UtilityController.php
Last active September 11, 2015 06:43 — forked from jchaney01/UtilityController.php
Angular.js Uploadify Directive with Image Editor and Laravel Backend
class UtilityController extends BaseController {
public function upload()
{
$file = Input::file('Filedata');
$name = Date("now").'-'.$file->getClientOriginalName();
$uploadSuccess = $file->move(public_path().'/uploads',$name);
if( $uploadSuccess ) {
return Response::json(array(
"status"=>"200",
namespace your_project_name
{
using System.Threading;
public abstract class PollerServiceBase : System.ServiceProcess.ServiceBase {
protected Thread workerThread = null;
protected AutoResetEvent finishedEvent = new AutoResetEvent(false);
public PollerServiceBase(string serviceName) {
@happygrizzly
happygrizzly / CoffeeCompiler.cs
Created December 22, 2015 10:03 — forked from Crisfole/CoffeeCompiler.cs
CoffeeScript and Less
using System;
using System.Collections.Generic;
using System.IO;
using MsieJavaScriptEngine;
public class CoffeeScriptCompiler : ContentCompiler {
public CoffeeScriptCompiler() {
Javascript.Engine.RegisterCompiler("CoffeeScript", LoadCoffeeScript, MakeCompiler);
}
@happygrizzly
happygrizzly / meta-tags.md
Created December 24, 2015 06:54 — forked from kevinSuttle/meta-tags.md
List of Usable HTML Meta and Link Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>