Jump to content

deanishe

Member
  • Posts

    8,759
  • Joined

  • Last visited

  • Days Won

    522

Reputation Activity

  1. Like
    deanishe got a reaction from vanitalo in Exclude folders and filetypes both globally and for file filters   
    Checking every result to see if its path starts with the path of an excluded folder or ends with an excluded extension is a very trivial operation.
     
    To add some actual numbers to the discussion, I benchmarked such a directory-blacklist filter on my ancient Mac Pro (this is running on one 2.8 GHz core):
    | No. of filters | Files filtered per second | | -------------- | ------------------------- | | 1 | 2611658 | | 5 | 949018 | | 10 | 535346 | | 20 | 283730 | | 50 | 118983 | | 100 | 61502 | Certainly, that might perceptibly affect performance if there were dozens of excludes, so add a warning.
     
    Let me choose my own performance/functionality trade-off. I'm a big boy
     
     
    Except, as noted in the OP, a whitelist-only approach is often a poor (or no) substitute for blacklisting. Even using file filters, the same applies.
     
     
    That doesn't help. You're talking about a different set of problems. Sure, sometimes you can get around the lack of blacklisting using whitelisting, but it's often not a satisfactory alternative.
     
    What if I want to search a dozen different kinds of documents, but ignore the 13th and 14th kind? Or 20 subdirectories, but not 21 and 22?
     
    That's a helluva lot of work to do with whitelists, and brittle: I'd have to remember to update my file filters every time I added a subdirectory or new kind of file.
     
    Even if it runs at half the speed the current system does, I don't care. I accept the trade-off. Please let me make that choice for myself.
  2. Like
    deanishe got a reaction from jiggle in How to Output Query in a Script?   
    You can just pass q to keystroke to "type" it into the app:
     
    keystroke q
  3. Like
    deanishe got a reaction from xilopaint in Searchio! Auto-suggestion from search engines in different languages   
    I had a look at the Foursquare API and it's way beyond the scope of this workflow, I'm afraid.
  4. Like
    deanishe reacted to vitor in Save and restore current clipboard   
    Emulating keystrokes can lead to trouble, but I’m not sure there’s a way to paste with AppleScript. You can also use it just for what you need and bash for the rest, for example.
    starting_clipboard="$(pbpaste)" pbcopy < /path/to/your/file osascript -e 'tell application "System Events" to keystroke "v" using {command down}' pbcopy <<< "${starting_clipboard}"
  5. Like
    deanishe reacted to vitor in Any advice on Quip integration?   
    When asking for help, be verbose. A link back to the application’s website is the minimum. Opening the website it’s not even possible to tell at a glance if it’s even available for OS X, as it seems to be mobile only. Many people would be able to give you a hand with this, but we shouldn’t have to do all the research. The more steps you make people go through, the less help you’ll get.
  6. Like
    deanishe got a reaction from Subject22 in Searchio! Auto-suggestion from search engines in different languages   
    Not until I've figured out if and how Alfred's killing scripts messes with Alfred-Workflow's caching code. I don't want the workflow generating loads of invalid query cache files because Alfred is killing the process in the middle of a cache write.
     
    It's simple enough to wrap critical code so that signals are ignored till the code completes, but there's other stuff much higher up the TODO list.
  7. Like
    deanishe reacted to tone in Movie and TV Show Search   
    Movie and TV Show Search
    Search for movies or tv shows and get general info and ratings from various sites.
     

     
    Features
    Get movie/tv show runtime, genre, MPAA rating Get ratings from IMDb, Rotten Tomatoes, Metacritic (if available) Show a link to a trailer (if available) Show a few credits  
    Download
    Get the workflow from Packal or GitHub.
     
    Usage
    Type 'movie' and the title you'd like to search for. Select item (ENTER) to get movie info. Type 'tv' and the title you'd like to search for. Select item (ENTER) to get show info.  
    Thanks
    Thanks to @deanishe for Alfred-Workflow. Uses TMDb and OMDb APIs for info. @vitor for all his help with developing a great workflow  
    Changelog
    For more recent changes, see the GitHub releases page.
     
    2.6 (2017-11-27)
    Big thanks to @vitor for implementing the following enhancements:
    - Add support for OneUpdater
    - Move OMDb API key to workflow environment variables
     
    2.5 (2017-11-27)
    - Added free OMDb API key
     
    2.3 (2015-07-30)
    - Add RottenTomatoes audience score
     
    2.2 (2015-05-01)
    - Open YouTube trailer (if available) when choosing to search all rating sites
    - Friendly message when internet connection isn't working properly   2.1 (2015-01-28)
    - added menu item to search all rating sites at once - added script behaviour queue delay (requires Alfred 2.6 or higher) - fixed rotten tomatoes search   2.0 (2015-01-20)
    - added tv show search
    - fixed issue with quick look not working for some items - removed tiny poster icon (didn't like the squishing and there was an issue with caching the icon in Alfred)   1.3 (2015-01-16)
    - removed argparse reference (and setting personal TMDb API key functionality)
    - updated alfred-workflow library to latest (v1.11.0)
    - fix/tidy up string encoding issues
    - error handling fixes
     
    1.2 (2015-01-11)
    - show tiny poster in movie details listing
    - generate sexy html file for when first item in details listing is selected
    - add fallback search item (must be added manually in Alfred preferences > Features > Default Results > Setup fallback results)
     
    1.1 (2015-01-10)
    - Add default TMDb API key
     
    1.0 (2015-01-10)
    - Initial release
     
    This workflow is released under the MIT Licence.
  8. Like
    deanishe got a reaction from Shadde in Searchio! Auto-suggestion from search engines in different languages   
    Searchio! workflow for Alfred
    Auto-suggest search results from multiple search engines and languages.
     
    There are a few existing workflows that provide auto-suggest results from one or the other search engine, but this includes not only multiple search engines, but also allows you to specify multiple languages/regions for your results.

    Supports the following search engines/websites:
    Google Google Images Google Maps YouTube Wikipedia Wiktionary Amazon eBay DuckDuckGo Bing Yahoo! Ask.com Yandex.ru Naver.com Wikia.com  
    Download and installation
    Download the latest version from the GitHub releases page or Packal.
    Usage
    There are several searches pre-configured. Only some have keywords (i.e. can be used as-is):
    g — Search Google in system (i.e. default) language m — Search Google Maps in system (i.e. default) language gi — Search Google Images in system (i.e. default) language w — Search Wikipedia in system (i.e. default) language wn — Search Wiktionary in system (i.e. default) language a — Search Amazon in system (i.e. default) language. If your system language is English, this will search Amazon.com. Use -l uk in the Script Filter to search Amazon.co.uk or -l ca to search Amazon.ca. yt — Search YouTube in system (i.e. default) language searchio [<query>] — Show settings and list of supported search engines. Currently, the only setting is a toggle to also show the <query> in the results list (default: No). searchiohelp — Open help file in your browser You can add a keyword to (and edit) one of the existing examples or add your own searches. For details on how to do that, see the GitHub page.
     
    Licensing, thanks
    The code in this workflow is released under the MIT Licence.
    The icons belong to the respective search engines.
    This workflow uses the Alfred-Workflow library and docopt (both MIT-licensed).
  9. Like
    deanishe reacted to smarg19 in First Workflow: Need Ideas, Suggestions, Examples, Documentation   
    Ok. There's obviously a lot going on here, but I think it's all right headed. First, I would recommend you stay with your inclination and start dipping into Python. Once I moved from AppleScript to Python, I've never looked back. If I ever need Applescript specific functionality, I can invoke directly within a Python script. So, big vote for Python.
    On that same line, I think building things for and with Alfred is a great way to start, so I would also recommend that intuition. It has a number of limitations, which keep things fairly well within scope, but it's also incredibly flexible, so you can do crazy things (my own workflows are all over the map in terms of functionality and how they use Alfred's interface). I really think you should start by reading the documentation for the Alfred-Workflow Python library. It's a great introduction to writing workflows for Alfred in Python. And that library is (IMHO) the best for integrating a scripting language with Alfred. Then, I'd also read through the source code on GitHub to start getting a feel for how Python is written, especially for Alfred. Dean, who wrote the library, is a very gifted Pythonista and his code is an excellent example of Python code; very clear, very direct, very clean.
    Next, start topics in this forum for specific questions. The people here are here frequently enough and like to help. And having a specific question with a specific goal will likely get some good responses. I've learned so much from the people on this forum.
    Finally, on general advice, I'd remind you to keep refactoring. You will learn new things all the time; go back and put them into practice in a code base you know well.

    So, that's general advice, here's some specific thoughts on your questions.
    First, I answered the Evernote images question in your other thread response. The key are HTML image links with URLs to local files.
    The infer_spaces() algorithm is a bit much to take in on first read, but it looks pretty efficient as it. As for passing arguments to a Python script from Applescript and getting the results back, check out my Wikify workflow, and specifically the en2md.scpt, which calls to a Python script. Passing over numbers should be fairly simple, just add an if clause to the function, like if isinstance(character, int): continue (this is Python). This would likely go best here in the Python code linked above:

    # Backtrack to recover the minimal-cost string. out = [] i = len(s) while i>0: if isinstance(s[i], int): continue c,k = best_match(i) assert c == cost[i] out.append(s[i-k:i]) i -= k Finally, for word frequency of texts, you should really check out the NLTK Python package. For some idea of how to get word frequency from a text using that Python package, see section "3.1 Frequency Distributions" here.Those are my initial responses. Please do respond with any further questions...
    stephen
  10. Like
    deanishe got a reaction from rice.shawn in Lock function on macbook with Yosemite loses wifi   
    I've been having all kinds of problems with the network on Yosemite, especially after sleeping.
    I think there's just something wrong with Yosemite.
  11. Like
    deanishe got a reaction from mixterdee in Browse Reddit   
    Reddit for Alfred

    Find subreddits and browse hot posts on Reddit.



    Download

    Get Reddit for Alfred from GitHub.

    Usage
    r/ — Show list of popular subreddits r/<query> — Search for subreddits matching <query> ↩ or ⇥ or ⌘+NUM — Show 50 hottest posts in subreddit r/subreddit/ — Show 50 hottest posts on subreddit <subreddit> r/<subreddit>/<query> — Filter posts by <query> ↩ or ⌘+NUM — Open post URL in default browser ⌘+↩ — Open Reddit comments in default browser ⌘+L — Show full post title in Alfred's Large Text window Note: OS X's "delete word" shortcut (⌥+⌫) is very handy for backing
    out of a subreddit.

    Description

    A fairly rudimentary workflow to browse subreddits.

    The subreddit search, r/<query>, uses Reddit's API to search for subreddits
    that match <query>. 25 results are retrieved by default.

    The subreddit search can be a bit odd, which is due to the oddness of Reddit's
    search function.

    Search within a subreddit, r/subreddit/<query>, only filters the list of hot
    results. 50 results are retrieved by default.
  12. Like
    deanishe got a reaction from xilopaint in Searchio! Auto-suggestion from search engines in different languages   
    Unfortunately, the Amazon sites all need to be hand-coded to get the right suggestions language, domain etc. I've added amazon.com.br in version 1.6.
     
    Also added yandex.ru (Russian-language only).
     
    Download from GitHub.
  13. Like
    deanishe got a reaction from lendenmc in Pocket for Alfred   
    Hi Fabio,
     
    Just had a quick look at the code. It should work on 10.7, which has Python 2.7, but not 10.6 because argparse wasn't in Python 2.6.
     
    You'll have to include it in the workflow to support 10.6.
  14. Like
    deanishe got a reaction from thanasut in Searchio! Auto-suggestion from search engines in different languages   
    Searchio! workflow for Alfred
    Auto-suggest search results from multiple search engines and languages.
     
    There are a few existing workflows that provide auto-suggest results from one or the other search engine, but this includes not only multiple search engines, but also allows you to specify multiple languages/regions for your results.

    Supports the following search engines/websites:
    Google Google Images Google Maps YouTube Wikipedia Wiktionary Amazon eBay DuckDuckGo Bing Yahoo! Ask.com Yandex.ru Naver.com Wikia.com  
    Download and installation
    Download the latest version from the GitHub releases page or Packal.
    Usage
    There are several searches pre-configured. Only some have keywords (i.e. can be used as-is):
    g — Search Google in system (i.e. default) language m — Search Google Maps in system (i.e. default) language gi — Search Google Images in system (i.e. default) language w — Search Wikipedia in system (i.e. default) language wn — Search Wiktionary in system (i.e. default) language a — Search Amazon in system (i.e. default) language. If your system language is English, this will search Amazon.com. Use -l uk in the Script Filter to search Amazon.co.uk or -l ca to search Amazon.ca. yt — Search YouTube in system (i.e. default) language searchio [<query>] — Show settings and list of supported search engines. Currently, the only setting is a toggle to also show the <query> in the results list (default: No). searchiohelp — Open help file in your browser You can add a keyword to (and edit) one of the existing examples or add your own searches. For details on how to do that, see the GitHub page.
     
    Licensing, thanks
    The code in this workflow is released under the MIT Licence.
    The icons belong to the respective search engines.
    This workflow uses the Alfred-Workflow library and docopt (both MIT-licensed).
  15. Like
    deanishe got a reaction from bachya in Movie and TV Show Search   
    Apart from people building super-cool workflow with the library (obviously), it's comments like this that make it all worth doing. Thanks very much, and I'm very glad to hear the docs are useful.
  16. Like
    deanishe got a reaction from smarg19 in Movie and TV Show Search   
    Apart from people building super-cool workflow with the library (obviously), it's comments like this that make it all worth doing. Thanks very much, and I'm very glad to hear the docs are useful.
  17. Like
    deanishe reacted to jarnot in Searchio! Auto-suggestion from search engines in different languages   
    That fixed it.  Thanks!
  18. Like
    deanishe reacted to tone in Movie and TV Show Search   
    Thanks deanishe! Very valuable info (your documentation is excellent). I appreciate you looking through the code. I've made the various changes you've suggested and will include it in the next release.
  19. Like
    deanishe got a reaction from jmjeong in Workflow Library for Python   
    IMPORTANT NOTE ABOUT HANGING PROCESSES ON SIERRA (2017-04-03)
     
    Versions of Alfred-Workflow older than 1.25 cannot launch background processes properly on Sierra. In fact, they regularly hang quite dramatically and consume 100% CPU  
     
    Users (in particular) affected by this bug should install and run this workflow, which can find and fix any workflows with broken versions of Alfred-Workflow.
     
     
    The workflow library for Python
     
    GitHub | Documentation

    A feature-rich library for developing Alfred workflows in Python

    The library is simple to install, has no external dependencies, is very well-documented and maintained, and boasts an eye-wateringly high feature-to-size ratio at under 400 KB. It is the only Python library that is always up-to-date with Alfred's features.

    Main features
    Supports all Alfred features from 2.0 to 3.6. Catches, logs and notifies users (and developers) of errors in Workflows. No more confusing, silent failure. Super-simple, yet powerful data caching (e.g. from a web service) and storage, including session-scoped data. Easy-to-use Workflow settings API. Supports Alfred's AppleScript API, including saving settings to info.plist and calling External Triggers. Keychain access for secure storage (and cross-machine syncing) of sensitive data, like passwords and API keys. Tunable and understandable Alfred-like fuzzy search (e.g. got matches Game of Thrones as well as Baby Got Back. Or not: that's up to you.) Extremely lightweight, but full-featured, HTTP library with Requests-like interface, but just 12 KB instead of > 2 MB. Convenient access to standard macOS icons, for high-quality, familiar icons without adding size to the library. Also available via proper English. Pre-configured, built-in logging to enable simpler Workflow debugging. Painlessly run (update) scripts in the background without blocking your workflow, so you can still show "old" results while fetching new ones. API for running AppleScript/JXA scripts. Simple support for 3rd-party libraries your Workflow relies on. "Magic" arguments to make developing/debugging Workflows so much easier, especially when helping less technically-inclined users. With "magic" arguments, you and your Workflow's users can open the Workflow's log file in Console.app, its cache and data directories in Finder, and its root directory in Finder or Terminal from the comfort of Alfred's query box. You can also delete the cache/data/settings if something is corrupted. Your workflow can update itself via GitHub releases. Smart handling of non-ASCII. Query sale will match result salé, but query salé will not match result sale. Functions to support migrating settings/data from older versions of your workflow. Alfred 3-only features
    Workflow variables Advanced modifiers Alfred 3-only updates Re-run Script Filters  
    And as you can see from the above links, there is extensive documentation, including a two-part tutorial on building a Workflow from scratch.

    Examples

    Here are a few examples of how you can do some pretty cools stuff in just a few lines of code.
    A simple Workflow I made to search Packal in ~90 lines of code. A simple Workflow to search your recent Pinboard posts in ~50 lines of code. A polished, user-friendly, wicked-fast Workflow to search your recent Pinboard posts in ~200 lines of code. Remember, each of these Workflows also has—for free—full error-catching and -logging support, and the ability to open its log file (which contains all errors) via Alfred's query box. No need to ask users to grub around in ~/Library or flounder in Terminal here. This is not the Workflow library 2014 deserves, but it's the one it needs   

    Feedback

    If you have any bug reports/feature requests, add them either here or on GitHub.

    More info

    The documentation is the definitive source of information on the Alfred-Workflow library. The User Guide and Tutorial provide fairly extensive information both on how to use Alfred-Workflow and write Workflows in general (if you're new to this lark).
     
  20. Like
    deanishe got a reaction from smarg19 in Workflow Library for Python   
    It's always a good idea to provide a link to the workflow you're talking about. The non-ASCII path bug has been fixed.
     
    The problem is elements in search_item_fields contains encoded (non-Unicode) strings.
     
    It's not non-ASCII characters that are the problem (sooner or later one of your users will be using them, so you have to handle them correctly), but that you're mixing Unicode and encoded strings in the workflow.
     
    The root problem is that your LastPassVaultManager.py module uses encoded strings throughout, while lpvm.py uses Unicode. You will have problems when you mix the two. In particular, you're not decoding the output of subprocess.check_output to Unicode. Subprocesses return bytes (usually UTF-8-encoded strings).
     
    You need to convert the encoded strings to Unicode with Workflow.decode() or unicodedata.normalize('NFC', unicode('<subprocess output here>', 'utf-8')) (they do the same thing). If you don't convert the output to Unicode, your workflow cannot handle non-ASCII strings.
     
    You should put from __future__ import unicode_literals at the top of LastPassVaultManager.py and make sure to decode all the output of subprocesses to Unicode as described above.
     
    This might help explain it a bit better.

    Also, I just downloaded your workflow to see, and the offending function is now on line 121, not 88, so it would appear your user is using an older version.
  21. Like
    deanishe got a reaction from frankspin in Browse Reddit   
    Reddit for Alfred

    Find subreddits and browse hot posts on Reddit.



    Download

    Get Reddit for Alfred from GitHub.

    Usage
    r/ — Show list of popular subreddits r/<query> — Search for subreddits matching <query> ↩ or ⇥ or ⌘+NUM — Show 50 hottest posts in subreddit r/subreddit/ — Show 50 hottest posts on subreddit <subreddit> r/<subreddit>/<query> — Filter posts by <query> ↩ or ⌘+NUM — Open post URL in default browser ⌘+↩ — Open Reddit comments in default browser ⌘+L — Show full post title in Alfred's Large Text window Note: OS X's "delete word" shortcut (⌥+⌫) is very handy for backing
    out of a subreddit.

    Description

    A fairly rudimentary workflow to browse subreddits.

    The subreddit search, r/<query>, uses Reddit's API to search for subreddits
    that match <query>. 25 results are retrieved by default.

    The subreddit search can be a bit odd, which is due to the oddness of Reddit's
    search function.

    Search within a subreddit, r/subreddit/<query>, only filters the list of hot
    results. 50 results are retrieved by default.
  22. Like
    deanishe got a reaction from smarg19 in Search StackOverflow   
    StackOverflow Search for Alfred
     
    Search for answers on StackOverflow.com from Alfred 2.
     

     
    Download
     
    Get StackOverflow for Alfred from GitHub or Packal.
     
    Usage
    .so <query> — Search StackOverflow.com for <query>. See below for syntax. ↩ or ⌘+NUM — Open result in default browser ⌘+L — Show full question title in Alfred's Large Text window Query syntax
     
    By default, words in <query> will be search for in the title of posts. To specify a tag, prefix it with ., e.g. python will search for python in the post title, .python will search for the tag python.
     
    Results
     
    Answered questions will be shown first in the list of results (and have a tick on their icon).
     
    Licensing, thanks
     
    This workflow is released under the MIT Licence.
     
    It is heavily based on Alfred-Workflow, also MIT-licensed.
  23. Like
    deanishe got a reaction from GatorMapi in Fakeum — Generate fake test datasets in Alfred   
    Fakeum

    Generate fake test data in Alfred for testing.



    Download

    Get the workflow from GitHub.


    Usage
     
    fake [<query>] — List/filter available fake data types ↩, ⌘+C or ⌘+NUM — Copy one fake datum to clipboard ⌘+↩ — Paste fake datum into frontmost app ⇥ — Specify number of datasets to copy to clipboard ⌘+L — Show generated data in Alfred's Large Text window fakeconfig [<query>] — Activate and deactivate locales for fake data ↩ — Toggle selected locale on or off If you specify multiple data, e.g. fake Name 〉 10 for 10 names, the data
    will be separated by newlines (\n).

    In the case of Paragraph and Address types, the data will be separated
    by two newlines (\n\n).

    Supported data types and locales

    See the GitHub page for details.
  24. Like
    deanishe got a reaction from vdesabou in Search StackOverflow   
    StackOverflow Search for Alfred
     
    Search for answers on StackOverflow.com from Alfred 2.
     

     
    Download
     
    Get StackOverflow for Alfred from GitHub or Packal.
     
    Usage
    .so <query> — Search StackOverflow.com for <query>. See below for syntax. ↩ or ⌘+NUM — Open result in default browser ⌘+L — Show full question title in Alfred's Large Text window Query syntax
     
    By default, words in <query> will be search for in the title of posts. To specify a tag, prefix it with ., e.g. python will search for python in the post title, .python will search for the tag python.
     
    Results
     
    Answered questions will be shown first in the list of results (and have a tick on their icon).
     
    Licensing, thanks
     
    This workflow is released under the MIT Licence.
     
    It is heavily based on Alfred-Workflow, also MIT-licensed.
  25. Like
    deanishe got a reaction from cands in Offline Unit Conversion Workflow   
    Critical update to v3.1 on 2017-11-02 (Yahoo! Finance API is dead)
     
    Alfred-Convert v3
    Yet another conversion workflow.
     
    Main features:
    Works offline, so super fast (occasional web access required to update exchange rates) Many hundreds of units supported 1000+ currencies supported, including cryptocurrencies Custom, user-defined units  Auto-updates  

     
     
    Downloading
    Download from GitHub.
     
    Usage
    The syntax is simple: the quantity, the unit you want to convert from then the unit you want to convert to. For example:
    conv 128 mph km conv 72in cm conv 100psi bar conv 20.5 m/s mph  
    Please see the README on GitHub for full instructions.
     
    Supported units
    Currently, Alfred-Convert supports all the units understood by the underlying Pint library plus a handful of additional units and 1000+ currencies. You can see a list of the supported currencies on the GitHub page.
     
    Adding custom units
     
    You can also add your own custom units. Use convinfo to open the unit definition file and the documentation describing how the definition format.
    If you have a unit you think should be included by default, please create a corresponding GitHub issue or ask in this thread.
×
×
  • Create New...