Skip to content

Instantly share code, notes, and snippets.

View lucasjellema's full-sized avatar

Lucas Jellema lucasjellema

View GitHub Profile
@lucasjellema
lucasjellema / oow2017-api-call.js
Created August 10, 2017 06:11
Scraping for Oracle OpenWorld 2017 Session Catalog (well, actually just calling the REST API)
var request = require("request");
var fs = require("fs");
// this options object is constructed based on the network calls the web application at https://events.rainfocus.com/catalog/oracle/oow17/catalogoow17 is making to its backend API
var options = {
method: 'POST',
url: 'https://events.rainfocus.com/api/search',
headers:
{
'cache-control': 'no-cache',
'content-type': 'application/x-www-form-urlencoded'
@lucasjellema
lucasjellema / app.js
Created August 20, 2017 06:42
Oracle JET - Table Filtering with multiselect filter and search field filter (with Node REST API)
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');
@lucasjellema
lucasjellema / SourceSelection.vue
Last active December 19, 2018 21:57
Vu2.js 2: Using HTML5 Input plus Data List for auto-suggest entry field. Based on blog article https://medium.com/codingthesmartway-com-blog/vue-js-2-vue-resource-real-world-vue-application-with-external-api-access-c3de83f25c00 that creates simple Vue.js 2 application with content from news api
<template>
<div class="sourceselection">
<div>
<div class="jumbotron">
<h2><span class="glyphicon glyphicon-list-alt"></span>&nbsp;News List</h2>
<h4>Select News Source</h4>
<input v-model="source" list="newssources-list" v-on:input="sourceChanged"
name="source-selection" id="source-selection" class="form-control"
placeholder="Please specify news source ..."/>
<datalist id="newssources-list">
@lucasjellema
lucasjellema / neo4j-node.js
Created December 31, 2018 17:10
Node JS code to load JSON document with countries and prepare some useful Sets with unique collections of data from the JSON document
var countriesDocumentURL = "https://raw.githubusercontent.com/mledoze/countries/master/countries.json"
request(countriesDocumentURL, async function (error, response, body) {
var countries = JSON.parse(body)
// get unique region values (see: https://codeburst.io/javascript-array-distinct-5edc93501dc4)
// take all elements in the countries array, for each of them: take the region element; create a Set of all the resulting region values (a Set contains unique elements)
var regions = [...new Set(countries.map(country => country.region))]
var subregions = [...new Set(countries.map(country => country.subregion))]
// see https://stackoverflow.com/questions/39837678/why-no-array-prototype-flatmap-in-javascript for this flatMap function
const flatMap = (f, xs) =>
@lucasjellema
lucasjellema / node-generator.js
Created April 24, 2019 19:23
ES 2018 Asynchronous Iterator (async generator function and await for..of loop) - foundation for pipelined and nevery ending generator functions
// asynchronous generator - read in await for..of loop
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}
const lg = (msg) => {
const d = new Date()
console.log(`${d.getSeconds()}:${d.getMilliseconds()} - ${msg}`)
}
const alphabet = async function* () {
@lucasjellema
lucasjellema / sensor-analysis-0.js
Last active April 29, 2019 04:47
ES 2018 Demonstration of Promises, Asynchronous Generators and Pipelining (requires Node 10 or higher)
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, Math.floor(milliseconds)))
}
const lg = (msg) => {
const d = new Date()
console.log(`${d.getSeconds()}.${Math.round(d.getMilliseconds() / 100)} - ${msg}`)
}
// each sensor has a slightly randomized timeput period, suggesting a different and somewhat varying production rate of measurements
@lucasjellema
lucasjellema / pancake-party-0.js
Last active April 29, 2019 09:36
Simulating a birthday party where pancakes are served - this gist describes a naïve approach (no parallel or aysnchronous processing, no use of pipelining) and a smart approach (where those mechanisms are employed). The code demonstrates the use of asynchronous generators in combination with promises.
// pancake party for my son's birthday
// I have promised him pancakes. Each pancake has to be baked, decorated (syrup, sugar, jam, ..) and sliced (in bite size sections)
const numberOfGuests = 8
// assuming each guest eats exactly three pancakes
const totalNumberOfPancakes = numberOfGuests * 3
const numberOfPans = 1
// times in milliseconds
const timeToBakeOnePancake = 3000;
@lucasjellema
lucasjellema / pipelined-sensor-analysis-0
Created May 1, 2019 05:17
ES 2018 Demonstration of Promises, Asynchronous Generators and Pipelining (requires Node 10 or higher) for running agregates
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, Math.floor(milliseconds)))
}
const lg = (msg) => {
const d = new Date()
console.log(`${d.getSeconds()}.${Math.round(d.getMilliseconds() / 100)} - ${msg}`)
}
// each sensor has a slightly randomized timeput period, suggesting a different and somewhat varying production rate of measurements
@lucasjellema
lucasjellema / pipelined-sensor-analysis-1.js
Created May 1, 2019 05:19
ES 2018 Demonstration of Promises, Asynchronous Generators and Pipelining (requires Node 10 or higher) - Time Windowed Aggregates
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, Math.floor(milliseconds)))
}
const lg = (msg) => {
const d = new Date()
console.log(`${d.getSeconds()}.${Math.round(d.getMilliseconds() / 100)} - ${msg}`)
}
// each sensor has a slightly randomized timeput period, suggesting a different and somewhat varying production rate of measurements
@lucasjellema
lucasjellema / pipelined-sensor-analysis-1.js
Created May 1, 2019 05:19
ES 2018 Demonstration of Promises, Asynchronous Generators and Pipelining (requires Node 10 or higher) - Time Windowed Aggregates
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, Math.floor(milliseconds)))
}
const lg = (msg) => {
const d = new Date()
console.log(`${d.getSeconds()}.${Math.round(d.getMilliseconds() / 100)} - ${msg}`)
}
// each sensor has a slightly randomized timeput period, suggesting a different and somewhat varying production rate of measurements