Search Results

Search found 3152 results on 127 pages for 'jq beginner'.

Page 51/127 | < Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >

  • Regular Expression Sanitize (PHP)

    - by atif089
    Hello, I would like to sanitize a string in to a URL so this is what I basically need. Everything must be removed except alphanumeric characters and spaces and dashed. Spaces should be converter into dashes. Eg. This, is the URL! must return this-is-the-url Thanks

    Read the article

  • passing a class method as opposed to a function in std::sort

    - by memC
    hi, Within a class, I am trying to sort a vector, by passing a method of the same class. But it gives errors at the time of compilation. Can anyone tell what the problem is? Thank you! it gives the following error: argument of type bool (Sorter::)(D&, D&)' does not matchbool (Sorter::*)(D&, D&)' I have also tried using sortBynumber(D const& d1, D const& d2) #include<vector> #include<stdio.h> #include<iostream> #include<algorithm> class D { public: int getNumber(); D(int val); ~D(){}; private: int num; }; D::D(int val){ num = val; }; int D::getNumber(){ return num; }; class Sorter { public: void doSorting(); bool sortByNumber(D& d1, D& d2); std::vector<D> vec_D; Sorter(); ~Sorter(){}; private: int num; }; Sorter::Sorter(){ int i; for ( i = 0; i < 10; i++){ vec_D.push_back(D(i)); } }; bool Sorter::sortByNumber(D& d1, D& d2){ return d1.getNumber() < d2.getNumber(); }; void Sorter::doSorting(){ std::sort(vec_D.begin(), vec_D.end(), this->sortByNumber); }; int main(){ Sorter s; s.doSorting(); std::cout << "\nPress RETURN to continue..."; std::cin.get(); return 0; }

    Read the article

  • Can someone explain to me why my output is this? And how would I correct my output?

    - by user342231
    /* in this slice of code I get an output of bbb 55 66 77 88 aaa the output I expect and want is bbb 55 66 77 88 bbb because I reassign ss from log[0] to log[1] So my question is why is the output different from what I expect and how do I change it to what I want? */ int w,x,y,z; stringstream ss (stringstream::in | stringstream::out); string word; string log[2]; log[0]="aaa 11 22 33 44"; log[1]="bbb 55 66 77 88"; ss<<log[0]; ss>>word; int k=0; ss>>w>>x>>y>>z; k++; ss<<log[k]; cout<<log[k]<<endl; ss>>word; cout<<word<<endl; return 0;

    Read the article

  • array, I/O file and standard deviation (c++)

    - by JohnWong
    double s_deviation(double data[],int cnt, double mean) { int i; double sum= 0; double sdeviation; double x; //x = mean(billy,a_size); for(i=0; i<cnt; i++) { sum += ((data[i]) - (mean)); } sdeviation = sqrt(sum/((double)cnt)); return sdeviation; } When I cout the result from this function, it gave me NaN. I tested the value of (mean) and data[i] using return data[i] and return mean they are valid. when i replaced mean with an actual number, the operation returned a finite number. but with mean as a variable, it produced NaH. I can't see anything wrong with my code at the moment. Again, I am sure mean, data are getting the right number based on those tests. Thank you

    Read the article

  • Java: calculate linenumber from charwise position according to the number of "\n"

    - by HH
    I know charwise positions of matches like 1 3 7 8. I need to know their corresponding line number. Example: file.txt Match: X Mathes: 1 3 7 8. Want: 1 2 4 4 $ cat file.txt X2 X 4 56XX [Added: does not notice many linewise matches, there is probably easier way to do it with stacks] $ java testt 1 2 4 $ cat testt.java import java.io.*; import java.util.*; public class testt { public static String data ="X2\nX\n4\n56XX"; public static String[] ar = data.split("\n"); public static void main(String[] args){ HashSet<Integer> hs = new HashSet<Integer>(); Integer numb = 1; for(String s : ar){ if(s.contains("X")){ hs.add(numb); numb++; }else{ numb++; } } for (Integer i : hs){ System.out.println(i); } } }

    Read the article

  • Returning currently displayed index of an array Javascript...

    - by Jeff Kindred
    I have a simple array with x number of items. I am displaying them individually via a link click... I want to update a number that say 1 of 10. when the next one is displayed i want it to display 2 of 10 etc... I have looked all around and my brain is fried right now... I know its simple I just cant get it out. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Page Title</title> <link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8"/> <script type="text/javascript"> var quotations = new Array() quotations[0]= "1" quotations[1]= "2" quotations[2]= "3" quotations[3]= "4" quotations[4]= "5" quotations[5]= "6" quotations[6]= "7" numQuotes = quotations.length; curQuote = 1; function move( xflip ) { curQuote = curQuote + xflip; if (curQuote > numQuotes) { curQuote = 1 ; } if (curQuote == 0) { curQuote = numQuotes ; } document.getElementById('quotation').innerHTML=quotations[curQuote - 1]; } var curPage = //this is where the current index should go </script> </head> <body> <div id="quotation"> <script type="text/javascript">document.write(quotations[0]);</script> </div> <div> <p><a href="javascript();" onclick="move(-1)">GO back</a> <script type="text/javascript">document.write(curPage + " of " + numQuotes)</script> <a href="javascript();" onclick="move(1)">GO FORTH</a></p> </div> </body> </html>

    Read the article

  • A general question about compilation and interpretation.

    - by wucnuc
    Hi stackoverflow, I apologize in advance for the possible stupidity of this question. However, the following has been the source of some confusion for me and I know the people here will be able to handily clear up the confusion for me. Basically, I would like to finally understand the relationship between any and all of the following terms. Some of the terms I do actually understand pretty well, but some of them are similar in my mind and I would like to once and for all to see their relationships/distinctions laid out all at once. They are: compiler interpreter bytecode machine code assembler assembly language binary object code executable Ideally, an answer would use examples from Java and C++ and other well-known programming languages that a young-ish student like me would be familiar with. Also, if you want to throw in any other useful terms that would be fine too :)

    Read the article

  • How do I splice a python string programmatically?

    - by Robin Welch
    Very simple question, hopefully. So, in Python you can split up strings using indices as follows: >>> a="abcdefg" >>> print a[2:4] cd but how do you do this if the indices are based on variables? E.g. >>> j=2 >>> h=4 >>> print a[j,h] Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: string indices must be integers

    Read the article

  • JButtons re-enable themselves after being disabled

    - by Anarchist
    I have an array of JButtons which form a keypad interface. After six numbers are entered I want to disable the keypad so that no further numbers can be entered by the user. I have written the code and the buttons do disable until the mouse hovers above any of them, then the buttons seem to re-enable themselves and run actionEvents added to them. The full code is available here. Possible things that I think are wrong. There is some sort of MouseListener which is ignoring when I set button.setEnabled(false); I haven't separated attributes from the buildGUI(); correctly, I only did this anyway so that the inner class could access them. Possibly something to do with the gridLayout as disabling the buttons seems to work for my services JPanel buttons.

    Read the article

  • Problem with foreach loop and $_GET

    - by phpExe
    I have a very simple foreach loop foreach($tv as $id => $channel) { $ID = $_GET['ID']; if($ID == $id){$class = "currentt";} echo '<a href="http://www.mysite.com/tst.php?ID='.$id.'" class="'.$class.'">'.$channel.'</a><br>'; } With url query, with every click the current class repeated. How can avoid this? Thanks alot.

    Read the article

  • Adding li element only if it not already there?

    - by Legend
    I am constructing an <li> element like this: var element = $("<li></li>") .html(mHTML) .attr('id', "elemid"); I am trying to add this element to a <ul> element only if it doesn't already exist. Any ideas on how to do this? Am I supposed to use contains() to see if the ul element contain the html and then decide? For instance, <ul id="elemul"> <li id="elemli1">Element 1</li> <li id="elemli2">Element 2</li> <li id="elemli3">Element 3</li> </ul> If I try adding Element 1, it should not add it. What should I do if its a longer string (not really long but about 150 characters). Note: I cannot rely on IDs to determine the uniqueness. i.e. I might end up forming something like: <li id="elemli3">Element 1</li> Do I go about using hashmaps?

    Read the article

  • TB3.0.10: Messages being sent back to me

    - by punkinette64
    Hello, I don't know if this will make any sense to you; but here goes. When I send an email and I get a response, more often than not, in the 'to:' is my email address. However, my email address also ends up in the 'from' column.The 'reply-from' address is nowhere to be found;so I don't have any address with which I can send my reply, as both of them have just my email address. What am I doing wrong here? Is there some set-up in my TOOLOPTIONS set-up incorrectly? The set-up in OPTIONS is pretty difficult to understand and it doesn't offer any 'to' or 'reply-from' choices. This is critical because I just cannot answer my emails because there is no one I can send a reply to. Please, please try to help me. If you have the answer, please email me at: [email protected] Thank you. Blessings. Shiloh

    Read the article

  • Sort database entries via a dropdown list

    - by Lin
    Hello! I'm curious if anyone could possibly help me, because I can't find anything exactly related to it anywhere, and it's driving me nuts. I'd like to have a dropdown list on a page, that will give the visitor the option to sort all entries by year. I have entries from i.e. 2001, 2005, 2009, 2010. The years should be displayed in the dropdown, so the visitor can easily just select all entries dated 2001 if they want. The year for each entry is located in the one database table I have. In other words, I simply want a "sort by" dropdown that you can see on pretty much any shopping site nowadays. But with set years. Thanks in advance for any replies!

    Read the article

  • Performance hit from C++ style casts?

    - by Trevor Boyd Smith
    I am new to C++ style casts and I am worried that using C++ style casts will ruin the performance of my application because I have a real-time-critical deadline in my interrupt-service-routine. I heard that some casts will even throw exceptions! I would like to use the C++ style casts because it would make my code more "robust". However, if there is any performance hit then I will probably not use C++ style casts and will instead spend more time testing the code that uses C-style casts. Has anyone done any rigorous testing/profiling to compare the performance of C++ style casts to C style casts? What were your results? What conclusions did you draw?

    Read the article

  • Assigning a value to a variable gets stored in the wrong spot?

    - by scribbloid
    Hello, I'm relatively new to C, and this is baffling me right now. It's part of a much larger program, but I've written this little program to depict the problem I'm having. #include <stdio.h> int main() { signed int tcodes[3][1]; tcodes[0][0] = 0; tcodes[0][1] = 1000; tcodes[1][0] = 1000; tcodes[1][1] = 0; tcodes[2][0] = 0; tcodes[2][1] = 1000; tcodes[3][0] = 1000; tcodes[3][1] = 0; int x, y, c; for(c = 0; c <= 3; c++) { printf("%d %d %d\r\n", c, tcodes[c][0], tcodes[c][1]); x = 20; y = 30; } } I'd expect this program to output: 0 0 1000 1 1000 0 2 0 1000 3 1000 0 But instead, I get: 0 0 1000 1 1000 0 2 0 20 3 20 30 It does this for any number assigned to x and y. For some reason x and y are overriding parts of the array in memory. Can someone explain what's going on? Thanks!

    Read the article

  • Using mercurial for web-design version control (dealing with images)

    - by Acorn
    I'm very new to Version Control, and I was wondering if I could get some advice on how it can fit into website design. At the moment I'm working on a typical, simple website that includes images: A few .html files and a .css file One folder full of photographs Another folder with the corresponding thumbnails Can I just put the whole lot in a repository? Or is there a better way I could apply Version Control to it? How should I deal with the images? edit: How well will it work with changes to the images? What if I decide to try and optimise my photographs or resize them. I wont be able to see what exactly changed about the images, should comments be enough to keep track of that?

    Read the article

  • foo and _foo - about variables inside a class

    - by kame
    class ClassName(object): """ """ def __init__(self, foo, bar): """ """ self.foo = foo # read-write property self.bar = bar # simple attribute def _set_foo(self, value): self._foo = value def _get_foo(self): return self._foo foo = property(_get_foo, _set_foo) a = ClassName(1,2) #a._set_foo(3) print a._get_foo() When I print a._get_foo() the function _get_foo prints the variable self._foo . But where does it come from? self._foo and self.foo are different, aren't they?

    Read the article

  • In what order should the Python concepts be explained to absolute beginners?

    - by Tomaž Pisanski
    I am teaching Python to undergraduate math majors. I am interested in the optimal order in which students should be introduced to various Python concepts. In my view, at each stage the students should be able to solve a non-trivial programming problem using only the tools available at that time. Each new tool should enable a simpler solution to a familiar problem. A selection of numerous concepts available in Python is essential in order to keep students focused. They should also motivated and should appreciate each newly mastered tool without too much memorization. Here are some specific questions: For instance, my predecessor introduced lists before strings. I think the opposite is a better solution. Should function definitions be introduced at the very beginning or after mastering basic structured programming ideas, such as decisions (if) and loops (while)? Should sets be introduced before dictionaries? Is it better to introduce reading and writing files early in the course or should one use input and print for most of the course? Any suggestions with explanations are most welcome.

    Read the article

  • How to display multiple categories and products underneath each category?

    - by shin
    Generally there is a category menu and each link to a category page where shows all the items under that category. Now I need to show all the categories and products underneath with PHP/MySQL in the same page. So it will be like this. Category 1 description of category 1 item 1 item 2 .. Category 2 description of category 2 item 5 item 6 .. Category 3 description of category 3 item 8 item 9 ... ... I have category and product table in my database. But I am not sure how to proceed. CREATE TABLE IF NOT EXISTS `omc_product` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `shortdesc` varchar(255) NOT NULL, `longdesc` text NOT NULL, `thumbnail` varchar(255) NOT NULL, `image` varchar(255) NOT NULL, `product_order` int(11) DEFAULT NULL, `class` varchar(255) DEFAULT NULL, `grouping` varchar(16) DEFAULT NULL, `status` enum('active','inactive') NOT NULL, `category_id` int(11) NOT NULL, `featured` enum('none','front','webshop') NOT NULL, `other_feature` enum('none','most sold','new product') NOT NULL, `price` float(7,2) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; CREATE TABLE IF NOT EXISTS `omc_category` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `shortdesc` varchar(255) NOT NULL, `longdesc` text NOT NULL, `status` enum('active','inactive') NOT NULL, `parentid` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; I will appreciate your help. Thanks in advance.

    Read the article

  • "Finding" an object instance of a known class?

    - by Sean C
    My first post here (anywhere for that matter!), re. Cocoa/Obj-C (I'm NOT up to speed on either, please be patient!). I hope I haven't missed the answer already, I did try to find it. I'm an old-school procedural dog (haven't done any programming since the mid 80's, so I probably just can't even learn new tricks), but OOP has my head spinning! My question is: is there any means at all to "discover/find/identify" an instance of an object of a known class, given that some OTHER unknown process instantiated it? eg. somthing that would accomplish this scenario: (id) anObj = [someTarget getMostRecentInstanceOf:[aKnownClass class]]; for that matter, "getAnyInstance" or "getAllInstances" might do the trick too. Background: I'm trying to write a plugin for a commercial application, so much of the heavy lifting is being done by the app, behind the scenes. I have the SDK & header files, I know what class the object is, and what method I need to call (it has only instance methods), I just can't identify the object for targetting. I've spent untold hours and days going over Apples documentation, tutorials and lots of example/sample code on the web (including here at Stack Overflow), and come up empty. Seems that everything requires a known target object to work, and I just don't have one. Since I may not be expressing my problem as clearly as needed, I've put up a web page, with diagram & working sample pages to illustrate: http://www.nulltime.com/svtest/index.html Any help or guidance will be appreciated! Thanks.

    Read the article

  • utf8 format in xml

    - by hussain
    i want to know how to store this è (this type of symbols) in xml file if i store this symbol in xml file.. the file shows this symbol like ? i was inserted in front of xml file is <?xml version="1.0" encoding="UTF-8"?> but that doest not shows correct thanks and advance

    Read the article

< Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >