Thursday, October 31, 2019
Monday, October 28, 2019
Tail-Recursion, Tail-Call Optimization
https://stackoverflow.com/questions/33923/what-is-tail-recursion
https://stackoverflow.com/questions/310974/what-is-tail-call-optimization
Examples done after reading the answers in the 1st link above:
//////////// Sum till n ////////////
//
// - normal recursion
function sumTo(n) {
return (n == 0 ? 0 : (n+sumTo(n-1)));
}
var result = sumTo(10);
console.log(result);
// - tail recursion
function sumTo2(n) {
return sumTo2_aux(n, 0);
}
function sumTo2_aux(n, acc) {
return (n == 0) ? acc : sumTo2(n-1, acc+n);
}
var result2 = sumTo2(10);
console.log(result2);
//
//////////// Factorial ////////////
//
// - normal recursion
function factorial(n) {
return (n == 1 ? 1 : n * factorial(n-1));
}
var factorial_result1 = factorial(10);
console.log(factorial_result1);
// - tail recursion
function factorial2(n) {
return factorial2_aux(n,1);
}
function factorial2_aux(n, acc){
return (n == 1 ? acc : n * factorial2_aux(n-1, acc));
}
var factorial_result2 = factorial2(10);
console.log(factorial_result2);
https://stackoverflow.com/questions/310974/what-is-tail-call-optimization
Examples done after reading the answers in the 1st link above:
//
//////////// Sum till n ////////////
//
// - normal recursion
function sumTo(n) {
return (n == 0 ? 0 : (n+sumTo(n-1)));
}
var result = sumTo(10);
console.log(result);
// - tail recursion
function sumTo2(n) {
return sumTo2_aux(n, 0);
}
function sumTo2_aux(n, acc) {
return (n == 0) ? acc : sumTo2(n-1, acc+n);
}
var result2 = sumTo2(10);
console.log(result2);
//
//////////// Factorial ////////////
//
// - normal recursion
function factorial(n) {
return (n == 1 ? 1 : n * factorial(n-1));
}
var factorial_result1 = factorial(10);
console.log(factorial_result1);
// - tail recursion
function factorial2(n) {
return factorial2_aux(n,1);
}
function factorial2_aux(n, acc){
return (n == 1 ? acc : n * factorial2_aux(n-1, acc));
}
var factorial_result2 = factorial2(10);
console.log(factorial_result2);
//
Saturday, October 26, 2019
Thursday, October 24, 2019
Uninstall Mongo old version and Install new version
1) backup data
mkdir mongodb-dump-oct24-2019
cd mongodb-dump-oct24-2019
mongodump
Above will create a folder called 'dump' within 'mongodb-dump-oct24-2019' folder.
2) Uninstall existing version of mongodb
https://medium.com/@rajanmaharjan/uninstall-mongodb-macos-completely-d2a6d6c163f9
3) Install new version
https://stackoverflow.com/questions/57856809/installing-mongodb-with-homebrew
cd mongodb-dump-oct24-2019
mongorestore
mkdir mongodb-dump-oct24-2019
cd mongodb-dump-oct24-2019
mongodump
Above will create a folder called 'dump' within 'mongodb-dump-oct24-2019' folder.
2) Uninstall existing version of mongodb
https://medium.com/@rajanmaharjan/uninstall-mongodb-macos-completely-d2a6d6c163f9
3) Install new version
https://stackoverflow.com/questions/57856809/installing-mongodb-with-homebrew
brew tap mongodb/brew
brew install mongodb-community@4.0
4) brew link --force mongodb-community@4.0brew services start mongodb-community@4.05) Restore data
cd mongodb-dump-oct24-2019
mongorestore
Monday, October 21, 2019
Wednesday, October 16, 2019
Tuesday, October 15, 2019
Monday, October 14, 2019
Video processing project
AWS Solution:
https://github.com/aws-samples/aws-media-services-vod-automation/blob/master/MediaConvert-WorkflowWatchFolderAndNotification/README-tutorial.md
Elixir:
https://elixirforum.com/t/video-processing-and-editing-in-elixir/13842
https://stackoverflow.com/questions/34246817/video-uploads-and-conversions-in-elixir-phoenix
https://github.com/aws-samples/aws-media-services-vod-automation/blob/master/MediaConvert-WorkflowWatchFolderAndNotification/README-tutorial.md
Elixir:
https://elixirforum.com/t/video-processing-and-editing-in-elixir/13842
https://stackoverflow.com/questions/34246817/video-uploads-and-conversions-in-elixir-phoenix
Monday, October 7, 2019
Friday, October 4, 2019
Wednesday, October 2, 2019
Subscribe to:
Posts (Atom)
Followers
Blog Archive
-
▼
2019
(229)
-
▼
October
(22)
- Styled Components
- Vue.js - Reactivity related
- Tail-Recursion, Tail-Call Optimization
- Docker related - How to run a Docker Container
- YAML Reference Card
- Firebase related
- Data Structures related
- Uninstall Mongo old version and Install new version
- JavaScript Destructuring ES6: The Complete Guide
- Mongodb related - elemMatch
- Ruby related - Understanding ruby load, require, g...
- Federation, SSO, Delegated vs Federated Id
- AWS & Ruby
- Ruby - find out method source code & location
- Video processing project
- AWS ElasticSearch related
- Design & Constraints
- Intro to Unix processes
- Multiprocessing in Ruby
- Javascript tutorial website
- Javascript: Cross Window communication
- Gleek - Tool for creating software diagrams
-
▼
October
(22)