Friday, April 29, 2016
postgres 57014
"ERROR: 57014: canceling statement due to statement timeout
Navicat, dotConnect for PostgreSQL
https://www.navicat.com/download/navicat-for-postgresql
https://www.devart.com/dotconnect/postgresql/download.html
https://www.devart.com/dotconnect/postgresql/download.html
PostGreSQL: getting started
http://www.enterprisedb.com/products-services-training/pgdownload#windows
http://www.postgresqltutorial.com/postgresql-sample-database/
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.
install add bin to path
psql.exe
\d
create table thingy(
In Visual studio, click on view, server explorer
1. localhost is the server
2. postgres is the database name
3. public is the schema
Thursday, April 28, 2016
Node js mongoose partial string search
https://scotch.io/tutorials/using-mongoosejs-in-node-js-and-mongodb-applications
http://stackoverflow.com/questions/10156768/find-matching-partial-string
http://stackoverflow.com/questions/10156768/find-matching-partial-string
db.users.find({'name': {'$regex': 'sometext'}})
below example implementation showing search on partial first name
router.get('/merged_xxxxx/', function (req, res, next) {
var conditions = {};
var first_name = req.query.first_name;
var last_name = req.query.last_name;
var full_name = req.query.full_name;
if (first_name !== undefined){
var firstExp = {};
firstExp ['$regex'] = first_name;
conditions['first_name'] = firstExp;
}
if (last_name !== undefined){
conditions['last_name'] = last_name;
}
if (full_name !== undefined){
conditions['full_name'] = full_name;
}
console.log(conditions);
KMMergedAuthors.find(conditions)
.sort(
buildSortClause(req)
)
.limit(getRecordsReturned(req, 50))
.exec()
.then(function (allMergedAuthors) {
res.json(allMergedAuthors);
});
});
heroku nodejs website
https://git.heroku.com/gregchu.git
https://gregchu.herokuapp.com/
https://gregchu.herokuapp.com/
Creating a basic site with Node.js and Express - nodemon
http://shapeshed.com/creating-a-basic-site-with-node-and-express/
npm install -g nodemon
Then you can start your app with
nodemon
Nodemon automatically looks in your project setting to find the appropriate files and setting to start your server. If this does not work try:
nodemon app.js
Using nodemon means you don't have to restart your app each time you make a change. For more infomation on nodemon see the README
stop nodemon just use control C
stop nodemon just use control C
Introduction to Mongoose for Node.js and MongoDB - steps
- use express generator (see another blog)
- connection to mongodb
- add schema
- add controller
- use postman to add note (API test)
- add html to replace postman
package.json
{ "name": "standup", "version": "0.0.0", "private": true, "scripts": { "start": "node ./bin/www" }, "dependencies": { "body-parser": "~1.13.2", "cookie-parser": "~1.3.5", "debug": "~2.2.0", "express": "~4.13.1", "mongoose": "^4.4.14", "morgan": "~1.6.1", "serve-favicon": "~2.3.0", "swig": "^1.4.2" } }
app.js
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var routes = require('./routes/index');
var users = require('./routes/users');
// Mongoose ODM...
var mongoose = require('mongoose');
// Connect to MongoDB...
mongoose.connect('mongodb://demo:standup123@ds052827.mongolab.com:52827/standupmeetingnotes');
var app = express();
var swig = require ('swig');
app.engine('html',swig.renderFile);
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'html');
// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes);
app.use('/users', users);
// catch 404 and forward to error handlerapp.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handlers
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}
// production error handler// no stacktraces leaked to userapp.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});
module.exports = app;
routes/index.js
var express = require('express');
var router = express.Router();
var standupCtrl = require('../controllers/standup.server.controller');
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
/* GET New Note page. */
router.get('/newnote', function(req, res) {
return standupCtrl.getNote(req, res);
});
/* POST New Note page. */
router.post('/newnote', function(req, res) {
return standupCtrl.create(req, res);
});
module.exports = router;
model/standup.server.model.js
var mongoose = require( 'mongoose' ); var Schema = mongoose.Schema; var standupSchema = new Schema({ memberName: String, project: String, workYesterday: String, workToday: String, impediment: String, createdOn: { type: Date, default: Date.now } }); module.exports = mongoose.model( 'Standup', standupSchema );
controllers/standup.server.controller.js
var Standup = require("../model/standup.server.model.js"); exports.create = function(req, res) { var entry = new Standup({ memberName: req.body.memberName, project: req.body.project, workYesterday: req.body.workYesterday, workToday: req.body.workToday, impediment: req.body.impediment }); entry.save(); // Redirect to the home page... res.redirect(301, '/'); }; exports.getNote = function(req, res) { res.render('newnote', { title: 'Standup - New Note' }); };
Wednesday, April 27, 2016
introduction to mongoose for node.js and mongodb
sample mongo database
ds052827.mongolab.com
52827
standupmeetingnotes
demo
standup123
see express generator blog for install
npm install mongoose --save
ds052827.mongolab.com
52827
standupmeetingnotes
demo
standup123
see express generator blog for install
npm install mongoose --save
swig - A Node.js and Browser-based JavaScript Template Engine
http://paularmstrong.github.io/swig/
express generator
I think next line should add --save at the end
$ npm install express-generator -g
express --help
express -H
open terminal do npm install
the above will install all dependecies
npm install swig --save
app.set('view engine', 'hjs');
change to html
var app = express();
var swig = require ('swig');
app.engine('html',swig.renderFile);
// view engine setupapp.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'html');
npm uninstall hjs --save
Friday, April 22, 2016
birth and death of javascript
https://www.destroyallsoftware.com/talks/the-birth-and-death-of-javascript
Thursday, April 21, 2016
Using Visual studio to debug Node.js
You read article below, but still not sure where the debugging gets triggered:
http://www.hanselman.com/blog/IntroducingNodejsToolsForVisualStudio.aspx
basically when you F5 to start debugging you will see a web site started as shown below:
the port # 1380 is important.
You can add to it, Ex:
http://localhost:1380/journal/304564
you will get to debugger (if you put a break point) of the API.
or use postman
or fiddler
Wednesday, April 20, 2016
Pentaho data transformation
http://www.pentaho.com
Thursday, April 14, 2016
mongodb find
https://docs.mongodb.org/manual/reference/method/db.collection.find/#db.collection.find
Microservice example http://microservices.io/
https://github.com/eventuate-examples/eventuate-examples-java-spring-todo-list
Saturday, April 9, 2016
Node js on Azure
https://azure.microsoft.com/en-us/develop/nodejs/
https://azure.microsoft.com/en-us/documentation/articles/web-sites-nodejs-develop-deploy-mac/
Thursday, April 7, 2016
Web hosting companies
Here is ipage's sister company that offers windows hosting: http://www.domain.com/domaincom/hosting/windows.bml
Wednesday, April 6, 2016
bought webstorm today 4/4/2016
The reason being checking JavaScript syntac
visual studio column select editing
hold down SHIFT + ALT while dragging the mouse pointer over a block of text you wont select the entire rows of text that you have dragge
http://joelabrahamsson.com/select-columns-of-text-in-visual-studio/
http://joelabrahamsson.com/select-columns-of-text-in-visual-studio/
Angular JS bootstrap
https://docs.angularjs.org/guide/bootstrap
Tuesday, April 5, 2016
web private mode - Browse in private with incognito mode
control shift N
https://support.google.com/chrome/answer/95464?hl=en
chrome cross reference
cd C:\Program Files
(x86)\Google\Chrome\Application
chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security
chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security
chrome.exe
--user-data-dir="C:/Chrome dev session" --disable-web-security
----------------------------------------------------------
cd C:\Program Files
(x86)\Google\Chrome\Application
THEN
chrome.exe
--user-data-dir="C:/Chrome dev session" --disable-web-security
Monday, April 4, 2016
angular js show and hide
http://www.angulartutorial.net/2014/04/show-and-hide-in-angular-js.html
Subscribe to:
Posts (Atom)