This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// includes bindings for fetching/fetched | |
var PaginatedCollection = Backbone.Collection.extend({ | |
initialize: function() { | |
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage', 'filtrate', 'sort_by'); | |
typeof(options) != 'undefined' || (options = {}); | |
typeof(this.limit) != 'undefined' || (this.limit = 20); | |
typeof(this.offset) != 'undefined' || (this.offset = 0); | |
typeof(this.filter_options) != 'undefined' || (this.filter_options = {}); | |
typeof(this.sort_field) != 'undefined' || (this.sort_field = ''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@section scripts { | |
<script> | |
var app = window.app = {}; | |
app.userTypes = @Html.Raw(Json.Encode(Model.GetUserTypes())); | |
</script> | |
<script src="~/Scripts/angular.min.js"></script> | |
<script src="~/Scripts/angular-resource.min.js"></script> | |
<script src="~/Scripts/underscore.min.js"></script> | |
<script src="~/Scripts/angular/main.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original idea: http://stackoverflow.com/questions/9565889/get-the-ip-address-of-the-remote-host | |
using System.Net.Http; | |
using System.ServiceModel.Channels; | |
using System.Web; | |
namespace CrowSoftware.Api | |
{ | |
public static class HttpRequestMessageHelper | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Dennis Rongo | |
# Date: 03.12.2013 | |
# Description: Thie script converts a Markdown (*.md) file to HTML within the same directory. | |
# This requires Pandoc (http://johnmacfarlane.net/pandoc/) to do the conversion. | |
import sys | |
import getopt | |
import subprocess | |
def process(arg): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Global override to make all AJAX calls as POST type */ | |
Backbone.ajax = function() { | |
var args = Array.prototype.slice.call(arguments, 0); | |
return Backbone.$.ajax.apply(Backbone.$, _.extend(args, {type: 'POST'})); | |
}; | |
/** Manual override per call */ | |
Collection.fetch({data: {id: 34}, type: 'POST'}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var President = Backbone.Model.extend({}); | |
var m = new President({first: 'Abraham', last: 'Lincoln', age: 90, registered: true}); | |
m.set({first: null}); | |
/** Loop through each property and unset if invalid. Also check if property if boolean type. */ | |
_.each(m.toJSON(), function(val, col){ | |
if (typeof val !=='boolean' && !val) { | |
m.unset(col); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Author: Dennis Rongo | |
Description: This demonstrates the jQuery deferred object and used when running asynchronous operations (non-AJAX) functions. | |
Each function returns a 'promise' object that notifies the subscriber when the operation has completed. | |
*/ | |
$(function(){ | |
/** Create a long operation */ | |
var loadQueue = function() { | |
var dfrQueue = new $.Deferred(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$('[id^="post-"]').click( | |
function() { | |
var self = $(this); | |
/** Toggle all posts except for the current one. */ | |
$('.post_content').not(self.find('.post_content')).hide(); | |
$('.image-box').not(self.find('.image-box')).show('slow', function(){}); | |
$('.post_excerpt').not(self.find('.post_excerpt')).show(500, function(){}); | |
/** Show full post but hide excerpt UI elements. */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Extends Handlebars with a basic get method for loading external | |
* Handlebars templates. Simply pass an options object which contains | |
* the following properties: | |
* - path (required) : Path to the external template file to be loaded | |
* - success (required) : Callback invoked with the compiled loaded template. | |
* - cache (optional) : true if the template is to be cached, otherwise false. | |
* | |
* In addition to the above arguments, any jQuery/Zepto.ajax options argument | |
* can be specified as well. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(['handlebars','text'], function (Handlebars, text) { | |
var _buildMap = {}; | |
var _buildTemplate = Handlebars.compile( | |
'define("{{pluginName}}!{{moduleName}}", ["handlebars"], function(Handlebars){'+ | |
' return {{fn}}'+ | |
'});\n' | |
); | |
return { | |
load: function (name, req, onLoad, config) { |
NewerOlder