instruction stringlengths 0 30k ⌀ |
|---|
|c#|web-services| |
I have created a web service in .net 2.0, C#. I need to log some information to a file whenever different methods are called by the web service clients.
The problem comes when one user process is writing to a file and another process tries to write to it. I get the error "The process cannot access the file because ... |
There is not a portable solution to this problem, since ANSI C does not define a standard millisecond-accurate time function. If you're using Windows, you can use GetTickCount(), timeGetTime(), or QueryPerformanceCounter()/QueryPerformanceFrequency(). Keep in mind that these have different accuracies and different ru... |
This may help you in identifing the pieces that have the most problems.
@ JB King
Thanks for reminding me. The Logging application block has a Instrumentation Event that can be used to trace events, you can find more info on the MS Enterprise library docs.
Using (New InstEvent)
<series of statements> ... |
Can't download file in IE7 but there isn't any problem in Firefox, Chrome, etc..? |
|php|internet-explorer-7|download| |
I have an script that receives an encrypted url and from that generates a download, the most critic par of the script is this:
$MimeType = new MimeType();
$mimetype = $MimeType->getType($filename);
$basename = basename($filename);
header("Content-type: $mimetype");
header("Content-Disposition... |
Enums do serialize to ints. But generally, if you don't like the way one of your properties gets serialized to XML, you can just do this:
[XmlIgnore]
public MyThing MyThing { get; set; }
[XmlElement("MyThing")]
private string MyThingForSerialization
{
get { return //convert MyThing... |
I use const on function parameters that are references (or pointers) which are only [in] data and will not be modified by the function. Meaning, when the purpose of using a reference is to avoid copying data and not to allow changing the passed parameter.
Putting const on the boolean b parameter in your example only... |
I use const on function parameters that are references (or pointers) which are only [in] data and will not be modified by the function. Meaning, when the purpose of using a reference is to avoid copying data and not to allow changing the passed parameter.
Putting const on the boolean b parameter in your example only... |
This is possible. I remember doing it in VB6 when writing screen savers. The screen saver control panel sends a commandline to the screen saver with the HWND of the preview window. Using that HWND, you can then get the HDC and from there everything else you need. |
The 'badarity' error means that you're trying to call a 'fun' with the wrong number of arguments. In this case...
%%L = for(1,N, fun() -> spawn(fun(I) -> wait(I,N) end) end),
The for/3 function expects a fun of arity 1, and the spawn/1 function expects a fun of arity 0. Try this instead:
L = for(1, N, fun(... |
C++ supports multiple inheritance so you can have a generic persistence API and inherit a persistence mechanism. This would still have to use introspection to get out the class metadata, but you would still have this issue with any persistence layer.
Alternatively you could do something similar but use the metadata... |
How do I add a "last" class on the last <li> within a Views-generated list? |
|drupal| |
Title says it all. |
|css|drupal| |
Along the line of Chii's answer, I would recommend taking a look at the [Windows Vista User Experience Guidelines][1] for general tips on making user interfaces.
Although the name ("Windows Vista User Experience Guidelines") and source (Microsoft) may suggest that it only contains Windows-centric tips and advice, it... |
Several questions about functional programming languages have got me thinking about whether XSLT is a functional programming language. If not, what features are missing? Has XSLT 2.0 shortened or closed the gap? |
|functional-programming|xslt| |
I've found enough modules to happily run my site on Drupal 6.x I think the only 5.x module I miss is one that did very easy Google ad integration, and that may have been updated I just haven't checked recently. I don't get enough traffic to make the ads worth the time in setting them up, so I just use the search part... |
Is there set division in SQL? |
|sql|database|set-theory|relational-algebra| |
I'm fully aware that set division can be accomplished through a series of other operations, so my question is:
Is there a command for set division in SQL? |
Star schemas are used to enable high speed access to large volumes of data. The high performance is enabled by reducing the amount of joins needed to satsify any query that may be made against the subject area. This is done by allowing data redundancy in dimension tables.
You have to remember that the star schema is... |
I got this on a machine that I was using for VB6 development. I had been building a lot of COM DLLs from VB6 (without binary compatibility) and the cruft that had built up in the registry eventually got too much.
Have a look at what size the registry is and what limit you have set. I doubled the registry size and th... |
In general I would choose the second one, because the scope of the 's' variable is limited to the loop. Benefits:
- This is better for the programmer because you don't have to worry about 's' being used again somewhere later in the function
- This is better for the compiler because the scope of the variable is smal... |
When you use Getopt::Long on something other than user input, be aware that some features are different based on the POSIXLY_CORRECT environment variable. You can override this with the appropriate call to Configure.
[Obligatory POSIXLY_CORRECT anecdote](http://everything2.com/node/877243).
|
Putting the code in the application layer will result in a DB independent application.
Sometimes it is better to use stored procedures for performance reasons.
It (as usual) depends on the application requirements. |
You can safely undefine them, contrary to claims from others. The reason is that they're just macros's. They only affect the preprocessor between their definition and their undefinition. In your case, that will be from early in windows.h to the last line of windows.h. If you need extra windows headers, you'd include th... |
There is no standalone right answer to this question. It depends on the requirements of your app, the preferences and skills of your developers, and the phase of the moon. |
Your constructor may (later, in an extension of your software) be called from the constructor of a subclass that overrides the virtual method. Now not the subclass's implementation of the function, but the implementation of the base class will be called. So it doesn't really make sense to call a virtual function he... |
c# determine the number of lines within a text file |
|c#|input|text-files| |
Is there an easy way to programmatically determine the number of lines within a text file? |
Business logic is to be put in the application tier and not in the database.
The reason is that a database stored procedure is always dependen on the database product you use. This break one of the advantages of the three tier model. You cannot easily change to an other database unless you provide an extra stored proc... |
Less useful generally, i think, but for the sake of completeness there is also a Big-Omega, which defines a lower-bound on an algorithm's complexity, and a Big-Theta, which defines both an upper and lower bound. |
Maybe write a "queue line" of sorts for writing to the file, so when you try to write to the file it keeps checking to see if the file is locked, if it is - it keeps waiting, if it isn't locked - then write to it. |
The power tools should let you do this.
C:\src\2\Merlin\Main>tfpt unshelve /?
tfpt unshelve - Unshelve into workspace with pending changes
Allows a shelveset to be unshelved into a workspace with pending changes.
Merges content between local and shelved changes. Allows migration of shelved
... |
That makes sense, but just for fun, what if the work doesn't need to run if the site gets shut down? If it's associated with the Application_Start event and only needs to run while people are browsing the site, what are the risks at that point?
Good answers, I'm just curious a little more about how that works on the... |
ADSI will not connect to IIS from XP Workstation |
|iis|adsi| |
I'm successfully using VBScript within WScript to remotely read and write IIS configurations from the server. When I attempt to run these same scripts from my desk box they fail, though. Example:
Dim vdir
Set vdir = GetObject("IIS://servername/w3svc/226/root")
Error = "Invalid syntax"
The code works p... |
Anything not in the <code>(c)time.h</code> header requires OS-specific methods. I believe all those methods are second resolution.
What OS are you working in? |
Depending on the size of the BLOBs, make sure you're storing them in-line / out of line appropriately.
See http://www.dba-oracle.com/t_table_blob_lob_storage.htm |
I do not use const for value-passed parametere. The caller does not care whether you modify the parameter or not, it's an implementation detail.
What is really important is to mark methods as const if they do not modify their instance. Do this as you go, because otherwise you might end up with either lots of const_c... |
I too am a fan of UnitTest++.
The snag is that the source distribution contains almost 40 seperate files. This is absurd. Managing the source control and build tasks for a simple project is dominated by looking after all these unit testing files.
I have modified UnitTest++ so that it can be integrated with a proj... |
I too am a fan of UnitTest++.
The snag is that the source distribution contains almost 40 seperate files. This is absurd. Managing the source control and build tasks for a simple project is dominated by looking after all these unit testing files.
I have modified UnitTest++ so that it can be integrated with a proj... |
well, now it seems to work just fine with the unc path. |
From the sound of it, it seems like you're talking about deterministic finalization (destructors in C++), which doesn't exist in C#. The closest thing that you will find in C# is the Disposable pattern. Basically you implement the **IDisposable** interface.
The basic pattern is this:
public class MyClass: IDi... |
FlowDocument myFlowDocument = new FlowDocument(); //get your FlowDocument
//put in some (or it already has) text
string inText = "Hello, WPF World!";
TextRange tr = new TextRange(FlowDocument.ContentStart, FlowDocument.ContentEnd);
tr.Text = inText;
//get the current text out o... |
Get the **Text** property of a **TextRange** object <i>initialized over the entire **FlowDocument**</i>:
FlowDocument myFlowDocument = new FlowDocument(); //get your FlowDocument
//put in some (or it already has) text
string inText = "Hello, WPF World!";
TextRange tr = new TextRange(FlowDoc... |
Use the following SQL to determine the collation of a database:
SELECT DATABASEPROPERTYEX('{database name}', 'Collation') SQLCollation; |
You may want to look at a custom document writer, rather than using the COM Wrapped API from Microsoft. I have heard good things about OfficeWriter. It's not free, but speed never is.
It doesn't require Word on the server.
[http://officewriter.softartisans.com/officewriter-59.aspx][1]
[1]: http://officew... |
If you can use `scp` instead of `ftp`, the `-r` option will do this for you. I would check to see whether you can use a more modern file transfer mechanism than FTP. |
How do I determine the collation of a databsae in SQL 2005? |
|sql|collation| |
How do you determine the collation of a database in SQL 2005, for instance if you need to perform a case-insensitive search/replace? |
How do I determine the collation of a database in SQL 2005? |
How do I get the image paint/paintComponent generates? |
|java|swing|paint|jcomponent| |
I have a quick question. How do I get the image generated by a JComponent.paint or paintComponent?
I have a JComponent which I use as a 'workspace' and where I have overwritten the paintComponent method to my own. The thing is that my workspace JComponent also has children which has their own paintComponent methods.... |
Again, a little bit off topic (not very far), but if you were aiming to put something between the array items being output, then if there was only a few lines to concatenate, join(', ', $output) would do it easily and quickly enough. This would be easier to write, and avoids having to check for the end of the list (whe... |
Transparent form on the desktop |
Unless you have a 5.x module that you can't do without, **and** that you know is being worked on to upgrade to 6.x, just use 6.x. i.e. Only start with 5.x now if you know you have a upgrade path with your site to 6.x (and then 7.x). If the module isn't being actively worked on, it mean you'll be unsupported when 7.x ro... |
Star schemas are a natural fit for the last layer of a data warehouse. How you get there is another question. As far as I know, there are two big camps, those of Bill Inmon and Ralph Kimball. You might want to look at the theories of these two guys if/when you decide to go with a star.
Also, some reporting tools ... |
To add on a bit to @[Esteban Araya's answer][1], they will both require the creation of a new string each time through the loop (as the return value of the `some Assignment` expression). Those strings need to be garbage collected either way.
[1]: http://stackoverflow.com/questions/110083/which-of-these-loops-is-be... |
LinearGradientBrush Artifact Workaround? |
|c#|gdi+| |
The LinearGradientBrush in .net (or even in GDI+ as a whole?) seems to have a severe bug: Sometimes, it introduces artifacts. (See [here][1] or [here][2] - essentially, the first line of a linear gradient is drawn in the endcolor, i.e. a gradient from White to Black will start with a Black line and then with the proper... |
The LinearGradientBrush in .net (or even in GDI+ as a whole?) seems to have a severe bug: Sometimes, it introduces artifacts. (See [here][1] or [here][2] - essentially, the first line of a linear gradient is drawn in the endcolor, i.e. a gradient from White to Black will start with a Black line and then with the proper... |
You should just include the standard/common css in the website and include it in the head of the masterpage instead of placing it in themes. |
[http://vadimtropashko.files.wordpress.com/2007/02/ch3.pdf][1]
From Page 32:
> Relational Division is not a fundamental operator. It can be expressed in terms of projection, Cartesian product, and set difference.
So, no. :)
[1]: http://vadimtropashko.files.wordpress.com/2007/02/ch3.pdf |
woo!
solved it on my own.
Use
self.combo['selection']
instead of
self.combo['value']
|
I would recommend you setup a scheduled task to run a page on your site. I usually point the scheduled task to a .vbs file with the following:
<pre>
On Error Resume Next
Dim objRequest
Dim URL
Set objRequest = CreateObject("Microsoft.XMLHTTP")
URL = "http://www.mywebsite.com/cron/pagetorun.ashx"
objRequest.o... |
Wikipedia has some [pseudocode][1] for finding the longest common substring between two sequences of data. In your case, you simply extract all common substring from the table that are not prefixes of other common substrings (i.e. maximal common substrings).
[1]: http://en.wikipedia.org/wiki/Longest_common_subst... |
You could probably write some assembly to do a slightly better job. However, I'd be pretty surprised if this was the bottleneck in your application; have you done any profiling? This function doesn't seem like it's worth optimizing. |
The [Stripes Framework][1] is an excellent framework. The only configuration involved is pasting a few lines in your web.xml.
It's a very straight forward request based Java web framework.
[1]: http://www.stripesframework.org/ |
This is probably not what you are looking for, but here's one minor speedup:
Pass only one argument, if they are guaranteed to be the same.
|
> $('select').change(onChange($(this));
You need to understand the difference between calling a function and passing it around as an object. Functions are first-class objects in JavaScript, they are an object just like anything else, so they can be stored in variables, passed as arguments to other functions, and so... |
Handles to internal windows data structures.
Database connections.
File handles.
Network connections.
COM/OLE references.
The list goes on.
It's important to call `Dispose` or even better yet, use the `using` pattern. |
* Handles to internal windows data structures.
* Database connections.
* File handles.
* Network connections.
* COM/OLE references.
The list goes on.
It's important to call `Dispose` or even better yet, use the `using` pattern. |
* Handles to internal windows data structures.
* Database connections.
* File handles.
* Network connections.
* COM/OLE references.
The list goes on.
It's important to call `Dispose` or even better yet, use the `using` pattern.
using (SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawi... |
I agree that locking binary files is a necessary feature for some environments. I just had a thought about how to implement this, though:
- Have a way of marking a file as "needs-lock" (like the "svn:needs-lock" property).
- On checkout, git would mark such a file as read-only.
- A new command `git-lock` would con... |
A commonly used trick for plain x86/x87 code is to force mantissa part of the float to represent the int. 32 bit version follows.
64 b version is analogical. LUA version posted above is faster, but relies on the truncation of double to 32b result, therefore requires x87 unit to be set to double precision, and cannot... |
A commonly used trick for plain x86/x87 code is to force mantissa part of the float to represent the int. 32 bit version follows.
64 b version is analogical. LUA version posted above is faster, but relies on the truncation of double to 32b result, therefore requires x87 unit to be set to double precision, and cannot... |
What do you mean by "users of SharePoint"?
Do you mean that they want to see data from inside a SharePoint page?
In that case you have to do impersonation in that page/application, and possible set up Kerberos correctly.
Then you will have to assign those SharePoint users (or better, their AD group) proper privi... |
1. [Writing Windows Services - Made easy][1]
2. [Five Steps to Writing Windows Services in C][2]
[1]: http://www.codeproject.com/KB/system/xservice.aspx
[2]: http://www.devx.com/cplus/Article/9857 |
I'd like to write some quicks scripts to play with bluetooth devices (scan etc…), for the Mac. Under linux I'd probably use `hcitool`, or the python bluez library.
What tools are there for the Mac? |
I'd like to write some quick scripts to play with bluetooth devices (scan etc…), for the Mac. Under linux I'd probably use `hcitool`, or the python bluez library.
What tools are there for the Mac? |
Are there any OS X equivalents to `hcitool`? |
@efotinis: You're right.
Here is a workaround until py2exe gets fixed and you don't want to include the same icon twice:
hicon = win32gui.CreateIconFromResource(win32api.LoadResource(None, win32con.RT_ICON, 1), True)
Be aware that **1** is not the ID you gave the icon in setup.py (which is the icon group... |
Be very careful about doing this kind of optimisation without having hard facts to measure against.
Most databases have several levels of caches. If these are tuned correctly, the database will probably do a much better job at caching, than you can do your self. |
We use LuntBuild which works perfectly with maven |
TFS 2008 is pretty good. It has continuous integration built in to TFS build. |
> (I'm always wondering why std::map does not include a member function for us to do so.)
Because it can't do it any better than you can do it. If a method's implementation will be no superior to a free function's implementation then in general you should not write a method; you should write a free function.
It'... |
My preferred solution for this would be to do the resizing server-side, so you are transmitting less unnecessary data.
If you have to do it client-side though, and need to keep the image ratio, you could use the below:
var image_from_ajax = new Image();
image_from_ajax.src = fetch_image_from_ajax(); // D... |
I have noticed this as well when using gradient brushes. The only effective workaround I have is to always create the gradient brush rectangle 1 pixel bigger on all edges than the area that is going to be painted with it. That protects you against the issue on all four edges. The downside is that the colors used at the... |
I found a good way [here][1]
[1]: http://kpumuk.info/ruby-on-rails/flexible-application-configuration-in-ruby-on-rails/ |
Getting a FILE* from a std::fstream |