Skip to content

Instantly share code, notes, and snippets.

@christopher-baek
christopher-baek / new_filename_from_exif.py
Created July 19, 2015 00:17
generate a new filename based on a JPEG file's EXIF data (in YYYYMMDDHHMMSS format)
import exifread
def new_filename_from_exif(filename):
new_filename = None
with open(filename, 'rb') as f:
tags = exifread.process_file(f)
if 'EXIF DateTimeOriginal' in tags:
exif_date_time_original = tags['EXIF DateTimeOriginal']
@christopher-baek
christopher-baek / new_filename_from_mtime.py
Created July 19, 2015 00:19
generate a new filename based on a file's "last modified" time (in YYYYMMDDHHMMSS format)
import os
import time
def new_filename_from_mtime(filename):
new_filename = time.strftime('%Y%m%d%H%M%S',
time.strptime(
time.ctime(os.path.getmtime(filename))))
return new_filename
@christopher-baek
christopher-baek / .Setting Environment Variables in OS X Yosemite.md
Last active May 11, 2022 06:46
Setting Environment Variables in OS X Yosemite

Setting Environment Variables in OS X Yosemite

shell

  • Terminal apps in OS X (Terminal, iTerm, etc.) process terminals as login shells, so these variables should be set in the ~/.bash_profile and not the ~/.bashrc file.

system (including GUI apps)

  • Create a ~/Library/LaunchAgents/environment.variables.plist file to have launchd run a script at login that will set environment variables
  • Create a /usr/local/bin/set-environment-variables.sh script (or wherever configured in the *.plist file) and "export" the environment variables here (bash syntax like "export JAVA_HOME ..." doesn't work here)
  • Register the *.plist file with launchd
@christopher-baek
christopher-baek / .PDF CLI Manipulation Examples.md
Last active April 3, 2016 23:21
PDF CLI Manipulation Examples

PDF CLI Manipulation Examples

@christopher-baek
christopher-baek / .rsync Archive With FAT Device.md
Last active April 3, 2016 21:38
rsync Archive With FAT Device

rsync Archive With FAT Device

rsync Man Page:

-a, --archive               archive mode; same as -rlptgoD (no -H)
-r, --recursive             recurse into directories
-l, --links                 copy symlinks as symlinks
-p, --perms                 preserve permissions
-t, --times                 preserve times
-g, --group preserve group
@christopher-baek
christopher-baek / .Install nvm to Custom Directory.md
Last active April 3, 2016 21:40
Install nvm to Custom Directory
@christopher-baek
christopher-baek / .Install sdkman to Custom Directory.md
Last active April 3, 2016 21:40
Install sdkman to Custom Directory