Skip to content

Instantly share code, notes, and snippets.

@Ja7ad
Ja7ad / QMessage.py
Last active December 11, 2020 13:45
PyQt5 QMessageBox with Details
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QGridLayout, QWidget, QCheckBox, QSystemTrayIcon, \
QSpacerItem, QSizePolicy, QMenu, QAction, QStyle, qApp, QMessageBox, QPushButton
from PyQt5.QtCore import QSize
class MainWindow(QMainWindow):
"""
Сheckbox and system tray icons.
Will initialize in the constructor.
"""
@Ja7ad
Ja7ad / ui_notification.py
Created December 2, 2020 12:19
PyQt5 Toast Notification in app and desktop
from PyQt5 import QtCore, QtWidgets, QtGui
import sys
class QToaster(QtWidgets.QFrame):
closed = QtCore.pyqtSignal()
def __init__(self, *args, **kwargs):
super(QToaster, self).__init__(*args, **kwargs)
QtWidgets.QHBoxLayout(self)
@Ja7ad
Ja7ad / google_search.py
Created December 2, 2020 12:30
Search Selected word in google and enter in speceficed site
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options
import time , json
try:
@Ja7ad
Ja7ad / Logger.py
Created December 2, 2020 12:34
Singleton Logger in python ( info, warning, error, debug )
import datetime
import os
class MetaSingleton(type):
_instance = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instance:
cls._instance[cls] = super().__call__(*args, **kwargs)
@Ja7ad
Ja7ad / pyd_installer.py
Created December 2, 2020 12:38
An pyd file installer for installed python3 in windows and linux
import sys, site, shutil, os, platform
pyMajorVersion = sys.version_info.major
pyMinorVersion = sys.version_info.minor
pyVersion = str(pyMajorVersion) + "." + str(pyMinorVersion)
print("This Python version " + pyVersion)
if not os.path.exists(pyVersion):
@Ja7ad
Ja7ad / repairdb.sql
Created December 2, 2020 12:44
Find invalid records in your database and remove record, Eventually repair your database
USE master
SELECT NAME,STATE_DESC FROM SYS.DATABASES
WHERE STATE_DESC='SUSPECT'
USE master
"Replace your database name with Your_Database_Name"
ALTER DATABASE Your_Database_Name SET EMERGENCY
DBCC CHECKDB (Your_Database_Name)
ALTER DATABASE Your_Database_Name SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CHECKDB (Your_Database_Name, REPAIR_ALLOW_DATA_LOSS)
@Ja7ad
Ja7ad / terminal run command with proxy
Last active December 4, 2020 15:24 — forked from ekiara/using-wget-with-socks-proxy
terminal run command with proxy
# This should work for everything includeing curl, pip, pipenv, etc
# TLDR: Use proxychains (https://github.com/haad/proxychains)
## INSTALL PROXY CHAINS ##
$ sudo apt update -y
$ sudo apt install proxychains
## EDIT PROXYCHAINS CONFIG ##
$ sudo nano /etc/proxychains.conf

Keybase proof

I hereby claim:

  • I am Ja7adR on github.
  • I am ja7adr (https://keybase.io/ja7adr) on keybase.
  • I have a public key whose fingerprint is 85BE B10B 45AF 1DA6 3E7A F688 CBDA 7C73 8BB6 6749

To claim this, I am signing this object:

@Ja7ad
Ja7ad / polymorphism.go
Created March 14, 2021 05:40
polymorphism example for golang
package main
import "fmt"
type Speaker interface {
Speak() string
}
type cat struct {}
type dog struct {}
@Ja7ad
Ja7ad / dbms.go
Created March 15, 2021 05:35
Gorm Singleton DBMS (SQLite, MySQL)
package db
import (
"gorm.io/driver/mysql"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"os"
)
var DB *gorm.DB