The request below is based upon an earlier version posted on the Aptana Tender site, where it didn't receive a response - presumably because the Aptana Tender site has now been deprecated in favour of StackOverflow.
I'm using Eclipse 3.6.2.r362_v20110210 with the Aptana Studio plugin version 3.0.3.201107141410 (i.e. all fully up-to-date, I believe) on Mac OS X 10.6.8 Snow Leopard on a Macbook.
I created a Ruby project, and then created a single file inside it called "item.rb", into which I wrote some Ruby code.
The file is very short: it defines an "Item" class with an initialisation method that asks the user for a value (using a "puts" followed by a "gets.chomp") and a get method that returns the value, and it also contains two more lines: one to create a new Item, and one to call that method on the newly-created Item.
When I run "ruby item.rb" from the Terminal, it works as expected: it asks the user for a value, and returns that value. No errors/warnings.
Now, I don't want to have to use the Terminal every time I want to execute the file, but I'm having trouble getting it running any other way.
Here are the steps to reproduce:
In the main Eclipse menu, go to Window > Open Perspective > Other.
In the resulting dialogue box, click "Ruby" and click "OK".
In the Script Explorer view, click the triangle next to the name of the project containing the file I want to run, so that the project's contents are shown.
In the Script Explorer view, double-click on the name of the file I want to run (item.rb).
This causes item.rb to open in an editor view, and gives that view focus (i.e. the editor view containing item.rb has a blue rather than a grey border, and there is an active cursor inside the view).
Click the "Run" button on the Eclipse toolbar (the one that looks like a green "Play") button.
THE FIRST PROBLEM: a "Run as..." dialogue box pops up (I don't know why) asking me to "Select a way to run 'item.rb'". It gives me two options (again, I don't know why): "Android Application", "Ruby Application".
Expected behaviour: because item.rb is a file ending in ".rb" and containing only valid Ruby code, Eclipse/Aptana should, by default, run it as a Ruby application.
I click "Ruby Application", and then click "OK".
THE SECOND PROBLEM: the dialogue box disappears, but nothing else happens.
Expected behaviour: the Console view should get focus, and item.rb should be executed, with the results showing up in the Console view's textarea.
By this point, it would be reasonable to give up. But programmers are unreasonably persistent, right? So: click the Console tab.
The Console view's header says, "item.rb [Ruby Application] /usr/bin/ruby", and below this is a blank textarea containing only a blinking cursor.
Press the <Return/Enter> key on the Macbook's keyboard once or twice.
THE THIRD PROBLEM: the Console view's textarea suddenly updates with the output of item.rb, but weirdly, it doesn't stop at gets.chomp, it just acts as though the user has entered an empty response at that stage (i.e. as though the user has simply pressed the <Return/Enter> key on the keyboard), and ploughs on until the entire program has executed. The Console view's header then changes to "<terminated> item.rb [Ruby Application] /usr/bin/ruby".
Expected behaviour: item.rb should execute in the Console view just as it does in the Terminal.
Please can you help me troubleshoot these three problems?
Many thanks.
It sounds like you have an older version of Aptana, RDT, RadRails or DLTK Ruby installed, as there is no "Ruby" perspective in Aptana Studio 3.x.
You should be able to right click the file in the Project Explorer, App Explorer, or in the open editor for the file and choose Run As > Ruby Application.
Ideally you'd remove any old installation of ruby plugins to avoid some sort of conflict before doing so. It should then launch the file as expected.
The Enter/Return behavior you're talking about sounds like the program is not flushing STDERR/STDOUT and hitting Enter is proceeding to enter in the input (so, it's buffering the output you should see that forms the prompt, then you hit Enter/Return and it takes that as the input so it proceeds after the gets call). if things printed to STDOUT don't show, you can try and force auto-flushing by adding $stdout.sync = true to the top of your script. Studio 3.x should set that up silently for you on programs launched through it. If not, then you should file a bug: http://jira.appcelerator.org/secure/CreateIssue!default.jspa
Related
I'm struggling with a feature.
I have a scenario where I click a hyperlink to download a CSV. I have the command to open the csv file sorted. Once that hyperlink is pressed, a pop up box shows up in Firefox and I need to select the Save File option then press OK.
I have no idea how to tell selenium to do this. I have a test code to confirm a new webpage has opened (below)
new_window=page.driver.browser.window_handles.last
page.within_window new_window do
current_url.should eql "https://...."
end
This approach doesn't work for the download pop up. I need to move to the pop up and press those two options.
Any help would be appreciated
You are missing one important thing: Once your hyperlink is pressed, Firefox directs the underlying operating system to launch a pop up. In other words, you are no longer dealing with Firefox, and therefore Selenium is completely blind to that modal window. Generally the solution is something like Sikuli, Robot, or some other framework.
Also, have a read through this: http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/
I am trying to make a keyboard shortcut to launch terminal in OS X Mountain Lion.
After some research I found out that I can use Automator to achieve this:
http://mac.tutsplus.com/tutorials/tips-shortcuts/how-to-launch-any-app-with-a-keyboard-shortcut/
It works, but I noticed that whenever I launch a terminal using this method, a process called WorkFlowServiceRunner starts and never terminates. To make matters worse when I launch more terminals (or launch different applications using shortcuts, again, through Automator) multiple WorkFlowServiceRunner processes start and quickly eat up the memory.
I've also tried writing my own applescripts but the problem does not go away. This clearly looks like a memory leak. Is this a bug in OS X Automator? Is there a way to write an applescript so that the WorkFlowServiceRunner terminates after doing its job (e.g. launch a terminal)? Automator seems to be the most "native" way of getting this done and I do not want to use any 3rd party apps.
I have noticed this from time to time.
One way around it would be to make your own service apps with a Cocoa-AppleScript Applet.
It is not very hard to do. And I will try and guide you through it. It should only take you a couple of minutes.
Step 1.
Open your Application Applescript Editor. And go to the "File" Menu -> "New from Template" -> Cocoa-AppleScript Applet.app
Step 2,
Paste this code into the new documents.
property NSWorkspace : class "NSWorkspace"
tell current application's NSApp to setServicesProvider_(me)
NSUpdateDynamicServices()
my runAService()
on runAService()
NSWorkspace's sharedWorkspace()'s launchAppWithBundleIdentifier_options_additionalEventParamDescriptor_launchIdentifier_("com.apple.Terminal", current application's NSWorkspaceLaunchDefault, missing value, missing value)
tell me to quit
end runAService
Step 3,
Compile
(click this to compile)
and Save the app.
*Make sure the show startup screen is unchecked in the Save dialogue.
Giving the app a name like LaunchTerminal.app
Step 4,
Click the "Bundle Contents" button on the top right hand side of the document.
This will open the applications contents view.
Click the Action button and then "Reveal in finder" sub menu.
step 5,
In the contents folder that opens in the finder you will see a file name "info.plist"
Open Terminal.app and type and run this code using the path to this file:
BUT make sure you do not include the ".plist" part of the name when entering it in Terminal.app
/usr/bin/defaults write /Users/YourUserNameHere/myServiceApps/LaunchTerminal.app/Contents/Info NSServices -array-add '{NSMenuItem={default="Launch Terminal";}; NSMessage="runAService"; NSSendTypes=();}'
( You can drag n drop the file into terminal to get the posix path string )
The path part looks like this: /Users/YourUserNameHere/myServiceApps/LaunchTerminal.app/Contents/Info
This code should add an array to the plist file which is part of the apps way of broadcasting it has a service.
step 6,
Compile and Save the App again.
Just to make sure it picks up the changes. ( I found I had to do this even though I should not have to)
step 7,
Double click the app to run it for the first time.
The App will quit straight away. But the first run should have broadcast that it has a service that should be registered with the system
step 8,
Open system Preferences and go to Services -> General (section)
And you will see the "Launch Terminal" service.
Set up your short cut as normal.
Hope this helps..
UPDATE :
I noticed that the tell application "Terminal" to activate. Would not open my default Window groups if I had closed them all and quit Terminal before. The normal behaviour if I have done this is for my default window group to open. ( I have two Tabs open at startup each cd'd to a different path).
So I have change the open application to a cocoa way of doing it.
A do shell script with open the/application/path/. will work also.
Try using Butler or QuicKeys. They both have endless "Trial periods."
I am using VS express 2012 to run a code that display content of many files. I found that first files content do not show and when I debug step by step I found that the content show on the console window and disappear when other results show, which means they get pushed out of the window. of course I scroll up and I find the latest files only not all. Is there any option control this feature? and how can I see all results?
To avoid this you should convert your console application to a Windows Forms one and put all the output on a TextBox. Just execute the command on the Form load and redirect all the output to the TextBox.
It's not much work IMHO.
This is the nature of a console application, no different than if you were to echo data to the Windows command prompt. If there is too much data then of course it will scroll off the visible screen.
I would work much faster if I could have some kind of command line running inside rubymine, is this possible? When testing I repeatedly have to switch to my terminal window and it gets quite annoying.
I can run rails console and also the sandboxed version side rubymine aswell as my rails server and spork server.
It would be nice to have a command prompt inside rubymine also would speed things up. Infact that would make rubymine 100% perfect for my rails development as it does everything else require.
There is no such feature in IDEA platform based products. You need to run terminal externally. Note that you can create an External Tool to run terminal window in the current file or module directory for convenience.
UPDATE: Terminal (SSH console) was added in PhpStorm/WebStorm 7.0, IDEA 13, RubyMine 6, PyCharm 2.7.3.
I have used CrazyCoder's instructions to do this. Here are the instructions for Windows:
File, Settings
bottom half of menu is titled IDE Settings, look in this list to find External Tools
Click in the only available button (for most), [+]
give your custom thing a name ("terminal"? "command prompt"?)
most of this stuff you just leave blank
click the [...] button next to Program, then simply navigate to Windows/system32/cmd.exe
Lastly, unless you want to have your starting command line (terminal) path as C:\Windows\system32 (CHANGE YOUR PATH), simply click on the [...] next to the "Working Directory" just below, and change your path to Desktop or whatever it is you prefer.
Click OK.
You're done! It's that easy. Now to access this (no restart required), click on Tools, and then under 'XML actions' (for me anyway) you should find your "terminal" or "cmd" or whatever it is you called it. You can test it out with an 'ipconfig' command. You can always go back to the the settings/external-tools place you went to in the first place to edit your settings (like your default path), or to make another custom tool, because this (RubyMine External Tools creator) is obviously a very powerful tool.
If someone is searching this for rubymine in version 7.
Press Alt+f12 for the terminal.
Source : https://www.jetbrains.com/ruby/webhelp/working-with-embedded-local-terminal.html
Often in MATLAB I turn on 'automatic' debugging with dbstop if error. When an error occurs, the function enters debug mode, and I am able to query the variables in the command window and see exactly what is going on. Very useful.
However, when this occurs, the focus switches to the editor. To me this seems counter-intuitive; we are in debug mode, so I want to find out what is going on, not look at the code (which I can already see in the adjacent window). I always immediately tab back to the command window.
So my first question is: Is there any point in accessing the editor at this point? What can I usefully do, when my script has crashed, in the editor?
And secondly: If I want to, can I change MATLAB's default behaviour to keep the focus in the command window?
To your second question:
If you use MATLAB's desktop environment, just deselect "Open Files when Debugging" in the "Debug" menu.
If you use MATLAB without the graphical desktop you can change this preference by modifying your matlab.prf file. This file stores preferences set from the GUI. The menu option described above makes the same changes as the manual process described below.
NOTE: Editing this file is entirely unsupported. Do so at your own risk.
Open the file from the MATLAB command prompt,
>> edit([prefdir '/matlab.prf'])
Or use the prefdir command in MATLAB to find the directory and then open the file in whatever editor you prefer.
Search for a line that says
EditorGraphicalDebugging=Btrue
Change it to read
EditorGraphicalDebugging=Bfalse
If the line doesn't exist, add it to the file.
Restart MATLAB.
You can use the invocation stack to see how you came about to the particular error position. Sure, you can use dbup and dbdown for this in the command window, but it's much easier in the editor.
Also, seeing the variables (and their values, using mouse hover) in the context of the code that caused the crash is far better for understanding the root cause of the error than just seeing the static values.
I can answer only your first question.
Things you can do in the editor:
Mouse hover a variable, which pops up a 'quick view' window.
Any action you can do when not in debug mode, treating the function as a script - running a line (highlight + F9), running a code block, etc.