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
okanmenevseoglu / delete-old-acr-tags.sh
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>
ACR_NAME=<acr-name>
REPO_NAME=<acr-repo-name>
OLD_IMAGE_TAGS=$(az acr repository show-tags --name $ACR_NAME --repository $REPO_NAME -o tsv)
@okanmenevseoglu
okanmenevseoglu / lsof.sh
Last active August 3, 2020 21:19
Listen Ports on Mac for Applications
lsof -Pi | grep LISTEN
@okanmenevseoglu
okanmenevseoglu / generate-ssh-key.sh
Last active March 31, 2020 13:40 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa
@okanmenevseoglu
okanmenevseoglu / git-commands.sh
Last active December 19, 2019 14:30
Git commands
// Clone a single branch
git clone --single-branch --branch <branch-name> <git-repo-name>
@okanmenevseoglu
okanmenevseoglu / docker-commands.sh
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
okanmenevseoglu / user-management.sql
Created February 23, 2018 06:45
Creating User and Giving Granular Access to the User on PostgreSQL
-- 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
okanmenevseoglu / pg_stat_activity.sql
Created February 13, 2018 12:50
Viewing the Activity Table on PostgreSQL in detail and Terminating a pid
-- 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
SELECT
@okanmenevseoglu
okanmenevseoglu / bootable-usb-install-drive-for-macos.sh
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\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume
@okanmenevseoglu
okanmenevseoglu / EntityQuery.java
Created January 29, 2018 11:31 — forked from ufuk/JpaEntityQueryBuilder.java
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.*;
import java.util.stream.Collectors;
@okanmenevseoglu
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.
CREATE EXTENSION pgcrypto;
-- 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');