Skip to content

Instantly share code, notes, and snippets.

@ecspresso
ecspresso / wallpaper_changer.sh
Created October 30, 2023 14:08
Change background image with cron, using images from a folder where the current background image is.
#!/bin/bash
PID=$(pgrep gnome-session | tail -n1)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ | tr '\0' '\n' |cut -d= -f2-)
current_image=$(gsettings get org.gnome.desktop.background picture-uri | xargs echo)
if [ "$1" == "echo" ]; then
echo $current_image
@ecspresso
ecspresso / pom.xml
Created May 8, 2023 07:43
POM.xml template for creating a fat jar and a Windows executable with launch4j using Maven.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ecspresso</groupId>
<artifactId>${appName}</artifactId>
<version>${version}</version>
@ecspresso
ecspresso / ImageHandler.java
Created January 17, 2022 13:31
Create ImageIcons from a given path.
import javax.swing.ImageIcon;
public class ImageHandler {
/**
* Returns an ImageIcon, or null if the path was invalid.
* https://docs.oracle.com/javase/tutorial/uiswing/components/icon.html
* @param path Path to image file.
* @return A new ImageIcon
*/
protected static ImageIcon createImageIcon(String path) {
@ecspresso
ecspresso / QuakeTerminal.ahk
Created November 16, 2020 08:42 — forked from andrewgodwin/QuakeTerminal.ahk
AutoHotkey script for making Windows Terminal appear/disappear with a single keypress
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
F12::ToggleTerminal()
ShowAndPositionTerminal()
{
WinShow ahk_class CASCADIA_HOSTING_WINDOW_CLASS
[System.Security.Principal.NTAccount]::new($(whoami.exe)).Translate([System.Security.Principal.SecurityIdentifier]).Value
@ecspresso
ecspresso / keepassotp_any_posh_version.ps1
Created May 26, 2020 14:32
Autoupdate KeePassOTP for KeePass (for any version of PowerShell edition)
$updateurl = 'https://firebasestorage.googleapis.com/v0/b/rookiestyle-43398.appspot.com/o/versioninfo.txt?alt=media&token=89da60c0-f331-4334-94bb-0dccf617818f'
$iwr = (New-Object System.Net.WebClient).DownloadString($updateurl)
$version = ($iwr.split() | Select-String '^KeePassOTP') -replace 'KeePassOTP:',''
if(-not (Test-Path -Path 'HKCU:\Software\keepass')) {
New-Item -Path 'HKCU:\Software\keepass' -ItemType Directory
}
try {
$keepassotp = (Get-ItemProperty -Path 'HKCU:\Software\keepass\' -Name 'keepassotp' -ErrorAction Stop).keepassotp
@ecspresso
ecspresso / keepassotp.ps1
Last active September 30, 2020 20:14
Autoupdate KeePassOTP for KeePass
function Format-KeePass {
param(
[Parameter(Mandatory=$true, ValueFromPipeLine=$true)]
[String]$update_information
)
# Split data on new line
$split = $update_information.split()
# Save delimiter
$delimiter = $split[0]
function Join-Array {
param (
[int]$ItemsPerLine,
[string]$separator,
[string[]]$array
)
for($i = 0; $i -lt $array.length; $i = $i + $ItemsPerLine) {
$array[$i..($i + $ItemsPerLine)] -join $separator
}
@ecspresso
ecspresso / poe_sockets.py
Created January 7, 2020 18:42
Apply currency fast in POE
import pyautogui
# valuta = 154, 636 # jewellersOrb
# valuta = 216, 637 # fusing
# valuta = 736, 338 # gemcutter
valuta = 591, 329 # arm, eq
# valuta = 495, 332 # black, vapen
item = 453, 671
@ecspresso
ecspresso / drscripto_rss_pushbullet.ps1
Created November 22, 2019 10:44
Get updates from Dr Scripto via PushBullet
$path = "$PSScriptRoot\drscripto_LastSeen.txt"
$apikey = '' # Secure String
if(-not (Test-Path -Path $path)) {
$null | Out-File $path
}
$latest = Get-Content $path
$rss = Invoke-RestMethod -Uri 'https://blogs.technet.microsoft.com/heyscriptingguy/feed/' | Select-Object -First 1