Skip to content

Instantly share code, notes, and snippets.

View SaitTalhaNisanci's full-sized avatar

Talha Nisanci SaitTalhaNisanci

View GitHub Profile
@SaitTalhaNisanci
SaitTalhaNisanci / hash_failure.sql
Last active August 24, 2021 08:45
Postgres 14 hash failure
Create or replace function test_jsonb() returns jsonb as
$$
begin
return '{"test_json": "test"}';
end;
$$ language plpgsql;
CREATE TABLE local
@SaitTalhaNisanci
SaitTalhaNisanci / latency.txt
Created June 29, 2021 09:37 — 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
10 total cols: 1 selected, 9 NULL, 10000000 rows 0.6916604042053223 seconds
10 total cols: 1 selected, 8 NULL, 10000000 rows 0.6812009811401367 seconds
10 total cols: 1 selected, 7 NULL, 10000000 rows 0.6044158935546875 seconds
10 total cols: 1 selected, 6 NULL, 10000000 rows 0.8335869312286377 seconds
10 total cols: 1 selected, 5 NULL, 10000000 rows 0.6090021133422852 seconds
10 total cols: 1 selected, 4 NULL, 10000000 rows 0.572737455368042 seconds
10 total cols: 1 selected, 3 NULL, 10000000 rows 0.584613561630249 seconds
10 total cols: 1 selected, 2 NULL, 10000000 rows 0.7285683155059814 seconds
10 total cols: 1 selected, 1 NULL, 10000000 rows 0.6625514030456543 seconds
10 total cols: 2 selected, 8 NULL, 10000000 rows 0.6221935749053955 seconds

Version 13 contains a number of changes that may affect compatibility with previous releases. Observe the following incompatibilities:

Change SIMILAR TO ... ESCAPE NULL to return NULL (Tom Lane)

This new behavior matches the SQL specification. Previously this caused the escape to be set to the default backslash character. The previous behavior has been retained in old views by keeping the original function unchanged. This also applies to substring(text FROM pattern ESCAPE text).

Have jsonb_to_tsvector() properly check "string" parameter (Dominik Czarnota)

In ltree, when using adjacent asterisks with braces, e.g. ".{2}.{3}", properly interpret that as ".*{5}" (Nikita Glukhov)

def log_on_exception(*tags):
"""
A utility decorator to log the exception with
the given tags.
it reraises the exception.
"""
def decorator(function):
@functools.wraps(function)
def wrapper(*args, **kwargs):
try:
@SaitTalhaNisanci
SaitTalhaNisanci / Hotjar-backend-challence.py
Created April 10, 2019 21:45
Hotjar backend challenge
def log_on_exception(*tags):
"""
A utility decorator to log the exception with
the given tags.
it reraises the exception.
"""
def decorator(function):
@functools.wraps(function)
def wrapper(*args, **kwargs):
try:
@SaitTalhaNisanci
SaitTalhaNisanci / interview.js
Created April 7, 2019 14:43
Flatten an array of nested elements.
// Flattens the given nested elements.
function flattenArray(elements) {
if (elements === undefined || !Array.isArray(elements)) {
throw "Array is expected";
}
return elements.reduce((result, current) => {
return result.concat(Array.isArray(current) ? flattenArray(current) : current);
}, []);
}