Skip to content

Instantly share code, notes, and snippets.

@saintc0d3r
saintc0d3r / productsSpec.js
Created September 4, 2013 05:18
[Node.js][Jasmine] A sample of a BDD Spec in Node.js using Jasmine-node
var urlRouter = require('./../../infrastructures/url-router.js');
var resourceLocator = require('./../../infrastructures/resource-locator.js');
require('./../../resources/resources-registrar.js');
var specInitialiser = require('./../spec-initialiser.js');
describe('Products Resource', function(){
var timeOutCall = 200;
var resolveResource = function(requestUrl, requestMethod){
var resolvedRequest = urlRouter.first(requestUrl, requestMethod);
expect(resolvedRequest).not.toBe(false);
@saintc0d3r
saintc0d3r / DependencyResolver.cs
Created October 10, 2013 13:01
[Ninject][ASP NET Web API] A demonstration of Dependency injection on ASP NET Web API's controller using Ninject & Dependency Resolver.
using System.Web.Http.Dependencies;
namespace Xtremecode.Infrastructure.Library.Di
{
public class DependencyResolver : DependencyScope, IDependencyResolver
{
public DependencyResolver() : base(DependencyInjector.GetKernel()) { }
public IDependencyScope BeginScope()
{
@saintc0d3r
saintc0d3r / Application.js
Last active December 25, 2015 12:19
[Ext.js][ASP NET MVC] Simple SPA using Ext.js & ASP .NET MVC
Ext.application({
appFolder: '/Extjs/Application',
controllers: ['HomeController'],
name: AppNamespace,
launch: function() {
Ext.create('Ext.container.Viewport', {
layout: 'fit',
items: [{
xtype: 'specialOffers'
@saintc0d3r
saintc0d3r / index.cshtml
Last active December 27, 2015 08:59
[HTML5][Jquery][ASP NET MVC] Create uploaded Image's Preview using HTML5 & JQuery on ASP NET MVC's Razor page.
@model SomeModel
@using (Html.BeginForm("Submit", "Home", FormMethod.Post, new { enctype ="multipart/form-data" }))
{
@Html.EditorForModel()
<label for="ImagePreview">Image Preview</label>
<p>
<output id="image-box"></output>
</p>
@saintc0d3r
saintc0d3r / ServiceConfiguration.Cloud.cscfg
Last active December 27, 2015 10:39
[Windows Azure] Creating a CloudStorageAccount instance from cloud configuration
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="DemoApp" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="3" osVersion="*" schemaVersion="2013-03.2.0">
<Role name="DemoApp_WebRole">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
<!-- The new config setting -->
<Setting name="DataConnectionString" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
</Role>
@saintc0d3r
saintc0d3r / HomeController.cs
Created November 6, 2013 21:12
[ASP .NET MVC] Maintain ModelState errors using ActionFilterAttributes when applying Post-Redirect-Get pattern.
using System;
using System.Diagnostics;
using System.IO;
using System.Web;
using System.Web.Mvc;
using DemoApp.Models;
using Infrastructure.WebMvc;
namespace DemoApp.Controllers
@saintc0d3r
saintc0d3r / App.config
Created November 16, 2013 14:34
[C#][AWS][SimpleDb][MsTest] A sample of AWS SimpeDb's Domain Repository.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="AWSAccessKey" value="AAOipiapsoif23oi34lk6"/>
<add key="AWSSecretKey" value="LKKUkjjkLIupoiYuhTYiuGyg"/>
<add key="AWSRegion" value="ap-southeast-1" />
</appSettings>
</configuration>
@saintc0d3r
saintc0d3r / GuestBookImageRepository.cs
Created November 17, 2013 05:11
[C#][AWS][S3][MsTest] A sample of AWS S3's File Repository.
using System;
using System.IO;
using Amazon.S3.Model;
using Amazon.S3.Transfer;
namespace GuestBook.Repository.Aws.S3
{
class GuestBookImageRepository : S3RepositoryBase, IGuestBookImageRepository
{
@saintc0d3r
saintc0d3r / HomeController.js
Last active August 29, 2015 14:01
HomeController.js
/**
* HomeController
*
* @module :: Controller
* @description :: A set of functions called `actions`.
*
* Actions contain code telling Sails how to respond to a certain type of request.
* (i.e. do stuff, then send some JSON, show an HTML page, or redirect to another URL)
*
* You can configure the blueprint URLs which trigger these actions (`config/controllers.js`)
@saintc0d3r
saintc0d3r / routes.js
Created May 27, 2014 04:53
config/routes.js
module.exports.routes = {
// By default, your root route (aka home page) points to a view
// located at `views/home/index.ejs`
//
// (This would also work if you had a file at: `/views/home.ejs`)
'/': {
controller: 'HomeController',
action: 'hello_world'
}