I'm using AsUnit for unit-testing my current AS3 project. My Main() is basically:
if ( UnitTest )
runUnitTests();
else
runMainProgram();
where I change UnitTest before building depending on whether I want to run the program or run the unit tests. Is there a way that makes it easier to switch between the two modes?
Optimally, I'd use F5 for building with UnitTest=false and another hotkey for building with UnitTest=false. What is the closest I can get with FlashDevelop?
You can do the following in FlashDevelop
if(CONFIG::debug) {
trace("Debug");
} else if(CONFIG::release) {
trace("Release");
}
These correspond to the drop down in the toolbar next to the play button.
See this link: http://www.flashdevelop.org/wikidocs/index.php?title=AS3_Conditional_Compilation
In terms of the shortcut, just create a macro that switches the release mode then hits play. From there you can add any shortcut you would like to your macro. So one shortcut will launch the course into debug/release mode as required.
Also note, you can have other CONFIG::bla's - so you might want to have CONFIG:unit1, CONFIG:unit2, etc, etc. See above link.
Easy solution:
duplicate the FlashDevelop project file (.as3proj) and name it "MyProject_tests.as3proj",
open this project, create a new ProjectTests class and set it as the main class,
change the output SWF in project settings.
Add another project file. To run the test using it as the primary. "Document class" the context menu on the file.
Like Chris mentioned, you can use FlashDevelop's Compiler Constants to do what you need, though it is a bit cumbersome turning these constants on and off.
However, there is a FlashDevelop plugin called Config::Toggle that makes that significantly quicker by providing an additional panel where you can enable/disable boolean constants with 1 click. The linked website describes the value of the plugin far better than I ever could. Hope that helps.
Related
I installed "Live Templates for Angular" plugin in PhpStorm. I think something is wrong with suggestion (triggered with Ctrl + Space). I have to write whole snippet a-component to get to right suggestion.
Can I improve it somehow in settings?
Here is a gif:
It's because the template name (abbreviation) has a dash - in it ... and when completing IDE treats a and component as separate parts until whole match is found (in case you were doing some subtraction operation with two variables). At very least that's my understanding of this behaviour based on my own usage experience.
You may just change the abbreviation and remove - from there and it will be much better recognized as valid completion item. But that may not be ideal in long run (potentially may have issues when plugin will be updated with new templates etc.)
To bypass it ... just use Live Template specific completion where only Live Templates will be listed. For that invoke shortcut assigned to Code | Insert Live Template... action (Ctrl + J on Windows using Default keymap) at any time when you're typing your Live Template abbreviation.
Please make sure the applicable context yet.
Apply to the specified type of file, or check everywhere.
Like below:
I'm currently working on a HTML5 projects in netbeans and wanted to change a variable name with multiple occurrence. However, when I clicked refactor and then rename, the IDE tells me that:
Rename refactoring can't be applied in this context.
So is it possible to refactor variable names in HTML5 projects in Netbeans?
The JavaScript refactoring options are very limited, typically it works only in context of single file and you can invoke it by placing cursor on the target variable/function and pressing Ctrl+R (sorry, not sure about the shortcut on Mac) and then typing a new name. This is not full refactoring, only "limited rename" and again, it will rename variables only in given file, not the whole project.
Please note that in NetBeans if you open Refactor from the main menu, there is also Rename action with the same shortcut displayed but the shortcut is actually doing something else than the menu item.
I have a project containing a big package "global" of classes which is designed for Web, I need to share these classes with a new mobile project, but when i add them with :
Properties -> Flex Build Path -> Source path -> Add Folder
they start appearing with index [source path] before the package name, and since them Flash Builder start trowing error messages :
"A file found in a source-path must have the same package structure '', as the definition's package, 'global'."
How can i fix this issue ?
As we've discussed in the comments, I think it would be a better approach to compile your "global" classes into a library (.swc).
You were concerned about loading unnecessary classes: when you link to a library as 'merged', only the classes you use are actually compiled into the main application (and any classes they depend on), so there's no need to worry about that.
As a last argument I also think this is a more flexible approach. A compiled library is easier to reuse and version, so the code can more easily be distributed to other developers on your team.
Rename one of the packages with right click->refactor. Than is should work.
If not you can also try to have your two codes available at the same project, and then you can select which to run in Flash Builder, by right-clicking to that .as or .mxml file, and selecting set as ... (or something like that)
I guess if you will include 'src' fonder instead of 'src/global' that problem will disappear.
I am developing a package in R
When I am debugging a particular function or set of functions, what is the best way to test the function?
Do I have to either use source('function.R') or R CMD build each time I want to check my changes?
(extra credit for associated emacs ess key-bindings)
See also http://github.com/hadley/devtools/ which provides some tools to make this task easier.
for example, after making changes to source code, you build, install, and reload a package with the function install():
library(devtools)
install("package_name")
devtools also makes it easier to:
Reload complete package:
load_all("pkg")
Create or update documentation using roxygen2
document("pkg")
run all scripts in /inst/test/:
test("pkg")
build and R CMD check:
check("pkg")
Take a look at ?insertSource, which is a new function in R 2.12.0, plus the other functions in the See Also section of that help page. Also, check out ?assignInNamespace if your package has a Namespace.
The above presumes you are talking about updating and debugging R sources, not compiled code.
I generally have used the source() route to load new versions of functions I am improving/debugging, alongside the usual R debugging tools. But I haven't got Namespaces in my packages as yet. My fingers have gotten quite used to the C-c C-l keybinding in emacs+ess for sourcing a buffer over the years.
You might want to have a look at the 'mvbutils' package. I use it to live-edit my packages all the time; I can add, remove, and edit functions and documentation while the package is loaded, and the changes are reflected both in the loaded version, in the installed version (so they're kept in the next R session), and [when I tell it] in the "source package". I only re-build via R CMD when I want to distribute a zipped version to someone else. To test code, I use the 'debug' package, which works fine on a loaded package.
I even use 'mvbutils' to live-edit 'mvbutils', which can be a bit hairy sometimes.
The 'mvbutils' documentation could really do with a full demo of this in action, but in theory the existing doco should show you how to proceed.
Can't help you with Emacs, sorry...
I had got the same issue and I solved it while using RStudio.
In the editor, I check the option "Source on save" for my R file that contains function. As I'm used to save my file each time I edit it (a good habit I think), the corresponding functions loaded in my R workspace is always up to date.
I have an MFC application that I was given (without source code) which opens a window with an 'Update' button, which then performs a very long update after being clicked.
I'd like to modify the program so that when the window is created (or somewhere else such as DoModal), a message is sent to the program to make it think that the button was pressed.
I've been toying around with this for a while in Ida Pro and OllyDbg to no avail. I looked at possibly using PumpMessage, but this did not bring any success.
Any advice?
If you don't like the idea of using a secondary "macro" program, you could patch the original program's binary to call the button's BM_CLICK handler. If you can find some space for the call (minimum 5 bytes without arguments), you can do this with OllyDbg alone (after editing the code, select it, and select "Copy to executable" -> "Selection" from the right-click menu). Otherwise, you'll need to create a new code section with a PE editor (e.g. LordPE or PE Tools) and add your code there (typically you'll want to change a call in the program to a jump to your section, where you perform the original call plus the call to the button's click handler, then jump back to the old position after your patched jump).
There are a few ways to do it using test automation techniques, but the simplest is to simply get the window handle for the button you want and send it a BM_CLICK message. This assumes that you have a working knowledge of C/C++ on Windows. If not, there are other means using .NET or other technologies. I'm not familiar with ida-pro or ollydbg.
See this perl module win32::guitest it could help you to do this.you can write with it a perl script and embed it in your program. or you can use the win32 api that wrap your required needs and use it.
Just create a 2nd program that will lunch it and will send a mouse click using SendInput(...)