Skip to content

Instantly share code, notes, and snippets.

View happygrizzly's full-sized avatar
🐻

Aleksey Filippov happygrizzly

🐻
View GitHub Profile
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",
@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'>
@happygrizzly
happygrizzly / MAMP Silex htaccess
Created February 3, 2016 13:56 — forked from crzapata/MAMP Silex htaccess
htaccess definition for silex when using MAMP
<IfModule mod_rewrite.c>
RewriteEngine on
#uncomment next line if silex app root is in a mamp subdirectory
#RewriteBase /your_mamp_htdocs_silex_app_root
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ web/index.php [L]
</IfModule>
define your silex routes as follows:
$app->get('/your_mamp_htdocs_silex_app_root/', function() {
@happygrizzly
happygrizzly / JsonMessageFormatter.cs
Created February 11, 2016 08:14 — forked from jchadwick/JsonMessageFormatter.cs
MSMQ Message JSON Formatter
using System;
using System.IO;
using System.Messaging;
using System.Text;
using Newtonsoft.Json;
public class JsonMessageFormatter : IMessageFormatter
{
private static readonly JsonSerializerSettings DefaultSerializerSettings =
new JsonSerializerSettings {
@happygrizzly
happygrizzly / generate.php
Created September 27, 2016 12:32 — forked from jreinke/generate.php
Default password encoding in Silex micro-framework
<?php
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
$encoder = new MessageDigestPasswordEncoder();
echo $encoder->encodePassword('foo', '');
// 5FZ2Z8QIkA7UTZ4BYkoC+GsReLf569mSKDsfods6LYQ8t+a8EW9oaircfMpmaLbPBh4FOBiiFyLfuZmTSUwzZg==