Automatic Tag Generator for DayOne Journals synced with Dropbox

Here’s how I created a system to automatically sync up keywords to tags in DayOne Journal. The journal is stored on my Dropbox, so if you have it in iCloud, I don’t know what you’re going to do.

First Step: Get text list of tags in a text file: (do this in the entries folder of your DayOne Journal, cd to it, if you can’t, google-fu.)

find . -type f |xargs sed -n “/<array>/,/<\/array>/p”|grep “<string>”|sed ‘s/<[^>]*>//g’|sed “s/^[ \t]*//”|tr -d ‘\011’|sort -f|uniq > tags.txt

Then copy this tags.txt folder to your home directory. Edit the file, be careful of phrases in XML that would confuse the system, Weather, Apple, DTD, String – that sort of thing, also be very careful around TLA’s as they can have unintended side effects. The later scripts that do the keyword searches don’t give a damn about cases, so your keywords or your KeYwOrDs will be equivalent.

You’ll need two more scripts. This one adds tags based on keywords passed to it as parameters: (be VERY careful, little L and capital I look very much the same, read man pages, yo)

tag.sh:

#!/bin/bash

cd /Users/username/Dropbox/Apps/Day\ One/Journal.dayone/entries

find . -type f -print0 |xargs -0 grep -L “<string>”$1″</string>”| xargs grep -li “”$1″” |xargs grep -l “<key>Tags</key>”|xargs -I file /usr/libexec/PlistBuddy -c “add Tags:Key string “$1″” file

find . -type f -print0 |xargs -0 grep -L “<string>”$1″</string>”| xargs grep -li “”$1″” |xargs grep -L “<key>Tags</key>”|xargs -I file /usr/libexec/PlistBuddy -c “add Tags array” file

find . -type f -print0 |xargs -0 grep -L “<string>”$1″</string>”| xargs grep -li “”$1″” |xargs grep -l “<key>Tags</key>”|xargs -I file /usr/libexec/PlistBuddy -c “add Tags:Key string “$1″” file

Next, you’ll need another script called updatetags.sh, looks like this:

#!/bin/bash
cat /Users/andy/Dropbox/Apps/Day\ One/tags.txt|xargs -n 1 /Users/andy/tag.sh

The last bit will be a new LaunchAgent, so go to ~/Library/LaunchAgents and mock up a plist file by copying one from there, if you need an example, try this:

more ~/Library/LaunchAgents/com.andymchugh.tag.plist
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE plist PUBLIC “-//Apple//DTD PLIST 1.0//EN”
“http://www.apple.com/DTDs/PropertyList-1.0.dtd”>
<plist version=”1.0″>
<dict>
<key>Label</key>
<string>org.andymchugh.tag</string>
<key>ProgramArguments</key>
<array>
<string>/Users/andy/updatetags.sh</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Minute</key>
<integer>00</integer>
<key>Hour</key>
<integer>06</integer>
</dict>
</dict>
</plist>

The name of the LaunchAgent has to be unique and the inside name (<string>org.andymchugh.tag</string>) should match the file name like you see here. Swap out the com bit for org, and forget the plist bit. This script will run every day at 6am. You can flavor it to your liking.

Then the final command to tie it all together:

launchctl load -w com.andymchugh.tag.plist

So now, when you write DayOne Journal entries you can mark up the tags.txt file that lives in your Dropbox. Value added, if you change this file anywhere, Dropbox will make sure it syncs up with all your other systems, so you can edit it and forget it pretty nicely as long as it’s not open-for-editing when your script fires off at 6am. That would be messy.

The first time you do it, you’ll notice your Dropbox churn for a long while and then all your other connected Dropboxes will churn as they sync up. Your iPhone and iPad will have huge downloads to do, but they’ll catch up well enough. As you create new DayOne Journal entries you can rest assured that your script will be doing keyword searching for you on your behalf and hooking up your tags to your DayOne Journal entries for you.

Just one more thing automated and out of the way. Hooray!

P.S. Backup your Journal, DIY. Be safe, be smart, learn how to use tar. man tar. Read it. Live it. tar is your delight and your savior. 🙂

EDIT: tags.sh needed a cd command first, otherwise it would just wander aimlessly. Sorry about that.

Tag Painting in Day One Journal

I’ve been really enjoying DayOne and they have recently updated their app so that the iPad, iPhone and Mac Apps can all create and manage tags. What’s been missing is a way to blast in tags based on keywords.

In this example, every time I have a journal entry with “Scott” in it, I want it to be tagged “Scott”.

Here’s how I did it:

1) Open Terminal, go to ~/Dropbox/Apps/Day One/Journal.dayone/entries

2) FOR FILES THAT DON’T HAVE TAGS, A TAG SECTION, PAINT THE SECTIONS WITH THE TAG

find . -print0 |xargs -0 grep -L “<string>Scott</string>”|xargs grep -l “Scott” |xargs grep -l “<key>Tags</key>”|xargs -I file /usr/libexec/PlistBuddy -c “add Tags:Key string ‘Scott'” file

3) FOR FILES THAT DON’T HAVE TAGS, DON’T HAVE A TAG SECTION, CREATE TAG SECTION

find . -print0 |xargs -0 grep -L “<string>Scott</string>”|xargs grep -l “Scott” |xargs grep -L “<key>Tags</key>”|xargs -I file /usr/libexec/PlistBuddy -c “add Tags array” file

4) Then go back to #2 and re-run it. Everything that has your text should be tagged with the text you choose.

Swanky! The only thing you have to watch out for here is the little l (little ell) looks a lot like a capital I (capital-eye) – might be best to copy this into a browser and set the font to Courier just to make sure before you run it, also, the last xargs does the changes, so skipping out on that might be smart. I can’t make any guarantees that it’ll work, but as far as I can tell, it works great!

YMMV. Careful.

Sharing

I ran into an inconvenience with the current way I share socially
online. I have established a new workflow. Short messages still end up
going to Twitter, and if I feel like they are worth sending to Facebook
I use “Selective Tweets” to push that single tweet forward into
Facebook. For longer entires I write them up in Day One no matter if
they are public or private and then save them there and then share them
via email if they are public with my WordPress blog. If they are private
matters, they simply get shared with Facebook with a default stringent
security setting so only the right people can see those posts.

The email routine actually has been hit and miss to start but now it’s
working out quite nicely. First I migrated my blog from WordPress.com to
Wordpress.org. This is just me moving stuff from a companies site (.com)
to the domain that I own with Scott (windchilde.com) and I figure since
I’m paying for it anyways I might as well use it. Plus the switch over
to the windchilde.com domain also allows me unlimited storage and
unlimited bandwidth so I can share photos and videos without having to
worry about running into any storage caps or having to pay for extra
storage when I’m already paying for a pretty good deal with the host
that runs windchilde.com. I originally started with WordPress.org and
figured that Jetpack, which is a feature crosstalk package between
Wordpress.com and WordPress.org, extending some of the things that I
liked about WordPress.com around my installation of WordPress.org for
free. One of those options was “Post by Email” which gave me a
gobbledegook address at post.wordpress.com. That feature never worked
for me. It was supposed to be turn-key but it fell on it’s face. So I
turned to plugins, which are how you can extend WordPress.org sites, but
not WordPress.com sites. The company keeps a tight lid on things like
that where the “DIY” system is far more flexible and accommodating. I
downloaded the plugin called “Postie” and configured it to use a POP
account that I created on the windchilde.com domain and got that all set
up. There were a wee bit of growing pains regarding how to set
Categories and Tags in the email posts that I was making out of Day One.
What I had was a rather clunky Evernote note with the copied text from
my WordPress Category page so I could refer to that to pick and choose
which category I wanted the email post to go into. This was a mess. I
thought about it for a while and when I was done working out at Anytime
Fitness it struck me in a eureka moment; Why not just use TextExpander
to do the heavy lifting? So I started TextExpander on my MBP at home and
it came up, loaded the settings from my Dropbox (neat) and I created a
new snippet, called it “Categories” and set it’s trigger to be “;cat”.
Then I loaded all my categories from WordPress into a bracketed
pull-down list that TextExpander enables you to make on-the-fly so once
I’m done with Day One editing, I can save the entry (also is stored in
my Dropbox, yay!) and then click Share, Email, and then with the open
email I can just type in the trigger for each category I want to add and
I don’t need to remember to go to Evernote to get the list, or risk a
typo screwing everything up. Using Categories this way is really
convenient and tags are a snap to add as well.

Every once in a while I like to plug software that really works for me.
I plug the tarnations out of Mac, of course, as it’s the platform that I
can actually get my work done on. The apps that run on the Mac make the
rest of it work oh-so-well. Day One is a magnificent personal journaling
app. It’s private and password protected on all my devices and stored on
my Dropbox so I don’t have to screw around with backups or restores or
worrying that my entire Journal may just flit off into nothingness if my
MBP or a flash drive decides to play dumb on me. Plus Day One has
in-built sharing features, so I can share via Email, Twitter, or
Facebook if I want to. WordPress.org is not really software that runs on
my Mac, but instead runs on a host. The host I use is iPage.com and they
do a competent job. Setting up a WordPress.org site is embarrassingly
easy, mostly just a handful of clicks and you get a starter email with
the address you should use and your username and a temporary password. I
started to use WordPress because I left LiveJournal when the Russians
bought SixApart, the company that runs LiveJournal. Not that I have
anything against russians, but I’m not a huge fan of my words in that
place, it’s a personal thing. WordPress.org also enables commenting and
stats collection and automatically publicizes on it’s own to Twitter and
Facebook and Tumblr so I don’t have to futz around and create links to
my blog posts after the fact – WordPress does it for me.

Day One stores everything, WordPress stores my public lengthy stories,
Facebook stores my private lengthy stories and Twitter and Facebook
handle the rest – the tiny stuff. It’s all held together by Dropbox,
TextExpander, Day One app, my host, WordPress.org, Twitter, Facebook,
and Tumblr. It seems complicated and it is rather too-involved, but this
way I can write freely without having to concern myself with
self-censorship or exposing the wrong people to the wrong kind of
information. This way it’s all compact and interrelated and convenient.
So far, this is great for me and it’s how I am able to “have my cake and
eat it too”, which I’m a huge fan of in general.

All these products that I mentioned are either cheap or free. Nothing
cost me an arm or a leg, even the host, when you spread the cost over a
whole year is a pittance. I could even help friends and family set up
their own WordPress.org blogs on my host if they, and Scott, agreed. So,
if you think some of this would suit you and Scott’s good with it, just
let me know.

 

Facebook Notification Autodisplay Trick

I recently moved over all my old Facebook Notes entries from the past and copied them into my Day One app for posterity. In the wayback machine I found an entry from March 25th, 2009 regarding a neat little thing I found that makes Facebook a little more neat. The entry back then covered how I found a way to make my Firefox browser automatically open up Facebook notifications as new tabs in my browser window all on it’s own. So as people that are connected to me on Facebook do things that fire off notifications, those automatically create new tabs in my browser and I don’t have to worry about playing catch up with the notification system and then overloading my browser with 20+ notifications. As I do other things my browser can tend to Facebook all on it’s own and I can look over the notifications in a more organic and pleasing way. I’ve just found a way to do the same thing on my Chrome browser and for anyone who is interested, here’s how I did it:

1) Start Chrome
2) Find the Chrome Extension RSS Live Links and install it
3) Browse to Facebook and click on your notifications, then find the RSS link and copy that to the clipboard.
4) In the options for RSS Live Links, add the RSS entry to the extensions RSS list and make sure you set the refresh time properly to where you want it and then check “Automatically open new items” checkbox. Click Save.
5) Save the extension options and then you are all set.

The extension will scan the RSS feed from Facebook every five minutes and if it notices changes it will automatically open up those new items as tabs in your Chrome browser. When you are all done, you can minimize your browser and do other things and over the day your browser will automatically fill with all the little notifications that Facebook throws down all on it’s lonesome. Then you go into your browser, see the notifications and then close the tabs (Command-W) when you are done with them. Easy peasy.