instruction
stringlengths 0
30k
⌀ |
---|
Here is a simple static method to do this in C#:
public static string ToTitleCaseInvariant(string targetString)
{
return System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(targetString);
} |
In what language?
In PHP it is:
[ucwords()][1]
example:
$HelloWorld = ucwords('hello world');
[1]: http://us2.php.net/manual/en/function.ucwords.php |
What I was thinking of can be achieved using list comprehensions, but I thought that there was a function that did this in a slightly neater way.
i.e. 'bar' is a list of objects, all of which have the attribute 'id'
The mythical functional way:
<pre><code>foo = 12
foo in iter_attr(bar, 'id')</code></pre>
The list comprehension way:
<pre><code>foo = 12
foo in [obj.id for obj in bar]</code></pre>
In retrospect the list comprehension way is pretty neat anyway. |
Without using a ready-made function, a super-simple low-level algorithm to convert a string to title case:
<pre><code>
convert first character to uppercase.
for each character in string,
if the previous character is whitespace,
convert character to uppercase.
</pre></code>
This asssumes the "convert character to uppercase" will do that correctly regardless of whether or not the character is case-sensitive (e.g., '+'). |
Get a new object instance from a Type in C# |
|c#|.net|reflection| |
One may not always know the Type of an object at compile-time, but may need to create an instance of the Type. How do you get a new object instance from a Type? |
Lucene Score results |
|lucene| |
In Lucence why does the same search on diffrent partitions return results with different scores? The results from the differnt servers match exactly. |
In Lucence if you had an multiple indexes that covered only one partition each. Why does the same search on different indexes return results with different scores? The results from the different servers match exactly. i.E If I searched for:
- Name - John Smith
- DOB - 11/11/1934
Partition 0 would return a score of 0.345
Partition 1 would return a score of 0.337
Both matched exactly on the name and dob. |
In Lucence if you had an multiple indexes that covered only one partition each. Why does the same search on different indexes return results with different scores? The results from the different servers match exactly. i.e If I searched for:
- Name - John Smith
- DOB - 11/11/1934
Partition 0 would return a score of 0.345
Partition 1 would return a score of 0.337
Both matched exactly on the name and dob. |
Use a normalised colour histogram. (Read the section on applications [here](http://en.wikipedia.org/wiki/Color_histogram)), they are commonly used in image retrieval/matching systems and are a standard way of matching images that is very reliable, relatively fast and very easy to implement.
Essentially a colour histogram will capture the colour distribution of the image. This can then be compared with another image to see if the colour distributions match.
This type of matching is pretty resiliant to scaling (once the histogram is normalised), and rotation/shifting/movement etc.
Avoid pixel-by-pixel comparisons as if the image is rotated/shifted slightly it may lead to a large difference being reported.
Histograms would be straightforward to generate yourself (assuming you can get access to pixel values), but if you don't feel like it, the [OpenCV](http://en.wikipedia.org/wiki/OpenCV) library is a great resource for doing this kind of stuff. [Here](http://vast.uccs.edu/~tboult/CS330/NOTES/OpenCVTutorial_II.ppt) is a powerpoint presentation that shows you how to create a histogram using OpenCV.
|
Should you run one or multiple applications per tomcat cluster? |
|tomcat|6|cluster-analysis| |
Currently I am setting up an application that can deploy other web apps to Tomcat 6 clusters. It is set up right now to have a one to one relationship between deployed web application and a cluster. My current reasoning for this is so that I can change the JVM args of the Tomcat server without disrupting other applications and so that the memory usage of the single application will not conflict with other applications.
The question is, what is considered best practice in terms of tomcat instance clusters? Should you only have one application running per cluster or multiple applications like in a single tomcat instance environment? Or does this depend on the size of your application?
Thank you |
|tomcat|cluster-analysis| |
How do you use **ssh** in a shell script? |
|ssh|shell|ksh|bash|rsh| |
**Warning**: I'm going to answer my own question in a minute or two. I just answered this question for a co-worker.
When I try to use an **ssh** command in a shell script, the command just sits there. Do you have an example of how to use **ssh** in a shell script? |
How do you use ssh in a shell script? |
When I try to use an **ssh** command in a shell script, the command just sits there. Do you have an example of how to use **ssh** in a shell script? |
|bash|shell|ssh|ksh|rsh| |
How would you use Java to handle various XML documents? |
|java|xml|sax|stax| |
I'm looking for the best method to parse various XML documents using a Java application. I'm currently doing this with SAX and a custom content handler and it works great - zippy and stable.
I've decided to explore the option having the same program, that currently recieves a single format XML document, receive two additional XML document formats, with various XML element changes. I was hoping to just swap out the ContentHandler with an appropriate one based on the first "startElement" in the document... but, uh-duh, the ContentHandler is set and **then** the document is parsed!
... constructor ...
{
SAXParserFactory spf = SAXParserFactory.newInstance();
try {
SAXParser sp = spf.newSAXParser();
parser = sp.getXMLReader();
parser.setErrorHandler(new MyErrorHandler());
} catch (Exception e) {}
... parse StringBuffer ...
try {
parser.setContentHandler(pP);
parser.parse(new InputSource(new StringReader(xml.toString())));
return true;
} catch (IOException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
}
...
So, it doesn't appear that I can do this in the way I initially thought I could.
That being said, am I looking at this entirely wrong? What is the best method to parse multiple, discrete XML documents with the same XML handling code? [I tried to ask in a more general post earlier... but, I think I was being too vague][1]. For speed and efficiency purposes I never really looked at DOM because these XML documents are fairly large and the system receives about 1200 every few minutes. It's just a one way send of information
To make this question too long and add to my confusion; following is a mockup of some various XML documents that I would like to have a single SAX, StAX, or ?? parser cleanly deal with.
products.xml:
<products>
<product>
<id>1</id>
<name>Foo</name>
<product>
<id>2</id>
<name>bar</name>
</product>
</products>
stores.xml:
<stores>
<store>
<id>1</id>
<name>S1A</name>
<location>CA</location>
</store>
<store>
<id>2</id>
<name>A1S</name>
<location>NY</location>
</store>
</stores>
managers.xml:
<managers>
<manager>
<id>1</id>
<name>Fen</name>
<store>1</store>
</manager>
<manager>
<id>2</id>
<name>Diz</name>
<store>2</store>
</manager>
</managers>
[1]: http://stackoverflow.com/questions/23106/best-method-to-parse-various-custom-xml-documents-in-java |
|c++|winapi|usb|device|hid| |
[Mastering Regular Expressions][1], devotes the last 4 chapters to Java, PHP, Perl, and .Net. One chapter for each. From what I know the [pocket edition][2] contains just those final four chapters.
[1]: http://www.amazon.com/Mastering-Regular-Expressions-Jeffrey-Friedl/dp/0596528124/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1219432420&sr=8-1
[2]: http://www.amazon.com/Regular-Expression-Pocket-Reference-Expressions/dp/0596514271/ref=pd_bbs_2?ie=UTF8&s=books&qid=1219432420&sr=8-2 |
For my own future reference, I'll offer the [Regexp Syntax Summary][1] page which contrasts the syntax for `grep`, `egrep`, Emacs, Perl, Python, and Tcl. As expected, Perl supports the greatest variety of operators, but Python looks equally capable, if not more so.
[1]: http://www.greenend.org.uk/rjk/2002/06/regexp.html |
I think it's because it's a creator method (not sure if there's a better name). All it does is take what you give it and return a single string object. It doesn't operate on an existing object. If it was non-static, you would need a string to begin with. |
Because the Format method has nothing to do with a string's current value. The value of the string isn't used. It takes a string and returns one. |
I am no authority in JavaScript, and perhaps more of a dunce than the asker, but AFAIK, the difference is that the "javascript:" prefix is preferred/required in URI-contexts, where the argument may be as well a traditional HTTP URL as a JavaScript trigger.
So, my intuitive answer would be that, since onChange expects JavaScript, the "javascript:" prefix is redundant (if not downright erroneous). You can, however, write "javascript:myFunction(this)" in your address bar, and that function is run. Without the "javascript:", your browser would try to interpret "myFunction(this)" as a URL and tries to fetch the DNS info, browse to that server, etc... |
I don't know if the "javascript:" prefix means anything within the onevent attributes but I know they are annoying in anchor tags when trying to open the link in a new tab. The href should be used as a fall back and **never** to attach javascript to links. |
IE Securty Zone Issues |
|internet-explorer|security-zone|ntlm|jcifs|intranet| |
I'm developing a website which will be used in the corporate intranet which uses JCIFS and NTLM to automatically authenticate the users without asking them to log on. Everything seems to be working in IE 6, but some users are being prompted for their passwords in IE 7.
We've had some success by getting the users to change their Lonon option to "Automatic logon using current username and password" (Tools > Internet Options > Securty Tab > Select Local Intranet > Custom Level > All the way at the bottom User Authentication > Logon), but we are still having a few users who are getting username/password prompts.
Also, we've had some users report they can just click cancel when the prompt comes up and the page will come up correctly.
If anyone has any other suggestions, I'd greatly appreciate them. |
You could try to encode the image as base64 and reference it directly in an img tag within the email ( `<img src="data:image/png;base64[your encoded image here...]` ) but i think most email clients correlate this technique with spam. I think you're better off referencing hosted images or simply attaching it to the email.
|
In case anyone is interested, a co-worker replied to this question to me via email:
Artem wrote:
There is a flag to MiniDumpWriteDump() that can do better crash dumps that will allow seeing full program state, with all global variables, etc. As for call stacks, I doubt they can be better because of optimizations... unless you turn (maybe some) optimizations off.
Also, I think disabling inline functions and whole program optimization will help quite a lot.
In fact, there are many dump types, maybe you could choose one small enough but still having more info
http://msdn.microsoft.com/en-us/library/ms680519(VS.85).aspx
Those types won't help with call stack though, they only affect the amount of variables you'll be able to see.
I noticed some of those dump types aren't supported in dbghelp.dll version 5.1 that we use. We could update it to the newest, 6.9 version though, I've just checked the EULA for MS Debugging Tools -- the newest dbghelp.dll is still ok to redistribute. |
In case anyone is interested, a co-worker replied to this question to me via email:
Artem wrote:
> There is a flag to MiniDumpWriteDump()
> that can do better crash dumps that
> will allow seeing full program state,
> with all global variables, etc. As for
> call stacks, I doubt they can be
> better because of optimizations...
> unless you turn (maybe some)
> optimizations off.
>
> Also, I think disabling inline
> functions and whole program
> optimization will help quite a lot.
>
> In fact, there are many dump types,
> maybe you could choose one small
> enough but still having more info
> [http://msdn.microsoft.com/en-us/library/ms680519(VS.85).aspx][1]
>
> Those types won't help with call stack
> though, they only affect the amount of
> variables you'll be able to see.
>
> I noticed some of those dump types
> aren't supported in dbghelp.dll
> version 5.1 that we use. We could
> update it to the newest, 6.9 version
> though, I've just checked the EULA for
> MS Debugging Tools -- the newest
> dbghelp.dll is still ok to
> redistribute.
[1]: http://msdn.microsoft.com/en-us/library/ms680519(VS.85).aspx |
A few months back, Dustin Sallings wrote a [fork][1] of GitNub that uses Mercurial. It's Leopard-only, but lovely.
On Tiger, the "view" exension mentioned in the other comments works okay, as does [hgview][2].
[1]: http://github.com/dustin/gitnub/wikis
[2]: http://www.logilab.org/project/hgview |
It would also help if you had a target language in mind as not all data structures and interactions are equally efficient and effective in all languages. |
How expensive is ST_GeomFromText |
|gis|postgis| |
In postgis, is the "ST_GeomFromText" call very expensive? I ask mostly because I have a frequently called query that attempts to find the point that is nearest another point that matches some criteria, and which is also within a certain distance of that other point, and the way I currently wrote it, it's doing the same ST_GeomFromText twice:
$findNearIDMatchStmt = $postconn->prepare(
"SELECT internalid " .
"FROM waypoint " .
"WHERE id = ? AND " .
" category = ? AND ".
" (b.category in (1, 3) OR type like ?) AND ".
" ST_DWithin(point, ST_GeomFromText(?," . SRID .
" ),". SMALL_EPSILON . ") " .
" ORDER BY ST_Distance(point, ST_GeomFromText(?,", SRID .
" )) " .
" LIMIT 1");
Is there a better way to re-write this?
Slightly OT: In the preview screen, all my underscores are being rendered as & # 9 5 ; - I hope that's not going to show up that way in the post. |
|c#|winforms|textbox| |
I have a user that want to be able to select a textbox and have the current text selected so that he doesn't have to highlight it all in order to change the contents. The contents need to be handle when enter is pushed. That part I think I have figured out but any suggections would be welcome. The part I need help with is that once enter has been pushed, any entry into the textbox should clear the contents again. |
I have a user that want to be able to select a textbox and have the current text selected so that he doesn't have to highlight it all in order to change the contents.
The contents need to be handle when enter is pushed. That part I think I have figured out but any suggestions would be welcome.
The part I need help with is that once enter has been pushed, any entry into the textbox should clear the contents again.
**Update:** The textbox controls an piece of RF hardware. What the user wants to be able to do is enter a setting and press enter. The setting is sent to the hardware. Without doing anything else the user wants to be able to type in a new setting and press enter again. |
I think your best best is to run the VNC server with a different geometry on a different port. I would try based on the <a href="http://www.realvnc.com/products/free/4.1/man/vncserver.html">man page</a>
> $vncserver :0 -geometry 1600x1200
> $vncserver :1 -geometry 1440x900
Then you can connect from work to one port and from home to another. |
I think your best best is to run the VNC server with a different geometry on a different port. I would try based on the <a href="http://www.realvnc.com/products/free/4.1/man/vncserver.html">man page</a>
> $vncserver :0 -geometry 1600x1200
> $vncserver :1 -geometry 1440x900
Then you can connect from work to one port and from home to another.
Edit: Then use xmove to move windows between the two x-servers. |
Hook into the KeyPress event on the TextBox, and when it encounters the Enter key, run your hardware setting code, and then highlight the full text of the textbox again (see below) - Windows will take care of clearing the text with the next keystroke for you.
TextBox1.Select(0, TextBox1.Text.Length); |
> Right-click the toolbox, click "Choose
> Items" from the context menu, browse
> to your DLL, and select it.
To extend on Greg's answer...
Just to clarify, you cannot add a user control to the tool box if the code for it is in the same project that you want to use it in. For some reason MS has never added this ability, which would make sense since we don't want to always have to create a User Control Library DLL everytime we want to use a user control. So, to get it in your tool box, you have to first create a separate "User Control Library" project (which *can* be in the same solution!) and then do what Greg said. |
[Splunk >][1] is great, and free. It allows you to visualize and search all of your logs in real time. And it's all web based, so you can view your logs from just about anywhere.
[1]: http://www.splunk.com/ |
No it is a side effect of Crystal Reports. If you don't need it, remove it from your computer it is nothing but a headache. It is safe to delete the aspnet_client folder. |
Your python interpreter is correct.
One (Stupid) way of calculating a modulus is to subtract or add the modulus until the resulting value is between 0 and modulus -1.
e.g
13 mod 5 = (13 - 5) mod 5 = (13 - 10) mod 5 = 3
or in your case
-2 mod 5 = (-2 + 5) mod 5 = 3 |
Well, -2 divided by 5 would be 0 with a remainder of 3. I don't believe that should be very platform dependent, but I've seen stranger things. |
It is indeed 3. In [modular arithmetic][1], a modulus is simply the remainder of a division, and the remainder of -2 divided by 5 is 3.
[1]: http://en.wikipedia.org/wiki/Modular_arithmetic |
The result of the modulus operation on negatives seems to be programming language dependent and here is a listing http://en.wikipedia.org/wiki/Modulo_operation |
Well, 0 % 5 should be 0, right?
-1 % 5 should be 4 because that's the next allowed digit going in the reverse direction (i.e., it can't be 5, since that's out of range).
And following along by that logic, -2 must be 3.
The easiest way to think of how it will work is that you keep adding or subtracting 5 until the number falls between 0 (inclusive) and 5 (exclusive).
I'm not sure about machine dependence - I've never seen an implementation that was, but I can't say it's never done. |
Your question seems similar to [this one][1], which has some additional answers.
[1]: http://stackoverflow.com/questions/41424/how-do-you-implement-a-did-you-mean |
I'm not sure about origin of *message* terminology. Most ofter I encounter *messages* in UML design. Objects (Actors in UML terminology) can communicate with each other by means of *messages*. In real-world code *message* is just a function call usually. I think of message as of attempt to communicate with some object. It can be a real message (like messages in OS) or function calls. |
You could also do it roughly the same as discussed [here][1]: (translated to AS3)
var age:int = (new Date()).fullYear - bDay.fullYear;
if ((new Date()) < (new Date((bDay.fullYear + age), bDay.month, bDay.date))) age--;
[1]: http://stackoverflow.com/questions/9/how-do-i-calculate-someones-age-in-c "Jeff Atwodd's Question about calculating age in C#" |
Usually, "Method" seems to be the proper name for Functions. However, each language has it's own keywords. Delphi for example even makes a difference between Methods that return something ("Functions") and Methods that return Nothing ("Procedures") whereas in C-Type languages, there is no difference. |
Troubleshoot Java Lucene ignoring Field |
|java|lucene| |
We're currently using Lucene 2.1.0 for our site search and we've hit a difficult problem: one of our index fields is being ignored during a targeted search. Here is the code for adding the field to a document in our index:
// Add market_local to index
contactDocument.add(
new Field(
"market_local"
, StringUtils.objectToString(
currClip.get(
"market_local"
)
)
, Field.Store.YES
, Field.Index.UN_TOKENIZED
)
);
Running a query ( * ) against the index will return the following results:
Result 1:
title: Foo Bar
market_local: Local
Result 2:
title: Bar Foo
market_local: National
Running a targeted query:
+( market_local:Local )
won't find any results.
I realize this is a highly specific question, I'm just trying to get information on where to start debugging this issue, as I'm a Lucene newbie.
|
[MSDN][1]:
> There is a very low probability that the value of the new Guid is all zeroes or equal to any other Guid.
[1]: http://msdn.microsoft.com/en-us/library/system.guid.newguid.aspx |
On this post on [Upgrading TFS 2005 to 2008 ][1] I mentioned that the SharePoint upgrade to 3.0 was the main difficulty. I thought it was performed as part of the upgrade, but it in fact is a separate upgrade process. You should also install Team Explorer 2008 before installing Visual Studio 2008 Service Pack 1 on developer's machines. If you don't, you have to go back and reinstall the service pack. Also be sure to get the SP1 RTM version, which MS just release in the past week or so. If you have already installed the SP1Beta, then you have to download a special removal tool, run that, then install SP1 RTM. We did not have any custom build types, but we did use a custom build guidance package from Conchango - and it upgraded OK.
[1]: http://stackoverflow.com/questions/32597/installing-team-foundation-server#32618 |
> Is a GUID unique 100% of the time?
Not guaranteed, since there are several ways of generating one. However, you can try to calculate the chance of creating two GUIDs that are identical and you get the idea: a GUID has 128 bits, hence, there are 2<sup>128</sup> distinct GUIDs – **much** more than there are stars in the known universe. Read the [wikipedia article](http://en.wikipedia.org/wiki/GUID) for more details. |
Both Subversion and CVS call them `Keywords`.
[Have a look in the SVN manual here][1] (scroll down to **svn:keywords**) or [here for CVS][2].
[1]: http://svnbook.red-bean.com/en/1.0/ch07s02.html#svn-ch-7-sect-2.3
[2]: http://badgertronics.com/writings/cvs/keywords.html |
Guids are statistically unique. The odds of two different clients generating the same Guid are infinitesimally small (assuming no bugs in the Guid generating code). You may as well worry about your processor glitching due to a cosmic ray and deciding that 2+2=5 today.
Multiple threads allocating new guids will get unique values, but you should get that the function you are calling is thread safe. Which environment is this in? |
Yeah. What I ended up doing is I converted to varchar(max) on the fly, and the replace took care of the rest.
-- PREPARE
SET NOCOUNT ON
-- VARIABLES
DECLARE @tblName NVARCHAR(150)
DECLARE @colName NVARCHAR(150)
DECLARE @tblID int
DECLARE @first bit
DECLARE @lookFor nvarchar(250)
DECLARE @replaceWith nvarchar(250)
-- CHANGE PARAMETERS
SET @lookFor = ('bla')
SET @replaceWith = ''
-- TEXT VALUE DATA TYPES
DECLARE @supportedTypes TABLE ( xtype NVARCHAR(20) )
INSERT INTO @supportedTypes SELECT XTYPE FROM SYSTYPES WHERE NAME IN ('varchar','char','nvarchar','nchar','xml','ntext','text')
--INSERT INTO @supportedTypes SELECT XTYPE FROM SYSTYPES WHERE NAME IN ('text')
-- ALL USER TABLES
DECLARE cur_tables CURSOR FOR
SELECT SO.name, SO.id FROM SYSOBJECTS SO WHERE XTYPE='U'
OPEN cur_tables
FETCH NEXT FROM cur_tables INTO @tblName, @tblID
WHILE @@FETCH_STATUS = 0
BEGIN
-------------------------------------------------------------------------------------------
-- START INNER LOOP - All text columns, generate statement
-------------------------------------------------------------------------------------------
DECLARE @temp VARCHAR(max)
DECLARE @count INT
SELECT @count = COUNT(name) FROM SYSCOLUMNS WHERE ID = @tblID AND
XTYPE IN (SELECT xtype FROM @supportedTypes)
IF @count > 0
BEGIN
-- fetch supported columns for table
DECLARE cur_columns CURSOR FOR
SELECT name FROM SYSCOLUMNS WHERE ID = @tblID AND
XTYPE IN (SELECT xtype FROM @supportedTypes)
OPEN cur_columns
FETCH NEXT FROM cur_columns INTO @colName
-- generate opening UPDATE cmd
PRINT 'UPDATE ' + @tblName + ' SET'
SET @first = 1
-- loop through columns and create replaces
WHILE @@FETCH_STATUS = 0
BEGIN
IF (@first=0) PRINT ','
PRINT @colName +
' = REPLACE(convert(nvarchar(max),' + @colName + '),''' + @lookFor +
''',''' + @replaceWith + ''')'
SET @first = 0
FETCH NEXT FROM cur_columns INTO @colName
END
PRINT 'GO'
CLOSE cur_columns
DEALLOCATE cur_columns
END
-------------------------------------------------------------------------------------------
-- END INNER
-------------------------------------------------------------------------------------------
FETCH NEXT FROM cur_tables INTO @tblName, @tblID
END
CLOSE cur_tables
DEALLOCATE cur_tables
|
Well, I figured it out myself, right after posting, which is the most embarassing way. :)
It seems every member of a StackPanel will simply fill it's minimum requested size.
In the DockPanel, I had docked things in the wrong order. If the TextBox or ListBox is the only docked item without an alignment, or if they are the last added, they WILL fill the remaining space as wanted.
I would love to see a more elegant method of handling this, but it will do. |
How do you make a post request into a new browser tab using JavaScript / XUL? |
|xul|firefox|ubiquity|javascript| |
I'm trying to open a new browser tab with the results of a POST request. I'm trying to do so using a function containing the following code:
var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interface
s.nsIWindowMediator);
var browserWindow = windowManager.getMostRecentWindow("navigator:browser");
var browser = browserWindow.getBrowser();
if(browser.mCurrentBrowser.currentURI.spec == "about:blank")
browserWindow.loadURI(url, null, postData, false);
else
browser.loadOneTab(url, null, null, postData, false, false);
I'm using a string as url, and JSON data as postData. Is there something I'm doing wrong?
Build identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1
Thanks in advance.
|
|javascript|firefox|xul|ubiquity| |
I'm trying to open a new browser tab with the results of a POST request. I'm trying to do so using a function containing the following code:
var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interface
s.nsIWindowMediator);
var browserWindow = windowManager.getMostRecentWindow("navigator:browser");
var browser = browserWindow.getBrowser();
if(browser.mCurrentBrowser.currentURI.spec == "about:blank")
browserWindow.loadURI(url, null, postData, false);
else
browser.loadOneTab(url, null, null, postData, false, false);
I'm using a string as url, and JSON data as postData. Is there something I'm doing wrong?
What happens, is a new tab is created, the location shows the URL I want to post to, but the document is blank. The Back, Forward, and Reload buttons are all grayed out on the browser. It seems like it did everything except executed the POST. If I leave the postData parameter off, then it properly runs a GET.
Build identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1
Thanks in advance.
|
Best Versioning Tools to use for Photoshop/Illustrator and related binary files? |
|versioning|photoshop| |
I previously asked about Version Cue 3 vs Subversion. I think this is a better question and someone suggested [http://www.gridironsoftware.com/Flow/][1] I hope this question will allow others to join in and suggest other tools or give specific recommendation to using Version Que versus other tools.
[1]: http://www.gridironsoftware.com/Flow/ |
|internet-explorer|ntlm|intranet|security-zone|jcifs| |
I'm developing a website which will be used in the corporate intranet which uses JCIFS and NTLM to automatically authenticate the users without asking them to log on. Everything seems to be working in IE 6, but some users are being prompted for their passwords in IE 7.
We've had some success by getting the users to change their Logon option to "Automatic logon using current username and password" (Tools > Internet Options > Securty Tab > Select Local Intranet > Custom Level > All the way at the bottom User Authentication > Logon), but we are still having a few users who are getting username/password prompts.
Also, we've had some users report they can just click cancel when the prompt comes up and the page will come up correctly.
If anyone has any other suggestions, I'd greatly appreciate them. |
I see nothing wrong with it being static..
The semantics of the static method seem to make a lot more sense to me. Perhaps it is because it is a primitive. Where primitives are used to often, you want to make the utility code for working with them as light as possible.. Also, I think the semantics are a lot better with _String.Format_ over _"MyString BLAH BLAH {0}".Format_ ... |
I think that what makes pointers tricky to learn is that until pointers you're comfortable with the idea that "at this memory location is a set of bits that represent an int, a double, a character, whatever".
When you first see a pointer, you don't really get what's at that memory location. "What do you mean, it holds an *address*?"
I don't agree with the notion that "you either get them or you don't".
They become easier to understand when you start finding real uses for them (like not passing large structures into functions). |
> It should only be used in the href tag.
That's ridiculous.
The accepted way is this:
<a href="/non-js-version/" onclick="someFunction(); return false">Blah</a>
But to answer the OP, there is generally no reason to use "javascript:" anymore. In fact, you should attach the javascript event from your script, and not inline in the markup. But, that's a purist thing I think :-D |
Instance methods are good when you have an object that maintains some state; the process of formatting a string does not affect the string you are operating on (read: does not modify its state), it creates a new string.
With extension methods, you can now have your cake and eat it too (i.e. you can use the latter syntax if it helps you sleep better at night). |
`String.Format` takes at least one String and returns a different String. It doesn't need to modify the format string in order to return another string, so it makes little sense to do that (ignoring your formatting of it). On the other hand, it wouldn't be that much of a stretch to make `String.Format` be a member function, except I don't think C# allows for const member functions like C++ does. [Please correct me and this post if it does.]
MSN |
I think it looks better in general to use String.Format, but I could see a point in wanting to have a non-static function for when you already have a string stored in a variable that you want to "format".
As an aside, all functions of the string class don't act on the string, but return a new string object, because strings are immutable. |
In SVN a tag and branch are really similar.
**Tag** = a defined slice in time, usually used for releases
**Branch** = also a defined slice in time that development can continue on, usually used for major version like 1.0, 1.5, 2.0, etc, then when you release you tag the branch. This allows you to continue to support a production release while moving forward with breaking changes in the trunk
**Trunk** = development work space, this is where all development should happen, and then changes merged back from branch releases. |
They don't really have any formal meaning. A folder is a folder to SVN. They are a generally accepted way to organize your project. The trunk is where you keep your main line of developmemt. The branch folder is where you might create, well, branches, which are hard to explain in a short post. A branch is a copy of a subset of your project that you work on separately from the trunk. Maybe it's for experiments that might not go anywhere, maybe it's for the next release, which you will later merge back into the trunk when it becomes stable. And the tags folder is for creating tagged copies of you repository, usually at release checkpoints.
But like I said, to SVN, a folder is a folder. branch, trunk and tag are just a convention.
[Edit] I'm using the word 'copy' liberally. SVN doesn't actually make full copies of things in the repository. |
The trunk directory is the directory that you're probably most familiar with, because it is used to hold the most recent changes. You main code base should be in trunk.
The branches directory is for holding your branches, whatever they may be.
The tags directory is basically for tagging a certain set of files. You do this for things like releases, where you want "1.0" to be these files at these revision and "1.1" to be these files at these revisions. You usually don't modify tags once they're made. For more information on tags, see http://svnbook.red-bean.com/en/1.4/svn.branchmerge.tags.html |
Making one interface overwrite a method it inherits from another interface in PHP |
|php|oop|interface|extends| |
*The "Question":*
**Is there a way in PHP to overwrite a method declared by one interface in an interface extending that interface?**
*The "Example":*
I'm probably doing something wrong, but here is what I have:
interface iVendor{
public function __construct($vendors_no = null);
public function getName();
public function getVendors_no();
public function getZip();
public function getCountryCode();
public function setName($name);
public function setVendors_no($vendors_no);
public function setZip($zip);
public function setCountryCode($countryCode);
}
interface iShipper extends iVendor{
public function __construct($vendors_no = null, $shipment = null);
public function getTransitTime($shipment = null);
public function getTransitCost($shipment = null);
public function getCurrentShipment();
public function setCurrentShipment($shipment);
public function getStatus($shipment = null);
}
Normally in PHP, when you extend something, you can overwrite any method contained therein (right?). However, when one interface extends another, it won't let you. Unless I'm thinking about this wrong... When I implement the iShipper interface, I don't have to make the Shipper object extend the Vendor object (that implements the iVendor interface). I just say:
class FedEx implements iShipper{}
and make FedEx implement all of the methods from iVendor and iShipper. However, I need the __construct functions in iVendor and iShipper to be unique. I know I could take out the $shipment = null, but then it wouldn't be as convenient to create Shippers (by just passing in the vendors_no and the shipment while instantiating).
Anyone know how to make this work? My fallback is to have to set the shipment by calling $shipper->setShipment($shipment); on the Shipper after I instantiate it, but I'm hoping for a way to get around having to do that...
*A little more explanation for the curious:*
*The FedEx Object has methods that go to the FedEx site (using cURL) and gets an estimate for the Shipment in question. I have a UPS Object, a BAXGlobal Object, a Conway Object, etc. Each one has COMPLETELY different methods for actually getting the shipping estimate, but all the system needs to know is that they are a "shipper" and that the methods listed in the interface are callable on them (so it can treat them all exactly the same, and loop through them in a "shippers" array calling getTransitX() to find the best shipper for a shipment).*
*Each "Shipper" is also a "Vendor" though, and is treated as such in other parts of the system (getting and putting in the DB, etc. Our data design is a pile of crap, so FedEx is stored right alongside companies like Dunder Mifflin in the "Vendors" table, which means it gets to have all the properties of every other Vendor, but needs the extra properties and methods supplied by iShipper).* |
|search|lucene| |
If the language you are using has a supported method/function then just use that (as in the C# ToTitleCase method)
If it does not, then you will want to do something like the following:
(1) Read in the string
(2) Take the first word
(3) Capatilise the first letter of that word*
(4) Go forward and find the next word
(5) Go to 3 if not at the end of the string, otherwise exit
*To capatilise it in, say, C - use the ascii codes (<http://www.asciitable.com/>) to find the integer value of the char and subtract 32 from it.
There would need to be much more error checking in the code (ensuring valid letters etc.), and the "Capatilise" function will need to impose some sort of "title-case scheme" on the letters to check for words that do not need to be capatilised ('and', 'but' etc. Here <http://answers.google.com/answers/threadview?id=349913> is a good scheme) |
The Activator class within the root System namespace is pretty powerful.
There are a lot of overloads for passing parameters to the constructor and such. Check out the documentation at: <http://msdn.microsoft.com/en-us/library/system.activator.createinstance.aspx>
Here are some simple examples:
ObjectType instance = (ObjectType)Activator.CreateInstance(objectType);
ObjectType instance = (ObjectType)Activator.CreateInstance("MyNamespace.ObjectType, MyAssembly"); |
No, there are many applications built with VS2005 that have to support Windows XP, 2000, NT, the whole stack. The issue is that (by default) VS2005 wants to use libraries/exports not present on NT.
See [this thread](http://www.mombu.com/microsoft/windows-programmer-win32/t-vs2005-and-nt4-392831.html) for some background.
Then start limiting your dependencies via preprocessor macros, and avoiding APIs which aren't supported on NT. |
Here is my current method. Any suggestions?
Regex singleMToDoubleRegex = new Regex("(?<!m)m(?!m)");
Regex singleDToDoubleRegex = new Regex("(?<!d)d(?!d)");
CultureInfo currentCulture = CultureInfo.CurrentUICulture;
// If the culture is netural there is no date pattern to use, so use the default.
if (currentCulture.IsNeutralCulture)
{
currentCulture = CultureInfo.InvariantCulture;
}
// Massage the format into a more general user friendly form.
string shortDatePattern = CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern.ToLower();
shortDatePattern = singleMToDoubleRegex.Replace(shortDatePattern, "mm");
shortDatePattern = singleDToDoubleRegex.Replace(shortDatePattern, "dd"); |
How about giving the format (mm/dd/yyyy or dd/mm/yyyy) followed by a printout of today's date in the user's culture. MSDN has an article on [formatting a DateTime for the person's culture][1], using the CultureInfo object that might be helpful in doing this. A combination of the format (which most people are familiar with) combined with the current date represented in that format should be enough of a clue to the person on how they should enter the date. (Also include a calendar control for those who still cant figure it out).
[1]: http://msdn.microsoft.com/en-us/library/5hh873ya(VS.71).aspx |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.