instruction stringlengths 0 30k ⌀ |
|---|
|asp.net-mvc| |
I'd like to have dashes separate words in my URLs. So instead of:
/MyController/MyAction
I'd like:
/My-Controller/My-Action
Is this possible? |
I'm trying to make that same decision about ASP.NET MVC, [Juan Manuel][1]. I'm now waiting for the right bite-sized project to come along with which I can experiment. If the experiment goes well--my gut says it will--then I'm going to architect my new large projects around the framework.
[1]: http://stackoverf... |
I'm trying to make that same decision about ASP.NET MVC, [Juan Manuel][1]. I'm now waiting for the right bite-sized project to come along with which I can experiment. If the experiment goes well--my gut says it will--then I'm going to architect my new large projects around the framework.
With ASP.NET MVC you lose ... |
A subselect is the standard way of doing this sort of thing. You just need a Unique Constraint on UserId, Code, and Date - and then you can run the following:
SELECT *
FROM Table
JOIN (
SELECT UserId, Code, MAX(Date) as LastDate
FROM Table
GROUP BY UserId, Code
) as Latest... |
On Mac OS X, I have used BBEdit since the early 1990's, so I use that as my reference for all other editors. I sometimes use BBEdit to edit files on a Linux box using ftp mode, and that works very well if you have a fast network connection to the Linux box.
I learned emacs two years ago because the rest of the progr... |
I use this code.It is VB code but you can easily translate it to C#. It works
Function NumberToText(ByVal n As Integer) As String
Select Case n
Case 0
Return ""
Case 1 To 19
Dim arr() As String = {"One","Two","Three","Four","Five","Six","Seven", _
"Eight","Nine","Ten","Eleven","Twelve"... |
+1 for XML Spy, I've used both the stand alone product and the visual studio plugin, and I've been impressed.
In terms of FOSS, try [Notepad++](http://notepad-plus.sourceforge.net/uk/site.htm) |
+1 for XML Spy, I've used both the stand alone product and the visual studio plugin, and I've been impressed.
In terms of FOSS, I use [Notepad++](http://notepad-plus.sourceforge.net/uk/site.htm) |
Peak detection of measured signal |
|language-agnostic|algorithm|data| |
We use a data acquisition card to take readings from a device that increases its signal to a peak and then falls back to near the original value. To find the peak value we currently search the array for the highest reading and use the index to determine the timing of the peak value which is used in our calculations.
... |
you could achive this in one query using 'UNION ALL' in MySQL.
Just loop through the tokens in PHP creating a UNION ALL for each token:
e.g if the tokens are 'x', 'y' and 'z' your query may look something like this
SELECT * FROM `entries` WHERE token like "%x%" union all SELECT * FROM `entries` WHERE token lik... |
What version of Tomcat are you using? To me this sounds like a bug in Tomcat, I can't think of any reason why you're doFilter method should be called with a response that's already been committed (if that filter is the only one in the chain, are you sure about this?). |
What version of Tomcat are you using? To me this sounds like a bug in Tomcat, I can't think of any reason why your doFilter method should be called with a response that's already been committed (if that filter is the only one in the chain, are you sure about this?). |
User Authentication in Pylons + AuthKit |
|python|authentication|pylons|sqlalchemy|authkit| |
I am trying to create a web application using Pylons and the resources on the web point to the [PylonsBook][1] page which isn't of much help. I want authentication and authorisation and is there anyway to setup Authkit to work easily with Pylons?
I tried downloading the [SimpleSiteTemplate][2] from the cheeseshop bu... |
It just depends on what type of testing you are doing. If you are doing behavior based testing you might want a dynamic mock so you can verify that some interaction with your dependancy occurs. But if you are doing state based testing you might want a stub so you verify values/etc |
It just depends on what type of testing you are doing. If you are doing behavior based testing you might want a dynamic mock so you can verify that some interaction with your dependancy occurs. But if you are doing state based testing you might want a stub so you verify values/etc
For example, in the below test yo... |
I really like python, it's usually my language of choice these days for small (non-gui) stuff that I do on my own.
However, for some larger Python projects I've tackled, I'm finding that it's not quite the same as programming in say, C++. I was working on a language parser, and needed to represent an AST in Python. ... |
Gnome apps work on KDE desktops and vice versa; you won't be locking anyone out. As far as toolkits go, it's fairly subjective. All of the toolkits are fairly cross-platform. If you're not open source, then GTK+ would be the cheaper option, as Qt is only free for open source use, whereas GTK+ is LGPL. |
How about a plugin for <a href="http://www.beagle-project.org/">Beagle</a> ?
It already searches PDFs but you can add other file types.
Here is the relevant wikipedia page : http://en.wikipedia.org/wiki/Beagle_(software) |
How to embed user-specific data in .NET windows setup app at setup download time? |
|.net|windows|installation|fogbugz| |
I'd like to have a link in my ASP.NET web site that authenticated users click to download a windows app that is already pre-configured with their client ID and some site config data. My goal is no typing required for the user during the client app install, both for the user friendliness, and to avoid config errors fro... |
If it helps RegexBuddy does this also. |
+1 on the Clbuttic mistake, I think it is important for "bad word" filters to scan for both leading and trailing spaces (e.g., " ass ") as opposed for just the exact string so that we won't have words like clbuttic, clbuttes, buttert, buttess, etc. |
You'll find mostly two answers to that – the religous one (Yes! Of course! It's the best language ever!) and the other religious one (you gotta be kidding me! Python? No... it's not mature enough). I will maybe skip the last religion (Python?! Use Ruby!). The truth, as always, is far from obvious.
**Pros**: i... |
I found that example through my Google searches too and did play with it. That wasn't the problem.
I found my bug. No one would have been able to solve the problem. It turns out that right before I test my bounds I had centered my map with bad data. I did something like the lngSpan = northEast.lng() - southWest.lng(... |
I found very insightful ideas about starting a new large project, based on
- common good practices
- Test Driven Development
- and pragmatic approach
in the book [Growing Object-Oriented Software, Guided by Tests][1].
It is still under development, but first 3 chapters may be what You are looking for... |
I have used [Komodo][1] and it's pretty good. I use textmate now.
[1]: http://www.activestate.com/Products/komodo_ide/index.mhtml "Komodo" |
Have you tried [Aptana][1]? Its based on Eclipse and they have a sweet [Rails][2] plugin.
[1]: http://www.aptana.com/
[2]: http://www.aptana.com/rails |
Powershell FINDSTR eqivalent? |
|powershell|searching| |
What's the DOS FINDSTR eqivalent for powershell? I need to search a bunch of log files for "ERROR" |
|search|powershell| |
Placement new itself is portable, but the assumptions you make about what it does with a specified block of memory are not portable. Like what was said before, if you were a compiler and were given a chunk of memory, how would you know how to allocate an array and properly destruct each element if all you had was a poi... |
How do you do a case insensitive search using a pattern modifier using less ? |
|unix|searching| |
It seems like the only way to do this is to pass the -i parameter in when you initially run less. Does anyone know of some secret hack to make something like this work
/something to search for/i
? |
It seems like the only way to do this is to pass the -i parameter in when you initially run less. Does anyone know of some secret hack to make something like this work
/something to search for/i
?
**Edit:** Wow how did I miss -i while less is running? Doh! |
Which file are you calling the getcwd() in and is that file is included into the one you are running (e.g. running index.php, including startup.php which contains gwtcwd()).
Is the file you are running in /dev-windows/ or /dev-windows-data/? It works on the file you are actually running.
---
Here's an example of... |
I use tables in two cases:
1) Tabular data
2) Any time I want my layout to dynamically size itself to its contents |
How to store Application Messages for a .NET Website |
|vb.net|website|storage| |
I am looking for a method of storing Application Messages, such as
* "You have logged in successfully"
* "An error has occurred, please call the helpdesk on x100"
* "You do not have the authority to reset all system passwords" etc
So that "when" the users decide they don't like the wording of messages I don't h... |
You could have an invisible div that gets shown via JavaScript when the page loads. |
- Put the strings in an xml file and use a filewatcher to check for updates to the file
- Put the strings in a database, cache them and set a reasonable expiration policy |
In your Web.config, under appSettings, change it to:
<appSettings file="StringKeys.config">
Then, create your StringKeys.config file and have all your keys in it.
You can still use the AppSettings area in the main web.config for any real application related keys.
|
[Alex's article][1] springs to mind here, however it's only applicable if you're using ASP.NET - it could be emulated in JavaScript however but again you'd have to use document.write();
[1]: http://weblogs.asp.net/alex_papadimoulis/archive/2008/02/21/scriptonly-the-opposite-of-a-noscript.aspx |
How can you test to see if two arrays are the same using CFML? |
|cfml| |
Using CFML (ColdFusion Markup Langauge, aka ColdFusion), how can you compare if two single dimension arrays are the same? |
|coldfusion| |
The primary reason stateless session beans are single threaded is to make them highly scalable for the container. The container can make a lot of simplifying assumptions about the runtime environment. A second reason is to make life easier for the developer because the developer doesn't have to worry about any synchro... |
This is the version we use here. It works, and its fairly simple. Its the same idea as Jeff's but I think its a little clearer because it separates out the logic for subtracting one, so its a little easier to understand.
public static int GetAge(this DateTime dateOfBirth, DateTime dateAsAt)
{
return dateAsAt.Y... |
Some solutions I have seen involve adding a version number to the end of the file in the form of a query string.
<script type="text/javascript" src="funkycode.js?v1">
Could could use the SVN revision number to automate this for you: [http://stackoverflow.com/questions/2308/aspnet-display-svn-revision-number][... |
Some solutions I have seen involve adding a version number to the end of the file in the form of a query string.
<script type="text/javascript" src="funkycode.js?v1">
You could use the SVN revision number to automate this [for you][1] by including the word **LastChangedRevision** in your html file after where... |
The Stack Overflow podcast is the reason I'm now here. Jeff, unfortunately, is a poor project manager in terms of managing expectations and setting timelines -- yet the beta has arrived, and it's pretty decent! The .NET world is alien to me, so I've enjoyed the Stack Overflow podcast.
This Week in Tech is another po... |
.htaccess directives to *not* redirect certain URLs |
|.htaccess|apache|mod-rewrite| |
In an application that heavily relies on .htaccess RewriteRules for its PrettyURLs (CakePHP in my case), how do I correctly set up directives to exclude certain directories from this rewriting? I.e.:
/appRoot/.htaccess
app/
static/
By default every request to /appRoot/* is being re... |
.NET - Throwing Exceptions best practices |
|.net|error-handling| |
What are the best practices to consider when catching exceptions, and re-throwing them. I want to make sure that the Exception object's InnerException and stack trace are preserved. Is there a difference between the following code blocks in how they handle this?
try
{
//some code
}
catch ... |
|c#|.net|error-handling| |
I would definitely use:
try
{
//some code
}
catch
{
throw;
}
That will preserve your stack. |
AT&T's [Synaptic Hosting](http://arstechnica.com/news.ars/post/20080806-atampt-has-head-in-the-clouds-with-synaptic-hosting.html) allows this, though I'm sure you'll pay through the nose, as it's all "enterprise" an' shit.
|
[Easy Git][1] has a nice page comparing actual usage of [Git and SVN][2] which will give you an idea of what things Git can do (or do more easily) compared to SVN. (Technically, this is based on Easy Git, which is a lightweight wrapper on top of Git.)
[1]: http://www.gnome.org/~newren/eg/
[2]: http://www.gno... |
At a former job we had a cluster of web servers with an F5 load balancer in front of them. We had a very similar problem in that our applications allowed users to upload content which might include photo's and such. These were legacy applications and we did not want to edit them to use a database and a SAN solution w... |
I've run OSX under VMWare, and I can tell you with confidence that it is not an environment that you would find comfortable for developing applications in. It was barely (not really) usable for testing Mac specific browser bugs that couldn't be reproduced in Safari on Windows.
On the other hand, if your hardware is... |
You're spoilt for choice in terms of options here. If you are using Sybase or SQL Server 2008 you can create variables of type date and assign them your datetime values. The database engine gets rid of the time for you. Here's a quick and dirty test to illustrate (Code is in Sybase dialect):
declare @date1 date
... |
Does the information need to be secure? If not, ClickOnce can use URL-based parameters. [Here's an article about that on MSDN][1].
[1]: http://msdn.microsoft.com/en-us/library/ms172242.aspx |
Have you thought of using Mono? Programs like Paint.NET work great under Linux & Windows. |
I recommend <a href="http://www.wxwidgets.org/">wxWidgets</a> or <a href="http://www.trolltech.no/">Qt</a>. They are both mature, well-structured and cross-platform, with decent documentation and sample source code. |
How Do Sites Supress Pasting Text? |
|javascript|onlinebanking|web-applications| |
I've noticed that some sites (usually banks) supress the ability to paste text into text fields. How is this done? I know that JavaScript can be used to swallow the keyboard shortcut for paste, but what about the right-click menu item? |
|javascript|web-applications|onlinebanking| |
How Do Sites Suppress Pasting Text? |
I've noticed that some sites (usually banks) suppress the ability to paste text into text fields. How is this done? I know that JavaScript can be used to swallow the keyboard shortcut for paste, but what about the right-click menu item? |
There are [Unicode box drawing characters](http://www.unicode.org/charts/symbols.html) (look for Box Drawing under Geometrical Symbols - the [chart itself](http://www.unicode.org/charts/PDF/U2500.pdf) is a PDF). I don't have any idea how widely supported those characters are, though. |
Rather than port the GUI code from whatever it is now to GTK or Qt, your best bet may be to port it to a cross-platform widget library such as [wxWidgets](http://en.wikipedia.org/wiki/WxWidgets), which would give you portability to any platform wxWidgets supports.
It's also important to make the distinction between ... |
Your best bet may be to port it to a cross-platform widget library such as [wxWidgets](http://en.wikipedia.org/wiki/WxWidgets), which would give you portability to any platform wxWidgets supports.
It's also important to make the distinction between Gnome libraries and GTK, and likewise KDE libraries and Qt. If you w... |
XML serialization in Java? |
|java|xml|serialization| |
Here's my split button implementation. It does not draw the arrow, and the focus/unfocus behavior is a little different.
Both mine and the originals handle visual styles and look great with Aero.
**Based on [http://wyday.com/blog/csharp-splitbutton][1]**
using System;
using System.Collections.Generic... |
You can do model-view-controller or model-view-presenter type architectures without using a full blown framework. You already found out that unit-testing ui-components is difficult. There are ways around that but you probably don't want to go that route. Usually this will make your tests very hard to maintain, more mai... |
OK, I found through Google the same page that Lars mentioned, and I believe it's a great explanation for people that don't quite know how memory works (like me).
http://shsc.info/WindowsMemoryManagement
My short conclusion was:
- Private Bytes = The Memory my process has requested to store data. Some of it ma... |
You're going from classic ASP to ASP with 3.5 without just re-writing? Skillz. I've had to deal with some legacy ASP @work and I think it's just easier to parse it and re-write it. |
The MVC framework mentioned above is the best way to test what the control does. However testing how it works is a bit different.
This is totally off the cuff but you could make the user control expose some protected methods and properties to return validation information and then have a testing user control inheri... |
Use namespaces to make a collection of functions:
namespace Console {
void WriteLine(...) // ...
}
As for memory, functions use the same amount outside a function, as a static member function or in a namespace. That is: no memory other that the code itself. |
> After I have everything coded I'll do a few passes at refactoring/testing. I'm just wondering if anyone has any tips on how to make this process a little easier/more efficient.

Normally I'm not a fan of TDD, but in the case of refactoring it rea... |
It just depends on what type of testing you are doing. If you are doing behavior based testing you might want a dynamic mock so you can verify that some interaction with your dependancy occurs. But if you are doing state based testing you might want a stub so you verify values/etc
For example, in the below test yo... |
From the simple test I have tried, aku is right, dispose is called as soon as the foreach block exit.
@David : However the object state is kept during the iteration, so the connection would not be closed.
Here is a simple program I tried to test the behavior...
class Program
{
static void M... |
From the simple test I have tried, aku is right, dispose is called as soon as the foreach block exit.
@David : However call stack is kept between call, so the connection would not be closed because on the next call we would return to the next instruction after the yield, which is the while block.
My understandi... |
|apache|mod-rewrite|.htaccess| |
In an application that heavily relies on .htaccess RewriteRules for its PrettyURLs (CakePHP in my case), how do I correctly set up directives to exclude certain directories from this rewriting? I.e.:
/appRoot/.htaccess
app/
static/
By default every request to /appRoot/* is being re... |
Remove the [L] from the previous rules:
RewriteBase /appRoot
RewriteRule ^$ app/webroot/
RewriteRule (.*) app/webroot/$1
[L] means "Stop the rewriting process here and don't apply any more rewriting rules." |