Daily Archives

Articles indexed Friday March 19 2010

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

  • c# - Library to write javascript code

    - by Melursus
    Is there a c# library that can help to write and indent Javascript code. It's because I'm writing some c# code that generated some Javascript code. Something like this : js += "<script type=\"text/javascript\">\n"; js += " function()...\n"; And I find that generated a lot of ugly code. So, I thought that maybe a existing library can help me doing that ?

    Read the article

  • How to get Nokogiri to ignore HTML elements that doesn't exist

    - by user296507
    any idea how i can get the code below to produce this output? 1 - 2 - B i'm getting this error "undefined method `text' for nil:NilClass (NoMethodError)", because i think table 1 does not have the element 'td class=r2' in it. require 'rubygems' require 'nokogiri' require 'open-uri' doc = Nokogiri::HTML.parse(<<-eohtml) <table class="t1"> <tbody> <tr> <td class="r1">1</td> </tr> </tbody> </table> <table class="t2"> <tbody> <tr> <td class="r1">2</td> <td class="r2">B</td> </tr> </tbody> </table> eohtml doc.css('tbody > tr').each do |n| r1 = n.at_css(".r1").text r2 = n.at_css(".r2").text puts "#{r1} - #{r2}" end

    Read the article

  • Refining Search Results [PHP/MySQL]

    - by Dae
    I'm creating a set of search panes that allow users to tweak their results set after submitting a query. We pull commonly occurring values in certain fields from the results and display them in order of their popularity - you've all seen this sort of thing on eBay. So, if a lot of rows in our results were created in 2009, we'll be able to click "2009" and see only rows created in that year. What in your opinion is the most efficient way of applying these filters? My working solution was to discard entries from the results that didn't match the extra arguments, like: while($row = mysql_fetch_assoc($query)) { foreach($_GET as $key => $val) { if($val !== $row[$key]) { continue 2; } } // Output... } This method should hopefully only query the database once in effect, as adding filters doesn't change the query - MySQL can cache and reuse one data set. On the downside it makes pagination a bit of a headache. The obvious alternative would be to build any additional criteria into the initial query, something like: $sql = "SELECT * FROM tbl MATCH (title, description) AGAINST ('$search_term')"; foreach($_GET as $key => $var) { $sql .= " AND ".$key." = ".$var; } Are there good reasons to do this instead? Or are there better options altogether? Maybe a temporary table? Any thoughts much appreciated!

    Read the article

  • How to handle multiple delegates

    - by mac_55
    I've got a view in my app that does pretty much everything, and I like it that way. The problem however is that it's implementing 5 or 6 different delegates, which seems a little bit messy. My question is, does the view controller have to implement all of the delegates? or is there some way I can separate the code out into different files (without having to do a major restructure or rewrite)? Here's all the delegates I'm implementing: @interface MyView : UIViewController <UIScrollViewDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIActionSheetDelegate, MFMailComposeViewControllerDelegate>

    Read the article

  • dojox.grid.DataGrid can't display repeat rows?

    - by Robert
    We have a situation where we need to display data from a database in a grid which has repeat rows, but it seems at least the basic examples fail when the cell data is identical with Sorry, an error occurred. An example follows: <script dojo.require("dojo.data.ItemFileWriteStore"); dojo.require("dojox.grid.DataGrid"); var historyData = { 'identifier': 'time', 'label': 'time', 'items': [ { 'message': 'Please turn in your TPS reports immediately', 'time': 'March 3 2010 7:20 AM', 'sentBy':'Bill Lumbergh' }, { 'message': 'Please turn in your TPS reports immediately', 'time': 'March 3 2010 7:20 AM', 'sentBy':'Bill Lumbergh' }] }; var historyGridLayout = [ [{ field: "message", name: "Message" }, { field: "time", name: "Display Date & Time" }, { field: "sentBy", name: "Sent By" }]]; </script <body class="tundra " <div dojoType="dojo.data.ItemFileWriteStore" data="historyData" jsId="historyStore" </div <div id="grid" dojoType="dojox.grid.DataGrid" store="historyStore" structure="historyGridLayout" </div </body Help!

    Read the article

  • Why are my attempts to open a file using open for writing failing? Ada 95

    - by mat_geek
    When I attempt to open a file to write to I get an Ada.IO_Exceptions.Name_Error. The procedure call is Ada.Text_IO.Open The file name is "C:\CC_TEST_LOG.TXT". This file does not exist. This is on Windows XP on an NTFS partition. The user has permissions to create and write to the directory. The filename is well under the WIN32 max path length. name_2 : String := "C:\CC_TEST_LOG.TXT" if name_2'last > name_2'first then begin Ada.Text_IO.Open(file, Ada.Text_IO.Out_File, name_2); Ada.Text_IO.Put_Line( "CC_Test_Utils: LogFile: ERROR: Open, File " & name_2); return; exception when The_Error : others => Ada.Text_IO.Put_Line( "CC_Test_Utils: LogFile: ERROR: Open Failed; " & Ada.Exceptions.Exception_Name(The_Error) & ", File " & name_2); end; end if;

    Read the article

  • Why do I get two clicked or released signals when using a custom slot for a QPushButton ?

    - by Chris
    here's the main code at first I thought is was the message box but setting a label instead has the same effect. #include <time.h> #include "ui_mainwindow.h" #include <QMessageBox> class MainWindow : public QWidget, private Ui::MainWindow { Q_OBJECT public: MainWindow(QWidget *parent = 0); void makeSum(void); private: int r1; int r2; private slots: void on_pushButton_released(void); }; MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { setupUi(this); } void MainWindow::on_pushButton_released(void) { bool ok; int a = lineEdit->text().toInt(&ok, 10); if (ok) { if (r1+r2==a) { QMessageBox::information( this, "Sums","Correct!" ); } else { QMessageBox::information( this, "Sums","Wrong!" ); } } else { QMessageBox::information( this, "Sums","You need to enter a number" ); } makeSum(); } void MainWindow::makeSum(void) { r1 = rand() % 10 + 1; r2 = rand() % 10 + 1; label->setText(QString::number(r1)); label_3->setText(QString::number(r2)); } int main(int argc, char *argv[]) { srand ( time(NULL) ); QApplication app(argc, argv); MainWindow mw; mw.makeSum(); mw.show(); return app.exec(); } #include "main.moc"

    Read the article

  • Consuming "Event Tracing for Windows" events

    - by Paul Baker
    An answer to this question has led me to look into using "Event Tracing for Windows" for our tracing needs. I have come across NTrace, which seems to be a good way to produce ETW events from C# code (using the XP-compatible "classic provider" model). However, I am unable to find an easy way to consume these events - to see them in real-time and/or log them to a file. The only way I have found is that described in the NTrace documentation: using a tool which is only available as part of the Windows DDK. In the case of a complex problem in the field, we may need to ask the user to produce a file containing a trace. We can't ask users to download the DDK or carry out a number of complex operations in order to do this. Is there a straightforward, user-friendly way to log ETW events to a file? Also, is it possible for someone to consume ETW events on Windows Vista/7 if they are not running as administrator?

    Read the article

  • ABCpdf7 Not Rendering Images using AddImageUrl

    - by ddango
    Fairly exotic it seems to me. We recently upgraded/migrated from Windows Server 2003 to 2008, and now it seems that images cannot be rendered when using Doc.AddImageUrl(). (when the pdf is saved, the images appear at the correct dimensions, but the IE8 missing image x shows up). If I understand correctly, ABCpdf uses IE rendering internally for this sort of thing. We thought it might be a permission issue, but we've check IE ESC and that seems to be configured as they suggest. Has anyone else run into a similar problem? Perhaps a code configuration is needed? Not the entire snippet, but the ABCpdf7 stuff: using (Doc doc = new Doc()) { doc.HtmlOptions.PageCacheEnabled = false; doc.HtmlOptions.UseNoCache = true; doc.HtmlOptions.PageCacheClear(); doc.HtmlOptions.PageCachePurge(); doc.HtmlOptions.UseResync = true; doc.HtmlOptions.ImageQuality = 25; int pageID = doc.AddImageUrl(url + "&guid=" + url.GetHashCode()); while (true) { if (!doc.Chainable(pageID)) break; doc.Page = doc.AddPage(); pageID = doc.AddImageToChain(pageID); } // file saving etc. }

    Read the article

  • Error C2451: Illegal conditional expression of type 'UnaryOp<E1, Op>' in ostream - visual studio 9

    - by Steven Hill
    I am getting a repeated error with VS 9. The code compiles under GNU C++, but I want debug with the VS IDE. Any idea what could be causing this error. Error 13 error C2451: conditional expression of type 'UnaryOp' is illegal \Microsoft Visual Studio 9.0\VC\include\ostream 512 //unary constraint template class UnaryOp : public Constraint { public: const E1& e1; UnaryOp(const E1& _e1); bool Satisfiable() const; Bool SatisfiableAux() const; void Print (std::ostream& os) const; UnaryOp* clone () const; //operator bool () const { return true; } }; template std::ostream& operator<<(std::ostream& os, const UnaryOp& unop); UnaryOp code that uses ostream: template INLINE void UnaryOp::Print (std::ostream& os) const { os << *this; } template INLINE std::ostream& operator<<(std::ostream& os, const UnaryOp& unop) { return os << Op::name << unop.e1; } ostream line with error: _Myt& __CLR_OR_THIS_CALL put(_Elem _Ch) { // insert a character ios_base::iostate _State = ios_base::goodbit; const sentry _Ok(*this); 512 if (!_Ok) _State |= ios_base::badbit; else { // state okay, insert character _TRY_IO_BEGIN

    Read the article

  • How can I make my Ruby on Rails 2.3.4 application "Rails 3-ready"

    - by marcgg
    I'm developing an application with Ruby on Rails that I want to maintain for at least a few years, so I'm concerned about the next version coming up soon. Going from Rails 1 to Rails 2 was such a big pain that I didn't bother and froze my gems and let the application die, alone, in the dark. On this project I don't want to do that. First because this new version looks awesome, but also because this application may turn into a real product. How can I prepare my application so that it will be upgradable with as little changes as possible. How time consuming do you think switching version will be? And what about my server? Deployment? I'm already looking at deprecation notices... what else can I do?

    Read the article

  • Extending Programming Languages

    - by chpwn
    (Since I just posted this in another question, but my browser had to be annoying and submit it without content first, here it is again:) I'm a fan of clean code. I like my languages to be able to express what I'm trying to do, but I like the syntax to mirror that too. For example, I work on a lot of programs in Objective-C for jailbroken iPhones, which patch other code using the method_setImplementation() function of the runtime. Or, in pyobjc, I have to use the syntax UIView.initWithFrame_(), which is also pretty awful and unreadable with the way the method names are structured. In both cases, the language does not support this in syntax. I've found three basic ways that this is done: Insane macros. Take a look at this "CaptainHook", it does what I'm looking for in a usable way, but it isn't quite clean and is a major hack. There's also "Logos", which implements a very nice syntax, but is written in Perl parsing my code with a ton of regular expressions. This scares me. I like the idea of adding a %hook ClassName, but not by using regular expressions to parse C or Objective-C. Finally, there is Cycript. This is an extension to JavaScript which interfaces with the Objective-C runtime and allows you to use Objective-C style code in your JavaScript, and inject that into other processes. This is likely the cleanest as it actually uses a parser for the JavaScript, but I'm not a huge fan of that language in general. Basically, this is a two part question. Should, and how should, I create an extension to Python and Objective-C to allow me to do this? Is it worth writing a parser for my language to transform the syntax into something nicer, if it is only in a very specialized niche like this? Should I just live with the horrible syntax of the default Objective-C hooking or pyobjc?

    Read the article

  • Disable integrated client certificate validation in IIS7?

    - by danford
    We have an IIS 7 hosted site that requires client certificates (two-way ssl). Unfortunately, I don't have access to the trusted certificate store on the host machines, and so I was forced to write a custom http module to verify the certificates. My module never gets a chance to do the authentication, however, because IIS doesn't recognize the certificates and responds with a 403.7 error. How do I turn off client certificate validation, while still requiring clients to provide them?

    Read the article

  • Creating a MSI patch (.msp) by hand?

    - by Jerry Chong
    Our team has recently been considering pushing out a minor registry fix to users to modify one particular problematic key. Pretty straightforward stuff, just needed to update 1 key/value inside the registry. So at the moment, we are using Wix to build .msi installers for the product. While looking into Wix's support for generating .msp patch files, it seems that the only way to create an .msp is a somewhat overcomplicated multi-step process to: Get a copy of the original MSI, and compile a new copy of the fixed MSI Write a new Wix file that points to both installers Compile the Wix file into a .wixobj with Candle to a .psp Run Torch/Pyro over before/after snapshots of the original installers and the .psp, or alternatively using MsiMsp.exe Now my question is, can't I simply describe the registry change into a Wix file and directly compile it into the .msp, without step 1 and 4 - which is a huge amount of effort for just a simple change?

    Read the article

  • ASP.Net Response Filter Causing SharePoint 2010 "Unexpected Error"

    - by Jason Weber
    Hello everyone, I'm debugging an HttpModule with an ASP.NET response filter. This dynamically rewrites portions of rendered SharePoint WCM pages. The publishing pages render fine in SP2007 on both Server 2003 and Server 2008. However the equivalent pages fail to render in SP2010 B2 on Server 2008 R2. The generic "An unexpected error has occurred message" page is displayed. This error only happens when the response filter is applied to an .aspx page. Other page types, such as .css, render fine on this platform. This error also happens when the response filter does not modify the page at all (pure pass-through). This KB article seems very closely related: http://support.microsoft.com/kb/2014472. However, this same error occurs with caching disabled. I see no related entries in any of the following: ULS for SP, Event Log, Failed Request Tracing (IIS7). Running under the debugger suggests that the custom code is not raising any exceptions. Any help or insight would be greatly appreciated.

    Read the article

  • showing progressbar progress with ajax request

    - by Ygam
    Hi guys! I want to show progress with jquery ui progress bar when an ajax request fires and when it finishes. The problem is I don't know how to set values for the progress bar depending on the progress of the ajax request. Please hlep. Here's a code to start with: function ajaxnews() { $('.newstabs a').click(function(e){ var section = $(this).attr('id'); var url = base + 'news/section/' + section; $.ajax({ url : url, dataTye : 'html', start : loadNews, success : fillNews }); }); } // start callback functions function loadNews() { $('#progressbar').fadeIn(); $('#progressbar').progressbar({ //how shoud I set the values here}); } function fillNews() { $('#progressbar').progressbar('option', 'value', ?? /* how do I find this?*/); $('#progressbar').fadeOut(); }

    Read the article

  • Preset value of HTML Forms

    - by laura
    Hi. I'm trying to preset the value of a dropdown menu and the value of a text box in an HTML form. As soon as the user taps the button in my iPhone app, it enters the webview and I was hoping to preset one of the dropdown menus and text field. How do I go about this? I want to set the dropdown to value "4" and the text field to "Giro Apps" Here's the relevant HTML form code: <select id="advSrcId" class="list" onchange="showOther($('advSrcId').options[$('advSrcId').selectedIndex].value)" name="advSrcId"> <option selected="" value="">Select</option> <option value="1">Google</option> <option value="2">Facebook</option> <option value="3">Friend Referral</option> <option value="4">Other</option> </select> <div id="otherAdvsrc" style=""> <p> Please give details here: <br/> <input class="text" type="text" value="" name="advsrc"/> <br/> </p> </div> TIA!

    Read the article

  • Async file uploads in Firefox reset on any DOM change

    - by Vibhu
    I'm pretty sure this is a Firefox or flash-related bug, but I just want to check if anyone has ran into this problem or knows how to fix it. Basically, we have a multi-file upload widget for our highly dynamic web app (think Gmail). We've tried both uploadify for jQuery, and YUI uploader. We've also tried taking those out of our app interface and putting them in an iFrame. What happens is that in the event of any DOM manipulation, even if the uploader is in an iFrame, be it a tab change (in our web app) that covers the iframe temporarily, or a block, etc., the uploader will stop its current upload. In the case of YUI uploader, it fires the "contentReady" event again. This ONLY happens in Firefox. IE and Chrome are fine. In case you are wondering, we really don't have any custom needs here. Just need to have multi-upload file support, and we need to give people free reign to tab around in our interface while an upload is in progress. It seems like Yahoo! and Gmail have both solved this problem. How? What are we doing wrong?

    Read the article

  • How to process AJAX requests more securely in PHP?

    - by animuson
    Ok, so I want to send AJAX requests to my website from my Flash games to process data, but I don't want people downloading them, decompiling them, then sending fake requests to be processed, so I'm trying to figure out the most secure way to process in the PHP files. My first idea was to use Apache's built in Authorization module to require a username and password to access the pages on a separate subdomain of my website, but then you'd have to include that username and password in the AJAX request anyway so that seems kind of pointless to even try. My current option looks pretty promising but I want to make sure it will work. Basically it just checks the IP address being sent using REMOTE_ADDR to make sure it's the IP address that my server runs on. <? $allowed = new Array("64.120.211.89", "64.120.211.90"); if (!in_array($_SERVER['REMOTE_ADDR'], $allowed)) header("HTTP/1.1 403 Forbidden"); ?> Both of those IP addresses point to my server. Things I'm worried about: 1) If I send a request from Flash/ActionScript, will that affect the IP address in any way? 2) Is it possible for malicious users to change the IP address that is being sent with REMOTE_ADDR to one of my IP addresses? Any other ways you would suggest that might be more secure?

    Read the article

  • Objective-C method not being called

    - by Matt S.
    It's either because of the fact I'm tired or because I'm doing it wrong, but for some reason I can't get it to call a method. Here's what I'm trying to call: -(void)newHighScore:(int)d Which right now just does an NSLog saying "yea I'm working!" I'm calling it like this: [highscore newHighScore:score]; highscore is what I called the HighScore class in the .h, and score is an int with the score.

    Read the article

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