TIL about the term cookie tossing, an attack leverages the feature that a subdomain can put a key=value pair in a cookie which can then also be read by the domain above it. For example, todayilearned.dev doesn’t know if this key comes from it or from cookie.todayilearned.dev.

This becomes problematic when a website allows untrusted people to host subdomains under its domain. They can then abuse this feature to write manipulated cookie information.

TIL about Count-Min Sketch, an algorithm used to answer questions like:

  • What’s the frequency of our samples?
  • What’s our most frequent samples?

Similar to bloom filters, it uses k distinct hash functions. Every observed value serves as an input for these functions and the output for each function is a number corresponding to a bucket.After finding the buckets we just need to increment a counter in each of these buckets.

In order to retrieve the frequency of an observed value we find the buckets for this value and return the minimum counter among all the buckets: min(bucket_x, bucket_y, bucket_z)

A short version the paper can be found here.

TIL about :scriptnames in order to get a list of scripts that vim has loaded. It’s pretty useful since we can infer if any of our scripts are being overridden by another one. We can also run this command as scr

TIL that Spotlight allows us to make calculations, get exchange rates and even the weather. Let’s see a few examples:

  • ceil(), floor() or sqrt()
  • 100USD in CAD
  • Weather Montreal

TIL about configuring a shortcut in iTerm2 to delete a word.

  1. Open the preferences (⌘ + ,) and go to the Keys tab.
  2. Add a shortcut key
  3. In the Action dropdown, select Send Hex Code and input 0x17

TIL about the status bar on iTerm2. It’s pretty useful with a mix of builtin components like Current Directory or git state and user defined variables or functions. To access and configure the status bar go to Preferences > Profiles > Session. Turn on Status bar enabled then click Configure Status Bar.

Again, scripting plays a huge part in how useful the status bar is.

As an example:

# In ~/.bash_profile
function iterm2_print_user_vars() {
  iterm2_set_user_var rubyVersion $(ruby -v | awk '{ print $2 }')

And the variable can be read inside a Custom Action > Configure Component > Configure Action through \(user.rubyVersion).

TIL that curl --data and curl --data-binary when used with a @filename outputs a different result. The most common one being that --data will strip newlines from the file but --data-binary will not.

TIL that in normal mode we can just type a percentage and vim will go there, like 50% or 75%.

TIL about the merkle tree data structure, a tree structure in which each leaf node is a hash of a block of data, and each non-leaf node is a hash of its children.

Label              ROOT
Value           H(H01 + H23)
                 /        \
Label       [H01]         [H23]
Value    H(H0 + H1)     H(H2 + H3)
           /     \        /     \
Label    [H0]   [H1]    [H2]   [H3]
Value    H(A)   H(B)    H(C)   H(D)
           |      |       |      |
           A      B       C      D

It’s mostly used in distributed systems for efficient data verification since it only depends on hashes instead of full files. Bitcoin and Ethereum makes full use of this data structure with variations like the Merkle Patricia Tree.

TIL about the console.group command used to create a new inline group in the Web Console log. It is used in order to create nesting in your console logs.

Let’s see an example:

console.log("This is the outer level");
console.log("Level 2");
console.log("Level 3");
console.warn("More of level 3");
console.log("Back to level 2");
console.log("Back to the outer level");

The generated log will be the following:

"This is the outer level"
  "Level 2"
    "Level 3"
    "More of level 3"
  "Back to level 2"
"Back to the outer level"

Copied to clipboard