Skip to content

Instantly share code, notes, and snippets.

View vasuadari's full-sized avatar
🤔
Thinking

Vasu Adari vasuadari

🤔
Thinking
View GitHub Profile

Here’s a quick cheat sheet for common data types and their storage sizes across popular relational databases (like MySQL, PostgreSQL, and SQL Server). Keep in mind that the sizes listed are typical, but some nuances or variations might apply based on specific DBMS configurations.

Numeric Data Types

Data Type Description Storage Size (in bytes)
TINYINT Integer between -128 and 127 (signed) 1
SMALLINT Integer between -32,768 and 32,767 (signed) 2
MEDIUMINT Integer between -8,388,608 and 8,388,607 3
INT/INTEGER Integer between -2,147,483,648 and 2,147,483,647 4
BIGINT Large integer between -9 quintillion to +9 quintillion 8

Here’s how the SOLID principles can be implemented using Ruby:

1. Single Responsibility Principle (SRP):

  • Violation:
    class User
      def initialize(name, email)
        @name = name
        @mail = email
      end
@vasuadari
vasuadari / latency.txt
Created August 22, 2024 13:48 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@vasuadari
vasuadari / sample_template_design_pattern.java
Last active July 27, 2020 08:43
Sample Template Design Pattern
// src: https://www.javatpoint.com/template-pattern
public interface Base {
boolean supports(EventModel event);
void apply(EventModel event);
}
// All different types of classes can implement this Base.
@vasuadari
vasuadari / chicken_biriyani_recipe.md
Created July 13, 2020 11:32
Recipe for Chicken Biriyani

Lets assume we're gonna cook for 3 people.

Things to buy

  • 500 to 600 grams of chicken which is mediumly cut
  • India gate basmati rice
  • 250 ml of Curd(Should be thick so go for milky mist cup or some other brand)
  • Garam masala
  • Biriyani masala
  • Red chilli powder
@vasuadari
vasuadari / tap.exs
Last active June 21, 2020 10:36
Tap a method in elixir(similar to ruby)
defmodule Tap do
defmacro tap(tapped_value, do: yield) do
quote do
var!(t) = unquote(tapped_value)
unquote(yield)
var!(t)
end
end
defmacro tap(tapped_value, :return, do: yield) do
@vasuadari
vasuadari / defoverridable.exs
Last active June 17, 2020 10:05
defoverridable example in elixir
defmodule DefaultModule do
@callback hello(any()) :: any()
defmacro __using__(_opts) do
quote do
@behaviour DefaultModule
def hello(:a) do
:a
end
@vasuadari
vasuadari / cheat_sheet.md
Last active September 27, 2022 09:40
My Cheat Sheet

MySQL

Dump a query result to a csv file

mysql -h [HOST] -P [PORT] -u [USER] DB_NAME -e '[QUERY]' -p > [FILE_NAME].csv

Networking

@vasuadari
vasuadari / delete_branches_older_than.sh
Last active May 20, 2020 15:28 — forked from redthor/delete_branches_older_than.sh
Script to delete branches older than a certain date, modification of 4586456
# Copy of https://gist.github.com/antonio/4586456
# With a modification to collect all the branch names so we can make one git request
# Set DRY_RUN=1 to get an echo of the command
# Format that works with `git log --since`, e.g. 2018-01-01
date=$1
branches=
for branch in $(git branch -r | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do
@vasuadari
vasuadari / mysql_5_8_keywords.txt
Created April 20, 2020 09:20
MySQL 5.8 keywords
active
admin
array
attribute
buckets
clone
component
cume_dist
definition
dense_rank