Skip to content

Instantly share code, notes, and snippets.

View iKlotho's full-sized avatar
🏠
Working from home

Umut Kahriman iKlotho

🏠
Working from home
  • İstanbul, Turkey
View GitHub Profile
@iKlotho
iKlotho / tqdm_gevent.py
Created August 20, 2020 10:29
Using tqdm progress bar with gevent
import gevent
import random
from gevent import local
from contextlib import contextmanager
from tqdm import tqdm
# globals
stash = local.local()
count = lambda: stash.count
tasks = []
@iKlotho
iKlotho / aiohttp_client_proxy.py
Created July 25, 2020 22:08
aiohttp pass proxy to ClientSession
from aiohttp.client import ClientSession
class CustomClientSession(ClientSession):
"""
Use proxy on every request when passed to Client
Usage
>> async with CustomClientSession(proxy="http://1.1.1.1:3128") as session:
"""
@iKlotho
iKlotho / youtube.py
Created February 19, 2020 21:27
Youtube Python Upload
"""
Upload a video to youtube
"""
import os
import time
import cookielib
import json
import requests
import mechanize
from BeautifulSoup import BeautifulSoup
@iKlotho
iKlotho / filter.conf
Created February 17, 2020 08:02
FreeSWITCH Invite DOS Attack Fail2ban Filter
# It only works if you are accepting users from domain address not ip. Otherwise it will ban all your users.
# add this line to /etc/fail2ban/filter.d/freeswitch.conf
# in failregex line
%(_pref_line)s \[WARNING\] sofia_reg\.c:\d+ SIP auth challenge \(INVITE\) on sofia profile \'internal\' for \[\+?(\d+|\w+)@(?:[0-9]{1,3}\.){3}[0-9]{1,3}\] from ip <HOST>$
@iKlotho
iKlotho / test.py
Created February 3, 2020 08:30
fastapi - asyncpg
async def setup_database():
global connection_pool
connection_pool = await asyncpg.create_pool(
user=os.getenv('PGUSER', 'x'),
password=os.getenv('PGPASS', 'xx'),
database='xx',
host='xxx',
port=5432
)
@iKlotho
iKlotho / nvi_handler.py
Last active March 12, 2023 12:13
NVI Adres Sorgulama Python API (adres.nvi.gov.tr/VatandasIslemleri/AdresSorgu)
import requests
import random
import json
from bs4 import BeautifulSoup
captcha = "03AGdBq25SyMYChQqUZMbWMftzdsGPyK9TztL3q95FoSWY-4042gCR56xovRI3i6i2Son38GjbKVf86X4P-L7GQU_jbZtSK4PwA8zZAPWDNU7FQ-RM1fpnMcUpyxtXOk635UOr2YR_P9Jo5o_72N0OqdCUjDJk6ohOUJPLUy4aAZDHd_oEdfRpmVJpkqCqL2aPtx5BFVqvx9QvQ5wIugNyPk4V3mDVTgxV2_0nieKyLTt92fNr34AeEStL16DQrXk02_zMgKaIHbNE4yYRkJ1Ac0m6Qle3PG_L4ochPAswsdLTgmukolRF8HtZmOU3rJ7F3K4HJ7j4bNBqmf9_KQ3_U-HM2T-MVZiHygJDF4EEg_DL3GsSA8ZGUXRQuk09LKTIfUt6AaNO81ARwCGLQFWbn2-po_K_6GKqkMm5ZxFnu0pWcZeXciJL5nBZDaAYf6YypcrNcWXsw_l4"
class NVIScraper:
""" NVI address query API
@iKlotho
iKlotho / cordovacall.java
Created November 7, 2019 12:28
CordovaCall Fix Huawei Permission Request
if(permissionCounter == 2) {
Intent intent = new Intent();
// context.startActivity(intent);
// Intent phoneIntent = new Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS);
// phoneIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.setComponent(new ComponentName("com.android.server.telecom","com.android.server.telecom.settings.EnableAccountPreferenceActivity"));
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
this.cordova.getActivity().getApplicationContext().startActivity(intent);
} else {
this.callbackContext.error("You need to accept phone account permissions in order to send and receive calls");
@iKlotho
iKlotho / terminator_config
Last active January 8, 2021 22:41
terminator config with gruvbox theme, custom layout and auto login ssh
# https://blog.ropnop.com/configuring-a-pretty-and-usable-terminal-emulator-for-wsl/
[global_config]
always_split_with_profile = True
focus = system
title_inactive_bg_color = "#657b83"
title_transmit_bg_color = "#dc322f"
[keybindings]
switch_to_tab_1 = <Primary>1
switch_to_tab_2 = <Primary>2
@iKlotho
iKlotho / consume_MT_messages_multipart.py
Last active November 28, 2022 12:05 — forked from pguillem/consume_MT_messages.py
Jasmin Consume MT messages Multipart Message
# -*- coding: utf-8 -*-
"""
Original file is the https://gist.github.com/pguillem/5750e8db352f001138f2
This version of the script uses psycopg2 instead of PySQLPool and handles multipart messages
"""
import sys
import pickle
from twisted.internet.defer import inlineCallbacks
@iKlotho
iKlotho / validate_taginputs.js
Created April 28, 2019 15:22
Validating TR numbers with bootstrap taginputs
/*
*https://github.com/jackocnr/intl-tel-input
*https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/
*/
$('#send_sms_numbers').on('beforeItemAdd', function(event) {
// event.item: contains the item
// event.cancel: set to true to prevent the item getting added
// TR numbers startswith 90
// we also delete 0 at the beginning for our convenience