ultimate node.js countdown - doag deutsche oracle ... · oracle-db https grunt socket.io ......

151
Ultimate Node.js countdown Alan Arentsen the coolest APEX examples http://10.30.4.108 please logon to:

Upload: ngotu

Post on 05-Jun-2018

238 views

Category:

Documents


0 download

TRANSCRIPT

Ultimate Node.js countdown

Alan Arentsen

the coolest APEX examples

http://10.30.4.108

please logon to:

@alanarentsen

alanarentsen.blogspot.com

http://10.30.4.108

http://10.30.4.108

Fast

Trustworthy

Scalable

Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for

data-intensive real-time applications that run across distributed devices.

Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for

data-intensive real-time applications that run across distributed devices.

http websocket

rest

oracle-db

https

grunt

socket.io

python uglify-js

soap-q

gulp

mysql

dropbox

http websocket

rest

oracle-db

https

grunt

socket.io

python uglify-js

soap-q

gulp

mysql

dropbox

http websocket

rest

oracle-db

https

grunt

socket.io

python uglify-js

soap-q

gulp

mysql

filbert

moment

q-superagent

async jshint

browserify

stylus

cheerio hapi

less

forever

chalk redis

underscore

mocha

sails

mongoose

commander

express

connect

nodemailer

mongodb-q mkdir

bower

awesome passport

optimist lodash

colors

q jade

validator

dropbox

//websockets

$(function() {

});

window.WebSocket = window.WebSocket || window.MozWebSocket;

if (!window.WebSocket) {

console.log('There is no websocket API available.');

}

} else if (typeof(ws_connection) !== 'undefined') {

console.log('There is a websocket live connection.');

}

else {

ws_connection = new WebSocket('ws://192.168.56.12:4880/&APP_USER.‘

,'echo-protocol');

ws_connection.onmessage = function(message) {

}

}

var jsonMsg = JSON.parse(message.data);

console.log('Received: ' + message.data);

apex.event.trigger(document, jsonMsg.task, jsonMsg.payload);

How do we do it….

How do we do it…. together

Chatbox

Group DEMO

http://10.30.4.108

Auto Refresh Report

function reportrefresh_Callback(staticID) {

$('#' + staticID).trigger('apexrefresh');

};

var intervalID = window.setInterval(reportrefresh_Callback('EMP'), 5000);

function reportrefresh_Callback(staticID) {

$('#' + staticID).trigger('apexrefresh');

};

var intervalID = window.setInterval(reportrefresh_Callback('EMP'), 5000);

Group DEMO

http://10.30.4.108

Websockets

apex.event.trigger(document, jsonMsg.task, jsonMsg.payload);

Event: Custom

Event: Custom

Custom Event: refresh_emp

Event: Custom

Custom Event: refresh_emp

Selection Type: JavaScript Expression

Event: Custom

Custom Event: refresh_emp

Selection Type: JavaScript Expression

Javascript Expression: document

Selfiestick

Group DEMO

http://10.30.4.108

declare

v_id number;

begin

begin

select usr.id

into v_id

from unc_users usr

where usr.username <> 'ADMIN'

and usr.userkey is not null

and usr.selfie is not null

order by dbms_random.value;

exception

when no_data_found

then v_id := null;

end;

apex_util.set_session_state('P6_RANDOM_ID', v_id);

end;

declare

v_id number;

begin

begin

select usr.id

into v_id

from unc_users usr

where usr.username <> 'ADMIN' and usr.userkey is not null

and usr.selfie is not null

order by dbms_random.value;

exception

when no_data_found

then v_id := null;

end;

apex_util.set_session_state('P6_RANDOM_ID', v_id);

end;

oracle_db

oracle = function() {

this.oracledb = require("oracledb");

};

oracle.prototype.insertUser = function(p_username, p_remoteaddress, p_userkey) {

this.oracledb.getConnection({

user: this.db_user,

password: this.db_password,

connectString: this.db_connectionstring

},

function(err, connection) {

//put your code to handle the callback here

});

};

oracle = function() {

this.oracledb = require("oracledb");

};

oracle.prototype.insertUser = function(p_username, p_remoteaddress, p_userkey) {

this.oracledb.getConnection({

user: this.db_user,

password: this.db_password,

connectString: this.db_connectionstring

},

function(err, connection) {

//put your code to handle the callback here

});

};

oracle = function() {

this.oracledb = require("oracledb");

};

oracle.prototype.insertUser = function(p_username, p_remoteaddress, p_userkey) {

this.oracledb.getConnection({

user: this.db_user,

password: this.db_password,

connectString: this.db_connectionstring

},

function(err, connection) {

//put your code to handle the callback here

});

};

function(err, connection) {

if (err) {

console.error(err.message);

return;

}

connection.action = "insertUser";

connection.module = process.title;

var sqlstatement = "merge into unc_users usr \

using (select :username username \

,:remoteaddress remoteaddress \

,:userkey userkey \

from dual) usr1 \

on (usr.username = usr1.username) \

when matched then \

update set usr.userkey = usr1.userkey \

when not matched then \

insert (username, remoteaddress, userkey)

values (usr1.username, usr1.remoteaddress, usr1.userkey)";

function(err, connection) {

if (err) {

console.error(err.message);

return;

}

connection.action = "insertUser";

connection.module = process.title;

var sqlstatement = "merge into unc_users usr \

using (select :username username \

,:remoteaddress remoteaddress \

,:userkey userkey \

from dual) usr1 \

on (usr.username = usr1.username) \

when matched then \

update set usr.userkey = usr1.userkey \

when not matched then \

insert (username, remoteaddress, userkey)

values (usr1.username, usr1.remoteaddress, usr1.userkey)";

function(err, connection) {

if (err) {

console.error(err.message);

return;

}

connection.action = "insertUser";

connection.module = process.title;

var sqlstatement = "merge into unc_users usr \

using (select :username username \

,:remoteaddress remoteaddress \

,:userkey userkey \

from dual) usr1 \

on (usr.username = usr1.username) \

when matched then \

update set usr.userkey = usr1.userkey \

when not matched then \

insert (username, remoteaddress, userkey)

values (usr1.username, usr1.remoteaddress, usr1.userkey)";

function(err, connection) {

if (err) {

console.error(err.message);

return;

}

connection.action = "insertUser";

connection.module = process.title;

var sqlstatement = "merge into unc_users usr \

using (select :username username \

,:remoteaddress remoteaddress \

,:userkey userkey \

from dual) usr1 \

on (usr.username = usr1.username) \

when matched then \

update set usr.userkey = usr1.userkey \

when not matched then \

insert (username, remoteaddress, userkey)

values (usr1.username, usr1.remoteaddress, usr1.userkey)";

select v.action

,v.module

,v.sql_text

from v$sql v

where v.parsing_schema_name = 'SANDBOX'

function(err, connection) {

if (err) {

console.error(err.message);

return;

}

connection.action = "insertUser";

connection.module = process.title;

var sqlstatement = "merge into unc_users usr \

using (select :username username \

,:remoteaddress remoteaddress \

,:userkey userkey \

from dual) usr1 \

on (usr.username = usr1.username) \

when matched then \

update set usr.userkey = usr1.userkey \

when not matched then \

insert (username, remoteaddress, userkey)

values (usr1.username, usr1.remoteaddress, usr1.userkey)";

connection.execute(sqlstatement

,[p_username, p_remoteaddress, p_userkey]

,{autoCommit: true}

,function(err, result) {

if (err) {

console.error(err.message);

return;

}

});

}

Google Maps

Group DEMO

http://10.30.4.108

DBMS_JOB

declare

jid pls_integer;

begin

dbms_job.submit (jid

,'begin

//do the job

end;'

);

end;

declare

jid pls_integer;

begin

dbms_job.submit (jid

,'begin

//do the job

end;'

);

end;

Group DEMO

http://10.30.4.108

Progress Bar

declare

jid pls_integer;

begin

dbms_job.submit (jid

,'begin

//do the job

end;'

);

end;

declare

jid pls_integer;

begin

dbms_job.submit (jid

,'begin

//do the job

end;'

);

end;

10%

declare

jid pls_integer;

begin

dbms_job.submit (jid

,'begin

//do the job

end;'

);

end;

20%

declare

jid pls_integer;

begin

dbms_job.submit (jid

,'begin

//do the job

end;'

);

end;

30%

declare

jid pls_integer;

begin

dbms_job.submit (jid

,'begin

//do the job

end;'

);

end;

40%

declare

jid pls_integer;

begin

dbms_job.submit (jid

,'begin

//do the job

end;'

);

end;

50%

declare

jid pls_integer;

begin

dbms_job.submit (jid

,'begin

//do the job

end;'

);

end;

60%

declare

jid pls_integer;

begin

dbms_job.submit (jid

,'begin

//do the job

end;'

);

end;

70%

declare

jid pls_integer;

begin

dbms_job.submit (jid

,'begin

//do the job

end;'

);

end;

80%

declare

jid pls_integer;

begin

dbms_job.submit (jid

,'begin

//do the job

end;'

);

end;

90%

declare

jid pls_integer;

begin

dbms_job.submit (jid

,'begin

//do the job

end;'

);

end;

100%

Group DEMO

http://10.30.4.108

apex_web_service.make_rest_request(

p_url => 'http://192.168.56.12:4880/',

p_http_method => 'PUT',

p_body => '{"task" : "dbms_job_ready"

,"payload": {"job": job_identifier}}'

);

apex_web_service.make_rest_request(

p_url => 'http://192.168.56.12:4880/',

p_http_method => 'PUT',

p_body => '{"task" : "dbms_job_ready"

,"payload": {"job": job_identifier}}'

);

req.on('data', function(data) {

var body = JSON.parse(data.toString());

if (body.task == 'dbms_job_ready') {

//code to send dbms_job_ready event to clients

} else if (body.task == 'dbms_job_status') {

var msgStringOut = JSON.stringify({task : body.task

,payload: {job : body.payload.job

,perc: body.payload.percentage}

});

for(var i in clients){

clients[i].sendUTF(msgStringOut);

};

resp.end(JSON.stringify({ message: 'Send to '+ clients.length + ' clients‘

}));

};

);

req.on('data', function(data) {

var body = JSON.parse(data.toString());

if (body.task == 'dbms_job_ready') {

//code to send dbms_job_ready event to clients

} else if (body.task == 'dbms_job_status') {

var msgStringOut = JSON.stringify({task : body.task

,payload: {job : body.payload.job

,perc: body.payload.percentage}

});

for(var i in clients){

clients[i].sendUTF(msgStringOut);

};

resp.end(JSON.stringify({ message: 'Send to '+ clients.length + ' clients‘

}));

};

);

req.on('data', function(data) {

var body = JSON.parse(data.toString());

if (body.task == 'dbms_job_ready') {

//code to send dbms_job_ready event to clients

} else if (body.task == 'dbms_job_status') {

var msgStringOut = JSON.stringify({task : body.task

,payload: {job : body.payload.job

,perc: body.payload.percentage}

});

for(var i in clients){

clients[i].sendUTF(msgStringOut);

};

resp.end(JSON.stringify({ message: 'Send to '+ clients.length + ' clients‘

}));

};

);

req.on('data', function(data) {

var body = JSON.parse(data.toString());

if (body.task == 'dbms_job_ready') {

//code to send dbms_job_ready event to clients

} else if (body.task == 'dbms_job_status') {

var msgStringOut = JSON.stringify({task : body.task

,payload: {job : body.payload.job

,perc: body.payload.percentage}

});

for(var i in clients){

clients[i].sendUTF(msgStringOut);

};

resp.end(JSON.stringify({ message: 'Send to '+ clients.length + ' clients‘

}));

};

);

req.on('data', function(data) {

var body = JSON.parse(data.toString());

if (body.task == 'dbms_job_ready') {

//code to send dbms_job_ready event to clients

} else if (body.task == 'dbms_job_status') {

var msgStringOut = JSON.stringify({task : body.task

,payload: {job : body.payload.job

,perc: body.payload.percentage}

});

for(var i in clients){

clients[i].sendUTF(msgStringOut);

};

resp.end(JSON.stringify({ message: 'Send to '+ clients.length + ' clients‘

}));

};

);

req.on('data', function(data) {

var body = JSON.parse(data.toString());

if (body.task == 'dbms_job_ready') {

//code to send dbms_job_ready event to clients

} else if (body.task == 'dbms_job_status') {

var msgStringOut = JSON.stringify({task : body.task

,payload: {job : body.payload.job

,perc: body.payload.percentage}

});

for(var i in clients){

clients[i].sendUTF(msgStringOut);

};

resp.end(JSON.stringify({ message: 'Send to '+ clients.length + ' clients‘

}));

};

);

Dropbox

Group DEMO

http://10.30.4.108

dropbox = function() {

this.dropbox_pkg = require("dropbox");

this.dropbox_client = new dropbox_pkg.Client({"key" : this.db_key

,"secret" : this.db_secret

,"token" : this.db_token

,"sandbox": false});

};

dropbox = function() {

this.dropbox_pkg = require("dropbox");

this.dropbox_client = new dropbox_pkg.Client({"key" : this.db_key

,"secret" : this.db_secret

,"token" : this.db_token

,"sandbox": false});

};

dropbox.prototype.getAccountInfo = function(callback) {

this.dropbox_client.getAccountInfo(function(error, accountInfo) {

if (error) {

callback(error, null);

return;

}

callback(null, accountInfo);

});

};

dropbox.getAccountInfo(function(error, accountInfo){

//put your code to handle the callback here

});

dropbox.prototype.getAccountInfo = function(callback) {

this.dropbox_client.getAccountInfo(function(error, accountInfo) {

if (error) {

callback(error, null);

return;

}

callback(null, accountInfo);

});

};

dropbox.getAccountInfo(function(error, accountInfo){

//put your code to handle the callback here

});

dropbox.prototype.getAccountInfo = function(callback) {

this.dropbox_client.getAccountInfo(function(error, accountInfo) {

if (error) {

callback(error, null);

return;

}

callback(null, accountInfo);

});

};

dropbox.getAccountInfo(function(error, accountInfo){

//put your code to handle the callback here

});

https://www.chromeexperiments.com/experiment/world-wide-maze

http://dinahmoelabs.com/plink

Some fun stuff to look at

Alan Arentsen [email protected]

alanarentsen.blogspot.com