Search Results

Search found 91526 results on 3662 pages for 'clean code'.

Page 270/3662 | < Previous Page | 266 267 268 269 270 271 272 273 274 275 276 277  | Next Page >

  • How can i optimize this python code

    - by RandomVector
    def maxVote(nLabels): count = {} maxList = [] maxCount = 0 for nLabel in nLabels: if nLabel in count: count[nLabel] += 1 else: count[nLabel] = 1 #Check if the count is max if count[nLabel] > maxCount: maxCount = count[nLabel] maxList = [nLabel,] elif count[nLabel]==maxCount: maxList.append(nLabel) return random.choice(maxList) nLabels contains a list of integers. The above function returns the integer with highest frequency, if more than one have same frequency then a randomly selected integer from them is returned. E.g. maxVote([1,3,4,5,5,5,3,12,11]) is 5

    Read the article

  • Shortest anagrams finder [C++]

    - by Cente
    Hey, take this as a challange, my informatics professor made it in less than 10 rows, it work perfectly and its very efficient. I'd like to "surprise" him giving a better/shorted version of it. Ofcourse i wouldn't take the credits, hah, u can trust in me. It's a simple anagras finder! If you can.. write it in c++! thanks!

    Read the article

  • Source code repository portal

    - by gmoorevt
    I am looking for a "portal" for wrapping our large Subversion repositories similar to GitHub. Does anyone know of any options? Features we are looking for are; home page for projects that include wiki bug tracking etc. This would be for an internal deployment.

    Read the article

  • JQuery-code on different content pages

    - by Ockonal
    Hello, I have a site with menu, which reloads content. Content is dynamically loadable, using ajax and php-script. At different content pages I need in different jquery-plugins. But If I'm writing including need plugin directly in some content page, I get a big lags during loading. So, now I'm includgin all plugins into main page... And it's not the best idea... Any suggestion? UPD: I have a div with content. Content is shown with effects (rolling up/down). When part of menu is clicked, I'm sending ajax-responce to the php script, which reads need text from database and returns it to the main page, from which I sent the responce. Than I'm pasting that content into a div and roll id down. So I'll include jquery-plugins in content pages, the animation of rolling will'nt be normal.

    Read the article

  • PHP: Remove all fcn not acting as expected, Code Inside

    - by Josh K
    I made this simple function (remove all $elem from $array): function remall($array, $elem) { for($i=0; $i < count($array); $i++) if($array[$i] == $elem) unset($array[$i]); $newarray = array_values($array); return $newarray; } But it isn't working perfectly, here are some inputs and outputs $u = array(1, 7, 2, 7, 3, 7, 4, 7, 5, 7, 6, 7); $r = remall($u, 7); Output of $r: 12345767 $n = array(7, 7, 1, 7, 3, 4, 6, 7, 2, 3, 1, -3, 10, 11, 7, 7, 7, 2, 7); $r = remall($n, 7); Output of $r: 1346231-30117727 Notice how there are still 7s in my outputs. Also, My function will only be removing numbers from an array. Let me know if you spot something, thanks.

    Read the article

  • how can this inner enum code be improved ?

    - by mafalda
    I have this construct public class Constants{ enum SystemA implements Marker{ ConstOne(1), ConstTwo(2), ConstThree(3); SystemA(int i) { number =i; } int number; } enum SystemB implements Marker{ ConstFour(4), ConstFive(5), ConstSix(6); SystemB(int i) { number =i; } int number; } } I have Marker so I can pass to method like this method(Constants.SystemA) or method(Constants.SystemB) What is the best way to list all the enum values ? I also want to make sure that it is not duplicating the number in any of the enums

    Read the article

  • get attribute value from html code in java

    - by sang
    Hi All i have HTML string value and i want to get one attribute(id) value from that html String value can u help me how to do it?? String msHTMLFile = "<ABBR class='HighlightClass' id='highlight40001' style=\"BACKGROUND-COLOR: yellow\" >Fetal/Neonatal Morbidity and Mortality</ABBR>"; result should come - highlight40001;

    Read the article

  • class member access specifiers and binary code

    - by pdehaan
    I understand what the typical access specifiers are, and what they mean. 'public' members are accessible anywhere, 'private' members are accessible only by the same class and friends, etc. What I'm wondering is what, if anything, this equates to in lower-level terms. Are their any post-compilation functional differences between these beyond the high-level restrictions (what can access what) imposed by the language (c++ in this case) they're used in. Another way to put it - if this were a perfect world where programmers always made good choices (like not accessing members that may change later and using only well defined members that should stay the same between implementations), would their be any reason to use these things?

    Read the article

  • How To Read C# Code From Java Background

    - by ChloeRadshaw
    I come from a Java background and have been using C# for the last year - So far the API docs I use are at MSDN (http://msdn.microsoft.com/en-us/library/ms132397.aspx). I tend to use the lightweight C# docs. What annoys me about that is that I don't see one page with details of the class, a list of members, a list of methods and properties like I would with a Java API definition. Is this possible?

    Read the article

  • floating point exception in C++ code !

    - by mekasperasky
    #include<stdio.h> #include<math.h> int main () { FILE *fp; fp=fopen("output","w"); float t,y=0,x=0,e=5,f=1,w=1; for (t=0;t<10;t=t+0.01) { if( y==inf && y== nan) break; fprintf(fp,"%lf\t%lf\n",y,x); y = y + ((e*(1 - x*x)*y) - x + f*cos(w*t))*t; x = x + y*t; } return (0); } why is the ouput giving infinite and NAN values?

    Read the article

  • Python: Problems finding string in website source code

    - by j00niner
    I open a website with urlopen. I then put the website sourcecode into a variable like so source = website.read() When I just print the source it comes out formatted correctly, however when I try to iterate through each line each character is it's own line. for example when I just print it looks like this <HTML> title</html> When I do this for line in source: print line it looks like this < H T M L ... etc I need to find a string that starts with "var" and then print that entire line.

    Read the article

  • C# Possible to partial class "program" class for a console application?

    - by JL
    I was wondering if its possible to change the default "program" class that gets created for any console application to a partial class. I want to do this because I want better organisation rather than have all methods in 1 file categorized by region. It would make more sense for me to have certain method categories sitting in separate files. My understanding of a partial class is that it is a class definition in multiple files that during a compile merges the class files into 1 class unit. I could be wrong, or there could be a better way for me to achieve better organisational structure. Any suggestions would help, and thanks

    Read the article

  • What is the problem with this code?

    - by eSKay
    #include<stdio.h> class A { public: int a;}; class B: public A { public: static int b; B(){ b++; printf("B:%d\n",b); } }; int main() { A* a1 = new B[100]; A* a2 = new B(); return 0; } Error: In function `main': undefined reference to `B::b' undefined reference to `B::b' undefined reference to `B::b' undefined reference to `B::b'

    Read the article

  • code setOnClickListener for multiple TextViews

    - by user2870583
    I have 40+ TextViews and I want to add click events on them, but I try to do it "shortly" : final GridLayout myGL; myGL = (GridLayout) v0725.findViewById( R.id.tab1 ); for( int i = 0; i < myGL.getChildCount(); i++ ) if ( getResources().getResourceEntryName(((TextView) myGL.getChildAt(i)).getId()).indexOf("v")==0 ) { ((TextView) myGL.getChildAt(i)).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Log.v("edf", getResources().getResourceEntryName(((TextView) myGL.getChildAt(i)).getId())); } }); }; But Eclipse stops me on the Log.v line, because i should be final (but I can't) any tips?

    Read the article

  • Why won't this piece of my code write to file

    - by user2934783
    I am developing a c++ banking system. I am able to get the float, newbal, values correctly and when I try to write to file, there is no data in the file. else { file>>firstname>>lastname; cout<<endl<<firstname<<" "<<lastname<<endl; cout<<"-----------------------------------\n"; string line; while (getline(file, line)) { //stringstream the getline for line string in file istringstream iss(line); if (iss >> date >> amount) { cout<<date<<"\t\t$"<<showpoint<<fixed<<setprecision(2)<<amount<<endl; famount+=amount; } } cout<<"Your balance is $"<<famount<<endl; cout<<"How much would you like to deposit today: $"; cin>>amountinput; float newbal=0; newbal=(famount+=amountinput); cout<<"\nYour new balance is: $"<<newbal<<".\n"; file<<date<<"\t\t"<<newbal; //***This should be writing to file but it doesn't. file.close(); The text file looks like this: Tony Gaddis 05/24/12 100 05/30/12 300 07/01/12 -300 //Console Output looks like this Tony Gaddis 05/24/12 100 05/30/12 300 07/01/12 -300 Your balance is: #1 How much wuld you like to deposit: #2 Your new balance is: #1 + #2 write to file close file. //exits to main loop:::: How can I make it write to file and save it, and why is this happening. I tried doing it with ostringstream as well considering how I used istringstream for the input. But it didn't work either :\ float newbal=0; newbal=(famount+=amountinput); ostringstream oss(newbal); oss<<date<<"\t\t"<<newbal; I am trying to self teach c++ so any relevant information would be kindly appreciated.

    Read the article

  • Access dynamically generated control from code behind

    - by user648922
    I load a piece of html which contains something like: <em> < input type="text" value="Untitled" name="ViewTitle" id="ViewTitle" runat="server"> </em> into my control. The html is user defined, do please do not ask me to add them statically on the aspx page. On my page, I have a placeholder and I can use LiteralControl target = new LiteralControl (); // html string contains user-defined controls target.text = htmlstring to render it property. My problem is, since its a html piece, even if i know the input box's id, i cannot access it using FindControl("ViewTitle") (it will just return null) because its rendered as a text into a Literal control and all the input controls were not added to the container's control collections. I definitely can use Request.Form["ViewTitle"] to access its value, but how can I set its value?

    Read the article

  • ruby code inside quotes

    - by chief
    I would like to embed videos and have managed to to do so by manually coding the url in where needed. If my url is stored in <%= @vid.url %, how can I use that string for the value and src parameter? <object width="480" height="385"><param name="movie" value="http://www.youtube.com/videos/abc123"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/videos/abc123" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>

    Read the article

  • asp code for excel upload

    - by vicky
    i want to upload an excel file from the client to the server using asp .then it shud check the field name of the file with the oracle database table and then save its content in the database. can somebody help me with this....??

    Read the article

< Previous Page | 266 267 268 269 270 271 272 273 274 275 276 277  | Next Page >