Skip to content

Instantly share code, notes, and snippets.

View mostafabahri's full-sized avatar
👨‍💻

Mostafa Bahri mostafabahri

👨‍💻
  • Germany
View GitHub Profile
@mostafabahri
mostafabahri / docker-compose.yml
Created May 7, 2021 15:14
docker-compose for node.js development starter
version: "3"
services:
app:
image: node:16
working_dir: /app
volumes:
- ./:/app
ports:
- 3000:3000
@mostafabahri
mostafabahri / shecan.sh
Created June 18, 2020 17:26
Shecan.ir script
shecan(){
# dns config file
conf=/etc/resolv.conf
downNames=$(cat << EOF
nameserver 8.8.4.4
nameserver 8.8.8.8
EOF
)
upNames=$(cat << EOF
# shecan servers
@mostafabahri
mostafabahri / hw3.sql
Created June 3, 2019 00:32
SCD 2 procedure
-- source tables
drop table if exists customers;
drop table if exists customer_type;
drop table if exists dim_customer;
drop function if exists update_dim_customer();
create table customer_type (
type_id int primary key,
type_description text
);
@mostafabahri
mostafabahri / convert.sh
Last active April 10, 2022 17:34
Convert svg to png bash script
for file in *.svg
do
name=$(basename $file .svg)
svgexport $name.svg $name.png 300:300 80%
done
@mostafabahri
mostafabahri / validate.sql
Last active February 27, 2020 23:20
pgSQL script to validate Iranian National ID format
-- AUTHOR: Mostafa
drop function if exists validate_national_id( text );
create or replace function validate_national_id(id text)
returns boolean as $$
declare
summation integer := 0;
arrayId text[] ;
rem integer;
@mostafabahri
mostafabahri / .gitlab-ci.yml
Last active April 14, 2020 01:16
gitlab ci npm with caching
---
stages:
- test
test:
image: node:11-alpine
stage: test
cache:
paths:
@mostafabahri
mostafabahri / rx.sh
Created October 10, 2018 09:23
Copy to clipboard and clean after 10 seconds
#!/bin/bash
cat - | xclip -selection c
(sleep ${1:-10}
xsel -bc) &
@mostafabahri
mostafabahri / docker-compse.yml
Last active August 8, 2018 15:13
Minimal Dockerized Postgres for Laravel
version: '2'
services:
dev-pg:
image: 'postgres:10-alpine'
volumes:
- 'dev:/var/lib/postgresql/data'
environment:
- POSTGRES_DB=app_dev
- POSTGRES_USER=laravel
- POSTGRES_PASSWORD=secret

some random shell/whatever snippets

rsync

resumable, showing progress rsync from remote:

rsync -avz --progress --append-verify user@remote.com:/file/path /local/file/path

@mostafabahri
mostafabahri / Caddyfile
Last active June 7, 2018 18:36
Reverse proxy and rate-limiting Caddy config
0.0.0.0:2015 {
gzip
log /tmp/caddy.log
proxy / localhost:9009 { # backend api
transparent
}
ratelimit * 3 5 second { # 3 req/sec & bursts of 5
whitelist 192.168.1.0/24