Daily Archives

Articles indexed Friday April 23 2010

Page 18/115 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • how do I make a portable isnan/isinf function.

    - by monkeyking
    I've been using isinf,isnan functions on linux platforms which worked perfectly. But this didn't work on osx, so I decided to use std::isinf std::isnan which works on both linux and osx. But the intel compiler doesn't recognize it, and I guess its a bug in the intel compiler according to http://software.intel.com/en-us/forums/showthread.php?t=64188 So now I just want to avoid the hassle and define my own isinf,isnan implementation. Does anyone know how this could be done Thanks edit: I ended up doing this in my sourcecode for making isinf/isnan working #include <iostream> #include <cmath> #ifdef __INTEL_COMPILER #include <mathimf.h> #endif int isnan_local(double x) { #ifdef __INTEL_COMPILER return isnan(x); #else return std::isnan(x); #endif } int isinf_local(double x) { #ifdef __INTEL_COMPILER return isinf(x); #else return std::isinf(x); #endif } int myChk(double a){ std::cerr<<"val is: "<<a <<"\t"; if(isnan_local(a)) std::cerr<<"program says isnan"; if(isinf_local(a)) std::cerr<<"program says isinf"; std::cerr<<"\n"; return 0; } int main(){ double a = 0; myChk(a); myChk(log(a)); myChk(-log(a)); myChk(0/log(a)); myChk(log(a)/log(a)); return 0; }

    Read the article

  • How to Load Data from Text File in MySQL?

    - by Taz
    I have this file availableHere Fields are separated by space and newline starts at new line. I am using this command to load data mysql> LOAD DATA LOCAL INFILE 'C:\\Documents and Settings\\Scan\\My Documents\\Downloads\\images_en.nt\\Sample4.txt' INTO TABLE NER.Images FIELDS TERMINATED BY' ' LINES TERMINATED BY '\n';' Only one row is loaded and if I execute again No row is loaded. Where is the problem? Data can be modified to reformat if required.

    Read the article

  • MySQL UPDATE problem

    - by comma
    I know the following MySQL code is not correct can some help me fix this code to use both tables I'm trying to grab the id from learned_skills and skill_id from users_skills for AND skill_id = id Here is the MySQL code. SELECT learned_skills.*, users_skills.* UPDATE learned_skills SET skill = '$skill', experience = '$experience', years = '$years' WHERE user_id = '$user_id' AND skill_id = id

    Read the article

  • Can a page opt out of IIS 7 compression?

    - by Glen Little
    My pages are automatically being compressed by IIS7 with GZIP. That is great... but, for one particular page, I need to stream it to the user, using Response.Flush() when needed. But when the output is being compressed, the IIS server seems to collect all my output until the page is done before compressing and sending it to the client. That nullifies my attempt to Flush the content out to the user. Is there a way that I can have this one page opt out of the compression? One possible option I've determined that if I manually set the content type to one that does not match the IIS configuration at c:\windows\system32\inetsrv\config\applicationhost.config, then IIS will not compress it. Eg. Response.ContentType = "x-text/html". This works okay with IE8, as it falls back to display the HTML. But Firefox will ask the user what to do with the unknown file type. This could work, if there was another Mime Type I could use that browsers would accept as HTML, that is not matched in the applicationhost.config. For reference, these are the mime types that will be compressed: <add mimeType="text/*" enabled="true" /> <add mimeType="message/*" enabled="true" /> <add mimeType="application/x-javascript" enabled="true" /> <add mimeType="application/atom+xml" enabled="true" /> <add mimeType="application/xaml+xml" enabled="true" /> Others options? Are there other options to opt out of compression?

    Read the article

  • How to reduce redundant code when adding new c++0x rvalue reference operator overloads

    - by Inverse
    I am adding new operator overloads to take advantage of c++0x rvalue references, and I feel like I'm producing a lot of redundant code. I have a class, tree, that holds a tree of algebraic operations on double values. Here is an example use case: tree x = 1.23; tree y = 8.19; tree z = (x + y)/67.31 - 3.15*y; ... std::cout << z; // prints "(1.23 + 8.19)/67.31 - 3.15*8.19" For each binary operation (like plus), each side can be either an lvalue tree, rvalue tree, or double. This results in 8 overloads for each binary operation: // core rvalue overloads for plus: tree operator +(const tree& a, const tree& b); tree operator +(const tree& a, tree&& b); tree operator +(tree&& a, const tree& b); tree operator +(tree&& a, tree&& b); // cast and forward cases: tree operator +(const tree& a, double b) { return a + tree(b); } tree operator +(double a, const tree& b) { return tree(a) + b; } tree operator +(tree&& a, double b) { return std::move(a) + tree(b); } tree operator +(double a, tree&& b) { return tree(a) + std::move(b); } // 8 more overloads for minus // 8 more overloads for multiply // 8 more overloads for divide // etc which also has to be repeated in a way for each binary operation (minus, multiply, divide, etc). As you can see, there are really only 4 functions I actually need to write; the other 4 can cast and forward to the core cases. Do you have any suggestions for reducing the size of this code? PS: The class is actually more complex than just a tree of doubles. Reducing copies does dramatically improve performance of my project. So, the rvalue overloads are worthwhile for me, even with the extra code. I have a suspicion that there might be a way to template away the "cast and forward" cases above, but I can't seem to think of anything.

    Read the article

  • Why am I not getting correct result when I calculate exponent with ^ in C++?

    - by xbonez
    I am using Bode's formuala to calculate distance of nth planet from sun dist = (4 + 3*(2^(n-2)))/10 If I calculate the distance this way, I get the right values: dist[2] = ((4 + 3*1)/10.0) ; dist[3] = ((4 + 3*2)/10.0) ; dist[4] = ((4 + 3*4)/10.0) ; But doing it this way, gives me incorrect values: vector <double> dist(5); for (unsigned int i = 2; i < 5; i++) { dist[i] = ((4 + 3*(2^(3-2)))/10.0) ; } Why so?

    Read the article

  • Manage utorrent webui with a desktop app

    - by thegreyspot
    Hi! Is there a desktop application that lets you connect to a utorrent server? It would be nice to manage my torrents away from my browser. Also it would be nice to just open a .torrent file and make it upload the file to the server and start downloading. I tried to do some google searches but all it displays is how to setup webui... Thanks!

    Read the article

  • Increase Google SERP Rank by Improving Your PageRank

    Having a good search engines results page (SERP) rank is the goal of SEO, this means higher organic traffic, more visitors and increased conversion rate. But how do we improve our SERP rank specially with Google who provides more than 70% of relevant search results? Well one of them is improving your website's PageRank, if you think SERP and PR are not related, keep on reading to find out.

    Read the article

  • How to set Options in jqgrid?

    - by Ankita
    I need to set the Options for Jqgrid like toppager, forceFit for which the "Can be changed?" value is set to "No" hence i tired it to set by adding it this way jQuery(document).ready(function() { jQuery("#list").setGridParam({ forceFit: true, toppager: true }).trigger("reloadGrid"); jQuery("#list").jqGrid({ url: '<%= Url.Action("GridData") %', datatype: 'json', mtype: 'GET', colNames:['Time', 'Description', 'Category', 'Type', 'Originator', 'Vessel'], colModel: [ { name: 'Time', index: 'Time', width: 200, align: 'left' }, { name: 'Description', index: 'Description', width: 600, align: 'left' }, { name: 'Category', index: 'Category', width: 100, align: 'left' }, { name: 'Type', index: 'Type', width: 100, align: 'left' }, { name: 'Originator', index: 'Originator', width: 100, align: 'left' }, { name: 'Vessel', index: 'Vessel', align: 'left'}], pager: jQuery('#pager'), rowNum: 20, rowList: [10, 20, 50], sortname: 'Time', sortorder: "desc", viewrecords: true, hoverrows: false, gridview: true, emptyrecords: 'No data for the applied filter', height: 460, caption: 'Logbook Grid', //forceFit: true, width: 1200 }); }); But it didnt work Can u pls let me know what exactly i am doing wrong or the right way for this ?

    Read the article

  • How to embedd cgi in html

    - by neversaint
    I have no problem executing a cgi file under the normal url like this: http://www.myhost.com/mydir/cgi-bin/test.cgi However when I tried to embedd it into HTML file (called index.html) like this: <HTML> <BODY> <P>Here's the output from my program: <FORM ACTION="/var/www/mydir/cgi-bin/test.cgi" METHOD=POST> </FORM> </P> </BODY> </HTML> The CGI doesn't get executed when I do: http://www.myhost.com/mydir/index.html The CGI file (test.cgi) simply looks like this: #!/usr/bin/perl -wT use CGI::Carp qw(fatalsToBrowser); print "Test cgi!\n"; What's the right way to do it?

    Read the article

  • Java OO design confusion: how to handle actions modified by states modified by actions...

    - by Arvanem
    Hi folks, Given an entity, whose action is potentially modified by states (of the entity and other entities) in turn potentially modified by other actions (of the entity and other entities) , what is the best way to code or design to handle the potential existence of the modifiers? Speaking metaphorically, I am coding a Java application representing a piano. As you know a piano has keys (which, when pressed, emit sound) and pedals (which, when pressed, modify the keys' sounds). My base class structure is as follows: Entity (for keys and pedals) State (this holds each entity's states, e.g. name such as "soft pedal", and boolean "Pressed"), Action (this holds each entity's actions, e.g. play sound when pressed, or modify others sounds). By composition, the Entity class has a copy of each of State and Action inside it. e.g.: public class Entity { State entityState = new State(); Action entityAction = new Action(); Thus I have coded a "C-Sharp" key Entity. When I "press" that entity (set its "Pressed" state to true), its action plays a "C-Sharp" sound and then sets its "Pressed" state to false. At the same time, if the "C-Sharp" key entity is not "tuned", its sound deviates from "C-Sharp". Meanwhile I have coded a "soft pedal" Entity. When that entity is "pressed", no sound plays but its action is to make softer the sound of the "C-Sharp" and other key entities. I have also coded a "sustain pedal" Entity. When that entity is "pressed", no sound plays but its action is to enable reverberation of the sound of the "C-Sharp" and other key entities. Both the "soft" and "sustain pedals" can be pressed at the same time with the result that keys entities become both softened and reverberating. In short, I do not understand how to make this simultaneous series of states and actions modify each other in a sensible OO way. I am wary of coding a massive series of "if" statements or "switches". Thanks in advance for any help or links you can offer.

    Read the article

  • iphone memory leaks and malloc?

    - by Brodie4598
    Okay so im finally to the point where I am testing my iPad App on an actual iPad... One thing that my app does is display a large (2mb) image in a scroll view. This is causing the iPad to get memory warnings. I run the app in the instruments to check for the leak. When I load the image, a leak is detected and i see the following in the allocations: ALl Allocations: 83.9 MB Malloc 48.55 MB: 48.55 MB Malloc 34.63 MB: 34.63 MB What im trying to understand is how to plug the leak obviously, but also why a 2MB image is causing a malloc of 20x that size I am very new to programming in obj-c so im sure this is an obvious thing, but I just cant figure it out. Here is the code:

    Read the article

  • how to create Java Application and query about OWL using SPARQL/Jena and how to do it on local/remot

    - by user323889
    I want to create simple application using Java Jena and SPARQL ,that insert, delete , update and query the OWL/RDF data I worked on protege to create the ontology and noticed SPARQL in it but I want to use SPARQL using java and jena ... 1) I saw this thread and I knew how to use SPARQL with jena (after http)stackoverflow.com/questions/2267333/using-jena-to-create-a-sparql-query-on-dbpedia it did work with me .. but I want my own ontology to work .. I mean to upload it to server or to work on localhost or whatever ... 2) SPARQL doesn't support operations like update or insert .. but querying is there any other languages/methods that support these operations ? or I should created it manually in java in each application ... 3) how can I upload my ontology and I prefer something related to protege ? because I tried this which got bug : (after http )semweb.krasu.ru/protege2joseki/ and this (which gave me lot of issues) (after http and wwwdot)joseki.org/ nothing work .. 4) RDF-store ... is for just RDF ? because I am working on OWL files .. I mean for example using MySQL as RDF-store .. would it work for OWL concept ?

    Read the article

  • How to mock ISerializable classes with Moq?

    - by asmois
    Hi there, I'm completly new to Moq and now trying to create a mock for System.Assembly class. I'm using this code: var mockAssembly = new Mock<Assembly>(); mockAssembly.Setup( x => x.GetTypes() ).Returns( new Type[] { typeof( Type1 ), typeof( Type2 ) } ); But when I run tests I get next exception: System.ArgumentException : The type System.Reflection.Assembly implements ISerializable, but failed to provide a deserialization constructor Stack Trace: at Castle.DynamicProxy.Generators.BaseProxyGenerator.VerifyIfBaseImplementsGet­ObjectData(Type baseType) at Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateCode(Type[] interfaces, ProxyGenerationOptions options) at Castle.DynamicProxy.DefaultProxyBuilder.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options) at Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors) at Moq.Proxy.CastleProxyFactory.CreateProxy[T](ICallInterceptor interceptor, Type[] interfaces, Object[] arguments) at Moq.Mock`1.<InitializeInstance>b__0() at Moq.PexProtector.Invoke(Action action) at Moq.Mock`1.InitializeInstance() at Moq.Mock`1.OnGetObject() at Moq.Mock`1.get_Object() Could you reccomend me the right way to mock ISerializable classes (like System.Assembly) with Moq. Thanks in advance!

    Read the article

  • a mechanism to address WPF bindings beyond NameScope

    There are many situations that a property should be bind to a DynamicResource. Many UI patterns like Composite UI Applications need a mechanism to support binding across modules. This article addresses these issues.  read moreBy Siyamand AyubiDid you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Linux filesystem suggestion for MySQL with a 100% SELECT workload

    - by gmemon
    I have a MySQL database that contains millions of rows per table and there are 9 tables in total. The database is fully populated, and all I am doing is reads i.e., there are no INSERTs or UPDATEs. Data is stored in MyISAM tables. Given this scenario, which linux file system would work best? Currently, I have xfs. But, I read somewhere that xfs has horrible read performance. Is that true? Should I shift the database to an ext3 file system? Thanks

    Read the article

  • In Windows 7, can a program overrride file associations not set in "Set Default Programs"?

    - by KL90
    I am using Windows 7. I installed a media application (KMPlayer) that does not show up in the "Set Default Programs" list. Now in the KMPlayer's preferences, there's a setting to associate file types with itself. But when I tried that, I noticed that the files still default to Windows Media Player. So can I assume that no external application can change the program associated with a file type unless explicitly done via the: [Set Default Programs] or [Associate a file type ... with a program] or the [Open with...] options? Thanks in advance! Btw, I know there are utilities that can help me batch change it. I'm just more curious about the "rules" that Windows 7 has in place regarding file types and their associated programs.

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >