Skip to content

Instantly share code, notes, and snippets.

@ew-git
ew-git / mouserecorder.py
Created August 26, 2022 00:49
Python script to record mouse click locations
from pynput import mouse, keyboard
import time
from datetime import datetime
import os.path
def timestamp_ms():
return int((datetime.utcnow() - datetime(1970, 1, 1)).total_seconds() * 1000)
FILE_NAME = os.path.expanduser(os.path.join("~", "Documents", f"records_{timestamp_ms()}.csv"))
MAX_TIME_SECONDS = 60
@ew-git
ew-git / npp-r-function-parser.xml
Last active September 18, 2018 04:04
A Notepad++ functionList.xml parser for R functions.
<!--Put this in associationMap-->
<association langID="54" id="r_function"/>
<!--Put this in parsers-->
<parser id="r_function" displayName="R function" commentExpr="(#.*?$)">
<function
mainExpr="(^\s*[a-zA-Z0-9_\.\$]+[\s<\-=]+function\s*\()"
displayMode="$functionName">
<functionName>
<nameExpr expr="^\s*([a-zA-Z0-9_\.\$]+)"/>
@ew-git
ew-git / image-greyer.r
Created September 6, 2018 02:01
R script to generate blank versions of images.
library(magick)
imagefiles <- list.files(pattern = "(\\.png|\\.jpg|\\.jpeg)")
imagefiles <- imagefiles[!grepl("blank-", imagefiles)]
for (imgname in imagefiles){
img <- image_read(imgname)
img <- image_fill(img, "lightgray", fuzz = 100)
img <- image_annotate(img, imgname)
@ew-git
ew-git / pdf-merge-text.r
Last active September 6, 2018 01:52
R script to generate LaTeX which combines fronts and backs of a document.
inclpdf <- function(fronts, backs, npages, reverse = FALSE){
if (reverse){
for (i in 1:npages){
cat("\\includepdf[pages=", i, "]{", fronts, "}\n",
"\\includepdf[pages=", npages - i + 1, "]{", backs, "}\n",
sep = "")
}
} else {
for (i in 1:npages){
cat("\\includepdf[pages=", i, "]{", fronts, "}\n",