Skip to content

Instantly share code, notes, and snippets.

View edib's full-sized avatar

ibrahim edib kokdemir edib

View GitHub Profile
import sys
import pandas as pd
json_file = "json_file.json"
if __name__ == "__main__":
for i, arg in enumerate(sys.argv):
if i == 1 and i is not None:
csv_file = arg
csv_file = pd.DataFrame(pd.read_csv(csv_file, sep = ",", header = 0, index_col = False))
68.2.1. Functional Dependencies
-- bir tablo
CREATE TABLE t (a INT, b INT);
-- sıralı veri ekliyoruz ve 2 kolonda birebir aynı
INSERT INTO t SELECT i % 100, i % 100 FROM generate_series(1, 10000) s(i);
--drop table hesap ;
create table hesap as SELECT number, round(random()*number)::int para FROM generate_series(1,4000000) number;
alter table hesap add column yil int;
update hesap set yil=(2000+(round(random()*1000)::int%3)) ;
-- drop index in_mmoney;
create index in_mmoney on hesap (para);
@edib
edib / pgbackrest-kullanimi.md
Created January 26, 2020 19:15
pgBackRest Kullanımı

Bu yazıyı okumadan önce, ssh ayarlarınızı yaptığınıza emin olun
Bu yazı PostgreSQL 11 ve PgBackRest 2.15 için yazılmıştır

Kurulum

Master ayarları

Öncelikle aşağıdaki komut ile pgbackrest kuralım:

sudo apt-get install pgbackrest -y
@edib
edib / psql_useful_stat_queries.sql
Created January 15, 2020 07:20 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@edib
edib / super_speedy_logical_replication_test.sh
Last active June 20, 2020 18:12
test script to install logical replicaiton in pg12 and create streaming replication and switchover all
/usr/pgsql-12/bin/initdb -D 12/rep1
/usr/pgsql-12/bin/initdb -D 12/rep2
printf "port = 6111 \nwal_level = logical\n" >> 12/rep1/postgresql.auto.conf
printf "port = 7111 \nwal_level = logical\n" >> 12/rep2/postgresql.auto.conf
/usr/pgsql-12/bin/pg_ctl -D 12/rep1 start
/usr/pgsql-12/bin/pg_ctl -D 12/rep2 start
@edib
edib / implicit-fk-delete.sql
Last active January 9, 2020 11:47
delete rows in implicitly relational tables
-- create a main table
CREATE TABLE test_123 AS SELECT id, md5(random()::text),(id+10) as myid FROM generate_series(1,5000) id;
-- create child table
CREATE TABLE test_456 AS SELECT id, md5(random()::text) FROM generate_series(11,5010) id;
-- check
select * from public.test_123;
select * from public.test_456;
@edib
edib / throwing-exception.java
Created January 5, 2020 20:12
simple java file to throw regular exceptions
package com.kokdemir;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Random;
import static java.lang.Class.forName;
public class Main {
@edib
edib / throwing-exception.java
Created January 5, 2020 20:12
simple java file to throw regular exceptions
package com.kokdemir;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Random;
import static java.lang.Class.forName;
public class Main {
@edib
edib / create-partitioned-table.sql
Last active May 20, 2020 15:20
Migrate non-partioned table to a partitioned table.
-- base table
-- drop table users cascade;
CREATE TABLE users (
id serial PRIMARY KEY,
username text NOT NULL UNIQUE,
password text,
created_on timestamptz NOT NULL,
last_logged_on timestamptz NOT NULL