Multiple SSH keys for different users

First, generate two separate keypairs, one for home and one for work:

ssh-keygen -t rsa -f ~/.ssh/id_rsa.home
ssh-keygen -t rsa -f ~/.ssh/id_rsa.work

Next, add an entry to your ~/.ssh/config file to pick the key to use based on the server you connect to:

Host home
Hostname home.example.com
IdentityFile ~/.ssh/id_rsa.home
User <your home acct>

Host work
Hostname work.example.com
IdentityFile ~/.ssh/id_rsa.work
User <your work acct>
Advertisements

Caching with Spring

  1. Know your topology.
  2. How about data consistency? Avoid real replication where possible.
  3. Avoid big heaps just for caching (because big heap 32Gb+ leads to long major GCs)
  4. Small caches are a bad idea. Many evictions fewer hits, no “hot data”. This is especially critical for replicating caches.
  5. Use a distributed cache for big amounts of data.
  6. Which data shall I cache? Make sure that only suitable data gets cached. The best cache candidates are read-mostly data, which are expensive to obtain. If you urgently must cache write-intensive data make sure to use a distributed cache and not replicated or invalidating one.
  7. Which cache shall I use? Only use existing cache implementations. Never write your own cache implementation ever.
  8. How do I introduce caching? Mind the security gap.
  9. Abstract your cache provider.

Continue reading “Caching with Spring”

Resolving Configuration in Spring Boot

1) Command Line Arguments – prefix any property with a double dash (for example –server.port=9000)

2) Embedded JSON in SPRING_APPLICATION_JSON (for example: SPRING_APPLICATION_JSON='{“server” : {“port” : “9000”}}’)

3) StandardServletEnvironment

  • A hierarchy within itself
    1. ServletConfig init parameters
    2. ServletContext init parameters
    3. JNDI attributes
    4. System.getProperties()
    5. OS environment vars

Continue reading “Resolving Configuration in Spring Boot”

Intro to JavaScript

1. Avoid using global variables.

function calculateSalary() {
	var address = "123 Main Street"; // local String variable
	age = 25;			 // global Number variable
	var married = true;		 // local boolean variable
	married = "don't remember";      // now it's String variable
}

2. Functions can be objects. You can create a function and then create an instance of the function.

3. You can declare a function that doesn’t belong to any class (or any instance).

4. You can declare a function and assign it to a variable, and then invoke that variable.

5. Functions can have memory.

6. Java 8 introduced Lambda expressions they are similar to JS functions.

Continue reading “Intro to JavaScript”