Skip to content

Instantly share code, notes, and snippets.

@nschum
nschum / README.md
Created September 21, 2014 20:44
OS X Yosemite Messages database merger

OS X Yosemite Messages database merger

Early betas of OS X Yosemite had a bug where the library of old messages wasn't migrated. Instead a new library was created and all old messages were gone.

The bug has been fixed, but if you were affected, you still have two separate libraries. This script merged them for me. Use it at your own risk! You might end up worse than before. Backup everything beforehand. Twice.

This is what your ~/Library/Messages folder will look like if you're affected:

  • chat.db
@cjolly
cjolly / sort.md
Last active April 30, 2017 09:48
How to identify malformed characters or illegal byte sequence in files

Legacy Data

When dealing with legacy data it's been pretty common to run into malformed / illegal byte sequences in files. Figuring out what's causing the issue is often really difficult, especially when the file has thousands of rows.

Here's a trick I pretty much stumpbled upon:

nl file.txt | sort

sort: string comparison failed: Illegal byte sequence
sort: Set LC_ALL='C' to work around the problem.
@eric-hu
eric-hu / Open iterm tab here
Last active March 11, 2022 02:45
Apple script to open an iterm2 tab from right-clicking on a file or folder in Finder. To use: (1) Open Automator (2) Create a new service (3) Change "Service receives selected" drop downs to "Files or folders" in "Finder" (4) Select "Run applescript" from the sidebar, then paste this script in and save
-- Adapted from these sources:
-- http://peterdowns.com/posts/open-iterm-finder-service.html
-- https://gist.github.com/cowboy/905546
--
-- Modified to work with files as well, cd-ing to their container folder
on run {input, parameters}
tell application "Finder"
set my_file to first item of input
set filetype to (kind of (info for my_file))
-- Treats OS X applications as files. To treat them as folders, integrate this SO answer:
@mkaito
mkaito / psync.sh
Created February 13, 2012 18:45
Shell helper functions to sync and backup your Android phone over Rsync + SSH. Put them in your .zshrc
# {{{ Android phone sync (PS) and backup
PS_BACKUP_DIR=~/Android/Backup # Where to keep backups
PS_BACKUP_KEEP=60 # Days to keep backups
PS_BACKUP_ENCRYPT_TO="0x00000000" # GPG key ID to sign and encrypt to
PS_IP="192.168.0.100" # The IP your device will be found at
PS_SSH="Nexus" # The SSH host of your phone, or an SSH alias
PS_STAGING=~/Android/Sync # The staging folder for sync, sans trailing slash
PS_SDCARD=/sdcard # The sync root on the phone, sans trailing slash
PS_RSYNC_OPT="-vzuLr --no-perms" # Extra options to pass to rsync