Skip to content

Instantly share code, notes, and snippets.

View okanmenevseoglu's full-sized avatar
Working from home

Okan Menevşeoğlu okanmenevseoglu

Working from home
View GitHub Profile
okanmenevseoglu /
Created February 28, 2022 14:31
This script is used for deleting old Azure Container Registry tags
#!/usr/bin/env bash
az login
az account set --subscription <subscription-id>
OLD_IMAGE_TAGS=$(az acr repository show-tags --name $ACR_NAME --repository $REPO_NAME -o tsv)
okanmenevseoglu /
Last active August 3, 2020 21:19
Listen Ports on Mac for Applications
lsof -Pi | grep LISTEN
okanmenevseoglu /
Last active March 31, 2020 13:40 — 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 December 19, 2019 14:30
Git commands
// Clone a single branch
git clone --single-branch --branch <branch-name> <git-repo-name>
okanmenevseoglu /
Last active August 3, 2020 21:21
Docker Commands
// 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
okanmenevseoglu / user-management.sql
Created February 23, 2018 06:45
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
okanmenevseoglu / pg_stat_activity.sql
Created February 13, 2018 12:50
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 /
Last active February 7, 2018 08:45
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 /
Created January 29, 2018 11:31 — 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 / postgresql-cryptography-functions.sql
Created January 29, 2018 11:29 — 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');