Daily Archives

Articles indexed Friday May 14 2010

Page 5/116 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • C++ using typedefs in non-inline functions

    - by ArunSaha
    I have a class like this template< typename T > class vector { public: typedef T & reference; typedef T const & const_reference; typedef size_t size_type; const_reference at( size_t ) const; reference at( size_t ); and later in the same file template< typename T > typename vector<T>::const_reference // Line X vector<T>::at( size_type i ) const { rangecheck(); return elems_[ i ]; } template< typename T > reference // Line Y vector<T>::at( size_type i ) { rangecheck(); return elems_[ i ]; } Line X compiles fine but Line Y does not compile. The error message from g++ (version 4.4.1) is: foo.h:Y: error: expected initializer before 'vector' From this I gather that, if I want to have non-inline functions then I have to fully qualify the typedef name as in Line X. (Note that, there is no problem for size_type.) However, at least to me, Line X looks clumsy. Is there any alternative approach?

    Read the article

  • Checking for any lowercase letters in a string

    - by pcampbell
    Consider a JavaScript method that needs to check whether a given string is in all uppercase letters. The input strings are people's names. The current algorithm is to check for any lowercase letters. var check1 = "Jack Spratt"; var check2 = "BARBARA FOO-BAR"; var check3 = "JASON D'WIDGET"; var isUpper1 = HasLowercaseCharacters(check1); var isUpper2 = HasLowercaseCharacters(check2); var isUpper3 = HasLowercaseCharacters(check3); function HasLowercaseCharacters(string input) { //pattern for finding whether any lowercase alpha characters exist var allLowercase; return allLowercase.test(input); } Is a regex the best way to go here? What pattern would you use to determine whether a string has any lower case alpha characters?

    Read the article

  • Lot of time spent with following waits 'SQL*Net message from client' and 'wait for unread message on

    - by Shravan
    My application that wraps around Oracle Data pump's executables IMPDP and EXPDP takes random amounts of time for the same work. On further investigation, I see it waiting for again random amounts of time with the event 'wait for unread message on broadcast channel'. This makes the application take anytime b/w 10 minutes to over an hour for the same work. I fail to understand if this has something to do with the way my application uses these executables, or it has got something to do with Load on my server or something totally alien to me.

    Read the article

  • Javascript: Uncaught exception: "too few args"

    - by Rosarch
    I think I must be making some really stupid mistake. I'm using the latest version of jQuery to write an AJAX app. function refreshGPAForTerm(term) { var meta_data = term.children('.' + TERM_META_DATA_CLASS); meta_data.children('.' + MEDIAN_GPA_CLASS).fadeOut('slow').remove(); meta_data.append(_getMedianGPAElem(term.data('GPA'))).hide().fadeIn('slow'); } function moveToTerm(original_course, helper, term) { var cloned_course = original_course.clone(true); term.data('credits', term.data('credits') + cloned_course.data('credits')); term.data('median_GPA', term.data('median_GPA') + cloned_course.data('credits') * cloned_course.data('GPA')); // error here refreshGPAForTerm(term); refreshCreditForTerm(term); original_course.addClass('already-scheduled'); original_course.draggable('disable'); cloned_course.appendTo(term).hide().fadeIn('slow').draggable(); } When refreshGPAForTerm(term) is called, Firebug displays: "Uncaught exception - Too few arguments". Stepping through in a debugger, the code then goes into jQuery. Why is this happening? What am I doing wrong?

    Read the article

  • Simple way to use Foreign Key values for sorting?

    - by Brian Rizzo
    Disclaimer: I jumped to C# 2008 recently and SubSonic 3 (3.0.0.4) at the same time. I haven't used Linq for much of anything in the past. Is there an easy way to use the foreign key display value for sorting, rather than the FK Id (which is numeric)? I've added a new Find method in my ActiveRecord.tt to help with sorting based on a string field name but after doing some testing I realized that even though its working as it should be, I am not handling foreign key fields at all (they are just sorting by their value). Even if I need to change how I am accessing the data it is early enough in the project to do that. Just looking for suggestions.

    Read the article

  • Cakephp Insert Ignore Feature?

    - by SeanDowney
    Is there a way to do an "insert ignore" in cake without using a model-query function? $this->Model->save(array( 'id' => NULL, 'guid' => $guid, 'name' => $name, )); Generates error: Warning (512): SQL Error: 1062: Duplicate entry 'GUID.....' for key 'unique_guid' [CORE/cake/libs/model/datasources/dbo_source.php, line 524] It would be great to be able to set some flag or option that says "don't care"

    Read the article

  • Why would the assignment operator ever do something different than its matching constructor?

    - by Neil G
    I was reading some boost code, and came across this: inline sparse_vector &assign_temporary(sparse_vector &v) { swap(v); return *this; } template<class AE> inline sparse_vector &operator=(const sparse_vector<AE> &ae) { self_type temporary(ae); return assign_temporary(temporary); } It seems to be mapping all of the constructors to assignment operators. Great. But why did C++ ever opt to make them do different things? All I can think of is scoped_ptr?

    Read the article

  • Google Maps custom marker - can the iframe accept one like the static maps?

    - by alex
    I was reading the static maps API, and it says you can include a custom marker in the GET params. You simply link to an image file. I now have a second Google Map within an iframe, and was wondering if you can attach custom markers via the GET params to it? Here is the src attribute of the iframe currently. http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=111+Fake+Street+Noosaville+Queensland+Australia&ie=UTF8&output=embed I can't seem to find the documentation on how to do this, if possible. Is this possible?

    Read the article

  • Using boost::asio::async_read with stdin?

    - by yeus
    hi poeple.. short question: I have a realtime-simulation which is running as a backround process and is connected with pipes to the calling pogramm. I want to send commands to that process using stdin to get certain information from it via stdout. Now because it is a real-time process, it has to be a non blocking input. Is boost::asio::async_read in conjunction with iostream::cin a good idea for this task? how would I use that function if it is feasible? Any more suggestions?

    Read the article

  • Search object array for matching possible multiple values using different comparison operators

    - by Sparkles
    I have a function to search an array of objects for a matching value using the eq operator, like so: sub find { my ( $self, %params ) = @_; my @entries = @{ $self->{_entries} }; if ( $params{filename} ) { @entries = grep { $_->filename eq $params{filename} } @entries; } if ( $params{date} ) { @entries = grep { $_->date eq $params{date} } @entries; } if ( $params{title} ) { @entries = grep { $_->title eq $params{title} } @entries; } .... I wanted to also be able to pass in a qr quoted variable to use in the comparison instead but the only way I can think of separating the comparisons is using an if/else block, like so: if (lc ref($params{whatever}) eq 'regexp') { #use =~ } else { #use eq } Is there a shorter way of doing it? Because of reasons beyond my control I'm using Perl 5.8.8 so I can't use the smart match operator. TIA

    Read the article

  • Port iPhone application to Android

    - by wgpubs
    What is the most efficient way to port an iPhone app to Android? I know Apple doesn't like 3rd-party, non-Objective C platforms generating code for their platform ... but is there something out there that can take an iPhone app and convert it to Android friendly code? If not, how have folks out there been creating Android versions of their existing iPhone apps? Thanks

    Read the article

  • Double script tags in Google Analytics tracking code

    - by Tom
    This is more a curiosity question than anything else... Google instructs to add the analytics tracking code as follows: <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try{ var pageTracker = _gat._getTracker("UA-xxxxxx-x"); pageTracker._trackPageview(); } catch(err) {} </script> I'm wondering some JS guru here could tell me why they're separating it into two script tags instead of sticking it all inside one. I know that the top part could be put in the header and the bottom part just before body tag to ensure the page loaded before it's tracked, but I'm wondering if there's something more to it. Anyone who'd know that would likely know how to separate the code into two tags anyway. I'm only asking as this is coming from the Goog and is being used by millions of sites... Thanks

    Read the article

  • Free SEO Analysis using IIS SEO Toolkit

    - by The Official Microsoft IIS Site
    In my spare time I’ve been thinking about new ideas for the SEO Toolkit , and it occurred to me that rather than continuing trying to figure out more reports and better diagnostics against some random fake sites, that it could be interesting to ask openly for anyone that is wanting a free SEO analysis report of your site and test drive some of it against real sites. So what is in it for you, I will analyze your site to look for common SEO errors, I will create a digest of actions to do and other...(read more)

    Read the article

  • Modify database for the SharePoint 2010 Enterprise Search administration web site

    - by Mark Hall
    Does anyone know how to modify the database settings for the Enterprise Search administration web site? When you configure the service application via Central Administration, SharePoint just decides to use the default database server and gives a name like Enterprise_Search_DB_Identifier. I want to modify this to atleast give a name that makes scense like SharePoint_Search_AdministrationWebContent, and it might be nice to move it to the database server that is hosting the crawl and property database. I figured out how to move the Central Administration web content database, but this database is not listed as a content database. It is listed as a Microsoft.Office.Server.Search.Administration.SearchAdminDatabase. I have not tested to see if the same process would work but because you are doing a RemoveContentDatabase and NewContentDatabase, I would assume not. Any help would be appreciated.

    Read the article

  • Power supply issue? New Radeon5850's fan runs at full speed and PC doesn't boot.

    - by Kris
    I recently bought a new ASUS EAH5850 graphics board. I installed it a custom PC which had an ASUS p5n-e SLI mobo along with a 500w Thermaltake W0093RU power supply. Sometimes when doing a cold boot the 5850's fan will run at full speed and the PC will not boot. Powering off by holding down the power button and powering back on sometimes remedies the situation and everything boots normally. Warm reboots also never seem to have problems. For some reason though cold boots almost always do. Another issue I notice is that when the PC does boot normally it takes longer (+30 secs) to POST than with my last video card. I flashed the mobo with the latest available BIOS but it had no effect. Is my problem a power issue or incompatible motherboard or something else I'm missing?

    Read the article

  • Sending and receiving async over multiprocessing.Pipe() in Python

    - by dcolish
    I'm having some issues getting the Pipe.send to work in this code. What I would ultimately like to do is send and receive messages to and from the foreign process while its running in a fork. This is eventually going to be integrated into a pexpect loop for talking to interpreter processes. ` from multiprocessing import Process, Pipe def f(conn): cmd = '' if conn.poll(): cmd = conn.recv() i = 1 i += 1 conn.send([42 + i, cmd, 'hello']) if __name__ == '__main__': parent_conn, child_conn = Pipe() p = Process(target=f, args=(child_conn,)) p.start() from pdb import set_trace; set_trace() while parent_conn.poll(): print parent_conn.recv() # prints "[42, None, 'hello']" parent_conn.send('OHHAI') p.join() `

    Read the article

  • Should a Perl constructor return an undef or a "invalid" object?

    - by DVK
    Question: What is considered to be "Best practice" - and why - of handling errors in a constructor?. "Best Practice" can be a quote from Schwartz, or 50% of CPAN modules use it, etc...; but I'm happy with well reasoned opinion from anyone even if it explains why the common best practice is not really the best approach. As far as my own view of the topic (informed by software development in Perl for many years), I have seen three main approaches to error handling in a perl module (listed from best to worst in my opinion): Construct an object, set an invalid flag (usually "is_valid" method). Often coupled with setting error message via your class's error handling. Pros: Allows for standard (compared to other method calls) error handling as it allows to use $obj->errors() type calls after a bad constructor just like after any other method call. Allows for additional info to be passed (e.g. 1 error, warnings, etc...) Allows for lightweight "redo"/"fixme" functionality, In other words, if the object that is constructed is very heavy, with many complex attributes that are 100% always OK, and the only reason it is not valid is because someone entered an incorrect date, you can simply do "$obj->setDate()" instead of the overhead of re-executing entire constructor again. This pattern is not always needed, but can be enormously useful in the right design. Cons: None that I'm aware of. Return "undef". Cons: Can not achieve any of the Pros of the first solution (per-object error messages outside of global variables and lightweight "fixme" capability for heavy objects). Die inside the constructor. Outside of some very narrow edge cases, I personally consider this an awful choice for too many reasons to list on the margins of this question. UPDATE: Just to be clear, I consider the (otherwise very worthy and a great design) solution of having very simple constructor that can't fail at all and a heavy initializer method where all the error checking occurs to be merely a subset of either case #1 (if initializer sets error flags) or case #3 (if initializer dies) for the purposes of this question. Obviously, choosing such a design, you automatically reject option #2.

    Read the article

  • How do I use accepts_nested_attributes_for? I cannot use the .build method (!)

    - by Angela
    Editing my question for conciseness and to update what I've done: How do I model having multiple Addresses for a Company and assign a single Address to a Contact, and be able to assign them when creating or editing a Contact? Here is my model for Contacts: class Contact < ActiveRecord::Base attr_accessible :first_name, :last_name, :title, :phone, :fax, :email, :company, :date_entered, :campaign_id, :company_name, :address_id, :address_attributes belongs_to :company belongs_to :address accepts_nested_attributes_for :address end Here is my model for Address: class Address < ActiveRecord::Base attr_accessible :street1, :street2, :city, :state, :zip has_many :contacts end I would like, when creating an new contact, access all the Addresses that belong to the other Contacts that belong to the Company. So here is how I represent Company: class Company < ActiveRecord::Base attr_accessible :name, :phone, :addresses has_many :contacts has_many :addresses, :through => :contacts end Here is how I am trying to create a field in the View for _form for Contact so that, when someone creates a new Contact, they pass the address to the Address model and associate that address to the Contact: <% f.fields_for :address, @contact.address do |builder| %> <p> <%= builder.label :street1, "Street 1" %> </br> <%= builder.text_field :street1 %> <p> <% end %> When I try to Edit, the field for Street 1 is blank. And I don't know how to display the value from show.html.erb. At the bottom is my error console -- can't seem to create values in the address table: My Contacts controller is as follows: def new @contact = Contact.new @contact.address.build # I GET AN ERROR HERE: says NIL CLASS @contact.date_entered = Date.today @campaigns = Campaign.find(:all, :order => "name") if params[:campaign_id].blank? else @campaign = Campaign.find(params[:campaign_id]) @contact.campaign_id = @campaign.id end if params[:company_id].blank? else @company = Company.find(params[:company_id]) @contact.company_name = @company.name end end def create @contact = Contact.new(params[:contact]) if @contact.save flash[:notice] = "Successfully created contact." redirect_to @contact else render :action => 'new' end end def edit @contact = Contact.find(params[:id]) @campaigns = Campaign.find(:all, :order => "name") end Here is a snippet of my error console: I am POSTING the attribute, but it is not CREATING in the Address table.... Processing ContactsController#create (for 127.0.0.1 at 2010-05-12 21:16:17) [POST] Parameters: {"commit"="Submit", "authenticity_token"="d8/gx0zy0Vgg6ghfcbAYL0YtGjYIUC2b1aG+dDKjuSs=", "contact"={"company_name"="Allyforce", "title"="", "campaign_id"="2", "address_attributes"={"street1"="abc"}, "fax"="", "phone"="", "last_name"="", "date_entered"="2010-05-12", "email"="", "first_name"="abc"}} Company Load (0.0ms)[0m [0mSELECT * FROM "companies" WHERE ("companies"."name" = 'Allyforce') LIMIT 1[0m Address Create (16.0ms)[0m [0;1mINSERT INTO "addresses" ("city", "zip", "created_at", "street1", "updated_at", "street2", "state") VALUES(NULL, NULL, '2010-05-13 04:16:18', NULL, '2010-05-13 04:16:18', NULL, NULL)[0m Contact Create (0.0ms)[0m [0mINSERT INTO "contacts" ("company", "created_at", "title", "updated_at", "campaign_id", "address_id", "last_name", "phone", "fax", "company_id", "date_entered", "first_name", "email") VALUES(NULL, '2010-05-13 04:16:18', '', '2010-05-13 04:16:18', 2, 2, '', '', '', 5, '2010-05-12', 'abc', '')[0m

    Read the article

  • Send jQuery array to PHP post?

    - by FFish
    I have a javascript function that gathers two arrays, imagepaths and captions. I want to send with PHP's post to the same page $_SERVER['PHP_SELF'], but I really don't know where to start.. PHP: if (isset($_POST['Submit'])) { $edit_photos->update_xml($edit_photos->album_id, $_POST['src_arr'], $_POST['caption_arr']); // prevent resending data header("Location: " . $_SERVER['PHP_SELF'] . "?ref=" . $ref); } JS: function getImgData() { var imgData = { 'src_arr': [], 'caption_arr': []}; $('.album img').each(function(index){ imgData.src_arr.push($(this).attr('src')); imgData.caption_arr.push($(this).attr('alt')); }); return imgData; }; HTML: <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF'] . "?ref=" . $ref; ?>">

    Read the article

  • ASP.NET 4.0 Routing and Subfolders

    - by IrishChieftain
    I have a folder structure like this: Site/About/About.aspx I have a link in a user control like this: <a href="~/About/About" id="aboutLink" title="About" runat="server">About</a> And in my RegisterRoutes() method, I have this: routes.MapPageRoute("", "About/About/", "~/About/About.aspx"); It works but produces the following URL: Site/About/About What I would like is this: Site/About Is this possible with out-of-the-box 4.0 routing?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >