Skip to content

Instantly share code, notes, and snippets.

View johnoscott's full-sized avatar

Johno Scott johnoscott

View GitHub Profile
<!doctype html>
<html lang="en" ng-app="app">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<title>Pizza.com.au</title>
<!-- CSS -->
<!-- from view-source:http://twitter.github.com/bootstrap/examples/starter-template.html -->
/*
* JavaScript Pretty Date
* Copyright (c) 2008 John Resig (jquery.com)
* Licensed under the MIT license.
*/
// Takes an ISO time and returns a string representing how
// long ago the date represents.
function prettyDate(time) {
var date = time,
(function(angular) {
'use strict';
/*
Usage:
-----
FILE --app.js--
<!doctype html><html ng-app> <head> <script src="http://code.angularjs.org/1.2.0-rc.3/angular.min.js"></script> </head> <body> Check me to check both: <input type="checkbox" ng-model="master"><br/> <input id="checkSlave" type="checkbox" ng-checked="master"> </body></html>
/*
atrs:
size, lineWidth, bg, bc, val
*/
app.directive('clDonut', function() {
return {
restrict: 'E',
template: '<canvas></canvas>',
replace: true,
link: function(scope, el, attrs) {
@johnoscott
johnoscott / resource.js
Created December 10, 2013 00:18
AngularJS $resource usage
// Create $resource singleton service with custom methods
// SERVICE DebugOrder
.factory('Order', ['$resource', '$http',
function ($resource, $http) {
return $resource(Prefs.getResourceBaseUrl() + '/api/orders/:_id', {}, {
'count': {method: 'PUT', params: {_id: 'count'}},
'distinct': {method: 'PUT', params: {_id: 'distinct'}},
'find': {method: 'PUT', params: {_id: 'find'}, isArray: true},
'group': {method: 'PUT', params: {_id: 'group'}, isArray: true},
@johnoscott
johnoscott / app.js
Created December 16, 2013 01:03 — forked from victorb/app.js
var myApp = angular.module('myApp', []);
myApp.directive('googleplace', function() {
return {
require: 'ngModel',
link: function(scope, element, attrs, model) {
var options = {
types: [],
componentRestrictions: {}
};
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
/**
* The MIT License (MIT)
*
* Copyright (c) 2013 Thom Seddon
* Copyright (c) 2010 Google
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;