Categories
Resources Software Development Web Development

yaml resources and links

Yaml is used for configuration of different software used for development.

WHY JSON ISN’T A GOOD CONFIGURATION LANGUAGE – good article that explains why yaml is better for configuration than json. When I originally encountered yaml I was like WTF another damn BS PITA I have to learn. Honestly I don’t learn this shit more than what I need to get things done. Your brain only remembers about 23% of what you learn 12 months later anyways. So trying to learn things 100% inside and out is over 75% a waste of time. LOL

Yaml website – reference card

Yaml primer – great intro on github

 

Categories
Software Development Web Development

How to install Nodejs npm nvm without sudo on linux

For a few days I have been wrestling with nvm, nodejs, php composer etc. trying to figure out why the hell I keep getting permission issues.

I followed the instructions and installed them without being the root user… or so I thought.  I completely failed to understand what was going on with permissions.

I tried to install composer and node while in the directory I usually use for my web server /var/www/app-folder .  When given permission denied errors I did the normal thing and added sudo.

I fully failed to understand WTF sudo does.

In my world, as long as I didn’t login as the root  I was still the user that is shown in the terminal myself@myself$. I figured that adding sudo kept me as the user I was shown as in the terminal.

It seems logical right, you use sudo and you never see your terminal user change to root, therefore you must not be root.

Nope when you use sudo apparently this not only elevates your privileges as a user, it totally changes you to the root user. More info about the nonsense of sudo in linux  

i am root
i am root

The reason I was getting errors and having to use sudo in the first place is because I was trying to install stuff from a folder owned by root but had permissions for group which my user was a member of.

I falsely assumed that using sudo kept me as the user I was only giving me higher privilege levels. Apparently sudo in fact makes you the root user for a short period, which is the same as sudo -i which leaves you logged in as the root.

To prevent these errors and install things not as root and not using sudo, you must be in a folder that your current user owns and is not just a member of a group of. I’ve been using Linux for a decade but never tried installing node, other software like compilers etc don’t give a shit and work.

For so long I’ve installed and built apps in /var/www/directory because that was always the default for Apache and Nginx.  This is an issue for people trying to package their node apps too from what I have read.

This creates another conundrum. Which folder should you use for web development? Which one should you put your apps in in docker containers?

The problem is, you need to research more to fully understand the implications of creating a directory with the current user as owner. You must understand what permission levels will be safe on a server. What is the minimum permissions for your user you need and still be safe?

So when installing node, nvm, npm or php composer, do it in a file your user owns. If you are installing for development you can do it right from the users Download folder for example, that one is owned by the user. But whatever you do, do not use sudo and do not install from any folder owned by root.

Link explaining file permissions

Categories
Resources Software Development

Random Links about Databases

Why Uber dropped PostgreSQL – interesting article if you are thinking about using PostgreSQL

https://db-engines.com/en/ranking – a really cool website that lists database engines by popularity check it out.

Cassandra Use Cases: When To Use And When Not To Use Cassandra – really good article about when to use and not use Cassandra Db

7 mistakes when using Apache Cassandra – Don’t make these mistakes if you want to use Cassandra database

Categories
Resources Software Development

Scala map and flatmap links and resources

Understanding map and flatmap can be a little hard at first if you have never encountered them. Below are some links to help you get a better understanding of these constructs.

Map, map and flatMap in Scala – good article explains the concepts well.

Maps Scala Documentation – basic coverage of maps from Scala documentation.

Categories
Random Software Development

Why are Scala val variables called values?

One of the oddest things I encountered when starting to learn Scala was seeing variables called values instead of variables.

When I first started reading the docs I saw a list of values of the classes, traits etc. I kept wondering WTF is a value why not call it a variable like every other language.

So for a while I just thought the Scala community just referred to all class variables as values.

Then I was reading the docs some more, I found this page. It has this one easy to miss line that answers the question why are vals called values instead of variables.

The second sentence below the difference between Val and Var

“Because val fields can’t vary, some people refer to them as values rather than variables.”

 

And that is the answer. In the Scala API documentation most classes/objects you see has a list of values defined with val.

I suppose the class variables are defined this way so that you don’t accidentally mutate them or change them.

I am still  not sure why methods are called members yet, when I figure that out maybe I’ll write about it.

Categories
Resources Software Development

Scala Play Framework Slick resources and links

Below is a list of resources, links, videos etc. a

Play Framework and Slick example updated – very helpful article

Categories
Resources Software Development

How Scala Imports and Packages work

One of the most important first things to learn about Scala is how Packages and Imports work. Below is a great video that covers the subject well. Why spend hours writing an article when an excellent resource exists?

Also if you would like to know more about Scala package objects, which allow you to reuse functions/ objects etc. then see my article what are Scala package objects

Packages and Imports (in Scala)

Categories
Resources Software Development

What are Scala package objects?

Scala package objects are basically code, functions, variables, classes, objects that you want available to all of your other code/files/objects in a given package. Basically it is like a system to provide utility, helper or common code all in one place.

Instead or writing an article I’ll post links to helpful resources. No reason to waste all my time writing articles if good article exist.

A minimal coverage of Package Objects by the  Scala docs.

The following link is from alvin alexander – from Scala Cook Book if you don’t own it you should buy it, this is an excellent resource. This link goes into much deeper detail than the documentation.
How to put common code in Scala package objects

Scala Tutorial – Learn How To Use Package Objects – excellent tutorial on how to use Package Objects.

Categories
Resources Software Development

HikariCP connection pooling software resources and links

HikariCP is a connection pool software that maintains connection pool resources so your code use them to access databases.

This can be used in place of Akka and Scala execution context for database connections. This helps keep your main application code from being blocked while it does a database query to either store or retrieve information.

HikariCP is the fastest and most resource efficient connection pool technology for the JVM.

 

Links

Introduction to HikariCP – a great introduction to what HikariCP is to start out with.

HikariCP documentation – a link to the actual documentation, you have to click the version of CP you want to use.

A quick guide to connection pooling in Java

Categories
Random Resources Software Development

Interesting blog about databases

I found this link somehow. This guy has all kinds of interesting information about databases, programming and technology in general . https://aphyr.com/tags/jepsen