Skip to content

Instantly share code, notes, and snippets.

View CouldBeThis's full-sized avatar

CouldBeThis CouldBeThis

  • lol nope
View GitHub Profile
@CouldBeThis
CouldBeThis / grab-commons-images-sh
Created November 4, 2021 20:55 — forked from loleg/grab-commons-images-sh
Download images and metadata from a Wikimedia Commons category or results page
#!/bin/bash
#
# Download images from a Wikimedia Commons category
#
# Highest preview resolution and metadata in XML format will be saved in subfolders.
# Usage: execute this script on a Linux command line, providing the full URL to the category page.
#
# Shell tools required for this script: wget sed grep
#
@CouldBeThis
CouldBeThis / shellcolors.sh
Created March 8, 2022 12:02 — forked from connorjan/shellcolors.sh
Definitions for the shell colors (and other attributes) through tput
# Text color - normal
fgblack="$(tput setaf 0)" # Black
fgred="$(tput setaf 1)" # Red
fggreen="$(tput setaf 2)" # Green
fgyellow="$(tput setaf 3)" # Yellow
fgblue="$(tput setaf 4)" # Blue
fgpurple="$(tput setaf 5)" # Purple
fgcyan="$(tput setaf 6)" # Cyan
fgwhite="$(tput setaf 7)" # White
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr to extract the URL
  • Use wget to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
@CouldBeThis
CouldBeThis / geanywl
Created March 26, 2022 18:29 — forked from gkatev/geanywl
Geany editor: Wrapper for per-workspace instances, opening in most recently focused window, and more
#!/bin/bash
GEANY_PATH="/usr/bin/geany"
if [ -z "$XDG_RUNTIME_DIR" ]; then
[ -z "$XDG_CACHE_HOME" ] &&
XDG_CACHE_HOME="$HOME/.cache"
XDG_RUNTIME_DIR="$XDG_CACHE_HOME"
fi
$originalsFolder = 'originals'
$resizedFolder = 'resized'
$reorganizedFolder = 'reorganized'
$originals = Get-ChildItem -Path $originalsFolder -Recurse -Include *.jpg
foreach ($original in $originals) {
$resized = Get-ChildItem -Path $resizedFolder -Recurse -Include $original.Name
$destination = ($resized.FullName).Replace($resizedFolder, $reorganizedFolder).Replace($resized.Name, "")
New-Item $destination -Type Directory