Skip to content

Instantly share code, notes, and snippets.

View krared's full-sized avatar
📡
sudo halt -q

krared krared

📡
sudo halt -q
View GitHub Profile
@krared
krared / headless.py
Created August 26, 2019 07:43 — forked from duhaime/headless.py
Python Selenium Headless Chrome OSX
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.binary_location = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver', chrome_options=chrome_options)
driver.get("http://www.duo.com")
@krared
krared / eyed3_batch_renamer.py
Last active September 16, 2019 10:51
Rename your files from ID3 info
import os
import re
import eyed3
for e,i in enumerate(sorted(os.listdir(path='.'))):
new_filename = ''
print('\n', e, i)
af = eyed3.load(i)
# check existence af.tag.artist
@krared
krared / gist:7e36e3b924197b12f768cb5b42c6831f
Last active February 14, 2022 08:02
adb fastboot install automate apps
adb reboot bootloader
fastboot flash recovery twrp.img
# fastboot boot twrp.img
fastboot reboot recovery
adb reboot recovery
for file in *.apk; do adb install $file; done
--------- SET STATIC IP ---------
sudo nano /etc/netplan/01-netcfg.yaml
sudo nano /etc/hosts
ip1 k8s-master
ip2 k8s-node1
ip3 k8s-node2
sudo netplan apply
ip a
@krared
krared / python_useful.py
Last active March 16, 2024 16:40
python useful
# divide set on 3 parts
import pickle
import numpy as np
your_set = {'1','2','3'}
triple_split = np.array_split(your_set, 3)
name_of_split = 'set_of_'
for i in range(len(triple_split)):
with open(f'{name_of_split}_{i}.pickle', 'wb') as handle:
@krared
krared / mcopy.py
Last active February 15, 2022 16:04
multithread copy for low sized files
import os
from os.path import join as jn
from shutil import copyfile
from multiprocessing import Pool, cpu_count
from datetime import datetime
from tqdm import tqdm
src = "/Users/krared/from"
dest = "/Users/krared/to"
@krared
krared / busybox.yaml
Last active November 2, 2022 14:20
k8s
apiVersion: v1
kind: Pod
metadata:
name: busybox
namespace: default
spec:
containers:
- image: busybox
command:
- sleep
@krared
krared / Xerox Phaser 3140 macOS Catalina driver update
Created December 14, 2022 07:46 — forked from santiago26/Xerox Phaser 3140 macOS Catalina driver update
How to get worked old Xerox printer in macOS Catalina
# Intro
Xerox said that Phaser 3140 hass "level 2" of support which means that Xerox not planning to update it's driver any way.
macOS no longer supports 32bit apps since macOS Catalina, and Xerox drivers installer provided at xerox.com is 32bit-app. But drivers will still work if we can install it. So we just need to install drivers itself manually.
To make it old printers work you just need to copy few files from installer to their designed locations.
# Download
You can download unpacked files from macOS 10.14 (10.11+) or unpack from official site by yourselve.
https://yadi.sk/d/K4Z-FlHFTyT2BQ?w=1
#Installation
@krared
krared / split.py
Last active December 19, 2023 08:11
split.py
def split_file(input_file, lines_per_segment=1000000, encoding='utf-8'):
with open(input_file, 'r', encoding=encoding) as file:
content = file.readlines()
num_segments = len(content) // lines_per_segment + (len(content) % lines_per_segment > 0)
for i in range(num_segments):
start_idx = i * lines_per_segment
end_idx = (i + 1) * lines_per_segment
segment_content = content[start_idx:end_idx]
@krared
krared / bash_aliases
Created February 8, 2024 13:29
.bash_aliases
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022