Jump to content

dfay

Member
  • Posts

    1,054
  • Joined

  • Last visited

  • Days Won

    62

Everything posted by dfay

  1. Should be easy to do since all the code for accessing last.fm API is already in this workflow: http://www.alfredforum.com/topic/2257-dj-pedro-itunes-playlist-based-on-lastfm-similar-artists/?hl=pedro
  2. Here's a revised version that works great for me. The only issue is that you need to hard-code a default directory for your TaskPaper files, which may not work with the way you work.... I keep all mine in a single directory in Dropbox so it works for me. Since Spotlight is now only searching a single directory, rather than the entire user home space, it's basically instantaneous. (BTW thanks to Gianni for writing nice self-documenting code that was v. easy to debug & modify ) -- Releas version: 1.1.1 -- Developed by Gianni Rondini -- more info at dropbyte.tumblr.com -- send bug and fix requests to -- giannivt [at] gmail [dot] com on alfred_script(evTest) set tpdir to "~/Dropbox/TaskPaper" set doc to "" set prj to "" set todo to "" set subSep to " sub " set inSep to " # " set noDoc to 0 set noPrj to 0 if evTest contains subSep then if evTest contains inSep then -- checking specific document set text item delimiters to inSep set prj_h to text item 1 of evTest set doc to text item 2 of evTest --saving document name set text item delimiters to subSep set prj to text item 2 of prj_h --saving project name set todo to text item 1 of prj_h --saving todo else set text item delimiters to subSep set prj to text item 2 of evTest --saving project name set todo to text item 1 of evTest --saving todo set doc to "toSave" --saving document name set noDoc to 1 end if else if evTest contains inSep then -- checking specific document set text item delimiters to inSep set todo to text item 1 of evTest --saving todo set doc to text item 2 of evTest --saving document name set prj to "Inbox" --saving project name set noPrj to 1 else set prj to "Inbox" set doc to "toSave" set todo to evTest set noDoc to 1 set noPrj to 1 end if end if if (doc as text) contains " " then set AppleScript's text item delimiters to " " set newText to text items of doc set AppleScript's text item delimiters to "\\ " set doc to newText as text end if tell application "TaskPaper" activate if noDoc is equal to 0 then set p to do shell script "mdfind -onlyin " & tpdir & " \"kMDItemFSName=='" & doc & ".taskpaper'\"" if (p as text) contains return then set Applescript's text item delimiters to return set lista to text items of p set p to {choose from list lista} end if if p is not equal to "" then open p else display dialog "Error: " & quote & doc & quote & " file does not exist!" with icon 1 buttons {"Cancel"} return end if else make new document with properties {name:doc} tell front document delete entries end tell end if tell front document if not (exists project named prj) then make new project with properties {name:prj} at front of projects end if tell project named prj make new entry with properties {text line:todo} end tell end tell end tell end alfred_script
  3. So I just tried both of the above commands in Applescript Editor. set p to do shell script "find ~ -iname work.taskpaper" returns an error in AppleScript Editor, presumably from the Permission denied messages from trying to find in savedState files in the Library. set p to do shell script "mdfind -onlyin ~ \"kMDItemFSName=='work.taskpaper'\"" returns the desired file, without any error messages. When I add the second line back to the original workflow as set p to do shell script "mdfind -onlyin ~ \"kMDItemFSName=='" & doc & ".taskpaper'\"" it still takes a long time (not quite as long as using find, but more than a minute) but does eventually add the item to the desired taskpaper file. So the question now is, is it really necessary to search ~ or can we restrict the search and get more speed?
  4. Ok....the multi-minute wait sees to be because of the line set p to do shell script "find ~ -iname " & doc & ".taskpaper" I just ran the shell script in terminal and it takes two minutes to run. And because it searches the entire home directory, it's trying to go into the Library folder and getting 15-20 lines ending in Permission denied tagged on the end. Is there a faster way of doing this search? Yes, with spotlight (mdfind) instead of find. >time find ~ -iname work.taskpaper ... real 2m16.608s user 0m0.465s sys 0m3.211s >time mdfind -onlyin ~ "kMDItemFSName=='work.taskpaper'" real 2m9.366s user 0m0.007s sys 0m0.006s user & sys time are way faster (which makes sense since Spotlight is caching all the info. that find is discovering afresh). Moreover using Spotlight only returns the desired file, rather than the desired file plus a whole bunch of Permission denied lines. I don't have time to work on this further right now but it seems pretty clear that the delay (at least - and possibly the error) is related to the do shell script... line in the code above. D
  5. I've tested it and have the same issue. But if I wait a few minutes, Alfred becomes responsive again. And once it does there is an error in system.log : May 29 13:37:00 ... Alfred 2[356]: [ERROR] AppleScript Error: {
  6. Yep, that fixed it! Thanks a bunch. It was only when it broke that I realized how much this has become an essential part of my research and reading.
  7. Hmmm....this was working great until this morning...now every search is resulting in an error - but the error message includes a doi URL that works fine when copied and pasted. I'm wondering if there was a change in the doi API that broke the workflow? Here's an example of what's returned if I use the "copy formatted reference" command: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>DOI Naming Authority [http:] Not Found</title> </head> <body bgcolor="#ffffff"> <table border="0" width="680" cellspacing="2" cellpadding="2"> <colgroup> <col width="10%"> <col width="90%"> </colgroup> <tr> <td align="center" colspan="2"> <img src="http://www.doi.org/images/banner2.gif" alt="The DOI Logo" width="680" height="53" border="0" align="middle"> <h3 align="center">Error - DOI Naming Authority [http:] Not Found</h3> </td> </tr> <tr> <td align="left" valign="top"> </td> <td align="left" valign="top"> <hr noshade width="80%" size="1"> <p>The DOI you requested -- </p> <p><b>http://dx.doi.org/10.1080/13504639851663</b></p> <p> -- cannot be found in the Handle System.</p> <p>Possible reasons for the error are:</p> <ul> <li>the DOI has not been created </li> <li>the DOI is cited incorrectly in your source</li> <li>the DOI does not resolve due to a system problem</li> </ul> </td> </tr> <tr> <td align="left" valign="top"> </td> <td><hr noshade width="80%" size="1"> <p>If you believe you have requested a DOI that should be found, you may report this error by filling out the form below:</p> <form action="http://notfound.doi.org/DoiError/servlet" method="POST" enctype="application/x-www-form-urlencoded" name="notFoundForm"> <table width="100%" border="0" cellspacing="2" cellpadding="2"> <tr> <td> <table width="100%" border="0" align="center" cellpadding="2" cellspacing="2"> <tr> <th width="35%" align="right" scope="row"><label>Missing DOI:</label></th> <td width="65%"><input name="missingHandle" type="text" value="http://dx.doi.org/10.1080/13504639851663" size="35" readonly="true"></td> </tr> <tr> <th align="right" scope="row"><label>Referring Page:</label></th> <td><input name="referringPage" type="text" value="" size="35" readonly="true"></td> </tr> <tr> <th align="right" scope="row">E-mail address:</th> <td><input name="userEmailAddress" type="text" value="Please enter your email address" size="35"></td> </tr> <tr> <th align="right" scope="row">Comments:</th> <td><textarea name="comments" cols="25" rows="3"></textarea></td> </tr> </table> </td> </tr> <tr> <td align="center"><p><input name="send" type="submit" value="Submit"></p></td> </tr> </table> </form> </td> </tr> <tr><td align="left" valign="top"> </td> <td> <hr noshade width="80%" size="1"> <p align="center"> </td> </tr> </table> <p><strong><em><small><a href="http://www.doi.org/">DOI Web Site</a><br></small></em></strong></p> </body></html>
  8. It took me a couple tries to get it to pair, but eventually Alfred did show up in the devices list. It works - but artist and album matching would make it a lot more useful....
  9. Edit the initial post, then click the "Use Full Editor" button, & the tags field will appear.
  10. Here is the content of the script (as found in the Run NSAppleScript block in the workflow). You can adjust the duration of any of the delay commands. But some delay is likely to be necessary for UI scripting to work successfully. on alfred_script(q) tell application "Safari" to activate delay 2 tell application "System Events" to tell process "Safari" keystroke "," using command down delay 2 tell window 1 click button "Extensions" of tool bar 1 delay 1 click checkbox 1 of group 2 of UI element 1 of scroll area 1 of group 1 of group 1 end tell keystroke "w" using command down end tell end alfred_script
  11. Same issue here. On iMac 29" and MB Air 13" both running 10.8.3 . But - it's inconsistent - the first time I do it (after a while...) it lags. On subsequent calls, it pops up quickly.
  12. Excellent, thanks. I will (probably) mostly use this to grab a quick reference for an email, so the restriction to APA format is not a big deal.
  13. Nice. I was just about to write a workflow to call wc but you've done it for me. Thanks!
  14. If you don't care about getting actual Genius data, this workflow http://www.alfredforum.com/topic/2257-dj-pedro-itunes-playlist-based-on-lastfm-similar-artists/?hl=pedro provides the same functionality, using last.fm data on artists.
  15. Another Applescript UI scripting workflow - the Safari Preferences screen will pop up briefly. Functionality should be obvious from the title . http://dfay.fastmail.fm/alfred/Toggle%20Safari%20Extensions.alfredworkflow
  16. Thanks! I was in the same situation - I had Services, BibDesk applescript, OnMyCommand commands, etc. but a lot of them were context-specific and in locations that didn't sync from one computer to another, so an Alfred workflow seemed like the perfect way to put it all in one place.
  17. This is a real time-saver, thanks again. Would it be possible to add an option to harness BibDesk to produce a formatted citation on the clipboard? (through a modifier key or separate command). This should just involve adding a few lines to the applescript that calls BD set thePub to selection of document 1 export document 1 using template "template name" to clipboard for thePub
  18. what database(s) does this search? never mind...just saw the read me. This is pretty sweet.
  19. Lots of resources here: http://j.mp/2013bbhack
  20. Here is a script: http://bensapplescripts.blogspot.com/2012/05/generate-genius-playlist.html but it seems to be written for iTunes 10 - it doesn't work for me. Same with this one: http://apple.stackexchange.com/questions/56522/launch-genius-via-applescript?rq=1 The main obstacle is that Genius functionality isn't directly scriptable in Applescript, so it needs to be done with UI scripting, which breaks easily, depends upon the iTunes view, etc. I have never seen a UI script that uses the new (>) buttons next to tracks, which may not even be Applescriptable, and which are the only way I see to get to Genius functionality in iTunes 11. Once you have a working script, hooking it into Alfred is easy.
  21. This update has fixed my problem - it gives me the full list of mailboxes. Thanks for continued work on this. I think the improvements you propose are right on track.
  22. Toggles the view mode in OS X mail - between the "Classic" view and the new view introduced with OS X Lion. Uses Applescript UI scripting (the only way I could find to do this) so the preference pane pops up briefly. http://dfay.fastmail.fm/alfred/Toggle%20Mail%20view.alfredworkflow
  23. Updated March 26, 2022 to use Python 3 for MacOS 12.3 Now featuring Universal Action triggers and hotkeys for the following five actions: Uppercase Lowercase Capitalize - capitalizes all words (e.g. Posting A New Topic In Share Your Workflows) Title Case - capitalizes word except for "the", "in", "of" etc. according to American English title conventions (e.g. Posting a New Topic in Share Your Workflows) Sentence Case - capitalizes only the first letter of the first word & converts the rest to lower case All of these are set to Copy to Clipboard and Paste by default. There's also a script filter cc which lets you view the query converted and select your choice (like the Code Case workflow). You can also connect a hot key directly to the cc script filter directly to view the output options without typing the cc command and pasting your text. Download: https://www.dropbox.com/s/8fydkkef1t699et/Case Converter 3.alfredworkflow?dl=0 NB This is a new link and will download as a new workflow - you'll need to migrate any hotkeys and delete or disable the older version. Here's the old Python 2 version in case anyone wants it: https://www.dropbox.com/s/3k2lh21g5wnqrkp/Case Converter 2.alfredworkflow?dl=0 The original version is described below and still available, if anyone prefers it. Workflow Version: This workflow converts the case of the text on the clipboard. http://dfay.fastmail.fm/alfred/Case%20Converter.alfredworkflow There are two workflows which display the following five options: Uppercase Lowercase Capitalize - capitalizes all words (e.g. Posting A New Topic In Share Your Workflows) Title Case - capitalizes word except for "the", "in", "of" etc. according to American English title conventions (e.g. Posting a New Topic in Share Your Workflows) Sentence Case - capitalizes only the first letter of the first word & converts the rest to lower case The keyword case will transform the text on the clipboard without pasting the result. The keyword casep will transform the text on the clipboard and paste (using Applescript System Events) Hotkey Version: Here is a version for use with hotkeys which will operate on the active selection in OS X and paste it with the converted text. These all have a half second delay prior to pasting, which is necessary for Applescript to be able to paste. http://dfay.fastmail.fm/alfred/Case%20Hotkeys.alfredworkflow Notes and Revision History: These use the Title Case perl script found at https://raw.github.com/ap/titlecase/master/titlecase . If you manage academic citations with BibDesk, Zotero, Papers, Mendeley, etc., Title Case conversion is especially useful for cleaning up downloaded citations. Updated May 3, 2013 with nicer colored icon thanks to mjv ( http://www.alfredforum.com/user/4384-mjv/ ) Updated February 5, 2014 to handle Sentence Case and to add a second keyword to paste after conversion. Updated May 20, 2014 with hotkeys
  24. Viewing running apps and quitting them is already built-in using the keyword "quit" http://support.alfredapp.com/features:system Alternatively (without Alfred) you can use command-Tab to switch and command-Q (while the command-Tab view is still on the screen) to quit an app without switching to it. http://osxdaily.com/2009/11/17/secrets-of-the-command-tab-mac-application-switcher/
×
×
  • Create New...