So I just tried excluding String[] args from the main method
It compiled alright !
But JVM is showing an exception
Why did it compile when String[] args HAS to be included every time ?
What is going on here ? Why won't it show a compilation error ?
typing this made me think that may be compiler did not see it as THE main method ..is that so ?
I have this code-
/**
Save the web view as a screenshot. Currently only supports saving to
the photo library.
/
- (void)saveScreenshot:(NSArray)arguments withDict:(NSDictionary*)options
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGRect imageRect = CGRectMake(0, 0, CGRectGetWidth(screenRect),
CGRectGetHeight(screenRect));
UIGraphicsBeginImageContext(imageRect.size);
[webView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, self, nil, nil);
UIAlertView *alert= [[UIAlertView alloc] initWithTitle:nil
message:@"Image Saved" delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
This is for saving whatever you drew in my app. How would I add the button for this in the HTML code. How do i call from it?
The following code is working sort of fine:
open( PIPE, '-|', 'ant' );
for( <PIPE> ) {
print;
}
However, it doesn't do what I want. Since the Ant build can take 5 minutes, I would like to see the output line by line.
Instead, I'm getting the entire input at the end of the process.
Looking at it with the Perl debugger, Perl waits at the 'for' statement, until Ant terminates. Why is that?
in my cms i have index.php, where client must enter username and password. if they are correct, he'll moove to admin.php, where the cms is.
but now hacker can enter to cms/admin.php, so my security now is awful.
i know, that i can use $_SESSION variable.
index.php - i can give some value to $_SESSION['error']:
$_SESSION['error'] = TRUE, and in admin.php just verify it
admin.php
if($_SESSION['error'] == TRUE)
{
my script here...
}
else header("Location: index.php");
but i want to rich this effect without SESSION.
could you give me an idea, how can i do it?
thanks
how can i create method which return sqrt of given nunber? for example sqrt(16) returns 4
and sqrt(5) returns 2.3... please help i am using java and know Math.sqrt() API function but i need method itself
Everytime the IWpfTextView's TextBuffer changes I am trying to get the history's redostack and undostack and simply checking the count. When doing this I am encountering a "Method not supported exception" when trying to access the two stacks.
Am I retrieving the history incorrectly or does VS not want me seeing/editing the contents of the stacks?
I can post the code if necessary...
Thanks,
Nick
I'm running PHP 5.3.0. I've found that the curly string syntax only works when the first character of the expression is $. Is there a way to include other types of expressions (function calls, etc)?
Trivial example:
<?php
$x = '05';
echo "{$x}"; // works as expected
echo "{intval($x)}"; // hoped for "5", got "{intval(05)}"
How do I split the UIPicker into multiple parts, like the date picker only not the Day, month, and year - my own specified variables such as - Gender and age?
I have some problems using two dimensional array in the code and need some help.
static const int PATTERNS[20][4];
static void init_PATTERN()
{
// problem #1
int (&patterns)[20][4] = const_cast<int[20][4]>(PATTERNS);
...
}
extern void UsePattern(int a, const int** patterns, int patterns_size);
// problem #2
UsePattern(10, PATTERNS, sizeof(PATTERNS)/sizeof(PATTERNS[0]));
in the first statement, I need to cast the const off the two dimensional array PATTERNS. The reason for this is that the init function is called only once, and in the remaining code, PATTERNS is strictly read-only.
In the second statement, I need to pass PATTERNS array to the int** argument. Direct passing resulted a compile error.
Thanks!
i am using excel to connect to a mysql database
i am doing this:
rs.Find "rowid='105'"
If Not rs.EOF Then cn.Execute "delete from batchinfo where rowid='105'"
and it works well
however, i need to be able to match data on multiple columns for example like this:
rs. find "rowid='105'" and "something='sometext'" and "somethingelse='moretext'"
i need to know whether or not rs.find matched ALL of the data.
how can i do this?
according to this i can't:
http://articles.techrepublic.com.com/5100-10878_11-1045830.html#
however perhaps there's a way i can rs.execute "some select statement"
can someone help with this?
would this do the trick for me and then i would check EOF:
rs.Filter "LastName='Adams' and FirstName='Lamont'"
I'm loading pixels from an image which is 32 w by 32 height. The format I'm loading them in is ARGB via java. When I bind this to the video card, I can expect that the video card might use somewhere around 32*32*4 bytes, or 4K.
Similarly, 1024 w, 1024 h would be 1024*1024*4 = 4MB.
Is my understanding correct? Now I understand where all the memory goes!
var arr1:Array = new Array();
arr1.push(item1);
arr1.push(item2);
arr1.push(item3);
then arr1 and its elements get passed to other functions
is there a way to know the index of an item in the array?
GetParentArrayIndex(item2) would give me 1;
Hi,
I have this POSIX thread:
void subthread(void)
{
while(!quit_thread) {
// do something
...
// don't waste cpu cycles
if(!quit_thread) usleep(500);
}
// free resources
...
// tell main thread we're done
quit_thread = FALSE;
}
Now I want to terminate subthread() from my main thread. I've tried the following:
quit_thread = TRUE;
// wait until subthread() has cleaned its resources
while(quit_thread);
But it does not work! The while() clause does never exit although my subthread clearly sets quit_thread to FALSE after having freed its resources!
If I modify my shutdown code like this:
quit_thread = TRUE;
// wait until subthread() has cleaned its resources
while(quit_thread) usleep(10);
Then everything is working fine! Could someone explain to me why the first solution does not work and why the version with usleep(10) suddenly works? I know that this is not a pretty solution. I could use semaphores/signals for this but I'd like to learn something about multithreading, so I'd like to know why my first solution doesn't work.
Thanks!
I have recently started using the excellent Texter. I wanted to set up a shortcut for creating html comments. However that it seems that the exclamation character (!) has special significance in the program, and so does not come out in script mode.
This character is of course required for...<!-- html comment here -->
Here is the code I tried to create the shortcut...
{HOME}<!-- {END}{BS} -->
Just wondering if there is a way of getting around this problem??
Cheers
I new to NUnit and looking for an explination as to why this test fails?
I get the following exception when running the test.
NUnit.Framework.AssertionException: Expected: equivalent to < <....ExampleClass, <....ExampleClass
But was: < <....ExampleClass, <....ExampleClass
using NUnit.Framework;
using System.Collections.ObjectModel;
public class ExampleClass
{
public ExampleClass()
{
Price = 0m;
}
public string Description { get; set; }
public string SKU { get; set; }
public decimal Price { get; set; }
public int Qty { get; set; }
}
[TestFixture]
public class ExampleClassTests
{
[Test]
public void ExampleTest()
{
var collection1 = new Collection<ExampleClass>
{
new ExampleClass
{Qty = 1, SKU = "971114FT031M"},
new ExampleClass
{Qty = 1, SKU = "971114FT249LV"}
};
var collection2 = new Collection<ExampleClass>
{
new ExampleClass
{Qty = 1, SKU = "971114FT031M"},
new ExampleClass
{Qty = 1, SKU = "971114FT249LV"}
};
CollectionAssert.AreEquivalent(collection1, collection2);
}
}
The problem in this code is that when it's run and I push "Yes" button, This is shown:
This means that my application stopped working, I just want it to end.
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
string message = "An unhandled exception has ocurred, do you want close the app?";
MessageBoxResult currentMB = MessageBox.Show(message, "SomeTitleApp", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
if (currentMB == MessageBoxResult.Yes)
{ Application.Current.Shutdown(); }
else
{ e.Handled = true; }
}
Hello,
I am having a form and many input elements in that. I want certain fields to be validated, so i keep validateLenth etc on those. And i want some fields to not be validated. For example, i have contact information and address information both on the same page. I want to treat contact information as one group. So if some fields are invalid they should not be submitted and address information to be independent of contact information. Thus, if address information is corrected it should be submitted. I have one form only on the page but two buttons, one for address and one for contact.
Simply put :- What is the equivalent of validationGroup of Asp.Net in JSF?
Masters of regular expressions, please help!
See this string:
$string = "http://www.url.com/?fieldA=123&fieldB=456&fieldC=789";
Assuming "fieldB" always has a positive non-decimal numerical value (but not necessarily three digits long), what preg_replace command do I need to remove it completely, such that the string will then read:
$string = "http://www.url.com/?fieldA=123&fieldC=789";
Thanks!
Why the following code prints "0-100"?
(function () {
for ( var i = 100; i >= 0; i -= 5) {
(function() {
var pos = i;
setTimeout(function() {
console.log(" pos = " + pos);
}, (pos + 1)*10);
})();
}
})();
I declare pos = i , which should be in a descending order. This code originated from John Resig' fadeIn() function in his book Pro javascript techniques.
Hi. Please see my code below.
ifstream myLibFile ("libs//%s" , line); // Compile failed here ???
I want to combine the path string and open the related file again.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string line;
ifstream myfile ("libs//Config.txt");
// There are several file names listed in the COnfig.txt file line by line.
if (myfile.is_open())
{
while (! myfile.eof() )
{
getline (myfile,line);
cout << line << endl;
// Read details lib files based on the each line file name.
string libFileLine;
ifstream myLibFile ("libs//%s" , line); // Compile failed here ???
if (myLibFile.is_open())
{
while (! myLibFile.eof() )
{
print "success";
}
myLibFile.close();
}
}
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
i've only ever created external .as files that extended a class such as sprite. now i just want to create one that doesn't extend anything and call it from a frame script.
package
{
public class Test
{
public function Test(val:Number, max:Number)
{
trace(val, max);
}
}
}
from my frame script of an .fla that is in the same folder as Test.as, i'll write this:
Test(50, 100);
this produces the following error:
1137: Incorrect number of arguments. Expected no more than 1.
public static void main(String[] args)
{
int [][]shatner = new int[1][1];
int []rat = new int[4];
shatner[0] = rat;
System.out.println(shatner[0][3]);
}
surprised, The answer is 0, Java doesn't check this kind of indexOutOfBound error?
Trying to use regex refind tag to find the content within the brackets in this example using coldfusion
joe smith <[email protected]>
The resulting text should be
[email protected]
Not having any luck. Any suggestions?