Skip to content

Instantly share code, notes, and snippets.

Working from home

Okan Menevşeoğlu okanmenevseoglu

Working from home
View GitHub Profile
okanmenevseoglu /
Created Feb 28, 2022
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 Aug 3, 2020
Listen Ports on Mac for Applications
lsof -Pi | grep LISTEN
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
// Clone a single branch
git clone --single-branch --branch <branch-name> <git-repo-name>
// 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 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
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 /
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 /
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 / 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');