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'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)}"
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
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?
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'"
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
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!
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;
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);
}
}
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.
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!
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.
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;
}
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?
Hi,
When creating a branch, what are the implications of selecting the following?
Create copy in the repository from:
HEAD revision in the repository
Specific revision the repository
Working copy
I just read a few threads on the discussion of singleton design in javascript. I'm 100% new to the Design Pattern stuff but as I see since a Singleton by definition won't have the need to be instantiated, conceptually if it's not to be instantiated, in my opinion it doesn't have to be treated like conventional objects which are created from a blueprint(classes). So my wonder is why not just think of a singleton just as something statically available that is wrapped in some sort of scope and that should be all.
From the threads I saw, most of them make a singleton though traditional javascript
new function(){}
followed by making a pseudo constructor.
Well I just think an object literal is enough enough:
var singleton = {
dothis: function(){},
dothat: function(){}
}
right? Or anybody got better insights?
[update] : Again my point is why don't people just use a simpler way to make singletons in javascript as I showed in the second snippet, if there's an absolute reason please tell me. I'm usually afraid of this kind of situation that I simplify things to much :D
Hello everyone, well I'm new here and I really need some help.. I want to create a table and this table's name will be inserted from a textfield. However when I run the query it's giving me an error, any help on this one? Ill paste the code here:
public boolean CreateTable() {
TableNumber=jTextField4.getText();
try {
String password = null;
String s = "CREATE TABLE '"+TableNumber+'" (Item char(50),Price char(50))";
ConnectionForOrders();
stmt = conn.createStatement();
stmt.executeUpdate(s);
boolean f=false;
ConnectionForOrdersclose();
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; }
}
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?
I have read most of the posts on here regarding floating point, and I understand the basic underlying issue that using IEEE 754 (and just by the nature of storing numbers in binary) certain fractions cannot be represented. I am trying to figure out the following: If both Python and JavaScript use the IEEE 754 standard, why is it that executing the following in Python
.1 + .1
Results in
0.20000000000000001 (which is to be expected)
Where as in Javascript (in at least Chrome and Firefox) the answer is .2
However performing
.1 + .2
In both languages results in
0.30000000000000004
In addition, executing
var a = 0.3; in JavaScript and printing a results in
0.3
Where as doing a = 0.3 in Python results in 0.29999999999999999
I would like to understand the reason for this difference in behavior.
In addition, many of the posts on OS link to a JavaScript port of Java's BigDecimal, but the link is dead. Does anyone have a copy?
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?
Hi everyone...
I'm doing some research on Simple Look Up Tables.
I have :
been thru wikipedia.
Googled Look-up tables
Browsed thedailywtf.com
Been thru several websites illustrating/documenting look-up table code.
Currently i am looking for any insight anyone can throw on the topic (LuTs).
Also, I am specifically looking for any anecdotes one would like to share (again on LuTs).
All content will be adequately acknowledge (or anonymised, if requested) in the article.
Thank You
Why does only the second example append the extension to the filename and what is the "/r" in ".csv/r" for.
#!/usr/bin/env perl
use warnings; use strict;
use 5.012;
use DBI;
my $dbh = DBI->connect( "DBI:CSV:f_dir=/home/mm", { RaiseError => 1, f_ext => ".csv/r"} );
my $table = 'new_1';
$dbh->do( "DROP TABLE IF EXISTS $table" );
$dbh->do( "CREATE TABLE $table ( id INT, name CHAR, city CHAR )" );
my $sth_new = $dbh->prepare( "INSERT INTO $table( id, name, city ) VALUES ( ?, ?, ?, )" );
$sth_new->execute( 1, 'Smith', 'Greenville' );
$dbh->disconnect();
# --------------------------------------------------------
$dbh = DBI->connect( "DBI:CSV:f_dir=/home/mm", { RaiseError => 1 } );
$dbh->{f_ext} = ".csv/r";
$table = 'new_2';
$dbh->do( "DROP TABLE IF EXISTS $table" );
$dbh->do( "CREATE TABLE $table ( id INT, name CHAR, city CHAR )" );
$sth_new = $dbh->prepare( "INSERT INTO $table( id, name, city ) VALUES ( ?, ?, ?, )" );
$sth_new->execute( 1, 'Smith', 'Greenville' );
$dbh->disconnect();