Jump to content

ClintonStrong

Member
  • Posts

    115
  • Joined

  • Last visited

  • Days Won

    7

Posts posted by ClintonStrong

  1. I haven't looked in to it much, but would it be possible to add checkmarks to the menu items? I see it's commented out in the code (kAXMenuItemMarkCharAttribute), just wondering if it's something that might be added in the future.

     

    Also, it was a bit confusing when I tried to action a menu item that was disabled. I had to check the menu bar to figure out why it wasn't working. Should they just be excluded from the results, or maybe prefixed with "Disabled: "?

  2. You have to walk the whole menu to be able to search it. Dumping is the slow point. On my computer it takes 1.6-1.7 seconds to dump the menu structure for Safari. Contrast that with iTerm, which takes 0.07 seconds.

     

    I _could_ special case Safari and exclude History and Bookmarks but then, of course, you can't search them. :-)

     

    It doesn't look like it's just a case of menu size either. The Chrome menu dumps in 0.25 seconds. Safari just doesn't like to give up its History and Bookmarks menus. If I exclude those two in Safari the time drops to Chrome territory.

     

    Considering there are already other workflows to search Safari's history, it may not be a bad idea to exclude them.

     

    Another idea is to do the searching in Objective-C, and limit the results from there. Not sure how feasible that would be though, or how much that would actually affect performance.

  3. I posted to the Apple forums, requesting a foolproof way of getting the link to the support/specification site for each model ... no responses yet. I'm starting to think perhaps I may have to remove the links (that functionality) in the final workflow, as it's not entirely universal, and requires too much work to get it to work for those that are new to alfred2: I am a FIRM believer in having things "JUST WORK."

    Maybe try loading the page with the 4 digit code, and if there was an error, load the page with the 3 digit code. You can then store the results of that in a cache file so it doesn't have to wait for a page request every time it runs.

  4. Very cool. I was actually going to make something like this myself, but I'm glad I don't have to now!

     

    Some cool things I'd like to see added (although not sure how feasible they are in Alfred):

     

    1. Matrix manipulation

    2. Calculus solver

     

    Also, how come you didn't make its keyword '=' since it's basically replacing the regular calculator?

     

    I personally use '=', but I didn't think it was a good default. I thought it might confusing if you typed '=' and got both the built-in calculator and the workflow's calculator at the same time. You can always change it though.

     

    Since it's essentially just a frontend for bc, I doubt it'll get too many advanced features. I'm still looking in to using (or perhaps creating) another parser, so it could be a possibility in the future. For now I'd probably just go with WolframAlpha for those kind of calculations.

  5. OK folks here is Verison02

     

    Download V02

     

    Nice workflow. Just had one problem: I had to modify the workflow to use the last 3 digits of my serial number in the URL to get the machine name. Otherwise, the curl request just returned this, and caused no results to show:

     

    <?xml version="1.0" encoding="utf-8" ?><root><error>0009</error><locale>en_US</locale></root>
    
  6. An alternative calculator for Alfred 2, supporting custom functions and variables, automatic parentheses matching, and percentages. It also supports k, m, and b (or thousand, million, and billion) as suffixes on a number.

    It's essentially a wrapper around bc with a few extras added in.
    quickcalc.png
    Installation

    Simply download the workflow and open the file. You'll need to have the Powerpack to install workflows.

    Default functions

    I've tried to add support for most of the functions from Alfred's advanced calculator.

    Supported functions: sin, cos, tan, log, log2, ln, exp, abs, sqrt, asin, acos, atan, sinh, cosh,tanh, asinh, acosh, atanh, ceil, floor, round, trunc, rint, near, dtor, rtod, pow, logx, mod, min, max.

    Most of these should be similar to the implementation of Alfred's advanced calculator, but there are a few additions:

    • pow(x, y) can be used to raise x to the power of y, without the integer limitations of the ^ operator in bc.
    • logx(base, x) lets you get the log of a number with a defined base (log calculates with a base of 10 and log2 with a base of 2).
    • mod(x, y) performs the modulo operation.
    • dtor(d) and rtod® converts between degrees and radians (this is part of Alfred's calculator, but I'm documenting them here since googling them doesn't turn up useful results).

    Defining custom functions and variables

    After using the workflow at least once, you can find the custom functions/variables file at "~/Library/Application Support/Alfred 2/Workflow Data/com.clintonstrong.QuickCalc/custom.txt"

    Here's an example custom.txt file:

    define f2c(q) { return (q - 32) / 1.8}define c2f(q) { return 1.8 * q + 32}tax = 8.25%vat = 20%

    In this case, I just defined some functions to convert between celsius and fahrenheit, and set up some variables to use in calculations. It uses the syntax of GNU bc.

    Known bugs and limitations

    When using functions that take multiple arguments, use both a comma and a space to separate the arugments. This is necessary since commas and spaces can be used as thousands separators. For example, use min(5, 10) instead of min(5,10).

    Because percent signs % are used for percentages, you'll need to use the mod function for modulo. For example: mod(10, 3)evaluates to 1.

    Due to limitations with bc, the exponentiation operator (^ or **) doesn't allow numbers to be raised to the power of a float (a number with digits after the decimal place). To get around this, you can use the pow function. For example, pow(2, 2.5) evaluates to 5.6568.

    Percentages don't work as expected within functions. They still get converted (by dividing by 100), but it doesn't work correctly with addition and subtraction (100 + 10% evaluates to 100.10 rather than 110). Percentages should still work fine outside of functions.

    The workflow currently doesn't have support for detecting locales. It expects a period . to be used as a decimal point, with commas, underscores, or spaces as optional thousands separators.

    More info

     

    Changelog

     

    • Apr 17, 2013: Added 'x' for multiplication. Bugfixes.
    • Fix for Ruby 2.0.0/Mavericks.
  7. If I use bundler, does that mean that everyone who uses the workflow has to have bundler installed? (i'm really new into ruby)

     

    Oh, sorry about that. When you use `bundle install --standalone`, it creates a folder called 'bundle' in the current directory and installs the gems there. If you add `require 'bundle/bundler/setup.rb'` to your file, it'll set up the paths to the gems even if Bundler isn't installed.

  8. It's a bit beyond me right now, I wasn't sure how to use gems with ruby scripts in alfred, so all the code is pure ruby 1.8 (is what ships with mnt lion)

    As the Pocket API returns a json object, serializing it myself is too tough of a job, unless someone can help me with it :)

     

    Have a look at Duane Johnson's install_gem.sh script to easily install gems in the workflow's directory. You could also look in to using Bundler and running `bundle install --standalone --clean` after setting up your Gemfile (this is what Zhao Cai's ruby template uses). Bundler basically lets you declare all your dependencies in one file so you can easily install/update them all at once.

  9. Is there a way for this to not open Chrome when running the workflow? I mainly use Safari and only occasionally use Chrome, so have it closed most of the time. Or if that's not possible just a workflow to search Safari tabs, without Chrome :)

     

    Hm, it shouldn't be opening a browser if it isn't already running. It just looks for "Google Chrome.app" in the process list (`ps ax`), but maybe there's a background process running that it's picking up.

     

    I tried making the search a bit more specific to make sure the browser itself is running, and not just a helper app. Let me know if that fixes it. (Updated download link in the original post.)

  10. I did some more testing, and it looks like I misreported the error.

    When a script filter returns either an empty set of XML results (like what I posted above) or any other output that isn't valid, Alfred continues to show those old results, rather than clearing them.

    However, if I wait a bit and type another character, Alfred clears the results.

    I'm not sure if this is intentional or not. If it is, should script filters display an item with a title of "No results found." instead? That gets around the issue, but you don't get the fallback searches like you normally would when no results were found.

  11. Nice script. Just want to point out that you need "Enable access for assistive devices" checked in the Accessibility preference pane for this to work.

     

    Generally, it'll work with apps that display a little document icon in the menu bar. It should work fine in text editors like Sublime Text or TextMate, but I've had trouble getting the proper AXDocument in Xcode -- not sure if there's a way around that in AppleScript.

     

    It might also be useful to get the selection in Finder rather than the open folder, but you'd have to figure out a way to deal with multiple selected files.

     

    Edit: Oh, and if you wanted to turn this into a workflow, you could just add something like `tell app "Alfred 2" to search "$filename"` to view the file in Alfred.

  12. This workflow doesn't seem to provide any results at all at character 3 or after, even if I type slowly. Are you sure this isn't something to do with your code? I made a similar workflow using my php class that included a .5 second sleep at the beginning and then added results and it seemed to work just as expected

     

    Here's a screenshot of the results I get (when I hit multiple keys at the same time): 

     

    Screen%20Shot%202013-03-23%20at%206.44.1

     

    To make sure it wasn't just my workflow, I made it write the query to last_query.txt and the XML output to last_output.xml. Here's the XML output from the command I ran to get that screenshot:

     

    <?xml version='1.0'?>
    <items/>
    

     

    Despite returning XML with no results, Alfred was still showing a result.

     

    Edit: There shouldn't be anything special about my workflow. I tried it with David's Faves workflow, and I get the same behavior: I type a query, but Alfred doesn't update its results to reflect that query.

  13. I'm using v2.0.2 (178) on OS X 10.8.3.

     

    When I type quickly, Alfred doesn't update its results to reflect that query. Alfred still runs the script filter with the correct query, it just doesn't display the updated results.

     

    I noticed this mostly seems to happen with slow scripts, like those that load network resources.

     

    To replicate it, I just made a simple workflow that waits half a second before outputting the XML, and filters them based on your query. If I type "asdf" slowly, it shouldn't match any results. However, if I type it fast (or if I just mash all the keys at the same time), it shows the results as if I had only typed the first letter ("a"). (You can download the workflow here.) I confirmed that the script filter is being run with the correct query and is displaying the correct output (it writes to last_query.txt and last_output.xml in the workflow folder), but it looks like Alfred isn't keeping up and doesn't update the results.

     

    Edit: Just to clarify, you can check last_query.txt and last_output.xml in the workflow folder after running it to see what the correct output should have been.

  14. Hey guys,

    I know that it feels nice to do everything possible right inside Alfred, but sometimes you have much better way.

    In your case you should just add a shortcut to the "Show Help Menu" action, you will then just have to type what you want and hit enter.

    Much faster and reliable than any AppleScript plugin.

    What it looks like : http://dl.dropbox.com/u/574568/Screenshots/y5Q3.png

     

    From my experience, the Help menu doesn't "learn" which menu items you use the most, unlike Alfred. Just another reason I'd like to see this done in Alfred.

  15. How do you go about doing that if you don't mind me asking? Thanks for the tip, I suffer from the same problem so limiting the results is probably going to speed things up for me a good bit. thanks in advance for the help explaining something that's probably apparent to most ;) cheers!

     

    Change line 74 of recent_downloads.rb to:

     

      results.first(40).each do |path|
    

     

    You can change 40 to however many results you want it to display. A better solution would be to add a setting in the config.yaml file, but this is just a quick patch.

  16. I noticed that this workflow was taking a little while to display the results. I did some testing and it looked like the slowdown was from rendering the XML for so many results (I had 276 files/directories in my downloads folder). When I limited the results to 20 or 40 (which is the max amount of results Alfred can show for its built in file search), it loaded about 3 times faster. Just a quick suggestion.

  17. Just a quick suggestion for the color picker: You can show the color picker with any application, not just Finder. You could even use Alfred 2 in the `tell` command. The main benefit is that it won't show any unrelated windows with the color picker, and you can easily bring it back up by invoking Alfred.

     

    This pretty much replaced the color picker application I used to use. Clicking the magnifying glass icon in the color picker replaces apps like ColorSnapper. Pretty cool.

  18. Are you displaying any dialogs in your script? osascript doesn't allow user interaction (such as dialogs), however you can wrap them in a tell block to get it working correctly:

     

    tell application "System Events"
    	activate
    	display dialog "It worked!"
    end tell

     

    If that doesn't fix it, make sure you're using the correct language in the script action (should be bash or zsh). If it still isn't working, you can try running the command from the Terminal, and see what errors it might be outputting.

×
×
  • Create New...