I need to get weather info from a website in C++ - c++

Well, I want to make a little console application that can get the weather and all its stats to show up in a little box, and I need to get this from a website, I'm thinking something like weather.com, and I need to do it in C++. I need it to simply grab some weather stats from the site and post them in a list on the console screen, in real time, or at least with a refresh button. Is this even possible or do I need to learn some java to do this?

Try feeds from news channel. Or popular Yahoo website API FOR WHETHER
Hey APIs are not in C or C++ specific(with some exception). You can directly download webpage where you can see whether report. Then press F12 & find under which HTML tag it lies. Then open that web page using socket API. THIS IS JUST SINGLE LINE CODE. for finding that tag you need string functions. Then copy & paste work. Also use threads to update time & date & obviously whether report.

I have an application which has nothing to do with the weather.. however those customers are interested in seeing the weather in a box just like the person who asked for this... in worse case I will call a bash script curl wttr.in and translate the output to nice graphics from Oxygene icons at iconarchive.com.
Who has a better solution?

Related

how to save a list in windows phone 8

I am beginner in this so I do not know much. So I am making an app where the user adds a checkbox(es) to a stack panel and looks something like this:
CheckBox CheckBox = new CheckBox();
CheckBox.Content = TextBox1.Text;
StackPanel1.Children.Add(CheckBox);
TextBox1.Text = "";
Then in the Application Bar i want user to be able to save their list in Isolated Storage and then close the app and then comeback and be able to open up a popup or a page that will display all their saved lists and when the press on them, it will open up their list. Much like in Microsoft word on PC where you can press open and it will display a folder containing all your documents.
I would really appreciate a DETAILED explanation as I am just a teen.
Thank You
The following link has some really great videos. I started off on using them. There is one video which does pretty much exactly what you want, I think it's at the bottom of page 4, and the continuation on page 5, but can't quite remember.
But you should check several of them out, there really great.
Channel 9 - Windows phone for beginners
I would also suggest you looking at this website which contains nice clear info about IsolatedStorage: All about IsolatedStorage
In fact the GeekChamp website is really good for finding out how to do things after you've started understanding more about Windows Phone and C#

Django -- printing lots of documents?

I have a Django app that stores client data. Currently, there are just over 1,000 clients in the database. Twice a year, I need to print a semi-customized letter for each client. Ideally, I want to be able to click a button/link and the entire batch is sent to the printer; I don't want to have to click "print" for each letter since that would be absurdly time consuming.
I have thought of is using Celery to chug through the process of printing all the documents, but I don't know how that would be accomplished. I would have to 'build' the document and send it to the printer without the user seeing this happen.
The other idea I had was to create a "web page" that contains all the letters on one page. Then the user can hit "Print" and the pages would come out of the printer as a collection of letters. Although, this seems sloppy.
Any ideas?
Thanks
I would advise using wkhtmltopdf for this task. You can then create the required letters from one long html with pagebreaks or separately and print them as you regularly print PDF's.
http://code.google.com/p/wkhtmltopdf/
As wk stands for WebKit it will print exceptionally good quality PDF's. It's a commandline tool that you can just download and run. Small tutorial is here for you.
http://shivul.posterous.com/django-create-dynamic-pdfs-using-wkhtmltopdf
ReportLab is also a good option. But myself I don't want to create raw pdf syntax and Pisa the html library for ReportLab is not really that good. wkhtmltopdf is much better and easier to use.
I'd suggest using something like Reportlab to create the whole thing as a single PDF document that you can send to the printer in one go.
See the docs on generating PDFs from Django.

Custom client app - need ability to control where documents are saved

Okay SO. I need some guidance. I apologize for the length of this post, but I need to provide some details:
I've got someone who is interested in me to do a small project for them. The application in general is a fairly straightforward employee record keeping / documentation app, but it makes pretty heavy use templated Word and Lotus documents. The idea is you select the employee “event” such as commendation, promotion, discipline, etc., and it loads the appropriate template doc and you fill it in from there, and later you can select an employee, view all the “events,” and view the individual documents associated with each one.
Thus, the app must know where the .docs are saved when the user is done.
The client actually has a v1 of this app (it doesn’t do any management of the files or anything, just launches Word/Lotus with the document you wanted to view in a new instance, presumably via a system() call.) We’ve not gotten into a detailed requirements phase, but the client and I agree that for this to really work, some kind of control over where the user saves the .doc’s to is going to be critical , because otherwise the app provides them with the new copy of the template doc, they "Save as" somewhere else, and the app is pointing to the blank copy it provided them with.
Obviously, I can’t think of a way to achieve “Save as” restriction/control in any way via just launching a new instance of Word. The client has the idea of an embedded Word/Lotus instance in the app with the template doc when you choose one, but I’ve few reservations with that:
I’ve dug around online and I’ve read that whichever version of Word I borrow MSWORD.OLB from will be the one the end user would require?
I’ve tried to do the MSDN example of embedding a Word doc from here, but as I’ve come to get used to, the MSDN example doesn’t even compile.
Even if I CAN figure out how to embed a .doc file into their application, I don’t know that I could control the use of “Save as…”
All of this STILL hasn’t touched on Lotus (!)
So… instinctively, I feel the embedded Word/Lotus thing has to be more work than it’s worth in the end.
So I’ve had a few other ideas brewing around.
One is looking into using Office XML (and if there’s a lotus equivalent), and get the user’s “inputs” separately and generate the document on the fly each time. I’m not particularly thrilled with that idea, but I think it COULD work, provided I just use old features to try and stay far backwards compatible.
Get user’s “inputs” separately and generate a document in HTML. Meh. Works, very cross platform and easily parsed and understood, but not good if you want to be able to email it to someone (who emails a .html? Works, yes, very unconventional which to the average user will throw them off) and even worse if you need to email it to someone for revisions…
Perhaps some kind of editable PDF? I know there are PDF libraries out there, and the more I stew on it, the more this sounds like the best option, though I’ve not done much work with PDFs and I don’t know how easily embeddable they are / what options one has when creating them. I know they can be save-disabled, I’ve had that with my bloody state taxes before.
I need some input here. Here’s the TLDR questions:
Is launching a new instance of Word for each .doc as bad as I feel, given user can “Save as” document wherever and then application is left pointing to a blank document?
Is trying to support embedded Word as big of a trouble as I feel like it is / more work than it’s worth / likely to cause problems with supporting multiple versions of Word? (Forward compatibility as well as currently released versions?)
What are thoughts on the PDF plan?
Any other good ideas?
Word does allow for programming some "Save" and "Save As" control via its object model. Any subroutines coded in VBA and placed into your Word template will be copied into all documents generated from that template. Additionally, most menu and Ribbon commands can be intercepted by creating a module containing subroutines named for the intercepted commands. So, for example, if a module contains a sub named FileSaveAs(), any code in that sub will be executed instead of the standard File|Save As command. Lastly, this code will replace Save As commands executed via keystroke, toolbar, menu, or Ribbon.
The code below will launch a dialog box to a predetermined path whenever a "Save" or "Save As" command is executed:
Sub FileSave()
ControlSaveLocation
End Sub
Sub FileSaveAs()
ControlSaveLocation
End Sub
Sub ControlSaveLocation()
Dim Directory As String
Directory = "C:\Documents\"
With Application.Dialogs(wdDialogFileSaveAs)
.Name = Directory
.Show
End With
End Sub
Hope this helps.

ColdFusion 8 Printing Issue

I've hit a weird snag developing a reports using ColdFuions 8. The report prints a number of large HTML tables and the customer wants them to be formated ins such a way that when they are printed out the user will get 2 of the tables per page.
So it wasn't hard to make a page break by using a
<p style="page-break-before: always"></p>
However, while I got the desired effect while using the development ColdFusion environment on my laptop, I get a diffent effect when printing reports generated on the test web server. There the reports print out with a much larger font so that the second table spills over onto a second page.
Has anyone else experienced this or has a recomendation for how to try and tackle it?
When a report needs to be printed, I would recommend using CFDOCUMENT to create a PDF. You get much more control over the final output including changing page orientation which is great for tables that are wide. It honors a lot of HTML and CSS including the page-break-before style so you shouldn't have to do to much conversion to use it outside of wrapping the report area with CFDOCUMENT tags. It has been available since CF7 so it should work for you on CF8.

I want to show off my C++ projects through a website

The problem is that, well, it's C++. The way I've created them makes it such that they've always been run via a terminal/console window and wait for user input or else simply take a sample input and run with that. The output has also always been to the terminal screen or sometimes to a file. I'm not quite sure how I could take all of that and integrate it with a website while leaving the source code as it is, if that's at all possible. I guess what I'm trying to aim for is to have whatever website I use behave like a terminal window that will accept user input and then send it off to run the C++ program in question and return with the output (whatever it may be), all with minimal modification to the source code. Either that or else set up a more automated kind of page where a user can just click 'Go' and the program will run using a sample input.
When it comes to web I consider myself intermediate with HTML, CSS, PHP & MySQL, and a beginner with Javascript, so if this can be accomplished using those languages, that would be fantastic. If not, don't be afraid to show me something new though.
The easiest interaction model to bring to the web is an application that takes its input up front and produces its output on stdout. In this situation, as the unknown poster mentioned, you could use CGI. But due to the nature of CGI, this will only work (in the simplest sense) if all the information is collected from the user in one page, sent to the application and the results returned in one page. This is because each invocation of a page using CGI spawns a new indepdent process to serve the request. (There are other more efficient solutions now, such as FastCGI which keeps a pool of processes around.) If your application is interactive, in that it collects some information, presents some results, prints some options, collects some more user input, then produces more results, it will need to be adapted.
Here is about the simplest possible CGI program in C++:
#include <iostream>
int main(int argc, char* argv[])
{
std::cout << "Content-type: text/plain\n" << std::endl;
std::cout << "Hello, CGI World!" << std::endl;
}
All it does is return the content type followed by a blank line, then the actual content with the usual boring greeting.
To accept user input, you would write a form in HTML, and the POST target would be your application. It will be passed a string containing the parameters of the request, in the usual HTTP style:
foo.cgi?QTY=123&N=41&DESC=Simple+Junk
You would then need to parse the query string (which is passed to the program via the QUERY_STRING environment variable) to gather the input fields from the form to pass to your application. Beware, as parsing parameter strings is the source of a great number of security exploits. It would definitely be worthwhile finding a CGI library for C++ (a Google search reveals many) that does the parsing for you. The query data can be obtained with:
const char* data = getenv("QUERY_STRING");
So at a minimum, you would need to change your application to accept its input from a query string of name=value pairs. You don't even need to generate HTML if you don't want to; simply return the content type as text/plain to begin with. Then you can improve it later with HTML (and change the content type accordingly).
There are other more sophisticated solutions, including entire web frameworks such as Wt. But that would involve considerable changes to your apps, which you said you wished to avoid.
Almost off-topic, but you might want to take a look at Wt.
have you considered using cgi ... its 19th century technology which lets webserver execute programs written in C/C++ to run and generate output
I do not know much about it ... but I used it for some school projects
Show it all off with Screencasts. I use Camtasia Studio, but there are a ton of them out there: http://en.wikipedia.org/wiki/Screencast
Camtasia will even generate all of the HTML and Flash you need to upload to your web server. Buy a nice USB microphone, and write a script of what you're going to say and show.
What is the purpose of showing off your projects? Do you wish to impress your friends or employers?
It doesn't seem feasible to emulate or port your C++ console apps through a web interface.
I suppose you could write a bridge between a server side script and your C++ binary which passes the user input through to your app, then returns the result through the web interface. Bear in mind this would be a huge task for you to undertake.
Ruby have a compiler on their website which demonstrates this can be done.
However no one on the web would expect to run your C++ apps in a web browser. Also I think that anyone who is interested in running a C++ app would be totally comfortable with downloading a C++ binary that you made and running it (apart from the security risk) but when you think about it we download apps and run them all the time, whilst trusting the source.
I have a portfolio website which I created for the purpose of letting employers see my work. Take a look, it will give you an idea of another way you can do things.
Basically I provide the binaries for download, videos, screenshots and links. Things that the user can use to see my work quickly if they don't have time (or an appropriate computer) to run my projects on.
Good luck
I have no experience with this (other than hearing a guy on BART talk about implementing his server-side code all in C), but you might consider taking a look at SWIG (http://www.swig.org/). It allows you to wrap C++ so that you can access C++ code when using languages such as PHP.