instruction stringlengths 0 30k ⌀ |
|---|
I found some old questions here on SO that might be interesting for you:
- [Whats a good standard code layout for a php application](http://stackoverflow.com/questions/5214/whats-a-good-standard-code-layout-for-a-php-application)
- Contains a link to an article on [Scalable and Flexible Directory Structure for ... |
@erlando,
Talking about refactoring it seems to be much easier to change variable type by assigning instance of new type to one variable rather then changing it in multiple places, isn't it ?
As for code review I see no big issues with *var* keyword. During code review I prefer to check code logic rather variable... |
How to get a counter inside xsl:for-each loop that would reflect the number of current element processed.
For example my source XML is
<books>
<book>
<title>The Unbearable Lightness of Being </title>
</book>
<book>
<title>Narcissus and Goldmund</title>
</book>
<book... |
How to get a counter inside xsl:for-each loop that would reflect the number of current element processed.
For example my source XML is
<books>
<book>
<title>The Unbearable Lightness of Being </title>
</book>
<book>
<title>Narcissus and Goldmund</title>
</book>
<book... |
If it doesn't have one, you can still redirect the output using `>` into a file, then deleting the file afterwards. If you are on *nix, you can redirect into `/dev/null`. |
If it doesn't have one, you can still redirect the output using `>` into a file, then deleting the file afterwards. If you are on *nix, you can redirect into `/dev/null`.
##edit
In MSDOS and `cmd.exe` you can redirect into NUL, instead of a file. Thanks to [agnul](http://stackoverflow.com/users/6069/agnul) for this... |
float divs |
|css|div|list|float| |
I have a list with two `<div>`s in every `<li>` and I want to float them one next to the other and I want the `<li>` to take the whole availabe space. How do I do it?
<html>
<head>
<title></title>
<style type="text/css">
body {
}
ul {
}
li {
}
.a {
}
.b... |
|html|css|float| |
It's because the page in window.opener comes from a POST Request
Maybe you can use
javascript:window.opener.location = window.opener.location; to do just a GET request if the data can be fetched without a POST. |
No, but there is a solution. Its generally considered good design to use a 302 redirect immediately after someone posts data to a page. This prevents that popup from ever occuring. Allow me to elaborate.
1) The user fills in a form and submits data via POST.
2) The backend receives the data and acts upon it.
3... |
I'd never heard of Droid Sans Mono before, but I installed it and tried it at 9 points, and I must say it's by far the highest quality mono font I've seen on Linux.
On my Mac it's Panic Sans all the way, using it at 11 or 12 points allow anti-aliasing that actually works on monospace, which I've never seen before. |
I could certainly see the use in such a thing, but in .Net won't you mostly just get a list of type names (String, Array, etc)? Most of the built-ins don't have "useful" ToString() overloads pre-written, do they? |
Close mootools Rokbox through Javascript |
|javascript|mootools| |
I am using the mootools based Rokbox plugin, on one of my sites, and I can't figure out how to close it with javascript.
I triggered the click event on the close button, but that did not work.
I found the code in the rokbox source that is used to add the click listener
this.closeButton.addEvent('click',fun... |
Why is my programmatically created user missing from the Welcome screen? |
|security|winapi| |
I have a program that creates a Windows user account using the [NetUserAdd()][1] API which is [suggested by Microsoft][2]. The user is created successfully, and I can log in as that user.
However, on Windows XP, the newly-created user is missing from the Welcome screen. If I disable the Welcome screen, I can log i... |
Same as palehorse, use soapUI or directly the specific component for that feature: [TCPMon][1].
[1]: http://ws.apache.org/commons/tcpmon/ |
Depending on your needs, a couple others you might look at:
**Flare**
[![flare][2]][1]
**Prefuse**
[![prefuse][3]][4]
[1]: http://flare.prefuse.org/demo
[2]: http://flare.prefuse.org/media/flare-demo.gif
[3]: http://prefuse.org/gallery/images/t_sense.us.gif
[4]: http://prefuse.org/ |
In any case, you have to loop through it. Linq offers the `Count` method:
var result = myenum.Count(); |
Not possible with LINQ, as calling .Count(...) does enumerate the collection. If you're running into the problem where you can't iterate through a collection twice, try this:
List<MyTableItem> myList = dataContext.MyTable.ToList();
int myTableCount = myList.Count;
foreach (MyTableItem in myList)
... |
you will have to enumerate to get a count. Other constructs like the List keep a running count. |
The best way to get a count of IEnumerable<T> |
|c#| |
Whats the best/easiest way to obtain a count of items within an IEnumerable<T> collection without enumerating over all of the items in the collection?
Possible with LINQ or Lambda? |
|c#|linq| |
There's also IList<T> or ICollection<T>, if you want to use a construct that is still somewhat flexible, but also has the feature you require. They both imply IEnumerable. |
There are several scopes that are available to any portion of your code: Session, Client, Cookie, Application, and Request. Some are inadvisable to use in certain ways (i.e. using Request or Application scope inside your Custom Tags or CFC's; this is [coupling][1], violates encapsulation principles, and is considered a... |
In some situations, it's faster and more convenient to not draw using the paint event, but getting the Graphics object from the control/form and painting "on" that. This may give some troubles with opacity/anti aliasing/text etc, but could be worth the trouble in terms of not having to repaint the whole shabang. Someth... |
template problem with gcc |
|c++|gcc|templates| |
The following code doesn't compile with gcc, but does with Visual Studio:
template <typename T> class A {
public:
T foo;
};
template <typename T> class B: public A <T> {
public:
void bar() { cout << foo << endl; }
};
I get the error:
test.cpp: In member func... |
Thanks for the pointers.
I don't know, whether this is the best approach to the problem or not, but here is how I got it to work.
I referenced the Microsoft XML, v2.6 dll in my VBA, and then the following code snippet, gives me the required values
Dim objXML As MSXML2.DOMDocument
Set objXML =... |
If you want something free, try Nagios.
http://www.nagios.org/ |
That syntax has its uses though ... there are times when you find you need to join two tables on more than one field |
> I'm probably misremembering, but I
> thought that Joel's question was about
> counting the "on" bits rather than
> reversing them.
Here you go:
#include <stdio.h>
int countBits(unsigned char byte);
int main(){
FILE* out = fopen( "bitcount.c" ,"w");
int i;
... |
@erlando,
Talking about refactoring it seems to be much easier to change variable type by assigning instance of new type to one variable rather then changing it in multiple places, isn't it ?
As for code review I see no big issues with *var* keyword. During code review I prefer to check code logic rather variable... |
The <file> include tells the preprocessor to search in -I directories and in predefined directories **first**, then in the .c file's directory. The "file" include tells the preprocessor to search the source file's directory **first**, and then revert to -I and predefined. All destinations are searched anyway, only the ... |
I use Eclipse for creating J2EE web applications and this will create the following project structure:
WebAppName\
\lib
\src
\tests
etc...
I would then create an SVN folder on our trunk called WebAppNameProject. Within this folder I would create folders called WebAppNameSou... |
How much accuracy do you need? Dividing the longitude by 15 would almost be right :p |
The PixelFormat enumeration lists the formats of 'bitmaps' you can create in .Net, so you'd want PixelFormat.Format32bppArgb:
<http://msdn.microsoft.com/en-us/library/system.drawing.imaging.pixelformat.aspx>
<http://msdn.microsoft.com/en-us/library/3z132tat.aspx>
However I'm not entirely sure that the BMP file... |
<a href="http://directory.fsf.org/project/emacs/">GNU Emacs</a> has long been working natively on Windows as part of the main source, and can be compiled with Visual Studio (you can also find some pre-compiled binaries). As far as I know, there are no significant differences. |
Do you have access to the OCX code? You shouldn't really be directly invoking the click of a button. You should refactor the code so that the OCX button click code calls a function, e.g.
CMyWindow::OnLButtonDown()
{
this->FooBar();
}
Then from your VB6 app, directly call the FooBar method. If... |
One thing that I found very helpful for unit tests was to have a myApp/src/ and also myApp/test_src/ directories. This way, I can place unit tests in the same packages as the classes they test, and yet I can easily exclude the test cases when I prepare my production installation. |
Can you not have the Foo (implementation) aggregate iBar (interface)? That seems to me the proper way to describe this relationship. |
Can you not have Foo (implementation) aggregate iBar (interface)? That seems to me the proper way to describe this relationship.
So something like this:
----------------- -----------------
| <<interface>> | | <<interface>> |
| iFoo |<> <>| iBar |
----------------- ... |
Text found on MSDN:
[http://msdn.microsoft.com/en-us/library/aa264524(VS.60).aspx][1]
> Visual Basic for Applications
> Reference Out of string space (Error
> 14)
>
> Specifics
>
> Visual Basic permits you to use very
> large strings. However, the
> requirements of other programs and the
> way you mani... |
You have to override any abstract elements of your base class. If they are marked abstract, it means the base class does not provide a default implementation, so you cannot call it. |
"\n".charCodeAt(0); |
The worker process is probably cycling.
[http://www.lattimore.id.au/2006/06/03/iis-dropping-sessions/][1]
[1]: http://www.lattimore.id.au/2006/06/03/iis-dropping-sessions/ |
I assume by take the whole space you mean a width of 100%. I would also assume that you do not want styling applied to the list, which is why I have removed it in this example. This is also hack-free. You need not clear anything, so long as your list item has a width and the overflow: hidden property/value pair.
... |
Separate configuration files, stored in the source control repository and updated by hand. Typically configuration does not change radically between one version and the next so synchronization (even by hand) isn't really a major issue.
For highly scalable systems in production environments I would <i>seriously</i> r... |
To follow up on Rons approach: You can find your z-values if you know how you've rotated your rectangle.
The trick is to find the projective matrix that did the projection. Fortunately this is possible and even cheap to do. The relevant math can be found in the paper "Projective Mappings for Image Warping" by Paul H... |
C++ operations are: & | ^ ~ (for and, or, xor and not bitwise operations). Also of interest are >> and <<, which are bitshift operations.
So, to test for a bit being set in a flag, you would use:
if (flags & 8) //tests bit 4 has been set
|
Example code to dump an object and its properties can be found here:
http://www.developer.com/net/csharp/article.php/3713886
|
The idiom is to use the bitwise or-equal operator to set bits:
flags |= 0x04;
To clear a bit, the idiom is to use bitwise and with negation:
flags &= ~0x04;
Sometimes you have an offset that identifies your bit, and then the idiom is to use these combined with left-shift:
flags |= 1 << offset... |
IIf vs. If |
|iif|if| |
In Visual Basic, is there a performance difference when using the IIf function instead of the If statement? |
|iif-function|if-statement|vb| |
|vb|if-statement|iif-function| |
In Visual Basic, is there a performance difference when using the **IIf** function instead of the **If** statement? |
IIf() vs. If |
MySQL Trigger & Stored Procedure Replication |
|mysql|stored-procedures|triggers| |
Ok,I'm running a setup with a single master and a number of slaves. All writes go through the master and are replicated down to the slaves which are used strictly for reads.
Now I have a stored procedure (not function) which is called by a trigger on an insert. According to the MySQL docs, for replication triggers ... |
There are several scopes that are available to any portion of your code: Session, Client, Cookie, Application, and Request. Some are inadvisable to use in certain ways (i.e. using Request or Application scope inside your Custom Tags or CFC's; this is [coupling][1], violates encapsulation principles, and is considered a... |
You should consider this, it is really ZIRRO friction and it integrates well in
various scenarios. <br />Not to mention it is free of charge.
[http://www.visualsvn.com/server/][1]
Cheers,
<br />Dragos
[1]: http://www.visualsvn.com/server/ "VisualSVN Server" |
I'm not quite sure this is what you want, but [Tigris.org](http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91), which hosts the Svn project, has an [MSI installer for Subversion 1.5](http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91). It includes bindings for Apache.
Perhaps yo... |
One solution would be to use a StateServer, rather than InProc session management.
Lots of things can cause the session state to be lost:
1. Editing Web.Config
2. IIS resetting
3. etc.
If the session state is important to your app then use either SQL state management, or the State Server which ships with ... |
Moving from VSS to SVN |
|svn|version-control|visual-sourcesafe| |
I need to write a script to make a source safe project ready to be moved to subversion, what do I need to do so far I can think of:
- remove .scc files
- remove .vspcc files
Do I need to remove the "read-only" attribute of all the files as well, or will that not matter?
What language would you write this ... |
As I said, it is not so easy to 'switch' or re-architect when this is a live, in production system. I'm slightly frustrated that MySQL provides no methods to check for locks or choose not to hang waiting on a lock. |
This should do:
using System.Text.RegularExpressions;
Regex.Replace(s, !@"^[0-9]*$”, "");
Where s is your String where you want the numbers to be extracted. |
Just make sure to escape the ampersand like so:
/=(\d+)\&/
|
This is not a new problem, there are several scenarios that must be handled if you want to catch all the ways a session can end, here are general examples of some of them:
1. The browser instance or tab is closed.
2. User navigates away from your website using the same browser instance or tab.
3. The users lose... |
I have different configuration folders holding the configurations for the target deployment, and I use ANT to select the one to use during the file copy stage. |
Why all the Active Record hate? |
|designpatterns|oop|activerecord| |
As I learn more and more about OOP, and start to implement various design patterns, I keep coming back to cases where people are hating on [Active Record][1].
Often, people say that it doesn't scale well (citing Twitter as their prime example) -- but nobody actually explains ***why*** it doesn't scale well; and / or... |
|ruby-on-rails|oop|designpatterns|activerecord| |
|ruby-on-rails|oop|design-patterns|activerecord| |
|ruby-on-rails|design-patterns|oop|activerecord| |
[Breaking changes in NHibernate 2.0](http://forum.hibernate.org/viewtopic.php?t=985289)
If you have good test coverage it's mostly busywork. |
[Breaking changes in NHibernate 2.0](http://forum.hibernate.org/viewtopic.php?t=985289)
**If you have good test coverage it's busywork.**
Edit: We upgraded this morning. There is nothing major. You have to Flush() the session after you delete. The Expression namespace got renamed to Criterion. All these are c... |
Can you provide more information about what you're trying to accomplish? It's not clear to me why you can't just say
for x in everything():
...
and have the everything function return everything, instead of writing a next function to just return one thing at a time. Generators can even do this qu... |
You need to turn off autopostback on the dropdown - then, you need to hook up some javascript code that will take over that role - in the event handler code for the onchange event for the dropdown, you would create a URL based on the currently-selected value from the dropdown and use javascript to then request that pag... |
You need to turn off autopostback on the dropdown - then, you need to hook up some javascript code that will take over that role - in the event handler code for the onchange event for the dropdown, you would create a URL based on the currently-selected value from the dropdown and use javascript to then request that pag... |
There are quite a few vi clones (e.g. vim) and also various Emacs implementations (Gnu Emacs vs. XEmacs spring to mind).
These clones differ on Unix themselves and will thus also differ on Windows.
One thing I found with vim is that the directory structure for plugins etc. is very different on Windows - `~/vim.rc... |
Always including the user in the django template context |
|python|authentication|django|session|cookies| |
I am working on a small intranet site for a small company, where user should be able to post. I have imagined a very simple authentication mechanism where people just enter their email address, and gets sent a unique login url, that sets a cookie that will always identify them for future requests.
In my template set... |
The Windows versions typically use the same base source code as the "regular", Unix-based versions. There may be sections of the code that are specific to Windows, just as there are sections specific to certain flavours of Unix. In general, though, the Windows versions of these packages will behave identically to the U... |
I use [GNU emacs built for Windows][1], and have found very few, if any, differences. There's the option to load your .emacs file from _emacs or .emacs (although .emacs works fine on XP and above). You can configure it to use Windows-style or Unix-style line endings by default (which I suppose you could do on a Unix sy... |
I had a similar issue, however I had first implemented the solution using JavaScript, and just afterwards considered how I would have done the same thing in django templates.
I used the serializer utility to turn a list off models into json, and used the json data as a basis for my hierarchy. |
You might find it a lot easier to parse the file with a proper parser generator - ANTLR can generate one in C#... Context Free parsers only seem hard until you "get" them - after that, they are much simpler and friendlier to use than Regular Expressions... |