Skip to content

Instantly share code, notes, and snippets.

@ShannonScott
ShannonScott / Docker_notes.md
Last active March 25, 2020 23:30
[Docker Notes] Docker notes. #tags: docker, notes

Docker Notes

Notes on using Docker in practice.

Override entry point in run command

Add the following option: --entrypoint "/bin/bash"

Access running container

@ShannonScott
ShannonScott / pinboard_export_to_text.py
Created October 11, 2019 22:55
[Pinboard Export as Text] Print Pinboard's JSON bookmark export as text. #tags: python, utility
'''
Print Pinboard's JSON export as text
'''
import sys
import json
import gzip
if len(sys.argv) < 2:
# Read from stdin pipe
@ShannonScott
ShannonScott / Python Copy Text to Clipboard (Linux).md
Created October 11, 2019 22:14
[Python Copy Text to Clipboard] Copy Text to the Linux / X Clipboard. #tags: linux, python

Copy Text to the Linux / X Clipboard

from subprocess import Popen, PIPE

def copy_clipboard(msg):
    ''' Copy `msg` to the clipboard '''
    with Popen(['xclip','-selection', 'clipboard'], stdin=PIPE) as pipe:
        pipe.communicate(input=msg.encode('utf-8'))
@ShannonScott
ShannonScott / Rename PDFs by Title.md
Last active October 10, 2019 16:37
[Rename PDFs by Title] Rename a directory of PDF files by their title as reported by `pdfinfo`. #tags: bash, pdf

Rename PDFs by Title.md

Rename a directory of PDF files by their title as reported by pdfinfo.

Bash script

#!/bin/bash
# Rename all PDFs in current dir to their title as reported by `pdfinfo`

mkdir -p "renamed"
@ShannonScott
ShannonScott / Install Anaconda Environment for Jupyter.md
Last active September 2, 2021 22:24
[Install Anaconda Environment for Jupyter] Make a conda environment available in Jupyter #tags: jupyter, python, anaconda
@ShannonScott
ShannonScott / Process files in Bash.md
Last active November 27, 2019 22:11
[Batch Process Files in Bash] Process a batch of files in Bash. #tags: bash

This is a super simple gist, but I never can remember it.

#!/bin/bash	

for file in *.jpg
do
    echo "converting $file"
    convert "$file" "$(basename "$file" .jpg).dds"
done
@ShannonScott
ShannonScott / readme.md
Last active June 4, 2023 20:35
[Moving efficiently in the CLI] Key-combination reference for movement in the shell. #tags: mac, linux, bash
@ShannonScott
ShannonScott / readme.md
Last active August 2, 2019 16:24
[Disk Usage] Sorted list of the total size of all children under the current directory. #tags: linux, mac, bash

Sorted list of the total size of all children under the current directory

Linux

alias ds='du -sh * | sort -h'

Mac

You must first (IIRC) install GNU gsort (via homebrew).

@ShannonScott
ShannonScott / readme.md
Created August 2, 2019 16:18
[Mac `open` command on Linux] Mac-style open command on Linux. #tags: mac, linux, bash

Mac-style open command on Linux

alias open=xdg-open
@ShannonScott
ShannonScott / readme.md
Last active August 2, 2019 16:14
[Mac copy/paste commands on Linux] pbcopy and pbpaste from MacOS on Linux. #tags: linux, mac, bash

Mac-style CLI copy / paste on Linux

alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'

Example usage

Pipe clipboard contents to do_something.bash and copy results back to the clipboard.