Skip to content

Instantly share code, notes, and snippets.

View zabih-alipour's full-sized avatar
🏠
Working from home

Zabihullah Alipour zabih-alipour

🏠
Working from home
View GitHub Profile
@zabih-alipour
zabih-alipour / KeycloakAdminClientExample.java
Created January 26, 2022 13:17 — forked from thomasdarimont/KeycloakAdminClientExample.java
Using Keycloak Admin Client to create user with roles (Realm and Client level)
package demo.plain;
import org.keycloak.OAuth2Constants;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.KeycloakBuilder;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.UserResource;
import org.keycloak.admin.client.resource.UsersResource;
import org.keycloak.representations.idm.ClientRepresentation;
@zabih-alipour
zabih-alipour / send-file-to-kafka.sh
Last active October 31, 2021 07:57
Read file line by line and send to kafka topic
#! /bin/bash
cd /opt/bitnami/kafka/bin/
input="/messages/data/messages.txt"
while IFS= read -r line
do
sh kafka-console-producer.sh --bootstrap-server 127.0.0.1:9092 --topic topic_name $line
done < "$input"
@zabih-alipour
zabih-alipour / message-count.sh
Last active October 31, 2021 07:57
Get kafka topic message count
kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic topic_name
@zabih-alipour
zabih-alipour / gist:9c0db907448ee34f774b207b08bc40e1
Created October 16, 2020 12:04
export Mysql current settings
All settingd:
mysql -uroot -p -A -e"SHOW VARIABLES;" > ~/MySQLCurrentSettings.txt
Global SEttings:
mysql -uroot -p -A -e"SHOW GLOBAL VARIABLES;" > ~/MySQLCurrentSettings.txt
Session Settings:
mysql -uroot -p -A -e"SHOW SESSION VARIABLES;" > ~/MySQLCurrentSettings.txt
@zabih-alipour
zabih-alipour / gist:0ddb67601b1ec4c1eeb98a94c29de8fa
Last active September 7, 2020 18:00
Add a progress in output in NodeJs
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write(`waiting.... ${progressNumber}`);
@zabih-alipour
zabih-alipour / gist:e5388f7237bcf0c21040f2948442519d
Created November 19, 2019 08:43
Set proxy on apt in ubuntu
Create file if not exists: /etc/apt/apt.conf.d/proxy.conf
Add your proxy info into file, like:
Acquire::http::Proxy "http://user:password@proxy.server:port/";
Acquire::https::Proxy "http://user:password@proxy.server:port/";
@zabih-alipour
zabih-alipour / gist:0ef4b19914f794befafeeafc21e87a76
Created November 9, 2019 15:55
Copy all specific type file to another folder
find . -maxdepth 4 -name "*.pdf" -type f -print0 | xargs --null -I {} cp -rf {} ~/Documents/cp_calibre_pdf/
SELECT s.schemaname,
s.relname AS tablename,
s.indexrelname AS indexname,
pg_relation_size(s.indexrelid) AS index_size,
s.idx_scan
FROM pg_catalog.pg_stat_user_indexes s
JOIN pg_catalog.pg_index i ON s.indexrelid = i.indexrelid
WHERE s.idx_scan > 0 -- has never been scanned
AND 0 <>ALL (i.indkey) -- no index column is an expression
AND NOT i.indisunique -- is not a UNIQUE index
WITH cte AS (
SELECT current_date - (n || ' day')::INTERVAL AS date
FROM generate_series(0, 29) n
)
SELECT date
FROM cte
@zabih-alipour
zabih-alipour / Debian Repository List
Created June 9, 2019 11:23
Get all repositories list in debian
grep ^[^#] /etc/apt/sources.list /etc/apt/sources.list.d/*