instruction stringlengths 0 30k ⌀ |
|---|
<a href="http://www.mattcutts.com/blog/common-google-chrome-objections/">Matt Cutts</a> (the Google
SEO guru) has a Q&A about chrome, and
writes about it:
<blockquote>Q: But I can’t install extension X! Google Chrome is dead to me if I can’t use extension X!<br/>
A: Then you’ll have to use another browser for a... |
We use branching in source control; everyone uses the head branch until they make a release. When they branch the release, they'll branch the common utilities project as well.
Additionally, our utilities project has its own unit tests. That way, other teams can know if they would break the build for other teams.
... |
Drop the first marble from the 3rd floor. If it breaks, you know it's floor 1 or 2, so drop the other marble from floor 2. If it doesn't break you've found that floor 2 is the highest. If it does break, you've found that floor 1 is the highest. 2 drops.
If dropping from the 3rd floor does not break the marble, d... |
ASP.NET Master Pages |
|.net|asp.net| |
I've just been learning about master pages in ASP.NET 2.0. They sound great, but how well do they work in practice? Does anybody have experience of using them for a large web site? |
I'm pretty sure I've only used master pages in the context of ASP.NET MVC so I'm not sure if it differs from web forms but in my experience they are not only excellent but I couldn't imagine not using them. Master pages are code inheritance to web pages. |
Not a technology podcast, but I really have to mention [FreelanceRadio][1]. A really great and sometimes hilarious resource. I'm listening to them in the morning, on the way to work. And sometimes feel really stupid just giggling by myself :P
[1]: http://freelanceswitch.com/podcasts/ |
@Curt: I think you came the closest. I haven't tested this but I think I sort of gave the answer in my original question.
[GetMessage][1] is a define in Windows.h wrapped in a ifndef block to switch between Ansi (GetMessageA) and Unicode (GetMessageW).
[1]: http://msdn.microsoft.com/en-us/library/ms644936.asp... |
This may be only marginally better, but what I usually do is :
public string ReturnAsCSV(ContactList contactList)
{
StringBuilder sb = new StringBuilder();
foreach (Contact c in contactList)
{
if (sb.Length > 0) { sb.Append(","); }
sb.Append(c.Name);
... |
Use **document.location.search** and **split()**
http://www.example.com/example.html?argument=value
var queryString = document.location.search();
var parts = queryString.split('=');
document.write(parts[0]); // The argument name
document.write(parts[1]); // The value
Hope it helps
... |
Can you use any scripting? Something like Javascript. If you can, then pass the values along in the query string (just add a ?ValueName=Value) to the end of your links. Then on the target page retrieve the query string value. The following site shows how to parse it out: [Parsing the Query String][1].
[1]: h... |
Can you use any scripting? Something like Javascript. If you can, then pass the values along in the query string (just add a "?ValueName=Value") to the end of your links. Then on the target page retrieve the query string value. The following site shows how to parse it out: [Parsing the Query String][1].
[1]:... |
Are there any resources about the PHP XMLWriter functionality? |
|php|xml|xmlwriter| |
The PHP documentation can be found [here][1], but I think it's rather lacking. There are no examples of how to use these functions, and few (if any) of the pages have user comments. So where might I be able to find an explanation (and example code) on how to use these functions to write an XML document?
[1]: htt... |
passwords:
$ gpg --gen-random 1 20 | gpg --enarmor | sed -n 5p
passphrases:
http://en.wikipedia.org/wiki/Diceware |
I ran into the same problem. I wanted tabs to work like buffers and I never quite manage to get them to. The solution that I finally settled on was to make buffers behave like tabs!
Check out the plugin called [Mini Buffer Explorer](http://vim.sourceforge.net/scripts/script.php?script_id=159), once installed and co... |
Well this is pretty basic with javascript, but if you want more of this and more advanced stuff you should really look into php for instance. Using php it's easy to get variables from one page to another, here's an example:
the url:
localhost/index.php?myvar=Hello World
You can then access myvar in index... |
If the client has Java installed, you could do something like this:
`ipAddress = java.net.InetAddress.getLocalHost().getHostAddress();`
Other than that, you will probably have to use a server side script.
Alex |
What are some good usability Addins for Visual Studio 2008? |
|visual-studio|visual-studio-2008|tabs|user-interface| |
John Ruby is correct that you need to include the id of the object in the select.
Also, you rarely need to use the :select option. You can with joins, or if there is a real performance issue with selecting the entire row, but this doesn't come up much.
And you really don't need to be setting all those variables ... |
I'd use this particular pattern:
string re = @"foo\[\]=(?<value>\d+)";
So something like (not tested):
Regex reValues = new Regex(re,RegexOptions.Compiled);
List<integer> values = new List<integer>();
foreach (Match m in reValues.Matches(...putInputStringHere...)
{
values.A... |
Based on new details in the comments, the solution may simply be an implementation of a standard random permutation generation algorithm. There is a lengthy discussion of random permutation generation algorithms here:
http://www.techuser.net/randpermgen.html
(From Google search: random permutation generation)
|
What is the simplest way to stub a complex interface in Java? |
|java|testing| |
My code takes an interface as input but only excercises a couple of the interface's methods (often, just getters).
When testing the code, I'd love to define an anonymous inner class that returns the test data. But what do I do about all the other methods that the interface requires?
I could use my IDE to auto-ge... |
Is the certificate on the client site valid? You may want to specify --no-certificate-check if it is a self-signed certificate.
[HTTPS (SSL/TLS) Options for wget][1]
[1]: http://www.gnu.org/software/wget/manual/wget.html#HTTPS-_0028SSL_002fTLS_0029-Options |
I think you'll find <tt>XMLGenerator</tt> from <tt>xml.sax.saxutils</tt> is the closest thing to what you want.
<pre>
import time
from xml.sax.saxutils import XMLGenerator
from xml.sax.xmlreader import AttributesNSImpl
LOG_LEVELS = ['DEBUG', 'WARNING', 'ERROR']
class xml_logger:
def __init__(self, ou... |
vim commands in Eclipse |
|eclipse|vim| |
I have been doing some java development lately and have started using Eclipse. For the most part, I think it is great, but being a C/C++ guy used to doing all of his editing in vim, I find myself needlessly hitting the Esc key over and over.
It would be really nice if I got all the nice features of Eclipse, but sti... |
I've found [iBatis][1] from the Apache group to be an excellent solution to this problem. My team is currently using iBatis to map all of our calls from Java to our MySQL backend. It's been a huge benefit as it's easy to manage all of our SQL queries and procedures because they're all located in XML files, not in our... |
If you need to do this more than one, the pythonic way would use an iterator
for x in iternext():
do_something_with_x
where `iternext` would be defined using something like
([explicit is better than implicit!][1]):
def iternext():
x = next()
while x != END:
yiel... |
If you need to do this more than once, the pythonic way would use an iterator
for x in iternext():
do_something_with_x
where `iternext` would be defined using something like
([explicit is better than implicit!][1]):
def iternext():
x = next()
while x != END:
yie... |
Wrap it in an interface and mock it. |
I know nothing of specman, but a fixed sized list is an array, so that might point you somewhere. |
Although all the other comments regarding SQL optimization are certainly valid, my main complaint with the active record pattern is that it usually leads to [impedance mismatch][1]. I like keeping my domain clean and properly encapsulated, which the active record pattern usually destroys all hope of doing.
[1]: h... |
PAD (Portable Application Description) files for shareware / freeware |
|open-source|freeware|software-distribution| |
I've been told that I should include [PAD files][1] with the freeware applications I distribute so hosting sites can list the information correctly and check for updates, etc.
Can you give me some info on using PAD files? Here are general questions which come to mind:
- Is it worth the effort?
- Do you use ... |
I've been using Visual Studio for a long time and the constant shuffling of the code tabs at the top drives me bonkers. I was wondering if there were any add-ins that might change this or other UI behavior.
Things that might be cool:
- Sticky Tabs that won't go away.
- Multi-code file collapsible tabs (maybe eac... |
What are some good usability addins for Visual Studio 2008? |
|visual-studio|visual-studio-2008|user-interface|tabs| |
I've been using Visual Studio for a long time and the constant shuffling of the code tabs at the top drives me bonkers. I was wondering if there were any add-ins that might change this or other UI behavior.
Things that might be cool:
- Sticky Tabs that won't go away.
- Multi-code file collapsible tabs (maybe eac... |
Let <code>p<sub>n</sub></code> be a list of all possible letter combinations of a given number string <code>s</code> up to the <code>n<sup>th</sup></code> digit.
Then, the following algorithm will generate <code>p<sub>n+1</sub></code>:
digit = s[n+1];
foreach(letter l that digit maps to)
{
... |
Use wget, do a recursive web suck, which will dump all the files onto your harddrive, then write another script to go through all the downloaded files and analyze them.
Edit: or maybe curl instead of wget, but I am not familiar with curl, I do not know if it does recursive downloads like wget. |
With a nested table, like:
<table id="foo">
<th class="sortasc">Header</th>
<tr><td>
<table id="nestedFoo">
<th class="sortasc">Nested Header</th>
</table>
</td></tr>
</table>
$('table#foo th.sortasc') will give you *all* the th's because you're using a [... |
If you're ready for a long read, [here][1] is a _great_ explaination. Long story short, it allows you to implement recursion in a language that doesn't necessarily support it natively.
[1]: http://mvanier.livejournal.com/2897.html |
If you're ready for a long read, [Mike Vanier has a _great_ explaination][1]. Long story short, it allows you to implement recursion in a language that doesn't necessarily support it natively.
[1]: http://mvanier.livejournal.com/2897.html |
Using Visual Studio 2005 or 2008 when you create a project for an executable, on the properties windows inside the "Application" panel there is a check box named “Make single instance application” that you can activate to convert the application on a single instance application. |
A nice, tactile keyboard helps. Especially if it's blank. You'll be speeding along in no time.
http://store.daskeyboard.net/prdaskeulorb.html
|
Unfortunately killing a thread is inherently unsafe due to the possibilities of using resources that can be synchronized by locks and if the thread you kill currently has a lock could result in the program going into deadlock (constant attempt to grab a resource that cannot be obtained). You will have to manually check... |
Practice, Practice and Practice |
You can approximate it but J2ME (the version of java on mobile phones) may not be the right technology to do this.
- starting a MIDlet (a Java application for mobile phones) when the phone is switched on is tricky at best without coding a small Symbian OS C++ module that will start it for you. If you want to try any... |
To expand on what Mendelt Siebenga suggested, I would also add a `web` directory (for JSP files, WEB-INF, web.xml, etc).
Tests should go in a folder named `test` that is a sibling of the main `src` folder - this way your unit test classes can have the same package name as the source code being tested (to ease with ... |
A print statement does its IO through "sys.stdout.write" so you can override sys.stdout if you want to manipulate the print stream. |
Conditional Display in ASPX Pages on Sharepoint |
|asp.net|sharepoint| |
I wonder what the best practice for this scenario is:
I have a Sharepoint Site (MOSS2007) with an ASPX Page on it. However, I cannot use any inline source and stuff like Event handlers do not work, because Sharepoint does not allow Server Side Script on ASPX Pages per default.
Two solutions:
1. Change the Page... |
Read up at [6.1 Namespace Scoping][1] and [6.2 Namespace Defaulting][2] on w3c.
Basically:
> The scope of a namespace declaration declaring a prefix extends from the beginning of the start-tag in which it appears to the end of the corresponding end-tag
However, the text here doesn't seem to explain if <foo:bar... |
Your idea should work fine. Basically you just want to spawn a bunch of threads, and make sure the ones writing the file take long enough to do it to actually make the readers wait. If all of your threads return without error, and without blocking forever, then the test succeeds. |
Your code not really compliant with [full CSV format][1]. If you are just generating CSV from data that has no commas, leading/trailing spaces, tabs, newlines or quotes, it should be fine. However, in most real-world data-exchange scenarios, you do need the full imlementation.
For generation to proper CSV, you can ... |
I know you asked for Java, but this strikes me as a task well suited to a scripting language. Here is a quick (very simple) solution written in Groovy.
**test.csv**
string,float1,float2,integer
hello world,1.0,3.3,4
goodbye world,1e9,-3.3,45
hello again,-1,23.33,456
hello world 3,1.40,34.8... |
One of the things that helped me was something I learned from pianist... when doing a touch typing program, deliberately slow down and speed up your rate of typing from disgustingly slow to really fast in slow waves. This helps train yourself to figure out how to get your fingers to work together faster and reinforces... |
It's not a Visual Studio add in, but it is a tool that I couldn't use Visual Studio without it...
[**ClipX**](http://bluemars.org/clipx/) - it's works with the normal clipboard, but saves the entries to a searchable list, you can use copy and paste as ususal, but you can hit CTRL+SHIFT+V and the list pops up. It wo... |
You should use 'multiOptions' instead of 'options'. |
We use different ant targets for different environments. The way we do it may be a bit inelegant but it works. We will just tell certain ant targets to filter out different resource files (which is how you could exclude certain beans from being loaded), load different database properties, and load different seed data i... |
How do I sort by the length of a field. |
|asp.net|datagrid| |
I have a DataGrid where each column has a SortExpression. I would like the sort expression to be the equivalent of "ORDER BY LEN(myField)".
I have tried
SortExpression="LEN(myField)"
but this throws an exception as it is not valid syntax. Any ideas? |
How do I sort an ASP.NET DataGrid by the length of a field? |
Check out JMock.
http://www.jmock.org/
|
The thread that is updating the 3D view should periodically check some flag (use a `volatile boolean`) to see if it should terminate. When you want to abort the thread, just set the flag. When the thread next checks the flag, it should simply break out of whatever loop it is using to update the view and return from i... |
The thread that is updating the 3D view should periodically check some flag (use a `volatile boolean`) to see if it should terminate. When you want to abort the thread, just set the flag. When the thread next checks the flag, it should simply break out of whatever loop it is using to update the view and return from i... |
My favorite uses are "filter" and "reduce" operations.
Let's say we're reading a file, and only want the lines which begin with "##".
def filter2sharps( aSequence ):
for l in aSequence:
if l.startswith("##"):
yield l
We can then use the generator function in a proper ... |
There's no notion of hosts or ip-addresses in the javascript standard library. So you'll have to access some external service to look up hostnames for you.
I recommend hosting a cgi-bin which looks up the ip-address of a hostname and access that via javascript.
|
If you want to generate passwords that are easier for users to remember, take a look at Markov chains. http://en.wikipedia.org/wiki/Markov_chain
This algorithm can produce nonsense words that can be pronounced, so they also become easier to remember and to relay over the phone. A little Google-fu can get you some c... |
Doing this would require to break the browser sandbox. Try to let your server do the lookup and request that from the client side via XmlHttp. |
We have experienced the same thing and have handled it by using ghost controls on page_load that have the exact same .ID and then the post back picks up the events and the data. As others said it's the dynamic adding of the control after the init stages that the state is built already and controls added after aren't s... |
Buffering. When it is efficient to fetch data in large chunks, but process it in small chunks, then a generator might help:
def bufferedFetch():
while True:
buffer = getBigChunkOfData()
# insert some code to break on 'end of data'
for i in buffer:
yield i
... |
|c#|vb.net|.net|bestpractices|dotnet| |
|.net|bestpractices| |
I have seen these being used every which way, and have been accused of using them the wrong way (though in that case, I was using them that way to demonstrate a [point](http://blog.gadodia.net/extension-methods-in-vbnet-and-c/)).
So, what do you think are the best practices for employing Extension Methods?
Should... |
|.net|bestpractices| |
|.net|bestpractices| |
|.net| |
Using unhandled exceptions instead of Contains()? |
|c#|.net|bestpractices|error-handling| |
Imagine an object you are working with has a collection of other objects associated with it, for example the Controls collection on a WinForm. You want to check for a certain object in the collection, but the collection doesn't have a Contains() method. There are several ways of dealing with this.
- Implement yo... |
|c#|.net|error-handling| |
Best way to access a control on another form in c#? |
|windowsforms|c#|controls|bestpractices| |
First off, this is a question about a desktop app using Windows Forms, not an ASP.Net question.
I need to interact with controls on other forms. Trying to access the controls by using, for example, the following...
otherForm.Controls["nameOfControl"].Visible = false;
...doesn't work the way I would expect.... |
First off, this is a question about a desktop app using Windows Forms, not an ASP.Net question.
I need to interact with controls on other forms. Trying to access the controls by using, for example, the following...
otherForm.Controls["nameOfControl"].Visible = false;
...doesn't work the way I would expect.... |
In general, there's no need to null objects after use, but in some cases I find it's a good practice.
If an object implements IDisposable and is stored in a field, I think it's good to null it, just to avoid using the disposed object. The bugs of the following sort can be painful:
this.myField.Dispose();
... |
Icons: How does a developer with no design skill make his apps look pretty? |
|user-interface|icons| |
I probably spend far too much time trying to make my visual interfaces look good, and while I'm pretty adept at finding the right match between usability and style one area I am hopeless at is making nice looking icons.
How do you people overcome this (I'm sure common) problem? I'm thinking of things like images on... |