Dexter Jin

Deprecated Experiments

Showing 106 changed files with 0 additions and 940 deletions
// Please implements multiplication tables (구구단)
var numbers = new Array(12, 45, 2, 31, 4, 56, 6, 7);
// find out maximum number and minimum numbers
for (var index in numbers) {
console.log ("index[" + index +"] = " + numbers[index]);
}
var numbers = new Array (10, 11, 2, 1, 3, 1, 4, 10, 20, 21);
// Sort numbers in ascending order
<html>
<body>
<script type="text/javascript">
<!--
document.write("Hello World");
//-->
</script>
</body>
</html>
console.log("Hello");
console.log("Hello");
console.log("Hello");
console.log("Hello");
console.log("Hello");
var a = 33;
var b = 10;
var c = "Test";
console.log("a + b = ");
result = a + b;
console.log(result);
console.log("a - b = ");
result = a - b;
console.log(result);
console.log("a / b = ");
result = a / b;
console.log(result);
console.log("a % b = ");
result = a % b;
console.log(result);
console.log("a + b + c = ");
result = a + b + c;
console.log(result);
a = a++;
console.log("a++ = ");
result = a++;
console.log(result);
b = b--;
console.log("b-- = ");
result = b--;
console.log(result);
var a = 33;
var b = 10;
console.log("Value of a => (a = b) => ");
result = (a = b);
console.log(result);
console.log("Value of a => (a += b) => ");
result = (a += b);
console.log(result);
console.log("Value of a => (a -= b) => ");
result = (a -= b);
console.log(result);
console.log("Value of a => (a *= b) => ");
result = (a *= b);
console.log(result);
console.log("Value of a => (a /= b) => ");
result = (a /= b);
console.log(result);
console.log("Value of a => (a %= b) => ");
result = (a %= b);
console.log(result);
var a = 2; // Bit presentation 10
var b = 3; // Bit presentation 11
console.log("(a & b) => ");
result = (a & b);
console.log(result);
console.log("(a | b) => ");
result = (a | b);
console.log(result);
console.log("(a ^ b) => ");
result = (a ^ b);
console.log(result);
console.log("(~b) => ");
result = (~b);
console.log(result);
console.log("(a << b) => ");
result = (a << b);
console.log(result);
console.log("(a >> b) => ");
result = (a >> b);
console.log(result);
var a = 10;
var b = 20;
console.log("(a == b) => ");
result = (a == b);
console.log(result);
console.log("(a < b) => ");
result = (a < b);
console.log(result);
console.log("(a > b) => ");
result = (a > b);
console.log(result);
console.log("(a != b) => ");
result = (a != b);
console.log(result);
console.log("(a >= b) => ");
result = (a >= b);
console.log(result);
console.log("(a <= b) => ");
result = (a <= b);
console.log(result);
var a = 10;
var b = 20;
var linebreak = "<br />";
console.log ("((a > b) ? 100 : 200) => ");
result = (a > b) ? 100 : 200;
console.log(result);
console.log ("((a < b) ? 100 : 200) => ");
result = (a < b) ? 100 : 200;
console.log(result);
var numbers = new Array(1,2,2,3,4)
for (var num in numbers) {
// key and Value
console.log(num + " = " + numbers[num]);;
}
console.log ("Exiting from the loop!");
var age = 20;
if( age > 18 ) {
console.log("Qualifies for driving");
}
var age = 15;
if( age > 18 ) {
console.log("Qualifies for driving");
} else {
console.log("Does not qualify for driving");
}
var book = "maths";
if( book == "history" ) {
console.log("History Book");
} else if( book == "maths" ) {
console.log("Maths Book");
} else if( book == "economics" ) {
console.log("Economics Book");
} else {
console.log("Unknown Book");
}
var a = true;
var b = false;
console.log("(a && b) => ");
result = (a && b);
console.log(result);
console.log("(a || b) => ");
result = (a || b);
console.log(result);
console.log("!(a && b) => ");
result = (!(a && b));
console.log(result);
var grade='A';
console.log("Entering switch block");
switch (grade)
{
case 'A':
console.log("Good job");
break;
case 'B':
console.log("Pretty good");
break;
case 'C':
console.log("Passed");
break;
case 'D':
console.log("Not so good");
break;
case 'F': console.log("Failed");
break;
default:
console.log("Unknown grade")
}
console.log("Exiting switch block");
switch (grade)
{
case 'A':
console.log("Good job");
case 'B':
console.log("Pretty good");
case 'C':
console.log("Passed");
case 'D':
console.log("Not so good");
case 'F':
console.log("Failed");
default:
console.log("Unknown grade");
}
console.log("Exiting switch block");
var a = 10;
var b = "String";
result = (typeof b == "string" ? "B is String" : "B is Numeric");
console.log("Result => ");
console.log(result);
result = (typeof a == "string" ? "A is String" : "A is Numeric");
console.log("Result => ");
console.log(result);
var name = "Ali";
var money;
money = 2000;
console.log("my name is " + name);
console.log("my money is " + money);
var myVar = "global"; // Declare a global variable
function checkscope( ) {
var myVar = "local";
// Declare a local variable
console.log("print myVar " + myVar);
}
console.log("print myVar " + myVar);
checkscope();
var count = 0;
console.log("Starting Loop ");
while (count < 10) {
console.log("Current Count : " + count);
count++;
}
console.log("Loop stopped!");
var count = 0;
console.log("Starting Loop");
do {
console.log("Current Count : " + count);
count++;
} while (count < 5);
console.log ("Loop stopped!");
function addPrice(amount) {
this.price = amount;
}
function book(title, author) {
this.title = title;
this.author = author;
this.addPrice = addPrice;
}
var bookList = new Array(new book("Perl1", "Mohtashim"),new book("Smith", "Mohtashim"),new book("Carl", "Mohtashim"),new book("Perl2", "Mohtashim"));
console.log(bookList);
console.log("After Sorting");
//bookList.sort(sortBook);
console.log(bookList);
function slice(str, start, end) {
}
var str = "Apples are round, and apples are juicy.";
var sliced = str.slice(1, 3);
console.log( sliced );
console.log( slice(str, 1, 3));
function reverse (input) {
}
var arr = [0, 1, 2, 3];
console.log ("Reversed array is : " + arr.reverse() );
console.log ("Reversed array is : " + reverse(arr));
var alpha = ["a", "b", "c"];
var numeric = [1, 2, 3];
var alphaNumeric = alpha.concat(numeric);
console.log("alphaNumeric : " + alphaNumeric );
var numbers = [1, 4, 9];
var element = numbers.pop();
console.log("element is : " + element );
var numbers = new Array(1, 4, 9);
var length = numbers.push(10);
console.log("new numbers is : " + numbers );
var arr = [0, 1, 2, 3].reverse();
console.log("Reversed array is : " + arr );
console.log("Reversed Again : " + arr.reverse());
var element = [105, 1, 2, 3].shift();
console.log ("Removed element is : " + element );
var arr = new Array("orange", "mango", "banana", "sugar");
var length = arr.unshift("water");
console.log("Returned array is : " + arr );
console.log("Length of the array is : " + length );
var test = new Array(1,2,3,4,5,6);
for (var aa in test) {
console.log(aa); // Set breakpoint here
}
function concatenate(first, last)
{
var full;
full = first + last;
return full;
}
function secondFunction()
{
var result;
result = concatenate('Zara', 'Ali');
console.log (result );
}
secondFunction();
var val = new Number(100.000);
console.log(val.toExponential());
console.log(val.toFixed());
console.log(val.toLocaleString());
console.log(val.toPrecision());
console.log(val.toString());
function addPrice(amount) {
this.price = amount;
}
function book(title, author) {
this.title = title;
this.author = author;
this.addPrice = addPrice;
}
var myBook = new book("Perl", "Mohtashim");
myBook.addPrice(100);
console.log("Book title is : " + myBook.title);
console.log("Book author is : " + myBook.author);
console.log("Book price is : " + myBook.price);
var val = new String("test");
console.log(val.charAt(1));
console.log(val.charCodeAt(1));
console.log(val.concat("aaa"));
console.log(val.indexOf("st"));
console.log(val.indexOf("t"));
console.log(val.lastIndexOf("t"));
console.log(val.replace("te","a"));
console.log(val.slice(2));
console.log(val.split("es"));
console.log(val.substr(2,2));
function add(a,b) {
return a+b;
}
function sub(a,b) {
return a-b;
}
var Producer = require('./producer');
var producer = new Producer();
producer.on('add', function(t) {
console.log('add:', t);
});
producer.start();
// stop the clock 10 seconds after
// setTimeout(function() {
// clock.stop();
// }, 10e3)
var inherits = require('util').inherits;
var EventEmitter = require('events').EventEmitter;
var Producer = function () {
if (! (this instanceof Producer)) return new Producer();
EventEmitter.call(this);
}
module.exports = Producer;
var fs = require("fs");
var searchString = "test";
var events = require('events');
var eventEmitter = new events.EventEmitter();
var connectHandler = function connected() {
console.log('connection successful.');
eventEmitter.emit('data_received');
}
eventEmitter.on('connection', connectHandler);
eventEmitter.on('data_received', function(){
console.log('data received successfully.');
});
eventEmitter.emit('connection');
console.log("Program Ended.");
var events = require('events');
var eventEmitter = new events.EventEmitter();
var listner1 = function listner1() {
console.log('listner1 executed.');
}
var listner2 = function listner2() {
console.log('listner2 executed.');
}
eventEmitter.addListener('connection', listner1);
eventEmitter.on('connection', listner2);
var eventListeners = require('events').EventEmitter.listenerCount(eventEmitter,'connection');
console.log(eventListeners + " Listner(s) listening to connection event");
eventEmitter.emit('connection');
eventEmitter.removeListener('connection', listner1);
console.log("Listner1 will not listen now.");
eventEmitter.emit('connection');
eventListeners = require('events').EventEmitter.listenerCount(eventEmitter,'connection');
console.log(eventListeners + " Listner(s) listening to connection event");
console.log("Program Ended.");
var dt = require('./mymodule');
console.log(dt.myDateTime());
exports.myDateTime = function () {
return Date();
};
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
var books = new Array();
app.get('/book/:bookId', function (req, res) {
// Get book information
});
app.put('/book/:bookId', function (req, res) {
// Update book information
})
app.post('/book', function (req, res) {
// Create book information
})
app.delete('/book/:bookId', function (req, res) {
// Delete book information
})
var server = app.listen(23023);
console.log(books);
{
"name": "assignment01",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.17.1",
"express": "^4.15.2"
}
}
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var session = require('express-session')
app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }}))
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
var users = new Array();
var userId = 'test';
var userPass = '1234';
app.get('/login/:userId/password/:password', function (req, res) {
if (req.params.userId == userId && req.params.password == userPass) {
req.session.userId = userId;
}
res.send("Login");
});
app.get('/logout/:userId', function (req, res) {
// Logout
req.session.userId = null;
res.send("LogOut");
});
var auth = function (req, res, next) {
// Session Check
if (req.session.userId != null)
next();
else
res.send("Error");
};
app.get('/user/:userId', auth,function (req, res) {
// get User Information
res.send("OK");
});
var server = app.listen(23023);
{
"name": "assignment02",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.17.1",
"express": "^4.15.2",
"express-session": "^1.15.2"
}
}
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('hello world');
})
app.route('/book')
.get(function (req, res) {
res.send('Get a random book');
})
.post(function (req, res) {
res.send('Add a book');
})
.put(function (req, res) {
res.send('Update the book');
});
var server = app.listen(23023);
{
"name": "approute",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.15.2"
}
}
var express = require('express');
var app = express();
var birds = require('./birds');
app.get('/', function (req, res) {
res.send('hello world');
})
app.use('/birds',birds);
var server = app.listen(23023);
var express = require('express');
var router = express.Router();
router.get('/', function (req, res) {
res.send('Birds home page');
})
router.get('/about', function (req, res) {
res.send('About birds');
});
module.exports=router;
{
"name": "expressrouter",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.15.2"
}
}
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello World');
})
var server = app.listen(23023, function () {
var host = server.address().address
var port = server.address().port
console.log("Example app listening at http://%s:%s", host, port)
})
{
"name": "helloworld",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.15.2"
}
}
var express = require('express');
var app = express();
app.get('/b', function (req, res, next) {
console.log('the response will be sent by the next function ...')
next()
}, function (req, res) {
res.send('Hello from B!')
})
var cb0 = function (req, res, next) {
console.log("call by cb0");
next()
}
var cb1 = function (req, res, next) {
console.log("call by cb1");
res.send('Hello from C!')
}
app.get('/c', [cb0, cb1])
var server = app.listen(23023);
{
"name": "multiplehandler",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.15.2"
}
}
var express = require('express');
var app = express();
app.set('view engine', 'ejs');
app.set('views', 'views');
app.get('/', function(req, res) {
res.render('index', { title: 'OSS Page' });
});
var server = app.listen(23023);
{
"name": "render",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"ejs": "^2.5.6",
"express": "^4.15.2"
}
}
var express = require('express');
var app = express();
app.get('/users/:userId/books/:bookId', function (req, res) {
res.send(req.params);
})
var server = app.listen(23023);
{
"name": "routeparameter",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.15.2"
}
}
var express = require('express');
var app = express();
// The routing path matches requests to /about
app.get('/about', function (req, res) {
res.send('about')
})
// The routing path matches requests to /random.text
app.get('/random.text', function (req, res) {
res.send('random.text')
})
// This route path matches abcd, abxcd, abRANDOMcd, ab123cd, and so on.
app.get('/ab*cd', function (req, res) {
res.send('ab*cd')
})
var server = app.listen(23023);
{
"name": "routingpath",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.15.2"
}
}
var express = require('express');
var app = express();
var session = require('express-session')
app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 60000 }}))
app.get('/', function(req, res, next) {
var sess = req.session;
console.log(req.session);
if (sess.views) {
sess.views++;
res.send("session Views " + sess.views);
res.send();
} else {
req.session.views = 1;
res.send("welcome to the session demo. refresh!");
res.end();
}
});
var server = app.listen(23023);
{
"name": "session",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.15.2",
"express-session": "^1.15.2"
}
}
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('hello world');
})
var server = app.listen(23023);
{
"name": "simplerouting",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.15.2"
}
}
var express = require('express');
var app = express();
app.all('/', function (req, res, next) {
console.log('Accessing the secret section ...')
next() // pass control to the next handler
})
app.get('/', function (req, res) {
res.send('hello world');
})
app.post('/', function (req, res) {
res.send('POST request to the homepage')
})
var server = app.listen(23023);
{
"name": "specialrouting",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.15.2"
}
}
var express = require('express');
var app = express();
app.use(express.static('public'));
app.get('/', function (req, res) {
res.send('Hello World');
})
var server = app.listen(23023);
{
"name": "staticfiles",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.15.2"
}
}
US President Donald Trump said no nation should underestimate American resolve, as he arrived in Japan at the start of a marathon Asian tour.
Addressing US troops at Yokota air base near Tokyo, he pledged to ensure the military had the resources needed to keep peace and defend freedom.
Mr Trump's visit comes amid heightened tensions with North Korea over its nuclear programme and missile tests.
It will be the longest tour of Asia by a US president in 25 years.
"No-one, no dictator, no regime... should underestimate American resolve," President Trump told cheering US and Japanese troops shortly after his arrival in Japan.
Before touching down, he told reporters on board Air Force One that he expected to meet Russian President Vladimir Putin during his trip.
"I think it's expected we'll meet with Putin," he said. "We want Putin's help on North Korea."
Mr Trump was meeting Japanese Prime Minister Shinzo Abe for lunch before the two leaders were due to play a round of golf.
Stops in South Korea, China, Vietnam and the Philippines are also on the itinerary in the coming week.
West Ham manager Slaven Bilic says he is under "big pressure" and in a "very difficult" situation after Saturday's 4-1 Premier League defeat by Liverpool.
Thousands of Hammers supporters left London Stadium early for the second home game in a row as the Hammers were left a point above the bottom three.
"The pressure mounts game by game and at this moment it is big," Bilic, 49, told BBC Sport.
"We will see what the club will do. The club is above everyone."
West Ham have lost three of their past four games at London Stadium and were unable to cope with Liverpool's pace on the counter-attack throughout Saturday's game.
Mohamed Salah scored twice for the visitors, with Joel Matip and Alex Oxlade-Chamberlain also on target. Manuel Lanzini briefly gave West Ham home by making it 2-1.
For less than a month’s rent in her hometown of Vancouver, Lydia Lee is having a second storey built onto the villa she rents on the tropical island of Bali.
Relocating to Indonesia seven years ago has meant she’s been able to build her business and afford a much more lavish lifestyle than she could at home. A life coach, Lee can now eat out every day, employ a cleaner and get weekly massages.
She ditched her six-figure salary in marketing and business development and now works for herself and travels the world. But relocating overseas doesn’t always work out so well financially.
Financial shocks
Not all expats find they can afford to live the high-life. InterNations, a networking resource for expats, recently surveyed more than 12,500 people living in 188 countries or territories and the picture the data paint of their finances is remarkably diverse.
#!/bin/bash
FILES=${1}
if [ ${#} -ne 1 ]
then
echo "Usage : psget process_name"
fi
#!/bin/bash
FILES=${1}
if [ ${#} -ne 1 ]
then
echo "Usage : rv files or directories"
fi
#!/bin/bash
DIRECTORY=${1}
if [ ${#} -ne 1 ]
then
echo "Usage : $0 directory"
fi
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.