Skip to content

Instantly share code, notes, and snippets.

View amirsafiallah's full-sized avatar
🏠
Working from home

AmirAshkan Safiallah amirsafiallah

🏠
Working from home
View GitHub Profile
@amirsafiallah
amirsafiallah / corrupted-wt.js
Created December 1, 2022 09:44
Find corrupted index/collection by wt file name
function findInDb(dbName, collectionIdToFind) {
var dbToSearch = db.getSiblingDB(dbName);
var collectionNames = dbToSearch.getCollectionNames();
for (var i = 0; i < collectionNames.length; i++) {
var name = collectionNames[i];
var stats = dbToSearch.getCollection(name).stats({
"indexDetails": true
});
var uris = [stats.wiredTiger.uri];
// Hobab Abshodeh Fardai
AbshodeFardai - ((Gold*AfsharFardai)/9.5742)
// Hobab Abshodeh Naghdi
AbshodeNaghdi - ((Gold*AfsharNaghdi)/9.5742)
// Hobab Sekke Fardai
SekkeFardai - ((Gold*AfsharFardai)*0.23533)
// Hobab Sekke Naghdi
ip tuntap add dev tun1 mode tun
ip addr add 10.0.0.1/24 dev tun1
ip link set tun1 up
ip route add 8.8.8.8/32 via metric 5
ip route add 8.8.8.8/32 via 192.168.1.1 metric 5
ip route add 8.8.4.4/32 via 192.168.1.1 metric 5
ip route add 157.119.188.28 via 192.168.1.1 metric 5
badvpn-tun2socks --tundev tun1 --netif-ipaddr 10.0.0.2 --netif-netmask 255.255.255.0 --socks-server-addr 157.119.188.28:9991 --username USERNAME --password PASSWORD
ip route add default via 10.0.0.2 metric 6
@amirsafiallah
amirsafiallah / packet_forward.md
Last active October 13, 2019 15:39
forward packet between `eth0` and `tun0`

Packet Forwarding Between Interfaces in Linux

forward packet between eth0 and tun0:

iptables -A FORWARD -i eth0 -o tun0 -j ACCEPT
iptables -A FORWARD -i tun0 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE

to save iptables rules

@amirsafiallah
amirsafiallah / pihole-docker.md
Created October 12, 2019 23:12
Run pihole docker on raspberry pi
docker run -d \
    --name pihole \
    --net=host \
    -e TZ="Asia/Tehran" -e WEBPASSWORD="13257106" -e ServerIP="192.168.1.100" -e WEB_PORT="8080" -e DNSMASQ_LISTENING="all" \
    -v "$(pwd)/etc-pihole/:/etc/pihole/" \
    -v "$(pwd)/etc-dnsmasq.d/:/etc/dnsmasq.d/" \
    --dns=1.0.0.1 --dns=1.0.0.1 \
    --restart=unless-stopped \
    --cap-add=NET_ADMIN \

pihole/pihole:latest

const host = `api/${token}`;
const config = {
// debug: true, // uncomment this line to see Library errors and warnings in the console
// fullscreen: true,
width: "100%",
height: "100%",
container_id: "tv_chart_container", //id of div which you wanna load chart
symbol: "AbshodeN",
interval: "1",
timezone: "Asia/Tehran",
@amirsafiallah
amirsafiallah / persian_wine_linux.md
Created January 15, 2019 08:23
How to make wine support persian (farsi)

if you run an app containing farsi (persian) words, and it doesn't display well, you can use the following approach:

open terminal and cd to app directory run app with the command:

LC_ALL=fa_IR.utf8 wine terminal.exe

which terminal.exe is the name of the app.

if it doesn't fix it you may also need to install Core Font Pack with this command:

@amirsafiallah
amirsafiallah / chmod.md
Created November 9, 2018 17:53
Change All Files and Folders to specific perimission

Change all files to 644

$ find ./ -type f -exec chmod 644 {} \;

Change all folders to 755

$ find ./ -type d -exec chmod 755 {} ;

@amirsafiallah
amirsafiallah / service.md
Last active November 5, 2018 14:17
Run Java as Service on Ubuntu

We're going to create a service called asakchart.

create and edit asakchart.service:

nano /etc/systemd/system/asakchart.service

with following content:

[Unit]

Description=Asakchart Webserivce

@amirsafiallah
amirsafiallah / mongoauth.md
Last active July 14, 2018 16:39
Enable Mongodb Authentication Linux

Open terminal:

$ mongo
> use admin
> db.createUser({
  user: "username",
  pwd: "password",
  roles: [ { role: "root", db: "admin" } ]
});

> exit