This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tpl from './demo.jade' | |
| export default function routes ($stateProvider) { | |
| 'ngInject' | |
| $stateProvider.state('demo', { | |
| url: '/demo', | |
| controller: 'DemoController', | |
| controllerAs: 'demo', | |
| templateUrl: tpl, | |
| resolve: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| h1 Demo app | |
| p | |
| a(ng-click='demo.DemoService.greet()') Say hi | |
| p foo = {{demo.DemoService.data.foo}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {IView, View} from './view.model' | |
| import * as express from 'express' | |
| export async function awaitIndex (req: express.Request, res: express.Response) { | |
| try { | |
| const lastVisit: IView = await View.create({ | |
| visitedAt: new Date(), | |
| visitedBy: getIp(req), | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export async function awaitIndex (req: express.Request, res: express.Response) { | |
| try { | |
| const lastVisit: IView = await View.create({ | |
| visitedAt: new Date(), | |
| visitedBy: getIp(req), | |
| }) | |
| const count: number = await View.count({}) | |
| res.send({ count, lastVisit: lastVisit.public }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export async function promiseIndex (req: express.Request, res: express.Response) { | |
| View.create({ | |
| visitedAt: new Date(), | |
| visitedBy: getIp(req), | |
| }) | |
| .then((lastVisit: IView) => { | |
| View.count({}).then(count => { | |
| return res.send({count, lastVisit: lastVisit.public}) | |
| }) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it('returns a new view', async function () { | |
| const t = await request.get('/api/views/await') | |
| expect(t.status).to.equal(200) | |
| expect(t.body).to.have.property('lastVisit') | |
| expect(t.body).to.have.property('count', 1) | |
| }) | |
| it('creates a view', async function () { | |
| expect(await View.count({})).to.equal(1) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Nuke every container, images and volumes and claim your disk space back. | |
| docker ps -aq | xargs docker stop ; \ | |
| docker ps -aq | xargs docker rm -f; \ | |
| docker images -aq | xargs docker rmi -f; \ | |
| docker volume ls | xargs docker volume rm -f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| square = -> x {x*x} #or its equivalent notation: square = lambda { |x| x*x } | |
| plus_one = -> x {x+1} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| square.(2) #=> 4 | |
| plus_one.(2) #=> 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| minus = -> f,g { -> x { f.(x) - g.(x) } } | |
| div = -> f,g { -> x { f.(x) / g.(x) } } | |
| mult = -> f,g { -> x { f.(x) * g.(x) } } |