Daily Archives

Articles indexed Wednesday April 7 2010

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

  • What do these C operators mean?

    - by Melkhiah66
    I'm reading the book "Programming Challenges: The Programming Contest Training Manual" and are implementing a problem where I do not understand the use of operators c1 and the comparison if (n&1), someone could help me to know they mean? this is the example code #include <stdio.h> #define MAX_N 300 #define MAX_D 150 long cache[MAX_N/2][2]; void make_cache(int n,int d,int mode) { long tmp[MAX_D]; int i,count; for(i=0;i<MAX_D;i++) tmp[i]=0; tmp[0]=1;count=0; while(count<=n) { count++; for(i=(count&1);i<=d;i+=2) { if(i) tmp[i] = tmp[i-1] + tmp[i+1]; else if(!mode) tmp[0]=tmp[1]; else tmp[0]=0; } if((count&1)==(d&1)) cache[count>>1][mode]=tmp[d]; } } int main() { int n,d,i; long sum; while(1) { scanf("%d %d",&n,&d); if(n&1) sum=0; else if(d==1) sum=1; else if(n<(d<<1)) sum=0; else if(n==(d<<1)) sum=1; else { make_cache(n,d,0); make_cache(n,d,1); sum=0; for(i=0;i<=(n>>1);i++) sum+=cache[i][0]*cache[(n>>1)-i][1]; } printf("%ld\n",sum); } return 0; }

    Read the article

  • Why is Google Charts not showing the right data for me? Are the axis messed up?

    - by alex
    http://chart.apis.google.com/chart?cht=lc&chs=600x400&chd=t:171,811,629,507,460,390,434,379,329,312,368,329,329,329,352,330,299,323,340,325,329,1895,1047,736,617,684,620,515 If you go there on your browser, you'll notice that you see a graph. However, the axis are messed up! And it seems like I can't see the ups and downs of my line graph. WHy? I don't get what's wrong. I just want to plot the simple stuff on a line chart. Just those data points. Nothing more, nothing less!

    Read the article

  • Unable to load detached NIB in View

    - by Sheehan Alam
    I have two NIB's ParentViewController.xib ChildViewController.xib ParentViewController.xib contains a UIView and a UIViewController. ChildViewController.xib contains a UIButton I want ChildViewController.xib to load in the ParentViewController.xib's UIView I have done the following: Created @property for UIView in ParentViewController Connected File's Owner to UIView in ParentViewController Set UIViewController in ParentViewController's NIB Name property to ChildViewController in Interface Builder Set ChildViewController view property to UIView in ParentViewController I was hoping this would load ChildViewController into my UIView in ParentViewController but no luck. I did get the following warning, which could be the culprit: 'View Controller (Child View)' has both its 'NIB Name' property set and its 'view' outlet connected. This configuration is not supported. I also have added additional code in ParentViewController's viewDidLoad(): - (void)viewDidLoad { [super viewDidLoad]; ChildViewController *childViewController = [[ChildViewController alloc]initWithNibName:@"ChildViewController" bundle:nil]; childViewController.view = self.myView; } Any thoughts on why ChildViewController does not load in the UIView of ParentViewController?

    Read the article

  • Connecting Multiple Buttons to one action?

    - by David
    Hello, I have multiple UIButtons in my app. I also use interfacebuilder. In my .h i have something like this IBOutlet UIButton *button1; IBOutlet UIButton *button2; IBOutlet UIButton *button3; - (IBAction)buttonPressed; Then In my m i want to do something like this (IBAction)buttonPressed { if (theButtonIpressed == button1) { } } The problem is I don't have something called "theButtonIpressed" so I cant do this. What should my if statement look like? Thanks, -David

    Read the article

  • "Attach to process" missing from Delphi 7's Run menu

    - by glob
    I have to resurrect an ancient Delphi 7 application, which means I have to use the D7 IDE. Upgrading the project to a more recent version of Delphi unfortunately isn't an option. My new D7 installation's Run menu is missing Attach to Process. Aside from the missing menu item, the debugger works fine (I can debug normal Delphi executables started with Run). I know D7 supported this feature (it's in the help file), so does anyone have any idea what I've missed? The installation is Delphi 7 Enterprise (Version 7.0 Build 4.453). Current Run menuitems: Run Parameters... - Step Over Trace Into Trace to next Source line Run to Cursor Run Until Return Show Execution Point Program Pause Program Reset - Evaluate/Modify Add Watch Add Breakpoint

    Read the article

  • Stuck on the logic of creating tags for posts (like SO tags)? (PHP)

    - by ggfan
    I am stuck on how to create tags for each post on my site. I am not sure how to add the tags into database. Currently... I have 3 tables: +---------------------+ +--------------------+ +---------------------+ | Tags | | Posting | | PostingTags | +---------------------+ +--------------------+ +---------------------+ | + TagID | | + posting_id | | + posting_id | +---------------------+ +--------------------+ +---------------------+ | + TagName | | + title | | + tagid | +---------------------+ +--------------------+ +---------------------+ The Tags table is just the name of the tags(ex: 1 PHP, 2 MySQL,3 HTML) The posting (ex: 1 What is PHP?, 2 What is CSS?, 3 What is HTML?) The postingtags shows the relation between posting and tags. When users type a posting, I insert the data into the "posting" table. It automatically inserts the posting_id for each post(posting_id is a primary key). $title = mysqli_real_escape_string($dbc, trim($_POST['title'])); $query4 = "INSERT INTO posting (title) VALUES ('$title')"; mysqli_query($dbc, $query4); HOWEVER, how do I insert the tags for each post? When users are filling out the form, there is a checkbox area for all the tags available and they check off whatever tags they want. (I am not doing where users type in the tags they want just yet) This shows each tag with a checkbox. When users check off each tag, it gets stored in an array called "postingtag[]". <label class="styled">Select Tags:</label> <?php $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $query5 = "SELECT * FROM tags ORDER BY tagname"; $data5 = mysqli_query($dbc, $query5); while ($row5 = mysqli_fetch_array($data5)) { echo '<li><input type="checkbox" name="postingtag[]" value="'.$row5['tagname'].'" ">'.$row5['tagname'].'</li>'; } ?> My question is how do I insert the tags in the array ("postingtag") into my "postingtags" table? Should I... $postingtag = $_POST["postingtag"]; foreach($postingtag as $value){ $query5 = "INSERT INTO postingtags (posting_id, tagID) VALUES (____, $value)"; mysqli_query($dbc, $query5); } 1.In this query, how do I get the posting_id value of the post? I am stuck on the logic here, so if someone can help me explain the next step, I would appreciate it! Is there an easier way to insert tags?

    Read the article

  • How should I manage data in an 2D vector based animation program?

    - by shadow
    I've been trying to design a program that makes 2D animations and then uses the ffmpeg library to create the video for possible use in tv and movies. The problem is when I think about how to manage the data in the application I can only think of two ways, I don't think either of them will work out very well. One is to use an SQlite database, but it seems like it will be difficult to save, especially if an artist puts 1000 things on screen. The other is to use something like linked lists, which would duplicate many features of the database and get complicated when dealing with things like points on a bezier curve and jumping to a frame and collecting all the objects that need to be drawn on that frame. Should I use one of these solutions, or is there something else that would be better? Currently planning to use C# for code.

    Read the article

  • Big text appears for few second on page refresh in IE, How to solve?

    - by metal-gear-solid
    Text always appears in big size for a few seconds when one refreshes the page on IE only, which doesn't look very good. pleas look at IE 7 and try to refresh (I've e.g. been pressing ctrl + F5) to see what i'm facing. I'm also using sIFR on this site I check a js error of page and this is the problematic area. <script type="text/javascript">var arr = new Array(3) arr[0] = "Jani" arr[1] = "Tove" arr[2] = "Hege"var arr2 = new Array(3) arr2[0] = "John" arr2[1] = "Andy" arr2[2] = "Wendy"document.write(arr.concat(arr2))</script>

    Read the article

  • modifying ajax returned data before showing

    - by Nick
    I'm processing subscribtion form with jQuery/ajax and need to display results with success function (they are different depending on if email exists in database). But the trick is I do not need h2 and first "p" tag. How can I show only div#alertmsg and second "p" tag? I've tried revoming unnecessary elements with method described here, but it didn't work. Thanks in advance. Here is my code: var dataString = $('#subscribe').serialize(); $.ajax({ type: "POST", url: "/templates/willrock/pommo/user/process.php", data: dataString, success: function(data){ var result = $(data); $('#success').append(result); } Here is the data returned: <h2>Subscription Review</h2> <p><a href="url" onClick="history.back(); return false;"><img src="/templates/willrock/pommo/themes/shared/images/icons/back.png" alt="back icon" class="navimage" /> Back to Subscription Form</a></p> <div id="alertmsg" class="error"> <ul> <li>Email address already exists. Duplicates are not allowed.</li> </ul> </div> <p><a href="login.php">Update your records</a></p>

    Read the article

  • Socket Read In Multi-Threaded Application Returns Zero Bytes or EINTR (104)

    - by user309670
    Hi. Am a c-coder for a while now - neither a newbie nor an expert. Now, I have a certain daemoned application in C on a PPC Linux. I use PHP's socket_connect as a client to connect to this service locally. The server uses epoll for multiplexing connections via a Unix socket. A user submitted string is parsed for certain characters/words using strstr() and if found, spawns 4 joinable threads to different websites simultaneously. I use socket, connect, write and read, to interact with the said webservers via TCP on their port 80 in each thread. All connections and writes seems successful. Reads to the webserver sockets fail however, with either (A) all 3 threads seem to hang, and only one thread returns -1 and errno is set to 104. The responding thread takes like 10 minutes - an eternity long:-(. *I read somewhere that the 104 (is EINTR?), which in the network context suggests that ...'the connection was reset by peer'; or (B) 0 bytes from 3 threads, and only 1 of the 4 threads actually returns some data. Isn't the socket read/write thread-safe? I use thread-safe (and reentrant) libc functions such as strtok_r, gethostbyname_r, etc. *I doubt that the said webhosts are actually resetting the connection, because when I run a single-threaded standalone (everything else equal) all things works perfectly right, but of course in series not parallel. There's a second problem too (oops), I can't write back to the client who connect to my epoll-ed Unix socket. My daemon application will hang and hog CPU 100% for ever. Yet nothing is written to the clients end. Am sure the client (a very typical PHP socket application) hasn't closed the connection whenever this is happening - no error(s) detected either. Any ideas? I cannot figure-out whatever is wrong even with Valgrind, GDB or much logging. Kindly help where you can.

    Read the article

  • jquery to check if returned data object is empty

    - by user253530
    $("#post").live("click",function() { $("input:checkbox[name='bookmarkid']:checked").each(function() { $.post("php/socialbookmark-post.php", {bookmarkID: $(this).val()},function(data) { if(data != "") alert(data); }); }); }); the php file outputs some text only if something goes wrong. The checking that I do fails if the data is empty and displays an empty message. I need to fix this. Any ideas?

    Read the article

  • Linux bash: when to use egrep instead of grep?

    - by Michael Mao
    Hi all : I am preparing for a Linux terminal assessment now, I tried to Google and found most resources are referring to the basic "grep" rather than the more powerful "egrep" -- well, that is at least what the professor said in lecture. I am always working with small samples so performance tuning is a thing too far away. So basically I'd like to know are there any areas where I must switch to egrep to do it in a better way? Is it safe to work with basic "grep" as for now? will there be potential risks? Sorry about my limited knowledge on Linux shell commands, the man page looks like a maze to me and honestly I haven't put much time in understanding all the features both command provide.

    Read the article

  • How do I log from inside my web application in Tomcat 6.

    - by Carlos
    How do I log from within my web application deployed on Tomcat 6? Where should I expect the logging output to go (internal tomcat log files, or will another logfile be generated)? I see a ton of documentation but am having a hard time finding a direct answer to the above questions. Where should I expect the logging to show up (currently it is log4j is not generating a log file and it is not showing up in my console). I am trying to follow http://www.laliluna.de/articles/log4j-tutorial.html . ### direct log messages to stdout ### log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n ### file appender log4j.appender.file=org.apache.log4j.RollingFileAppender log4j.appender.file.maxFileSize=100KB log4j.appender.file.maxBackupIndex=5 log4j.appender.file.File=test.log log4j.appender.file.threshold=info log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n log4j.rootLogger=debug, stdout In my application I define a log object: private static org.apache.log4j.Logger log = Logger.getLogger(MyClass.class); log.error("LOGGING!"); Thanks for the help.

    Read the article

  • How to change default conjunction with Lucene MultiFieldQueryParser

    - by Luke H
    I have some code using Lucene that leaves the default conjunction operator as OR, and I want to change it to AND. Some of the code just uses a plain QueryParser, and that's fine - I can just call setDefaultOperator on those instances. Unfortunately, in one place the code uses a MultiFieldQueryParser, and calls the static "parse" method (taking String, String[], BooleanClause.Occur[], Analyzer), so it seems that setDefaultOperator can't help, because it's an instance method. Is there a way to keep using the same parser but have the default conjunction changed?

    Read the article

  • Server doesn't notice when client closes socket (.NET CF & GPRS)

    - by HansA
    Client written in .NET Compact Framework running over GPRS connection. Client connects a socket to the server. The server accepts the connection. Client sends 62 bytes of data and then closes the socket. Server never detects that the client has closed the socket and is therefore not able to know that the transfer has completed. This code works fine when run over a wireless connection. Any ideas?

    Read the article

  • How can my WiX uninstall restore a registry value change?

    - by Thomas
    The installer I'm writing using WiX 3.0 uses a RegistryValue element to modify an existing registry value (originally written by our main product). I'm trying to figure out a way to restore the registry value when the user uninstalls my utility. I'd like to avoid using a custom action, but that might be the only recourse? TIA.

    Read the article

  • How much RAM required by Varnish?

    - by Gobind Singh Deo
    Hi, I'm using Apache for serving static files. Apache2 require too much RAM. I want to reduce the RAM usage. I don't have experience with Varnish. It's said to be faster. I don't know how Varnish works. So, How much RAM needed for running Apache2+Varnish? Will Apache2+Varnish have higher RAM usage than Apache2 without Varnish? Thanks.

    Read the article

  • Replace text in div when image is clicked

    - by Adam
    Hello, I'm trying to replace certain text inside the div "info" when an image (which serve as links) is clicked. I'm just unsure of what methods could do this. I would prefer this be jquery. My code so far looks like: <div class="info"> <p>I would like this text replaced</p> <script> </script> </div><!--end info--> <li><a href="1.jpg"><img src="1-s.png" width="55" height="55" alt="" class="latest_img" /></a><p>Replace the div "info" text with the text here when clicked on</p></li>

    Read the article

  • Can I resolve ASP.NET "~" app paths to the website root without a Control being present?

    - by jdk
    I want to Resolve "~/whatever" from inside non-Page contexts such as Global.asax (HttpApplication), HttpModule, HttpHandler, etc. but can only find the Resolution methods specific to Controls (and Page). I think the app should have enough knowledge to be able to map this outside the Page context. No? Or at least it makes sense to me it should be resolvable in other circumstances, wherever the app root is known. Update: The reason being I'm sticking ~ paths in the web.configuration files. Update 2: I'm trying to resolve them to the website root such as Control.Resolve(..) URL does, not to a file system path.

    Read the article

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