Search Results

Search found 2654 results on 107 pages for 'c sharp newbie'.

Page 7/107 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Taking "do the simplest thing that could possible work" too far in TDD: testing for a file-name kno

    - by Support - multilanguage SO
    For TDD you have to Create a test that fail Do the simplest thing that could possible work to pass the test Add more variants of the test and repeat Refactor when a pattern emerge With this approach you're supposing to cover all the cases ( that comes to my mind at least) but I'm wonder if am I being too strict here and if it is possible to "think ahead" some scenarios instead of simple discover them. For instance, I'm processing a file and if it doesn't conform to a certain format I am to throw an InvalidFormatException So my first test was: @Test void testFormat(){ // empty doesn't do anything nor throw anything processor.validate("empty.txt"); try { processor.validate("invalid.txt"); assert false: "Should have thrown InvalidFormatException"; } catch( InvalidFormatException ife ) { assert "Invalid format".equals( ife.getMessage() ); } } I run it and it fails because it doesn't throw an exception. So the next thing that comes to my mind is: "Do the simplest thing that could possible work", so I : public void validate( String fileName ) throws InvalidFormatException { if(fileName.equals("invalid.txt") { throw new InvalidFormatException("Invalid format"); } } Doh!! ( although the real code is a bit more complicated, I found my self doing something like this several times ) I know that I have to eventually add another file name and other test that would make this approach impractical and that would force me to refactor to something that makes sense ( which if I understood correctly is the point of TDD, to discover the patterns the usage unveils ) but: Q: am I taking too literal the "Do the simplest thing..." stuff?

    Read the article

  • jquery full calendar

    - by madrat
    hello everybody. I am new to fullCalendar and i do not kno how to use gotoDate method. What i have is a tabbed page with 12 tabs (every tab is a month of the year). What i need is when i load jquery calendar, foreach tab, the calendar to switch to the month that is assigned. (e.g when i click and load page for January the calendar shows days for january, and so on). thanks for your help.

    Read the article

  • What exactly are tuples in Python?

    - by Sergio Tapia
    I'm following a couple of Pythone exercises and I'm stumped at this one. # C. sort_last # Given a list of non-empty tuples, return a list sorted in increasing # order by the last element in each tuple. # e.g. [(1, 7), (1, 3), (3, 4, 5), (2, 2)] yields # [(2, 2), (1, 3), (3, 4, 5), (1, 7)] # Hint: use a custom key= function to extract the last element form each tuple. def sort_last(tuples): # +++your code here+++ return What is a Tuple? Do they mean a List of Lists?

    Read the article

  • I want to better organize my website files, but I can access the .php files using the folder heirarc

    - by Sergio Tapia
    For example, to access a page in my search folder, I have to write: mywebsite.tld/search/searchJob.php I don't want users to have to write down folder structure and whatnot. What can I do to change this? OR, is there a better way to organize my files? Because I'm only two pages in and I decided to move some files and got lost in the heirarchy (that's why I moved them like in the picture).

    Read the article

  • Generic collection as a Java method argument

    - by Guido
    Is there any way to make this work in Java? public static void change(List<? extends Object> list, int position1, int position2) { Object obj = list.get(position1); list.set(position1, list.get(position2)); list.set(position2, obj); } The only way I've successfully avoided warnings and errors is this: public static <T> T change(List<T> list, int position1, int position2) { T obj = list.get(position1); list.set(position1, list.get(position2)); list.set(position2, obj); return obj; } but I don't like to be forced to return a value.

    Read the article

  • How do you clear the focus in javascript?

    - by Andres
    I know this shouldn't be that hard, but I couldn't find the answer on Google. I want to execute a piece of javascript that will clear the focus from whatever element it is on without knowing ahead of time which element the focus is on. It has to work on firefox 2 as well as more modern browsers. Is there a good way to do this?

    Read the article

  • Drupal: How long should it take to rebuild permissions

    - by Shaun
    Hi, I have just installed the ACL and Content Access module. Imedietly after enabling them I was asked to rebuild the permissions. All perfectly normal I am told. However, I set the 'rebuild' permissions page running about 40 minutes ago and it still says 'Initializing'. How long should it take? Am I doing something wrong?

    Read the article

  • Python 2.5.2: trying to open files recursively

    - by user248959
    Hi, the script below should open all the files inside the folder 'pruebaba' recursively but i get this error: Traceback (most recent call last): File "/home/tirengarfio/Desktop/prueba.py", line 8, in f = open(file,'r') IOError: [Errno 21] Is a directory This is the hierarchy: pruebaba folder1 folder11 test1.php folder12 test1.php test2.php folder2 test1.php The script: import re,fileinput,os path="/home/tirengarfio/Desktop/pruebaba" os.chdir(path) for file in os.listdir("."): f = open(file,'r') data = f.read() data = re.sub(r'(\s*function\s+.*\s*{\s*)', r'\1echo "The function starts here."', data) f.close() f = open(file, 'w') f.write(data) f.close() Any idea? Regards Javi

    Read the article

  • Bundle module with app on Google App Engine

    - by Oscar Reyes
    This may be a basic question but how can I include a module with my app. I'm very new to python and what I want to do is to include this module simplejson with my app, but after downloading it I have no idea what to do next :( This is how the module looks like after unzip it. I don't know what files to move to my app.

    Read the article

  • Shutdown and WakeUp Script C#

    - by Stephen Murby
    Hiya I am very new to C#, infact this is basically my first task set by work whilst i learn the language. Yes i am also new to programming, be gentle :). Context: My script needs to query active directory, grab of OU's and put them to a combo box in a form. Next query ActDir for a list of machines in a selected OU (Done this in a vbscript already) Next query the machines in turn for there IP, and MAC addresses.(Done this in a vbscript already) Next needs to shut those machines down(Done this in a vbscript already) and dump all the machine and NIC info to a txt file The other half of the script grabs the info for the machines out of the text file and sends them a magic packet to wake them up. The shutdown section i have already written a VBscript for, but decided it wasn't future prrof, and i was learninc C# at home, so figured it was the best option to start over with. Im not looking for anyone to write this for me, but if anyone had any pointers on where to go for information etc. . . It would be more than appreciated :)

    Read the article

  • git-svn merge 2 svn branches

    - by idimba
    I using svn. I have two branches and on both of them were performed a lot of changes. In addition of one of the branches a lot of files were renamed, so now svn can not help me merge changes in those files (well know svn limitation). Is it possible using git-svn to perform the merge of the branches? Will git-svn hanndle renamed files too? Thanks

    Read the article

  • Why can't I install psycopg2? (Python 2.6.4, PostgreSQL 8.4, OS X 10.6.3)

    - by cojadate
    UPDATE: After updating all my software, the error message has changed. Now, when I run "python setup.py install" I get the following: Warning: Unable to find 'pg_config' filebuilding 'psycopg2._psycopg' extension gcc-4.0 -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.2.1 (dt dec ext pq3)" -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1 -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -I. -c psycopg/psycopgmodule.c -o build/temp.macosx-10.3-fat-2.6/psycopg/psycopgmodule.o followed by a very long list of other error messages. After running python setup.py install I get the following: Warning: Unable to find 'pg_config' filebuilding 'psycopg2._psycopg' extension gcc-4.0 -arch ppc -arch i386 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 - DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.2.1 (dt dec ext pq3)" -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1 -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -I. -c psycopg/psycopgmodule.c -o build/temp.macosx-10.3-fat-2.6/psycopg/psycopgmodule.o unable to execute gcc-4.0: No such file or directory error: command 'gcc-4.0' failed with exit status 1 There's probably something screamingly obvious there to anyone who knows the first thing about back-end web programming, but unfortunately it's all gobbledegook to me. The psycopg2 documentation was not helpful.

    Read the article

  • Does height and width not apply to span?

    - by Kyle Sevenoaks
    Total noob question, but here. CSS .product__specfield_8_arrow { /*background-image:url(../../upload/orng_bg_arrow.png); background-repeat:no-repeat;*/ background-color:#fc0; width:50px !important; height:33px !important; border: 1px solid #dddddd; border-left:none; border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px; border-bottom-left-radius:0px; border-top-left-radius:0px; -moz-border-radius-bottomleft:0px; -moz-border-radius-topleft:0px; -webkit-border-bottom-left-radius:0px; -webkit-border-top-left-radius:0px; margin:0; padding:2px; cursor:pointer; }??? HTML <span class="product__specfield_8_arrow">&nbsp;</span>? Fiddle Basically I'm trying to emulate a button, make a span (or something) look like a button next to an input field that actually doesn't need to be one because of an auto fill generator that generates errors onEnter. Thought this'd be a quick fix for now but obviously not. Thanks.

    Read the article

  • Project Euler #290 in python, hint please

    - by debragail
    This solution is grossly inefficient. What am I missing? #!/usr/bin/env python #coding: utf-8 import time from timestrings import * start = time.clock() maxpower = 18 count = 0 for i in range(0, 10 ** maxpower - 1): if i % 9 == 0: result1 = list(str(i)) result2 = list(str(137 * i)) sum1 = 0 for j in result1: sum1 += int(j) sum2 = 0 for j in result2: sum2 += int(j) if sum1 == sum2: print (i, sum1) count += 1 finish = time.clock() print ("Project Euler, Project 290") print () print ("Answer:", count) print ("Time:", stringifytime(finish - start))

    Read the article

  • Method synonyms in Ruby

    - by Max
    I'm familiarizing myself with Ruby and it's the first time I see synonyms for methods in the standard library. For now I've found the ones in the Enumerable module: collect <- map detect <- find include <- member etc. Probably other modules contains synonymic methods too. Why are they there? Is it some kind of backward compatibility? Or is it a feature of the language, so the programmer can choose between different options depending on the context to make the program look like plain English?

    Read the article

  • Efficient splitting of elements in a field

    - by Gary
    I have a field in a text file exported from a database. The field contains addresses but sometimes they are quite long and the database allows them to contain multiple lines. When exported, the newline character gets replaced with a dollar sign like this: first part of very long address$second part of very long address$third part of very long address Not every address has multiple lines and no address contains more than three lines. The length of each line is variable. I'm massaging the data for import into MS Access which is used for a mailmerge. I want to split the field on the $ sign if it's there but if the field only contains 1 line, I want to set my two extra output fields to a zero length string so that I don't wind up with blank lines in the address when it gets printed. I have an awk file that's working correctly on all the other data in the textfile but I need to get this last bit working. I tried the below code. Aside from the fact that I get a syntax error at the else, I'm not sure this is a good way to do what I want. This is being done with gawk on Windows. BEGIN { FS = "|" } $1 != "HEADER" { if ($6 ~ /\$/) split($6, arr, "$") address = arr[1] addresstwo = arr[2] addressthree = arr[3] addressLength = length(address) addressTwoLength = length(addresstwo) addressThreeLength = length(addressthree) else { address = $6 addressLength = length($6) addresstwo = "" addressTwoLength = length(addresstwo) addressthree = "" addressThreeLength = length(addressthree) } printf("%*s\t%*s\t\%*s\n", addressLength, address, addressTwoLength, addresstwo, addressThreeLength, addressthree) }

    Read the article

  • Open Source Contribution for a newbie programmer.

    - by sasayins
    Hi, I am teaching programming to my nephews and I want them to improve their skills by contributing to open source projects. Now my question is, do you know any open source project that suit for a newbie programmer. What I mean is, the project does not have a large codebase, the project is very interesting and the project is written in C because I chose C language as their starting language but you can suggest other project made in other language. My goal here are to improve their logic by reading other source codes, familiarize to the available development tools like bug tracker, version control system, etc. and open their interest in open source community. Thanks. =)

    Read the article

  • Why does ANTLR not parse the entire input?

    - by Martin Wiboe
    Hello, I am quite new to ANTLR, so this is likely a simple question. I have defined a simple grammar which is supposed to include arithmetic expressions with numbers and identifiers (strings that start with a letter and continue with one or more letters or numbers.) The grammar looks as follows: grammar while; @lexer::header { package ConFreeG; } @header { package ConFreeG; import ConFreeG.IR.*; } @parser::members { } arith: term | '(' arith ( '-' | '+' | '*' ) arith ')' ; term returns [AExpr a]: NUM { int n = Integer.parseInt($NUM.text); a = new Num(n); } | IDENT { a = new Var($IDENT.text); } ; fragment LOWER : ('a'..'z'); fragment UPPER : ('A'..'Z'); fragment NONNULL : ('1'..'9'); fragment NUMBER : ('0' | NONNULL); IDENT : ( LOWER | UPPER ) ( LOWER | UPPER | NUMBER )*; NUM : '0' | NONNULL NUMBER*; fragment NEWLINE:'\r'? '\n'; WHITESPACE : ( ' ' | '\t' | NEWLINE )+ { $channel=HIDDEN; }; I am using ANTLR v3 with the ANTLR IDE Eclipse plugin. When I parse the expression (8 + a45) using the interpreter, only part of the parse tree is generated: http://imgur.com/iBaEC.png Why does the second term (a45) not get parsed? The same happens if both terms are numbers. Thank you, Martin Wiboe

    Read the article

  • Wondering where to begin

    - by Cat
    Hello all. After being interested for years and years (and years), I have finally decided to start learning how to create software and web applications. Base on recommendations, I have started with learning the basics of web design first (which I am almost done with) and then will move on to the meat of my process: learning the languages. Problem is, I don't know where to start :/ PHP, Ruby, Perl...and where would SQL, JavaScript and .NET fit into the mix? I am assuming they build on each other/play off of each other somewhat so following some sort of 'order' will make the process more logical and digestible. You're probably thinking, "Just go to school for computer engineering, duh!" But I already have a degree and don't plan on going back to school. I believe I have an adequate aptitude for this sort of thing, and although it will be challenging, with the support of the community I know I can do it on my own. Thank in advance everyone and I am very sorry for the length. I look forward to hearing what all you have to say. Warm Regards, Cat

    Read the article

  • Aspiring Web Developer

    - by ihaveitnow
    Hi guys, I want to be a web developer and mobile web developer...I know HTML Iv done some research and read that XML and XHTML are necessary. Are there any other languages that I need to know? Would knowledge of Flash help me in my quest? I also want to become an Android App developer :) (go open-source!) But thats for a different post. I hope I can make links within this community, thanks for reading and even more for responses.

    Read the article

  • asyncronous call doesn't return json

    - by Rebecca
    I am running wamp on an xp box. I am fairly new to web programming, this is for a student project, and have run out of avenues to try to solve this problem. Problem We have client side JavaScript code that uses GDownloadUrl- from the Google api- to wrap xmlHttpRequest calls to a php server side program that is accessing our database. In my callback program, the result of this call is always " ". However, if I use an alert to display the http:// call, with the arguments, and cut and paste that into my browser, the json I expected is displayed. I zipped my dir containing all the files, and tried it out on another team member's computer, and they were able to get the json in the callback function. Note this is exactly the same code and structure I was using, he just unzipped and ran. So now I'm thinking this is something about Firefox or Wamp? Would this be a config problem? I'm running wamp server 2.0, and Firefox 3.5.8. I have no problems with syncronous php, or reading in files asyncronously. Any help would be greatly appreciated. Rebecca

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >