Skip to content

Instantly share code, notes, and snippets.

View DamienBell's full-sized avatar

Damien Bell DamienBell

View GitHub Profile
@DamienBell
DamienBell / example.js
Created August 12, 2013 23:16
Compile a handlebars template without calling res.render On node typically use handlebars to render our webpage, but from time to time it's useful to compile a template from our views directory on the server as a string.
var express = require('express');
var fs = require('fs');
var hbs = require('hbs');
var app = module.exports = express.createServer();
app.configure(function(){
app.set('views', __dirname + '/views');
//app.set('view engine', 'jade');
app.set('view engine', 'hbs');
@DamienBell
DamienBell / 0_reuse_code.js
Created April 11, 2014 15:49
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@DamienBell
DamienBell / App.get.js
Created April 14, 2014 14:56
App.get //basic ajax request.
App= {
/*
config= {
options:{
host: 'ichart.yahoo.com',
path: '/table.csv?s=GOOG&a=01&b=1&c=2013'
},
success: function(json){},
error: function(error){}
}
@DamienBell
DamienBell / async_example.js
Created April 14, 2014 15:02
Basic template for executing a series of async functions on an array before calling an onComplete function
//var async = require('async');
async.forEach([],
function(arg, callback){
//do this for each item in list
//then
callback(null);
},
//completion
function(err){
@DamienBell
DamienBell / dollars.js
Created April 14, 2014 15:04
make it rain. Convert a number to dollars
function dollars(num){
num= Number(num);
return Math.round(num*100)/100
}
@DamienBell
DamienBell / setUpLayout.swift
Last active August 29, 2015 14:07
Medium: post embed for setUpLayout method
func setUpLayout(){
//This is an example of setting up a responsive layout using NSConstraints
//Compared to html/css it is absolutely insane.
//We'll try to do this as little as possible,
//but this setup will go a long way in future proofing our layout.
//set view properties
//By Default these are white.
//
// DBNibLoadingView.swift
// Created by Damien Bell on 2/15/16.
// Copyright © 2016 Damien Bell. All rights reserved.
//
//How To Use:
//Create a nib file where the name of the file matches the class name
//set the xib's files owner to the relevant class. Important! set files owner and not the UIView class on the xib object itself
//Using this approach you can still set iboutlets and properties as normal
import UIKit
@DamienBell
DamienBell / MKMapViewExtensions.swift
Last active June 8, 2016 03:57
Handy MKMapView methods
//
// MKMapViewExtension.swift
// AutocompleteTextfieldSwift
//
// Created by Mylene Bayan on 2/22/15.
// Copyright (c) 2015 MaiLin. All rights reserved.
//
import Foundation
import MapKit
@DamienBell
DamienBell / PFObjectExtensions.swift
Created May 31, 2016 15:36
Handy PFObject extensions
//
// PFObjectExtensions.swift
// Only Indie Coffee
//
// Created by Damien Bell on 5/30/16.
// Copyright © 2016 Damien Bell. All rights reserved.
//
import Foundation
import Parse
@DamienBell
DamienBell / DynamicTableViewController.swift
Last active May 31, 2016 17:00
These are some of the basics of UITableView implementation that are used repeatedly. Logic is added here to account for dynamically sizing TableCells, as well as loading a tableCellView from a nib.
//
// ShopsDetailsTableViewController.swift
// Only Indie Coffee
//
// Created by Damien Bell on 5/31/16.
// Copyright © 2016 Damien Bell. All rights reserved.
//
import UIKit