I am working in flex and I am just setting a variable to false. It doesnt do anything in the program but everything breaks when I put this line of code in:
somevar = false;
Does anyone know why?
Hi guys,
I am having a string which contains more the 25 characters;
NSString *str = @"This is the string to be truncated to 15 characters only";
In the above string I need only the 15 characters to be stored in another variable after truncation.
can anyone suggest me how to do this?
Anyone's help will be much appreciated.
Thank you,
Monish
I'm writing a page that does very simple search queries, resulting in something like:
SELECT * FROM my_table WHERE A in (a1, a2, a3) AND B in (b1, b2) AND C in (c1, c2, c3, c4) AND
And so on for a variable number of columns, usually ~5. If I create a separate index for each column (one for A, one for B, one for C, not (A,B,C)), will all of them be used in the above query?
DatarowsForOneDay = dt.Select(
dt.Columns[0].Caption + "='" + x.ToString("dd/MM/yyyy HH") + "'");
doesn't work, but
DatarowsForOneDay = dt.Select(
dt.Columns[0].Caption + "='" + x.ToString("dd/MM/yyyy") + "'");
works.
So how can I select the date with a same hour?
Variable x type is DateTime.
We have server on Python and client + web service on Ruby. That works only if file from URL is less than 800 k. It seems like "socket.puts data" in a client works, but "output = socket.gets" - not. I think problem is in a Python part. For big files tests run "Connection reset by peer". Is it buffer size variable by default somewhere in a Python?
Lets say I have a variable that will always be a string.
Now take the code below:
if($myVar === "teststring")
Note $myVar will always be a string, so my questions is
Which is quicker/best, using === (Indentity) or the == (Equality)?
I have a Range variable that contains an address - $2:$2,$4:$205,$214:$214 - (3 groups of rows).
I would like to get the count of all the rows in that range.
However, range.Count gives me the count of all the cells (50,000~) and range.Rows.Count only return 1 - the count of all the rows in the first group. How do I get the count of all the rows
Thanks
I am using JPA and I need to make the "tableName" a variable.
In a database, I have many tables, and my code needs to access the table where I specify it to read.
@Entity
@Table(name = "tableName")
public class Database implements Serializable {...............}
Any ideas?
Hello!
I want to enable debug (DEBUG = True) For my Django project only if it runs on localhost. How can I get user IP address inside settings.py? I would like something like this to work:
#Debugging only on localhost
if user_ip = '127.0.0.1':
DEBUG = True
else:
DEBUG = False
How do I put user IP address in user_ip variable inside settings.py file?
I guess, DAO is thread safe, does not use any class members.
So can it be used without any problem as a private field of a Servlet ? We need only one copy, and
multiple threads can access it simultaneously, so why bother creating a local variable, right?
Does this mean that it will be looking for index.php and provide the GET variable y with /home/xxx/public_html/control/&x=shell?
http://www.xxx.com/control/?y=/home/xxx/public_html/control/&x=shell
Long story: Website got defaced, and found this b374k script when browsing to one of the page, I am trying to figure out where exactly they injected this script, thus trying to figure out a hint from this url where the scripts resides in.
use sed to replace every occurrence of /dir with $dir (replace / with $) in every script in a directory.
sed "s#/dir#$dir#g"
The $ keeps being interpreted as a function or variable call.
Is there a way around this?
thanks
What's the best practice of making a variable that would be accessible by almost all classes in a Grails project? Is there a config file that I can use for storage of that data (i.e. application.properties)?
Thanks.
how pass a parameter to onload function??
<body onLoad="myFunction(<%=myVar%>)">
It crashes.
The parameter is a vb variable defined with Dim
The function is a vbscript function
Urgent HELP
In my code, is there a shorthand that I can use to assign a variable the value of a object's property ONLY if the object isn't null?
string username = SomeUserObject.Username; // fails if null
I know I can do a check like if(SomeUserObject != null) but I think I saw a shorthand for this kind of test.
I tried:
string username = SomeUserObject ?? "" : SomeUserObject.Username;
But that doesn't work.
What's the best way of writing robust code so that a variable can be checked for null and blank.
e.g.
string a;
if((a != null) && (a.Length() > 0))
{
//do some thing with a
}
I can't remember what the method is meant to be for ensuring the scope of a variable in a query is restricted to prevent mysql injection.
where should i put brackets in the following examples?
UPDATE table SET col_1 = '$var', col_2 = '$var2' WHERE col_1 = '$var3'
and
SELECT * FROM table WHERE WHERE col_1 >= '$var1'
(Obviously looking for answers not using PDO!)
I thought about this: Is there a performance difference in these two practices:
Store the return value of a function in a temporary variable than
give that variable as a parameter to another function.
Put the function into the other function.
Specification
Assuming all classes and functions are written correctly.
Case 1.
ClassA a = function1();
ClassB b = function2(a);
function3(b);
Case 2.
function3(function2(function1()));
I know there aren't a big difference with only one run, but supposed that we could run this a lot of times in a loop, I created some tests.
Test
#include <iostream>
#include <ctime>
#include <math.h>
using namespace std;
int main()
{
clock_t start = clock();
clock_t ends = clock();
// Case 1.
start = clock();
for (int i=0; i<10000000; i++)
{
double a = cos(1);
double b = pow(a, 2);
sqrt(b);
}
ends = clock();
cout << (double) (ends - start) / CLOCKS_PER_SEC << endl;
// Case 2.
start = clock();
for (int i=0; i<10000000; i++)
sqrt(pow(cos(1),2));
ends = clock();
cout << (double) (ends - start) / CLOCKS_PER_SEC << endl;
return 0;
}
Results
Case 1 = 6.375
Case 2 = 0.031
Why is the first one is much slower, and if the second one is faster why dont we always write code that way? Anyway does the second pratice has a name?
I also wondered what happens if I create the variables outside the for loop in the first case, but the result was the same. Why?
I'm currently using statement-based replication. After upgrading to MySql 5.1, I'm considering using row-based replication.
After reading the docs it seems that you can change the format of the master on the fly.
Will the slave automatically adapt to whatever type of binary log it is sent?
Do I have to make any changes to the slave or master to get ready for switching or can I simply modify the binlog_format variable on the master?
Should I store the user's ID, name & email address in a session variable or should I query for the user's user's ID, name & email address everytime i need to use it?
I'm looking for a bash function that will shorten long path names to keep my PS1 variable from getting excessively long. Something along the lines of:
/this/is/the/path/to/a/really/long/directory/i/would/like/shortened
might end up as:
/t../i../t../p../to/a/r../l../d../i/w../like/shortened
something that the took the path and a maximum acceptable number of characters to shorten to would be perfect for my .bashrc file.
How do I convert the value of a PHP variable to string? I was looking for something better than concatenating with an empty string:
$myText = $myVar . '';
like the ToString() method in Java or .NET.
I want to use a database which name is stored in a variable. How do I do this?
I first thought this would work but it doesn't:
exec('use '+@db)
That will not change database context
Suggestions anyone?