Is there a simple way to see if the xsd code generating C# code has a particular column? Or if you can reference a variable column? table.getColumn("column") instead of table.column?
I am using rails 2.3.16 ruby 1.8.7
For the following line of code I ma getting error as follows:
Code:
ForeignScheduledItem.find(:all,
:conditions => { :foreign_scheduled_item =>
{ :scheduled_items => { :subscription_id => params[:subscription_id] } } },
:joins => :scheduled_item).each { |i| @subscriptions.push(Subscription.find_by_id(i.subscription_id)) }
Error:
ActiveRecord::StatementInvalid (ActiveRecord::StatementInvalid):
Can u please help in this regard.
Im doing a project where I connect to a webpage using the NSURLConnection to be able to monitor the status codes that are returned (200 OK / 404 ERROR). I would like to send the user to the top url www.domain.com if I recieve 404 as status code and if i recieve as 200 status code I would like to load the page in to a webview. I have seen several implementations of this problem by creating a new request but I feel that it is unnecessary since you already received the html in the first request so i would just like to load that HTML in to the webView.
So i try to use the [webView loadHTMLFromString: baseURL:] but it doesn't always work, I have noticed that when i print the NSString with html in the connectionDidFinnishLoading it sometimes is null and when I monitor these cases by printing the html in didReceiveData a random number of the last packets is NULL (differs between 2-10). It is always the same webpages that doesn't get loaded. If I load them to my webView using [webView loadRequest:myRequest] it always works. My implementation looks like this perhaps someone of you can see what Im doing wrong.
I create my first request with a button click.
-(IBAction)buttonClick:(id)sender
{
NSURL *url = [NSURL URLWithString:@"http://www.domain.com/page2/apa.html"];
NSURLRequest *theRequest = [NSURLRequest requestWithURL:url]
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if( theConnection )
{
webData = [[NSMutableData data] retain];
}
else
{
}
}
Then I monitor the response code in the didReceiveResponse method by casting the request to a NSHTTPURLResponse to be able to access the status codes and then setting a Bool depending on the status code.
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
NSHTTPURLResponse *ne = (NSHTTPURLResponse *)response;
if ([ne statusCode] == 200){
ok = TRUE;
}
[webData setLength: 0];
}
I then check the bools value in connectionDidFinnishLoading. If I log the html NSString I get the source of the webpage so i know that it isn't an empty string.
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *html = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:@"http://www.domain.com/"];
if (ok){
[webView loadHTMLString:html baseURL:url];
ok = FALSE;
}
else{
//Create a new request to www.domain.com
}
}
webData is an instance variable and I load it in didReceiveData like this.
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[webData appendData:data];
}
I was doing some type conversion routines last night for a system I am working on. One of the conversions involves turning string values into their DateTime equivalents.
While doing this, I noticed that the Convert.ToDateTime() method had an overload which accepted a boolean parameter.
First question? Under what circumstances could this ever be useful?
I went a little further and tried to execute the method in QuickWatch. Either way ( true or false ), the routine returns an InvalidCastException.
Second question? Why is this method even here?
At some places in my code, I print debug messages like this:
int ret = getLinkSpeed(device.getSysName(), linkSpeed);
if (ret < 0)
{
logDebug("Failed to obtain port speed for this device. Error: " + std::string(strerror(errno)));
}
From the documentation it is not entirely clear if strerror will return 0 under certain conditions (which would cause my code to crash). Does anyone know if it's safe?
I am generating an excel file through C# code. the cell Data type I'm giving as "" . Once I give Number instead of String The generated Excel could not open.
How can I change the Datatype of the cell which I generated through the Code?
Thanks in Advance.
I just found two piece of code
#if CONSOLE // defined by the console version using
ournamespace.FactoryInitializer;
#endif
and
#if _NET_1_1
log4net.Config.DOMConfigurator.ConfigureAndWatch(new System.IO.FileInfo(s) );
#else
log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(s) );
#endif
Can any one please tell me with a running sample( please provide a simple one) what is the significance of those code snippets and when and how to use those?
Thanks.
some case i write code like these:
a,temp,b = s.partition('-')
i just need to pick the first and 3rd element. temp would never be used. is there a better way to do this?
the common case is ,a better way to pick separted element to make a new list?
for example
i want to make a new list use old list 0,1,3,7 element
code would be this:
newlist = [oldlist[0],oldlist[1],oldlist[3],oldlist[7]]
it's pretty ugly,isn't it?
I would like to know whether it a possible to detect whether a HTML page contains a video.
I know that one possible way is to look for ".swf" in the HTML source code. But most of the pages do not contain the file name.
For example, given following URL and possibly its source code, is it possible to find out whether it contains a video:
http://www.cnn.com/video/
I would like to pass some variables in the constructor of my ListActivity
I start activity via this code:
startActivity(new Intent (this, viewContacts.class));
I would like to use similar code, but to pass two strings to the constructor. How is possible?
I know this is probably a very obvious answer and that I'm exposing myself to less-than-helpful snarky comments, but I don't know the answer so here goes.
If Python compiles to bytecode at runtime, is it just that initial compiling step that takes longer? If that's the case wouldn't that just be a small upfront cost in the code (ie if the code is running over a long period of time, do the differences between C and python diminish?)
This code is being used to parse email, it's stored as a table in a mySQL database. I believe it's PHP code. What does the (.+) do?
/A new order has been successfully placed through(.+)Name:(.+)Company:(.+)Email:(.+)Address 1(.+)Order ID:(.+)Date:(.+)Payment Type:(.+)Order Status:(\s*)Accepted(.*)\n(.+)\$([\d\.]+)\s+X/si
Thanks, super-brainiacs!
Greetings,
The question relates to ASP.NET MVC
I am creating some divs dynamically using AJAX (some views render dynamically). Inside these views a have some JS code. When user click on link i would like to open dialog box with google map. However, because these views are rendered dynamically it does not work because js code is not injected (what can be seen in page source). How can I resolve this problem?
Hi,
I have 2 view (view A and view B).
In viewA when I touch a button I execute this code to flip a viewB:
viewB.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:viewB animated:YES];
And now when I came back to viewA I use this code:
[self dismissModalViewControllerAnimated: YES]; //here is my problem
I need to set same parameters to viewA when I execute dismiss.
How can I do it?
Hi,I have a range say,1-100 and i want the user to select a value from this range.Ofcourse showing this with a spinner will be awful.I want to use the functionality of date widget,where we can pick a date by pressing a +/- sign,the longer the press ,higher the iteration speed.
I found numberpicker.java that has the code the date widget uses to get this functionality, but do i have to paste that entire code to achieve this functionality!
this is the code I am using:
tabPage1.Controls.Add(AXViewer1);
where AXViewer1 is a third party ActiveX contorl (non .NET) that I want to add it to the my tab page.
Is it wrong to it the way I did ? since it has not added it to the tab page with that code.
Please see code snippet:
File[] additionalFiles = new File(FILE_PATH).listFiles();
boolean isDirectory = file.isDirectory();
I have verified that the directory path is correct, and when I run the code on Windows, the value of isDirectory is true (as it should be). Any suggestions as to why this occurs on Linux (RedHat Enterprise Linux)?
I have a RESTful service that exposes enums.
Should I expose them as localised strings, or plain integers?
My leaning is toward integers for easy conversion at the service end, but in that case the client needs to grab a list of localised strings from somewhere in order to know what the enums mean. Am I just creating extra steps for nothing?
There seems to be little information I can find about which is commonly done in RESTful APIs.
EDIT:
OK. Let's say I'm writing a website that stores information about people's pets. I could have an AnimalType enum
0 Dog
1 Cat
2 Rabbit
etc.
When people grab a particular pet resource, say /pets/1, I can either provide a meaningful localised string for the animal type, or just provide the ID and force them to do another look up via a /pets/types resource.
Or should I provide both?
I have a WinForm set up and a process that loops until a button is pressed on the form.
When I try to run my code, the form does not even display. I suspect this is because the code gets stuck in the loop and doesn't get far enough to display the WinForm. How can I get the form to display and the loop to run after that point?
After performing an ajax request if the input in the form was wrong I am trying to get this validatationTextBox to be focussed on and display an indicator message showing the problem.
The code is:
dijit.byId("passwordField").focusNode.focus()
The form element is as mentioned a validationTextBox.
The matter that is confusing me even further is that before in dojo 1.5, this piece of code was simply dijit.byId("passwordField").focus() and this worked fine. How can I fix this?
Im having the following code, however, I can see that the radio button isnt being diplayed. Only the label is being displayed. what is wrong with the code?
<%Html.RadioButton("Role", Role.User, true);%><%=Role.User%>
I dont have perl install on windows. I would like to copy the entire testdb to testdb on my linux VM. What is the easiest way to do that? I can run code on my windows machine to connect to both DB and do sql operations. I am using C#.NET so if i need to write code and its simple then i'm open to that.
On my application, the user needs to click on a file name, and then the user is supposed to choose either to download the file or open it. I put code for it that is working fine for .doc, .txt extentions yet it is not working fine for .docx
My code is the following:
@header('Location:'.$attachment_path);
Any idea of how to do it so it will work for all kind of attachment?
Hi,
Just wondering, if I install a Windows service from 64-bit process (service code embedded in the process), is the service itself Win32 service or can services be 64-bit as well?
I need to know this since my service would inject code to Win32-process, so due to WOW64 restrictions the service-process itself cannot be 64-bit.
Best regards,
nhaa123
With a cURL request I load a complete website into a variable: $buffer.
In the source of the site there are two labels in between which my relevant content is placed.
****** bunch of code *******
<!-- InstanceBeginEditable name="Kopij" -->
this part I want to store in a match
<!-- InstanceEndEditable -->
****** bunch of code *******
I've been messing around with preg_match and its regexp. Can someone try to help me?
Thanx in advance.