Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Zabih Alipour zabih-alipour

🏠
Working from home
View GitHub Profile
View gist:e5388f7237bcf0c21040f2948442519d
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 Nov 9, 2019
Copy all specific type file to another folder
View gist:0ef4b19914f794befafeeafc21e87a76
find . -maxdepth 4 -name "*.pdf" -type f -print0 | xargs --null -I {} cp -rf {} ~/Documents/cp_calibre_pdf/
View Find unused indexes in postgres
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
View Calendar with CTE in postgresSQL
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 Jun 9, 2019
Get all repositories list in debian
View Debian Repository List
grep ^[^#] /etc/apt/sources.list /etc/apt/sources.list.d/*
@zabih-alipour
zabih-alipour / Hibernate_query_statistics
Last active Jun 9, 2019
Log hibernate query statistics and query parameter
View Hibernate_query_statistics
############################################# Hibernate query statistics #################################################
### For use in spring boot
spring.jpa.properties.hibernate.generate_statistics=true
### For use in hibernate config
hibernate.generate_statistics=true
### Log parameters
logging.level.org.hibernate.stat=debug
@zabih-alipour
zabih-alipour / CurlRequestCall
Created Apr 26, 2019
Repeat request calling for n times with curl
View CurlRequestCall
curl -X POST http://localhost:8081/api/v1/users?[0-100] -H 'Content-Type: application/json' -H 'cache-control: no-cache' -d '{ "name": "2Mohammad", "email": "Asghar2" }'
View gist:9c710206220b5a8066880a5fd5ce12d4
# View git log
* git log --pretty=oneline // show log in one line
* git log --pretty=format:"%h : %an : %ar : %s" // version : user : date : commit message
@zabih-alipour
zabih-alipour / gist:7bec86c6a62e224c64d681365b31e6e3
Created Oct 6, 2018
Attach idea debagger to maven testcase
View gist:7bec86c6a62e224c64d681365b31e6e3
mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE" -Dtest=BankAccountTest test
View Reset jenkins password
0. SSH to server
1. Edit /opt/bitnami/apps/jenkins/jenkins_home/config.xml
2. set userSecurity to false: <userSecurity>false</userSecurity>
3. delete
<authorizationStrategy> and <securityRealm>
4. /etc/init.d/bitnami restart
You can’t perform that action at this time.