Tuesday, 14 August 2012

SVN Tip

SVN Patch

Run command in project root

1. Create a patch
svn diff > mypatch.diff

2. apply a patch
download patch

patch -p0 -i fix_path.diff

3. reverse patch
 patch -p0 -R -i fix_path.diff

4.  How to revert svn commit:
The following two commands will do the trick

svn merge -r 101:100 http://svn.example.com/repos/calc/trunk
svn ci



5. SVN Blame

svn blame svn://repositoy/filename
                       

Thursday, 2 August 2012

Set up localhost server

  1. npm init
  2. npm install express
  3. create a index.html and index.js
  4. node index.js
  5. http://localhost:5000
//index.js
const express = require('express');
const app = express();
const port = 5000;

app.get('/', (req, res) => {
    res.sendFile('index.html', {root: __dirname});
});

app.listen(port, () => {
    console.log(`Now listening on port ${port}`);
});

Create a post api using express

const express = require('express');
const app = express();

//middleware to parse incoming request with json payload
app.use(express.json());

//middleware to parse incoming request with url encoded payload
app.use(express.urlencoded({ extended: true }));

const port = 5000;

app.get('/', (req, res) => {
    res.sendFile('index.html', { root: __dirname });
});

app.listen(port, () => {
    console.log(`Now listening on port ${port}`);
});

app.post('/api/create_transaction', (req, res) => {
    const body = req.body;
    console.log("body:", body);
    res.status(201).json([]);
});