Skip to content

Instantly share code, notes, and snippets.

View mostafaasadi's full-sized avatar
💻
developing ...

Mostafa Asadi mostafaasadi

💻
developing ...
View GitHub Profile
@mostafaasadi
mostafaasadi / keychron_linux.md
Last active December 7, 2021 05:33 — forked from andrebrait/keychron_linux.md
Keychron keyboards on Linux (+ Bluetooth fixes)

Here is the best setup (I think so :D) for Keychron + Linux

Make Fn + F-keys work

Keychron Keyboards on Linux use the hid_apple driver (even in Windows/Android mode), both in Bluetooth and Wired modes. By default, this driver uses the F-keys as multimedia shortcuts and you have to press Fn + the key to get the usual F1 through F12 keys.

In order to change this, you need to change the fnmode parameter for the hid_apple kernel module. Here's some documentation on it, but a quick summary can be found below:

@mostafaasadi
mostafaasadi / BSTDictionary.py
Created January 10, 2020 16:34
a simple dictionary based on BST in Python
# -*- coding: utf-8 -*-
class Node:
def __init__(self, word, mean):
self.lc = None
self.rc = None
self.word = word
self.mean = mean
@mostafaasadi
mostafaasadi / fandoghibot.py
Created August 1, 2019 12:50
a simple python telegram bot for fandogh
from telegram.ext import Updater, MessageHandler, Filters
# Telegram API
updater = Updater(token='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
dispatcher = updater.dispatcher
def gpt(bot, update):
bot.sendMessage(
chat_id=update.message.chat_id,
@mostafaasadi
mostafaasadi / zarb.py
Created July 2, 2019 04:54
قطعه کدی برای بررسی و آنالیز تکرار واژگان در ضرب‌المثل‌های فارسی
import urllib.request
import arabic_reshaper
from bs4 import BeautifulSoup
from collections import Counter
from bidi.algorithm import get_display
from persian_wordcloud.wordcloud import PersianWordCloud
def get():
links = list()
@mostafaasadi
mostafaasadi / stopwords.txt
Created July 2, 2019 04:15
some persian stopword
شد
نمي
كسي
نميشه
زير
((
))
خود
بايد
مي
@mostafaasadi
mostafaasadi / najva-notify.py
Created January 27, 2019 20:42
A python script for najva.com api
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import json
import pytz
import requests
import datetime
# dely time
delay = datetime.timedelta(seconds=10)
time = datetime.datetime.now(pytz.timezone('Asia/Tehran')) + delay
@mostafaasadi
mostafaasadi / hny97.sh
Last active March 20, 2019 21:10
happy new year shell
#!/bin/bash
# GPL
# A fork from https://github.com/subins2000/new-year-bash
# Config
name='Mostafa Asadi'
correction=0
trap "tput reset; tput cnorm; exit" 2
clear
@mostafaasadi
mostafaasadi / dlm.sh
Created March 2, 2018 07:05
A download manager has written in scu linux class
#!/usr/bin/env bash
clear
# pre-text
echo -e "\n\t\tIn the name of Allah"
echo -e "\t\t wellcome to download manager"
# get link
read -p "link: " link
# get start hour
@mostafaasadi
mostafaasadi / backup_mongo.sh
Last active February 25, 2018 13:01
A tiny script to backup mongodb
# database name as first argument
# it backup database in /var/www/html as zip and remove that database
mongodump -d $1
cd dump
zip -r $1.zip $1
sudo mv *.zip /var/www/html
rm -rf $1
mongo $1 --eval "db.dropDatabase()"
@mostafaasadi
mostafaasadi / count_mongodb.py
Last active April 8, 2018 22:55
A simple script to count all documents in all mongo databases
from pymongo import MongoClient
client = MongoClient()
cot = 0
size = 0
db_list = client.database_names()
db_list.sort()
# forked from persepolis download manager
def humanReadbleSize(size):