Friday, November 29, 2019

Difference between Dynamic Programming & Divide And Conquer

https://en.wikipedia.org/wiki/Dynamic_programming

There are two key attributes that a problem must have in order for dynamic programming to be applicable: optimal substructure and overlapping sub-problems. If a problem can be solved by combining optimal solutions to non-overlapping sub-problems, the strategy is called "divide and conquer" instead.[1] This is why merge sort and quick sort are not classified as dynamic programming problems.

RSA Encryption Algorithm


Wednesday, November 27, 2019

An educated mind

Aristotle famously stated that the mark of an educated mind is the ability to entertain a thought without accepting it.

Intro to B-Trees

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);

//

Thursday, October 24, 2019

Firebase related

Data Structures related

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

brew tap mongodb/brew  
brew install mongodb-community@4.0
4) brew link --force mongodb-community@4.0
brew services start mongodb-community@4.0
5) Restore data
cd mongodb-dump-oct24-2019
mongorestore

Sunday, September 22, 2019

'less' related

To search for 1st occurrence from top of file:
less +/FATAL log/production.log

To search for 1st occurrence from bottom of file:
less +?"Processing by" log/production.log


Linux - Tools, System Administration Basics

Monday, September 16, 2019

Thursday, August 29, 2019

Open Source related - 'Funding' Experiment Recap

Very interesting and thought-provoking article about Funding for OSS
https://feross.org/funding-experiment-recap/
However the comments section also includes this very valid comment from Mjölnir :
There were numerous valid concerns like the ones I'm raising now. You've only cherry-picked the most positive ones and used them to support your arguments. Yes there was an inundation of responses and I'm sure it's not easy to be at the receiving end of so much derision but there were TONS of valid concerns and dismissing the VAST majority of people in the ecosystems with such a flagrant disregard for conflicting opinions does not bode well
More comments over here - https://www.reddit.com/r/programming/comments/cwwe8c/recap_of_the_funding_experiment_ferossorg/


Thursday, August 22, 2019

Seated-Meditation vs Seated-Programming

"It's thought that KungFu was developed by the early Chinese monks as a way to stay fit enough for hours of seated meditation."




Seated Programming/Studying is not very different from Seated-Meditation.
Hence, the need for being extremely fit for hours of seated-meditation applies to seated-studying/programming as well.

Monday, August 19, 2019

mysql2 gem problems on Mac

https://github.com/brianmario/mysql2/issues/1005

commented on 26 Oct 2018

To fix for a manual gem install:
brew install openssl
gem install mysql2 -- --with-opt-dir="$(brew --prefix openssl)"
To fix for all bundle installs:
brew install openssl
bundle config --global build.mysql2 --with-opt-dir="$(brew --prefix openssl)"
bundle install

Saturday, August 3, 2019

Web Components

State of Web Components (2019) -
https://medium.com/swlh/the-state-of-web-components-e3f746a22d75

Web Components - The Secret Ingredient Helping Power The Web


Embedded Systems Tutorials

Crash Course in Lisp

Elixir related - Concurrency & Absinthe, Temple HTML library, Elixir + Kubernetes, How Elixir helped improve performance, setup Phoenix + PostgreSQL using docker-compose

https://www.reddit.com/r/elixir/comments/ckihkc/i_thought_concurrency_was_a_big_thing/ - A discussion about concurrency and Elixir libraries like Absinthe.

https://www.mitchellhanberg.com/introducing-temple-an-elegant-html-library-for-elixir-and-phoenix - Introducing Temple: An elegant HTML library for Elixir and Phoenix

https://bbhoss.io/posts/announcing-cainophile/ - a library to assist you in building change data capture (CDC) systems in Elixir. With Cainophile, you can quickly and easily stream every change made to your PostgreSQL database, with no plugins, Java, or Zookeeper required.

https://itnext.io/elixir-plus-kubernetes-part-1-80129eab14f0? - Elixir + Kubernetes

https://selleo.com/blog/how-elixir-helped-me-boost-app-performance - How Elixir Helped Me Boost App Performance

https://medium.com/@ricardo.trindade743/setting-up-phoenix-postgresql-with-docker-compose-for-local-development-afeb4a4ace6c - Setting up Phoenix + PostgreSQL with docker-compose for local development


Sunday, July 28, 2019

Chinese Banking revolution - Use of big data and artificial-intelligence technology to give loans to Small Businesses

 Chinese Banking revolution - Use of big data and artificial-intelligence technology to give loans to Small Businesses:

https://economictimes.indiatimes.com/news/international/business/jack-mas-290-billion-loan-machine-is-changing-chinese-banking/articleshow/70418197.cms

Excerpts:
One uniquely Chinese source of information for banks is the government-administered social credit system, which is being tested in cities across the country as a way to reward good deeds and punish misbehavior. In one potential scenario cited by MYbank President Jin Xiaolong in a recent interview, a small-business owner whose social credit score dropped because he failed to return a borrowed umbrella would find it harder to get a loan. 

But the biggest data trove may come from payments providers like the one operated by Ma’s Ant Financial, the biggest shareholder of MYbank. After obtaining authorization from borrowers, MYbank analyzes real-time transactions to gain insights into creditworthiness. For example, a drop in customer payments at a retailer’s flagship store might be an early indicator that the company’s prospects -- and its ability to repay debt -- are deteriorating. 

The upshot of more information is a loan approval rate at MYbank that’s four times higher than at traditional lenders, which typically reject 80% of small-business loan requests and take at least 30 days to process applications, according to Jin, who plans to double MYbank’s roster of borrowers in three years. He said the Hangzhou-based firm’s operating cost per loan is about 3 yuan, versus 2,000 yuan at traditional rivals. 


Friday, July 19, 2019

Understanding Enough awk to Search Piles of Files and Text

Yes silver bullet by Mark Seemann

https://blog.ploeh.dk/2019/07/01/yes-silver-bullet/
Excerpts:
So it is with technology improvements. Automated testing is available, but not ubiquitous. Git is free, but still organisations stick to suboptimal version control. Haskell and F# are mature languages, yet programmers still program in C# or Java.
....
.... 
If you accept my argument, that order-of-magnitude improvements appeared after 1986, this implies that Brooks' premise was wrong. In that case, there's no reason to believe that we've seen the last significant improvement to software development.
I think that more such improvements await us. I suggest that statically typed functional programming offers such an advance, but if history teaches us anything, it seems that breakthroughs tend to be unpredictable.

Scene.js - Library to Create Timeline-Based Animation

Sunday, June 16, 2019

DevOps Tutorial for Beginners



Intellipaat DevOps course: https://intellipaat.com/devops-certif... In this devops tutorial for beginners video you will learn devops end to end right from what is devops, various devops tools it has like docker, git, jenkins, chef, kubernetes, nagios, puppet, ansible in detail.

https://intellipaat.com/tutorial/devops-tutorial/

how SignalR manages connection between multiple server using a back plane?

Things I Wish Someone Told Me About ASP.NET Core WebSockets (June 5 2018)

.Net related: Blazor

Rust related: Actix & Actix Web framework

OTP -> rust Actix, Phoenix -> actix-web, Ecto -> diesel

https://actix.rs/
https://github.com/actix/actix
https://github.com/actix/actix-web

Sunday, June 9, 2019

Would you still pick Elixir in 2019? (github.com) - continuation - comparison with Scala/Akka


An interesting question  and discussion related to Elixir for same link as previous post:


Does anyone have experience with Elixir as well as Scala/Akka. Afaik, these are the two largest Erlang inspired systems out there. I only have experience with Akka, and I'd love to hear a comparison.

I have experience with both. I have recently been working with Elixir. It's okay. I find the lack of static typing to be some thing I celebrate and curse. Elixir is VERY simple and beam is VERY slow at computation. I wouldn't recommend anyone working with scala/akka look at elixir unless you want to understand how BEAM works but I would recommend _everyone_ working with elixir learn different functional programming languages. Ultimately I'm much happier writing scala with akka. I get more done faster (except things like handling json sometimes because it's hard with types), can refactor the code more freely, and release less broken code to production.

Also, I have to say that elixir developers are generally not very experienced with it and seem to be generally less desirable than the people who are working with scala. You get rubyists that have some interest in working with elixir because there were some blog posts saying it's the new hotness. Scala seems to attract more comp-sci savvy people. And generally those people will refuse to work with elixir when there are Scala job out there that will pay. Startups should use scala for these reasons. Elixir may be a mistake for the resource pool alone.
One thing that's trecherous is that rubyists can bring whatever they believe to be the right way to do things and assume everything should be exactly the same, especially with regards to ecto vs active record. Elixir isn't ruby. Ecto isn't rails active record. Not anywhere close. It just happens to look like ruby and there are some influences in the design but Ecto tells you not too implement STI like rails does for example so don't assume you're going to do it like you would in rails. I'd argue ruby is more like scala than it is like elixir as it has multiple paradigms. Elixir is squarely functional, just a very very simple functional language. The skill ceiling is pretty low and it should take very little time for someone to get up to speed which is important because you won't find a big pool of rockstars using it in the job market so you'll have to hire good people without experience and hope they will be okay using elixir and not jump ship to go work with strong typed languages.

> Also, I have to say that elixir developers are generally not very experienced with it and seem to be generally less desirable than the people who are working with scala.
Scala has been around for 14 years and is built on top of a much more used VM compared to Elixir. Given Scala's growth, it is expected that Scala developers are more experienced as they have been around for longer. Scala also had more time to spread to comp-sci fields, especially as it is taught by many universities. All thanks to Scala's merits, of course!
So while I agree that experience is a factor, I wouldn't draw conclusions that those are intrinsic to Elixir or to its users. I also have heard of companies that had no trouble to hire Elixir developers (some have 80 Elixir devs and growing) and some that had many difficulties. As with any other technology, YMMV.

Scala/Akka has a much worse developer experience than Elixir/Phoenix. BEAM is fairly slow but you can make FFI calls into much faster implementations if your workload is CPU bound (most of the workloads I am familiar with in the web world are not).
Release less broken code to production? I am not sure about it either.

I've used both in production and I must say I'm a very big proponent of both. Actor model of concurrent computation I think maps very well to, at least my, way of thinking and I think is the most productive way of writing distributed systems.
Elixir/Erlang/OTP: + Very mature, very well thought out. While the newer stuff may feel a still under construction (string handling, date handling) all the concurrency primitives are rock solid, and by rock I mean diamond. + Elixir is simply a great language and you can get quickly very productive in it once you grasp the actor/process model of BEAM + Has one very big advantage over akka that actors can receive messages in different order than they were sent. That of course can cause some headaches if not handled carefully, but 99% of the time straight up leads to nicer and simpler programs. Really a lot of akka code very often is just written to deal with the order in which the messages may arrive. + Truly resilient with very good error recovery design once you know how to work with it. I still don't know more graceful and productive way of recovering from failures in a running system.
- For doing any expensive computations it's slow and it's a fact. Not much can be done about it. - Library coverage is 7/10 or 8/10, but these few missing points can sometimes make a big difference.
Scala/Akka: +/- I love Scala language and static typing, but one must be honest that it's much more complex. You can learn Elixir (without macros) in an afternoon. One really needs to take some time and think it through to utilize Scala properly and a true mastery lies even further. To be fair proficiency with Elixir macros also requires a considerable effort, but one can go very far with Elixir without writing macros, while with Scala already the upfront cost is pretty high. + Up to my best knowledge Akka Streams is completely unique and completely amazing library that is gaining support throughout library ecosystem. This is one point where Scala/Akka completely outshines everything else. Streams are such a great abstraction and gave a huge productivity boost to most of the projects I was working on. Compared to that, elixir GenStage feels much less robust and polished. + Speed of JVM should be enough for 99% of applications, and with that respect it wins with BEAM. + Java/Scala library ecosystem is very deep and is simply much more comprehensive than Elixir/Erlang one.
- There are places around akka that still feel a bit immature/adhoc, but the library is steadily improving. It just is not as mature as BEAM/OTP. - Over small and mid size projects I think I was more productive with Elixir. Meaning, if I had the same amount of time, I could implement more features in less time using Elixir. But it could be just a personal thing.
Overall I think both are fantastic platforms and I'm happy to have both of them to choose for each project. If I were to chose what to select today:
- Choose Elixir/OTP for a system where we need to do a lot of io but not much computation and we're sure existing libraries cover our needs. Very big plus if we need it to be resilient. - Choose Scala/Akka if we need speed or call any existing JVM libraries. Very big plus if your project could use Akka Streams.

Agreed. The BEAM run-time and the preemptive scheduler implementation is designed to never block and keep chugging a long; highly desirable for the Actor model. The trade-off is you're further from the metal and raw-compute isn't as powerful as a JVM language like Scala. That said an Actor model on the JVM (Akka) can't make the same run-time guarantees using a cooperative scheduler; instead you get all the enterprise libraries and developer hours to tap into. So the trade-off of more complexity in Scala/Akka is probably worth it for big enterprise who are probably already in bed with the JVM.
I think we'll see more Akka features built in Elixir through things like Genstage and Flow, but it's hard to argue with the mountain of exiting developer man-hours in the JVM.

Followers

Blog Archive