Skip to content

Instantly share code, notes, and snippets.

@GluTbl
GluTbl / PdfSplitter.py
Last active February 3, 2021 15:03
Pdf Duplex printing split file
#!/usr/bin/python3
import argparse
import os
import sys
from pathlib import Path
from PyPDF2 import PdfFileWriter, PdfFileReader
@GluTbl
GluTbl / sample.sh
Last active March 29, 2021 08:02
[sudo running in as user mode] #linux
#!/bin/bash
#Detect the name of the display in use
display=":$(ls /tmp/.X11-unix/* | sed 's#/tmp/.X11-unix/X##' | head -n 1)"
#Detect the user using such display
user=$(who | grep '('$display')' | awk '{print $1}' | head -n 1)
#Detect the id of the user
uid=$(id -u $user)
@GluTbl
GluTbl / ReadMe.md
Created March 2, 2021 05:06
[Esptool]
@GluTbl
GluTbl / sample.js
Last active March 25, 2021 15:39
[Text formating at Js]
//Source https://stackoverflow.com/questions/7975005/format-a-javascript-string-using-placeholders-and-an-object-of-substitutions
const stringWithPlaceholders = 'My Name is {name} and my age is {age}.';
const replacements = {
name: 'Mike',
age: '',
};
@GluTbl
GluTbl / logger_util.py
Last active August 11, 2024 17:00
[Python logger] get logging in python #python
import logging
# Copied from https://stackoverflow.com/a/56944256
class LogFormat(logging.Formatter):
BLUE = {"color": "blue"}
GREEN = {"color": "green"}
GREY = {"color": "grey"}
YELLOW = {"color": "yellow"}
RED = {"color": "red"}
@GluTbl
GluTbl / ultrasonic_distance_measure.ino
Created April 26, 2021 05:31
[Ultrasonic distance measurre without delay by using interupts]
#include <Arduino.h>
#include <Ticker.h>
#define ULTRASONIC_PIN_INPUT D1
#define ULTRASONIC_PIN_OUTPUT D4
@GluTbl
GluTbl / droidVNC.sh
Last active June 6, 2021 03:55
[DroidVNC] #shell #linux
#!/bin/bash
echo "Connecting to the adb of the droid"
adb connect 192.168.29.246 &&
echo "Giving Accessibility Permision...."
adb shell "su -c 'settings put secure enabled_accessibility_services net.dinglisch.android.taskerm/net.dinglisch.android.taskerm.MyAccessibilityService:com.joaomgcd.autoinput/com.joaomgcd.autoinput.service.ServiceAccessibility:de.abr.android.avnc/de.abr.android.scclib.etc.AcService'" &&
sleep 5
echo "Launching app...."
adb shell am start -n de.abr.android.avnc/de.abr.android.avnc.activity.VncActivity &&
@GluTbl
GluTbl / pdf_eroder.py
Last active July 3, 2021 09:00
[Pdf Erorder] #python
import os
import shutil
import sys
import traceback
import uuid
import time
import cv2
import numpy as np
from fpdf import FPDF
from pdf2image import convert_from_path, pdfinfo_from_path
@GluTbl
GluTbl / image2stl.py
Created July 6, 2021 04:50
[image to stl] #python3
#Source code copied from https://github.com/andrisdru/image2stl
#pip3 install numpy-stl pillow argparse
import argparse
import numpy as np
from stl import mesh
from PIL import Image
@GluTbl
GluTbl / subprocess_utill.py
Created July 17, 2021 08:48
[Python runnng subprocess]
################Executing Command################
def execution_timer(time_out, cmd_process):
kill = lambda process: process.kill()
my_timer = Timer(time_out, kill, [cmd_process])
try:
my_timer.start()
stdout, stderr = cmd_process.communicate()
finally: