Skip to content

Instantly share code, notes, and snippets.

@ycaty
Last active October 7, 2022 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ycaty/3bcbdde22cbf7d7aed354079b17cb452 to your computer and use it in GitHub Desktop.
Save ycaty/3bcbdde22cbf7d7aed354079b17cb452 to your computer and use it in GitHub Desktop.
from random import randint
from uuid import uuid4
import pickle
import time
from hands.ip_wait_change import ip_change_wait
import json
from termcolor import colored
from pygments import highlight
from pygments.formatters.terminal import TerminalFormatter
from pygments.lexers.web import JsonLexer
import os
class hextech():
def __init__(self,quiet=False):
# fetch existing functions
temp = [x if not "__" in x else '' for x in (dir(hextech))]
dumpy = []
for x in temp:
if x:
dumpy.append(x)
if not quiet:
mycolor = self.fetch_color()
print(colored("<hextech online>", mycolor))
self.do_swag()
self.color_json(dumpy)
self.ip_change_wait = ip_change_wait()
# END existing functions END
def do_swag(self):
colors = ['grey', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']
for color in colors:
print(colored({'all cats are yellow': 1771}, color))
def fetch_color(self):
colors = ['red', 'green', 'yellow', 'blue', 'magenta', 'cyan']
mycolor = colors[randint(0, len(colors) - 1)]
return mycolor
def ip_change_check(self, pstub):
print('yaya ip_change_check function')
self.ip_change_wait.wait_ip_change(pstub, display=1)
return 1
def gen_fout_fname(self,dirx,file_ext=".json"):
temp = uuid4()
fname = str(temp).replace("-","_")
gen_fname = dirx + fname + file_ext
print('gen_fname => ', gen_fname)
return gen_fname
def gen_fout_fname_V2(self,dirx,file_ext=".json"):
temp = uuid4()
#print(temp)
temp = str(temp).split("-")[0]
#print (temp)
fname = str(temp).replace("-","_")
gen_fname = dirx + fname + file_ext
print('gen_fname => ', gen_fname)
return gen_fname
def sleep_till_x_mins(self, minz):
'returns time to sleep till_ input minz in future'
tstampx = time.time()
till_ = minz * 60
tstampx += float(till_)
return tstampx
def grab_rng_sleepy(self,x, y):
'min max seconds || will also hard_code add 0.0 -> 0.9 '
rng1 = str(randint(x, y))
rng2 = str((randint(0, 9)))
rng = float(rng1 + "." + rng2)
return rng
def fetch_fkey(self, d):
'''
fetches first key in dict
__stub__
{ key:{
cake_key:[data,rata],
pie_key:420
}
}
'''
return [a for a in d.keys()][0]
def gen_rot_proxy_skelly(self, proxy_string):
"""proxy format=> 827.136.229.14:8888:username:password
returns => {'https': 'http://user:pass@ip:port',
'http': 'http://user:pass@ip:port}
"""
skelly = {'https': 'http://',
'http': 'http://'}
temp = proxy_string.split(":")
ip = temp[0]
port = temp[1]
username = temp[2]
password = temp[3]
skelly['https'] += username + ":" + password + "@" + ip + ":" + port
skelly['http'] += username + ":" + password + "@" + ip + ":" + port
return skelly
def color_json(self,dict):
raw_json = json.dumps(dict, indent=4)
colorful_json = highlight(
raw_json,
lexer=JsonLexer(),
formatter=TerminalFormatter(),
)
print(colorful_json)
def check_folder_exists_else_create(self,dirx):
try:
os.listdir(dirx)
except Exception as e:
print (e)
print ('Ok created dir -> ',dirx)
os.mkdir(dirx)
def check_LIST_OF_folders_exists_else_create(self,dirx_list):
created = 0
for dirx in dirx_list:
try:
os.listdir(dirx)
except Exception as e:
print (e)
print ('Ok created dir -> ',dirx)
os.mkdir(dirx)
created+=1
if created>=5:
print ('HAULT MADE 2 MANY DIRS EXITING')
exit(13645)
def notes(self):
code = """
# Get all function names in class (call from outside of class)
temp = [x if not "__" in x else '' for x in (dir(hextech))]
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment