Skip to content

Instantly share code, notes, and snippets.

View lukestanley's full-sized avatar

Luke Stanley lukestanley

View GitHub Profile
@lukestanley
lukestanley / hotspot.sh
Created February 19, 2020 10:48
Setting up hotspot corners on Ubuntu Desktop 18.04
# Something like this:
mkdir -p $HOME/.local/share/gnome-shell/extensions/[email protected]
cd ~/Downloads/
wget https://extensions.gnome.org/extension-data/customcorner%40eccheng.gitlab.com.v3.shell-extension.zip
restart
unzip [email protected] -d $HOME/.local/share/gnome-shell/extensions/[email protected]
# restart your window manager sesson, for the Wayland window manager this may require logging out, sorry!
gnome-tweaks
# enable the extension and set the hot spot regions as desired
# if you want to lock the computer, this command can help:
@lukestanley
lukestanley / compress_pdf.sh
Last active May 4, 2020 14:47
Compress PDF as JPG
# Adjust these variables as desired:
quality=80
density=200
convert -density $density "$1" -background white -alpha remove -alpha off -compress none BMP3:_temp_conv_file%02d.bmp
for f in _temp_conv_file*.bmp;
do
cjpeg -quality $quality -outfile "$f.jpg" "$f";
done;
@lukestanley
lukestanley / auto_apply_screen_layout.py
Created June 25, 2020 18:03
Detects external monitor by polling xrandr and sets up my custom layout saved from arandr because XFCE didn't do it for me.
from time import sleep
from subprocess import check_output
from os import system as run
def shell(command):
return check_output(command, shell=True)
def display_count():
return str(shell("xrandr -q")).count(' connected')
@lukestanley
lukestanley / save_open_x_window_icons.py
Last active September 14, 2021 16:13
Saves icons for open X windows to a folder
"""Saves icons for open X windows to a folder.
Pypanel inspired me, by showing that Python can get icons with Xlib.
This does that in a more simple and uses PIL to save them too :)
"""
from PIL import Image
from Xlib import X, display, error, Xatom
DIRECTORY = "/home/user/icons/"
@lukestanley
lukestanley / pingy_meter_now.py
Last active October 6, 2021 13:06
pingy_meter_now.py is a Python script that shows how reliable your Internet connection is. It graphs how long it takes 8.8.8.8 to respond to ping requests. It depends on plotille. It runs on all Unix systems that support Python 3. Unacceptable ping attempts are marked in red, passes are green, response time is shown in milliseconds.
"""
pingy_meter_now.py is a Python script that shows how reliable your Internet connection is.
It graphs how long it takes 8.8.8.8 to respond to ping requests.
It depends on plotille.
It runs on all Unix systems that support Python 3.
Unacceptable ping attempts are marked in red, passes are green, response time is shown in milliseconds.
"""
try:
import plotille
@lukestanley
lukestanley / vm_launcher.py
Last active April 22, 2022 11:41
PySide2 VirtualBox VM launcher script for Linux
"""
A PySide2 script to open selected VirtualBox VMs.
It shows a list of VirtualBox VM's and that is filtered on every key press (without pressing enter).
When enter is pressed, we launch or switch to the first matching VirtualBox machine.
Later the filter query is cleared ready for the next interaction.
VirtualBox's own GUI doesn't clear it's search box after using it.
This annoyed me so I wrote this for my Linux box.
It depends on PySide2, wmctrl, and VBoxManage.
"""
from PySide2.QtWidgets import (
@lukestanley
lukestanley / convert.js
Last active July 21, 2022 19:00
WIP, Somewhat generic functions to converts a Kendraio App JSON "website template" to a JSON Schema that can be filled in
// We already have a system that allows creating templates with empty placeholder sections for pages of sites as JSON.
// We need to take JSON that looks like this and turn it into editable real JSON Schema:
template = {
"name": "Great Example",
"domain": "great.example",
"websitemodel": [
{
"uuid": "44c2f597-79ef-49ed-9769-681f72f6b15e",
"name": "About and 404 pages",
"pagemodel": [
@lukestanley
lukestanley / xuuid.py
Last active March 26, 2023 14:56
xuuid 0.1.1 -- Extended Universally Unique Identifiers Extremely large UUIDs that are more certainly unique, descriptive, supported by tooling for short local reference. There is a distinction made between "hard" and "soft" data for an identifier.
# xuuid.py
"""
xuuid 0.1.1 -- Extended Universally Unique Identifiers
Extremely large UUIDs that are:
more certainly unique,
descriptive,
supported by tooling for short local reference.
There is a distinction made between "hard" and "soft" data for an identifier.
@lukestanley
lukestanley / browser_with_thumbs_on_top.py
Last active September 26, 2022 06:29
A tabbed browser with thumbnails of each site in the tab bar on Linux using PySide2 with basic easylist adblocking
import sys
import time
import json
import os
import hashlib
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import (
QApplication,
QTabWidget,
@lukestanley
lukestanley / echo_server.py
Created November 29, 2022 11:11
A Flask server to echo HTTP request headers as JSON to investigate issues with a CORS proxy
# A Flask server to echo HTTP request headers as JSON to investigate issues with a CORS proxy.
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/')
def index():
return jsonify(dict(request.headers))