Skip to content

Instantly share code, notes, and snippets.

View code-for-coffee's full-sized avatar

James code-for-coffee

  • Chicago, IL
View GitHub Profile
@code-for-coffee
code-for-coffee / bindingJSON
Last active July 18, 2018 08:22
ASP.NET MVC: Intro to MVC Binding JSON objects to Models
ASP.NET MVC: Intro to MVC using Binding JSON objects to Models
This post is designed to assist in jump-starting your MVC (model-view-control) project binding JSON to models (using Ajax posts). I feel that this is a vital skill to any journeyman ASP.NET MVC developer. Before we start note that all examples using Xamarin (Mono 3.2.0) - this should be opened in Visual Studio 2010+.
If you're new to MVC, here is a brief explanation. This design pattern is designed to keep your code into specific parts dedicated for specific usage. Models are designed to represent your data objects. The controller works with/manipulates models (backend, server side code). It then generates a View (rendered HTML) that is presented to the user on their web browser. The Model and Controller are written in C# for this project. The View is rendered in pure HTML with Javascript.
Create a new MVC project and call it "bindingJSON" (using the standard, no authentication). Now, inspect the object you need to model. Using an object orien
@code-for-coffee
code-for-coffee / karma_install.bat
Created April 23, 2014 18:55
Karma installation on windows
npm install -g karma
npm install -g karma-cli
@code-for-coffee
code-for-coffee / gist:3adf9f6ef3d9b1df37df
Last active August 29, 2015 14:04
Border-radius sample for Chris
<html lang="en">
<head>
<!-- in Stylesheets, a class can be prefixed with a "." and an ID with a "#" -->
<style type="text/css">
/* assign the entire HTML body an ID of "home" */
#home {
font-weight: bold;
font-color: black;
}
/* you only need to worry about this "class" */
@code-for-coffee
code-for-coffee / gist:44c8b6f756a56cc3e1bf
Created July 27, 2014 03:20
brief-intro-to-modern-html-and-css
/**
* A brief intro to Modern HTML and CSS
*/
<table></table>'s have been replaced by <div></div>'s for body layout. This allows for more flexibility in modern browser
rendering engines (and uses less memory to compute positioning). Tables are now used for data output
(such as charts, grids, raw data, etc).
To style these divs and give them a meaning, there are a variety of HTML styles that can be applied.
These are traditionally stored in an external stylesheet inside of the <head></head> HTML tags, ie:
@code-for-coffee
code-for-coffee / ch2-1.js
Last active August 29, 2015 14:12
Backbone Enterprise Book Ch2.1
/* Create namespace objects for each Backbone object type */
App = new Object() || {};
App.Models = new Object() || {};
App.Views = new Object() || {};
App.Routers = new Object() || {};
App.Collections = new Object() || {};
@code-for-coffee
code-for-coffee / ch2-2.js
Last active August 29, 2015 14:12
Backbone Enterprise Book Ch2.2
/* use namespace for storage */
App.Models.BaseModel = Backbone.Model.extend({
defaults: {
id: 1,
name: "BaseModel"
}
});
App.Views.BaseView = Backbone.View.extend({
el: undefined,
model: undefined
@code-for-coffee
code-for-coffee / ch2-3.js
Created December 25, 2014 22:05
Backbone Enterprise Book - Ch2.3
/* use namespace for storage */
var myModel = new App.Models.BaseModel({
comment: "Test!"
});
var myView = new App.Views.BaseView({
el: $('body'),
model: myModel
});
@code-for-coffee
code-for-coffee / ch2-4.js
Created December 25, 2014 22:08
Backbone Enterprise Book - Ch2.4
/* Create namespace objects for each Backbone object type */
App = new Object() || {};
App.Models = new Object() || {};
App.Views = new Object() || {};
App.Routers = new Object() || {};
App.Collections = new Object() || {};
App.ActiveModels = new Object() || {};
App.ActiveViews = new Object() || {};
App.ActiveRouters = new Object() || {};
App.ActiveCollections = new Object() || {};
@code-for-coffee
code-for-coffee / ch3-1.js
Last active August 29, 2015 14:14
Backbone Enterprise Practices Ch3 #1
App = new Object() || {};
App.Models = new Object() || {};
App.Collections = new Object() || {};
App.Views = new Object() || {};
App.Models.TableRow = Backbone.Model.extend({
});
@code-for-coffee
code-for-coffee / ch3-table-view.hbs
Created February 4, 2015 05:51
Backbone Best Practices - Ch3 Table View
{{!-- view-table-template --}}
<div class="table-responsive">
<table class="table">
<thead>
{{#each column}}
{{this}}
{{/each}}
</thead>
<tbody id="{{tbody-id}}" class="{{tbody-class}}">
{{!-- filled by view-table-row-template --}}