instruction stringlengths 0 30k ⌀ |
|---|
|.net| |
How much should one DataSet represent? Using the example of an ordering system: While showing your order I also show a list of items similar to one of yours as well as a list of our most popular items.
While your items are tangled in a web of relationships involving you and your past orders, preferred suppliers, and the various other kinds of information related to you as a client, the other items do not have these same relationships. The set of queries I use to navigate the set of stuff representing you is different than the queries I use for one of these other lists of items.
My inclination is to create different DataSets for different kinds of relationships but then I create ten separate item DataTables and that seems wrong. When I instantiate the larger DataSet even though I am only interested in a small subset that seems wrong, and when I try to pack all of these into one DataSet I have a big messy looking thing with several items tables next to each other and I am pretty sure that IS wrong.
Maybe I am over-valuing the relationship feature of DataSets or maybe I just need to get over myself, either way I could use some guidance.
|
The one time I wrote a singleton in Python I used a class where all the member functions had the classmethod decorator.
class foo:
x = 1
@classmethod
increment(cls, y = 1)
cls.x += y |
Scaffoling in pylons |
|python|pylons| |
Is there anything similar to rails' scaffolding fo pylons? I've been poking around google, but fofund only this thing caled dbsprockets, which is fine, although probably way to much for my needs. What i really need is a basic CRUD thas is based on the SQLAlchemy model. |
Scaffolding in pylons |
I've been using [Prototype][1] + [Scriptaculous][2].
They have good API documentation and work great for me! The biggest benefits are:
- Cleans up messy javascript code
- Cross browser compatibility
- Simplifies AJAX handling
- Smooth UI effects
[1]: http://www.prototypejs.org/
[2]: http://script.aculo.us/ |
Is the Modal Window popped up using the IE Modal window? Or is it a DIV that you are showing?
If it is an IE Modal Pop up you need to ensure you have
<base target="_self" />
To make sure the post back are to the modal page.
If it is a DIV make sure you have your XHTML correct or it might not know what to update. |
Scrum: Resistance is (not) futile |
|scrum|agile|xp| |
I'm the second dev and a recent hire here at a PHP/MySQL shop. I was hired mostly due to my experience in wrangling some sort of process out of a chaotic mess. At least, that's what I did at my last company. ;)
Since I've been here (a few months now), I've brought on board my boss, my product manager and several other key figures (But mostly chickens, if you pardon the Scrum-based stereotyping). I've also helped bring in some visibility to the development cycle of a major product that has been lagging for over a year. People are loving it!
However, my coworker (the only other dev here for now) is not into it. She prefers to close her door and focus on her work and be left alone. Me? I'm into the whole Agile approach of collaboration, cooperation and openness. Without her input, I started the Scrum practices (daily scrums, burndown charts and other things I've found that worked for me and my previous teams (ala [H. Kniberg's cool wall chart][1]). During out daily stand up she slinks by and ignores us as if we actually weren't standing right outside her door (we are actually). It's pretty amazing. I've never seen such resistance.
Question... how do I get her onboard? Peer pressure is not working.
Thanks from fellow Scrum-borg,
beaudetious
[1]: www.crisp.se/henrik.kniberg/ScrumAndXpFromTheTrenches.pdf |
|agile|scrum|xp|development-practice| |
Here is the method I've used in the past with good success:
/trunk - bleeding edge. Next major release of the code. May or may not work at any given time.
/branches/1.0, 1.1, etc. Stable maintenance branches of the code. Used to fix bugs, stabilize new releases. If a maintenance branch, it should compile (if applicable) and be ready for QA/shipping at any given time. If a stabilization branch, it should compile and be feature complete. No new features should be added, no refactoring, and no code cleanups. You can add a pre- prefix to indicate stabilization branches vs maintenance branches.
/branches/cool_feature. Used for highly experimental or destructive work that may or may not make it into trunk (or a maintenance branch). No guarantees about code compiling, working, or otherwise behaving sanely. Should last the minimum time as possible before merging into the mainline branch.
/tags/1.0.1, 1.0.2, 1.1.3a, etc. Used for tagging a packaged & shipped release. Never EVER changes. Make as many tags as you want, but they're immutable. |
We seem to be in the golden age of version control, with a ton of choices, all of which have their pros and cons.
Here are the ones I see most used:
- svn - currently the most popular open source?
- git - very hot since Linus switched to it
- mercurial - some smart people I know swear by it
- cvs - the one everybody is switching from
- perforce - imho, the best features, but it's not open source. The two-user license is free, though.
- visual sourcesafe - I'm not much in the Microsoft world, so I have no idea about this one, other than people like to rag on it as they rag on everything from Microsoft.
- sccs - for historical interest we mention this, the great-grandaddy of many of the above
- rcs - and the grandaddy of many of the above
My recommendation: you're safest with either git, svn or perforce, since a lot of people use them, they are cross platform, have good guis, you can buy books about them, etc.
Dont consider cvs, sccs, rcs, they are antique.
The nice thing is that, since your projects will be relatively small, you will be able to move your code to a new system once you're more experienced and decide you want to work with another system. |
"How do you go from an arithmetic expression (e.g. in a string) such as "2 + (2)" to an expression tree using polymorphism?" (Amazon Interview Question ala Steve Yegge) |
|polymorphism|oop|binary-tree|recursion| |
How do you go from an arithmetic expression (e.g. in a string) such as "2 + (2)" to an expression tree using polymorphism? |
|oop|polymorphism|recursion|binary-tree| |
Expression Evaluation and Tree Walking using polymorphism? |
|oop|polymorphism|binary-tree|recursion| |
Expression Evaluation and Tree Walking using polymorphism? (ala Steve Yegge) |
|oop|recursion|polymorphism|binary-tree| |
This morning, I was reading [Steve Yegge's: When Polymorphism Fails][1], when I came across a question that a co-worker of his used to ask potential employees when they came for their interview at Amazon.
> As an example of polymorphism in
> action, let's look at the classic
> "eval" interview question, which (as
> far as I know) was brought to Amazon
> by Ron Braunstein. The question is
> quite a rich one, as it manages to
> probe a wide variety of important
> skills: OOP design, recursion, binary
> trees, polymorphism and runtime
> typing, general coding skills, and (if
> you want to make it extra hard)
> parsing theory.
>
> At some point, the candidate hopefully
> realizes that you can represent an
> arithmetic expression as a binary
> tree, assuming you're only using
> binary operators such as "+", "-",
> "*", "/". The leaf nodes are all
> numbers, and the internal nodes are
> all operators. Evaluating the
> expression means walking the tree. If
> the candidate doesn't realize this,
> you can gently lead them to it, or if
> necessary, just tell them.
>
> Even if you tell them, it's still an
> interesting problem.
>
> The first half of the question, which
> some people (whose names I will
> protect to my dying breath, but their
> initials are Willie Lewis) feel is a
> Job Requirement If You Want To Call
> Yourself A Developer And Work At
> Amazon, is actually kinda hard. The
> question is: how do you go from an
> arithmetic expression (e.g. in a
> string) such as "2 + (2)" to an
> expression tree. We may have an ADJ
> challenge on this question at some
> point.
>
> The second half is: let's say this is
> a 2-person project, and your partner,
> who we'll call "Willie", is
> responsible for transforming the
> string expression into a tree. You get
> the easy part: you need to decide what
> classes Willie is to construct the
> tree with. You can do it in any
> language, but make sure you pick one,
> or Willie will hand you assembly
> language. If he's feeling ornery, it
> will be for a processor that is no
> longer manufactured in production.
>
> You'd be amazed at how many candidates
> boff this one.
>
> I won't give away the answer, but a
> Standard Bad Solution involves the use
> of a switch or case statment (or just
> good old-fashioned cascaded-ifs). A
> Slightly Better Solution involves
> using a table of function pointers,
> and the Probably Best Solution
> involves using polymorphism. I
> encourage you to work through it
> sometime. Fun stuff!
So, let's try to tackle the problem all three ways. How do you go from an arithmetic expression (e.g. in a string) such as "2 + (2)" to an expression tree using cascaded-if's, a table of function pointers, and/or polymorphism?
Feel free to tackle one, two, or all three.
[1]: whttp://steve.yegge.googlepages.com/when-polymorphism-fails |
> At least in the intranet scenario, I
> think Active Directory (or similar) is
> still one of the best options.
Yep, in any case, Active Directory is behind the curtains of the OpenId Server Provider.
In order to develop a SSO solution within an Intranet there are commercial options such as Access Manager (former IChain)+Active Directory but I dont know if theres an open solution apart from "Own OpenId Server"+"Something cool yet to develop"+LDAP.
|
As for the ID's on server-controls: You can find the actually ID that is going to be written to the browser by accessing ClientID. That way you can combine server-side og client-side scripting and still dont have to hardcode _id="ct100_nav"_
I always try to use the included controls instead of "hacking" HTML, because if there is an update or some improvement later on, all my code will still work by just replacing the framework and I don't have to change any HTML.
Hope this helps |
JSON is Javascript Object Notation, so if you are using Javascript you are already there!
Have a look at these links, they give examples of how to create Javascript objects from JSON:
http://www.hunlock.com/blogs/Mastering_JSON_(_JavaScript_Object_Notation_)
http://betterexplained.com/articles/using-json-to-exchange-data/
If you decide to go the Flex / AS3 route, then as the jsight said, as3corelib is a good place to start. |
I have a fairly natural way of coding. The key is to treat the page like a document or an article. If you think of it like this the following becomes logically clear:
1. The page title is a top level heading
* Whether you make the site title or actual page title the h1 is up to you - personally I'd make About Us the h1 rather than Stack Overflow.
2. The navigation is a table of contents, and thus an **ordered list** - you may as well use an ol over a ul.
3. Section headers are h2, sections within those sections are h3s etc. Stack them up.
4. Use blockquotes and quotes where possible. Don't just surround it with ".
5. Don't use b and i. Use strong and em. This is because HTML is structural rather than presentational markup. **Strong** and **em**phasis tags should be used where you'd put emphasis on the word.
6. `<label>` your form elements.
7. Use `<acronym>`s and `<abbr>`s where possible, but only in the first instance.
8. The easiest: always, *always* give your images some alternate text.
9. There's lots of HTML tags you could use that you probably haven't - address for postal addresses, screen code output. Have a look at [HTML Dog][1] for some, it's my favourite reference.
That's just a few pointers, I'm sure I could think of more.
[1]: http://www.htmldog.com/ |
I have a fairly natural way of coding. The key is to treat the page like a document or an article. If you think of it like this the following becomes logically clear:
1. The page title is a top level heading
* Whether you make the site title or actual page title the h1 is up to you - personally I'd make About Us the h1 rather than Stack Overflow.
2. The navigation is a table of contents, and thus an **ordered list** - you may as well use an ol over a ul.
3. Section headers are h2, sections within those sections are h3s etc. Stack them up.
4. Use blockquotes and quotes where possible. Don't just surround it with ".
5. Don't use b and i. Use strong and em. This is because HTML is structural rather than presentational markup. **Strong** and **em**phasis tags should be used where you'd put emphasis on the word.
6. `<label>` your form elements.
7. Use `<acronym>`s and `<abbr>`s where possible, but only in the first instance.
8. The easiest: always, *always* give your images some alternate text.
9. There's lots of HTML tags you could use that you probably haven't - address for postal addresses, screen code output. Have a look at [HTML Dog][1] for some, it's my favourite reference.
That's just a few pointers, I'm sure I could think of more.
Oh, and if you want a challenge write your XHTML first, then write the CSS. When CSS-ing you aren't allowed to touch the HTML. It's actually harder than you think (but I've found it's made me quicker).
[1]: http://www.htmldog.com/ |
It depends on what the thin WCF service does. If it's really thin and there's no interesting code there, don't bother unit testing it. Don't be afraid to not unit test something if there's no real code there. If the test cannot be at least one level simpler then the code under the test, don't bother. If the code is dumb, the test will also be dumb. You don't want to have more dumb code to maintain.
If you can have tests that go all the way to the db then great! It's even better. It's not a "true unit test?" Not a problem at all. |
We've certainly used gcov to get coverage information on our multi-threaded application.
You want to compile with gcc 4.3 which can do coverage on dynamic code.
You compile with the -fprofile-arcs -ftest-coverage options, and the code will generate .gcda files which gcov can then process.
We do a separate build of our product, and collect coverage on that, running unit tests and regression tests.
Finally we use lcov to generate HTML results pages. |
Maybe you should use another jdk version.
For your "puzzling one", there is a bug entry for 1.5.0_08. A memory leak is reported (I do not know, if this is related to your problem):
<http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6469701>
Also you could get the source code and look, what happens at line 1383. On the other side, it could just be the stack dump, after the original error occurred. |
I have been using Proggy Clean TT with Visual Studio for a couple of years now. I like the ability to choose a zero slashed font so when management decides to program instead of manage they don't confuse 0101 with 0101(zeros).
http://www.proggyfonts.com/ |
You cannot use OpenSSL with Indy version 10.5 that shippes with Delphi 2007. You have to download version 10,6 from http://www.indyproject.org/ and install it into the IDE.
Note that other packages might use Indy, like RemObjects, and therefore they have to be re-compiled too and this can be tricky due to cross-references.
|
VMware or Hyper-V for Developers |
|vmware|virtualization|hyper-v| |
I'm looking to replace a couple of machines in the office with a more powerful multi-processor machine running either VMware or Microsoft's Hyper-V with a view to hosting a mix of Windows Server 2003, Windows Server 2008 and Linux operating systems. The machines are used mainly for testing ASP.Net or Perl web sites. I don't need advanced features like live migration of running systems but it would be useful to be able to restore a machine to a known state. Performance is not really a big issue either unless one is noticeable faster than the other.
My question is: Should I play safe and go with VMware or is Hyper-V mature enough to be a candidate? |
I have not used gcov for multi-threaded coverage work. However, on MacOS the Shark tool from Apple handles multiple threads. It's primarily a profiler, but can do coverage info too.
http://developer.apple.com/tools/sharkoptimize.html |
I am not sure is it 100% what your looking for, **but check out the built in example that comes packaged with NetBeans 6.1**. It uses JSF/EJB3/ApacheDerby. I played around with it for like 20 minutes and thought it was pretty cool as a simple/starter JavaEE application to learn from. |
@monjardin
The main reason we use it is because of the re-factoring/search tools provided through Visual Assist X (by Whole Tomato). Although there are a number of other nice to haves like Intelli-sense. We are also investigating integrations with our other tools AccuRev, Bugzilla and Totalview to complete the environment.
@roo
Using multiple compilers sounds like a pain. We have the luxury of just sticking with gcc for all our platforms.
@josh
Yikes! That sounds like a great way to introduce errors! :-) |
Yeah, attributes cannot have anything but constants in them, so you cannot use reflection to get the version number. The WebServiceAttribute class is sealed too, so you cannot inherit it and do what you want from there.
A solution might be to use some kind of placeholder text as the Name, and set up an MsBuild task to replace it with the version number when building the project. |
Hm, where I work we have all our projects in the same repository. I really don't see the benefit of separating them, doesn't that just create a lot of extra work -creating new repositories, granting access to people, etc? I guess separate repositories makes sense if the projects are completely unrelated, and you have, say, external customers that needs to have access to the repo. |
Another solution would be to wrap the call to the server and have it always return an array to simplify the rest of your life:
sub call_to_service
{
my $returnValue = service::call();
if (ref($returnValue) eq "ARRAY")
{
return($returnValue);
}
else
{
return( [$returnValue] );
}
}
Then you can always know that you will get back a reference to an array, even if it was only one item.
foreach my $item (@{call_to_service()})
{
...
}
|
css2 offers:
@font-face { font-family:Garamond; src:url(garamond.eot), url(garamond.pfr); }
|
I never realized how much that annoyed me as well! I haven't been able to find a setting, but in `Options > Environment > Keyboard` you can bind a shortcut to `Window.CloseAllDocuments`. `ALT+X` was unbound for me so I just used that. I'm interested if there's some hidden setting to automatically do this on solution exit though (or load). |
> Note that a responsible web developer does not use fonts that are only available on Windows (and especially ones that are only available on Vista), nor do they use a technology that isn't supported by at least the majority of browsers.
Well… You can, as long as you know how it will render on non-Vista/non-Windows OS.
Otherwise: yep, @font-face in CSS2 is the best standard alternative, even if it is not widely supported. |
Safari and to a lesser extent Firefox 3 have support for @font-face in CSS which lets you use custom fonts. You need to have the appropriate licence to distribute the font files though. These articles explain it in more detail:
- [http://www.css3.info/preview/web-fonts-with-font-face/][1]
- [http://www.alistapart.com/articles/cssatten][2]
- [http://www.sitepoint.com/blogs/2008/07/30/custom-web-fonts-pick-your-poison/][3]
[1]: http://www.css3.info/preview/web-fonts-with-font-face/
[2]: http://www.alistapart.com/articles/cssatten
[3]: http://www.sitepoint.com/blogs/2008/07/30/custom-web-fonts-pick-your-poison/ |
>Is the device running out of memory and therefore gives up the ghost when it requires the additional memory to stop at the breakpoint?
No, there's over a gig of RAM to go, and even more of virtual memory. |
I'm not sure I quite understand what you are getting at, but here's a few things I can suggest you can try...
1. This behaviour changes between different versions of Delphi. I'd suggest that this is due to the hoops they jumped through to support Windows Vista in Delphi 2007.
2. If you are using Delphi 2007, try removing the line from the project source file that sets the Application.MainFormOnTaskBar boolean variable.
3. With this removed, you should be able to use the various Form's BringToFront / SendToBack methods to achieve the Z-ordering that you are after.
I suspect that what you've discovered has been discussed on [this link](http://www.stevetrefethen.com/blog/TheNewVCLPropertyTApplicationMainFormOnTaskbarInDelphi2007.aspx)
Of course, I may have just missed your point entirely, so apologies in advance!
|
What is /dev/ttys# (notice the little s)? |
|linux|serial|serial-port| |
I'm working on linux, trying to get the serial port to work. I know /dev/ttyS0 is a serial port, but what is /dev/ttys0? |
If the ID's prefix added by ASP.NET is an issue for you to access them later using JS or something... you have the .ClientID property server side.
If the overhead added by ASP.NET you should consider ASP.NET MVC (still preview) where you have full control over the emitted html.
I'm moving to MVC because I don't like all that stuffs added too.... |
Try these links for a start.
http://www.ilog.com/products/ganttnet/
http://www.netronic.com/products-for-developers/gantt-charts.html?gclid=COLdutasoZUCFQunQwodoWOPkw |
@Brian,
Yup! You can pretty much control all the behaviour.. Consider looking into creating Custom Controls (there are three types). I recently gave an overview of them in my question [here](http://stackoverflow.com/questions/17532/aspnet-custom-controls-composites).
I would _strongly_ recommend checking them out, has help me no end :) |
If I won't edit the property I'll use a `get_property()` public method unless it's a special occasion such as a MySQLi object inside another object in which case I'll just public the property and refer to it as `$obj->object_property`.
Inside the object it's always $this->property for me. |
Personally,
I think the standard ASP.NET controls are fine for inhouse stuff - quick and dirty is good in that scenario. But, I once worked with a web developer who was also a designer and he refused to use the ASP.NET controls and only code in HTML and add runat="server" tags when needed. This was more because he wanted to know exactly how his HTML was going to be rendered, and at the time anyway, some of the ASP.NET controls wouldn't render to standards compliance.
I sit somewhere in the middle - use HTML where appropriate and not when not. You can sort of best of both worlds with the [CSS control Adapters][1]
[1]: http://weblogs.asp.net/scottgu/archive/2006/05/02/444850.aspx |
It's not exactly hidden, but reflection is incredibly useful and powerful. It is great to use a simple Class.forName("...").newInstance() where the class type is configurable. It's easy to write this sort of factory implementation. |
There's something about it on [Google c++ coding style document][1].
[1]: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Preincrement_and_Predecrement#Preincrement_and_Predecrement |
If you have lastupdate columns you can check for the writes, there is really no easy way to check for reads. You could run profiler, save the trace to a table and check in there
What I usually do is rename the table by prefixing it with an underscrore, when people start to scream I just rename it back |
On your source repository : use hooks before each commits (pre-commit hook for SVN for example)
In that hook, check for the existence of at least one use case for each method. Use a convention for unit test organisation that you could easily enforce via a pre-commit hook.
On an integration server compile everything and check regularely the test coverage using a test coverage tool. If test coverage is not 100% for a code, block any commit of the developer. He should send you the test case that covers 100% of the code.
Only automatic checks can scale well on a project. You cannot check everything by hand.
The developer should have a mean to check if his test cases covers 100% of the code. That way, if he doesn't commit a 100% tested code, it is his own fault, not a "oops, sorry I forgot" fault.
Remember : People never do what you expect, they always do what you inspect. |
The **core** attribute isn't used anymore.
From [Brian Rosner's Blog](http://oebfare.com/blog/2008/jul/20/newforms-admin-migration-and-screencast/):
> You can safely just remove any and all core arguments. They are no longer used. newforms-admin now provides a nice delete checkbox for exisiting instances in inlines. |
I looked into it by checking out my file associations.
It seems that a .reg file is just called as the first parameter to the `regedit.exe` executable on Windows.
So you can just say `regedit.exe "mytest.reg"`. What I'm not sure of is how to get rid of the dialog box that pops up that asks for your confirmation. |
Simple. Don't talk about scrum. Don't use scrum on her. Instead take the underlying principles of scrum (e.g. the purpose as opposed to the application) and create different approaches that accommodate her way of working but have subtle tints of scrum.
All humans are different and a lot of programmers dislike scrum. I wouldn't force it upon them as that would just be counter-productive. I'd suggest identifying the problems in the development process (in a non-scrum fashion), see if you can get her to agree that the issues exist, then ask _her_ what she thinks would be a good solution. Her co-operation and input into the process is essential to her co-operation, if she doesn't have buy-in she wont become a citizen.
From there on in you can hopefully create some sort of quasi-hybrid scrum + her approach to the process where you can both agree on the way forward. |
If by not used, you mean your application has no more references to the tables in question and you are using dynamic sql, you could do a search for the table names in your app, if they don't exist blow them away.
I've also outputted all sprocs, functions, etc. to a text file and done a search for the table names. If not found, or found in procedures that will need to be deleted too, blow them away. |
wikipedia's Definition
Lazy loading is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed. ...
http://en.wikipedia.org/wiki/Lazy%20loading |
Gmail's SMTP-server requires a very specific configuration.
From [Gmail help][1]:
Outgoing Mail (SMTP) Server (requires TLS)
- smtp.gmail.com
- Use Authentication: Yes
- Use STARTTLS: Yes (some clients call this SSL)
- Port: 465 or 587
Account Name: your full email address (including @gmail.com)
Email Address: your email address (username@gmail.com)
Password: your Gmail password
You can probably set these settings up in [Pear::Mail][2] or [PHPMailer][3]. Check out their documentation for more details.
[1]: http://mail.google.com/support/bin/answer.py?answer=13287
[2]: http://pear.php.net/package/Mail
[3]: http://phpmailer.codeworxtech.com/ |
The DataSet is vastly overrated and overused. Use strongly-typed collections (thank you, generics and automatic properties!). As icing on the cake, you can now even do cool query things against your custom objects with LINQ.
Good Esposito article on datasets versus custom objects:
<http://msdn.microsoft.com/en-us/magazine/cc163751.aspx>
Automatic properties:
<http://weblogs.asp.net/dwahlin/archive/2007/12/04/c-3-0-features-automatic-properties.aspx>
LINQ with your objects:
<http://blogs.msdn.com/wriju/archive/2006/09/16/linq-custom-object-query.aspx>
|
This is why I don't use datasets. If you use strongly-typed datasets you benefit from the strong typing but you pay for it in terms of the time it takes to create one even if you're just using part of it and its extensibility in terms of the code base. If you want to modify an existing one and you modify a row definition then this will create "shotgun" breaks in the code base as each definition for adding a new row will have to be modified as it wont compile anymore.
To avoid the above scenario the most sensible approach is to generally give up on sensible re-use. Define a dataset per purpose and per use. However the main issue with this is API use, you end up with dataset that is simliar to another dataset but because it is a different dataset type you have to transform it to use the common API which is both painful and inelegant.
This, plus the fact that strongly typed datasets make your code look horrid (the length of the type declarations) are pretty much the reasons i've given up on datasets and switched to business objects instead. |
Lazy Loading is a programming practice in which you only load or initialize an object when you first need it. This can potentially give you a big performance boost, especially if you have a lot of components in your application.
As usual, [Wikipedia][1] has more details.
[1]: http://en.wikipedia.org/wiki/Lazy_loading |
One good way to do this is via fixtures, particularly the `initial_data` fixtures.
A fixture is a collection of files that contain the serialized contents of the database. So it's like having a backup of the database but as it's something Django is aware of it's easier to use and will have additional benefits when you come to do things like unit testing.
You can create a fixture from the data currently in your DB using `django-admin.py dumpdata`. By default the data is in JSON format, but other options such as XML are available. A good place to store fixtures is a `fixtures` sub-directory of your application directories.
You can load a fixure using `django-admin.py loaddata` but more signicantly, if your fixture has a name like `initial_data.json` it will be automatically loaded when you do a `syncdb`, saving the trouble of importing it yourself.
Another benefit is that when you run `manage.py test` to run your Unit Tests the temporary test database will also have the Initial Data Fixture loaded.
Of course, this will work when when you're adding attributes to models and columns to the DB. If you drop a column from the Database you'll need to update your fixture to remove the data for that column which might not be straightforward. |
The primary tool I've also used was FitNesse. I've used it at several companies, with very good results. We did have test cases numbering in the many thousands, and we had to be very disciplined in how we organized and used them.
I've tried some other tools, including writing my own DSL (domain-specific language) and using things like RSpec. I really like RSpec, but it is certainly more of a developer tool than a business one.
I know Rick Mugridge has been working on a tool called ZiBreve (<a href="http://www.zibreve.com/visit.php?page=index">http://www.zibreve.com/visit.php?page=index</a>) which is supposed to have stronger refactoring support. I haven't used it myself, but I know Rick and have talked to him several times. I know there was discussion at Agile 2008 on some different ways to deal with the Fitnesse tests in general.
Other than that, I haven't seen a lot of good tools out there. Even tools like WinRunner are fine for QA type tests, but for exploratory testing of requirements by the business, FitNesse or a custom DSL seem to be the ways to go right now. |
When I write unit tests I limit the scope of the code being tested to the class I am currently writing by mocking dependencies. If I am writing a Sentence class, and Sentence has a dependency on Word, I will use a mock Word. By mocking Word I can focus only on its interface and test the various behaviors of my Sentence class as it interacts with Word's interface. This way I am only testing the behavior and implementation of Sentence and not at the same time testing the implentation of Word.
Once I've written the unit tests to ensure Sentence behaves correctly when it ineteracts with Word based on Word's interface I write the integration test to make sure that my assumptions about the interactions where correct. For this I supply the actual objects and write a test that excercises a feature that will end up using both Sentence and Word.
|
Hyper-V works quite well and even supports Linux VM's. The main advantage is that if you are already running Windows server 2008 it comes along for free whereas you have to pay for VMWare separately. I think that VM ware provides better system management tools, but that isn't really a big benefit in this particular case.
I personally have used Hyper-V for development, i.e. running a vista machine for testing on top of a server 2008 box. |
I believe I've found the answer. It seems that Microsoft, in all their infinite wisdom, has blocked batch files from being executed by IIS in Windows Server 2003. Brenden Tompkins has a work-around here:
http://codebetter.com/blogs/brendan.tompkins/archive/2004/05/13/13484.aspx
That won't work for me, because my batch file uses IF and GOTO, but it would definitely work for simple batch files. |
VMware did recently release a free version of ESXi recently.
VMware has a few advantages:
1. VMware virtual machines are portable across different types of hardware. IIRC, Hyper-V uses the drivers from the Host OS.
2. VMware virtual machines are portable across different VMware products (although you may need to use their converter tool to go from some hosted virtual machines to ESX or ESXi).
3. The VMware platforms have been in use much longer, and are quite mature products and generally better-known for troubleshooting.
With VMware, you could develop and test a virtual machine on your local system using VMware Workstation, Fusion, Server, or Player, and then deploy it to a production server later. With Hyper-V, I believe you would have to build the virtual machine on the target box for best results. If performance isn't really that big of an issue, then VMware Server may be the best option, for it can run most .vmx machines directly and is generally a bit easier to manage; if performance becomes critical, you still have the ESX or ESXi upgrade option that you can use those same virtual machines with.
This entry talks about how Virtual Server machines will not run on Hyper-V:
<http://blogs.technet.com/jhoward/archive/2008/02/28/are-vhds-compatible-between-hyper-v-and-virtual-server-and-virtual-pc.aspx> |
[see this][1]
[1]: http://www.linuxselfhelp.com/HOWTO/Text-Terminal-HOWTO-6.html
> For a pseudo terminal pair such as
> ptyp3 and ttyp3, the pty... is the
> master or controlling terminal and the
> tty... is the slave. There are only 16
> ttyp's: ttyp0-ttypf (f is a
> hexadecimal digit). **To get more
> pairs, the 3 letters q, r, s may be
> used instead of p**. For example the
> pair ttys8, ptys8 is a pseudo terminal
> pair. The master and slave are really
> the same "port" but the slave is used
> by the application program and the
> master is used by a network program
> (or the like) which supplies (and
> gets) data to/from the slave port.
|
Using Regex to generate Strings rather than match them |
|java|regex| |
I am writing a Java utility which helps me to generate loads of data for performance testing. It would be *really* cool to be able to specify a regex for Strings so that my generator spits out things which match this. Is there something out there already baked which I can use to do this? Or is there a library which gets me most of the way there?
Thanks |
And this: [http://lists.opensuse.org/archive/opensuse/2003-12/msg02404.html][1]
[1]: http://lists.opensuse.org/archive/opensuse/2003-12/msg02404.html |
In the Linux devices.txt file in the kernel docs it says:
3 char Pseudo-TTY slaves
0 = /dev/ttyp0 First PTY slave
1 = /dev/ttyp1 Second PTY slave
...
255 = /dev/ttyef 256th PTY slave
These are the old-style (BSD) PTY devices; Unix98
devices are on major 136 and above.
and goes on to say
4 char TTY devices
0 = /dev/tty0 Current virtual console
1 = /dev/tty1 First virtual console
...
63 = /dev/tty63 63rd virtual console
64 = /dev/ttyS0 First UART serial port
...
255 = /dev/ttyS191 192nd UART serial port
UART serial ports refer to 8250/16450/16550 series devices.
Older versions of the Linux kernel used this major
number for BSD PTY devices. As of Linux 2.1.115, this
is no longer supported. Use major numbers 2 and 3.
I don't know how much this helps you, but should get you started in the right direction. |
Credit due to @Blorgbeard for sharing his script. I'll certainly bookmark it in case I need it.
Yes, you can "right click" on the table and script the `CREATE TABLE` script, but:
- The a script will contain **loads** of cruft (interested in the extended properties anyone?)
- If you have 200+ tables in your schema, it's going to take you half a day to script the lot by hand.
With this script converted into a stored procedure, and combined with a wrapper script you would have a nice automated way to dump your table design into source control etc.
The rest of your DB code (SP's, FK indexes, Triggers etc) would be under source control anyway ;) |
From [Wikipedia](http://en.wikipedia.org/wiki/Flash_video)
>>**Embedded in an SWF file** using the Flash authoring tool (supported in Flash Player 6 and later). The entire file must be transferred before playback can begin. Changing the video requires rebuilding the SWF file.[citation needed]
>>**Progressive download via HTTP** (supported in Flash Player 7 and later). This method uses ActionScript to include an externally hosted Flash Video file client-side for playback. Progressive download has several advantages, including buffering, use of generic HTTP servers, and the ability to reuse a single SWF player for multiple Flash Video sources. Flash Player 8 includes support for random access within video files using the partial download functionality of HTTP, sometimes this is referred to as streaming. However, unlike streaming using RTMP, HTTP "streaming" does not support real-time broadcasting. Streaming via HTTP requires a custom player and the injection of specific Flash Video metadata containing the exact starting position in bytes and timecode of each keyframe. Using this specific information, a custom Flash Video player can request any part of the Flash Video file starting at a specified keyframe. For example, Google Video and Youtube support progressive downloading and can seek to any part of the video before buffering is complete. The server-side part of this "HTTP pseudo-streaming" method is fairly simple to implement, for example in PHP, as an Apache HTTPD module, or a lighttpd module. Rich Media Project provides players and Flash components compatible with "HTTP pseudo-streaming" method.
>>**Streamed via RTMP to the Flash Player** using the Flash Media Server (formerly called Flash Communication Server), VCS, ElectroServer, Wowza Pro or the open source Red5 server. As of April 2008, there are four stream recorders available for this protocol, re-encoding screencast software excluded.
There is a useful introduction from Adobe here: [Flash video learning guide](http://www.adobe.com/devnet/flash/articles/video_guide_02.html) |
We use the wild, wild, west style of git-branches. We have some branches that have well-known names defined by convention, but in our case, tags are actually more important for us to meet our corporate process policy requirements.
I saw below that you use Subversion, so I'm thinking you probably should check out the section on branching in the [Subversion Book][1]. Specifically, look at the "repository layout" section in [Branch Maintenance][2] and [Common Branch Patterns][3].
[1]: http://svnbook.red-bean.com/
[2]: http://svnbook.red-bean.com/nightly/en/svn.branchmerge.maint.html
[3]: http://svnbook.red-bean.com/nightly/en/svn.branchmerge.commonpatterns.html |
Perl has a taint option which considers all user input "tainted" until it's been checked with a regular expression. Tainted data can be used and passed around, but it taints any data that it comes in contact with until untainted. For instance, if user input is appended to another string, the new string is also tainted. Basically, any expression that contains tainted values will output a tainted result.
Tainted data can be thrown around at will (tainting data as it goes), but as soon as it is used by a command that has effect on the outside world, the perl script fails. So if I use tainted data to create a file, construct a shell command, change working directory, etc, Perl will fail with a security error.
I'm not aware of another language that has something like "taint", but using it has been very eye opening. It's amazing how quickly tainted data gets spread around if you don't untaint it right away. Things that natural and normal for a programmer, like setting a variable based on user data or opening a file, seem dangerous and risky with tainting turned on. So the best strategy for getting things done is to untaint as soon as you get some data from the outside.
And I suspect that's the best way in other languages as well: validate user data right away so that bugs and security holes can't propagate too far. Also, it ought to be easier to audit code for security holes if the potential holes are in one place. And you can never predict which data will be used for what purpose later. |
Use the Win32 API function ShellExecute() or ShellExecuteEx(). If the comment is 'open' it should merge the .reg file. I haven't tested it, but it should work. |
"Out of the box" there is not a way to do this. You can create one by deriving your own Dictionary class and implementing the restrictions you need. |
MSSQL2000 won't give you that kind of information. But a way you can identify what tables ARE used (and then deduce which ones are not) is to use the SQL Profiler, to save all the queries that go to a certain database. Configure the profiler to record the results to a new table, and then check the queries saved there to find all the tables (and views, sps, etc) that are used by your applications.
Another way I think you might check if there's any "writes" is to add a new timestamp column to every table, and a trigger that updates that column every time there's an update or an insert. But keep in mind that if your apps do queries of the type
select * from ...
then they will receive a new column and that might cause you some problems.
|
I have to put in another vote for [jQuery][1]. It is dead-simple to use and makes your javascript much cleaner.
As an example, if you want to add an onclick event to all the divs inside an element with id "clickdivs", you just do this:
function clickedme(event) {
alert('Someone clicked me!');
}
$('#clickdivs div').click(clickedme);
Your HTML would look like this:
<div id="clickdivs">
<div>Click Here</div>
<div>And Here</div>
<p>Not here</p>
<div>Click Here Too</div>
</div>
Viola!
[1]: http://jquery.com/ |
You might want to look at [DropThings][1] on [Codeplex][2].
[1]: http://www.codeplex.com/dropthings
[2]: http://www.codeplex.com |
You can use the `svn:keywords` property to enable the `Rev` keyword.
You can then use `$Rev$` in your code and SVN will expand it automatically when updating to `$Rev: 256 $` which can then parse...
[More info on the Subversion manual](http://svnbook.red-bean.com/en/1.0/ch07s02.html#svn-ch-7-sect-2.3.4) |
Doesn't the %c parameter pass in the command issued (including the files being committed)?
|
> A DBA has no freedom to make changes
> to the data model without forcing you
> to change your compiled code. With
> stored procedures, you can hide these
> sorts of changes to an extent, since
> the parameter list and results set(s)
> returned from a procedure represent
> its contract, and the innards can be
> changed around, just so long as that
> contract is still met.
I really don't see this as being a benefit. Being able to change something in isolation might sound good in theory, but just because the changes fulfil a contract doesn't mean it's returning the correct results. To be able to determine what the correct results are you need context and you get that context from the calling code. |
Dim returnXDoc As New XmlDocument(xDoc.NameTable)
returnXDoc = xDoc.Clone()
The first line here is redundant - you are creating an instance of an XmlDocument, then reassigning the variable:
Dim returnXDoc As XmlDocument = xDoc.Clone()
This does the same.
Seeing as you appear to be inserting each XmlNode from your node list into a different place in the new XmlDocument then I can't see how you could possibly do this any other way.
There may be faster XPath expressions you could write, for example pre-pending an XPath expression with "//" is almost always the slowest way to do something, especially if your XML is well structured. You haven't shown your XML so I couldn't really comment on this further however. |
pretty sure Money maps to System.Decimal
[Check here][1]
[1]: http://msdn.microsoft.com/en-us/library/bb386947.aspx |
You could try:
static bool HasNet35()
{
try
{
AppDomain.CurrentDomain.Load(
"System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
return true;
}
catch
{
return false;
}
}
HTH |
You could try:
static bool HasNet35()
{
try
{
AppDomain.CurrentDomain.Load(
"System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
return true;
}
catch
{
return false;
}
}
@[Nick][1]: Good question, I'll try it in a bit.
Kev
[1]: http://stackoverflow.com/questions/16178/best-way-to-determine-if-net-35-is-installed#16253 |
Personally I would log it to either a log file or the event log depending on the issue. I think storing it using a users permissions would be a bad idea, what happens if that user does not have the correct rights? or worse still they get elevated permissions by browsing the list in explorer view?
The log file would be the best way, that way you rely only on the file system being available - you dont have to worry about trapping errors happening whilst connecting to the database etc.
Mauro |
At a previous job, I used a Java obfuscator that as well as obfuscating the code, also removed classes and methods that weren't being used. If you were doing "Class.byName" or any other type of reflection stuff, you needed to tell the obfuscator because it couldn't tell by inspecting the code what classes or methods called by called that way.
The problem, of course, is that you don't know if other parts of the third party library are doing any reflection, and so removing an "unused" class might cause things to break in an obscure case that you haven't tested. |