Skip to content

Instantly share code, notes, and snippets.

@davidblurton
davidblurton / gist:9440434
Last active August 29, 2015 13:57
I wanted the index page to be a static page (which you can write in the Ghost editor) rather than the list of posts (which you can only edit by changing the template). Hacked the router so the index page redirects to a static page at /index
var frontend = require('../controllers/frontend');
module.exports = function (server) {
/*jslint regexp: true */
// ### Frontend routes
server.get('/rss/', frontend.rss);
server.get('/rss/:page/', frontend.rss);
server.get('/page/:page/', frontend.homepage);
server.get('/blog/', frontend.homepage);
// Module dependencies
var crypto = require('crypto'),
express = require('express'),
hbs = require('express-hbs'),
fs = require('fs'),
uuid = require('node-uuid'),
Polyglot = require('node-polyglot'),
semver = require('semver'),
_ = require('lodash'),
when = require('when'),
// Component is a collection of links that have a viewing and editing state.
var Link = React.createClass({
mixins: [React.addons.LinkedStateMixin],
getInitialState: function() {
return {
title: this.props.title, // Copy props to state so we can use LinkedStateMixin. This feels like a hack.
description: this.props.description
};
},
FROM stackbrew/ubuntu:trusty
RUN apt-get update && apt-get install -y software-properties-common --force-yes && add-apt-repository -y ppa:chris-lea/node.js
RUN apt-get update && apt-get -y install nodejs
RUN npm install -g grunt-cli bower gulp
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /srv/www
ADD . /srv/www
RUN npm install
FROM stackbrew/ubuntu:trusty
RUN apt-get update && apt-get install -y software-properties-common --force-yes && add-apt-repository -y ppa:chris-lea/node.js
RUN apt-get update && apt-get -y install nodejs
RUN npm install -g bower gulp
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /srv/www
ADD . /srv/www
RUN npm install && bower install
{
init: function(elevators, floors) {
floors.forEach(function(floor) {
floor.on("up_button_pressed", function() {
var emptiestElevator = getEmptiestElevator();
emptiestElevator.goToFloor(floor.floorNum());
});
floor.on("down_button_pressed", function() {
var emptiestElevator = getEmptiestElevator();
emptiestElevator.goToFloor(floor.floorNum());
{
"count": 4,
"results": [
{"title": "Drunk J Crew", "image": "http://i.imgur.com/XKkITfW.jpg", "link":"http://drunkjcrew.tumblr.com"},
{"title": "Drunk J Crew", "image": "http://i.imgur.com/XKkITfW.jpg", "link":"http://drunkjcrew.tumblr.com"},
{"title": "Drunk J Crew", "image": "http://i.imgur.com/XKkITfW.jpg", "link":"http://drunkjcrew.tumblr.com"},
{"title": "Drunk J Crew", "image": "http://i.imgur.com/XKkITfW.jpg", "link":"http://drunkjcrew.tumblr.com"}
]
}
{
"bold_folder_labels": true,
"color_scheme": "Packages/User/SublimeLinter/Oceanic Next (SL).tmTheme",
"ensure_newline_at_eof_on_save": true,
"fold_buttons": false,
"folder_exclude_patterns":
[
".svn",
".git",
".hg",
(ns verbs.core
(:require [clojure.data.csv :as csv]
[clojure.java.io :as io])
(:gen-class))
(def types {
:verb "so"
:pronoun "pfn"
:adjective "lo"
:number "to"
@davidblurton
davidblurton / gist:5115878
Last active December 14, 2015 16:29
ViewModel is a base class for all view models. It handles INotifyPropertyChanged using the C#5 caller member name attribute
public abstract class ViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected void RaisePropertyChanged([CallerMemberName] string propertyName = string.Empty)
{
if (propertyName = string.Empty)
{
throw new NotSupportedException("Cannot raise property changed on an empty property name. Make sure you are using the C# 5 compiler to make CallerMemberName work.")