Skip to content

Instantly share code, notes, and snippets.

View dixonge's full-sized avatar

Glenn Dixon dixonge

View GitHub Profile
@dixonge
dixonge / Delete-line-only-if-blank-in-all-files-in-folder
Created April 2, 2020 16:41
Delete a line only if blank in all files in a folder
find ./ -type f -exec sed '1{/^$/d}' {} \;

@dixonge
dixonge / Rename-files-all-subdirectories
Last active April 2, 2020 16:45
Rename files in all subdirectories. . If the file name is the same, just use filename instead of 'pattern.ext' - if the file names are different, use a pattern like '*.md'
find . -iname pattern.ext -exec rename 's/oldname/newname/' '{}' \;
@dixonge
dixonge / Extract-Title-Description-from-flickr-json
Created April 2, 2020 16:46
Extract Title and Description from json file and write it to jpg file after downloading from Flickr using Flickr Downloadr
for jpg in *.jpg; do exiftool -json=$jpg.json $jpg; done

@dixonge
dixonge / Kernel-customization-Elan-touchpad-Lenovo-Ideapad-330-Ubuntu18.04
Created April 2, 2020 16:48
Kernel customization to enable Elan touchpad on Lenovo Ideapad 330 w/ Ubuntu 18.04
#ifdef CONFIG_ACPI static const struct acpi_device_id elan_acpi_id[] = {
{ "ELAN0000", 0 },
{ "ELAN0100", 0 },
{ "ELAN0600", 0 },
{ "ELAN0602", 0 },
{ "ELAN0605", 0 },
{ "ELAN0608", 0 },
{ "ELAN0609", 0 },
{ "ELAN060B", 0 },
{ "ELAN060C", 0 },
@dixonge
dixonge / Set-photo-title-description-exiftool
Created April 2, 2020 16:49
Set photo title and description with exiftool
exiftool -title='Title goes here' -description='Description goes here' .
@dixonge
dixonge / Rename-photos-name-original-date-timestamp
Last active April 2, 2020 16:51
Rename photos with name followed by original file date/timestamp using exiftool
exiftool '-filename<file-name-text-goes-here-$CreateDate' -d %Y-%m-%d_%H-%M-%S%%-c.%%le *.jpg
@dixonge
dixonge / Rename-folders-moving-date-from-end-to-beginning-of-folder-name
Created April 2, 2020 17:00
Rename folders by moving date from end to beginning of folder name
rename -v -- 's/^(.*)-(\d{4})-(\d{2})-(\d{2})/$2-$3-$4-$1/' *
@dixonge
dixonge / VS-Code-Regex-find-line-beginning-with-specific-text-append-end-of-line
Created April 2, 2020 17:02
VS Code Regex to find line beginning with specific text and append to end of line
Find: ^(find-this.*)
Replace: $1append-this
@dixonge
dixonge / Download-articles-from-paywalled-sites
Created April 2, 2020 17:05
Download articles from even paywalled web sites (like Medium or Wired)
wget -m -np --page-requisites --adjust-extension --convert-links <web site link>
@dixonge
dixonge / VSCode-Regex-Search-Replace-Markdown-Images
Last active March 23, 2023 01:20
Regex to find markdown images and replace with img tag in VS Code (or template engine shortcode, etc.)
Find: !\[(.*?)\]\((.*?)\)
Replace: <img alt="$1" src="$2">