Skip to content

Instantly share code, notes, and snippets.

View peace899's full-sized avatar

Peace L peace899

  • Johannesburg, ZA
View GitHub Profile
@peace899
peace899 / sqlite.py
Created January 30, 2024 12:54 — forked from michalc/sqlite.py
Use libsqlite3 directly from Python with ctypes: without using the built-in sqlite3 Python package, and without compiling anything
# From https://stackoverflow.com/a/68876046/1319998, which is itself inspired by https://stackoverflow.com/a/68814418/1319998
from contextlib import contextmanager
from collections import namedtuple
from ctypes import cdll, byref, string_at, c_char_p, c_int, c_double, c_int64, c_void_p
from ctypes.util import find_library
from sys import platform
def query(db_file, sql, params=()):
@peace899
peace899 / expressWebview.js
Created November 28, 2023 19:29
Simple webview/express js app
//Requires: https://github.com/suchipi/webview-node and expressjs
var webview = require("webview");
var express = require("express");
const path = require('path')
const app = express();
app.use('/static', express.static(path.join(__dirname, 'public')))
@peace899
peace899 / filewatch.py
Last active August 15, 2023 19:59
Async File watchdog with watchfiles.awatch and process detected files in batches.
import asyncio
from watchfiles import awatch
from pathlib import Path
from .helpers import Iterator, AsyncIter
async def produce():
async for changes in awatch(watch_path):
for change_type, path in changes:
print(f" {change_type.name}: {path}")
from PyQt5.QtWidgets import QApplication, QMainWindow, QToolTip
import sys
from PyQt5.QtChart import QChart, QChartView, QBarSet, QPercentBarSeries, QBarCategoryAxis
from PyQt5.QtGui import QPainter, QPixmap, QTransform
from PyQt5.QtCore import Qt, QPointF, QRect
from functools import partial
class Window(QMainWindow):
def __init__(self):
@peace899
peace899 / 47091216.py
Created November 25, 2020 09:38 — forked from eyllanesc/47091216.py
47091216
from PyQt5.QtCore import *
from PyQt5.QtGui import QDrag
from PyQt5.QtWidgets import *
class TreeWidget(QTreeWidget):
customMimeType = "application/x-customTreeWidgetdata"
def mimeTypes(self):
mimetypes = QTreeWidget.mimeTypes(self)
@peace899
peace899 / organize.py
Created November 9, 2020 14:34 — forked from sqordfish/organize.py
Python script for organizing files in windows into multiple folders by file type. I made this primarily to organize my downloads folder.
#Author: Jacob Rust
#Date: 7/8/2013
#Description:This script organizes downloaded files into separate folders depending
#on the file type. This was made for windows systems.
#Download directory should be the first command line argument
#New file types can be added to the dictionary in the main method
import os
import sys
import hashlib
@peace899
peace899 / both.json
Created May 11, 2020 14:54 — forked from cglacet/both.json
Comparing concave from Turf and Concaveman
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@peace899
peace899 / folium_leaflet_cm_drag.py
Last active April 19, 2019 15:39
Draggable circlemarker in folium with custom JS
import folium
from branca.element import Element
start_coords = (27.815318747058587, -26.607971936214536)
folium_map = folium.Map(location=start_coords, zoom_start=3)
map_id = 'map_' + folium_map._id
circlemove_js = """\nfunction circlemove(e) {{
var clickedCircle = e.target;
@peace899
peace899 / b315_wanswitch.py
Created August 6, 2018 16:59
Script to change Huawei B315 connection mode from LAN Only to Dynamic IP and vice versa
import time
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException, NoSuchElementException
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import Select