Skip to content

Instantly share code, notes, and snippets.

View jdx's full-sized avatar

jdx

View GitHub Profile
@jdx
jdx / index.html
Last active October 16, 2015 21:09
<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
<meta charset="UTF-8">
<title>simple-mean</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.7/angular.js"></script>
<script src="/scripts/app.js"></script>
</head>
<body>
<div ng-controller="TodoCtrl">
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>simple-mean</title>
</head>
<body>
It works!
</body>
</html>
'use strict';
let express = require('express');
let app = express();
app.get('/', function (req, res) {
// render out the angular bootstrap page
res.render('index.html.ejs');
});
@jdx
jdx / express.js
Created October 14, 2015 19:29
Express.js example
'use strict';
let express = require('express');
let app = express();
app.get('/statuscheck', function (req, res) {
res.json({status: 'success'});
});
app.listen(process.env.PORT || 3000);
@jdx
jdx / koa.js
Last active October 16, 2015 14:28
koa example
app.get('/user/:id', function* (id) {
let user = yield db.get(id);
res.json(user);
});
@jdx
jdx / wrap.js
Created August 13, 2015 19:01
wrap inquirer in es6 promise
yield new Promise(function (resolve, reject) {
inquirer.prompt( questions, function ( answers ) {
if (answers.pipeline) resolve(answers.pipeline);
else reject('Must pick a pipeline');
});
});
@jdx
jdx / request.js
Last active August 29, 2015 14:24
simple node json http request function with promises and no dependencies
'use strict';
let http = require('http');
let https = require('https');
let parseUrl = require('url').parse;
function concat (stream, callback) {
var strings = [];
stream.on('data', function (data) {
strings.push(data);
let p = heroku.apps().list()
.then(function (apps) {
return heroku.apps(apps[0].name).configVars().info();
});
cli.action("working", p);
require 'multi_json'
MultiJson.load("{
\"config_vars\": [
\"DATABASE_URL\"
],
\"created_at\": \"2015-05-15T20: 56: 57Z\",
\"id\": \"b84428f9-06cd-4a92-b238-9081afa27344\",
\"name\": \"walking-purposefully-7680\",
\"addon_service\": {
\"id\": \"6c67493d-8fc2-4cd4-9161-4f1ec11cbe69\",
if _, err := os.Stat(filename); os.IsNotExist(err) {
fmt.Printf("no such file or directory: %s", filename)
return
}