instruction stringlengths 0 30k ⌀ |
|---|
Yes, although you have to apply some pragmatism to the situation. I always take the Law of Demeter as a guideline as opposed to a rule.
Certainly you may well want to avoid the following:
CurrentCustomer.Orders[0].Manufacturer.Address.Email(text);
perhaps replace with:
CurrentCustomer.Orders[0].Emai... |
In Windows, async operations are done by file operation, not by descriptor. There are several ways to wait on file operations to complete asynchronously.
For example, if you want to know when data is available on a network socket, issue an async read request on the socket and when it completes, the data was availabl... |
I've looked at [Life's Contingency's Package][3], various Actuarial Outpost [forum][1] [threads][2], and the [Comprehensive Symbol List][4] for LaTeX, and combined the best into the following macros:
\DeclareRobustCommand{\lcroof}[1]{
\hbox{\vtop{\vbox{%
\hrule\kern 1pt\hbox{%
... |
**Why is it needed?**
When data is stored on disk based storage devices, it is stored as blocks of data. These blocks are accessed in their entirety, making them the atomic disk access operation. Disk blocks are structured in much the same way as linked lists; both contain a section for data, a pointer to the locati... |
I have noticed a mismatch sometimes between the IDE parser and the compiler whenever a compile-time error occurs in a referenced assembly or code file. In that circumstance the IDE will correctly identify the types and provide full support for them, but since the compiler was unable to create the referenced objects, it... |
As I suspected it was something silly that I did. I think I solved this twice as fast because of some of the clues in comments in the messages above. Thanks to those especially those who pointed to something early in the app overwriting the stack. I actually found several answer here more useful that the post I have... |
Simple enough:
for(var propertyName in myObject) {
// propertyName is what you want
// you can get the value like this: myObject[propertyName]
}
Now, you will not get private variables this way because they are not available. |
Simple enough:
for(var propertyName in myObject) {
// propertyName is what you want
// you can get the value like this: myObject[propertyName]
}
Now, you will not get private variables this way because they are not available.
----------
EDIT: [@bitwiseplatypus][1] is correct that un... |
Multiple Inheritance in PHP |
|php|oop|inheritance| |
I'm looking for a good, clean way to go around the fact that PHP5 still doesn't support multiple inheritance. Here's the class hierarchy:
Message
-- TextMessage
-------- InvitationTextMessage
-- EmailMessage
-------- InvitationEmailMessage
The two types of Invitation* classes have a lot ... |
How do you load an embedded icon from an exe file with PyWin32? |
|python|pywin32|exe|icons| |
I have an exe file generated with py2exe. In the setup.py I specify an icon to be embedded in the exe:
windows=[{'script': 'my_script.py','icon_resources': [(0, 'my_icon.ico')], ...
I tried loading the icon using:
hinst = win32api.GetModuleHandle(None)
hicon = win32gui.LoadImage(hinst, 0, win32con... |
|python|exe|icons|pywin32| |
I have an exe file generated with py2exe. In the setup.py I specify an icon to be embedded in the exe:
windows=[{'script': 'my_script.py','icon_resources': [(0, 'my_icon.ico')], ...
I tried loading the icon using:
hinst = win32api.GetModuleHandle(None)
hicon = win32gui.LoadImage(hinst, 0, win32con... |
False:
[1][1]#
(False is a stack language: # is a while loop that takes 2 closures, a conditional and a body. The body is the one that causes the overflow). |
Best way to aggregate multiple log files from several servers |
|logging|distributed|monitoring|parsing| |
I need a simple way to monitor multiple text log files distributed over a number of HP-UX servers. They are a mix of text and XML log files from several distributed legacy systems. Currently we just ssh to the servers and use *tail -f* and *grep*, but that doesn't scale when you have many logs to keep track of.
Sinc... |
I'm surprised no one has mentioned basic knowledge of XAML yet. Knowing what XAML is, and the ability to do some basic editing using XAML rather than a graphical design tool. Mid-level developers should be able to knock up form / graphic prototypes using a tool like XAMLPad. |
That's like saying you want to stop spam-bots from harvesting emails on your publicly visible page - it's very tough to tell the difference between users and bots without forcing your viewers to log in to confirm their identity.
You could use robots.txt to disallow the spiders that actually follow those rules, but t... |
Delphi doesn't have static variables, you have to use a global variable.
To make it as private as possible, put it in the <code>implementation</code> section of your unit. |
Before version 7, Delphi didn't have static variables, you'd have to use a global variable.
To make it as private as possible, put it in the <code>implementation</code> section of your unit. |
Just open-source it. Most probably, nobody will start contributing yet. But at least you can write on the press-releases that your product is GPL or whatever.
The first step is that people start using it...
And maybe then, after users get comfortable, they will start contributing.
|
The selectedIndex can only be -1 when the control is first initalised and there is no items within the collection.
It's not possible to have no item selected in a web drop down list as you would on a WinForm.
I find it's best to have:
this.myDropDownList.Items.Add(new ListItem("Please select...", ""));
This w... |
I use reparse points http://www.hanselman.com/blog/MoreOnVistaReparsePoints.aspx to redirect My Documents. |
You should follow the instructions in this mactips post: <http://www.mactips.org/archives/2007/12/20/word-movement-in-terminal/>.
Works perfectly for me. |
*Unbound* means there is no data associated with form (either initial or provided later), so the validation may fail. As mentioned in other answers (and in your own conclusion), you have to provide initial values and check for both bound data and initial values.
The use case for forms is form processing **and** vali... |
Many thanks guys, I can now call my assembly from my reports.
**Supplementary question:**
Is there a namespace I can include when I'm creating my assembly that makes it aware of objects in the report designer such as fields and parameters? It'd be really great if I could pass, say, a collection of fields in a stron... |
DefaultButton in ASP.NET forms |
|asp.net|key|defaultbutton|enter|pressed| |
What is the best solution of defaultButton and "Enter key pressed" for ASP.NET 2.0-3.5 forms? |
Please see chapter 5 of the spring reference manual here: [5.4.2.1. Registering additional custom PropertyEditors][1]
[1]: http://static.springframework.org/spring/docs/2.5.x/reference/validation.html |
Please see chapter 5 of the spring reference manual here: [5.4.2.1. Registering additional custom PropertyEditors][1]
[1]: http://static.springframework.org/spring/docs/2.5.x/reference/validation.html#beans-beans-conversion-customeditor-registration |
Practically speaking, endianess refers to the way the processor will interpret the content of a given memory location. For example, if we have memory location 0x100 with the following content (hex bytes)
<pre><code>
0x100: 12 34 56 78 90 ab cd ef
Reads Little Endian Big Endian
8-bit: 12 ... |
What's the best way to extract table content from a group of HTML files? |
|java|html|excel|csv|extract| |
After cleaning a folder full of HTML files with TIDY, how can the tables content be extracted for further processing? |
If your email is business critical, then you need to get a dedicated server with a white-hat hosting company, control over DNS to set up your SPF/SenderID record, and to register with the Hotmail, AOL and Yahoo postmasters for whitelisting and feedback loops. Most of these will only accept requests for dedicated serve... |
Meh - User.Dial(number). The phone is meaningless in the given context. SOL (speak out loud) is a nice way to think this through (idioms and principles aside):
Phones have a dial. They can't dial themselves.
Phone numbers are digits.
Users dial PhoneNumbers on a Phone Dial.
|
Simple enough:
for(var propertyName in myObject) {
// propertyName is what you want
// you can get the value like this: myObject[propertyName]
}
Now, you will not get private variables this way because they are not available.
----------
EDIT: [@bitwiseplatypus][1] is correct that un... |
Do an inner join. It's much easier and more readable.
<pre><code>select
customerName,
customerID,
count(*) as numberTransactions
from
customerdata c inner join purchases p on c.customerID = p.customerID
group by customerName,customerID
order by numberTransactions
</code></pre> |
Do an inner join. It's much easier and more readable.
<pre><code>select
customerName,
customerID,
count(*) as numberTransactions
from
customerdata c inner join purchases p on c.customerID = p.customerID
group by customerName,customerID
order by numberTransactions
</code></pre>EDIT: Hey Nathan,
Yo... |
How many tests did you do before you averaged? Very, very small deviations are statistically insignificant! There are plenty of reasons for speed to vary slightly between tests. |
What are the best Java examples sites? |
|java| |
DDD is the GNU frontend for gdb: http://www.gnu.org/software/ddd/ |
A couple of things to add/expand on (speaking from the .NET point of view):
Generic types allow you to create role-based classes and interfaces. This has been said already in more basic terms, but I find you start to design your code with classes which are implemented in a type-agnostic way - which results in highl... |
I've never really understood this myself (I don't program GUIs). Why even have menu items hidden or disabled in the first place? It is non-intuitive for most users who are looking for a particular menu option to find it disabled, or not even present.
Tooltips are also non-intuitive. If I'm moving my mouse across men... |
As with most questions about usability, the answer is "it depends". It depends on the problem domain, the type of user, how critical the function is and so on. There is no single answer to your question.
I think the general consensus is, never ever totally remove items from a menu. Menus allow the user to freely dis... |
I'm not 100% sure how to achieve this but I know where a good place to start would be, in the ASP.NET MVC source. In recent versions it is capable of taking the form response and pass it into a helper method which does the writing to a LINQ data source.
I believe MVC is C# so if you're looking for a VB translation y... |
There is really no benefit to doing this, except if you are dealing with metaclasses.
the class: suite really isn't what you think it is. It is a weird scope, and it does strange things. It really doesn't even make a class! It is just a way of collecting some variables - the name of the class, the bases, a little di... |
This is my new favorite solution, using the populator and faker gems:
[http://railscasts.com/episodes/126-populating-a-database][1]
[1]: http://railscasts.com/episodes/126-populating-a-database |
Does anyone know of a way of hiding a column in an asp.net listview? |
|asp.net|listview| |
I know you can put <% if %> statements in the LayoutTemplate to hide controls but the column is still there.
Does anyone know of a better way? |
I know you can put <% if %> statements in the ItemTemplate to hide controls but the column is still there.
You cannot put <% %> statements into the LayoutTemplate which is where the column headings are declared, hence the problem.
Does anyone know of a better way? |
I've used [Trolltech's Qt framework][1] in the past and had great success with it:
In addition, it's also cross-platform, so in theory you can target Win, Mac, & Linux (provided you don't do anything platform-specific in the rest of your code, of course ;) )
[1]: http://trolltech.com/products/qt/ |
I've used [Trolltech's Qt framework][1] in the past and had great success with it:
In addition, it's also cross-platform, so in theory you can target Win, Mac, & Linux (provided you don't do anything platform-specific in the rest of your code, of course ;) )
Edit: I notice that you're targeting Windows Mobile; that... |
I had this exact same issue a few months ago when I was setting up a cert for a client.
There's a MachineKeys folder that the Administrator need rights -
\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys
give **Administrator** (or the Administrator group) **Full Control**... |
I had this exact same issue a few months ago when I was setting up a cert for a client.
There's a MachineKeys folder that the Administrator need rights -
\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys
give **Administrator** (or the Administrator group) **Full Control**... |
Class/Static Constants in Delphi |
|delphi| |
Many thanks guys, I can now call my assembly from my reports.
**Supplementary question:**
Is there a namespace I can include when I'm creating my assembly that makes it aware of objects in the report designer such as fields and parameters? It'd be really great if I could pass, say, a collection of fields in a stron... |
I am using the free version of [WinSQL](http://www.synametrics.com/SynametricsWebApp/WinSQL.jsp).
I am also looking at [SQLDeveloper](http://www.oracle.com/technology/products/database/sql_developer/index.html) from Oracle. I have heard it mentionned in the same breath as Toad.
In a pinch, I find that Microsoft ... |
A lot of people still cling to notions about faulty box-models in IE and reckon that if you start messing around with element widths, padding and margins, you're going to get into trouble.
That's pretty outdated advice - assuming you're using [a correct doctype][1], all browsers (including IE6) will work to the same... |
A lot of people still cling to notions about faulty box-models in IE and reckon that if you start messing around with element widths, padding and margins, you're going to get into trouble.
That's pretty outdated advice - assuming you're using [a correct doctype][1], all fairly modern browsers (including IE6+) will w... |
[Progress Reporting][1] for long running LINQ queries. In the blog post you can find an extension method WithProgressReporting() that lets you discover and report the progress of a linq query as it executes.
[1]: http://blog.functionalfun.net/2008/07/reporting-progress-during-linq-queries.html |
I have Alt-Left/Right working: open *Preferences » Settings » Keyboard*, set the entry for *option cursor left* to *send string to shell: \033b*, and set *option cursor right* to *send string to shell: \033f*. You can also use this for other Control key combinations. |
Use [ccache](http://ccache.samba.org/). It will hash the inputs to a compilation, and cache the results, which will drastically increase the speed of these sorts of compiles.
If you wanted to detect the multiple includes, so that you could remove them, parsing the output of `gcc -E` might be a fruitful approach. |
What are the best java example sites? By which I mean places that you go when you have a specific question, and you want a little java code snippet to solve it. |
This isn't specifically RoR however, it is pretty slick port of Gruff to javascript: http://bluff.jcoglan.com/ |
I like both solutions presented, so I avoided posting this for a while. But you could also make an update to the main table, having saved the state of the affected rows in some cache before hand.
This could be combined with the two-tier (The traffic cop system Zathrus proposed)--because it really wouldn't be needed... |
How can I specify the maximum amount of heap an RTP can use in VxWorks? |
|vxworks| |
We are creating a Real-Time Process in VxWorks 6.x, and we would like to limit the amount of memory which can be allocated to the heap. How do we do this? |
The Java Developer's Almanac: http://www.exampledepot.com/ |
Date manipulation in VBA |
|vba| |
Is it possible to manipulate the components (year, month, day) of a date in VBA? I'd like a function that, given a day, a month, and a year, returns the corresponding date. |
When I use SQL Management Studio I do not get the 'Modify' option, only 'Design' or 'Edit'. If you have Visual Studio (I have checked VS.NET 2003, 2005 & 2008) you can use the Server Explorer to change the schema. Right click on the table and select 'Design Table' (2008) or 'Open Table Definition' (2003, 2005). Highli... |
I like Java Almanac (now renamed www.exampledepot.com/). It has great examples and very pertinent questions, but it only goes through java 1.4, so unfortunately it's pretty out of date. It has good coverage of simple questions like "Quintessential Regular Expression Search and Replace Program" and "Reading Text from ... |
As this is starting to look like a `tie()` problem, try the following experiment. Save this as a foo.pl and run it as `perl foo.pl "x=1"`
use CGI;
CGI::ReadParse();
p($in{x}, "$in{x}");
sub p { my @a = @_; print "@a\n" }
It should print `1 1`. If it doesn't, we've found the culprit.
|
The Astra components are distributed with the complete source code. Flash CS3 components use compiled shims because otherwise you'd need to manually add the raw source files to your classpath. As a bonus, they also improve compile times because they're already built for you. Look in the "Source" folder in the Astra zip... |
Just add the "defaultbutton" attribute to the form and set it to the ID of the button you want to be the default.
<pre><form defaultbutton="button1" runat="server">
<asp:textbox id="textbox1" runat="server"/>
<asp:button id="button1" text="Button1" runat="server"/>
</form> </pre>
... |
Finding a list of characters that are common in ALL strings at a certain position is trivially simple. Just iterate on each string for each character position 1 character position at a time. If any string's character is not the match of it's closest neighbor string's character, then the position does not contain a co... |
from __future__ import braces |
No I haven't used it in production code.
Why?
1. We have to support 6+ platforms with _native_ _platform_ compilers. It's
hard enough to use STL in this envrionment let alone modern template
techniques.
2. Developers don't seem to be keeping up C++ advances anymore. We use C++
when we have to. We hav... |
No I haven't used it in production code.
Why?
1. We have to support 6+ platforms with _native_ _platform_ compilers. It's
hard enough to use STL in this environment let alone modern template
techniques.
2. Developers don't seem to be keeping up C++ advances anymore. We use C++
when we have to. We hav... |
I've used BeautifulSoup for such things in the past with great success. |
Might be a typo, but you are missing a semicolon here:
margin-left:auto; margin-right:auto position:relative;
Should be:
margin-left:auto; margin-right:auto; position:relative;
If that doesn't work, make sure the element you are trying to center the text on has some width. Try setting the width to 1... |
The reason this happens is because of PHP's old register_globals functionality. The . character is not a valid character in a variable name, so PHP coverts it to an underscore in order to make sure there's compatibility.
In short, it's not a good practice to do periods in URL variables. |
PHP: Can I reference a single member of an array that is returned by a function ? |
|php|arrays|function| |
["Writing Solid Code: Microsoft's Techniques for Developing Bug-Free C Programs (Microsoft Programming Series)"][1] by Steve MacGuire.
Interesting what a large proportion the books mentioned here are C/C++ books.
[1]: http://www.amazon.com/Writing-Solid-Code-Microsofts-Programming/dp/1556155514 |
[Firebug][1] is the best all around client-side debugger. I frequently use it to debug CSS code as well as javascript. It allows you to easily find offending areas of code. I especially like the ability to modify tag attributes in the firebug pane and see the effects immediately before committing. Very useful for an... |
I made myself a handy one-page cheat sheet and used it to learn all the non-basic features. However, practice is about the only way to master anything.
vi is nice because it's on every UNIX-type computer, Mac OS X, Solaris, Linux. Find an old decstation box on eBay? It's got vi. How about Sun OS 4? vi again. |
I'm mid-way through a similar project except I have multiple sites that need to keep in sync over slow connections (dial-up in some cases).
Firstly you need to track changes, if you can use SQL 2008 (even the Express version is enough if the 2Gb limit isn't a problem) this will ease the pain greatly, just turn on Ch... |
KDevelop works pretty well. |