Is there any easy way to get the number of rows returned by a sqlite statement? I don't want to have to go through the process of doing a COUNT() first. Thanks.
Why do i need to create an instance of Random class, if i want to create a random number between 1 and 100 ....like
Random rand = new Random();
rand.Next(1,100);
Is there any static function of Random class to do the same? like...
Random.Next(1,100);
I don't want to create an instance unnecessarily
I wrote a T-SQL query which includes a test for valid EmployeeNo. If the EmployeeNo is not valid, I do the following:
RAISERROR(5005, 10, 1, N'Invalid Employee No')
return @@Error
Back in VB.Net I test the sql exception and found that when the Employee No is invalid the error.number is not 5005 as I would expect, but 2732.
What is the explanation for this?
Thank you.
I'm using a raw query and i'm having trouble finding out how to get the number of results it returns. Is there a way?
edit
.count() doesnt work. it returns: 'RawQuerySet' object has no attribute 'count'
Hi all,
I'm beginner in Flash CS4 and I'd like to know how to increase the number of image per second of my sequence because I want more smooth morphing. The time will not change.
Actually, I have 24 image per second and I'd like to put 48. Is there a way to make it automatically without changing all by hand.
Thanks
I have two fields, 'from_date' and 'to_date' on my rails form. When a user enters the dates I have to display the number of working days i.e, exclude (sat, sun and a list of other official holidays in a database table).
Is this something that should be done in the client side javascript
Or is this something that should be done by making an ajax request to rails.
Can you tell me how I can accomplish this.
thanks much.
hey guys this is my 1st android app(learning), so i want to call a number given in the textbox but i'm getting error as "The application 'xyz'(process com.adroid) has stoped unexpectedly".. following the code i have done so far... where m doing wrong ??
EditText txtPhn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button callButton = (Button)findViewById(R.id.btnCall);
txtPhn = (EditText)findViewById(R.id.txtPhnNumber);
callButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+txtPhn.getText().toString()));
startActivity(callIntent);
} catch (ActivityNotFoundException activityException) {
Log.e("Calling a Phone Number", "Call failed", activityException);
}
}
});
}
EDITED LogCat
03-09 11:23:25.874: ERROR/AndroidRuntime(370): FATAL EXCEPTION: main
03-09 11:23:25.874: ERROR/AndroidRuntime(370): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxx-xxx-xxxx flg=0x10000000 cmp=com.android.phone/.OutgoingCallBroadcaster } from ProcessRecord{40738d70 370:org.krish.android/10034} (pid=370, uid=10034) requires android.permission.CALL_PHONE
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at android.os.Parcel.readException(Parcel.java:1322)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at android.os.Parcel.readException(Parcel.java:1276)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1351)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1374)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at android.app.Activity.startActivityForResult(Activity.java:2827)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at android.app.Activity.startActivity(Activity.java:2933)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at org.krish.android.caller$1.onClick(caller.java:29)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at android.view.View.performClick(View.java:2485)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at android.view.View$PerformClick.run(View.java:9080)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at android.os.Handler.handleCallback(Handler.java:587)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at android.os.Handler.dispatchMessage(Handler.java:92)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at android.os.Looper.loop(Looper.java:123)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at android.app.ActivityThread.main(ActivityThread.java:3683)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at java.lang.reflect.Method.invokeNative(Native Method)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at java.lang.reflect.Method.invoke(Method.java:507)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
03-09 11:23:25.874: ERROR/AndroidRuntime(370): at dalvik.system.NativeStart.main(Native Method)
Greetings,
I need to implement a jquery based validation for a text field that contains a phone number, for that I need the regular expression of these two strings, I am requesting this because I am very naive with RegEx:
First One:
0(5NN) NNN NN NN
Second One:
0(53N) NNN NN NN
N means an integer between 0-9
I would like to use a GroupTemplate to separate a list of items into groups. However, I need each Group to be numbered sequentially so I can link to them and implement some JS paging. I'm binding to an IEnumerable
Here's some pseudo code. I would like the output to look like this:
<a href="#group1">Go to Group 1<a>
<a href="#group2">Go to Group 2<a>
<a href="#group3">Go to Group 3<a>
<ul id="group1">
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ul>
<ul id="group2">
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ul>
<ul id="group3">
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ul>
Is this easy to do in a ListView, using GroupTemplate and ItemTemplate?
<asp:ListView ID="lv" runat="server" GroupPlaceholderID="groupPlaceholder">
<LayoutTemplate>
<asp:PlaceHolder ID="groupPlaceholder" runat="server"></asp:PlaceHolder>
</LayoutTemplate>
<GroupTemplate>
<ul id="<!-- group-n goes here -->">
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
</ul>
</GroupTemplate>
<ItemTemplate>
<li>Item</li>
</ItemTemplate>
</asp:ListView>
I can get the number of groups to do the links at the top from the Datasource and basic math, but how do I get id="groupN" number into the template?
Hey everyone. This question is about the number 169716931325235658326303.
According to http://www.alpertron.com.ar/ECM.HTM it is prime.
According to my miller-rabin implementation in python with 7 repetitions is is composite. With 50 repetitions it is still composite. With 5000 repetitions it is STILL composite.
I thought, this might be a problem of my implementation. So I tried GNU MP bignum library, which has a miller-rabin primality test built-in. I tested with 1000000 repetitions. Still composite.
This is my implementation of the miller-rabin primality test:
def isprime(n, precision=7):
if n == 1 or n % 2 == 0:
return False
elif n < 1:
raise ValueError("Out of bounds, first argument must be > 0")
d = n - 1
s = 0
while d % 2 == 0:
d //= 2
s += 1
for repeat in range(precision):
a = random.randrange(2, n - 2)
x = pow(a, d, n)
if x == 1 or x == n - 1: continue
for r in range(s - 1):
x = pow(x, 2, n)
if x == 1: return False
if x == n - 1: break
else: return False
return True
And the code for the GMP test:
#include <gmp.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
mpz_t test;
mpz_init_set_str(test, "169716931325235658326303", 10);
printf("%d\n", mpz_probab_prime_p(test, 1000000));
mpz_clear(test);
return 0;
}
As far as I know there are no "exceptions" (which return false positives for any amount of repetitions) to the miller-rabin primality test. Have I stumpled upon one? Is my computer broken? Is the Elliptic Curve Method wrong? What is happening here?
EDIT
I found the issue, which is http://www.alpertron.com.ar/ECM.HTM. I trusted this applet, I'll contact the author his applet's implementation of the ECM is faulty for this number. Thanks.
EDIT2
Hah, the shame! In the end it was something that went wrong with copy/pasting on my side. NOR the applet NOR the miller-rabin algorithm NOR my implementation NOR gmp's implementation of it is wrong, the only thing that's wrong is me. I'm sorry.
Is there an actual package in CPAN to convert such string:
my $string = "54.4M"
my $string2 = "3.2G"
into the actual number in bytes:
54,400,000
3,200,000,000
And vice versa.
Hi,
I wanted to know if there is any limit on the number of arguments that are set to kernel function in OpenCL. I am getting the error as INVALID_ARG_INDEX while setting arguments. I am setting 9 arguments in the kernel function. Please help me in this regard.
Thanks,
Rakesh.
Hi guys,
I'm struggling with getting the result OUT variable from a MySQL stored procedure. I get the following error:
java.sql.SQLException: Parameter number 3 is not an OUT parameter
The stored procedure looks like this:
CREATE DEFINER=`cv_admin`@`localhost` PROCEDURE `CheckGameEligibility`(
IN gID INT(10),
IN uID INT(10),
OUT result TINYINT(1)
)
BEGIN
# Do lots of stuff, then eventually:
SET result = 1;
END
My java function takes an array of strings* and creates the CallableStatement object dynamically:
public static int callAndReturnResult( String sql , String[] values )
{
int out = 0 ;
try
{
// construct the SQL. Creates: CheckGameEligibility(?, ?, ?)
sql += "(" ;
for( int i = 0 ; i < values.length ; i++ )
{
sql += "?, " ;
}
sql += "?)" ;
System.out.println( "callAndReturnResult("+sql+"): constructed SQL: " + sql );
// Then the statement
CallableStatement cstmt = DB.prepareCall( sql );
for( int i = 0 ; i < values.length ; i++ )
{
System.out.println( " " + (i+1) + ": " + values[ i ] ) ;
cstmt.setString(i+1, values[ i ] );
}
System.out.println( " " + (values.length+1) + ": ? (OUT)" ) ;
cstmt.registerOutParameter( values.length + 1 , Types.TINYINT );
cstmt.execute();
out = cstmt.getInt( values.length );
cstmt.close();
}
catch( Exception e )
{
System.out.println( "*** db trouble: callAndReturnResult(" + sql + " failed: " + e );
e.printStackTrace() ;
}
return out ;
}
*) I suppose I should be using an int array instead of a string array, but it doesn't seem to be what the error message was about.
Anyway, here's the output it generates:
callAndReturnResult(CheckGameEligibility(?, ?, ?)): constructed SQL: CheckGameEligibility(?, ?, ?)
1: 57
2: 29
3: ? (OUT)
*** db trouble: callAndReturnResult(CheckGameEligibility(?, ?, ?) failed: java.sql.SQLException: Parameter number 3 is not an OUT parameter
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
at com.mysql.jdbc.CallableStatement.checkIsOutputParam(CallableStatement.java:692)
at com.mysql.jdbc.CallableStatement.registerOutParameter(CallableStatement.java:1847)
at org.apache.commons.dbcp.DelegatingCallableStatement.registerOutParameter(DelegatingCallabl>eStatement.java:92)
at Tools.callAndReturnResult(Tools.java:156)
Any ideas what might be the problem? :)
Thanks in advance!
I have an XMLList 'Keywords', which consists of about 30 XML items. I want to count the number of unique keywords in the List, and how often they occur. Then display the top 3 most occuring keywords.
There's probably a simple sorting/count function to carry this out, however, i'm quite new to as3 so please forgive my naivety.
Cheers.
Is there a way to restrict the number
of characters in the Flex Rich Text Editor?
I guess there should be, since it's possible
in a textarea. So, if I could get hold
of the textarea contained in the rich
text editor, I would be able to do it
How is it better to encode a complex number into RGB pixel and vice versa?
Probably (logarithm of) an absolute value goes to brightness and an argument goes to hue.
Desaturated pixes should receive randomized argument in reverse transformation.
Something like:
0 - (0,0,0)
1 - (255,0,0)
-1 - (0,255,255)
0.5 - (128,0,0)
i - (255,255,0)
-i - (255,0,255)
(0,0,0) - 0
(255,255,255) - e^(i * random)
(128,128,128) - 0.5 * e^(i *random)
(0,128,128) - -0.5
Are there ready-made formulas for that?
Is there a way to use unix date to print the number of seconds since epoch?
I'm open to using other standard shell commands if there is a way
(I'm using Solaris, so there isn't date "+"%s")
Thanks
Hi!
Is there a straightforward way of determining the number of decimal places in a(n) integer/double value in PHP? (that is, without using explode)
Thanks,
Erwin
Hi,
I do have two buttons
'btnPrev' and 'btnNext'
What I want to do is to be able to determine the number of clicks of the button so that I could enable and disable them. The process is almost similar to 'paging' method.
Initial state: btnPrev - disabled, btnNext - enabled
1st Click (btnNext): btnPrev - enabled, btnNext - enabled
2nd Click (btnNext): btnPrev - enabled, btnNext - enabled
3rd Click (btnNext): btnPrev - enabled, btnNext - disabled
the idea is almost the same vice-versa (for btnPrev)
any suggestions how to do it?
I'm using a jQuery plugin called InfiniteScroll (https://github.com/paulirish/infinite-scroll) and I have a URL with this pattern: '/category/2/', when I paged the result I use the following pattern: "/category/2?page=2".
When Infinite Scroll makes de request, he increments the wrong number, in the case above, the request is: "/category/3?page=2" in place of "/category/2?page=3".
Anyone knows how workaround this?
My JSON looks like this:
{
"[email protected]":"Person1",
"[email protected]":"Person65",
"[email protected]":"Person24"
}
It's returned in various number of elements, and various keys. How do I traverse the data if my code is like this:
$.post("includes/ajax.php", {
group_id : $('#group').val()
}, function(data) {
//how do i traverse data here?
}, "json");
Any help will be appreciated :)
Thanks!
In the following short program:
use Template;
my $template = Template->new (INCLUDE_PATH => ".");
$template->process ("non-existent-file")
or die $template->error ();
why does "die" not produce a line number and newline? Output looks like this:
$ perl template.pl
file error - non-existent-file: not found ~ 503 $