instruction stringlengths 0 30k ⌀ |
|---|
|apache|.htaccess|mod-rewrite| |
I want:
all links which not contained filename (not .html, .jpg, .png, .css) redirect with state 301 to directory, for example: http://mysite.com/article -> http://mysite.com/article/
But http://mysite.com/article/article-15.html not redirects.
What regulat expression I must write to .htaccess? |
|apache|mod-rewrite|.htaccess| |
I want:
all links which not contained filename (not .html, .jpg, .png, .css) redirect with state 301 to directory, for example: http://mysite.com/article -> http://mysite.com/article/
But http://mysite.com/article/article-15.html not redirects.
What regulat expression I must write to .htaccess for adding slash to vi... |
Is there an RTF display widget in SWT |
I believe you can use imp.find_module() and imp.load_module() to load the specified module. You'll need to split the module name off of the path, i.e. if you wanted to load "/home/mypath/mymodule.py" you'd need to do "imp.find_module('mymodule', '/home/mypath/')", but that should get the job done. |
With jQuery:
$j('a').each( findOffset );
function findOffset()
{
alert
( 'x=' + $j(this).offset().left
+ ' y=' + $j(this).offset().top
+ ' width=' + $j(this).width()
+ ' height=' + $j(this).height()
);
} |
Mathematica has a package "DatabaseLink" built in that should make this easy but you need to find a driver for Oracle. |
Mathematica has a package "DatabaseLink" built in that should make this easy but you need to find a driver for Oracle. Installing the "oracle client libraries" should do that... |
As an indirect answer to your question, here is how I do it without a named query.
var session = GetSession();
var criteria = session.CreateCriteria(typeof(Order))
.Add(Restrictions.Eq("Product", product))
.SetProjection(Projections.CountDistinct("Price"));
return (int) criteria.UniqueR... |
DataSet.Select and DateTime |
|c#|.net|dataset| |
How can I use .NET DataSet.Select method to search records that match a DateTime?
What format should I use to enter my dates in? |
You should be able to to speed up your `script/spec` calls by running `script/spec_server` in a separate terminal window, then adding the additional `-X` parameter to your spec calls. |
As already stated, this is bug [#201307][1]. The workaround is to disable smooth scrolling:
Edit -> Prefrences -> Advanced -> General tab -> uncheck "Use smooth scrolling"
[1]: https://bugzilla.mozilla.org/show_bug.cgi?id=201307 |
LINQ allows you to join two "tables" together, like so:
var query = from c in companies
join p in people on c equals p.Company into matching
select new { Company = c, Count = matching.Count() };
|
*(EDIT misunderstood the question, revising my answer to the following)*
Your LinqDataSource could point to a view, which allows you to overcome the problem of not being able to express a Join in the actual element. From ["How to: Create LINQ to SQL Classes Mapped to Tables and Views (O/R Designer)"][1]:
> The O/... |
The `stl` provides no such container. You can define your own, backed by either a `set/multiset` or a `vector`, but you are going to have to re-sort every time the sorting function changes by either calling `sort` (for a `vector`) or by creating a new collection (for `set/multiset`).
If you just want to change from ... |
Unix Proc Directory |
|unix|proc|current| |
I am trying to find the virtual file that contains the current users id. I was told that I could find it in the proc directory, but not quite sure which file. |
|linux|unix|proc| |
Bash can do this all on it's own, thank you very much. If you look at the section of the man page on **Parameter Expansion**, you'll see that that bash has built-in substitutions, substring, trim, rtrim, etc.
To eliminate all non-alphanumeric characters, do
CLEANSTRING=${STRING//[^a-zA-Z0-9]/}
**That's... |
I think you should move the repository interface over to the DataAccess assembly. Then DataAccess has no need to reference MessageManager anymore.
However, it remains hard to say since I know next to nothing about your architecture... |
You only have two choices: add an assembly to hold the interface or move the interface into the DataAccess assembly. Even if you're developing an architecture where the DataAccess class may someday be replaced by another implementor (even in another assembly) of the repository interface, there's no reason to exclude it... |
Pick a few times that you'd like to do it and offer them as choices to the decider-types. Whatever you do, put up a "down for routine maintenance" page while you deploy. |
* Check the time of least usage
* Clone/copy/update latest production code to another directory
* If there exists any database migrations to be done, perform any that are required, and non conflicting with the old code base
* At time of least usage, move symlink to point to latest code |
You should separate your interface out of either assembly. Putting the interface along with the consumer or the implementor defeats the purpose of having the interface.
The purpose of the interface is to allow you to inject any object that implements that interface, whether or not it's the same assembly that your Da... |
You could always use a list comprehension and check the results with all, it would be a little less resource intensive than using a regex: `all([c in string.letters + string.digits + ["_"] for c in mystring])` |
You could always use a list comprehension and check the results with all, it would be a little less resource intensive than using a regex: `all([c in string.letters + string.digits + ["_", "-"] for c in mystring])` |
var people = from p in Person
where p.age < 18
select p
Translates to:
SELECT [t0].[PersonId], [t0].[Age], [t0].[FirstName]
FROM [dbo].[Person] AS [t0]
WHERE [t0].[Age] < @p0
where @p0 gets sent through as 18
var otherPeople = from p in people
... |
If you open the "File Associations" page (Window -> Preferences -> General -> Editors -> File Associations) you should see a list of all file types which Eclipse recognises. Scroll down to the "*.xml" entry, highlight "Ant Editor" in the "Associated Editors" pane and hit the "Default" button on the right-hand side. Ecl... |
One of the great things about this question (and Python in general) is that you can just mess around in the interpreter! [Python 3.0 rc1 is currently available for download][1].
>>> import urllib.request
>>> fh = urllib.request.urlopen('http://www.python.org/')
>>> print(type(fh.read(100)))
<class... |
WebRequest and more specifically the HttpWebRequest class is a good starting point for what you want to achieve. To create the request you will use the WebRequest.Create and cast the created request to an HttpWebRequest to actually use it. You will then create your post data and send it to the stream like:
HttpW... |
A more friendly starting place, with links to just a select few of the other perlxxx pages, is [perldoc perlintro](http://perldoc.perl.org/perlintro.html). |
You can use the [CompiledTemplateBuilder][1] Class.
Here is an example:
<http://iridescence.no/post/Using-Templated-Controls-Programmatically.aspx>
[1]: http://msdn.microsoft.com/en-us/library/system.web.ui.compiledtemplatebuilder.aspx |
If you are trying to build .chm based help, try [**chm-build**][1]
[1]: http://sourceforge.net/projects/chm-build/ |
Just remembered: depending on what you want to do, you can use doxygen (www.doxygen.org) or the free help tool from http://www.vizacc.com/. |
You could try making a ping to the server and check the response.
Take a look at this [article][1].
[1]: http://classicasp.aspfaq.com/general/how-do-i-execute-a-ping-command-from-asp-and-retrieve-the-results.html |
You could take a look at [IIOP.NET][1], which addresses this issue.
[1]: http://www.codeproject.com/KB/cs/iiop_net_and_ejb.aspx |
If you're using DHCP then the server will give you a list of all that information.
This website has a good tutorial on using powershell to get networking information http://www.powershellpro.com/powershell-tutorial-introduction/powershell-scripting-with-wmi/
If you neet to get quick list of computer names you ca... |
This is a subjective question.
I would personally include all calculations within PHP and only really use MySQL as a table.
But, If you feel that it is easier to use stored procedures then by all means, go ahead and do it. |
If you're using Team Foundation Server for source control, you'll probably have to use a Web Application Project, as you need a .csproj file.
There are more details from Jeff Atwood himself: [Web Site Projects vs. Web Application Projects][1]
> Web Site web projects are particularly painful in Team System due to... |
scp as mentioned above is usually a best way, but don't forget colon in the remote directory spec otherwise you'll get copy of source directory on local machine. |
Check that there isn't a firewall that is ending the connection after certain period of time (this was the cause of a similar problem we had) |
There are more sites using PAC than, I think, people realize. For example, [drupal][1] uses the PAC pattern and there are a lot of sites (and a lot of big sites) built with drupal. Many people confuse [MVC][2] and [PAC][3]. [Larry Garfield does a good job explaining the difference and how drupal uses PAC][4].
In my ... |
I would recommend setting the parameter as a comma delimited string of values and use a Split function in SQL to turn that into a single column table of values and then you can use the IN feature.
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648 - Split Functions
|
As everyone else has noted, you are not allowed to extend String (due to final). However, if you are feeling really wild, you can modify String itself, place it in a jar, and prepend the bootclasspath with -Xbootclasspath/p:myString.jar to actually replace the built-in String class.
For reasons I won't go into, I'v... |
How to tie into a domain server's login for program access rights |
|c#| |
OK, this code worked
s = socket.socket()
s.connect((ip,port))
s.send("my request\r")
print s.recv(256)
s.close()
It was quite difficult to work that out from the Python socket module documentation. So I'll accept The.Anti.9's answer. |
I believe the [W3C validato][1]r does it, but maybe not to the extent you are looking for.
[1]: http://validator.w3.org/ |
Be careful how you're defining your keys there. While your example works, it might not always:
$myArr = array();
$myArr[A] = "a"; // "A" is assumed.
echo $myArr['A']; // "a" - this is expected.
define ('A', 'aye');
$myArr2 = array();
$myArr2[A] = "a"; // A is a constant
e... |
start_time = timer
function()
exec_time = timer - start_time |
Another common gotcha is thinking you can ignore the Form DragOver (or DragEnter) events. I typically use the Form's DragOver event to set the AllowedEffect, and then a specific control's DragDrop event to handle the dropped data. |
If you think of it in terms of template development, then it is wise to keep it in the view, and not in the code behind. What if if needs to change from a anchor to a list item with unobtrusive JS to handle a click? Yes, this is not the best example, rather just that, and example.
I always try to think in terms of i... |
Invoke it in a loop with a ton of invocations, then divide by the number of invocations to get the average time.
so:
// begin timing
for (int i = 0; i < 10000; i++) {
invokeFunction();
}
// end time
// divide by 10000 to get actual time. |
nickf, good to know, thanks. Unfortunately that has readability problems beyond a few commas. |
I always just use sc.exe (see <http://support.microsoft.com/kb/251192>). It should be installed on XP from SP1, and if it's not in your flavor of Vista, you can download load it with the Vista resource kit.
I haven't done anything too complicated with Java, but using either a fully qualified command line argument (... |
Depends on the compiler, but with gcc (for example, since that's the one you referred to), some of the standard (both C and POSIX) have builtin intrinsics. This means that the compiler library shipped with your compiler (libgcc in this case) contains an implementation of the function. The compiler will allow an impli... |
|c#|html|dom|diff| |
In <a href="http://stackoverflow.com/questions/48669/are-there-any-tools-out-there-to-compare-the-structure-of-2-web-pages">this post</a> I asked if there were any tools that compare the structure (not actual content) of 2 HTML pages. I ask because I receive HTML templates from our designers, and frequently miss minor ... |
If you are adding non-UI elements to the listbox (such as strings or non-UI data objects), then this is probably pretty difficult. However if you wrap your items in some sort of FrameworkElement-derived object before adding them to the listbox, you can use TransformToVisual to get the relative size and use Height and ... |
What you are looking for is MakeGenericType
string elementTypeName = Console.ReadLine();
Type elementType = Type.GetType(elementTypeName);
Type[] types = new Type[] { typeof(int) };
Type listType = typeof(List<>);
Type genericType = listType.MakeGenericType(types);
IProxy proxy = (IPr... |
What you are looking for is MakeGenericType
string elementTypeName = Console.ReadLine();
Type elementType = Type.GetType(elementTypeName);
Type[] types = new Type[] { elementType };
Type listType = typeof(List<>);
Type genericType = listType.MakeGenericType(types);
IProxy proxy = (IPr... |
|java|eclipse|swt|rtf| |
I would like to display an RTF document in an SWT (actually Eclipse RCP) application.
I know there is a Swing widget for displaying and editing RTF text, but it is Swing and quite alien in look and feel when used in the otherwise platform (not to mention that to the last of my knowledge it did not display images and... |
The smart ass answer is "by doing so" - unless you aren't working with multiple IDEs you don't know if you are really prepared for working with multiple IDEs. Honest. :)
I always have seen multiple platforms as more cumbersome, as they may use different encoding standards (e.g. Windows may default to ISO-8859-1, Lin... |
You could use StringBuilder instead of creating those three different strings. You can help it out by preallocating about how much memory you need to store your string. You could also use String.Format instead.
If this is all your submit button is doing why make it a .Net page at all and instead just have a GET form... |
[This page][1] has a complete backup script for a webserver, including the pg_dump output.
Here is the syntax it uses:
BACKUP="/backup/$NOW"
PFILE="$(hostname).$(date +'%T').pg.sql.gz"
PGSQLUSER="vivek"
PGDUMP="/usr/bin/pg_dump"
$PGDUMP -x -D -U${PGSQLUSER} | $GZIP -c > ${BACKUP}/${PFILE... |
>So, if I load say 20MB from MySQL, in the Task Manager the RAM for the application goes up by about 25MB. Then when I close the connection and try to dispose the ByteArray, the RAM never frees up. However, if I use System.totalMemory, flash player shows that the memory is being released, which is not the case.
>Is ... |
I need to write a program used internally where different users will have different abilities within the program.
Rather than making users have a new username and password, how do I tie into an existing domain server's login system?
Assume .NET (C#, VB, ASP, etc)
-Adam |
Have you tried truncating the table? |
How can I stop bursty writes to SD/USB stalling my time-critical apps on embedded Linux? |
|embedded|linux|filesystems|real-time|video| |
Bursty writes to SD/USB stalling my time-critical apps on embedded Linux |
|linux|embedded|video|filesystems|real-time| |
I'm working on an embedded Linux project that interfaces an ARM9 to a hardware video encoder chip, and writes the video out to SD card or USB stick. The software architecture involves a kernel driver that reads data into a pool of buffers, and a userland app that writes the data to a file on the mounted removable devic... |
I'm working on an embedded Linux project that interfaces an ARM9 to a hardware video encoder chip, and writes the video out to SD card or USB stick. The software architecture involves a kernel driver that reads data into a pool of buffers, and a userland app that writes the data to a file on the mounted removable devic... |
if ((object)uq1 == null)
return ((object)uq2 == null)
else if ((object)uq2 == null)
return false;
else
//return normal comparison
This compares them as equal when both are null. |
I had to alter your code a little:
var x = {"hdrs": ["Make","Model","Year"],
"data" : [
{"Make":"Honda","Model":"Accord","Year":"2008"},
{"Make":"Toyota","Model":"Corolla","Year":"2008"},
{"Make":"Honda","Model":"Pilot","Year":"2008"}]
};
alert( x.data[0].Make ); |
I had to alter your code a little:
var x = {"hdrs": ["Make","Model","Year"],
"data" : [
{"Make":"Honda","Model":"Accord","Year":"2008"},
{"Make":"Toyota","Model":"Corolla","Year":"2008"},
{"Make":"Honda","Model":"Pilot","Year":"2008"}]
};
alert( x.data[0].Make );
EDIT: ... |
I always used to use Roybot Assembler - which had you enter your program using the BASIC editor and REM statements. The Hisoft Gens and Mons assembler and disassembler are probably fairly popular.
For high-level compiling, the "Mira Modula-2" compiler is very good. |
I always used to use [Roybot Assembler][1] - which had you enter your program using the BASIC editor and REM statements. It comes with a decent debugger/disassembler that lets you single-step machine code too.
The Hisoft Gens and Mons assembler and disassembler (aka Devpak) are probably fairly popular.
For high-... |
[BITS][1] is a library from Microsoft for downloading files piece by piece using unused bandwidth. You can basically have your clients trickle-download the new video files. The problem, however, is that you'll have to update your program to utilize BITS first.
[1]: http://msdn.microsoft.com/en-us/library/aa36270... |
Can you run the program on the build machine under a debugger?
If so, then debug the problem - **there's no need to guess**.
Have the debugger on the dev machine catch the exception, set a break point at the same place on the build machine. See what's different between the two. |
How do you manage "pick lists" in a database. |
|database| |
I have an application with a number of "pick list" entities (used to populate single choice dropdown selection boxes). These entities need to be pulled from the database. How do I persist these entities in the database? Should I create a new table for each pick list? Is there a better solution? |
You can use the Kernel#Array method as well.
profiles = Array(AProfileResource.search(params))
output = profiles.collect do | profile |
profile.to_hash
end |
You can use the Kernel#Array method as well.
profiles = Array(ProfileResource.search(params))
output = profiles.collect do | profile |
profile.to_hash
end |
Is there a folder in both WinXP and WinVista to which all users have writing permissions? |
|windows|installation| |
We have a NET app that gets installed to the Program Files folder.
The app itself writes some files and creates some directories to its app folder.
But when a normal windows user tries to use our application it crashes because that user does not have permission to write to app folder.
Is there any folder in both Wi... |
ISO standards cost money, from a moderate amount (for a PDF version), to a bit more (for a book version).
While they aren't finalised however, they can usually be found online, as drafts. Most of the times the final version doesn't differ significantly from the last draft, so while not perfect, they'll suit just fin... |
The original dialog can't be modal if the user is supposed to interact with other elements—that's the definition of modal. Does the original dialog *really* need to be modal at all? If so, have you tried toggling the modal property of the original dialog before you open the other elements?
|
I agree with (and upvote) Robert Paulson's practice. That is assuming you are in control of a development team with the responsibility and discipline to adhere to such a practice.
To "force" that onto my teams, our solutions maintain at least one database project from **[Visual Studio Team Edition for Database Profe... |
If you're using DHCP then the server will give you a list of all that information.
This website has a good tutorial on using powershell to get networking information http://www.powershellpro.com/powershell-tutorial-introduction/powershell-scripting-with-wmi/
If you neet to get quick list of computer names you ca... |
If you're using DHCP then the server will give you a list of all that information.
This website has a good tutorial on using powershell to get networking information http://www.powershellpro.com/powershell-tutorial-introduction/powershell-scripting-with-wmi/
If you neet to get quick list of computer names you ca... |
Windows generally protects shares via two methods - permissions on the share itself, and then NTFS shares. Good practice would be to have the share permissions as "Authenticated User" and remove the "Everyone" group.
Personally I would make sure that usernames and passwords match up on each computer, and control pe... |