Skip to content

Instantly share code, notes, and snippets.

View imneonizer's full-sized avatar
:octocat:
Developing for the python community!

Nitin Rai imneonizer

:octocat:
Developing for the python community!
  • SmartCow.ai
  • Delhi, India
  • 04:07 (UTC +05:30)
  • X @imneonizer
View GitHub Profile
import os
import glob
import shutil
import uuid
class TempFile:
def __init__(self, base_path, ext):
self.path = os.path.normpath("{base_path}/{rand}{ext}".format(
base_path=base_path,
rand=str(uuid.uuid4()),
#requirements: requests, pillow, imthread
#usage: python yd-downloader.py -i urls.txt -o images --threads 1000
import requests
from requests import exceptions
from PIL import Image
import os
import time
import argparse
@imneonizer
imneonizer / resolve-apt-repo-problem.md
Last active May 14, 2020 05:37
How to resolve apt repository problem on linux
Error: Could not resolve 'bionic' unable to find package

These problems occur when sources repository address is configured wrong.
To fix this problem sudo nano /etc/apt/sources.list find out which repository is causing problem and remove it.

To add add default repositories use below command:

sudo add-apt-repository main
@imneonizer
imneonizer / auto_tmux_attach.sh
Created April 13, 2020 15:16
add this file to ~/.bashrc and when ever you will do a ssh connection / open terminal, a tmux session will automatically created/attached
if (`tmux attach -t backup`) ; then
echo "tmux attach -t backup"
else
echo "tmux new -s backup"
`tmux new -s backup`
fi
// collect images links
function collect(){
images = document.getElementsByClassName("serp-item")
images = Object.keys(images).map(key => JSON.parse(images[key].getAttribute("data-bem"))['serp-item']["img_href"])
return images
}
// returs boolean value to check if page end has reached
function footer_hidden(){

Download from google drive using wget

Set the file to Public, get sharing link and extract FILEID

for small files These can also be directly download by visiting the address or using wget

wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O FILENAME

for large files

{
"pushitbot": "558fc32f64b2adaf889bc29bb97d8150"
}

How to find disk usage information on linux

Install this simple tool ncdu for linux

sudo apt install ncdu

After this simply run the command:

sudo ncdu -x /
import cv2
def VideoCapture(uri, width, height, latency):
gst_str = ('rtspsrc location={} latency={} ! '
'rtph264depay ! h264parse ! omxh264dec ! '
'nvvidconv ! '
'video/x-raw, width=(int){}, height=(int){}, '
'format=(string)BGRx ! '
'videoconvert ! appsink').format(uri, latency, width, height)
return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)
@imneonizer
imneonizer / how to rename hostname on linux.md
Created February 25, 2020 08:34
how to rename hostname on linux