Daily Archives

Articles indexed Thursday April 22 2010

Page 10/123 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • How to handle response from webserver in libcurl

    - by sfactor
    i have to send a file to a webserver via libcurl. so i send a HTTP POST form with the file and login credentials. it responds to me with some response (can be anything like HTML code or a SUCCESS or FAILURE string). i need to handle this in my code. can someone tell me how do i capture this response in libcurl.

    Read the article

  • What to do when you need more verbs in REST

    - by Richard Levasseur
    There is another similar question to mine, but the discussion veered away from the problem I'm encounting. Say I have a system that deals with expense reports (ER). You can create and edit them, add attachments, and approve/reject them. An expense report might look like this: GET /er/1 => {"title": "Trip to NY", "totalcost": "400 USD", "comments": [ "john: Please add the total cost", "mike: done, can you approve it now?" ], "approvals": [ {"john": "Pending"}, {"finance-group": "Pending"}] } That looks fine, right? Thats what an expense report document looks like. If you want to update it, you can do this: POST /er/1 {"title": "Trip to NY 2010"} If you want to approve it, you can do this: POST /er/1/approval {"approved": true} But, what if you want to update the report and approve it at the same time? How do we do that? If you only wanted to approve, then doing a POST to something like /er/1/approval makes sense. We could put a flag in the URL, POST /er/1?approve=1, and send the data changes as the body, but that flag doesn't seem RESTful. We could put special field to be submitted, too, but that seems a bit hacky, too. If we did that, then why not send up data with attributes like set_title or add_to_cost? We could create a new resource for updating and approving, but (1) I can't think of how to name it without verbs, and (2) it doesn't seem right to name a resource based on what actions can be done to it (what happens if we add more actions?) We could have an X-Approve: True|False header, but headers seem like the wrong tool for the job. It'd also be difficult to get set headers without using javascript in a browser. We could use a custom media-type, application/approve+yes, but that seems no better than creating a new resource. We could create a temporary "batch operations" url, /er/1/batch/A. The client then sends multiple requests, perhaps POST /er/1/batch/A to update, then POST /er/1/batch/A/approval to approve, then POST /er/1/batch/A/status to end the batch. On the backend, the server queues up all the batch requests somewhere, then processes them in the same backend-transaction when it receives the "end batch processing" request. The downside with this is, obviously, that it introduces a lot of complexity. So, what is a good, general way to solve the problem of performing multiple actions in a single request? General because its easy to imagine additional actions that might be done in the same request: Suppress or send notifications (to email, chat, another system, whatever) Override some validation (maximum cost, names of dinner attendees) Trigger backend workflow that doesn't have a representation in the document.

    Read the article

  • Escaping single quote in PHP when inserting into MySQL

    - by hairdresser-101
    I have a perplexing issue that I can't seem to comprehend... I'm hoping someone here might be able to point me in the right direction... I have two SQL statements: - the first enters information from a form into the database. - the second takes data from the database entered above, sends an email and then logs the details of the transaction The problem is that it a appears that a single quote is triggering a MySQL error on the second entry only!!! The first instance works without issue but the second instance triggers the mysql_error(). Does the data from a form get handled differently from the data captured in a form? Query#1 - This works without issue (and without escaping the single quote) $result = mysql_query("INSERT INTO job_log (order_id, supplier_id, category_id, service_id, qty_ordered, customer_id, user_id, salesperson_ref, booking_ref, booking_name, address, suburb, postcode, state_id, region_id, email, phone, phone2, mobile, delivery_date, stock_taken, special_instructions, cost_price, cost_price_gst, sell_price, sell_price_gst, ext_sell_price, retail_customer, created, modified, log_status_id) VALUES ('$order_id', '$supplier_id', '$category_id', '{$value['id']}', '{$value['qty']}', '$customer_id', '$user_id', '$salesperson_ref', '$booking_ref', '$booking_name', '$address', '$suburb', '$postcode', '$state_id', '$region_id', '$email', '$phone', '$phone2', '$mobile', STR_TO_DATE('$delivery_date', '%d/%m/%Y'), '$stock_taken', '$special_instructions', '$cost_price', '$cost_price_gst', '$sell_price', '$sell_price_gst', '$ext_sell_price', '$retail_customer', '".date('Y-m-d H:i:s', time())."', '".date('Y-m-d H:i:s', time())."', '1')"); Query#2 - This fails when entering a name with a single quote (i.e. O'Brien) $query = mysql_query("INSERT INTO message_log (order_id, timestamp, message_type, email_from, supplier_id, primary_contact, secondary_contact, subject, message_content, status) VALUES ('$order_id', '".date('Y-m-d H:i:s', time())."', '$email', '$from', '$row->supplier_id', '$row->primary_email' ,'$row->secondary_email', '$subject', '$message_content', '1')");

    Read the article

  • Submit form using javascript, work in FF but not in IE

    - by Permana
    I have this code. The code below is working in Firefox, but it is not in IE <body> <?php $data = getLoginData($_SESSION['whoyouare']); ?> <form name="frm_redirect_dfr" action="<?php echo $data['url']; ?>" method="POST" id="frm_redirect_dfr" style="display: none;"> <input name="DFRNet_User" value="<?php echo $data['username']; ?>" type="hidden" /> <input name="DFRNet_Pass" value="<?php echo $data['password']; ?>" type="hidden" /> <input name="tbllogin" value="login" type="hidden" /> <input type="submit" value="submit" /> </form> <script language="javascript" type="text/javascript"> document.forms["frm_redirect_dfr"].submit(); </script> </body> What I want to do is, when user access the page, it first will try to get login data, echo it in the form, and submit the form automatically using javascript

    Read the article

  • jQuery UI Dialog and Textarea Focus Issue

    - by Gimli
    I'm working on a modal comment system using jQuery and jQuery UI, but I'm having some issues with focus. I have a series of divs inside the modal to switch between Login and Add comment, as below: <div id="modal" title="Loading"> <div id="modalContent"></div> <div id="modalLogin"> <div class="loginBox"></div> <div class="addCommentBox"></div> <div class="commentReview"></div> </div> </div> Inside of the addCommentBox div, I've got the comment code: <form action="/comments/add" class="addCommentForm" name="addCommentForm" method="post"> <textarea name="content" class="addCommentContent"></textarea> <button value="Add Comment" type="submit" class="commentPost"/> <button value="Clear Comment" type="submit" id="clearComment"/> </form> The issue is that about half the time after opening the dialog the textarea inside the addCommentBox div doesn't react to keyboard inputs when selected. The mouse works correctly and will allow text to be selected, but keyboard control does nothing. I have no event listeners on the textarea. I've got some on the buttons, but they are targeting only the buttons. The only thing that happens in the HTML seems to be the fact that every time I click on the modal, the z-index increases for the overall modal div. I have set the addCommentBox div to have a z-index of 9999, greater than the z-index of the modal. Any suggestions or directions to research would be greatly appreciated. Thanks!

    Read the article

  • Translate query to NHibernate

    - by Rob Walker
    I am trying to learn NHibernate, and am having difficulty translating a SQL query into one using the criteria API. The data model has tables: Part (Id, Name, ...), Order (Id, PartId, Qty), Shipment (Id, PartId, Qty) For all the parts I want to find the total quantity ordered and the total quantity shipped. In SQL I have: select shipment.part_id, sum(shipment.quantity), sum(order.quantity) from shipment cross join order on order.part_id = shipment.part_id group by shipment.part_id Alternatively: select id, (select sum(quantity) from shipment where part_id = part.id), (select sum(quantity) from order where part_id = part.id) from part But the latter query takes over twice as long to execute. Any suggestions on how to create these queries in (fluent) NHibernate? I have all the tables mapped and loading/saving/etc the entities works fine.

    Read the article

  • Change a UIButton View's background upon press

    - by Michael
    This should be easy but its got me stumped. I've got a button on each row of a table cell. The button is to delete the file associated with that row. I have an image that indicates if the file is present on the iPhone or not present. When the user presses the button, the target action method (showDeleteSheet) then calls a UIActionSheet with a variable to give it the indexPath of the row pressed. Then the user presses delete on the action sheet and the action sheet's clickedButtonAtIndex method deletes the file. Now, I need to update the button's background image property to change the image in the appropriate table cell to the not downloaded image. This can be done in either the button's target action method or the action sheet's clickedButtonAtIndex method. Here is some code: In the table's cellForRowAtIndexPath method I create the button: UIButton *deleteButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain]; [deleteButton addTarget:self action:@selector(showDeleteSheet:) forControlEvents:UIControlEventTouchDown]; deleteButton.frame = CGRectMake(246, 26, 30, 30); if (![AppData isDownloaded:[dets objectForKey:@"fileName"]]) { [deleteButton setBackgroundImage:notdownloadedImage forState:UIControlStateNormal]; } else { [deleteButton setBackgroundImage:notdownloadedImage forState:UIControlStateNormal]; } In the button's target method: -(void)showDeleteSheet:(id)sender { //get the cell row that the button is in NSIndexPath *indexPath = [table indexPathForCell:(UITableViewCell *)[[sender superview] superview]]; NSInteger currentSection = indexPath.section; NSInteger currentIndexRow = indexPath.row; NSLog(@"section = %i row = %i", currentSection, currentIndexRow); UIButton *deleteButton = [UIButton buttonWithType:UIButtonTypeCustom]; [table reloadData]; //if deleteButton is declared in .h then the other instances of deleteButton show 'local declaration hides instance variable' [deleteButton setBackgroundImage:[UIImage imageNamed:@"not-downloaded.png"] forState:UIControlStateNormal]; UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Delete this file?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete" otherButtonTitles:nil]; actionSheet.tag = currentIndexRow; actionSheet.actionSheetStyle = UIActionSheetStyleDefault; [actionSheet showInView:self.view]; [actionSheet release]; } Perhaps the issue is that the call to [deleteButton setBackgroundImage...]; doesn't know which cell's button should be updated. If so I don't know how to tell it which. Because I test if the file is downloaded when the button is made and the background image is set, when I scroll down so the cell in question is de-queued then scroll back up it show's the correct image. I've tried to force the table to reload but [table reloadData]; is doing nothing. I've tried reloadRowsAtIndexPaths and still no good. Any one care to educate me on how this is done?

    Read the article

  • how to write a script that logs into an application and checks a page

    - by josh
    Is it possible to write a script that will login to an application using uname/pwd? the username/password are not passed in through POST (they dont come in the URL) Basic steps I am looking for are: Visit url enter uname/pwd click a button click a link get the raw html to make sure it does not have 500 error Is that possible to do in any language? Please point me to some examples as well

    Read the article

  • Checkbox In Listview + vb.net

    - by Mark
    Can anyone help me on how to do this.. I have a ListView with Checkboxes in vb.net and what I want to do is when the user check the checkbox, the program ignore the response of the user in checking the checkbox, instead it leaves the checkbox uncheck.. This concern is uses for may validation.. Thanks for your positive response regarding this..

    Read the article

  • Can't get python.manage.py syncdb to work

    - by Diego
    I just created my first django app, initialized variables DATABASE_ENGINE and DATABASE_NAME in settings.py, but now when I run python manage.py syncdb, I get the following error Can somebody help? Does this have to do with having two python versions installed? I'm a django/python noob, please help. thanks!! my-computer:~/Django-1.1.1 mycomp$ python manage.py syncdb /Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python: can't open file 'manage.py': [Errno 2] No such file or directory my-computer:~/Django-1.1.1 mycomp$ export PATH=/Users/mycomp/bin:$PATH

    Read the article

  • Scraped HTML is not written at the beginning of text file.

    - by karikari
    Currently, I'm scraping the HTML code of a page, and writing it to a text file. My problem is, why must there be empty spaces or empty lines at the beginning? The HTML codes written to the txt file do not seem to start at the beginning of the text file. This means that the '<' is not located at the position 0 of the txt file. After a few runs, my HTML is always written a few lines down inside the text file. Can anyone tell me why?

    Read the article

  • Sniffing at work- How to detect

    - by coffeeaddict
    Because of the place I work has some real issues (people) especially in IT and the owner, I wonder if we are being sniffed. Is there any way to tell if on a Vista 64-bit machine: 1) In system logs some identification that would tell me that someone might log into my PC such as an Admin 2) Something in the logs that would give me a flag about maybe I'm being monitored some other way? 3) How can I be sure that my gmail, hotmail, and chat is not being sniffed. I know there are things like Simp, etc. I'm talking about specific hidden system signs either in registry or logs. Obviously I'm not going to raise any suspicion by me asking our network admin. I don't trust anyone at this company. is there a good way to basically monitor for this as an end user? Could someone log in and basically watch me work and if so, would there be any goodies left behind for me to find out if this has happened other than visual signs which would not be present...maybe some running processes?

    Read the article

  • What's the best way to move c:\users to d:\users under vista/W7

    - by Scott
    I just installed Windows 7 RC1 and want to move c:\users to d:\users. What's the best way to do this? Due to the fact that Windows 7 creates a reserved partition that is mounted as C: in the recovery console, I had to use the following commands robocopy /mir /xj D:\Users E:\Users mklink D:\Users D:\Users /j Both D's in the mklink command are correct. When the system reboots, the drive that was D in the recovery console becomes the C drive.

    Read the article

  • Win32 API prevent standby

    - by bobobobo
    What is the Win32 api function that prevents the system from going into standby? Some programs use it, which is pretty annoying in my opinion. I know there's a couple of WM_SYSCOMMAND messages you can trap to prevent the screensaver from coming on..

    Read the article

  • Dynamic Linq query issue

    - by Alex
    Hey All, Im trying to query the Netflix OData feed. I have the following query that works fine in LinqPad: from g in Genres from t in g.Titles where g.Name == "Horror" && t.AverageRating == 2 && t.ReleaseYear == 2004 select t But, when I move it over to my Silverlight app, the user selects what to search on so I may or may not have all of the params. That being the case, I need to construct the query at runtime. Ive looked the the Dynamic Query stuff and that will do fine...the issue that I have is that I need an initial acceptable query to append to and this doesn't fly: from g in Genres from t in g.Titles select t; Any additional thoughts would be appreciated. Thanks in advance

    Read the article

  • gae error when i login.

    - by zjm1126
    i am using http://code.google.com/p/gaema/source/browse/#hg/demos/webapp, and this is my traceback: Traceback (most recent call last): File "D:\Program Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 510, in __call__ handler.get(*groups) File "D:\gaema\demos\webapp\main.py", line 31, in get google_auth.get_authenticated_user(self._on_auth) File "D:\gaema\demos\webapp\gaema\auth.py", line 641, in get_authenticated_user OpenIdMixin.get_authenticated_user(self, callback) File "D:\gaema\demos\webapp\gaema\auth.py", line 83, in get_authenticated_user url = self._OPENID_ENDPOINT + "?" + urllib.urlencode(args) File "D:\Python25\lib\urllib.py", line 1250, in urlencode v = quote_plus(str(v)) UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128) how to do this thanks ??????????????? ???????? ??????????? ?????????????? ???????

    Read the article

  • Java2D Distance Collision Detection

    - by Trizicus
    My current setup is only useful once collision has been made; obviously there has to be something better than this? public boolean CollisionCheck(Rectangle rect1, Rectangle rect2) { if(rect1.intersects(rect2)) { return true; } return false; } How can I do preemptive collision detection?

    Read the article

  • ArrayList throwing exception on retrieval from google datastore (with gwt, java)

    - by sumeet
    I'm using Google Web Toolkit with java and google datastore as database. The entity class has arraylist and on trying to retrieve the data from data base I'm getting the exception: Type 'org.datanucleus.sco.backed.ArrayList' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized. I'm using JPA. Entity code: package com.ver2.DY.client; import java.io.Serializable; import java.util.ArrayList; import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.PersistenceCapable; import javax.jdo.annotations.Persistent; import javax.jdo.annotations.PrimaryKey; import com.google.gwt.user.client.rpc.IsSerializable; @PersistenceCapable public class ChatInfo implements Serializable, IsSerializable{ @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Long topicId; @Persistent private String chatTopic; @Persistent private ArrayList messages = new ArrayList(); @Persistent private boolean isFirstPost; public ChatInfo() { } public Long getTopicId() { return topicId; } public void setTopicId(Long topicId) { this.topicId = topicId; } public String getChatTopic() { return chatTopic; } public void setChatTopic(String chatTopic) { this.chatTopic = chatTopic; } public ArrayList getMessages() { return messages; } public void addMessage(String newMsg) { messages.add(newMsg); } public boolean isFirstPost() { return isFirstPost; } public void setFirstPost(boolean isFirstPost) { this.isFirstPost = isFirstPost; } } Method in db class: @Transactional public ChatInfo[] getAllChat() { PersistenceManager pm = PMF.get().getPersistenceManager(); List chats = null; ChatInfo[] infos = null; String query = "select from " + ChatInfo.class.getName(); try{ chats = (List) pm.newQuery(query).execute(); infos = new ChatInfo[chats.size()]; for(int i=0;i } It is a bit strange because earlier I was able to insert and retrieve the data but it now throwing an exception. On searching the web I could find that I need to convert the Arraylist from some DataNucleus type to java util but not sure how to do that.

    Read the article

  • Thin and Bundler on Windows Rails

    - by Bob
    Trying to get Thin working with Bundle on Windows, I know, major PITA but anyways, I'm new to Thin and Bundle gem, I'm on Ruby 1.8.6 and Rails 2.3.5 and trying to get someone else's app running on my laptop, the app uses Thin and Bundle gem to install gems required. I noticed that bundle created a .bundle folder under My Documents folder and put all the gems there for the app. When I tried "thin run", it reported 'thin' is not recognized as an internal or external command, operable program or batch file. I check the environment path and it doesn't point to the .bundle folder at all and I found there is a thin.bat in C:\Documents and Settings\Bob\.bundle\ruby\1.8\bin When I tried "C:\Documents and Settings\Bob.bundle\ruby\1.8\bin\thin" start, it gave me another error c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:777:in `report_activate_error': Could not find RubyGem thin (>= 0) (Gem::LoadError) from c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:211:in `activate' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:1056:in `gem' from C:/Documents and Settings/Bob/.bundle/ruby/1.8/bin/thin:18 I get the same error if I added "C:\Documents and Settings\Bob.bundle \ruby\1.8\bin" to the env path. Anyone know I can get this working?

    Read the article

  • php curly braces groups

    - by David
    is there a function or regex or anything to group items by a { and } tag? so it should group items by the opening tag { and the closing tag }. but be careful, there are also groups inside parent groups like so: group { text1 group2 { text2 } } so basically think of it like php, you make an opening tag, you need to close it with a closing tag, curly braces in php's case. i just need it to like substr() each group into an associative array somehow, except I cant figure it out with the whole, "group inside a parent group".

    Read the article

  • How to import music into Android library

    - by android_dev
    Hello, I would like to know how can I import songs from a web service into Android library without having to download the file into sdcard. I have all the data from the web service but I do not know how to integrate the tracks into Android database. My idea is not to have to download the files, but playing them on streaming using the music player. Do I need to download the tracks to the sd card and then Android does all the stuff? Thanks in advance

    Read the article

  • http, https and ftp is not working but smtp and imap is working

    - by Unicron
    hi all, yesterday on a computer of a friend a strange thing happened. after booting the ports fo http, https and ftp are closed but e-mail is still working. in the control panel the windows firewall seems active even if he tries to deactivate it. i have a suspision that it is the faul of norton internet security 2010, we have tried to uninstall it, but the uninstallation did not work. when using the removal tool from symantec it just goes to 23% and then it crashes. the process ccSvcHst.exe is still running. how can i safeley remove the rest of norton internet security? thanks in advance [edit] norton internet security 2010 is sucesfully removed, but still no connectivity

    Read the article

  • Seemingly random network connectivity.

    - by AngryHacker
    This has been driving me nuts for a while. When I turn on the PC (which has a wired Ethernet connection), it cannot be accessed by other computers on the network. In other words, inbound connections do not work. The firewall is disabled. The PC itself can hit up anything it wants just fine. By process of elimination, I've figured out that checking or unchecking the Eaclift driver in the properties for my network connection restored the inbound connection. I do not know what Eaclift driver is or does or how it even got on my PC (e.g. I am not allowed to uninstall it either). And it does not matter whether it's on or off - I just need to toggle it to restore connectivity. One other thing that happens when I toggle the Eaclift driver, is than an Internet Connection icon appears in the Network Connections and it was not there before. Can someone shed some light as to what is going on? How to fix it so that I don't have to deal with this insanity?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >