Skip to content

Instantly share code, notes, and snippets.

View Grinderofl's full-sized avatar

Nero Sule Grinderofl

View GitHub Profile
@Grinderofl
Grinderofl / gist:1004387
Created June 2, 2011 13:08
PHP CakePHP: Testing Gist
<?php
class AppController extends Controller {
var $components = array('Auth', 'Session');
var $helpers = array('Html', 'Javascript', 'Form', 'Session');
function beforeFilter() {
parent::beforeFilter();
$this->Auth->loginRedirect = array(
@Grinderofl
Grinderofl / json_source.php
Created October 27, 2011 09:08
PHP CakePHP: JSON DataSource
<?php
// CORE/app/models/datasources/json_source.php
/**
* JSON Source module for CakePHP.
*
* @package cake
*/
@Grinderofl
Grinderofl / RandomStringGenerator.cs
Created October 27, 2011 09:09
C# .NET: Random String Generator
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RandomStringGenerator.cs" company="">
// Nero Sule
// </copyright>
// <summary>
// Class for random string generation. Does not include ambiguous characters like
// I, 1 and l.
// Every four characters include one lower case character, one upper case character,
// one number and a special symbol in a random order. String will start with
// an alphanumeric character.
@Grinderofl
Grinderofl / gist:1319117
Created October 27, 2011 09:10
Recursion Limiter
public static object Limit(object o, int level)
{
if (level <= 0)
return null;
PropertyInfo[] properties = o.GetType().GetProperties();
foreach (var property in properties)
{
if (property.PropertyType.IsClass && property.CanWrite && property.PropertyType is IEnumerable)
@Grinderofl
Grinderofl / Security.cs
Created October 27, 2011 09:12
C# .NET: Security functions
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Security.cs" company="">
//
// </copyright>
// <summary>
// Class to manage security functions, such as Base64 encode/decode, SHA encryption, etc.
// Requires the Random String Generator class.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
@Grinderofl
Grinderofl / AllowAnonymousAttribute.cs
Created October 27, 2011 09:13
C# .NET: Allow Anonymous Attribute
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AllowAnonymousAttribute.cs" company="">
// Nero Sule
// </copyright>
// <summary>
// Extra attribute to allow making all methods apart from those tagged "AllowAnonymous" to be requiring authorization
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Web.Filters
@Grinderofl
Grinderofl / LogonAuthorize.cs
Created October 27, 2011 09:15
C# .NET: Logon Authorization Enforcer when no AllowAnonymousAttribute is defined.
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="LogonAuthorize.cs" company="">
// Nero Sule
// </copyright>
// <summary>
// Class to enforce authorization on everything that isn't declared with AllowAnonymous Attribute.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Web.Filters
@Grinderofl
Grinderofl / HtmlHelpers.cs
Created October 27, 2011 09:18
C# .NET: ActionLink Helpers for MVC3
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="HtmlHelpers.cs" company="">
// Nero Sule
// </copyright>
// <summary>
// HTML Helpers
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Web.HtmlHelpers
@Grinderofl
Grinderofl / MultiViewController.cs
Created October 27, 2011 09:20
C# .NET: MultiViewController for MVC3
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MultiViewController.cs" company="">
// Nero Sule
// </copyright>
// <summary>
// Defines the MultiViewController type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Web.Infrastructure
@Grinderofl
Grinderofl / NinjectDependencyResolver.cs
Created October 27, 2011 09:22
C# .NET: Ninject Dependency Resolver
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="NinjectDependencyResolver.cs" company="">
// Nero Sule
// </copyright>
// <summary>
// Dependency Injection
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Web.Infrastructure