Hey all. Newbie JavaScript question here. I have an array: {r=1, g=4, b=6} How do i go about getting the value of each (r,g,b) into a separate variable?
In Python I have a list of n lists, each with a variable number of elements. How can I create a single list containing all the possible permutations:
For example
[ [ a, b, c], [d], [e, f] ]
I want
[ [a, d, e] , [a, d, f], [b, d, e], [b, d, f], [c, d, e], [c, d, f] ]
Note I don't know n in advance. I thought itertools.product would be the right approach but it requires me to know the number of arguments in advance
Is there a way to make emacs pull autocompletions of ruby methods the way Eclipse and NetBeans do? That is if I type File. and press CTRL-space in Eclipse I will get a list of File methods. Same with variables. I have installed autocomplete plugin, ruby-mode, rinari and cedet, but so far it will complete local variable and method names, but will not native ones.
One of my friends sent this code to me, saying it doesn't work as expected:
#include<stdio.h>
void main()
{
int a [10] ={23, 100, 20, 30, 25, 45, 40, 55, 43, 42};
int sizeOfInput = sizeof(a)/sizeof(int);
int b, outer, inner, c;
printf("Size is : %d \n", sizeOfInput);
printf("Values before bubble sort are : \n");
for ( b = 0; b < sizeOfInput; b++)
printf("%d\n", a[b]);
printf("End of values before bubble sort... \n");
for ( outer = sizeOfInput; outer > 0; outer-- )
{
for ( inner = 0 ; inner < outer ; inner++)
{
printf ( "Comparing positions: %d and %d\n",inner,inner+1);
if ( a[inner] > a[inner + 1] )
{
int tmp = a[inner];
a[inner] = a [inner+1];
a[inner+1] = tmp;
}
}
printf ( "Bubble sort total array size after inner loop is %d :\n",sizeOfInput);
printf ( "Bubble sort sizeOfInput after inner loop is %d :\n",sizeOfInput);
}
printf ( "Bubble sort total array size at the end is %d :\n",sizeOfInput);
for ( c = 0 ; c < sizeOfInput; c++)
printf("Element: %d\n", a[c]);
}
I am using Micosoft Visual Studio Command Line Tool for compiling this on a Windows XP machine.
cl /EHsc bubblesort01.c
My friend gets the correct output on a dinosaur machine (code is compiled using TCC there).
My output is unexpected. The array mysteriously grows in size, in between.
If you change the code so that the variable sizeOfInput is changed to sizeOfInputt, it gives the expected results!
A search done at Microsoft Visual C++ Developer Center doesn't give any results for "sizeOfInput".
I am not a C/C++ expert, and am curious to find out why this happens - any C/C++ experts who can "shed some light" on this?
Unrelated note: I seriously thought of rewriting the whole code to use quicksort or merge sort before posting it here. But, after all, it is not Stooge sort...
Edit: I know the code is not correct (it reads beyond the last element), but I am curious why the variable name makes a difference.
Please tell me what is difference
== if i write query directly in storedprocedure
== and write query in string variable and than run it in exec in stored procedure.
i am using ms sql server 2005
Hi
I have an app that creates a variable number of ScatterviewItems based on which tagged object is placed on the surface table.
The ScatterViewItems are added programatically to the ScatterView based on info looked up in a DB
The Scatterview does a good job of displaying this info
However, I would like them to be
evenly distributed across the table and
not have any items overlapping
Any ideas how to do that?
How can i fetch column names from a tale on index basis, like i want to make a tables whose column name should be the name of last column fields of a result set of a query, but those result sets last columns value may be different at different execution time, so i want to know how can i fetch those index value of that last column to make a temp table with column name of those last columns value of a result set.
Is there any way/function in sql server to dynamically form that?
Worrying about duplicates but can not seem to find and answer I can understand in any of the other posts, I just have to ask:
When I have in my .h:
@interface SecondViewController : UIViewController{
NSString *changeName;
}
@property (readwrite, retain) NSString *changeName;
then in my .m
@synthesize changeName;
-(IBAction)changeButton:(id)sender{
changeName = @"changed";
}
Is it the synthesized property or the instance variable that get changed when I press "changeButton" ?
Could really use with some help here...
I've got a servlet that generates an XML string (relatively long) which I then pass to a javascript variable in a forwarded jsp file:
$(document).ready(function() {
...
var itXML = <% out.print((String)request.getAttribute("xml"));% ;
...
}
This seems to work just fine in Firefox but when I run the same project on IE8 I get a syntax error for this line.
Any Ideas?
Thanks!
So, as I get comfortable with Cocoa/Cocoa-Touch I, like others can't help but notice the rather verbose method names.
What is the absolutely longest method in Cocoa-Touch that you have come across?
To kick things off, I submit that perennial favorite from UITableViewController -
tableView:accessoryButtonTappedForRowWithIndexPath:
Cheers,
Doug
Hi,
I want to send the following JSON text {"Email":"[email protected]","Password":"123456"} to a web service and read the response. I know to how to read JSON. The problem is that the above jason object must be sent in a variable name jason. How can i do this from android? Like creating a request object setting content headers etc.
Hi, i need to check the type of a variable in javascript, i know 3 ways to do it:
instanceof operator: if(a instanceof Function)
typeof operator: if(typeof a=="function"
toString method (jQuery uses this): Object.prototype.toString.call(a) == "[object Function]"
Which is the most accurate way to do type checking beetween these solutions? and why? Please don't tell me that the last solution is better only because jQuery uses that.
Hello,
I have a db.BlobProperty property (called "Icon") in my entity which contains an image binary. I want to run a GQL query to retrieve all entities with an image (i.e. their "Icon" property is not NULL).
Trying to use the following query:
"SELECT * FROM Names WHERE Icon!=NULL"
did not work... Trying to use .filter("Icon!=",None) did not work as well...
Any ideas?
Thanks!
Joel
I have a form page in PHP that reads a DBF, and conditionally converts it into a MySQL - extracting the data from an old, but still production accounting app. The conversion should be able to be actioned without user intervention, ie scripted from the web-host's command line on a cron job.
How can I get PHP to submit the form automatically when receiving variables at command line, like for instance a specific post variable? Every auto-submit I've found so far relied upon javascript, which would be useless at PHP command line.
Please help me with writing a sql query - I have a table with id, name and marks columns.
If I arrange the table in ascending order of marks, how can I fetch 5 names whose marks are close to a particular name.
Hey,
I have this mysql tables I want to display with jqgrid. The problem appears when I want to display a parametrized query.
For example lets say I want to display all students older than 21. I have this variable named age which I want to pass to server.php file where I can construct the XML or JSON.
On server I see some variables like $examp = $_REQUEST["q"]; but I dont know where to put $age to be accesed in server.php
Thanks
I would like Qt Creator to build the project according to the type I specify in the little computer button.
Using:
CONFIG(debug, debug|release)
{
DESTDIR = Debug
OBJECTS_DIR = Debug/.obj
MOC_DIR = Debug/.moc
RCC_DIR = Debug/.rcc
UI_DIR = Debug/.ui
}
CONFIG(release, debug|release)
{
DESTDIR = Release
OBJECTS_DIR = Release/.obj
MOC_DIR = Release/.moc
RCC_DIR = Release/.rcc
UI_DIR = Release/.ui
}
Or, using the answer from here, makes qmake chose the last time a variable was defined.
How do I set it?
Thnx
P.S I don't know if it has something to do with my problem, but I'm using Ubuntu and not Windows
I would like to assign a value in a class property dynamically (that is referring to it using a variable).
#Something like:
setPropValue($obj, $propName, $value);
This probably an easy thing to do but for some reason I can't get a handle on it.
I have a simple form that allows people to select one if three items for sale. When they chose their item I need to pass that variable into an iFrame with a third party checkout page to safely process their cc transaction.
How would I do this?
Cheers-
I wonder if syntax as follows would be helpful in your opinion as a code readability improvent and self-commenting of code:
std::map<std::string name, std::vector<int> scores> myMap;
In this example it clearly says and no other comment is needed, what for we are using myMap variable.
Looking forward to your opinions.
Hi all,
I have been writhing a rather large document with latex.
Now I would like to list all the figures / tables / algortihms once again at the end of the file so that I can check if they all look the same.
For example, if every algorithm has the same notation.
How can I do this?
I know about \listofalgorithms and \listoffigures but they only list the names of the algorithms or figures and the pages where they are.
Thanks.
I'm trying to check if a window has a certain style using GetWindowLong(hWnd, GWL_STYLE) but that gives me a LONG type of variable. how would you check for a specific style from that?
I have a formula which is working; the formula uses an array. I tried to extract the formula to create a custom formula but now get an error in the syntax.
I am wondering if the array is causing the problem as the error is on the line:
last_element_current:=val(sc_array[1]) + 1;
and the error is: the ) is missing and highlights the variable sc_array before the index [1].