Skip to content

Instantly share code, notes, and snippets.

@chrismatheson
chrismatheson / gist:2895004
Created June 8, 2012 11:04
callbacks in loops
var processQueue = function(data) {
if(typeof data === 'undefined'){
//start of queue
data = new Object({});
}
util.isError(data){
console.error('error sending msg');
console.error(util.inspect(data));
//process.exit(1);
@chrismatheson
chrismatheson / SimpleNoteExport.js
Created July 11, 2012 09:28
Node script to convert simple note json output to standard text files
var fs = require('fs');
var notesString = fs.readFileSync('simplenote_export.json', 'utf8');
var notesArray = JSON.parse(notesString);
console.log('you have '+notesArray.length+' notes');
for (var i = notesArray.length - 1; i >= 0; i--) {
var filename = notesArray[i].content.substr(0,30)
filename = filename.replace(/(\r\n|\n|\r|\/|\\|<|>|:)/gm," ");
@chrismatheson
chrismatheson / Method 1
Created September 3, 2012 12:22
Backbone MVC example
var RawView = Parse.View.extend({
$:'#raw',
template: _.template("Some pre text: <br><br><br>{{this.model.toJSON()}}"),
render: function(){
$('#raw').html( this.template( this ) );
}
});
@chrismatheson
chrismatheson / main.js
Created October 4, 2012 09:22
Parse Cloud Code test
Parse.Cloud.define("random", function(request, response) {
var Quotes = Parse.Collection.extend({
initialize:function(){
this.fetch({
success: function(collection) {
//this is now 'window' object
console.log('Data back from server');
},
error: function(collection, error) {
console.error('The collection could not be retrieved.');
@chrismatheson
chrismatheson / PagableArray
Created June 20, 2013 13:05
First go at a "remoteObject" or pagable array which can auto-update itself
/*globals angular, console*/
angular.module("app")
.service("users", ["$http", "security", "$log", "$q", function ($http, security, $log, $q) {
"use strict";
/**
* Super duper array which has pagination & updating stuff in it allready.
*/
var users = [{Firstname: "Default"}],
defered = $q.defer();
@chrismatheson
chrismatheson / README.md
Created October 29, 2013 12:41
ivCard proposal

#ivCard componenet

has two views, front and back. The card itself adds a button to flip between these views and manages this stae internally.

###Events changes in view are emited up the scope chain and can be broadcast from the parent scopes to control the view state.

###Useage

@chrismatheson
chrismatheson / gist:7317223
Created November 5, 2013 10:49
local server
grunt.registerTask('server', function () {
var express = require('express'),
proxy = require('simple-http-proxy'),
app = express();
app.use('/platform/', express.logger('tiny'));
app.use('/platform/v1/', proxy('https://siam.ivendi.com/platform/v1/'));
app.use('/src', express['static']('src'));
app.use('/vendor', express['static']('vendor'));
@chrismatheson
chrismatheson / componenet.html
Last active December 28, 2015 07:39
angular component
<section>
<script type="application/javascript">
/*jslint nomen:true */
/*globals angular, _*/
angular.module('ivLender', [])
.directive('ivLender', function () {
'use strict';
return {
restrict: 'A',
@chrismatheson
chrismatheson / directive.js
Created December 19, 2013 12:04
isolate scope :(
/*jslint nomen:true */
/*globals angular, _, console*/
angular.module('ivErrors', [])
.directive('ivErrors', ['$log', function ($log) {
'use strict';
return {
restrict: 'A',
templateUrl: 'ivErrors/ivErrors.tpl.html',
scope: {},
/*jslint nomen:true*/
/*globals angular, _, console*/
angular.module('ivYearsMonths', [])
.directive('ivYearsMonths', ['$filter', function ($filter) {
'use strict';
return {
priority: 0,
replace: true,