Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View stormwild's full-sized avatar
🏠
Working from home

Alexander R Torrijos stormwild

🏠
Working from home
View GitHub Profile
@stormwild
stormwild / Controller.cs
Created December 10, 2011 11:45
To get a list of errors in the model state
[HttpPost]
public ActionResult Edit(ViewModel viewModel)
{
if (ModelState.IsValid)
{
repository.SaveModel(viewModel);
TempData["message"] = "Changes have been saved";
return RedirectToAction("Index");
}
else
@stormwild
stormwild / dabblet.css
Created February 23, 2012 06:41
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height:100%;
font-family: Arial, Helvetica, san-serif;
@model MyAppDomain.Entities.Role
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<?php
namespace Album;
use Album\Model\AlbumTable;
class Module
{
public function getAutoloaderConfig()
{
return array (
@stormwild
stormwild / script.js
Created December 8, 2012 02:50
Immediately-Invoked Function Expression (IIFE) / (jQuery Self Executing Closure Pattern) and other useful javascript snippets
// “self-executing anonymous function” (or self-invoked anonymous function)
// Reference: http://stackoverflow.com/questions/188663/jquery-javascript-design-self-executing-function-or-object-literal
;(function($) {
var myPrivateFunction = function() {
};
var init = function() {
var app;
app = (function(){
var myPrivateVariable = "my private content";
var application = {
init: function(){
console.log(myPrivateVariable);
},
var app = app || {};
//object literal
app = {
init: function(){
this.cache();
this.bind();
},
cache: function(){
this.anchor = $( 'a' );
http://www.impressivewebs.com/my-current-javascript-design-pattern/#comment-32835
(function ($, App, window) {
'use strict';
var ready = false,
handler = function (e) {
},
init = function (page) {
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
/**
 *@namesomeFunction
 *@authorkfb
 *
 *Basicusage:
 * var someFunction = new SomeFunction();
 * someFunction.init();
 *
 * additionally you can use methods like someFunction.methodName();