I have a variable a = 1.
I want to generate a variable name of the form:
variableNumber
so in this example, I would want
a1
a2
a3
as variables.
How can I do that?
I recently read the source code of couch-db, I find this type definition which i don't understand:
-type branch() :: {Key::term(), Value::term(), Tree::term()}.
-type path() :: {Start::pos_integer(), branch()}.
-type tree() :: [branch()].
I did read Erlang doc, But what is the meaning of Start, Key, Value and Tree? From what i understand, they are Erlang variables! I didn't find any information about this in Erlang doc.
I am using SQL server and ODBC in visual c++ for writing to the database. Currently i am using parameter binding in SQL queries ( as i fill the database with only 5 - 6 queries and same is true for retrieving data). I dont know much about stored procedures and I am wondering how much if any performance increase stored procedures have over parameter binding as in parameter binding we prepare the query only once and just execute it later in the program for diferent set of values of variables.
I am playing around with PHPFog and as a result I ended up with a MySql database. I am trying to figure out how to connect to it with a success message.
PHPFog says use this:
mysql_connect(
$server = getenv('MYSQL_DB_HOST'),
$username = getenv('MYSQL_USERNAME'),
$password = getenv('MYSQL_PASSWORD'));
mysql_select_db(getenv('MYSQL_DB_NAME'));
So I basically plug my variables into the above? Or Do I do something different?
Thanks,
Jim
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?
Using the standard VS IDE, is there a fast way to create class properties that are linked to the local variables?
The class diagram seems to provide something, but it basically just created a property stub. Is there something better / easier out there ?
Simply I need to write
"echo" t${count} = "$"t${count}"
To a text file, including all the So the output would be something like:
echo " t1 = $t1"
With " as they are. So I have tried:
count=1
saveIFS="$IFS"
IFS=$'\n'
array=($(<TEST.txt))
IFS="$saveIFS"
for i in "${array[@]}"
do
echo "echo" t${count} = "$"t${count}""
(( count++ ))
done >> long1.txt
And variations on this such as:
echo "echo" """"" t${count} = "$"t${count}""
But I guess the wrapping in double " is only for variables.
Ideas?
In my windows installation PATH includes C:\Program Files\nodejs, where executable node.exe is. I'm able to launch node from the shell, as well as npm. I'd like new executables to be installed in C:\Program Files\nodejs as well, but it seems impossible to achieve.
Setting NODE_PATH and NODE_MODULES variables doesn't change anything: things are still installed in %appdata%\npm by default.
How can I change the global installation path?
If I have 5 String variables and between 0 and 5 of them are null or empty is there an easy/short way of returning the first one that is not null or empty? I am using .NET 3.5
I've been playing around to see how my computer works under the hood. What I'm interested in is seeing is what happens on the stack inside a function. To do this I've written the following toy program:
#include <stdio.h>
void __cdecl Test1(char a, unsigned long long b, char c)
{
char c1;
unsigned long long b1;
char a1;
c1 = 'b';
b1 = 4;
a1 = 'r';
printf("%d %d - %d - %d %d Total: %d\n",
(long)&b1 - (long)&a1, (long)&c1 - (long)&b1,
(long)&a - (long)&c1,
(long)&b - (long)&a, (long)&c - (long)&b,
(long)&c - (long)&a1
);
};
struct TestStruct
{
char a;
unsigned long long b;
char c;
};
void __cdecl Test2(char a, unsigned long long b, char c)
{
TestStruct locals;
locals.a = 'b';
locals.b = 4;
locals.c = 'r';
printf("%d %d - %d - %d %d Total: %d\n",
(long)&locals.b - (long)&locals.a, (long)&locals.c - (long)&locals.b,
(long)&a - (long)&locals.c,
(long)&b - (long)&a, (long)&c - (long)&b,
(long)&c - (long)&locals.a
);
};
int main()
{
Test1('f', 0, 'o');
Test2('f', 0, 'o');
return 0;
}
And this spits out the following:
9 19 - 13 - 4 8 Total: 53
8 8 - 24 - 4 8 Total: 52
The function args are well behaved but as the calling convention is specified, I'd expect this. But the local variables are a bit wonky. My question is, why wouldn't these be the same? The second call seems to produce a more compact and better aligned stack.
Looking at the ASM is unenlightening (at least to me), as the variable addresses are still aliased there. So I guess this is really a question about the assembler itself allocates the stack to local variables.
I realise that any specific answer is likely to be platform specific. I'm more interested in a general explanation unless this quirk really is platform specific. For the record though, I'm compiling with VS2010 on a 64bit Intel machine.
Today I had an epiphany, and it was that I was doing everything wrong. Some history: I inherited a C# application, which was really just a collection of static methods, a completely procedural mess of C# code. I refactored this the best I knew at the time, bringing in lots of post-college OOP knowledge. To make a long story short, many of the entities in code have turned out to be Singletons.
Today I realized I needed 3 new classes, which would each follow the same Singleton pattern to match the rest of the software. If I keep tumbling down this slippery slope, eventually every class in my application will be Singleton, which will really be no logically different from the original group of static methods.
I need help on rethinking this. I know about Dependency Injection, and that would generally be the strategy to use in breaking the Singleton curse. However, I have a few specific questions related to this refactoring, and all about best practices for doing so.
How acceptable is the use of static variables to encapsulate configuration information? I have a brain block on using static, and I think it is due to an early OO class in college where the professor said static was bad. But, should I have to reconfigure the class every time I access it? When accessing hardware, is it ok to leave a static pointer to the addresses and variables needed, or should I continually perform Open() and Close() operations?
Right now I have a single method acting as the controller. Specifically, I continually poll several external instruments (via hardware drivers) for data. Should this type of controller be the way to go, or should I spawn separate threads for each instrument at the program's startup? If the latter, how do I make this object oriented? Should I create classes called InstrumentAListener and InstrumentBListener? Or is there some standard way to approach this?
Is there a better way to do global configuration? Right now I simply have Configuration.Instance.Foo sprinkled liberally throughout the code. Almost every class uses it, so perhaps keeping it as a Singleton makes sense. Any thoughts?
A lot of my classes are things like SerialPortWriter or DataFileWriter, which must sit around waiting for this data to stream in. Since they are active the entire time, how should I arrange these in order to listen for the events generated when data comes in?
Any other resources, books, or comments about how to get away from Singletons and other pattern overuse would be helpful.
I've been wondering if using long descriptive variable names in WinForms C# matters for performance? I'm asking this question since in AutoIt v3 (interpreted language) it was brought up that having variables with short names like aa instead of veryLongVariableName is much much faster (when program is bigger then 5 liner). I'm wondering if it's the same in C#?
UISomeController *controller = [[UISomeController alloc] initWithNibName:@"UISomeController" bundle:nil];
[self.navigationController pushViewController:controller animated:YES];
Is it possible to initialize some variables in the controller at the creation time? And how to do that?
I was wondering if there is any library that can be used to represent SQL queries as objects in Java.
In the code I have plenty of static variables of type java.lang.String that are hand written SQL queries. I would be looking for library having a nice fluent API that allows me to represent the queries as objects rather than strings.
Example:
Query q = select("DATE", "QUOTE")
.from("STOCKMARKET")
.where(eq("CORP", "?"))
.orderBy("DATE", DESC);
i have this querystring that shall open up my page.
http://www.a1-one.com/[email protected]&stuid=123456
Now when this page loads, on page_load, I want to pick up email and stuid in two different variables. So I can use them to insert into my database (sql server)
how can this be done in vb.net
i downloaded the "phantomjs-1.7.0-windows.zip " for windows from the following url:
http://phantomjs.org/download.html.
i even set up the path of the extracted folder in the environment variables.But i am getting the "parse error" when i try to enter any command like "phantomjs --version" in the phantomjs.exe command prompt.
my windows is 64 bit . I am not getting the reason y it is throwing the error.could u please suggest me what the problem would be with ??
instead of User.
def myview(request):
return render_to_response('tmpl.html', {'user': User.objects.get(id=1})
works fine and passes User to template.
But
def myview(request):
return render_to_response('tmpl.html', {}, context_instance=RequestContext(request))
with a context processor
def user(request):
from django.contrib.auth.models import User
return {'user': User.objects.get(id=1)}
passes AnonymousUser, so I can't get the variables I need :(
What's wrong?
Hello. Currently I have a very basic file viewer working as follows :
- in JOptionPane I browse for files, and set some variables to display (colors, line connecting etc)
- previous windows loads a frame with drawn points
Code :
http://paste.pocoo.org/show/220066/
Now I'd like to throw it into one window, with JMenu for selecting files and changing display parameters. How to get started ? Should I rewrite everything to JDialog ?
Why is still C99 mixed declarations and code not used in open source C projects like the Linux kernel or GNOME?
I really like mixed declarations and code since it makes the code more readable and prevents hard to see bugs by restricting the scope of the variables to the narrowest possible. This is recommended by Google for C++.
For example, Linux requires at least GCC 3.2 and GCC 3.1 has support for C99 mixed declarations and code
int a = 1, b;
if(a > 0) b = 1;
if(a <= 0) b = 2;
System.out.println(b);
If I run this, I receive:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The local variable b may not have been initialized
at Broom.main(Broom.java:9)
I know that the local variables are not initialized and is your duty to do this, but in this case, the first if doesn't initialize the variable?
Hi.
I need the remote client name (aka computer name) to save it into a database, I was looking into $_SERVER variables but it doesn't exist. How can I get this just using another PHP's function or even javascript if it is necessary.
If I use OnError event handler in my SSIS package, there are variables System::ErrorCode and System::ErrorDescription from which I can get the error information if any things fails while execution.
But I cant the find the same for OnTaskFailed event handler, i.e. How to get the ErrorCode and ErrorDescription from the OnTaskFailed event handler when any things fails while execution in case we want to only implement OnTaskFailed event handler for our package?
(x-y)^2+(y-z)^2+(z-x)^2=2*r^2
Like in the above,only x,y,z are variables,how to show the graph in a general way that will also work for those doesn't have explicit form?
Using python and wsgiref.handlers, I can get a single variable from a form with self.handler.request.get(var_name), but how do I iterate through all form variables, be they from GET and POST? Is it something like this?
for field in self.handler.request.fields:
value = self.handler.request.get(field)
Again, it should include both fields included in the POST and fields from the query string, as in a GET request.
Thanks in advance folks...