instruction stringlengths 0 30k ⌀ |
|---|
you can try this trick that Scott Guthrie posted on his blog [http://weblogs.asp.net/scottgu/archive/2006/12/19/tip-trick-how-to-run-a-root-site-with-the-local-web-server-using-vs-2005-sp1.aspx][1]
to cut to the fix: select your project/solution in solution explorer and then open the Properties tab like you would if... |
Your first step is to find and understand the parallelism in your problem. It is really easy to write multi-threaded code that performs no better than the single-threaded code it replaces. "Patterns for Parallel Programming" [(Amazon)][1] is a great introduction to the key concepts.
Once you have a workable design, ... |
Take a look at how some of the popular PHP frameworks use templating. Examples include cakePHP, Zend Framework, and Code Igniter. Even if you are not going to base your site on these frameworks, the template design pattern is a good way to keep php code away from your web designers, so they can focus on layout and not ... |
I usually use includes, as they can be very useful for organising and grouping functions together. Also, comment your code. There's nothing worse than for someone else to see your work and not know why you've done this. Naming variables and functions sensibly can go a long way too - for example:
$userName = "Joh... |
Does the outside person need to edit the logic, or just the display (HTML)?
If it's the latter case, check out the [Smarty][1] template engine.
[1]: http://www.smarty.net/ |
@[Flávio Amieiro](#36420)
MeasureIt is an unnecessary extension to have if you install the Web Developer Toolbar. Web Developer Toolbar includes a ruler as one of its features. Under the "`Miscellaneous`" category for Web Developer click the option "`Display Ruler`" to use a ruler identical to the MeasureIt one.
... |
The ones I have are...
- [Y-SLow][1]
- [Live Headers][2]
- [Firebug][3]
- [Dom Inspector][4]
[1]: https://addons.mozilla.org/en-US/firefox/addon/5369
[2]: https://addons.mozilla.org/en-US/firefox/addon/3829
[3]: https://addons.mozilla.org/en-US/firefox/addon/1843
[4]: https://addons.mozill... |
We considered it when we were looking at open source frameworks. But we saw the same thing your did that there really just isn't much support or information for it. You should always weight the community support factor surrounding open source projects before picking one. (which is what you are doing here) :) |
How to Test Numerical Analysis Routines? |
|testing|numerical| |
Are there any good online resources for how to create, maintain and think about writing test routines for numerical analysis code?
One of the limitations I can see for something like testing matrix multiplication is that the obvious tests (like having one matrix being the identity) may not fully test the functionali... |
Personally, the second one as everything you are using is in the direct order it will be output in. Whereas with the first you have to match up the {0} and {1} with the proper var, which is easy to mess up.
At least it's not as bad as the C++ sprintf where if you get the variable type wrong the whole thing will b... |
I think this depends heavily on how complex the output is. I tend to choose whichever scenario works best at the time.
Pick the right tool based on the job :D Whichever looks cleanest! |
For very simple manipulation I'd use concatenation, but once you get beyond 2 or 3 elements Format becomes more appropriate IMO.
Another reason to prefer String.Format is that .NET strings are immutable and doing it this way creates fewer temporary/intermediate copies. |
I prefer the second as well but I have no rational arguments at this time to support that position.
|
I've done a lot of work on this kind of parsing. Because there are errors you won't get 100% accuracy, but there are a few things you can do to get most of the way there, and then do a visual BS test. Here's the general way to go about it. It's not code, because it's pretty academic to write it, there's no weirdness, j... |
|actionscript-3|naming|convention| |
I'm trying to write a RegEx for a code generator (in C#) to determine a proper class or package name of an AS3 class.
I know
- Must start with a letter (capital or otherwise)
- any other digit can be alphanumeric
- cannot have spaces
Is there anything else? |
If you're using C++ (or any other language with deterministic destructor execution when scopes end) you can take a look at [Scope Guards][1]. This technique can probably also be adapted to .NET by making ScopeGuard implement IDisposable and sprinkling "using" statements as needed.
[1]: http://www.ddj.com/cpp/184... |
[This article][1] seems like it would fit what you want. You'll need to change the saving imagejpeg() function to imagepng() and have it save the file to a string rather than output it to the page, but other than that it should be easy copy/paste into your existing code.
[1]: http://www.phpit.net/article/image-... |
Authenticate on an ASP.Net Forms Authorization website from a console app |
|c#|asp.net|authentication| |
I'm trying to build a C# console application to automate grabbing certain files from our website, mostly to save myself clicks and - frankly - just to have done it. But I've hit a snag that for which I've been unable to find a working solution.
The website I'm trying to which I'm trying to connect uses ASP.Net form... |
Is GD absolutely required? [ImageMagick][1] is faster, generates better images, is more configurable, and finally is (IMO) much easier to code for.
[1]: http://imagemagick.org/ |
I think [this page][1] is a good starting point. It uses imagecreatefrom(jpeg/gif/png) and resize and converts the image and then outputs to the browser. Instead of outputting the browser you could output to a BLOB in a DB without many minuttes of code-rewrite.
[1]: http://codecaine.co.za/posts/zend-image-class-... |
As for speeding up the IIS reset, Andrew Connell has some tips here as well
[http://www.andrewconnell.com/blog/archive/2006/08/21/3882.aspx
][1]
[1]: http://www.andrewconnell.com/blog/archive/2006/08/21/3882.aspx
This brought my IIS reset time from 10+ seconds down to less than 2 seconds.
|
|refactoring|url-rewriting| |
I'm sure you have all been there, you take on a project where there is a creaky old code base which is barely fit for purpose and you have to make the decision to either re-write it from scratch or repair what already exists.
Conventional wisdom tends to suggest that you should never attempt a re-write from scratc... |
I have a webpage about [rotary encoders and how to use them][1], which you might find useful.
Unfortunately without more information I can't troubleshoot your particular problem.
Which microcontroller pins are connected to the encoder, and what is the code you're currently using to decode the pulses?
-Adam Da... |
I have a webpage about [rotary encoders and how to use them][1], which you might find useful.
Unfortunately without more information I can't troubleshoot your particular problem.
Which microcontroller pins are connected to the encoder, and what is the code you're currently using to decode the pulses?
Ok, you'... |
You could simply put the elements in the set into a hash until you find a collision. In ruby, this is a one-liner.
def find_dupe(array)
h={}
array.detect { |e| h[e]||(h[e]=true; false) }
end
So, `find_dupe([1,2,3,4,5,1])` would return 1.
This is actually a common "trick" interview ques... |
There's a nice [apache commons lang](http://commons.apache.org/lang/) library which has a good api for common :) actions. You could use statically import StringUtils and use its method isNotEmpty(String ) to get:
while(isNotEmpty(line)) {
System.out.println(line);
line = br.readLine();
... |
For web developing I use the [Web Developer Toolbar](https://addons.mozilla.org/en-US/firefox/addon/60), [CSS Viewer](https://addons.mozilla.org/en-US/firefox/addon/2104) and [MeasureIt](https://addons.mozilla.org/en-US/firefox/addon/539).
But I'm really not one of those who has a thousand of extensions to do everyt... |
For web developing I use the [Web Developer Toolbar](https://addons.mozilla.org/en-US/firefox/addon/60), [CSS Viewer](https://addons.mozilla.org/en-US/firefox/addon/2104) <del>and [MeasureIt](https://addons.mozilla.org/en-US/firefox/addon/539).</del>
But I'm really not one of those who has a thousand of extensions t... |
There are many options and the best solution will depend on the nature of the problem you are trying to solve. If you are trying to solve an [embarassingly parallel][1] problem then dividing and parallelising the tasks will be trivial. In that case the challenge will come in distributing and managing the data used. ... |
I took a "lisp class" in college back in the eighties. Despite grokking all the concepts presented in the class, I was left without _any_ appreciation for what makes lisp great. I'm afraid that a lot of people look at lisp as just another programming language, which is what that course in college did for me so many ye... |
You don't need a "system" to do templating.
You can do it on your own by keeping presentation & logic separate.
This way the designer can screw up the display, but not the logic behind it.
Here's a simple example:
<?php
$people = array('derek','joel','jeff');
$people[0] = 'martin'; // all your lo... |
Convert an ruby string with brackets to an array |
|ruby|arrays| |
I would like to convert the following string into an array/nested array:
str = "[[this, is],[a, nested],[array]]"
newarray = # this is what I need help with!
newarray.inspect # => [['this','is'],['a','nested'],['array']] |
How do I convert a Ruby string with brackets to an array? |
Althoug the documentation is poor on this topic, I managed to get some working code by looking at the source. Although it is missing the xml header which normally contains important information. Here is a small example program that does what you are looking for using rapidxml:
#include <iostream>
#include <... |
[Here's a great thread][1] about serializing and deserializing objects in Silverlight 1.1.
As for a "best way," I'd say it would definitely be caching the xaml for the control and calling createFromXaml on it.
[1]: http://silverlight.net/forums/t/1730.aspx |
A more modern version of this is to use:
#pragma once
It is quite unusual to see this in a .c file, normally it is in the header files only. |
> So when you place the html link to the ugly domain name, assuming that it is the same PHP server (with the same sessions initialized), you can put it like this ...
> `www.myIsv.com/myWebSite/?PHPSESSID=<?=session_id()?>`
From a security point of view, I really really really hope that doesn't work |
Take a look at the oracle package DBMS_METADATA. In particular, the following methods are particularly useful: DBMS_METADATA.GET_DDL, DBMS_METADATA.SET_TRANSFORM_PARAM, DBMS_METADATA.GET_GRANTED_DDL. Once you are familiar with how they work (pretty self explanitory) you can write a simple script to dump the results o... |
Security advice for jquery ajax data post? |
|security|jquery|ajax|post| |
I'm using jquery ajax to post updates back to my server. I'm concerned about making sure I have put in place appropriate measures so that only my AJAX calls can post data.
My stack is PHP on Apache against a MySQL backend.
Advice greatly appreciated! |
[A blog post covering several of the alternatives][1], including [PyGame][2], [PyCap][3], [SpriteCraft][4], and [ika][5]. I have also seen [pyglet][6] mentioned.
You may also want to look at [Panda][7], which is a very easy to use 3D engine with Python bindings. It is used for rapid prototyping at [Carnegie Mellon's... |
It's not so black and white... it really depends on a lot of factors (the more important being "what does the person paying you want you to do")
Where I work we re-wrote a development framework, and on the other hand, we keep modifying some old systems that cannot be migrated (because of the client's technology and ... |
Refactor unless it is very bad indeed.
[Joel has a lot to say on this... ][1]
[1]: http://www.joelonsoftware.com/articles/fog0000000069.html
At the very least, rewrite the code with the old code in front of you and don't just start over from scratch. The old code may be terrible, but it is the way it i... |
Just clean up the code a little bit every time you work with it. If there isn't one already, setup a unit testing framework. All new code should get tests written. Any old code you fix as a result of bugs, try to slide in tests too.
As the cleanups progress, you'll be able to sweep more and more of the nasty code... |
Depends on how large/small/diverse the numbers are though. A radix sort might be applicable which would reduce the sorting time of the O(N log N) solution by a large degree. |
Just a small comment. Never ever go to the database direct. If there is no way to do it via published and supported API's, then there is no way to do it. End of story. This applies even to when you are "just reading data", as this can still cause significant issues. |
I don't understand... what do you mean by "having an MDF file in App_Data"? You need a proper SQL Server installation for that to work. You can always use the free SQL Server Express for developing the application, and then move the database to the proper SQL Server once you are done. Check [here][1].
[1]: http:... |
Some folks in our company do that with their external dependencies, and they get occasional build errors, usually because a library or header can't be retrieved. When they rebuild again it all works. Of course the speed and traffic-level of your network would have a major effect on this. |
There are data services that given a zip code will give you list of street names in that zip code.
Use a regex to extract Zip or City State - find the correct one or if a error get both.
pull the list of streets from a [data source][1] Correct the city and state, and then street address. Once you get a valid Addres... |
Select Query on 2 tables, on different database servers |
|sql|asp|vbscript|sybase| |
I am trying to generate a report by querying 2 databases (Sybase) in classic ASP.
I have created 2 connection strings:<br>
> connA for databaseA<br>
connB for databaseB
Both databases are present on the same server (don't know if this matters)<br>
Queries:
> q1 = SELECT column1 INTO #temp FROM databaseA..... |
Have you compared with the [SHA1CryptoServiceProvider.ComputeHash][1] method? It takes a byte array and returns a SHA1 hash, and I believe it's pretty well optimized. I used it in an [Identicon Handler][2] that performed pretty well under load.
[1]: http://msdn.microsoft.com/en-us/library/system.security.cryptog... |
Generally I prefer the former, as especially when the strings get long it can be much easier to read.
The other benefit is I believe one of performance, as the latter actually performs 2 string creation statements before passing the final string to the Console.Write method. String.Format uses a StringBuilder under t... |
Maybe not an advanced technique, but one I see all the time that drives me crazy:
if (x == 1)
{
x = 2;
}
else
{
x = 3;
}
can be condensed to:
x = (x==1) ? 2 : 3; |
Calling .NET Web Service (WSE 2/3, WS-Security) from Java |
|.net|java|ws-security|wse|apache-axis| |
You didn't say what OS you're using but on Linux I been using a tabbed window manager ([wmii][1]) for a year or so and it has radically changed the way I use applications - consoles or otherwise.
I often have four or more consoles and other apps on a virtual desktop and with wmii I don't have to fiddle with resizing... |
sudo gem install gemname
sudo gem update gemname |
Alignment restrictions for malloc()/free() |
|c|malloc| |
K&R (2nd ed.) and other C-language texts I have read that cover implementation of a dynamic memory allocator in the style of malloc() and free() usually also mention, in passing, something about alignment restrictions. Apparently certain platforms restrict how you can store and address certain values, requiring, for ex... |
> @John Topley: Thanks. Is there a
> similar command to update Ruby itself?
Not really. You don't say which operating system you're using. I use Mac OS X and tend to [build Ruby from source][1].
[1]: http://hivelogic.com/articles/2008/02/ruby-rails-leopard |
Alignment is still quite important today. Some processors (the 68k family jumps to mind) would throw an exception if you tried to access a word value on an odd boundary. Today, most processors will run two memory cycles to fetch an unaligned word, but this will definitely be slower than an aligned fetch. Some other pro... |
If you don't want to use an ORM you can also use reflection for things like this (though in this case because ProductID is not named the same on both sides, you couldn't do it in the simplistic fashion demonstrated here):
[List Provider in C#][1]
[1]: http://wiki.lessthandot.com/index.php/Generic_List_Provider_... |
How to set up a DB2 linked server on a 64-bit SQL Server 2005 |
|sql-server|sqlserver2005| |
I need to create a linked server to a DB2 database on a mainframe. Has anyone done this successfully on a 64-bit version of SQL Server 2005? If so, which provider and settings were used.
It's important that the linked server work whether we are using a windows authenticated account to login to SQL Server or a SQL S... |
|sql-server| |
|sql-server|db2| |
[This page][1] should get you started. You need to first make a request to the page, and then saving the cookie to a container that you include in all later request. That should keep you logged in, and able to retrieve the files.
Hope this helps
[1]: http://www.netomatix.com/development/httpwebrequestredirect.a... |
Here are a few links that might be helpful as an overview.
From my own experience, when I first started using MVC based web-frameworks the biggest issue I had was with the Models. Prying SQL out of my fingers and making me use Objects just felt strange. Once I started thinking of my data as Objects instead of SELE... |
If you want to use gdlib, use gdlib 2 or higher. It has a function called imagecopyresampled(), which will interpolate pixels while resizing and look much better.
Also, I've always heard noted around the net that storing images in the database is bad form:
- It's slower to access than the disk
- Your server ... |
Can you compile Apache HTTP Server and redeploy its binaries to a different location ? |
|unix|apache|httpserver| |
As others have stated, the best performance comes from the bottom one since you are just rethrowing an existing object. The middle one is least correct because it looses the stack.
I personally use custom exceptions if I want to decouple certain dependencies in code. For example, I have a method that loads data from... |
Looking around, it seems some people resolved this by repairing or reinstalling the .NET SDK. You might want to give that a try.
P.S. I see why you didn't include more of the compiler output, now. Not much to really see there. :) |
This could also be accomplished by joining the table with itself,
SELECT DISTINCT t1.name
FROM tbl t1
INNER JOIN tbl t2
ON t1.name = t2.name
WHERE t1.key != t2.key; |
I don't know if this will help, but from [this forum][1]:
> Add an .ico file to the application section of the properties page, and recieved the error thats been described, when I checked the Icon file with an icon editor, it turn out that the file had more than one version of the image ie (16 x 16, 24 x 24, 32 x 32... |
I'd recommend picking up a copy of [Digital Video Compression][1] - it's a really good overview of compression algorithms for images and video.
[1]: http://isbn.nu/9780071424875/price |
Can you sniff the traffic to find what's actually being sent? Is it sending any auth data at all and it's incorrect or being presented in a form the server doesn't like, or is it never being sent by firefox at all? |
Ah, this is killing me! I did this at work about 3 months ago, and now I can't remember all the details.
I do remember, however, that you need basicHttpBinding, and you can't use the new serializer (which is the default); you have to use the "old" XmlSerializer.
Unfortunately, I don't work at the place where I di... |
I need to call a web service written in .NET from Java. The web service implements the WS-Security stack (either WSE 2 or WSE 3, it's not clear from the information I have).
The information that I received from the service provider included WSDL, a policyCache.config file, some sample C# code, and a sample applic... |
For basic string concatenation, I generally use the second style - easier to read and simpler. However, if I am doing a more complicated string combination I usually opt for String.Format.
String.Format saves on lots of quotes and pluses...
Console.WriteLine("User {0} accessed {1} on {2}.", user.Name, file... |
Check out a book by [David Gries][1] called [The Science of Programming][2]. It's about proving the correctness of programs. If you want to be sure that your programs are correct (to the point of proving their correctness), this book is a good place to start.
Probably not exactly what you're looking for, but it's th... |
Based on the sample data:
1. I would start at the end of the string. Parse a Zip-code (either format). Read end to first space. If no Zip Code was found Error.
2. Trim the end then for spaces and special chars (commas)
3. Then move on to State, again use the Space as the delimiter. Maybe use a lookup list t... |
Concatenating strings is fine in a simple scenario like that - it is more complicated with anything more complicated than that, even LastName, FirstName. With the format you can see, at a glance, what the final structure of the string will be when reading the code, with concatenation it becomes almost impossible to imm... |
As part of our product release we ship Apache HTTP Server binaries that we have compiled on our (UNIX) development machine.
We tell our clients to install the binaries (on their UNIX servers) under the same directory structure that we compiled it under. For some clients this is not appropriate, e.g. where there are ... |
|apache|unix|httpserver| |
As part of our product release we ship Apache HTTP Server binaries that we have compiled on our (UNIX) development machine.
We tell our clients to install the binaries (on their UNIX servers) under the same directory structure that we compiled it under. For some clients this is not appropriate, e.g. where there are ... |
Take a look at the [Zend Framework][1], specifically Zend_Db. It has a Database Abstraction layer that doesn't require anything other than the MySQLi extension to be installed and isn't a full-blown ORM model.
[1]: http://framework.zend.com |