Skip to content

Instantly share code, notes, and snippets.

View meysam81's full-sized avatar
📝
Learning

Meysam meysam81

📝
Learning
View GitHub Profile
import numpy as np
import sys
## initialization
with open('dataset.csv') as f:
dataset = f.readlines()
edges = sorted([tuple(int(y) for y in x.split('\t')) for x in dataset])
@meysam81
meysam81 / HITS.py
Last active December 22, 2018 10:58
import numpy as np
import sys
## initialization
with open('dataset.txt') as f:
dataset = f.readlines()
edges = sorted([tuple(int(y) for y in x.split('\t')) for x in dataset])
@meysam81
meysam81 / pdlist.sh
Created December 9, 2018 16:48
a bash script to gather p30download.com links to for download
#!/bin/bash
if [[ "$#" -ne 2 ]]; then
echo "usage pdlist <filename> <number_of_parts>"
exit 1
fi
parts="$2"
filename="$1"
@meysam81
meysam81 / saham.py
Last active December 24, 2018 05:34
#/usr/bin/python3
import sys
try:
bazar = sys.argv[1]
hajm = int(sys.argv[2])
gheymat_kharid = int(sys.argv[3])
gheymat_foroush = int(sys.argv[4])
if bazar == 'bours':
print(hajm * (1.00575 * gheymat_foroush - 1.00464 * gheymat_kharid))
@meysam81
meysam81 / unrar.sh
Last active January 11, 2019 06:19
#!/bin/bash
one_line_equal() {
x=0
while [ $x -lt `tput cols` ]; do
echo -n '='
let x=$x+1
done
echo
}

Install Samba

sudo apt-get update sudo apt-get install samba

Set a password for your user in Samba

sudo smbpasswd -a <user_name>

Note: Samba uses a separate set of passwords than the standard Linux system accounts (stored in /etc/samba/smbpasswd), so you'll need to create a Samba password for yourself. This tutorial implies that you will use your own user and it does not cover situations involving other users passwords, groups, etc...
@meysam81
meysam81 / .bashrc
Last active June 4, 2019 11:31
This is my config files for bashrc, tmux & emacs
# custom aliases
alias c='xclip -sel clip'
alias h='history'
alias hw='h -w'
alias sess="tmux new -s"
alias edit="emacs -nw"
alias busy="ps -eo pcpu,pid -o comm= | sort -n -k1 -r | head"
alias battery="upower -d | egrep percentage | head -1"
# for virtualenv & virtualenvwrapper
@meysam81
meysam81 / multidb-postgres-docker.sh
Last active June 4, 2019 11:30
multiple database for dockerized postgres
#!/bin/bash
for database in $(echo "$POSTGRES_MULTIPLE_DATABASES" | tr ',' ' '); do
psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -h "$POSTGRES_HOST" <<EOSQL
CREATE USER "$database";
CREATE DATABASE "$database";
GRANT ALL PRIVILEGES ON DATABASE "$database" TO "$database";
EOSQL
done
@meysam81
meysam81 / async_logger.py
Last active October 19, 2020 09:51
my yummy logger
import os
import logging
import aiologger
from aiologger.formatters.json import Formatter
NOCOLOR = "\033[0m"
RED = "\033[01;31m"
GREEN = "\033[01;32m"
@meysam81
meysam81 / create_mongo.py
Created June 3, 2019 10:29
my yummy mongoer
from pymongo import MongoClient
def create_db():
mongo_user = "MONGO_USER"
mongo_pass = "MONGO_PASS"
mongo_host = "MONGO_HOST"
mongo_port = "MONGO_PORT"
mongo_uri = "mongodb://{}:{}@{}:{}".format(
quote_plus(mongo_user),