Search Results

Search found 28877 results on 1156 pages for 'do good'.

Page 54/1156 | < Previous Page | 50 51 52 53 54 55 56 57 58 59 60 61  | Next Page >

  • Writing good tests for Django applications

    - by Ludwik Trammer
    I've never written any tests in my life, but I'd like to start writing tests for my Django projects. I've read some articles about tests and decided to try to write some tests for an extremely simple Django app or a start. The app has two views (a list view, and a detail view) and a model with four fields: class News(models.Model): title = models.CharField(max_length=250) content = models.TextField() pub_date = models.DateTimeField(default=datetime.datetime.now) slug = models.SlugField(unique=True) I would like to show you my tests.py file and ask: Does it make sense? Am I even testing for the right things? Are there best practices I'm not following, and you could point me to? my tests.py (it contains 11 tests): # -*- coding: utf-8 -*- from django.test import TestCase from django.test.client import Client from django.core.urlresolvers import reverse import datetime from someproject.myapp.models import News class viewTest(TestCase): def setUp(self): self.test_title = u'Test title: bareksc' self.test_content = u'This is a content 156' self.test_slug = u'test-title-bareksc' self.test_pub_date = datetime.datetime.today() self.test_item = News.objects.create( title=self.test_title, content=self.test_content, slug=self.test_slug, pub_date=self.test_pub_date, ) client = Client() self.response_detail = client.get(self.test_item.get_absolute_url()) self.response_index = client.get(reverse('the-list-view')) def test_detail_status_code(self): """ HTTP status code for the detail view """ self.failUnlessEqual(self.response_detail.status_code, 200) def test_list_status_code(self): """ HTTP status code for the list view """ self.failUnlessEqual(self.response_index.status_code, 200) def test_list_numer_of_items(self): self.failUnlessEqual(len(self.response_index.context['object_list']), 1) def test_detail_title(self): self.failUnlessEqual(self.response_detail.context['object'].title, self.test_title) def test_list_title(self): self.failUnlessEqual(self.response_index.context['object_list'][0].title, self.test_title) def test_detail_content(self): self.failUnlessEqual(self.response_detail.context['object'].content, self.test_content) def test_list_content(self): self.failUnlessEqual(self.response_index.context['object_list'][0].content, self.test_content) def test_detail_slug(self): self.failUnlessEqual(self.response_detail.context['object'].slug, self.test_slug) def test_list_slug(self): self.failUnlessEqual(self.response_index.context['object_list'][0].slug, self.test_slug) def test_detail_template(self): self.assertContains(self.response_detail, self.test_title) self.assertContains(self.response_detail, self.test_content) def test_list_template(self): self.assertContains(self.response_index, self.test_title)

    Read the article

  • CodeCharge : is it any good?

    - by David Burrows
    Hi, A job came in to me that's built with CodeCharge - had a look at it and seems to be a pretty basic point-and-click site builder tool. Has anyone got any in-depth experience with it? My first reaction is one of horror and to just rebuild the code in Rails or PHP but I thought I'd ask the question first, maybe i'm missing something...

    Read the article

  • Good book suggestions for building enterprise software

    - by ncoder
    Enterprise software are built using technologies/softwares/terminologies/APIs such as EJB, JBoss, Seam, Hibernate(JPA), Maven, Eclipse, Spring, JTS, JMS, JNDI etc. I know there are great books out there for each of these individually, however can someone suggest a book or two that covers all (or most of) these topics in lesser detail and gives examples of how these are integrated? I have intentionally left the client side stuff out because its highly unlikely a single book would cover that much. If anyone knows of a book (or books) that cover most of or various combinations (like EJB, Hibernate, Spring and Seam) of these technologies, please do suggest the same. The idea is not to become an expert in all however know about them in reasonable detail and why each one is required.

    Read the article

  • WiX: Extracting Binary-string in Custom Action yields string like "???good data"

    - by leiflundgren
    I just found a weird behaviour when attempting to extract a string from the Binary-table in the MSI. I have a file containing "Hello world", the data I get is "???Hello world". (Literary question mark.) Is this as intended? Will it always be exactly 3 characters in the beginning? Regards Leif Sample code: [CustomAction] public static ActionResult CustomAction2(Session session) { View v = session.Database.OpenView("SELECT `Name`,`Data` FROM `Binary`"); v.Execute(); Record r = v.Fetch(); int datalen = r.GetDataSize("Data"); System.IO.Stream strm = r.GetStream("Data"); byte[] rawData = new byte[datalen]; int res = strm.Read(rawData, 0, datalen); strm.Close(); String s = System.Text.Encoding.ASCII.GetString(rawData); // s == "???Hello World" return ActionResult.Success; }

    Read the article

  • What's A Good Real Time Html Editing Extension?

    - by David
    Hi, i always like to real-time edit a web page source in the browser and updated as i type, but firebug really sucks, i can't insert scripts in the current page, some times the changes i type aren't updated at all, Is there any robust firefox/chrome extension for that? i try to temporarely edit/add code to an existing web page in the internet, not a local one Thanks

    Read the article

  • Good learning resources for JNDI implementation (JBoss 5)

    - by iandisme
    I have been working with JavaEE/EJB3 web apps for about half a year now. Until recently, I haven't had to touch a lot of the behind-the-scenes stuff, just the meat of the code. I have been wrestling with JNDI problems, and though I've solved a couple of them, I'm pretty much just doing the whole cargo cult copy-paste routine. It would really help me to better understand JNDI; my understanding of it right now can be summarized as "it's that thing these classes sometimes do to find other classes." My question is, has anyone had success learning JNDI/EJB3/related topics from a book or online content? I've googled for it but the stuff that comes up is old or specific to a certain framework I'm not using. I'm looking for something that's either JBoss-specific or generic enough to be useful anyway.

    Read the article

  • What some good PHP jobs?

    - by ggfan
    I am no professional PHP coder or anything, in fact I am fairly new. I can develop sites but nothing too crazy or fancy with PHP,Mysql,CSS,HTML,javascript. Up to now, all I have been doing is practice coding from books and websites. I am now looking for a 'real-life' experience. Besides going to a company and getting an interview, are there any other options in which I can get paid to code? I have posted some ads on craiglists but that's about it. And because this is my first time going to the 'real-word' and can make mistakes, am I liable if...a site I made for someone gets hacked and that person losses information?

    Read the article

  • Good conventions for embedding schema of a flat file

    - by Ville Koskinen
    We receive lots of data as flat files: delimitted or just fixed length records. It's sometimes hard to find out what the files actually contain. Are there any well established practices for embedding the schema of the file to the beginning or the end of a file to make the file self-explanatory? Just to get an idea, imagine something like this: <data name=test records=2 type=fixed> <field name=foo start=0 length=2 type=numeric> <field name=bar start=2 length=4 type=text> </data> 11test 12ing We would parse the xml in the beginning and use it for reading the records.

    Read the article

  • Good style for handling constructor failure of critical object

    - by mtlphil
    I'm trying to decide between two ways of instantiating an object & handling any constructor exceptions for an object that is critical to my program, i.e. if construction fails the program can't continue. I have a class SimpleMIDIOut that wraps basic Win32 MIDI functions. It will open a MIDI device in the constructor and close it in the destructor. It will throw an exception inherited from std::exception in the constructor if the MIDI device cannot be opened. Which of the following ways of catching constructor exceptions for this object would be more in line with C++ best practices Method 1 - Stack allocated object, only in scope inside try block #include <iostream> #include "simplemidiout.h" int main() { try { SimpleMIDIOut myOut; //constructor will throw if MIDI device cannot be opened myOut.PlayNote(60,100); //..... //myOut goes out of scope outside this block //so basically the whole program has to be inside //this block. //On the plus side, it's on the stack so //destructor that handles object cleanup //is called automatically, more inline with RAII idiom? } catch(const std::exception& e) { std::cout << e.what() << std::endl; std::cin.ignore(); return 1; } std::cin.ignore(); return 0; } Method 2 - Pointer to object, heap allocated, nicer structured code? #include <iostream> #include "simplemidiout.h" int main() { SimpleMIDIOut *myOut; try { myOut = new SimpleMIDIOut(); } catch(const std::exception& e) { std::cout << e.what() << std::endl; delete myOut; return 1; } myOut->PlayNote(60,100); std::cin.ignore(); delete myOut; return 0; } I like the look of the code in Method 2 better, don't have to jam my whole program into a try block, but Method 1 creates the object on the stack so C++ manages the object's life time, which is more in tune with RAII philosophy isn't it? I'm still a novice at this so any feedback on the above is much appreciated. If there's an even better way to check for/handle constructor failure in a siatuation like this please let me know.

    Read the article

  • Rails - good tool to create a scheduled background process which will regularly retrieve messages fr

    - by adam
    Background Job gets mentioned a lot but all the tutorials I've seen seem to indicate that its for queuing jobs which are created by some external event such as a user clicking "Send mail". But what about when you have code that needs to scheduled to run every 30 seconds to listen for new messages from twitter? Normally rake is recommended for set in stone schedules but it inst so efficient for frequent jobs as it has to to load the entire rails app each time. Can anyone recommend anything for this situation?

    Read the article

  • Are functional programming languages good for practical tasks?

    - by Clueless
    It seems to me from my experimenting with Haskell, Erlang and Scheme that functional programming languages are a fantastic way to answer scientific questions. For example, taking a small set of data and performing some extensive analysis on it to return a significant answer. It's great for working through some tough Project Euler questions or trying out the Google Code Jam in an original way. At the same time it seems that by their very nature, they are more suited to finding analytical solutions than actually performing practical tasks. I noticed this most strongly in Haskell, where everything is evaluated lazily and your whole program boils down to one giant analytical solution for some given data that you either hard-code into the program or tack on messily through Haskell's limited IO capabilities. Basically, the tasks I would call 'practical' such as Aceept a request, find and process requested data, and return it formatted as needed seem to translate much more directly into procedural languages. The most luck I have had finding a functional language that works like this is Factor, which I would liken to a reverse-polish-notation version of Python. So I am just curious whether I have missed something in these languages or I am just way off the ball in how I ask this question. Does anyone have examples of functional languages that are great at performing practical tasks or practical tasks that are best performed by functional languages?

    Read the article

  • What's a good way to create an Event Calendar

    - by iFloh
    Hi, I want to create an Event Calendar for my iPhone App. In a first instance the Event Calendar is supposed to list the Events and have a Details View with additional info. It is also supposed to contain an action to trasfer a specific event to the iPhone Calendar. First thoughts go towards using a UITableView where I make the event dates as sections. Since the Calendar is supposed to span many month I am unsure whether this really is the best way to go about it. Any suggestions? Do you probably know some sample code that I might use ? thanks in advance

    Read the article

  • Alternative to Page_Load in ASP.NET (and a good WTF story)

    - by Jason
    Woo, I have a doozy of a problem (might even be one for the Daily WTF) and I'm hoping there's a solution. (My apologies for the long post...) I have been working on a website that I inherited about a month ago. One of the parts I have been working on is fixing one of the controls (essentially a dynamic header bar) so that it displays additional information as requested by my users. As part of doing this project, I created a Site.master file so that I wouldn't have to recode the header bar into every single page. When I first started doing this, it seemingly worked very well. All the pages I had developed looked great and the bar updated as it should displaying the information as it should. Well, when I dropped the Site.master (and this control) into older site pages (ones I did not specifically develop) I noticed that it looked bad on some of them, but not all of them. When I say it looked bad, basically, the control would left-align itself to the page rather than center as it should. I spent a couple hours debugging to no avail - CSS looked correct, the HTML appeared to be okay, I didn't see anything in the Javascript (although, I did miss something as I'll point out in a second), and even the old code looked correct (to the best that it could - it's not very well written). Another coworker took a look at the site and couldn't find anything at first, either. It wasn't until I just thought to look at the rendered source code of the page (I had been working in the developer view up to this point in IE8) that it became clear what was wrong. The original developer performs searches on many of the pages. To accomplish this, he queries the database for ALL the data and then loads them into Javascript arrays within the page so he can get access to them. This in itself is a huge problem because we're talking about thousands of items, and it obviously isn't scalable (and, yes, the site is slow). However, it finally clicked what was screwing up the Site.master - when he loads the data into the Javascript arrays, he writes out the data to the HTML upon Page_Load using numerous Response.Write(string) calls. The WTF (and what was messing me up) is that he inserts the Javascript before the DOCTYPE causing IE to go into quirks mode! So, because I need to at least get this release out (I'll fix the real problem later), I was wondering: is there a way I can force this Javascript to be inserted elsewhere into the HTML—after the DOCTYPE at the very least? Right now, all the Response.Write() calls are being done in the Page_Load method. I just need them to be inserted later.

    Read the article

  • Is a base class with shared fields and functions good design

    - by eych
    I've got a BaseDataClass with shared fields and functions Protected Shared dbase as SqlDatabase Protected Shared dbCommand as DBCommand ... //also have a sync object used by the derived classes for Synclock'ing Protected Shared ReadOnly syncObj As Object = New Object() Protected Shared Sub Init() //initializes fields, sets connections Protected Shared Sub CleanAll() //closes connections, disposes, etc. I have several classes that derive from this base class. The derived classes have all Shared functions that can be called directly from the BLL with no instantiation. The functions in these derived classes call the base Init(), call their specific stored procs, call the base CleanAll() and then return the results. So if I have 5 derived classes with 10 functions each, totaling 50 possible function calls, since they are all Shared, the CLR only calls one at a time, right? All calls are queued to wait until each Shared function completes. Is there a better design with having Shared functions in your DAL and still have base class functions? Or since I have a base class, is it better to move towards instance methods within the DAL?

    Read the article

  • Disposable Registry: good pattern?

    - by illdev
    Imagine a: public class Global : IDisposable { private static readonly List<IDisposable> Disposables = new List<IDisposable>(); public void ApplicationStart() { var heavyLifter = new HeavyLifter(); Disposables.Add(heavyLifter); } public void Dispose() { Disposables.ForEach(d => d.Dispose()); } } I am somewhat inexperienced with IDisposable. Is this a viable pattern?

    Read the article

  • [jscript] Good (better) substition for setInterval or setTimeout

    - by riffnl
    I've got a masterpage with some nice UI (jQuery) features. One of these options is interefering with my embedded YouTube (or other alike-) objects. On each, in this case, setInterval event the embedded video stops displaying new frames (for like a second). More detail: I've got a "polaroid" gallery (in the header) with only 5 100x100 images in it (test: preloading has no effect on performance) and my gallery will show or hide them (fade-in / fade-out) after a period of time. (test: non-animated display:hide or display:block has no effect on performance). After some testing and I've come to the conclusion that it isn't the "animated" showing or hiding of the pictures, but it's the interval itself (- since altering to display:hide or block had the same result). Perhaps it is my "gallery" "function" on itself ... function poladroid() { if (!galleryHasFocus) { if (galleryMax >= 0) { galleryCurrent++; if (galleryCurrent > galleryMax) { galleryCurrent = 0; showPictures = !showPictures; } if (showPictures) { $('#pic-' + galleryCurrent.toString()).show("slow"); } else { $('#pic-' + galleryCurrent.toString()).hide("slow"); } } } if (!intervalSet) { window.setInterval("poladroid()", 3000); intervalSet = true; } } It's not like my function is doing really awkward stuff is it? So, I was thinking I needed a more "loose" interval function.. but is there an option for it?

    Read the article

  • Is switching to PHP 5.3 a good idea?

    - by understack
    I'm using PHP 5.2.11. I've seen that 5.3 version has several backward incompatibility issues and because of that some code might require changes. Since my website is hosted on shared server, many have suggested that those server won't upgrade to 5.3 in near future (probably due to incompatibility issues for many shared users). Would it be wise to develop a new project in 5.3 which would be hosted on shared server?

    Read the article

  • iframe for ad loading good or bad?

    - by Cedar Jensen
    According to Yahoo's "Best Practices for Speeding Up your Site", the pros for using iframes: Helps with slow third-party content like badges and ads Download scripts in parallel but the cons are: Costly even if blank Blocks page onload I want to use an iframe to load ads using the technique mentioned on this site: http://meanderingpassage.com/2007/08/15/keeping-javascript-widgets-from-controlling-your-blog/ Does using this technique mean that as soon as the html contents requested by the iframe are returned to the client, it will load the ad script, potentially blocking the rest of the page's rendering and downloading? Or will the iframe request get processed concurrently while rest of the document is downloaded and rendered?

    Read the article

  • which techonology is good for my online store?

    - by 5YrsLaterDBA
    I am thinking about build a online store for my wife to sale something. we need database for customer info and goods info. we also need shopping cart for customers to use. I have yrs java experience but no web experience (know a little about jsp and servlet). I am thinking using wicket and other java technologies plus MySQL to build it. but I am open to other options. I am willing to learn new things. what's your expert views? thanks,

    Read the article

  • Good excuses NOT to use version control

    - by Kent Fredric
    This question may seem backwards to all logical reasoning, but I encountered a team member who was working on a side project out of the main tree, and had decided ( rephrased ) I'm the only developer, we don't need version control, that's stupid Now personally, the idea horrifies me, and I can't for one justify it. So now my stance is clear, I want some legitimate answers why somebody can excuse themselves from using version control. The default answers will of course be "there is no excuse". Not what I want to see. If you can't see an excuse, then just don't post. ( Feel free to downmod excuses others post that are illegitimate/bad and give reasoning )

    Read the article

  • need a good frontend for MySQL for beginner user

    - by aadersh patel
    implementing a database and need an easy to use frontend. Have tried: HeidiSQL - editing fields was very tedious MySQL-Front - wasnt adding tables through the SQL Editior, and only updated when the prog was restarted. Can anyone recommend a Frontend which they think would be appropriate? Many thanks

    Read the article

  • how to build good python web application

    - by Moayyad Yaghi
    hello i never worked with web programming and i've been asked lately to write a web-based software to manage assets and tasks. to be used by more than 900 persons what are the recommended modules , frameworks , libraries for this task. and it will be highly appreciated if you guyz recommend some books and articles that might help me. thanks in advance

    Read the article

< Previous Page | 50 51 52 53 54 55 56 57 58 59 60 61  | Next Page >