Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jfoclpf's full-sized avatar

João Pimentel Ferreira jfoclpf

View GitHub Profile
@jfoclpf
jfoclpf / nodejs-multicore-example.md
Last active September 5, 2022 13:54
Node.js multi-thread for data processing and storing results in file

NodeJS is a powerful tool for backend developers, but you must be aware of multi-core processing in order to maximize the potential of your CPU. This NodeJS multi-core feature is mostly used for webservers and NodeJS has already out of the box the cluster module thereto. Although NodeJS has also out of the box the module threads used for CPU intensive jobs, it's not so easy to deal with.

Let's create a project that will test a single-thread and a multi-thread application with the task of running N iterations, each iteration doing heavy data processing and writing some random data to a file, each iteration having a different file.

Create the project:

mkdir test-threads && cd test-threads
npm init -y
@jfoclpf
jfoclpf / Apache Cordova light setup for Hello World.md
Last active May 31, 2022 13:42
TLDR for Apache Cordova light setup for Hello World (for Android)

Develop APPs simply with vanilla Javascript

The nice thing about Apache Cordova is that you can develop APPs for both Android and iOS simply using vanilla Javascript. You can then add whatever library with which you feel comfortable, like Bootstrap or jQuery, for example. You can also use ES6 if you prefer.

Apache Cordova is though a bit cumbersome to start with due to the software requirements. Furthermore if you never programmed for Android or iOS, you might feel a bit insecure with all this terminology.

Though instead of a long detailed explanation, I will just provide a short todo list on how you can have your first program to run as fast as possible. You’ll have to investigate further if you get stuck on a specific step, or feel free to leave a comment or question on the comment section below.

TLDR from official documentation

@jfoclpf
jfoclpf / getEmailAddressesFromEwsDistributionList.js
Last active March 4, 2022 15:33
Get public Distribution List email addresses from Microsoft EWS with Javascript, for MS Office JS API
// this will get an Array of Email addresses from Public Distribution List stored in Exchange Server
getDLFromEws('publiclist@example.com', (err, res) => {
if (!err) {
console.log(res)
}
})
function getDLFromEws (emailAddress, callback) {
const DLRequest = generateDistributionListSoapRequest(emailAddress)
console.log('request:', prettifyXml(DLRequest))
@jfoclpf
jfoclpf / pureJSUploadDownloadForCordova.md
Last active January 9, 2021 14:02
Pure Vanilla Javascript download and upload functions for Apache Cordova

Pure Vanilla Javascript download and upload functions for Apache Cordova

The cordova plugin cordova-plugin-file-transfer is due to be deprecated and its latest npm version fails on iOS.

Therefore these two working functions are purely based on JS, and thus no need to use extra plugins, besides the standard plugin cordova-plugin-file. Therefore this is compatible with any platform.

// for different types of cordovaFileSystem check here: 
// https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/#where-to-store-files
// or simply type in the console `console.log(cordova.file)`
@jfoclpf
jfoclpf / minification_apachecordova.md
Last active September 2, 2022 19:17
How to minify html, css and js files in Apache Cordova

How to minify html, css and js files in Apache Cordova

Problem

Minifying assets in Apache Cordova helps you to reduce the size of your apk or aab file, and also allows you to uglify any sensible information you may have therein. The minification should be done to all assets, specifically html, css and js files after cordova prepare, that is, before cordova compile.

What to minify

The files to be minified should obey the following pattern, inside your www dir:

./**/*.html # all .html files
@jfoclpf
jfoclpf / cordova_handlebars.md
Last active January 10, 2021 18:24
How to use Handlebars with Apache Cordova

How to use Handlebars with Apache Cordova

Problem

Apache Cordova deals poorly with html, since native html does not allow partial files nor templates. I solved that with standard Handlebars because it allowed me to structure my html, but still having a full complete single html file produced after cordova prepare and before cordova compile. That is, contrary to jQuery with load, the html partial files are not loaded in runtime, but assembled before cordova compile. I did not want to use Handlebar templates in the browser either for the same reason. I wanted everything to be assembled before being compiled.

Structure

The html/handlebars file structure will be something like this inside your www dir: