Jump to content

phyllisstein

Member
  • Posts

    366
  • Joined

  • Last visited

  • Days Won

    7

Posts posted by phyllisstein

  1. Curiouser and curiouser! Well, believe it or not, that could've gone worse. I can add a version check and not look for the second value in Python < 2.7. There's one other call to NSPropertyListSerialization that I'm a little worried about; if you have a tagged file you can try this on, that'd be great, otherwise I'll upload what I have and we can see what happens. Here's s'more code for the interpreter; as convention goes, lines that start with >>> should be input, and lines that don't are what the output ought to look like.

    >>> from Foundation import *
    >>> from ctypes import *
    >>> libc = cdll.LoadLibrary("libc.dylib")
    >>> path = "/Users/danielsh/Desktop/tagged.txt".encode("utf-8")
    >>> cPath = c_char_p(path)
    >>> data = create_string_buffer(4096)
    >>> name = "com.apple.metadata:kMDItemOMUserTags".encode("utf-8")
    >>> dataSize = libc.getxattr(cPath, name, data, 4096, 0, 0x0001)
    >>> dataSize
    52
    >>> nsData = NSData.dataWithBytes_length_(data, dataSize)
    >>> NSPropertyListSerialization.propertyListWithData_options_format_error_(nsData, kCFPropertyListImmutable, None, None)
    ((
        sublime
    ), 200, None)
    

    You'll have to enter the line path = ... by hand, since you'll need to give it the path to a file with tags. What we're looking for is for a positive number to come after dataSize, and three values, one of which is a list of tags, to be returned by NSPropertyListSerialization. If it's more or less than three, I'll have to add another version check.

  2. Sorry it's giving you so much trouble—I haven't been able to do any testing on 10.6. It'd be a big help if you could spend a couple of minutes in the Python interpreter for me, but I don't want to cause too much trouble; the other thing I can always do is rewrite it in Objective-C and trust that compiled code will be more reliable than interpreted code. Not something I mind doing, though it might take a day or two.

     

    Anyway, if you want to really debug the bastard, fire up a Terminal and run python. Paste the lines below in one at a time, hitting Return after each one:

    from Foundation import *
    t = NSMutableArray.arrayWithCapacity_(0)
    t.addObject_(NSString.stringWithCString_encoding_("foo".encode("utf-8"), NSUTF8StringEncoding))
    t.addObject_(NSString.stringWithCString_encoding_("bar".encode("utf-8"), NSUTF8StringEncoding))
    t.addObject_(NSString.stringWithCString_encoding_("baz".encode("utf-8"), NSUTF8StringEncoding))
    t.addObject_(NSString.stringWithCString_encoding_("qux".encode("utf-8"), NSUTF8StringEncoding))
    NSPropertyListSerialization.dataWithPropertyList_format_options_error_(t, kCFPropertyListBinaryFormat_v1_0, NSPropertyListImmutable, None)
    

    You shouldn't get any output from any of that until the last line; on my machine, hitting Return spits this out:

    (<62706c69 73743030 a4010203 0453666f 6f536261 72536261 7a537175 78080d11 15190000 00000000 01010000 00000000 00050000 00000000 00000000 00000000 001d>, None)
    

    It'd be a great help to know whether you get something similar. But, again, if you're not feeling Terminal, hang tight for a couple of days and I'll look into redoing it.

  3. Hey everybody, it's your old pal Daniel. I just wanted to share a workflow that I threw together this morning. I've gotten a number of requests for an alp tutorial that walks one through the process of making a workflow with Alfred 2 and alp one step at a time, and I needed a sample to look at as I was working. And lo, "Yourls Stats" was born. It's not especially complex, but it makes use of many of alp's more advanced features—some of which got slightly rewritten as I worked—to do something marginally useful. I thought I'd get it out there in advance of writing the tutorial to see if it had any lingering bugs.

     

    Enter "ystat" (or a keyword of your choice) to trigger the workflow. The first time you invoke it, it'll need to be configured; go to your Yourls admin site's "Tools" page and copy your secret signature token, then enter "ystat url=mysite.ly signature=0123456789" into Alfred. You'll note that the workflow guesses the location of the API PHP as you type, and that the feedback item won't be valid till both values are entered. Once they are, hit Return. Your signature token will be stored securely in the Keychain, your URL in cleartext in the workflow's settings JSON. Alfred will pop back up with your custom keyword already entered and begin downloading your Yourls data. Enter a query to search fuzzily through the links' titles and short keywords, and press Return to copy a link to the clipboard.

     

    You can download the workflow here, and, as always, do let me know if it breaks.

     

    ystats1.png

     

    ystats2.png

  4. Whoa, how did I manage to miss this?! Very well done, dear, I'm duly impressed! Would love to get a look at the Objective-C, if you've a mind to stick it on Github.

     

    Also, I'm gonna be a feature freak and ask: Since it looks like the workflow collects shortcut keys, is there any way to show them in its feedback? It'd be a boon for memorizing more esoteric Sublime key-combos.

  5. @jkdram: The forum breaks every time I try to quote your post for some reason, but I keep trying to say that we should be able to solve this without listing all your downloads. Could you check the workflow folder for any .log files and either post their content here (they shouldn't contain anything sensitive) or e-mail them to me at d-at-daniel-dot-sh?

  6. Thanks for going to the trouble of looking up an article about it. That would work great if I just needed to print or manipulate the content, but there's a Python module called ctypes that complicates things a bit.

     

    I'm in the middle of finals right now, but I should be able to try something in a day or two. Sorry for the delay and the ajada!

  7. Maybe there is something in my Downloads folder that the workflow does not enjoy that much. After the keyword dl I see Alfred search which tells there was an error:

    Traceback (most recent call last):
      File "feedback.py", line 70, in <module>
        do_feedback()
      File "feedback.py", line 27, in do_feedback
        downloads = find_downloads()
      File "feedback.py", line 20, in find_downloads
        color = get_finder_label(path)
      File "/Users/Carlos/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.3A9F6317-CC0B-4D14-9CEC-69417CA8389B/labels.py", line 21, in get_finder_label
        flags = get_flags(path)
      File "/Users/Carlos/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.3A9F6317-CC0B-4D14-9CEC-69417CA8389B/labels.py", line 8, in get_flags
        path = path.encode("utf-8")
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xcc in position 39: ordinal not in range(128)
    

    Nice idea!

     

    Jaysus, I can never seem to get this Unicode stuff right. I've just uploaded a new version to http://alfred.daniel.sh/Workflows/Downer.alfredworkflow that MAY fix the problem, but it's sort of a shot in the dark—ctypes confuse me to begin with, and the encoding stuff just makes it worse.

  8. Might be an issue at my end but the d/l link and screenshots are all borked.

     

    Screenie - http://d.pr/i/vcM

     

     

    Yeah, obviously a few hiccups right now with the hosting. @phyllisstein - Please let us know when the file is up again so we can down downer. Eh, tease... ;)

     

    Hah, sorry about that—I switched hosts and kept having to reconfigure from scratch. As God is my witness, never another custom mail server again ever. Should be consistently back up now.

     

     

     

    Awesome workflow,

     

    what would be great would be an "Autosort" option using user defined rules that (rather than deleting the file) would put the file in a particular folder depending on its extension (.pdf / .mp3 / etc.  )

     

    I thought about that, but I think there may be a fine line between killing an afternoon avoiding finals and totally rewriting Hazel.

  9. Hey all! I've just made some small changes to the workflow so that it can take advantage of alp's fuzzy searching functions, making it a bit faster and smoother. Otherwise things are mostly unchanged. Download the update through Alleyoop or at http://alfred.daniel.sh/Workflows/OpenInSublime.alfredworkflow

     

    The keywords are "subl" to list and open recent projects or the current Finder selection and "sub*" to do a Spotlight search for any file and pass it to Sublime. There's also an optional hotkey to open the Finder selection in Sublime immediately (mine's set to "⌥+⌘+↓").

  10. Hello, fellow workers of flow! I've just thrown together a new workflow for managing your Downloads folder. Right now, it lists recent downloads, allowing you to open them (press Return), delete them (press Ctrl+Return), set their OpenMeta tags (press ⌥+Return, enter a list separated by spaces), and set their Finder label colors (press ⌘+Return).

     

    You can download it here. Be sure to let me know if anything breaks!

  11. Hmm ... so the setup script finds your databases. Could you please check if there is a file called databases in

    ~/Library/Application Support/Alfred 2/Workflow Data/com.markokaestner.devonthinksearch

    What does the devon.log inside the workflow directory say?

     

    I'm having the same trouble; devondb! returns 0 databases, but setup shows the expected output. My log reports that the databases file doesn't exist, which is indeed true; the folder isn't even in "Workflow Data."

    ./search: line 9: /Users/danielsh/Library/Application Support/Alfred 2/Workflow Data/com.markokaestner.devonthinksearch/databases: No such file or directory
    ./search: line 12: /Users/danielsh/Library/Application Support/Alfred 2/Workflow Data/com.markokaestner.devonthinksearch/databases: No such file or directory
    <?xml version='1.0'?><items>
    <item uid='13686176981' arg='all' valid='yes' autocomplete=''><title>All databases</title><subtitle></subtitle><icon>icon.png</icon></item> </items>
    
    
    user.workflow.29738129-4604-40FB-90DF-595F0EE93F50 danielsh$ ./setup
    C87C2F4E-376D-4834-87E1-B357835D91E4|Academy
    8CE9316C-21C0-43FD-9DDC-7ECA91E8EA23|Inbox
    
  12. The documentation explains it in more detail, but with alp you wind up giving it a list—which you have—and a key function—which accesses a search string for each element in the list. If you wanted to fuzzily search names and descriptions, for example, you'd do this:

    alp.fuzzy_search(query, cache, key=lambda x: "{0} - {1}".format(x['name'], x['description']))
    

    I should also note that your original code has the potential to generate unreliable results. There's no guarantee, in Python, that the for…in loop is moving through things sequentially, so iterating i within it could break it under certain circumstances. I think you could replace it with something like this, if that's the JSON form of the objects you're getting:

    for list in cache:
        name= list['name']
        id = list['id']
        # etc.
    
  13.  

     
    I did quick research and here is some technical details:
     
    Google Chrome/Chromium application locks "History" database :( when it is running and it means that if you try to open and search something via database you will get:
    $ sqlite3 "/Users/$USER/Library/Application Support/Google/Chrome/Default/History"
    SQLite version 3.7.12 2012-04-03 19:43:07
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite> select * from urls;
    Error: database is locked
    sqlite> 
    From my point of view this feature wouldn't useful, because you have to remember to close the application before searching.

     

     

    Thanks so much for this workflow! (Also, your Alfred site is lovely.) I worked around this problem with my Things workflow by copying the database to a temporary directory, extracting what I needed, then deleting it; it's a hack, but it did the trick with Things.

  14. I pushed an update to the original links that allows syncing all devices at once by using the 'alt' modifier key when selecting any device. If folks would prefer a seperate menu item for this, I'd be happy to add that instead (or in addition).

    Also, I think I found a more reliable way to monitor iTunes for a completed sync. This seems to work quite well on OSX running the current iTunes 11. If anyone can provide input on how it works on other set-ups that would be great.

    Let me know any issues, etc. Enjoy!

    Direct download

     

    Sorry to be the bearer of bad news, but while the workflow triggered my iPhone's sync beautifully, the "Completed syncing" notification appeared almost immediately after the process had started. It was syncing over WiFi, so maybe it was moving slower than expected?

  15. Although I don't know Alfred-Python, and so I'm not quite sure what the data you get from cache looks like, I think you just need to do something like this:

    name = cache[i]['name']
    desc = cache[i]['description']
    
    if query in name or query in desc:
        # do your string manipulation
        feedback.addItem(title=name, subtitle=desc, uid='bc' + str(id), valid=True, icon='basecamp.png', arg=url)
    
    feedback.output()
    

    My own Alfred module, alp, contains a fuzzy searching method contributed by Github user jlegewie that makes the searching a bit smoother, but it's hard to see how it would be implemented here without knowing more about the data you get back from cache—the iterator is throwing me for, as it were, a loop.

×
×
  • Create New...