Jump to content

rice.shawn

Member
  • Posts

    973
  • Joined

  • Last visited

  • Days Won

    57

Reputation Activity

  1. Like
    rice.shawn got a reaction from ErfahrungenCOM in Google Translate (Languages Configurable)   
    I just pushed an update that should fix those settings and also fix an icon.
  2. Like
    rice.shawn got a reaction from rigrassm in Google Translate (Languages Configurable)   
    Note: the original version of this workflow utilized an unofficial API that Google Translate exposed. Unfortunately, the Google has shut down the API. There is an alternative workflow that uses the official (paid) Google Translate API that you can find here: http://www.packal.org/workflow/translate-api. It's actually pretty cheap. 
     
    Here's a little ditty that interfaces with Google Translate. The upside of this one is that it gives you access to all of Google Translate's languages (or at least about 80 of them). You can enable/disable languages from inside the workflow.
     
    Find it on Packal.
     
    Demo:
     

     
     
    Current Languages:
    Afrikaans Albanian Arabic Armenian Azerbaljani Basque Belarusian Bengali Bosnian Brazilian Portuguese Bulgarian Catalan Cebuano Chinese Croatian Czech Danish Dutch English Esperanto Estonian Filipino Finnish French Galician Georgian German Greek Gujarati Hatian Creole Hausa Hebrew Hindi Hmong Hungarian Icelandic Igbo Indonesian Irish Italian Japanese Javanese Kannada Khmer Korean Lao Latin Latvian Lithuanian Macedonian Malay Maltese Maori Marathi Mongolian Nepali Norwegian Persian Polish Portuguese Punjabi Romanian Russian Serbian Slovak Slovenian Somali Spanish Swahili Swedish Tamil Telugu Thai Turkish Ukranian Urdu Vietnamese Welsh Yiddish Yoruba Zulu
  3. Like
    rice.shawn got a reaction from Teodin in Google Translate (Languages Configurable)   
    Fixed it. So, v1.2 (now available on Packal) should work. Updates away.
  4. Like
    rice.shawn got a reaction from forgetfulfellow in Google Translate (Languages Configurable)   
    Note: the original version of this workflow utilized an unofficial API that Google Translate exposed. Unfortunately, the Google has shut down the API. There is an alternative workflow that uses the official (paid) Google Translate API that you can find here: http://www.packal.org/workflow/translate-api. It's actually pretty cheap. 
     
    Here's a little ditty that interfaces with Google Translate. The upside of this one is that it gives you access to all of Google Translate's languages (or at least about 80 of them). You can enable/disable languages from inside the workflow.
     
    Find it on Packal.
     
    Demo:
     

     
     
    Current Languages:
    Afrikaans Albanian Arabic Armenian Azerbaljani Basque Belarusian Bengali Bosnian Brazilian Portuguese Bulgarian Catalan Cebuano Chinese Croatian Czech Danish Dutch English Esperanto Estonian Filipino Finnish French Galician Georgian German Greek Gujarati Hatian Creole Hausa Hebrew Hindi Hmong Hungarian Icelandic Igbo Indonesian Irish Italian Japanese Javanese Kannada Khmer Korean Lao Latin Latvian Lithuanian Macedonian Malay Maltese Maori Marathi Mongolian Nepali Norwegian Persian Polish Portuguese Punjabi Romanian Russian Serbian Slovak Slovenian Somali Spanish Swahili Swedish Tamil Telugu Thai Turkish Ukranian Urdu Vietnamese Welsh Yiddish Yoruba Zulu
  5. Like
    rice.shawn got a reaction from vanderholm in Google translate workflow   
    Okay. It can work. I just updated mine.
     
    The endpoint has changed slightly, so the URL needs to be corrected. Also, the trick to get good JSON that Dean pointed out a few posts back no longer works, so you have to scrub the data. Next, the keys seem to have changed in that they're all just numeric arrays.
     
    Here's what I did (it is truly an inelegant hack, but I just wanted to get it working again), so you can crib from it to get this one working again.
    foreach ( $languages as $code => $name ) : $query = "http://translate.google.com/translate_a/single?client=json&ie=UTF-8&oe=UTF-8"; $query .= "&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at"; $query .= "&q=" . urlencode( $text ); $query .= "&hl=en&sl=auto&"; $query .= "tl=" . $code; $trans = file_get_contents( $query ); while ( false !== strpos( $trans, '[,' ) ) : $trans = str_replace( '[,', '[null,', $trans ); endwhile; while ( false !== strpos( $trans, ',,' ) ) : $trans = str_replace( ',,', ',null,', $trans ); endwhile; $trans = json_decode( $trans, true ); $string = ''; foreach ( $trans[0] as $t ) : $string .= trim( $t[0] ) . ' '; endforeach; $w->result( '', $string, $string, "$name: $text", "icons/$code.png", 'yes', '' ); endforeach; (Note: mine lets you use multiple languages at once, so that's why there is the big foreach loop. I haven't updated this to use Alphred yet, so it still uses David's Workflows library)
     
    The while loops scrub the response into something that json_decode can read.
  6. Like
    rice.shawn got a reaction from bonka in Google translate workflow   
    It looks like Translate Shell (which used the same path) found a new way to use it. It should easily be adaptable. So this means that they didn't close it; they just changed it....
  7. Like
    rice.shawn got a reaction from alfredappuser in Google Translate (Languages Configurable)   
    Actually, I think I found a way around it. I need to do some more testing to make sure, but there is some hope.
  8. Like
    rice.shawn got a reaction from bonka in Google translate workflow   
    I don't think it is new. The endpoint that this (and my) workflow used was unofficial, and the paid translation API has been around for quite a while. So, these just used a sort of backdoor that Google had left open. Now, the URL leads to a redirect captcha challenge that redirects nowhere.
     
    It's a pity that they closed the endpoint, but we can't be too mad because it was never official to begin with.
  9. Like
    rice.shawn got a reaction from Grug in Battery - view summary stats about your laptop battery   
    Opening Google search is just the "fallback" search, which means that the workflow failed to produce any usable results for Alfred.
     
    This happened to me as well at some point with some upgrade. To fix it, just open the file battery.sh in the workflow and, around line 81, change
    <title>$TEMPERATURE° C</title> <subtitle>Temperature</subtitle> <icon>temp.png</icon> </item> to
    <title>${TEMPERATURE}° C</title> <subtitle>Temperature</subtitle> <icon>temp.png</icon> </item> So, probably some Yosemite upgrade changed a version of Bash, and that version of Bash chokes when the degree symbol is next to a variable.
  10. Like
    rice.shawn got a reaction from twinpeaks in Alfred Workflow Nodejs   
    There is a pinned thread that explains how to do this sort of thing. Basically, you save previous steps in text files and call alfred to search with new terms.
  11. Like
    rice.shawn reacted to deanishe in Google Books Search   
  12. Like
    rice.shawn got a reaction from xilopaint in Google Books Search   
    Here's a quick way to search Google Books:
     
    Download it from Packal.
     
    It grabs some book images for you in the background so that searches will features them, although image downloading is pushed to the background so it doesn't slow down the script filter. It caches searches for a month (which seems reasonable for Google books), so subsequent searches are prety quick.
     
    Selecting a result will open the Google books page.
     
    I needed this for my own use, and so, using Alphred, I wrote in in less than the time that I took to drink a beer, but I figured that others might enjoy using it, so I'm sharing it here. I'm open to feature requests.
     
    Cheers.
  13. Like
    rice.shawn got a reaction from sirmon in Can't Find the Remote [Resolved]   
    This isn't helpful, but the title of the post makes me want to tell you to check under your couch cushions. That's where I always lose mine.
  14. Like
    rice.shawn got a reaction from Subject22 in Applescript doesn't function properly when called from Bash   
    Well, `osadecompile` doesn't help because it gives you the exact text that you typed in (I was curious if it would). What's hilarious is that this code works:
    osascript -e "$(osadecompile test2.scpt)" But, of course, that's just dumb.
     
    But, the source of the problem is that, when compiled, "state" is not returned as a string (even though you request it as one).
     
    When I try this code:
    #!/usr/bin/osascript tell application "iTunes" set state to (get player state as string) as string if state is "playing" then do shell script "echo is playing: " & state pause else do shell script "echo not playing: " & state end if end tell Then, when playing, I get "not playing: «constant ****kPSP»", and when it is not playing, I get "not playing: «constant ****kPSp»". So, the difference is the big v little p at the end of the constant, but the problem is that it is a constant and not a string.
     
    The actual fix is the following:
    if application "iTunes" is running then tell application "iTunes" if player state is playing then pause end tell end if In other words, if you don't try to make it into a string, then it just works. (Both from the command line and from the script editor).
  15. Like
    rice.shawn got a reaction from dfay in Can't Find the Remote [Resolved]   
    This isn't helpful, but the title of the post makes me want to tell you to check under your couch cushions. That's where I always lose mine.
  16. Like
    rice.shawn got a reaction from dfay in Applescript doesn't function properly when called from Bash   
    It works just fine for me from bash.
     
    All I did was copy/paste the snippet in the OP into a file called test.scpt. I opened iTunes, pressed play on the first track (which, apparently is a Ke$ha track... don't ask). Then, in iTerm I entered the command `osacript test.scpt`, and iTunes paused just fine.
     
    But, let's get a bit more specific. To create the script, I did `nano test.scpt` from in iTerm and copy/pasted there.
     
    As a curiosity, I tried it again by saving it through Script Editor as `test2.scpt`. The script would work correctly when run from Script Editor, but it wouldn't work via the Bash command. So I can reproduce your problem that way.
     
    So there has to be a problem with the way that Script Editor is saving that particular script. When I `cat test.scpt`, then I see the script. When I `cat test2.scpt`, then I get the binary version of the script (garbled text). The size difference is 
    staff 1952 Mar 4 11:45 test2.scpt staff 163 Mar 4 11:35 test.scpt So, 163 bytes vs 2kb. Weird, right?
     
    So, I propose a work around: save the script as plain text rather than as a compiled binary script file. While the latter should work, something is making it not work.
  17. Like
    rice.shawn got a reaction from Subject22 in Applescript doesn't function properly when called from Bash   
    It works just fine for me from bash.
     
    All I did was copy/paste the snippet in the OP into a file called test.scpt. I opened iTunes, pressed play on the first track (which, apparently is a Ke$ha track... don't ask). Then, in iTerm I entered the command `osacript test.scpt`, and iTunes paused just fine.
     
    But, let's get a bit more specific. To create the script, I did `nano test.scpt` from in iTerm and copy/pasted there.
     
    As a curiosity, I tried it again by saving it through Script Editor as `test2.scpt`. The script would work correctly when run from Script Editor, but it wouldn't work via the Bash command. So I can reproduce your problem that way.
     
    So there has to be a problem with the way that Script Editor is saving that particular script. When I `cat test.scpt`, then I see the script. When I `cat test2.scpt`, then I get the binary version of the script (garbled text). The size difference is 
    staff 1952 Mar 4 11:45 test2.scpt staff 163 Mar 4 11:35 test.scpt So, 163 bytes vs 2kb. Weird, right?
     
    So, I propose a work around: save the script as plain text rather than as a compiled binary script file. While the latter should work, something is making it not work.
  18. Like
    rice.shawn got a reaction from RodgerWW in Applescript doesn't function properly when called from Bash   
    It works just fine for me from bash.
     
    All I did was copy/paste the snippet in the OP into a file called test.scpt. I opened iTunes, pressed play on the first track (which, apparently is a Ke$ha track... don't ask). Then, in iTerm I entered the command `osacript test.scpt`, and iTunes paused just fine.
     
    But, let's get a bit more specific. To create the script, I did `nano test.scpt` from in iTerm and copy/pasted there.
     
    As a curiosity, I tried it again by saving it through Script Editor as `test2.scpt`. The script would work correctly when run from Script Editor, but it wouldn't work via the Bash command. So I can reproduce your problem that way.
     
    So there has to be a problem with the way that Script Editor is saving that particular script. When I `cat test.scpt`, then I see the script. When I `cat test2.scpt`, then I get the binary version of the script (garbled text). The size difference is 
    staff 1952 Mar 4 11:45 test2.scpt staff 163 Mar 4 11:35 test.scpt So, 163 bytes vs 2kb. Weird, right?
     
    So, I propose a work around: save the script as plain text rather than as a compiled binary script file. While the latter should work, something is making it not work.
  19. Like
    rice.shawn got a reaction from vdesabou in Alphred: new PHP library   
    What is Alphred?
    Alphred is a PHP library to aid in the creation of workflows for Alfred. Most of Alphred should work with PHP 5.3+ (OS X 10.6+), but some features need PHP 5.4+ (OS X 10.9+). Alphred generally needs Alfred v2.5+ to run.
    It's not quite complete because it needs some testing and a bit more documentation. Please help with the former.
     
    Features
    Simple AlfredXML generation for script filters, including extended XML attributes Create and manage configuration files in ini, json, or sqlite3 from a few lines of code Easy http requests with get or post, including data caching Use the system keychain to store and retrieve passwords Simple logging to single or multiple files as well as the console with variable log levels Filter results easily to match a query Make your script filters faster by using the cli-server (PHP 5.4+) with almost no change to your existing code Easily change dates into strings, exact (1 day, 3 hours, and 23 minutes ago) or fuzzy (yesterday) Use title case without any extra work fork php scripts to have them run in the background (and they know that they're in the background) send asynchonrous notifications with no external library know if the user's theme is light or dark (to set different icons) write complex workflows in 50-60 lines of code  
    Example
    An example workflow (download) that takes your Github Username and Password and grabs a list of your repos and filters them by query is in the example folder. It uses the cli-server. You can see the well-documented code for the script filter and the action script. Without the comments, they reduce to about 60 lines of code together.
    -----
     
    Mostly Original Post:
     
    It seems mostly complete now for a v1 release. It features easy script filter XML generation (with extended XML), an easy way to make http requests, easy results filtering (taken almost verbatim from Deanishe's Python library: thanks, Dean!), keychain interaction, AppleScript, text filters, and more.
     
      I've squashed all the bugs that I can find, but I still need to write up some tutorials on how to use it, but I figure that I'd make a pre-release available if people want to start playing with it. Do remember that I might change the API a bit before v1.0.0, and I might do that because I'd love to get some feedback on how the library feels or what doesn't work.
     
    For now, find v0.9.3-alpha on the Github release page. Just download the attached Alphred.phar file because that's all you need.
    To find automagically generated API docs, check out this page. There are links to both PHPDocumentor and Apigen generated docs. Let me know which ones you like better.
    There are also a few markdown files, for now, in the repository under the tutorial section, and there is also a very simple example workflow (or the script filter and action files) under the example directory.
     
    I'll update this post with more information as we go along, but, for now, that's what I got.
     
    Shawn
  20. Like
    rice.shawn got a reaction from Hatticus24 in [Request] Workflow to resize window to specific size   
    I've put it on Dropbox (temporarily) as a workflow. Remember, it's incomplete because I stopped writing it because a better one with a better approach was published as I was writing it. So, not all of the corners work correctly. But I just tested it, and it seems like the all, north, east, south, and west ones work. The keyword is `fly`.
     
    Open up the workflow and see if you can work from there.
  21. Like
    rice.shawn got a reaction from gabamnml in Packal: Workflow and Theme Repository   
    Not yet. I'm stuck between rewriting Packal, writing Alphred (new PHP library), and writing a dissertation. The latter needs to take priority. But the other two seem to grab my time. Still, because of the diss, I can't make any time promises.
  22. Like
    rice.shawn got a reaction from vdesabou in Spotify Mini Player: Control your Spotify library at your fingertips   
    I just have to chime in and say that this workflow is really amazing. It's one of the most polished ones that I've seen released. I recently looked at the code, and it's pretty amazing how much effort has been put into it, so kudos Vincent for making something so amazing and eminently useful.
  23. Like
    rice.shawn got a reaction from deanishe in Alphred: new PHP library   
    What is Alphred?
    Alphred is a PHP library to aid in the creation of workflows for Alfred. Most of Alphred should work with PHP 5.3+ (OS X 10.6+), but some features need PHP 5.4+ (OS X 10.9+). Alphred generally needs Alfred v2.5+ to run.
    It's not quite complete because it needs some testing and a bit more documentation. Please help with the former.
     
    Features
    Simple AlfredXML generation for script filters, including extended XML attributes Create and manage configuration files in ini, json, or sqlite3 from a few lines of code Easy http requests with get or post, including data caching Use the system keychain to store and retrieve passwords Simple logging to single or multiple files as well as the console with variable log levels Filter results easily to match a query Make your script filters faster by using the cli-server (PHP 5.4+) with almost no change to your existing code Easily change dates into strings, exact (1 day, 3 hours, and 23 minutes ago) or fuzzy (yesterday) Use title case without any extra work fork php scripts to have them run in the background (and they know that they're in the background) send asynchonrous notifications with no external library know if the user's theme is light or dark (to set different icons) write complex workflows in 50-60 lines of code  
    Example
    An example workflow (download) that takes your Github Username and Password and grabs a list of your repos and filters them by query is in the example folder. It uses the cli-server. You can see the well-documented code for the script filter and the action script. Without the comments, they reduce to about 60 lines of code together.
    -----
     
    Mostly Original Post:
     
    It seems mostly complete now for a v1 release. It features easy script filter XML generation (with extended XML), an easy way to make http requests, easy results filtering (taken almost verbatim from Deanishe's Python library: thanks, Dean!), keychain interaction, AppleScript, text filters, and more.
     
      I've squashed all the bugs that I can find, but I still need to write up some tutorials on how to use it, but I figure that I'd make a pre-release available if people want to start playing with it. Do remember that I might change the API a bit before v1.0.0, and I might do that because I'd love to get some feedback on how the library feels or what doesn't work.
     
    For now, find v0.9.3-alpha on the Github release page. Just download the attached Alphred.phar file because that's all you need.
    To find automagically generated API docs, check out this page. There are links to both PHPDocumentor and Apigen generated docs. Let me know which ones you like better.
    There are also a few markdown files, for now, in the repository under the tutorial section, and there is also a very simple example workflow (or the script filter and action files) under the example directory.
     
    I'll update this post with more information as we go along, but, for now, that's what I got.
     
    Shawn
  24. Like
    rice.shawn got a reaction from duarteharris in Change system time   
    You'll have to use the Bash command `systemsetup`
    systemsetup Help Information ------------------------------------- Usage: systemsetup -getdate Display current date. Usage: systemsetup -setdate <mm:dd:yy> Set current date to <mm:dd:yy>. Usage: systemsetup -gettime Display current time. Usage: systemsetup -settime <hh:mm:ss> Set current time to <hh:mm:ss>. Usage: systemsetup -gettimezone Display current time zone. Usage: systemsetup -settimezone <timezone> Set current time zone to <timezone>. Use "-listtimezones" to list time zones. If you read through this thread at the Adobe forums, then you'll see some examples of AppleScript. Because the command needs an administrator's password (sudo access), you'll probably have to do something like:
    set _month to 12 set _day to 12 set _year to 12 set myScript to "systemsetup setdate " & _month & ":" & _day & ":" & _year do shell script myScript with Administrator privileges Obviously, you'll want to set the variables dynamically because that script will just set your system date to 12 Dec 2012. But, I haven't tested it, and screwing around my the date on my system is going to make so many programs throw so many fits that I don't really want to test it, so I leave you here on your own.
     
    Be careful about breaking things.
  25. Like
    rice.shawn got a reaction from voidPortal in Sending Keyboard Modifiers (Ctrl etc.)   
    No. You shouldn't need to do so.
     
    Okay. Here is a script that I just wrote for you.
    on increase_volume(step_size_) set volume_ to output volume of (get volume settings) if volume_ > (100 - step_size_) then set volume output volume 100 else set volume output volume (volume_ + step_size_) end if if output muted of (get volume settings) is true then set volume without output muted end if end increase_volume on decrease_volume(step_size_) set volume_ to output volume of (get volume settings) if 0 > (volume_ - step_size_) then set volume output volume 0 set volume with output muted else set volume output volume (volume_ - step_size_) end if end decrease_volume on mute_volume() set volume with output muted end mute_volume on unmute_volume() set volume without output muted end unmute_volume  That defines four functions (handlers): increase_volume, decrease_volume, mute_volume, and unmute_volume.
     
    Now, this is not complete because for each action, you need to declare what one you're doing. (I don't know you're writing this as a workflow or as simple run applescripts....). If you want to create a workflow with those actions, then use this script, and then use an argument to figure out which function to call. (Note: step_size_ is a variable which is how much you want to increase the volume. Min volume is 0, max volume is 100. If your step_size_ is 7, then it will increase by 7 each time. This can use integers only).
     
    If you want to just have a "run script" for each, then cannibalize the functions. In other words, create a "Volume Up" remote button that is a "Run Applescript". In that box, put in this:
    on alfred_script() set step_size_ to 7 set volume_ to output volume of (get volume settings) if volume_ > (100 - step_size_) then set volume output volume 100 else set volume output volume (volume_ + step_size_) end if if output muted of (get volume settings) is true then set volume without output muted end if end alfred_script (And adjust the step size to whatever you want).
     
    Do the same thing for Decrease Volume, etc...
×
×
  • Create New...