instruction stringlengths 0 30k ⌀ |
|---|
A lot of people would probably argue that the second option is "correct", because any value used more than once should be refactored into a constant. I would most likely use the first option. You have already gotten close to the "Code Complete" solution by encapsulating the dictionary entry in a strong typed property. ... |
What about Exif? It's probably not as secure as what you're thinking, but most users don't even know it exists and if you make it that easy to read the watermark information those who care will still be able to do it anyway. |
As per Coincoin's answer, this feature is also great for setting the default editor for ASPX. If you want to go to the Code Editor most often, then this is a default you'd want to change. |
Alternative Hostname for an IIS web site for internal access only |
|iis|sharepoint|moss| |
I'm using IIS in Windows 2003 Server for a SharePoint intranet. External incoming requests will be using the host header `portal.mycompany.com` and be forced to use SSL.
I was wondering if there's a way to set up an alternate host header such as `http://internalportal/` which only accepts requests from the internal ... |
|sharepoint|iis|moss|wss| |
What is the best way to create rounded corners using CSS? |
|css| |
What is the best way to create rounded corners using CSS? |
ImageMagick delegates the PDF->bitmap conversion to GhostScript anyway, so here's a command you can use (it's based on the actual command listed by the `ps:alpha` delegate in ImageMagick, just adjusted to use JPEG as output):
gs -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT \
-dMaxBitmap=500000000... |
ImageMagick delegates the PDF->bitmap conversion to GhostScript anyway, so here's a command you can use (it's based on the actual command listed by the `ps:alpha` delegate in ImageMagick, just adjusted to use JPEG as output):
gs -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT \
-dMaxBitmap=500000000... |
Have a look at [Sandcastle][1], which does exactly that. It's also one of the more simpler solutions out there, and it's more or less the tool of choice, so in the long run, maybe we could help you to set up Sandcastle if you specify what issues you encountered during setup?
[1]: http://blogs.msdn.com/sandcastle... |
Despite what the [MSDN article][1] says about User/Machine Hive, it doesn't write to HKEY_USERS. Rather it writes to HKCU if you select Just Me and HKLM if you select Everyone.
So my solution is going to be to use the User/Machine Hive, and then in the application it checks if the registry entries are in HKCU and i... |
Google Tech Talk: Linus Torvalds on git
<http://www.youtube.com/watch?v=4XpnKHJAok8>
The Git Wiki's comparison page
<http://git.or.cz/gitwiki/GitSvnComparsion> |
Git is not better than Subversion. But is also not worse. It's different.
The key difference is that it is decentralized. Imagine you are a developer on the road, you develop on your laptop and you want to have source control so that you can go back 3 hours.
With Subversion, you have a Problem: The SVN Repository... |
You'll need to compile with the target CPU set to x86 to force your code to use the 32 bit version of the VFP OLE Db provider. [Microsoft has stated][1] that there are no plans on releasing a 64-bit edition of the Visual FoxPro OLE Db provider. For what's worth, Microsoft has [also stated][2] that VFP 9 is the final ... |
Depends on the version, 4 is by value, 5 is by reference. |
Would you mind sharing which hosting environment you're using? It's common for a shared host to support Python and MySQL with the MySQLdb module (e.g., GoDaddy does this). Can you checked to see if that is installed?
Try the following CGI script to see if MySQLdb is installed.
#!/usr/bin/python
impor... |
So I'm working on a project that will allow users to enter poker hand histories from sites like PokerStars and then display the hand to them.
It seems that regex would be a great tool for this, however I rank my regex knowledge at "slim to none".
So I'm using PHP and looping through this block of text line by lin... |
|php|regex| |
We actually use a combination of NAnt and MSBuild with Cruise Control. NAnt is used for script flow control and calls MSBuild to compile projects. After the physical build is triggered, NAnt is used to publish the individual project build outputs to a shared location.
Not sure this is <i>the best</i> process. I t... |
We use MSBuild, because we started with VS2005 (now 2008), and MSBuild was already "built in" to the SDK - less maintenance on the build server. It's a nAnt clone, really. |
We use MSBuild, because we started with VS2005 (now 2008), and MSBuild was already "built in" to the SDK - less maintenance on the build server. It's a nAnt clone, really - both tools are infinitely flexible in that they let you create custom build tasks in code, and both have a decent set of community build tasks alr... |
I've used both and prefer nAnt. It's really hard for me to say one is "better" than the other. |
Look at the PCRE section in the PHP Manual. Also, http://www.regular-expressions.info/ is a great site for learning regex. Disclaimer: Regex is very addictive once you learn it. |
ADD:
LIMIT n,1
That will limit the results to one result starting at result n. |
You should only need to override the equals() method if you want specific behaviour when adding objects to sorted data structures (SortedSet etc.)
When you do that you should also override hashCode.
See [here][1] for a complete explanation.
[1]: http://www.geocities.com/technofundo/tech/java/equalhash.htm... |
I'm not entirely sure what exactly to use for that without trying it, but a great tool I use all the time to validate my RegEx is [RegExr][1] which gives a great flash interface for trying out your regex, including real time matching and a library of predefined snippets to use. Definitely a great time saver :)
... |
there is an [official][1] recommendation
and in [djangobook][2]
[1]: http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users
[2]: http://www.djangobook.com/en/1.0/chapter12/#cn222 |
One method you might want to consider if you're going to be working with the values a lot is to write them to a temporary table first. Then you just join on it like normal.
This way, you're only parsing once.
It's easiest to use one of the 'Split' UDFs, but so many people have posted examples of those, I... |
According to [ASP.NET AJAX in Action](http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2FASP-NET-AJAX-Action-Alessandro-Gallo%2Fdp%2F1933988142&tag=diaryofamadma-20&linkCode=ur2&camp=1789&creative=9325), p. 257
> Just before the old markup is replaced with the updated HTML, all the... |
I setup the gridview and then used the html text writer object to spit it out to a .xls file, like so:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'get the select command of the gridview
sqlGridview.SelectCommand = Session("strSql")
gvCo... |
To combine revision 3 and 4 into a single revision, you can use git rebase. If you want to remove the changes in revision 3, you need to use the edit command in the interactive rebase mode. If you want to combine the changes into a single revision, use squash.
I have successfully used this squash technique, but have... |
Possible in [CSS2][1] (@page, looks like [Opera only][2]) and in [CSS3][3] which will work [nowhere][4]. Sorry.
[1]: http://www.w3.org/TR/CSS2/page.html#page-size-prop
[2]: http://www.webdevout.net/browser-support-css#css2propsprint
[3]: http://www.w3.org/TR/css3-page/#page-size-prop
[4]: http://www.web... |
It means that rather than needing to push the instruction pointer on the stack, you can simply jump to the top of a recursive function and continue execution. This allows for functions to recurse indefinitely without overflowing the stack.
I wrote a [blog][1] post on the subject, which has graphical examples of wha... |
Have a look at Hibernate as a simpler way to interface to a database. |
If I were designing the next version of C#, I'd think about each function having an automatically included local variable holding the name of the class and the name of the function. If most instances, the compiler's optimizer would take it out.
I'm not sure there's much of a demand for that sort of thing though. |
If I were designing the next version of C#, I'd think about each function having an automatically included local variable holding the name of the class and the name of the function. In most cases, the compiler's optimizer would take it out.
I'm not sure there's much of a demand for that sort of thing though. |
Who is your web host?
This is just a guess, but it's common for a shared host to support Python and MySQL with the MySQLdb module (e.g., GoDaddy does this). Try the following CGI script to see if MySQLdb is installed.
#!/usr/bin/python
module_name = 'MySQLdb'
head = '''Content-Type: text/html
... |
I don't have any experience with <http://www.SiteGround.com> as a web host personally.
This is just a guess, but it's common for a shared host to support Python and MySQL with the MySQLdb module (e.g., GoDaddy does this). Try the following CGI script to see if MySQLdb is installed.
#!/usr/bin/python
... |
It's by value according to the [PHP Documentation][1].
> By default, function arguments are passed by value (so that if the value of the argument within the function is changed, it does not get changed outside of the function). To allow a function to modify its arguments, they must be passed by reference.
>
> To ... |
Git and DVCS in general is great for developers doing a lot of coding independently of each other because everyone has their own branch. If you need a change from someone else, though, she has to commit to her local repo and then she must push that changeset to you or you must pull it from her.
My own reasoning als... |
How do you debug PHP scripts? |
|php|debugging| |
How do you debug your PHP script?
I am aware of basic debugging such as using the Error Reporting. The breakpoint debugging in PHPEclipse is also quite useful. Any other good/better techniques out there? |
I've used the [Zend Studio (5.5)][1], together with [Zend Platform][2]. That gives proper debugging, breakpoints/stepping over the code etc., although at a price.
[1]: http://www.zend.com/products/studio/
[2]: http://www.zend.com/en/products/platform/ |
When you only use a magic string in one context, like you do, I think it's alright.
But if you ever need to use the key in another part of the class, go <code>const</code>. |
Hudson can't build my Maven 2 project because it says artifacts are missing from the repository? (they aren't) |
|continuous-integration|maven-2|hudson|mvn| |
I'm using Hudson and Maven 2 for my automated build/CI. I can build fine with maven from the command line, but when I run the same goal with Hudson, the build fails complaining of missing artifacts. I'm running Hudson as a windows XP service. |
Database sharding and Rails |
|database|ruby-on-rails|activerecord|sharding|shards| |
What's the best way to deal with a sharded database in Rails? Should the sharding be handled at the application layer, the active record layer, the database driver layer, a proxy layer, or something else altogether? What are the pros and cons of each? |
If you disable the text box (set `Enable=false`), the text in it is still scrollable and selectable. If you don't like the visual presentation of a disabled text box (gray background usually) you can manually override the colors.
Be warned, manually overriding colors is going to make your form/control look weird on ... |
Make sure you're running Hudson as the same user that you are using to run Maven from the command line. Maven creates a separate repository for each user. If you are running Hudson as a Windows service, this won't be the same user as you have logged on as and will be running "mvn" commands with. This means the artif... |
This page does a good job of addressing some of my questions: http://www.b-list.org/weblog/2006/sep/10/django-tips-laying-out-application/
Specifically:
> 1. To define custom template tags or filters, you must create a sub-directory in the application’s directory called templatetags, and it must contain a file... |
Your algorithm isn't quite clearly defined. If you have a complete graph, your algorithm would seem to entail, in the first step, removing all but the two minimum elements. Also, listing _all_ the cycles in a graph can take exponential time. |
Your algorithm isn't quite clearly defined. If you have a complete graph, your algorithm would seem to entail, in the first step, removing all but the two minimum elements. Also, listing _all_ the cycles in a graph can take exponential time.
Elaboration:
In a graph with n nodes and an edge between every pair of... |
Have you tried debugging into the framework source code? Maybe there are some comments in the HttpCachePolicy class with an explanation. Sounds like a bug to me though.
I agree with you. There is nothing in the HTTP Spec that should prevent Etag when cache-control is private.
I see where UpdateCachedHeaders wi... |
I think you need to use HttpCacheability.ServerAndPrivate
That should give you cache-control: private in the headers and let you set an ETag.
The documentation on that needs to be a bit better. |
I think you need to use HttpCacheability.ServerAndPrivate
That should give you cache-control: private in the headers and let you set an ETag.
The documentation on that needs to be a bit better.
**Edit:** Markus found that you also have call cache.SetOmitVaryStar(true) otherwise the cache will add the Vary: * h... |
I wouldn't consider SOAP legacy at all. REST vs. SOAP is really just the continuation of the debate of COM/CORBA vs. HTTP POST/GET etc. SOAP is nothing more than an updated version of the same principles defined with C and C (contracts, providers, consumers etc.). It's just that has appeared to SOAP succeed (at leas... |
For a laugh:
ary = eval("[[this, is],[a, nested],[array]]".gsub(/(\w+?)/, "'\\1'") )
=> [["this", "is"], ["a", "nested"], ["array"]]
Disclaimer: You definitely shouldn't do this as `eval` is a terrible idea, but it is fast and has the useful side effect of throwing an exception if your nested arrays ar... |
Where does "Change Management" end and "Project Failure" begin? |
|project-management|project-failure|change-management| |
I got into a mini-argument with my boss recently regarding "project failure." After three years, our project to migrate a codebase to a new platform (a project I was on for 1.5 years, but my team lead was on for only a few months) went live. He, along with senior management of both my company and the client (I'm one of... |
I got into a mini-argument with my boss recently regarding "project failure." After three years, our project to migrate a codebase to a new platform (a project I was on for 1.5 years, but my team lead was on for only a few months) went live. He, along with senior management of both my company and the client (I'm one of... |
I follow the article at [http://dev.piwik.org/trac/wiki/HowToSetupDevelopmentEnvironmentWindows][1] to setup an Eclipse environment that has debugging features like you mentioned. The ability to step into the code is a much better way to debug then the old method of var_dump and print at various points to see where you... |
print_r( debug_backtrace() );
or something like that :-) |
It's all about the ease of use/steps required to do something.
If I'm developing a single project on my PC/laptop, git is better, because it is far easier to set up and use.
You don't need a server, and you don't need to keep typing repository URL's in when you do merges.
If it were just 2 people, I'd say g... |
If you have the ability to use WScript.Shell then you can just execute pscp.exe from the [Putty][1] package. Obviously this is less then ideal but it will get the job done and let you use SCP/SFTP in classic ASP.
[1]: http://www.chiark.greenend.org.uk/~sgtatham/putty/ |
I am by no means authoritative, but I believe the only supported path is from 6.5 to 7. Certainly that would be the most sane route, then I believe you can migrate from 7 directly to 2005 pretty painlessly.
As for scripting out all the objects - I would advise against it as you will inevitably miss something (unless... |
<http://www.php.net/manual/en/migration5.oop.php>
> In PHP 5 there is a new Object Model. PHP's handling of objects has been completely rewritten, allowing for better performance and more features. In previous versions of PHP, objects were handled like primitive types (for instance integers and strings). The drawbac... |
Variables containing primitive types are passed by value in PHP5. Variables containing objects are passed by reference. There's quite an interesting article from Linux Journal from 2006 which mentions this and other OO differences between 4 and 5.
<http://www.linuxjournal.com/article/9170> |
I worked on a project for my previous employer that used .NET, and there was a built in .resx format we used. We basically had a file that had all translations in the .resx file, and then multiple files with different translations. The consequence of this is that you have to be very diligent about ensuring that all s... |
I have found mootools to be pretty slick for animations, just a little smoother than JQuery.
Generally prefer JQuery, which I find to be a little more intuitive (in my head anyway), but would go mootools if slick animation is your biggest requirement. |
I suppose how successful the project is depends on who the client is. If the client were the company directors and they are happy, then the project was successful regardless of the failures along the way. |
XStream from codehaus.org
XML serialization/deserialization largely without coding.
You can use annotations to tweak it.
Working well in two projects where I work.
See my users group presentation at [http://cjugaustralia.org/?p=61][1]
[1]: http://cjugaustralia.org/?p=61 |
I would go for the your final option JavaDB (Sun's distribution of [Derby][1]) and use an object relational layer like [Hibernate][2] or [iBatis][3]. Using the first three aproaches means you are going to spend more time building a database engine than developing application features.
[1]: http://db.apache.org/d... |
EXEC sp_helplogins
You can also pass an "@LoginNamePattern" parameter to get information about a specific login:
EXEC sp_helplogins @LoginNamePattern='fred' |
I have found that Indy, while a simpler concept in the beginning, is awkward to manage due to the need to kill sockets to free threads at application termination. In addition, I had the Indy library stop working after an OS patch upgrade. ScktComp works well for my application. |
Select * From Master..SysUsers Where IsSqlUser = 1 |
Environment.NewLine
for system independant newlines. |
@allain, @GateKiller your query selects users not logins
To select logins you can use this query:
SELECT name FROM master..sysxlogins WHERE sid IS NOT NULL
In MSSQL2005/2008 syslogins table is used insted of sysxlogins |
Have a look in the syslogins or sysusers tables in the master schema. Not sure if this still still around in more recent MSSQL versions though. In MSSQL 2005 there are views called sys.syslogins and sys.sysusers. |
Selecting from sysusers will get you information about *users* on the selected database, not *logins* on the server. |
@DrPizza Profiling only really helps improve an implementation, it doesn't reveal opportunities for parallel execution, or suggest better algorithms (unless you've experience to the otherwise, in which case I'd really like to see your profiler).
I've only single core machines at home, but ran a Java equivalent of yo... |
Consistency, convenience and readability. "UINT32" is much more readable and writeable than "unsigned long long", which is the equivalent for some systems.
Also, the compiler and processor may be fixed for the life of a project, but the code from that project may find new life in another project. In this case, havin... |
It depends.
If I am genuinely hacking something up for my own use then I will write the best code that I don't have to think about. Let the compiler be my friend for warnings etc. but I won't automatically create types for the hell of it.
The more likely the code is to be used, even occasionally, I ramp up the l... |
Is the C# static constructor thread safe? |
|c#|multithreading|singleton| |
In other words, is this Singleton implementation thread safe:
public class Singleton
{
private static Singleton instance;
private Singleton() { }
static Singleton()
{
instance = new Singleton();
}
public static Singleton Instance
... |
I'll take a different definition of defensive programming, as the one that's advocated by _[Effective Java](http://java.sun.com/docs/books/effective/)_ by Josh Bloch. In the book, he talks about how to handle mutable objects that callers pass to your code (e.g., in setters), and mutable objects that you pass to callers... |
I don't know if you can say that there is any one technique that is "the best". Below are a whole bunch of different approaches. Find one that suits your site and coding style, and go with it.
1. [CSS Design: Creating Custom Corners
& Borders][1]
2. [CSS Rounded Corners 'Roundup'][2]
3. [25 Rounded Corners... |
I looked at this early on in the creation of Stack Overflow and couldn't find *any* method of creating rounded corners that didn't leave me feeling like I just walked through a sewer.
[CSS3 does finally define](http://24ways.org/2006/rounded-corner-boxes-the-css3-way) the
border-radius:
Which is exactly h... |
Publishing Flash video |
|flash|video|webcam| |
What options do I have to publish Flash video from webcams other than Adobe's Media Server and Red5? I would prefer a solution in .NET, Python or PHP but can't find anything.
|
What options do I have to publish Flash video from webcams other than Adobe's Flash Media Server and Red5? I would prefer a solution in .NET, Python or PHP but can't find anything.
|