Search Results

Search found 31491 results on 1260 pages for 'simple talk'.

Page 75/1260 | < Previous Page | 71 72 73 74 75 76 77 78 79 80 81 82  | Next Page >

  • Regex vs. string:find() for simple word boundary

    - by user576267
    Say I only need to find out whether a line read from a file contains a word from a finite set of words. One way of doing this is to use a regex like this: .*\y(good|better|best)\y.* Another way of accomplishing this is using a pseudo code like this: if ( (readLine.find("good") != string::npos) || (readLine.find("better") != string::npos) || (readLine.find("best") != string::npos) ) { // line contains a word from a finite set of words. } Which way will have better performance? (i.e. speed and CPU utilization)

    Read the article

  • Simple haskell splitlist

    - by js7354
    I have the following function which takes a list and returns two sublists split at a given element n. However, I only need to split it in half, with odd length lists having a larger first sublist splitlist :: [a] -> Int -> ([a],[a]) splitlist [] = ([],[]) splitlist l@(x : xs) n | n > 0 = (x : ys, zs) | otherwise = (l, []) where (ys,zs) = splitlist xs (n - 1) I know I need to change the signature to [a] - ([a],[a]), but where in the code should I put something like length(xs) so that I don't break recursion? Thank you.

    Read the article

  • Simple OpenCL Kernel

    - by Yuuta
    I'm trying to write a kernel which is a little long but the output is not correct. I took out a lot almost everything and finally narrowed down the an initialization problem and I found that the following works: __kernel void k_sIntegral(__global const float* eData,__global const unsigned long* elements,__global float* area){ const int i = get_global_id(0); if(i < elements[0]){ area[i] = i; } } But the following does not work: __kernel void k_sIntegral(__global const float* eData,__global const unsigned long* elements,__global float* area){ const int i = get_global_id(0); if(i < elements[0]){ __local float a,b,c,j,k,h,s; area[i] = i; } } Using the first kernel, I get: area[1] = 1 Using the second kernel, I get: area[1] = 0 (from calloc) Update: It seems like the code does work, but I need to change the function name otherwise it somehow calls the previous function even though it was not compiled (?). Any leads to why that happens? If anyone can let me know what might be the problem I'll be really grateful, thanks in advance!

    Read the article

  • Special simple random number generator

    - by psihodelia
    How to create a function, which on every call generates a random integer number? This number must be most random as possible (according to uniform distribution). It is only allowed to use one static variable and at most 3 elementary steps, where each step consists of only one basic arithmetic operation of arity 1 or 2. Example: int myrandom(void){ static int x; x = some_step1; x = some_step2; x = some_step3; return x; } Basic arithmetic operations are +,-,%,and, not, xor, or, left shift, right shift, multiplication and division. Of course, no rand(), random() or similar staff is allowed.

    Read the article

  • Simple nested setTimeout() only runs once (JavaScript)

    - by danielfaraday
    For some reason my galleryScroll() function only runs once, even though the function calls itself using setTimeout(). I'm thinking the issue may be related to scope, but I'm not sure: http://jsfiddle.net/CYEBC/2/ $(document).ready(function() { var x = $('#box').offset().left; var y = $('#box').offset().top; galleryScroll(); function galleryScroll() { x = x + 1; y = y + 1; $('#box').offset({ left: x, top: y }); setTimeout('galleryScroll()', 100); } });? The HTML: <html> <head> </head> <body> <div id="box"> </div> </body> </html>

    Read the article

  • Rewriting URL's in ASP.net (Simple question)

    - by Tom Gullen
    On my master page I have: <link rel="stylesheet" href="css/default.css" /> I also have a page "blog.aspx" in the root directory. I have the rule: <rewrite url="~/blog/blog.aspx" to="~/blog.aspx" /> My questions are: Am I meant to make all my links in my site point to blog/blog.aspx now instead of just blog.aspx where it is physically located How is best to cope with the paths of the stylesheets etc now being messed up because they are one dir up?

    Read the article

  • Possibly simple PHP/MYSQL issue with retrieving and showing data

    - by envoys
    I have been racking my brains over this for a while now. Here is the data i have in the sql data base as an example: ID | TYPE | DATA 1 | TXT | TEST 2 | PHP | php 3 | JS | JAVASCRIPT That is just an example, there are multiple listing for TXT, PHP and JS throughout the table. What I want to do is retrive all the data and display it all into separate drop down/select boxes. Meaning, select box one would list all data with type TXT, select box two would list all data with type PHP and select box 3 would list all data with type JS. The only way I have came about doing this is doing individual sql queries for each different type. I know there is a way to do it all in 1 query and then display it the way I want to but I just can't seem to figure out how and I know its going to drive me nuts when someone helps and I see just how they did it. Thanks for the input.

    Read the article

  • simple interview question

    - by calvin
    Input integer array: a[8] = { a1, a2, a3, a4, b1, b2, b3, b4 } Output array: a[8] = { a1, b1, a2, b2, a3, b3, a4, b4 } Forget all corner cases, make sure your solution works for any int array of size 2n. You can use one or two temp variables for looping or anything, but you shouldn't use any temp arrays/stacks/queues etc to store entire array or part of array. I'm able to get answer in O(n*log n), but I'm looking for better solution.

    Read the article

  • simple for loop not running

    - by NativeCoder
    for ( var i:int = 0 ; i < 1; i++) { for ( var j:int = 0 ; j < 1; j++) { if (shape[j][i] == 0 ) { pencil.graphics.beginFill(0); pencil.graphics.drawRect(10,10,5,5); pencil.graphics.endFill(); } } } i am trying to run this code where shape is an array 2*2 gives an error ReferenceError: Error #1069: Property 0 not found on Number and there is no default value. at Main() need help

    Read the article

  • Very simple mod_rewrite questions

    - by Camran
    1- Does mod_rewrite means that if I make this url: domain.com/ad.php?id=8498292 INTO domain.com/8498292 that all links on my website will have to be changed to the later above? example the link: domain.com/ad.php?id=8498292 wont work now, unless I replace it with domain.com/8498292 ? Or will the server know that they are the same still? 2- Will the rewritten link appear rewritten in the browsers adress bars also, so if I enter domain.com/ad.php?id=8498292 it will actually appear as domain.com/8498292 in the adress bar itself? 3- Will images and all other related links and material on the page whose link is rewritten remain intact? ie will pictures and links still work FROM that page which are relative? Thanks

    Read the article

  • Simple syntax question

    - by stabby
    Hey everyone, First off, sorry for my noob-ness. Believe me when i say ive been rtfm'ing. Im not lazy, im just dumb (apparently). On the bright side, this could earn someone some easy points here. I'm trying to do a match/replace with a pattern that contains special characters, and running into syntax errors in a Flex 3 app. I just want the following regex to compile... (while also replacing html tags with "") value.replace(/</?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)/?>/g, ""); On a side note, the pattern /<.*?/g wouldn't work in cases where there are html entities between tags, like so: <TEXTFORMAT LEADING="2"> <P ALIGN="LEFT"> <FONT FACE="Arial" SIZE="11" COLOR="#4F4A4A" LETTERSPACING="0" KERNING="0"><one</FONT> </P> </TEXTFORMAT><TEXTFORMAT LEADING="2"> <P ALIGN="LEFT"> <FONT FACE="Arial" SIZE="11" COLOR="#4F4A4A" LETTERSPACING="0" KERNING="0">two</FONT> </P> </TEXTFORMAT> The first regex would get both "<one" and "two", but the second would only get "hi" Thanks! Stabby L

    Read the article

  • simple query Delete records in a table based on count logic

    - by user1905941
    a table with a pk and status column which is having values as 'Y','N','NULL' Query: get the count of records with status column as 'Y', if this count exceeds 1% of total count of records then dont delete , else delete the records in the table. i tried like this Declare v_count Number; v_count1 Number; BEGIN v_count := select count(*) from temp; v_count1 := select count(*) from temp where status = 'Y' ; v_count := v_count + ((0.1) * (v_count)) if (v_count1 > v_count) { insert into temp1 values(pk,status) } else { Delete from temp ; } END;

    Read the article

  • How should 4 decimals places behave, being simple yet powerful

    - by vener
    I have a UI question that troubled me on the best method to handle 4 decimal places for prices. In an table already cramped full of data, I would want to simplified the interface to make it not so cluttered. The actual current UI is shown below. http://i41.tinypic.com/bg5tub.jpg The problem is, for a unit price/units/D.Price and Dis.(Discount) to have 4 decimal places ($0.3459) is quite rare but it still happens (5 in 100 entries). This will result a lot of junk decimal places, cluttering up the interface. What is the best solution to this problem? In short, I want to declutter it yet maintain the precision. Note: This is web app

    Read the article

  • Simple accordion menu (jQuery)

    - by Nimbuz
    // ACCORDION $('.accordion .answer').hide(); // hide all $('.accordion .question').click(function(){ $('.accordion .answer').slideUp(); // hide all open $(this).addClass('active').next().slideDown(); // show the anwser return false; }); HTML: <dl class="accordion"> <dt class="question">question</dt> <dd class="answer">answer</dd> <dt class="question">question</dt> <dd class="answer">answer</dd> </dl> ... works, but the 'active' class is removed from inactive question elements and atleast one of the answer remains open, all answers should be able to close. Thanks!

    Read the article

  • Simple bind not working in IE for Radiobutton in jQuery

    - by Jonathan
    Hi this works fine in Firefox, but not IE. What am I doing wrong? Thanks for the help in advance! $(document).ready(function(){ $("#radiodiv").buttonset(); $('#radio1').bind("click", function() { alert('Hello'); }); } <form> <div id="radiodiv"> <input type="radio" id="radio1" name="radio" checked="checked" /><label for="radio1">WaveHeight</label> <input type="radio" id="radio2" name="radio" /><label for="radio2">Current</label> <input type="radio" id="radio3" name="radio" /><label for="radio3">WaveHeightDir</label> </div> </form>

    Read the article

  • Simple Reliable UDP C++ Libraries

    - by EToreo
    Hello, I am in need of a reliable UDP library. The one I wrote does not work too well and I would like to see what a 3rd party can do in the same circumstances. Enet will not work because of some "interesting" compile issues in xcode (I have another question on stack overflow about that). Any suggestions for a portable, reliable UDP library would be greatly appreciated.

    Read the article

  • simple question: Difficulty in declaring and using variable

    - by user281180
    What is wrong with the following code: I`m having the error message Error 1 ; expected <%if (Model.ReferenceFields != null) {%> <%int count = 1; %> <%foreach (var referenceName in Model.ReferenceFields) {%> <%var value = "value"; %> <%count++; %> <%value = value + count.ToString(); %> <tr> <td><input type="hidden" name="Tests.Index" value='<%value%>' /></td> <td><input type="text" name="Tests['<%value%>'].Value"/></td> <td><input type="button" value= "Add" /></td></tr> <%} %> <%} %>

    Read the article

  • simple question about oracle indexes

    - by john
    If I have an oracle query like below: SELECT * FROM table_a where A = "1", B = "2", C = "3" for this query to pickup one of the indexes of table_a...does the index need to be on all 3 of these columns? What I am asking is: What if Index is on A, B, C, D? What if Index is on B, C? Will the index only be picked when it is on A, B, C?

    Read the article

  • Simple Jquery function won't work

    - by stijn26
    I have following jQuery code $(document).ready(function() { for(var i=1;i<4;i++) { var img= ".img"+i; var p= ".p"+i; $(img).on("click", function(){ $(p).hide(); }); } }); Applied on the following html: <div> <article> <h1>Over mezelf <img src='images/plus.png' class='img1'/></h1> <p class='p1'>Test</p> </article> <article> <h1>Contact <img src='images/plus.png' class='img2'/></h1> <p class='p2'>Test</p> </article> <article> <h1>Website <img src='images/plus.png' class='img3'/></h1> <p class='p3'>Test</p> </article> </div> When I click on the images, the last <p> disappears, it doesn't work on the other ones.

    Read the article

< Previous Page | 71 72 73 74 75 76 77 78 79 80 81 82  | Next Page >