Pages

Thursday, December 7

Sort emails by year, using AppleScript

So, way back when I was using Thunderbird, I had this awesome plugin that organized my archived emails by year. It was super handy for finding stuff or just taking a trip down memory lane.

But when I switched to Mail.app, I couldn't find a similar plugin that I liked. Plus, even if one existed, I'd have to install it on every new Mac I got. So, I decided to take matters into my own hands and whip up some AppleScript magic.

In the code, you can pick a folder (sourceFolder) - in my case, it's "Recovered". You also need to specify your account name, like "iCloud" in my code. If your account goes by a different name, like "Exchange" or "Gmail", just tweak that part.

Then there's this variable called "yearsMailbox" at the top of the code, (in my case "Years") which is basically the folder where the emails will end up based on their years. You can rename it if you're feeling fancy.

You can probably make this more efficient by having it map the year folders one time instead of checking every time it wants to move a message, but I feel you're just playing "AppleScript golf" at that point.  This works.  It works great.  Moving on.

tell application "Mail"

-- Specify the parent mailbox where the year folders are located

set yearsMailbox to mailbox "Years" of account "iCloud" -- Adjust if the path is different

-- List of sub-mailboxes under 'Years', each named with a four-digit year

set yearFolders to every mailbox of yearsMailbox

-- Specify the source folder where emails are currently located

set sourceFolder to mailbox "Recovered" -- Replace "SourceFolder" with the name of your folder

repeat with eachMessage in (get messages of sourceFolder)

set messageDate to date received of eachMessage

set messageYear to year of messageDate as string

-- Check if a folder for the year exists and move the message

repeat with eachYearFolder in yearFolders

if name of eachYearFolder is messageYear then

move eachMessage to eachYearFolder

exit repeat

end if

end repeat

end repeat

end tell





Please leave comments below.

Monday, November 13

Moving from Omnifocus to Reminders

Let's say you're like me, an avid Omnifocus user, but you've been hearing great things about Reminders on MacOS/iOS/iPadOS, and you want to give it a shot.  Well, here's an AppleScript that will move everything over for you. It won't delete anything out of Omnifocus, so nothing will get messed up, but, it will take your existing projects and move them over as separate lists, then move the tasks over, preserving flagged, priorities, and the notes in each task (to Reminders.app's limitations).

TWO CAVEATS THOUGH

1. It can't move nested (subtasks) tasks from Omnifocus over, this is a very tricky problem to solve, and it's beyond my AppleScripting skills to access the subtasks and move them over properly.  
2. I wanted to implement "tags" from Omnifocus over to the "tags" feature in Reminders, however Apple doesn't have "tags" as a Reminders dictionary item in AppleScript.

Other than that, this works fine:

property defaultList : "Inbox"


tell application "OmniFocus"

activate

tell front document of application "OmniFocus"

set theProjects to flattened projects -- Gets all projects, ignoring folders

repeat with aProject in theProjects

set projectName to name of aProject

set projectStatus to completed of aProject

-- Process only if the project is not completed

if not projectStatus then

set theTasks to tasks of aProject

-- Create a list in Reminders for each non-completed project

my createListInReminders(projectName)

repeat with aTask in theTasks

set taskStatus to completed of aTask

-- Process only if the task is not completed

if not taskStatus then

set theTaskName to name of aTask

set theNote to note of aTask

set theDueDate to due date of aTask

set isFlagged to flagged of aTask -- Check if the task is flagged

-- Determine priority based on flagged status

set thePriority to 0 -- default no priority

if isFlagged then

set thePriority to 1 -- high priority for flagged tasks

end if

-- Add tasks to the corresponding list in Reminders

my createReminder(projectName, theTaskName, theDueDate, theNote, thePriority)

end if

end repeat

end if

end repeat

end tell

end tell


on createListInReminders(listName)

tell application "Reminders"

if not (exists (list listName)) then

make new list with properties {name:listName}

end if

end tell

end createListInReminders


on createReminder(thelist, theTask, theDate, theNote, thePriority)

try

set theBody to theNote

tell application "Reminders"

if not (exists (list thelist)) then

my createListInReminders(thelist)

end if

tell list thelist of default account

if theDate is not missing value then

make new reminder with properties {name:theTask, remind me date:theDate, body:theBody, priority:thePriority}

else

make new reminder with properties {name:theTask, body:theBody, priority:thePriority}

end if

end tell

end tell

on error

-- Error handling can be implemented here if needed

end try

end createReminder





Please leave comments below.

Wednesday, January 4

A shortcut to make a PDF out of a webpage and save it to Notes.app

While on MacOS (and iOS) you can use the Share Sheet from Safari to share a webpage to Notes, it only shares the title, URL, and the favicon to save to a new Note.

I wanted a PDF of the entire page, so I wrote a shortcut to do it.


Here's a link to it, but also, here's a screenshot, since I know the shortcut links can be somewhat unreliable.




It grabs the input from the share sheet, gets the content of the page, and it saves the contents of the page as a variable called "Title".  Then it creates a PDF from the shortcut input.  It also grabs the URL from the shortcut input

Then I use the output of the variable "Title" in the Text block to grab the Name of the page:


Then it creates a Note with the title of the Note as the "Name" from the Title variable in a folder in my notes called "Scans", appends the URL from the "Get URLs" block and saves that in the Note, then appends the PDF to it.



Please leave comments below.

Thursday, April 8

Call of Duty Error 6034 for the Xbox

Several friends and I play Call of Duty nearly every night.  However, Activision’s most recent multiplayer update broke the heck out of Call Of Duty Modern Warfare’s Multiplayer mode. Luckily, my buddy Nigel figured out how to fix it, so here I am writing it down for you. 

Go to the Home menu, put your selector (cursor) on the game, hit start (not “A”). A menu will come up, on that menu it says “Manage Game and Add-Ons”. 

Select it, then go into the Addons section on the right.  You will need to remove some packages 

Look for Multiplayer Pack 2 (9.1 GB). Uncheck this one. 
Look for Multiplayer Pack 3 .  Uncheck this one. 

You need to have Multiplayer Pack 2 (22 GB) and Mutiplayer/Special Ops packs installed. 

Over on the night select save or whatever to save the state of the game. (To uninstall those two packages)

Now restart the game. You should be good. 

Wednesday, April 17

Evernote, Omnifocus, and my productivity

Over the past several years my job here at Cisco Talos has changed drastically.  I took on new roles, which is awesome and exciting, but in the process while trying to organize and create process and clarity for my team and those that work with my team, I lost my personal productivity.  Something I've written about extensively on this blog.

I shifted from Evernote (which I've been using forever, as readers of this blog will know) to Notes.app, and from Omnifocus (Also have been using it forever) to Reminders.app, all in an attempt to reduce the amount of 3rd party apps I had installed on my laptop, iPad, and iPhone and use a "native Apple experience".

I quickly outgrew them both.   I found out that Notes really tops out at around 2000 notes, then it becomes basically nonfunctional. My notes are not your typical Apple Notes.app "jot down a few things" type Notes though.  I've had a lot of people tell me that Notes handles their notes fine.  My notes have attachments, drawings, photos, complex formatting, etc.  I have thousands and thousands of notes.  I just don't think Notes.app could handle it.  Another feature I missed: Notes doesn't allow you to "Tag".  I can arrange my notes by topic, much like the "Notebook" feature in Evernote, but I can't "tag" something in Notes.app.

For example, how I use this in Evernote, and I'll touch on this later as well...  let's say I am going to a conference.  I get the agenda for the conference, my flights, my receipts, my notes, my meetings, everything that I am doing at the conference, I tag it something that represents the conference.  For example, my tag for "CiscoLive United States" is "clus".  I can find everything regardless of Notebook or arrangement with that tag.   I could compensate for this in Notes.app with something like #clusat the top of the note, and that worked for awhile, but as I said earlier, Notes.app's searching at thousands-of-notes scale is ridiculously slow, and let's not get started with the frustration of syncing across devices.

More on searching...  Notes can find text in a PDF or a Doc, that's fine, but it doesn't show you where in the PDF the text was.  Notes also doesn't do a good job of searching handwritten notes.  Something I do a lot of on my iPad. (I'll get to this later with my comments on Notability and Penultimate.)

As for Reminders.  It doesn't do any nesting of actions, vital to how I work in Omnifocus.  Plus I had a bunch of Applescripts that organized and automated things for my in Evernote and Omnifocus, and I had to rewrite some of them to deal with Reminders and Notes.  Things like being able to simply tap a keystroke, which prompts an entry box so I can create myself a reminder very quickly.  Omnifocus has this natively.  Reminders.app, I had to find one (or write one, I honestly don't remember which at this point)  btw --  here it is.

tell application "System Events"
display dialog"Create a new reminder" default answer"" cancel button"Cancel" giving up after 20 with icon path to resource "Reminders.icns" in bundle(path to application "Reminders")
set reminTitle to text returned of result
tell application "Reminders"
set newremin to make new reminder
set name of newremin to reminTitle
end tell
 end tell

If you use Reminders, and you want to steal that and make a keyboard shortcut that calls that AppleScript (if you use Reminders.app) feel free.

So, after using this new system for awhile, I found out it was a disaster, and in the past two weeks I have dedicated significant amounts of time to get back to my happy place where things were productive.

So, I'm back to using Evernote and Omnifocus again, and I am going write a few posts on how I've developed a system the works for me with these three tools.  Consider this.. part one.



Please leave comments below.

Wednesday, September 5

Is Evernote going away?

Evidently we don't know if Evernote is sticking around, since there seems to be some panic on the internet about it today.

https://appleinsider.com/articles/18/09/05/evernote-might-be-in-trouble-so-heres-how-to-get-your-notes-out-of-it-completely-and-safely

It is really easy to move your notes out of Evernote and into Notes.app on the Mac.  (Click the above link for the easy instructions.

However, if you use Hazel, to say, monitor the "Downloads" folder on your Mac, and if any files show up there (like a PDF for example) and you want to have it automatically saved to Notes.app.  (This is handy after you try it).

I wrote a little AppleScript to do this for you, (in Hazel) since I couldn't find one on the Internet, and it wasn't rocket science:

tell application "Notes"
set mynote to make new note at folder "PDFS"
make new attachment at mynote with data theFile
end tell

If you have a folder in Notes.app called "PDFS", it will create a new note in the folder for each file and attach the file to it (which for me, then syncs it with iCloud so the file is on all my devices). Pretty handy.

Anyway, putting this here in case any one else can use it.

Please leave comments below.

Monday, December 12

VimWiki, this looks pretty cool.

As it is very themed with some of my blog posts, I discovered this today, for all of you command line types:

VimWiki

Copy and pasted directly from their website, go check it out:

With Vimwiki you can

  • organize notes and ideas
  • manage todo-lists
  • write documentation
  • write a diary

Features

  • three markup syntaxes supported: Vimwiki's own syntax, Markdown, MediaWiki
  • export everything to HTML
  • link to other wiki pages and external files
  • search through all wiki pages
  • outline notes and tasks in indented lists
  • quickly manipulate numbered and bulleted lists
  • tag wiki pages or arbitrary places and quickly jump to tags
  • tables

Please leave comments below.

Wednesday, June 15

Why don't you write on your blog anymore?

1.  I don't feel like I have much to say.


I do a tremendous amount of writing and blogging on the Snort, ClamAV, and Talos blogs.  So, I get exhausted when I think about things I would want to write for this blog.

2.  When I do think about what I want to write about, I want to rant against companies and competitors.

But why would I want to give any competitors an intel on what they are doing wrong, or in some cases right?

3.  Twitter is 140 characters of BS, and I can't even think of 140 characters to spew on there half the time.

I know a bunch of people that just post random thoughts and spew for 100s of tweets a night about something, and they have thousands of followers.  I just don't feel like that's me, or it gets me anywhere.

4. Gov't or politics

I know a bunch about the subject, and I just don't feel like talking about it, since that's all the news is saying right now.  

Basically, no one cares!

And now I am tired.

Please leave comments below.

Thursday, March 10

You can't have it both ways

Too long for Twitter. 

Law enforcement agencies consistently praise Apple for introducing “activation lock,” which they claim has reduced violent robberies because criminals can’t steal iPhones and resell them.

However, these agencies now want Apple to allow law enforcement to bypass this feature, which is essentially the same.

While the lock screen passcode differs from the activation lock on an iPhone, the request is essentially the same: please allow us to guess or bypass the password.

I understand both sides of this issue, but I also believe that there are places, like the human brain, protected by the fifth amendment, where the government should not have access.

Tuesday, July 7

I just had the best travel experience ever

Left my office at 4:30 for a 5:15 flight.  I know what you are thinking, you are crazy...

You're right. Normally would never do this, but was running behind with stuff today.  Drove from my office in Columbia, MD to BWI. 

Parked the car, no problem. 

Walked to security (already checked in on my phone), went through TSA pre line, using the boarding pass on my watch.  No line. 

No one bothered me about my bag, no one told me to have my boarding pass and ID out and ready...

Went through security in about 30 seconds. 

Walked to gate, plane too small to bring on roller board bag, so, pink tag check it at gate.  Done. 

Boarded with watch, zone 1, only one in zone 1.

Went right to my seat, no waiting.

Hour flight, quick Coke on the flight, I wrote three emails, done. 

Got off flight had to wait 5 minutes for bag, darn. 

Walked out to car rental bus, had to wait another five minutes, darn. Bus driver was friendly, no waiting there, went to car rental facility, no traffic, got my space from the Hertz Gold board, walked to car, got in, tapped my phone to give me the address and directions to hotel, drove to hotel.

I was already checked in (via app) at hotel, no lines, picked up my key, walked to room. In room, was waiting a small snack.  


From when I left my office to my hotel room, less than three hours.  

Over the course of my career I have encountered everything that can possibly be wrong with a trip (except crashing in a plane, knock on wood).   Today, nothing went wrong.  

Today was a good day. 

Friday, March 13

Should we fire low-quality contributors to projects?

Friend of mine at work pointed this article out to me this morning:

Should we fire low-quality contributors to projects?

Good article that deals with the dilemma of dealing with toxic community members to a project.

Luckily in Snort and ClamAV, I've only had to deal with a handful of these.  Usually people that hide behind nicknames and like to try and shame people into submission to their ideas.  I've actually had people apologize to me years later for trolling or simply being toxic.

However, if you are a community manager for an open source project or a community project, this article gives you a couple things to think about.


Please leave comments below.

Monday, March 9

Threat Spotlight: Angler Lurking in the Domain Shadows

Nick Biasini on our Talos Outreach team wrote a piece of awesome over on our Talos Blog, I just wanted to highlight it.
Over the last several months Talos researchers have been monitoring a massive exploit kit campaign that is utilizing hijacked registrant accounts to create large amounts of subdomains for both initial redirection and exploitation. This campaign has been largely attributed to Angler Exploit Kit with fileless exploits serving various malicious payloads.
Check out the Angler Blog Post.

Please leave comments below.