Skip to content

Instantly share code, notes, and snippets.

@pensacola1989
pensacola1989 / authentication.ts
Created March 27, 2017 02:55 — forked from btroncone/authentication.ts
Angular 2 application role access decorator, wrapping built in CanAccess functionality. Prevents view transitions when user roles are not appropriate.
import { Injectable } from 'angular2/core';
import { Storage } from './storage';
import { CurrentUser } from '../interfaces/common';
@Injectable()
export class Authentication{
private _storageService : Storage;
private _userKey : string = "CURRENT_USER";
constructor(storageService : Storage){
@pensacola1989
pensacola1989 / gist:1654b73c81604b35ac0960b7cede5b6f
Created March 24, 2017 06:21 — forked from bgrins/gist:1789787
C# Multipart File Upload
// Implements multipart/form-data POST in C# http://www.ietf.org/rfc/rfc2388.txt
// http://www.briangrinstead.com/blog/multipart-form-post-in-c
public static class FormUpload
{
private static readonly Encoding encoding = Encoding.UTF8;
public static HttpWebResponse MultipartFormDataPost(string postUrl, string userAgent, Dictionary<string, object> postParameters)
{
string formDataBoundary = String.Format("----------{0:N}", Guid.NewGuid());
string contentType = "multipart/form-data; boundary=" + formDataBoundary;
@pensacola1989
pensacola1989 / class_decorator.ts
Created December 13, 2016 07:12 — forked from remojansen/class_decorator.ts
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
// Waveファイル 読み込みと書き込み
// 16bit形式のみ対応
// 読み込んだデータはList<short>に格納されます
using System;
using System.Collections.Generic;
using System.IO;
namespace ConsoleApplication1
{
class Program
namespace Audio
{
using System;
using System.IO;
/// <summary>
/// Provides methods for saving byte arrays of audio samples to a wav file in mono or stereo.
/// </summary>
public static class WaveSaver
{
namespace Audio
{
using System;
using System.IO;
/// <summary>
/// Provides methods for saving byte arrays of audio samples to a wav file in mono or stereo.
/// </summary>
public static class WaveSaver
{
using Microsoft.Phone.Controls;
using System;
using System.Windows.Controls.Primitives;
/// <summary>
/// This class detects the pull gesture on a LongListSelector. How does it work?
///
/// This class listens to the change of manipulation state of the LLS, to the MouseMove event
/// (in WP, this event is triggered when the user moves the finger through the screen)
/// and to the ItemRealized/Unrealized events.

There's no shortage of good resources for learning laravel. So instead of the usual introductory tutorial were just gonna learn Laravel by building a project from scratch and that's gonna be a User Management System.

I don't know if my definition of a User Management System is correct but here's my idea of what's it's capable of doing:

  • Register Roles
  • Register Users
  • Update Users
// Overriding Backbone.sync to either load locally or from the server
sync: function(method, model, options) {
// Pull the key and stored object localStorage
var storageKey = localStorage.getItem('storage');
var storageData = localStorage.getItem('storage-' + storageKey);
// Apply the callback with our local data
if(storageData) {
options.success(JSON.parse(storageData));
@pensacola1989
pensacola1989 / vm_property_logic.cs
Created November 23, 2012 07:29 — forked from waynebaby/vm_property_logic.cs
MVVMSideKick 用Rx来配置属性之间的关系
namespace TableGameSidekick_Metro.Games.DefaultTradeGame.Models
{
[DataContract]
public class ResourceConfig : BindableBase<ResourceConfig>
{
// If you have install the code sniplets, use "propvm + [tab] +[tab]" create a property。
// 如果您已经安装了 MVVMSidekick 代码片段,请用 propvm +tab +tab 输入属性
public ResourceConfig(int players)