Search Results

Search found 1375 results on 55 pages for 'rob sanders'.

Page 36/55 | < Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >

  • curl_multi_exec stops if one url is 404, how can I change that?

    - by Rob
    Currently, my cURL multi exec stops if one url it connects to doesn't work, so a few questions: 1: Why does it stop? That doesn't make sense to me. 2: How can I make it continue? EDIT: Here is my code: $SQL = mysql_query("SELECT url FROM shells") ; $mh = curl_multi_init(); $handles = array(); while($resultSet = mysql_fetch_array($SQL)){ //load the urls and send GET data $ch = curl_init($resultSet['url'] . $fullcurl); //Only load it for two seconds (Long enough to send the data) curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_multi_add_handle($mh, $ch); $handles[] = $ch; } // Create a status variable so we know when exec is done. $running = null; //execute the handles do { // Call exec. This call is non-blocking, meaning it works in the background. curl_multi_exec($mh,$running); // Sleep while it's executing. You could do other work here, if you have any. sleep(2); // Keep going until it's done. } while ($running > 0); // For loop to remove (close) the regular handles. foreach($handles as $ch) { // Remove the current array handle. curl_multi_remove_handle($mh, $ch); } // Close the multi handle curl_multi_close($mh);

    Read the article

  • Using PHP, can I put variables inside of variables?

    - by Rob
    For example, take this code: $ch = curl_init($resultSet['url']."?get0=get0&get1=".$get1."&get2=".$get2."&get3=".$get3); This of course, looks very ugly, and kind of a pain in the ass to read. So my question is, would I be able to use something like this: $allgets ="?act=phptools&host=".$host."&time=".$duration."&port=".$port; $ch = curl_init($resultSet['url'] . $allgets); Very simple question I suppose, but my server is undergoing maintenance, so I can't upload it and test it myself. I suppose a yes or no answer will suffice, but if you have a more efficient way of doing this, that would be even better. :)

    Read the article

  • Variable declarations in header files - static or not?

    - by Rob
    When refactoring away some #defines I came across declarations similar to the following in a C++ header file: static const unsigned int VAL = 42; const unsigned int ANOTHER_VAL = 37; The question is, what difference, if any, will the static make? Note that multiple inclusion of the headers isn't possible due to the classic #ifndef HEADER #define HEADER #endif trick (if that matters). Does the static mean only one copy of VAL is created, in case the header is included by more than one source file?

    Read the article

  • Recursion in prepared statements

    - by Rob
    I've been using PDO and preparing all my statements primarily for security reasons. However, I have a part of my code that does execute the same statement many times with different parameters, and I thought this would be where the prepared statements really shine. But they actually break the code... The basic logic of the code is this. function someFunction($something) { global $pdo; $array = array(); static $handle = null; if (!$handle) { $handle = $pdo->prepare("A STATEMENT WITH :a_param"); } $handle->bindValue(":a_param", $something); if ($handle->execute()) { while ($row = $handle->fetch()) { $array[] = someFunction($row['blah']); } } return $array; } It looked fine to me, but it was missing out a lot of rows. Eventually I realised that the statement handle was being changed (executed with different param), which means the call to fetch in the while loop will only ever work once, then the function calls itself again, and the result set is changed. So I am wondering what's the best way of using PDO prepared statements in a recursive way. One way could be to use fetchAll(), but it says in the manual that has a substantial overhead. The whole point of this is to make it more efficient. The other thing I could do is not reuse a static handle, and instead make a new one every time. I believe that since the query string is the same, internally the MySQL driver will be using a prepared statement anyway, so there is just the small overhead of creating a new handle on each recursive call. Personally I think that defeats the point. Or is there some way of rewriting this?

    Read the article

  • What are Code Smells? What is the best way to correct them?

    - by Rob Cooper
    OK, so I know what a code smell is, and the Wikipedia Article is pretty clear in its definition: In computer programming, code smell is any symptom in the source code of a computer program that indicates something may be wrong. It generally indicates that the code should be refactored or the overall design should be reexamined. The term appears to have been coined by Kent Beck on WardsWiki. Usage of the term increased after it was featured in Refactoring. Improving the Design of Existing Code. I know it also provides a list of common code smells. But I thought it would be great if we could get clear list of not only what code smells there are, but also how to correct them. Some Rules Now, this is going to be a little subjective in that there are differences to languages, programming style etc. So lets lay down some ground rules: ** ONE SMELL PER ANSWER PLEASE! & ADVISE ON HOW TO CORRECT! ** See this answer for a good display of what this thread should be! DO NOT downmod if a smell doesn't apply to your language or development methodology We are all different. DO NOT just quickly smash in as many as you can think of Think about the smells you want to list and get a good idea down on how to work around. DO downmod answers that just look rushed For example "dupe code - remove dupe code". Let's makes it useful (e.g. Duplicate Code - Refactor into separate methods or even classes, use these links for help on these common.. etc. etc.). DO upmod answers that you would add yourself If you wish to expand, then answer with your thoughts linking to the original answer (if it's detailed) or comment if its a minor point. DO format your answers! Help others to be able to read it, use code snippets, headings and markup to make key points stand out!

    Read the article

  • Protecting Content with AuthLogic

    - by Rob Wilkerson
    I know this sounds like a really, really simple use case and I'm hoping that it is, but I swear I've looked all over the place and haven't found any mention of any way - not even the best way - of doing this. I'm brand-spanking new to Ruby, Rails and everything surrounding either (which may explain a lot). The dummy app that I'm using as my learning tool requires authentication in order to do almost anything meaningful, so I chose to start by solving that problem. I've installed the AuthLogic gem and have it working nicely to the extent that is covered by the intro documentation and Railscast, but now that I can register, login and logout...I need to do something with it. As an example, I need to create a page where users can upload images. I'm planning to have an ImagesController with an upload action method, but I want that only accessible to logged in users. I suppose that in every restricted action I could add code to redirect if there's no current_user, but that seems really verbose. Is there a better way of doing this that allows me to define or identify restricted areas and handle the authentication check in one place?

    Read the article

  • Is it possible to craft your own packets with python?

    - by Rob
    Well, I know its possible, using external libraries and modules such as scapy. But how about without external modules? Without running the script as root? No external dependencies? I've been doing a lot of googling, but haven't found much help. I'd like to be able to create my own packets, but without running as root, or installing extra dependencies. Any suggestions?

    Read the article

  • Get the selected value from a Select box and check that value against an array in the same form

    - by Rob Allen
    I'm new to JSTL/EL and JSP and can't seem to find a reference which covers the following scenario: I have an array of values in JavaScipt: var Countries = ('US', 'CA'); I then need to check to see if the currently selected value of a standard HTML select box is in that array. This is what I have so far: <select id="shippingCountry"> <option value="AT">Austria</option> <option value="CA">Canada</option> <option value="DE">Germany</option> //... <option value="US">United States</option> </select> <c:choose> <c:when test=" "> // I don't know what to put in the 'test' case <span class="required">*</span> </c:when> </c:choose>

    Read the article

  • Javascript: Using the Module Pattern for larger projects

    - by Rob
    I'm interested in using the Module Pattern to better organize my future projects. Unfortunately, there are only a few brief tutorials and proof-of-concept examples of the Module Pattern. Using the module pattern, I would like to organize projects into this sort of structure: project.arm.object.method(); Where "project" is my global project name, "arm" is a sub-section or branch of the project, "object" is an individual object, and so on to the methods and properties. However, I'm not sure how I should be declaring and organizing multiple "arms" and "objects" under "project". var project = window.project || {}; project.arm = project.arm || {}; project.arm.object = (function() { var privateVar = "Private contents."; function privateMethod() { alert(privateVar); } return { method: privateMethod }; }()); Are there any best practices or conventions when defining a complex module structure? Should I just declare a new arm/object underneath the last?

    Read the article

  • Chaining jQuery animations using recursion crashes browser

    - by Rob Sobers
    Here's the basic idea of what I'm trying to do: Set the innerHTML of a DIV to some value X Animate the DIV When the animation finishes, change the value of X and repeat N times If I do this in a loop, what ends up happening is, because the animations occur asynchronously, the loop finishes and the DIV is set to its final value before the animations have had a chance to run for each value of X. As this question notes, the best way to solve this problem is to make a recursive call to the function in the callback handler for the animation. This way the value of the DIV doesn't change until the animation of the previous value is complete. This works perfectly...to a point. If I animate a bunch of these DIVs at the same time, my browser gets overwhelmed and crashes. Too much recursion. Can anyone think of a way to do this without using recursion?

    Read the article

  • SQL Server Conditional Mailing Address Formatting

    - by Rob Packwood
    I have the following SQL to format a US address into each line for a mailing address but it is rather ugly. Is there a better way to solve this problem or does it have to be this ugly? declare @NL varchar(2); set @NL = char(13) + char(10); select case when rtrim(coalesce(AttentionLine,'') ) != '' then rtrim(AttentionLine ) + @NL else '' end + case when rtrim(coalesce(Recipient,'') ) != '' then rtrim(Recipient ) + @NL else '' end + case when rtrim(coalesce(AddlAddrLine,'') ) != '' then rtrim(AddlAddrLine ) + @NL else '' end + case when rtrim(coalesce(DeliveryAddr,'') ) != '' then rtrim(DeliveryAddr ) + @NL else '' end + case when rtrim(coalesce(LastLine,'') ) != '' then rtrim(LastLine ) + @NL else '' end + case when rtrim(coalesce(Country,'') ) != '' then rtrim(Country ) + @NL else '' end as FormattedMailingAddress from Address where Id = 1

    Read the article

  • Commercial web application--scalable database design

    - by Rob Campbell
    I'm designing a set of web apps to track scientific laboratory data. Each laboratory has several members, each of whom will access both their own data and that of their laboratory as a whole. Many typical queries will thus be expected to return records of multiple members (e.g. my mouse, joe's mouse and sally's mouse). I think I have the database fairly well normalized. I'm now wondering how to ensure that users can efficiently access both their own data and their lab's data set when it is mixed among (hopefully) a whole ton of records from other labs. What I've come up with so far is that most tables will end with two fields: user_id and labgroup_id. The WHERE clause of any SELECT statement will include the appropriate reference to one of the id fields ("...WHERE 'labroup_id=n..." or "...WHERE user_id=n..."). My questions are: Is this an approach that will scale to 10^6 or more records? If so, what's the best way to use these fields in a query so that it most efficiently searches the relevant subset of the database? e.g. Should the first step in querying be to create a temporary table containing just the labgroup's data? Or will indexing using some combination of the id, user_id, and labroup_id fields be sufficient at that scale? I thank any responders very much in advance.

    Read the article

  • How to fix button size?

    - by rob
    I am using three buttons along with the list view.These three buttons are added to the layout using the TableRow.The first button takes more space on content, so the other two becomes smaller in size than first one. When the application runs, it doesn't even show the two other buttons. How can I make the size of three buttons equal and display all of them when application runs?

    Read the article

  • Any way to have delayed_job execute some run-once code at startup and use across all jobs?

    - by Rob Cameron
    So I've got a delayed_job task that pushes some info to an XMPP server. Ideally you create a connection to XMPP once and then constantly push data to it, rather than creating a new connection every time you have some data to send. Is there any kind of facility in delayed_job for running a sort of 'setup' method when a worker starts, have it set some instance variables (like the XMPP connection object) that can then be used by all the jobs that come up? It's okay if each worker runs its own setup method. I just don't want every job (thousands per day) connecting to the XMPP server from scratch every time. Thanks for any help!

    Read the article

  • Does CAS Support Application Level Impersonation?

    - by Rob Wilkerson
    I have a PHP application that is successfully authenticating against a CAS server. One of the features supported by the application is impersonation; a user with the appropriate privileges can impersonate another of the application. Generally, this isn't a problem because the app itself can keep track of who the user is impersonating and manage privileges (which are based on username). A new requirement has come up, though, that requires the original app to include, via an iframe, content from a second PHP app that is also CAS-enabled. Somehow, I need for the second app to know whether impersonation is happening in the first. I don't want to pass usernames around for security reasons, so I'm wondering whether I can offload the responsibility for handling impersonation to the CAS server which is shared by both apps. Thanks.

    Read the article

  • WYSIWYG with Qt - font size woes

    - by Rob
    I am creating a custom Qt widget that mimics an A4 printed page and am having problems getting fonts to render at the correct size. My widget uses QPainter::setViewport and QPainter::setWindow to mimic the A4 page, using units of 10ths of a millimetre which enables me to draw easily. However, attempting to create a font at a specific point size doesn't seem to work and using QFont:setPixelSize isn't accurate. Here is some code: View::View(QWidget *parent) : QWidget(parent), printer(new QPrinter) { printer->setPaperSize(QPrinter::A4); printer->setFullPage(true); } void View::paintEvent(QPaintEvent*) { QPainter painter(this); painter.setWindow(0, 0, 2100, 2970); painter.setViewport(0, 0, printer->width(), printer->height()); // Draw a rect at x = 1cm, y = 1cm, 6cm wide and 1 inch high painter.drawRect(100, 100, 600, 254); // Create a 72pt (1 inch) high font QFont font("Arial"); font.setPixelSize(254); painter.setFont(font); // Draw in the same box // The font is too large painter.drawText(QRect(100, 100, 600, 254), tr("Wg\u0102")); // Ack - the actual font size reported by the metrics is 283 pixels! const QFontMetrics fontMetrics = painter.fontMetrics(); qDebug() << "Font height = " << fontMetrics.height(); } So I'm asking for a 254 high font (1 inch, 72 pts) and it's too big and sure enough when I query for the font height via QFontMetrics it is 283 high. Does anyone else know how to use font sizes in points when using custom mapping modes like this? It must be possible. Note that I cannot see how to convert between logical/device points either (i.e. the Win32 DPtoLP/LPtoDP equivalents.)

    Read the article

  • What are the advantages to use StringBuilder versus XmlDocument or related to create XML documetns?

    - by Rob
    This might be a bit of a code smell, but I have seen it is some production code, namely the use of StringBuilder as opposed to XmlDocument when creating XML documents. In some cases these are write once operations (e.g. create the document and save it to disk) where as others are passing the built string to an XmlDocument to preform an XslTransform to a document that is returned to the client. So obvious question: is there merit to doing things this way, is it something that should be done on a case-by-case basis, or is this the wrong way of doing things?

    Read the article

  • UIPickerView didSelectRow delay

    - by Rob Bonner
    Hello all, I have a UIPickerView implemented in one of my pages that depends on the didSelectRow delegate method. An odd behavior I have noticed is when the user moves a wheel and leaves it between selections, then the wheel will move very slowly to the closest selection. The didSelectRow event will not fire until this is complete, sometimes 3 seconds later. Is there a way to speed this up, or detect when the wheel is being moved, so I can freeze my interface during this time?

    Read the article

  • Why doesn't Request.IsAjaxRequest() work in ASP.NET MVC 3?

    - by Rob Ellis
    I'm creating a new project, asp.net mvc3 with Razor, and wanting to turn the LogOn into an ajax request. HTML @using (Ajax.BeginForm("LogOn", "Account", new AjaxOptions { HttpMethod="post", OnSuccess="LoginSubmitted"})) { } Controller if (Request.IsAjaxRequest()) { return Json(new { ResultMessage = "Username or password provided is incorrect"}); } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } Everything else remains the same. First, looking at the the http response with Fiddler, I notice there is no x-requested-with header. So I add <input type="hidden" name="X-Requested-With" value="XMLHttpRequest" /> That seems to work, but now what I receive back is a Json object, which isn't being parsed and instead Google Chrome is just rendering the Json to screen. Whats happening?

    Read the article

  • Convert this PHP code to C#

    - by Rob
    I've got this php code and I'd like to get the exact equivalent C# $ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_192, MCRYPT_MODE_CBC); $iv = mcrypt_create_iv($ivSize, MCRYPT_RAND); $encryptedData = mcrypt_encrypt(MCRYPT_RIJNDAEL_192, $key, $salt . $message . $nonce, MCRYPT_MODE_CBC, $iv); $base64Data = base64_encode($salt . $iv . $encryptedData); $urlEncodedData = rawurlencode($base64Data); all contributions gratefully received

    Read the article

  • selenium cannot find element with class in IE

    - by Rob
    I'm using selenium_client with cucumber, webrat + IE As you'd expect, Firefox works fine. I've tried the following: selenium.is_visible("css=#flash .flash_notice") selenium.is_visible("xpath=//*[@id='flash']/*[@class='flash_notice]") selenium.is_visible("xpath=//*[@id='flash']/*[contains(@class,'flash_notice]')") both cannot find the element. I think it must be something to do with IE, looking closer at the html selenium returns from IE... It looks like this: <UL id=flash> <LI className=flash_notice>Deleted</LI> </UL> Notice IE returns the class attribute as className, is this confusing selenium? How can I get round this so that I can use the same statement for selenium using IE and Firefox Just to confuse us even more, this example works, confirming its something to do with checking the class attribute selenium.is_visible("xpath=//*[@id='flash']/*[. =\'Deleted\']")

    Read the article

  • Adorning a non-DependencyObject with a DependencyProperty

    - by Rob
    I'm trying to bind to a WinForms control's DataSource property in my WPF application but I'm not having much luck... Falafel.com gives it a shot, but although it claimes that a DependencyObject is not required to perform the binding, that seems to be the only way of doing it. Has anyone done this before?

    Read the article

  • Unable to output XML data in a manageable way

    - by Rob
    I've been given data from a previous version of a website (it was a custom CMS) and am looking to get it into a state that I can import it into my Wordpress site. This is what I'm working on - http://www.teamworksdesign.com/clients/ciw/datatest/index.php. If you scroll down to row 187 the data starts to fail (there should be a red message) with the following error message: Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/teamwork/public_html/clients/ciw/datatest/index.php:132 Stack trace: #0 /home/teamwork/public_html/clients/ciw/datatest/index.php(132): SimpleXMLElement-__construct(' Can anyone see what the problem is and how to fix it? This is how I'm outputting the date: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <?php ini_set('memory_limit','1024M'); ini_set('max_execution_time', 500); //300 seconds = 5 minutes echo "<br />memory_limit: " . ini_get('memory_limit') . "<br /><br />"; echo "<br />max_execution_time: " . ini_get('max_execution_time') . "<br /><br />"; libxml_use_internal_errors(true); $z = new XMLReader; $z->open('dbo_Content.xml'); $doc = new DOMDocument; $doc->preserveWhiteSpace = false; // move to the first <product /> node while ($z->read() && $z->name !== 'dbo_Content'); $c = 0; // now that we're at the right depth, hop to the next <product/> until the end of the tree while ($z->name === 'dbo_Content') { if($c < 201) { // either one should work $node = simplexml_import_dom($doc->importNode($z->expand(), true)); if($node->ClassId == 'policydocument') { $c++; echo "<h1>Row: $c</h1>"; echo "<pre>"; echo htmlentities($node->XML) . "<br /><br /><br /><b>*******</b><br /><br /><br />"; echo "</pre>"; try{ $xmlObject = new SimpleXMLElement($node->XML); foreach ($xmlObject->fields[0]->field as $field) { switch((string) $field['name']) { case 'parentId': echo "<b>PARENT ID: </b> " . $field->value . "<br />"; break; case 'title': echo "<b>TITLE: </b> " . $field->value . "<br />"; break; case 'summary': echo "<b>SUMMARY: </b> " . $field->value . "<br />"; break; case 'body': echo "<b>BODY:</b> " . $field->value . "<br />"; break; case 'published': echo "<b>PUBLISHED:</b> " . $field->value . "<br />"; break; } } echo '<br /><h2 style="color:green;">Success on node: '.$node->ContentId.'</h2><hr /><br />'; } catch (Exception $e){ echo '<h2 style="color:red;">Failed on node: '.$node->ContentId.'</h2>'; } } // go to next <product /> $z->next('dbo_Content'); } } ?> </body> </html>

    Read the article

< Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >