Untyped Constants in Golang

Golang is extremely explicit with types. It supports constants of a type. But how about a const 2 or hello. What type would they assume!? Go solved this problem with untyped constants. Untyped means: A constant’s type depends on the type of assignee variable. The assignee’s type must […]

Ubiquitous Client for Redis Server: Netcat

Forget about redis-cli. Just use nc bash-5.0# nc -v 10.x.x.x 6379 10.x.x.x (10.x.x.x:6379) open select 14 +OK What is ncat? NAME nc — arbitrary TCP and UDP connections and listens SYNOPSIS nc [-46AcDCdhklnrtUuvz] [-b boundif] [-i interval] [-p source_port] [-s source_ip_address] [-w timeout] [-X proxy_protocol] [-x proxy_address[:port]] [–apple-delegate-pid […]

SIngle Thread LRUCache in C++

#include <iostream> #include <list> #include <unordered_map> using namespace std; size_t capacity; class LRUCache { public: bool Lookup(int key, int *price) { auto it = hash_table.find(key); if (it == hash_table.end()) { return false; } *price = it->second.second; // update the key in the queue MoveToFront(key, it); return true; } […]

Understanding Ruby Symbols

Ruby is an interpreted language. It is dynamically typed and uses a new memory for a variable. A variable has a name and a value. Symbols are an optimized variable that holds single instance of memory. It is good for variables that assume the same values across the […]