Jump to content

deanishe

Member
  • Posts

    8,759
  • Joined

  • Last visited

  • Days Won

    522

Reputation Activity

  1. Like
    deanishe got a reaction from nesdroc in Goodreads Book Search   
    Search Goodreads.com from Alfred.
     

     
    Download from GitHub.
     
    Search by book/author View your bookshelves and add/remove books List books by author List books in series Open details on Goodreads.com Add custom scripts to pass book data to other programs/URLs  
    See the documentation on GitHub for more information.
     
    The workflow will ask you to authorise it to read your Goodreads data (via OAuth) on first run.
  2. Like
    deanishe got a reaction from xanimus in Store Variables from Run Script Output   
    Hi Dino,
     
    This question belongs in the Workflow Help & Questions forum, where you will find the answer you seek stickied:
    If you have any further questions about workflow variables, please ask in that thread or forum.
  3. Like
    deanishe got a reaction from xanimus in Fuzzy search helper for Script Filters   
    Add fuzzy search to your Script Filters

    This is a simple script you can add to your Script Filters to replace "Alfred filters results" with a fuzzy search algorithm.
     
    https://github.com/deanishe/alfred-fuzzy
     
     
     
    How it works

    Instead of calling your script directly, you call it via fuzzy.py, which caches your script's output for the duration of the user session (as long as the user is using your workflow), and filters the titles of the items emitted by your script against the user's query using a fuzzy algorithm.

    Example usage

    fuzzy.py only works in Script Filters, and you should run it as a bash/zsh script (i.e. with Language = /bin/bash or Language = /bin/zsh).
    Instead of running your own script directly, place ./fuzzy.py in front of it.
    For example, if your Script Filter script looks like this:

    /usr/bin/python myscript.py
    You would replace it with:

    # export user query to `query` environment variable, so `fuzzy.py` can read it export query="$1" # or if you're using "with input as {query}" # export query="{query}" # call your original script via `fuzzy.py` ./fuzzy.py /usr/bin/python myscript.py

    Note: Don't forget to turn off "Alfred filters results"!  
    Caveats

    As the script is written in Python and uses a more complex matching algorithm, it can only handle a few thousands items at most before it becomes irritatingly sluggish (Alfred can handle many tens of thousands).

    If there's interest in the script, I will rewrite it in a compiled language. My Go library uses the same algorithm, and it can comfortably handle 20K+ items.
     

    You can grab a demo workflow from GitHub to see it in action.

    See the GitHub repo for more information.
     
  4. Like
    deanishe got a reaction from Prashant Dwivedi in Web Search : allow basic {query} string manipulation   
    You can do this with a workflow easily enough.
     
    Keyword -> Run Script -> Open URL.
     
    URLs can be manipulated much more powerfully in Python or Ruby than via some additional options in the Web Search dialog.
     
    Here are a few examples in Python:

    from urlparse import urlsplit, urlunsplit url = "{query}" parsed = urlsplit(url) # Domain print(parsed.netloc) # Without scheme:// print(urlunsplit(('',) + parsed[1:]).lstrip('/')) # Hostname print(parsed.hostname) # Resolve URL redirects / Expand shortened URLs import urllib2 print(urllib2.urlopen(url).geturl())
  5. Like
    deanishe got a reaction from Alan He in Remote Use on 2 Computers?   
    Yes, Alfred Remote supports multiple Macs.
  6. Confused
    deanishe got a reaction from devalias in keyword aliases   
    OP wants multiple keywords because he often forgets the right ones. Being able to look up the right one is a better solution than adding aliases and hoping you can remember one of those instead.
     
    Ideally, you would also be able to launch the workflow directly from the search results, but like I said, the feature currently isn't very useful.
  7. Like
    deanishe got a reaction from andy4222 in Automatic spelling correction? Flummoxed by ... spell chekced y'all.   
    It was very easy for me because I already knew all of the necessary stuff (basic text parsing, structure of an Alfred snippet/snippet collection, creating a ZIP file in Python).
     
    I copied this list into my code editor (I use Sublime Text, but whatever), made sure each misspelling only had one correction (i.e. deleted all but one alternative), and pasted the text into a Jupyter Python notebook.
     
    Then I wrote the code to (a) parse the text into (misspelling, correction) pairs, (b) convert each pair into the appropriate structure for an Alfred snippet, (c) convert those structures to JSON, and (d) put them all in a ZIP file. (Alfred workflows and snippet collections – and a whole host of other file formats – are just ZIP files with different extensions.)
     
    It's only about 40 lines of code, all in all.
  8. Like
    deanishe got a reaction from xilopaint in Alfred-Man - Man Pages Search, View (Terminal, PDF, HTML)   
    Congratulations, you have won a body part! The rump is very good, sir.
  9. Like
    deanishe got a reaction from jopemachine in What is your workflow for developing these workflows?   
    Create a new directory for your project with a "src" subdirectory. Create a new, empty workflow in Alfred. Configure the workflow's name, bundle ID, icon etc. in Alfred's UI. Reveal the workflow in Finder. Move everything to the "src" subdirectory of your new project. Delete the workflow from Alfred. Symlink your workflow from the project directory: workflow-install -s src workflow-install script.
  10. Like
    deanishe got a reaction from jopemachine in What is your workflow for developing these workflows?   
    I symlink my own workflows. Your code belongs in version control, not in an .alfredpreferences bundle in your Dropbox.
    So that this works cleanly, for Python, I keep the actual workflow in a src subdirectory of the repo. That way, I can symlink the subdirectory to Alfred without the .git directory ending up in Dropbox, which isn't great. Also, building the workflow is as simple as zipping up the contents of the src directory. Keeps it nice and simple. When the repo root is the same as the workflow root, you have to be careful to exclude files during building. I've seen a few workflows that contained copies of themselves that contained copies of themselves that contained copies of themselves… because the author kept the built workflow alongside the source in his repo.
    With Go, because it needs compiling anyway, I write a build script that puts the completed workflow in a build subdirectory, which can then be symlinked to Alfred or (its contents) zipped into a workflow.
    I also keep all the code in external files and use Alfred's Script boxes like a shell to call the scripts. Alfred is a terrible programmer's editor, and you lose a lot of the benefits of git etc. if all your code is embedded in info.plist.
    This has the overhead of an extra bash process, but that's about 0.01s when it isn't loading your dotfiles.
    With regard to libraries like Alfred-Workflow, I don't think they're as necessary in Alfred 3 thanks to the ease of generating JSON compared to XML (at least in scripting languages). There's a lot more to AW than just generating XML/JSON, but with Alfred 2 you basically needed a library for the XML generation alone.
    Finally, I generally write my workflows as command-line programs. If you have environment variables mapped to command-line flags, you can do some really neat stuff with workflow variables.
  11. Like
    deanishe got a reaction from Alan He in How does the 'alfred:// url handler work?   
    The alfred:// URL is for exporting/importing custom Web Searches. If you open this URL, for example, Alfred will offer to import my TheTVDB.com search:
    alfred://customsearch/Search%20TheTVDB.com%20for%20%27%7Bquery%7D%27/tv/utf8/nospace/http%3A%2F%2Fthetvdb.com%2F%3Fstring%3D%7Bquery%7D%26searchseriesid%3D%26tab%3Dlistseries%26function%3DSearch  
    In Alfred 2, it was also the default way to share themes, but Alfred 3 exports files. This is my "Essen by Night" theme, and should still import in Alfred 3:
    alfred://theme/searchForegroundColor=rgba(211,211,211,0.73)&resultSubtextFontSize=1&searchSelectionForegroundColor=rgba(0,0,0,1.00)&separatorColor=rgba(8,7,7,0.91)&resultSelectedBackgroundColor=rgba(55,52,53,1.00)&shortcutColor=rgba(72,240,62,0.29)&scrollbarColor=rgba(55,52,53,1.00)&imageStyle=4&resultSubtextFont=Helvetica&background=rgba(8,7,7,0.91)&shortcutFontSize=2&searchFontSize=2&resultSubtextColor=rgba(88,83,88,1.00)&searchBackgroundColor=rgba(8,7,7,0.91)&name=Essen%20by%20Night&resultTextFontSize=2&resultSelectedSubtextColor=rgba(212,119,0,0.42)&shortcutSelectedColor=rgba(212,119,0,0.64)&widthSize=2&border=rgba(9,54,66,0.00)&resultTextFont=Helvetica%20Neue&resultTextColor=rgba(206,205,207,0.46)&cornerRoundness=3&searchFont=Helvetica&searchPaddingSize=3&credits=Dean%20Jackson&searchSelectionBackgroundColor=rgba(178,215,255,1.00)&resultSelectedTextColor=rgba(212,119,0,0.71)&resultPaddingSize=2&shortcutFont=Helvetica  
  12. Like
    deanishe got a reaction from crs in Clipboard history - ping frequently used ones   
    Save it as a snippet. That's the place for clipboard entries you want to hold onto.
     
    Hit ⌘S on a clipboard history item to save it as a snippet. You don't have to give the snippet a keyword: you can just keep it around to search for later.
  13. Like
    deanishe got a reaction from zeitlings in [SOLVED] DevonThink 3 Results in Alfred   
    That isn't where the Spotlight/Alfred data are. You need to specify the directory where the exported metadata are, not the database. I just installed DevonThink 3 demo to test, and the correct path appears to be ~/Library/Metadata/com.devon-technologies.think3 (where ~ means your home directory).
     
    Add that to Alfred's Search Scope and see if it works then.
  14. Confused
    deanishe got a reaction from KopperHead in Using PHP on Monterey (macOS 12)?   
    Use Language = /bin/bash and call your script with the appropriate path:
     

    /usr/local/bin/php WorkflowScript.php "$1"
     
    Or put a shebang in your script, make it executable, then run it as an External Script.
  15. Like
    deanishe got a reaction from cocoaaa in Watch List — Play and manage local media and streams   
    Perhaps you could give an example of that?
  16. Thanks
    deanishe got a reaction from jackwayneright in Altered diacritic representation on shell script input?   
    Alfred normalises Unicode to NFD form before passing it to scripts. If you need the raw input as entered by the user, tell Alfred to write it to a text file and read it from there.
  17. Like
    deanishe got a reaction from capripot in Contact searching is accent-sensitive   
    The root cause is that the Spotlight API does diacritic folding, the AddressBook API doesn't.
    To get diacritic folding with contacts, turn on:
    Alfred Preferences > Features > Contacts > Advanced > Use Spotlight metadata for searching contacts.
  18. Like
    deanishe got a reaction from giovanni in Currency Converter   
    It's not a standard package, so you should bundle it with the workflow. Asking non-technical users to install software libraries when you could easily bundle them isn't great.
     
    And, that's not a great way to install requests, either. You should always call pip via /path/to/python -m pip, so you know which Python you’re installing the packages in. There’s no telling what will get called if you just run pip because different Pythons all want to use /usr/local/bin/pip and will overwrite each other.
     
    Alfred also doesn’t use the same PATH as your shell, so python won’t be the same command in Alfred as in a shell. So use the full path to the Python executable.
     
    Finally, you shouldn’t install packages globally like that. Install them in your user-specific library folder, so you aren’t changing the system and don’t need admin rights: /path/to/python -m pip install --user requests
  19. Like
    deanishe got a reaction from giovanni in Making Script Filter `uid`s unique to each session   
    PID is an ideal one for this case. Let the OS guarantee the uniqueness.
     
    I’d also recommend this technique (caching a value in an environment variable) for passwords stored in Keychain. Calling /usr/bin/security is slow, but you don’t want to store passwords in plaintext.
     
    So do password = get_env_var('varname') or get_and_export_keychain_password('account name', 'varname') to ensure /usr/bin/security is only called once instead of every time the Script Filter is run.
     
  20. Thanks
    deanishe got a reaction from Jasondm007 in Search within folder currently selected in Finder   
    No idea, tbh. If you already have a script, you can open the files with /usr/bin/open -a ApplicationName /path/to/file /path/to/other/file instead.
  21. Like
    deanishe got a reaction from znerd in Open Web Search in specific Google Chrome profile   
    Alfred can't do it, no, but you can use an application specifically designed for this kind of thing, like Choosy, to open specific URLs in a particular browser (profile).
     
    I'd say that's your best bet. I don't see Alfred ever implementing such a niche feature.
  22. Thanks
    deanishe got a reaction from GatorMapi in [SOLVED] Strip the Domain out of a URL on copy?   
    Here you go. This Extract Email from URL workflow does what you want.
  23. Like
    deanishe got a reaction from Chris Messina in [SOLVED] Running "npx create-react-app' in Run Script   
    You have to use /usr/local/bin/npx (or whatever the full path to the command is).
  24. Like
    deanishe reacted to dpsr in Alfred not searching within Dropbox folder following update to Dropbox (new Apple silicon version)   
    It appears that Dropbox Beta and OneDrive (which also now uses Apple's File Provider API) the contents of the folder don't load until you navigate to that folder. Due to this, the "files" never make it to the Spotlight index and therefore Alfred doesn't show them. Navigate to the folder and immediately Alfred has the file in its searches. This also makes the File Search Troubleshooter always yield positive results, because to test a file you have to first navigate to Finder, thus adding it to the Spotlight/Alfred index.
     
    A workaround that I've created, which appears to be working for the most part, is to run a small command in Terminal that forces all the folders to enumerate and therefore they get added to the index. Open Terminal and go to the top Dropbox/OneDrive folder, then run this command:
    ls -R */  
    The ls command doesn't change files, but merely lists all folders/files
    The -R switch says to do it recursively through subfolders
    The */ says to list subfolder contents
     
    Depending on the number of subfolders, this command might take a while, but you can leave the Terminal window open with the command running in the background while you do other things.
     
    Update: You also will need to add ~/Library/CloudStorage to Alfred's search scope for Alfred to index the files.
  25. Like
    deanishe got a reaction from Rooter in Script Filter Rerun sends selection to top, even if unrelated items are present   
    Hmm. Could be the user doesn't want to use the Script Filter, though, so you'd have the same problem of the selection jumping away from the item you're after.
     
    Perhaps it'd be better if the selection remained in the same place (i.e 2nd item, 3rd item etc.) when a rerun fires?
×
×
  • Create New...