Skip to content

Instantly share code, notes, and snippets.

View molcay's full-sized avatar
:octocat:

M. Olcay Tercanlı molcay

:octocat:
View GitHub Profile
@molcay
molcay / UsefulScripts.md
Created July 8, 2020 07:35
Some useful scripts

Some useful scripts

  • Hide the creator(alexandra) gif of sci-hub.tw webpage:
[...document.querySelectorAll('[href="//sci-hub.tw/alexandra"]')].forEach(hideme)
@molcay
molcay / downloader.py
Created May 5, 2020 07:55
Download multiple URLs simultaneously
"""
A rudimentary URL downloader (like wget or curl) to demonstrate Rich progress bars.
SOURCE: https://github.com/willmcgugan/rich/blob/master/examples/downloader.py
"""
from concurrent.futures import ThreadPoolExecutor
from functools import partial
import os.path
@molcay
molcay / logging.sh
Last active May 27, 2020 08:58
Logging helpers for shell
##### Logging Setup #####
# NOTE this code piece taken from: https://gist.github.com/goodmami/6556701
exec 3>&2 # logging stream (file descriptor 3) defaults to STDERR
_trc_lvl=0
_crt_lvl=1
_err_lvl=2
_wrn_lvl=3
_inf_lvl=4
_dbg_lvl=5
@molcay
molcay / log_helper.py
Last active June 25, 2021 08:46
Utililty class and method for general-purposed
import logging
import logging.handlers as handlers
from pathlib import Path
DEFAULT_LOG_FORMAT = '%(asctime)s [%(levelname)s] (%(name)s) [%(filename)s:%(lineno)d] [%(threadName)s] - %(message)s'
LOG_BASE_DIR = Path('/var/log/app')
def create_logger(name: str,
log_level: str = logging.INFO,

Q 1: A program that gets the input and returns the output.

Input 1

data = {
    "x": {
        "w": 5,
    },
 "x/y": {
@molcay
molcay / scripts.md
Last active November 18, 2020 13:39
Bazı siteler için toplam harcanan paranın miktarının bulan scriptler

UYARI: Önce sayfa sonuna kadar inip, bütün paralar görünmesini sağlayınız. Bütün paraların göründüğünden emin olduktan sonra Geliştirici Araçlarından JS Konsolu açıp, ilgili sitenin scriptini yapıştırıp ne kadar harcadığınızı görebilirsiniz.

  • YemekSepeti:
[...document.querySelectorAll('div.order-item > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > strong:nth-child(1)')].map(e => Number.parseFloat(e.innerText.replace('TL', ''))).reduce((acc, cur) => acc + cur, 0)
  • Hepsiburada:
@molcay
molcay / install_python3.7.4.sh
Last active August 6, 2019 13:01
Python v3.7.4. installation commands for Debian 9-based systems.
sudo apt update -qq
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget curl
mkdir -p /opt/Downloads && cd /opt/Downloads
curl -O https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tar.xz
tar xf Python-3.7.4.tar.xz
cd Python-3.7.4
@molcay
molcay / Pipenv Notes.md
Created May 24, 2019 12:08
Notes about Pipenv

Pipenv Notes

  • Install pipenv:
pip install pipenv
  • Create or activate virtualenvironment:
pipenv shell
import random as r
import string
def randomized_default():
domains = [string.ascii_uppercase, string.ascii_lowercase, string.digits]
r.shuffle(domains)
as_list = list(''.join(domains))
r.shuffle(as_list)
return ''.join(as_list)
@molcay
molcay / app.py
Last active May 24, 2019 12:11
Sample application for peewee ORM
#!/usr/bin/env python3
"""app.py
Peewee demo app
Usage:
app create_db
app create_users
app update_user --user <user_id> --name <new_name>
app update_user2 --user <user_id> --name <new_name>
app update_user3 --user <user_id> --name <new_name>