Skip to content

Instantly share code, notes, and snippets.

View elmoiv's full-sized avatar
:shipit:
Busy...

Khaled ElMorshedy elmoiv

:shipit:
Busy...
View GitHub Profile
@elmoiv
elmoiv / facebook_user_id.py
Last active November 5, 2020 09:55
Getting ID of any facebook user without scraping.
import re, urllib.request
query = input()
rgx = re.split(r'((http|https):\/\/)?(www\.)?(facebook|fb)\.com\/([.a-z0-9]+)', query.lower())
name = rgx[0] if len(rgx) == 1 else rgx[5]
redirected = urllib.request.urlopen(f'https://m.me/{name}').geturl().split('%2F')
@elmoiv
elmoiv / is_int.py
Created December 7, 2019 11:38
[Python Tricks #1] Check if number is integer.
is_int = lambda n: not n % 1
@elmoiv
elmoiv / count_repeated_numbers_in_any_file.py
Last active March 12, 2020 09:17
Count repeated numbers in any file [plain-text and binary]
import re, mimetypes
def extract(file_name):
get_type = mimetypes.guess_type(file_name)[0]
type = 'rb' if get_type != 'text/plain' else 'r'
unicode = 'utf-8' if type == 'r' else None
raw_data = str(open(file_name, type, encoding=unicode).read())
return re.findall(r'\d+\.*\d*', raw_data)
def counter(extracted_data):
@elmoiv
elmoiv / 2_nums_equal_no_==.py
Created December 9, 2019 17:13
[Python Tricks #2] Check if 2 numbers are equal without ==.
is_equal = lambda a, b: not a ^ b
@elmoiv
elmoiv / thousands_separators.py
Created March 12, 2020 09:27
[Python Tricks #3] Apply thousand separators to numbers.
# Normal
## Python 2.7
n = input()
'{:,}'.format(n)
## Python 3.6
n = int(input())
f'{n:,}'
# With rounding
@elmoiv
elmoiv / gtx_1650_updater.py
Created August 28, 2020 14:31
GTX 1650 driver updater
from urllib.request import urlopen
from urllib.parse import unquote
import os
DRIVER_URL = 'https://gfwsl.geforce.com/services_toolkit/services/com/nvidia/services/' \
'AjaxDriverService.php?func=DriverManualLookup&psid=112&pfid=897&osID=57&' \
'languageCode=1078&beta=0&isWHQL=0&dltype=-1&dch=1&upCRD=0&qnf=0&sort1=0&' \
'numberOfResults=10'
DRIVER_DATA = os.popen('nvidia-smi --query-gpu=driver_version --format=csv')

Keybase proof

I hereby claim:

  • I am elmoiv on github.
  • I am elmoiv (https://keybase.io/elmoiv) on keybase.
  • I have a public key ASBnXteL7kYjn4-GRVWsY2tTowojcKaAYrotAAXzi1wrwwo

To claim this, I am signing this object:

@elmoiv
elmoiv / SoMuchLove.py
Created November 29, 2020 15:42
So Much Love
exec('>)#\'!tlxlt&.N-+ BtOr@aItPsW\'h(um6eAtTsbyps".JsAoa;d)#)_4J/V/d0Y4*2=4Yfbxp0T(E*G)?4*667V2Ux{03(Yrchzc_(pe}tuixr6wT.O)X\'180-`fJtSug\'Y=vgHnRi4dZoPcfnXeB,i\'~wG\'6,`\'&trxBtH.T-@\'U(%n4eMp5o4;^)C)f\'ipvo+tSkasUe-D&\'k,v]g\'5EUL9IMF$OkR!P4RgELS(U>\'4[5n_o1rRizvNneee.!s+o0(#nti|objl.IhItLaQpa.js9oL(<rCi}dFhmcu.%s6od;{sLo) 6torQocpWmfi'[::-1][::2])
@elmoiv
elmoiv / azan.py
Created December 19, 2020 15:43
Get Damietta Prayer Times
import requests
import re
from datetime import datetime
URL = 'https://prayertimes.me/Damietta.html'
PRAYERS = ['Fajr', 'Dhuhr', 'Asr', 'Maghrib', 'Isha']
def getPrayerTimes(page):
'''
Gets prayer times from prayertimes.me
@elmoiv
elmoiv / rdr2_convertor.py
Created March 18, 2021 08:15
Read Dead Redemption 2 Snapmatics Convertor
import os
OFFSET = 300
# Chnage this according to your SaveGame location
RDR2_DIR = 'Path\\to\\SaveGame'
RDR2_SAVE = os.path.expanduser('~') + '\\Desktop\\RDR2_SNAPMATICS'
J = os.path.join
B = os.path.basename
def convert(snapmatic):