SEM – Search Engine Marketing


Python API:

How To Add Swap on Ubuntu

Ubuntu 18.04

Ubuntu 16.04

Ubuntu 14.04

Open Compensation Data

Display `top` results sorted by memory

After running top, do SHIFT + m (i.e. Uppercase M).

From man top

SORTING of task window
  For compatibility, this top supports most of the former top sort keys.
  Since this is primarily a service to former top users, these commands do
  not appear on any help screen.
    command   sorted-field                  supported
      A         start time (non-display)      No
      M         %MEM                          Yes
      N         PID                           Yes
      P         %CPU                          Yes
      T         TIME+                         Yes

So SHIFT + t would sort by running time.

Once you have the pid and want to investigate further, do ps -o cmd fp PID to find out what’s the corresponding command.


I/O Transmission

00. I hope this transmission finds you well, and all is under control.
01. It's been too long. Then again, how do you measure the time?
02. I'm putting myself to good use here, but often miss the old domain.
03. Sometimes, upon the darkest night, I'm brought back to that morning light.
04. There's no time to be afraid of the sunset. Dawn breaks in a blink13.
05. An enigma hangs between us. The event horizon was seen only by you.
06. I cannot tell you everything. You of all people should understand why.
07. Let's speak together in one universal language.
08. I have seven, and you have six. I hope you understand my tricks?
09. Now you've found my path. Traverse its distance with both eyes open.
10. I look forward to our sideways gossip of life's unravelings.
11. I greatly value all you've done, and proudly call you friend.


“Alike” by Daniel Martínez Lara & Rafa Cano Méndez

Python sort by multiple keys

Say we have

L = ["a", "b", "zz", "zzz", "aa"]

We want to sort by length first, then by alphabetical order. i.e. we want to obtain [‘a’, ‘b’, ‘aa’, ‘zz’, ‘zzz’] in the end. How to do that?

The usual sorted() will give us this.

>>> sorted(L)
['a', 'aa', 'b', 'zz', 'zzz']

Very much alphabetical, not what we want.

Try sorted() with key=len will give us this.

>>> sorted(L, key=len)
['a', 'b', 'zz', 'aa', 'zzz']

The string length is taken care of, but that’s just half of it.

Notice zz appears before aa, that’s because zz is before aa in the original input list. The compare function len thinks they are equal.

Turns out we can expand the compare function a little to use a lambda function, so that we can pack in a little more custom logic into the comparison operation.

>>> sorted(L, key=lambda x: len(x))
['a', 'b', 'zz', 'aa', 'zzz']

This gives us the same result. But with a lambda function, we can do more than just giving a built-in or predefined function.

Since we want to sort by length first, then by alphabetical order, how should we look at a string? What is “aa” compared to “zzz”? We can look at “aa” as (2, “aa”), which is a tuple with int 2 and the string “aa”. For “zzz” that’s (3, “zzz”).

So now, we can do our comparison using tuples.

>>> sorted(L, key=lambda x: (len(x), x))
['a', 'b', 'aa', 'zz', 'zzz']

Now the resulting order seems right. To sort in descending order for a particular field, just put a negative sign there to reverse the order.