Skip to content

Instantly share code, notes, and snippets.

Working from home

Okan Menevşeoğlu okanmenevseoglu

Working from home
View GitHub Profile
okanmenevseoglu / postgres-create-drop-index-online.sql
Last active Jan 29, 2018
Create/Drop a database index online (without locking the table) on PostgreSQL
View postgres-create-drop-index-online.sql
CREATE INDEX CONCURRENTLY {indexName} ON {tableName} ({columnName});
okanmenevseoglu / postgresql-cryptography-functions.sql
Created Jan 29, 2018 — forked from ufuk/postgresql-cryptography-functions.sql
Enable cryptography functions (pgcrypto extension) in PostgreSQL.
View postgresql-cryptography-functions.sql
-- Examples
SELECT ENCODE(DIGEST('password', 'md5'), 'hex');
SELECT ENCODE(DIGEST('password', 'sha1'), 'hex');
SELECT ENCODE(DIGEST('password', 'sha224'), 'hex');
SELECT ENCODE(DIGEST('password', 'sha256'), 'hex');
SELECT ENCODE(DIGEST('password', 'sha384'), 'hex');
SELECT ENCODE(DIGEST('password', 'sha512'), 'base64');
okanmenevseoglu /
Created Jan 29, 2018 — forked from ufuk/
Easy to use query builder for JPA Criteria API (including example usages)
package ...;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.*;
import java.util.*;
okanmenevseoglu /
Last active Feb 7, 2018
How to Make a Bootable macOS USB Install Drive
# 1) Download Mac Version to install from App Store
# 2) Put a USB stick at least 8 GB
# 3) Open Terminal and enter the following command:
sudo /Applications/Install\ macOS\ High\ --volume /Volumes/MyVolume
okanmenevseoglu / pg_stat_activity.sql
Created Feb 13, 2018
Viewing the Activity Table on PostgreSQL in detail and Terminating a pid
View pg_stat_activity.sql
-- To be able to use these in full detail, you must have the necesarry role authentication
-- Find activity list on DB
select * from pg_stat_activity
-- Find pid, user name, query, backend start date, transaction start date, query start date and the longest running sql times that are active and idle in transaction
SELECT pid, usename, query, backend_start, xact_start, query_start, (now() - query_start) AS run_time FROM pg_stat_activity WHERE state IN ('active', 'idle in transaction') ORDER BY query_start
-- Terminate the sql with the given pid
okanmenevseoglu / user-management.sql
Created Feb 23, 2018
Creating User and Giving Granular Access to the User on PostgreSQL
View user-management.sql
-- Create new user to the DB
CREATE USER {{username}} WITH ENCRYPTED PASSWORD {{password}};
-- Give access connection to the wanted DB
GRANT CONNECT ON DATABASE {{dbname}} TO {{username}};
-- Give access to the wanted schema
GRANT USAGE ON SCHEMA {{schemaname}} TO {{userName}};
-- Give select access to the sequences for the wanted schema
// Pull and image from a repository.
docker pull <repository-image-url>:<tag>
// Run an image with a bash shell.
docker run -it <image-name or image url>:<tag> /bin/bash
// Mount a volume to an image and run it
docker run -v <host-volume>:<docker-volume> <image-name or image url>:<tag>
// Connect to a running container
// Clone a single branch
git clone --single-branch --branch <branch-name> <git-repo-name>
okanmenevseoglu /
Last active Mar 31, 2020 — forked from grenade/
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "" -f ~/.ssh/mozilla_rsa
okanmenevseoglu /
Last active Aug 3, 2020
Listen Ports on Mac for Applications
lsof -Pi | grep LISTEN