Skip to content

Instantly share code, notes, and snippets.

var devices = [
{id:0, name: "iphone", assetTag:"a23456", owner:"dev", desc:"iOS4.2"},
{id:1, name: "loaner-laptop-1", assetTag:"a13936", owner:"dev", desc:""},
{id:2, name: "loaner-laptop-3", assetTag:"a43056", owner:"qa", desc:""},
{id:3, name: "android", assetTag:"a33756", owner:"dev", desc:"android2.4"},
{id:4, name: "galaxy tab", assetTag:"a53356", owner:"dev", desc:"android"},
{id:5, name: "loaner-laptop-2", assetTag:"a63556", owner:"qa", desc:""},
{id:6, name: "iphone", assetTag:"a73856", owner:"dev", desc:"iOS5"}
];
var express = require('express');
var app = express();
var devices = [
{id:0, name: "iphone", assetTag:"a23456", owner:"dev", desc:"iOS4.2"},
{id:1, name: "loaner-laptop-1", assetTag:"a13936", owner:"dev", desc:""},
{id:2, name: "loaner-laptop-3", assetTag:"a43056", owner:"qa", desc:""},
{id:3, name: "android", assetTag:"a33756", owner:"dev", desc:"android2.4"},
{id:4, name: "galaxy tab", assetTag:"a53356", owner:"dev", desc:"android"},
@sunkay
sunkay / gist:5457190
Created April 25, 2013 02:53
Angularjs forms controllers, using a shared service & using $location to redirect to our desired path
function addDeviceController($scope, $location, Devices)
{
//console.log("add-Field" + $scope.device.name);
$scope.add = function(device){
device['id'] = (Devices.query().length)+1;
Devices.add(device);
console.log(device);
// redirect to main screen
@sunkay
sunkay / gist:5457171
Created April 25, 2013 02:50
Sharing data using Angular Services
// create a module to support getting and managing the device list
var deviceModule = angular.module('DeviceModule', []);
// setup the service factory to create our items. Should retrieve from the server side db
deviceModule.factory('Devices', function(){
var items = {};
items.data = [
{id:0, name: "iphone", assetTag:"a23456", owner:"dev", desc:"iOS4.2"},
{id:1, name: "loaner-laptop-1", assetTag:"a13936", owner:"dev", desc:""},
@sunkay
sunkay / gist:5457136
Created April 25, 2013 02:43
Form with ng-model hooks
<div ng-controller="addDeviceController">
<form novalidate name="addDevice" class="form-horizontal">
<div class="control-group">
<label class="control-label">Name</label>
<div class="controls">
<input type="text" id="name" ng-model="device.name" required placeholder="Enter Name">
</div>
</div>
<div class="control-group">
<label class="control-label">Asset Tag</label>
@sunkay
sunkay / gist:5446739
Created April 23, 2013 19:40
Basic Angular Form partial
<div ng-controller="addDeviceController">
<form novalidate name="addDevice" class="form-horizontal">
<div class="control-group">
<label class="control-label">Name</label>
<div class="controls">
<input type="text" id="name" placeholder="Enter Name">
</div>
</div>
<div class="control-group">
<label class="control-label">Asset Tag</label>
@sunkay
sunkay / gist:5438504
Created April 22, 2013 21:00
shows how to use ng-show & ng-hide
<div ng-controller="deviceListController">
<div ng-hide="devices.length">
You have no devices setup.
<a href="#/admin/add-new">Would you like to add?</a>
</div>
@sunkay
sunkay / nginx
Last active December 16, 2015 11:59
nginx commands
Mac:cotd$ sudo nginx
Mac:cotd$ ps -ef|grep nginx
0 22354 1 0 5:10PM ?? 0:00.00 nginx: master process nginx
-2 22355 22354 0 5:10PM ?? 0:00.00 nginx: worker process
502 22357 19529 0 5:10PM ttys000 0:00.00 grep nginx
STOPPING NGINX
Mac:cotd$ sudo nginx -s stop
Mac:cotd$ ps -ef|grep nginx
@sunkay
sunkay / cotd.js
Created April 21, 2013 20:54
main controller which provides the routes & models
// Global app module listing all its dependencies
var cotdServices = angular.module('cotd', ['DeviceModule']);
// setup mappings routes and templates
function cotdRouteConfig($routeProvider){
$routeProvider.
when('/', {
controller: deviceListController,
templateUrl: 'listDevices.html'
}).
<div ng-controller="deviceListController">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Asset Tag</th>
<th>Owner</th>
<th>Description</th>
</tr>
</thead>