instruction stringlengths 0 30k ⌀ |
|---|
First, I agree with the other posters who suggested a resource leak. You really want to rule that out first.
Hopefully, the heap manager you are currently using has a way to dump out the actual total free space available in the heap (across all **free** blocks) and also the total number of blocks that it is divided ... |
As you suggest, Doug Lea's malloc might work well. It's cross platform and it has been used in shipping code. At the very least, it should be easy to integrate into your code for testing.
Having worked in fixed memory environments for a number of years, this situation is certainly a problem, even in non-fixed envi... |
With as little information you provided, i would choose Regex.
But what kind of information you want to parse and what you would want to do will change the decision to Lex/Yacc maybe..
But it looks like you've already made your mind up with String search :)
|
How to best merge information, at a server, into a "form", a PDF being generated as the final output |
|.net|forms|pdf-generation| |
|.net|pdf|forms|pdf-generation| |
**Background**:
I have a VB6 application I've "inherited" that generates a PDF for the user to review using unsupported Acrobat Reader OCX integration. The program generates an FDF file with the data, then renders the merged result when the FDF is merged with a PDF. It only works correctly with Acrobat Reader 4 :-(.... |
**Background**:
I have a VB6 application I've "inherited" that generates a PDF for the user to review using unsupported Acrobat Reader OCX integration. The program generates an FDF file with the data, then renders the merged result when the FDF is merged with a PDF. It only works correctly with Acrobat Reader 4 :-(.... |
This snippet will do so. If you're going to do it frequently, you might want to make a 'sortkeys' method or somesuch to make it easier on the eyes.
keys = list(d.keys())
keys.sort()
for key in keys:
print d[key]
Edit: dF's solution is better -- I forgot all about sorted(). |
I don't think it's a hate for the *idea* of it per se. It's just that people don't like the *implementation* of it.
[http://efvote.wufoo.com/forms/ado-net-entity-framework-vote-of-no-confidence/][1]
[1]: http://efvote.wufoo.com/forms/ado-net-entity-framework-vote-of-no-confidence/ |
SCOPE_IDENTITY(); is your best bet. And if you are using .NET just pass an our parameter and check the value after the procedure is run.
CREATE PROCEDURE [dbo].[InsertProducts]
@id INT = NULL OUT,
@name VARCHAR(150) = NULL,
@desc VARCHAR(250) = NULL
AS
INSER... |
Summing up, the answer, as you originally thought, is **no, you cannot**.
There are workarounds already mentioned by many people in this thread, like using isset() or empty() in conditions and suppressing notices in PHP configuration. That in addition to the obvious workaround, using @, which you don't want.
|
Or shorter,
for key, value in sorted(d.items()):
print value |
>>> d = {'b' : 'this is b', 'a': 'this is a' , 'c' : 'this is c'}
>>> for k,v in sorted(d.items()):
... print v, k
...
this is a a
this is b b
this is c c
|
There is the state machine approach.
private enum State
{
None = 0,
InTokin,
InQuote
}
private static IEnumerable<string> Tokinize(string input)
{
input += ' '; // ensure we end on whitespace
State state = ... |
My understanding is yes, you're trying to load an untrusted module into your local app domain. |
The MSI function MsiGetProperty can be used to get the name of the ProductCode property. I don't know if that would work in this case, since I've never created a .NET installer. |
Scriptaculous Autocompleter monitors the onclick event on the 'li'. When you stick an image inside an 'li', both the 'img' and the 'li' will get the click event, as this demonstrates. That's why Autocompleter is just doing its normal thing when the button is clicked:
<ul>
<li onclick="alert('li');">
... |
An extension to Matt Sheppard's answer might be something like the following:
<script type="text/javascript">
var thePg=window.location.pathname;
var theSite=window.location.hostname;
var theImage=new Image;
theImage.src="/test/hitcounter.php?pg=" + thePg + "?site=" + theSite;
... |
In SQL Server you can look at the Query Plan in Query Analyzer or Management Studio. This will tell you the rough percentage of time spent in each batch of statements. You'll want to look for the following:
- Table scans; this means you are completely missing indexes
- Index scans; your query may not be using... |
Not quite. Designing a type as class or struct shouldn't be driven by your need to store it in collections :) You should look at the 'semantics' needed
The problem you're seeing is due to value type semantics. Each value type variable/reference is a new instance. When you say
Struct obItem = MyList[1];
wha... |
I figured it out...
the worksheet was protected!
myWs.Unprotect(Properties.Settings.Default.PasswordSheet);
fixes it...for those playing along at home...don't forget to protect the sheet when you're done.
myWs.Protect(Properties.Settings.Default.PasswordSheet, Type.Missing, Type.Missing, Type.Missing,... |
just link to related SO question:
- [sizeof() equivalent for reference types?][1]
[1]: http://stackoverflow.com/questions/26570/sizeof-equivalent-for-reference-types |
A loop in JavaScript looks like this:
for (var=startvalue;var<=endvalue;var=var+increment)
{
code to be executed
} |
sizeof() equivalent for reference types? |
|c#| |
I'm looking for a way to get the size of an instance of a reference type. sizeof is only for value types. Is this possible? |
Make sure that:
1. You are using a Web Application project rather than a Web Site project, this will result in a precompiled binary for your code behind
2. You have turned off debug code generation in the web.config file - I guess if this is different to when you used aspnet_compiler the code may be recompiled
I... |
How about using [drb][1]? It's not real multi-threading but communication between several processes, but you can use it now in 1.8 and it's fairly low friction.
[1]: http://chadfowler.com/ruby/drb.html |
The trick is to combine a <code>UNION</code> with a literal string to determine the type of 'object' returned. The following pattern should suffice:
SELECT "group" type, name
FROM groups
WHERE name LIKE "%$text%"
UNION
SELECT "user" type, name
FROM users
WHERE name LIKE ... |
The trick is to combine a <code>UNION</code> with a literal string to determine the type of 'object' returned. In most (?) cases, UNION ALL will be more efficient, and should be used unless duplicates are required in the sub-queries. The following pattern should suffice:
SELECT "group" type, name
FROM g... |
I Agree with the previous answers that state that conflicts are possible and even likely.
If you are planning to reformat code then at least make sure that you don't mix reformat checkins with those that change the function of the actual code. This way people can skip past check-ins that are simple reformattings. I... |
Make sure this is set in web.config `<compilation debug=false>`. In my case, I also have a batch file which issue Get requests for all the main pages before giving to users (page loading simulation). |
Depends on your goals. If administration portal is part of application and will only be used from computers where your application is installed, there are plenty of advantages of going fully Silverlight - or even WPF.
But if you can see a scenario where it will be used either from random PC or by random person, full... |
d = {'b' : 'this is b', 'a': 'this is a' , 'c' : 'this is c'}
ks = d.keys()
ks.sort()
for k in ks:
print "this is " + k |
Depending how you access your SVN repo - if you're accessing it as file:// URLs, I think you're out of luck. But if you're using svnserve, or one of the HTTP gateways, you should be able to check your server logs for access to the SVN urls. |
What is the operator precedence order in VB6? |
|vb6| |
In particular, for the logical operators |
Best way to parse Space Seperated Text |
|c#|string|tokenize| |
I have string like this
/c SomeText\MoreText "Some Text\More Text\Lol" SomeText
I want to tokenize it, however I can't just split on the spaces. I've come up with somewhat ugly parser that works, but I'm wondering if anyone has a more elegant design.
This is in C# btw.
|
I have string like this
/c SomeText\MoreText "Some Text\More Text\Lol" SomeText
I want to tokenize it, however I can't just split on the spaces. I've come up with somewhat ugly parser that works, but I'm wondering if anyone has a more elegant design.
This is in C# btw.
**EDIT:** My ugly version
... |
Best way to parse Space Separated Text |
I have string like this
/c SomeText\MoreText "Some Text\More Text\Lol" SomeText
I want to tokenize it, however I can't just split on the spaces. I've come up with somewhat ugly parser that works, but I'm wondering if anyone has a more elegant design.
This is in C# btw.
**EDIT:** My ugly version, while ... |
The execution plan is a great start and will help you figure out what part of your query you need to tackle.
Once you figure out the where, it is time to tackle the how and why. Take a look at the type of queries you are trying to preform. Avoid loops at all cost as they are slow. Avoid cursors at all costs because ... |
although i dont think it'd make a difference, what happens if you do your linq like this:
(from i in items orderby i.prop1, i.prop2, i.prop3).Skip(...).Take(...).ToArray();
|
There are some optimizations you can use when filling a DataTable, such as calling BeginLoadData(), inserting the data, then calling EndLoadData(). This turns off some internal behavior within the DataTable, such as index maintenance, etc. See [this article](http://www.objectsharp.com/cs/blogs/datasetfaq/archive/2004... |
Empty namespace using Linq Xml |
|xml|linq| |
I'm trying to create a sitemap using Linq to Xml, but am getting an empty namespace attribute, which I would like to get rid of. e.g.
XNamespace ns = "http://www.sitemaps.org/schemas/sitemap/0.9";
XDocument xdoc = new XDocument(new XDeclaration("1.0", "utf-8", "true"),
new XElement(ns + "urlset"... |
On major difference is that DataSets can hold multiple tables and you can define relationships between those tables.
If you are only retuning a single result set though I would think a DataTable would be more optimized. I would think there has to be some overhead (granted small) to offer the functionality a DataSet... |
A further and perhaps subtle difference is that in some database implementations the count(*) is computed by looking at the indexes on the table in question rather than the actual data rows. Since no specific column is specified, there is no need to bother with the actual rows and their values (as there would be if yo... |
Close and Dispose - which to call? |
|.net| |
|c#|.net| |
Here's my solution in c#
bool isPalindrome(string s)
{
string rev = string.Empty;
for (int i = s.Length - 1; i >= 0; i--)
{
char c = s[i];
rev += c;
}
return rev.Equals(s, StringComparison.CurrentCultureIgnoreCase);
} |
Here's my solution in c#
static bool isPalindrome(string s)
{
string allowedChars = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string compareString = String.Empty;
string rev = string.Empty;
for (int i = 0; i <= s.Length - 1; i++)
{
char c = s[i];
if (allowedChars... |
Here's my solution in c#
static bool isPalindrome(string s)
{
string allowedChars = "abcdefghijklmnopqrstuvwxyz"+
"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string compareString = String.Empty;
string rev = string.Empty;
for (int i = 0; i <= s.Length - 1; i++)
{
char c = s[i];
... |
I agree with the NHibernate approach and auto-database-generation. But, if you want to avoid writing a configuration file, and stay close to the code, use Castle's [ActiveRecord][1]. You declare the 'schema' directly on the class with via attributes.
[ActiveRecord]
public class User : ActiveRecordBase<User>... |
Here is an example of a for loop:
We have an array of items **nodes**.
for(var i = 0; i< nodes.length; i++){
var node = nodes[i];
alert(node);
} |
We have a similar set up as the one you are describing. We support at least 3 different platforms, so the we found that using [CMake](http://www.cmake.org/HTML/index.html) to mange the different Visual Studio solutions. Set up can be a bit painful, but it pretty much boils down to reading the docs and a couple of tutor... |
I would definitely go for a full Silverlight application, specially if you have good experience from WPF. You will be able to reuse your knowledge from WPF, and should be able to pick up Silverlight fairly quickly. I've been working with Silverlight since Beta 1, and the current Beta 2 is of solid quality. I guess it's... |
The previous comments have dealt with most of the downsides of using Silverlight for a site like this and I agree. If you're determined to have rich-client style development and your audience is small (for admins only) then I'd probably recommend WPF over Silverlight as it currently provides a richer set of tools and c... |
@Simon:
* The project is a Web Application. Websites are then slower to startup (I had no idea it had an incidence, beside the different code organization)?
* I checked, and while I edit the web.config after aspnet_compiler is called, I don't touch the debug value (I will however check the website is not faster to ... |
I agree with what everyone had said so far and I think this Flow Chart, which is aimed at Flash, also applies to Silverlight.
![alt text][1]
*[Source of Image][2]*
[1]: http://www.thegooglecache.com/flash-website-flowchart.jpg
[2]: http://www.thegooglecache.com/rants-and-raves/should-i-make-a-flash-site... |
Why not use just the same layout? Normally you won't need build because there's no compilation step, but the rest seems OK to me.
I'm not sure what you mean by a module but if it's just a single class a separate folder wouldn't be necessary and if there's more than one file you normally write a module-1.rb file (at ... |
Yes, as far as I understand they are only there for compatibility with existing products. You should always use the type safe version (i.e. use System.Collections.Generic over System.Collections).
http://msdn.microsoft.com/en-us/library/ms379564.aspx
|
Algorithm to generate anagrams.. |
|language-agnostic|algorithm|puzzle|problem-solving| |
What would be the best strategy to generate anagrams.
> An anagram is a type of word play, the result of rearranging the letters
> of a word or phrase to produce a new word or phrase, using all the original
> letters exactly once;
> ex.
>
> - **Eleven plus two** is anagram of ***Twelve plus... |
If possible, I also need to be able to drag column headers and make them row headers and have the data summarize and group accordingly. Something along the lines of old ActiveX DataDynamics Dynamicube.
http://www.datadynamics.com/Products/ProductOverview.aspx?Product=DC
Auto Summary, Filtering of the Data Items ... |
The netdom.exe command line program can be used. This is available from the Windows XP Support Tools or Server 2003 Support Tools (both on the installation CD).
Usage guidelines [here][1]
[1]: http://support.microsoft.com/kb/298593 |
Here's another way of doing it with a WHS script:
Set objWMIService = GetObject("Winmgmts:root\cimv2")
For Each objComputer in _
objWMIService.InstancesOf("Win32_ComputerSystem")
objComputer.rename "NewComputerName", NULL, NULL
Next
[Source](http://msdn.microsoft.com/en-us... |
In Python, how can you easily retrieve sorted items from a dictionary? |
|python|list|sorting|dictionary| |
Dictionaries unlike lists are not ordered (and do not have the 'sort' attribute). Therefore, you can not rely on getting the items in the same order when first added.
What is the easiest way to loop through a dictionary containing strings as the key value and retrieving them in ascending order?
For example, you ... |
|python|sorting|list|dictionary| |
Dictionaries unlike lists are not ordered (and do not have the 'sort' attribute). Therefore, you can not rely on getting the items in the same order when first added.
What is the easiest way to loop through a dictionary containing strings as the key value and retrieving them in ascending order by key?
For exampl... |
Having read the threads [Is SqlCommand.Dispose enough?][1] and [Closing and Disposing a WCF Service][2] I am wondering for classes such as SqlConnection or one of the several classes inheriting from the Stream class does it matter if I close Dispose rather than Close?
[1]: http://stackoverflow.com/questions/60919/... |
For SqlConnection, from the perspective of the connection itself, they are equivalent. According to Reflector, Dispose() calls Close() as well as doing a few additional memory-freeing operations -- mostly by setting members equal to null.
For Stream, they actually are equivalent. Stream.Dispose() simply calls Clos... |
Answering my question myself, I recently discovered [hgshelve](http://piranha.org.ua/blog/2008/05/19/hgshelve/) and [gitshelve](http://www.newartisans.com/blog_files/git.versioned.data.store.php) that is almost exactly what I was looking for.
|
Before ASP.NET v3.5 added routes you could create your own friendly URLs simply by writing an HTTPModule to and rewrite the request early in the page pipeline (like the BeginRequest event).
Urls like http://servername/page/Param1/SomeParams1/Param2/SomeParams2 would get mapped to another page like below (often using... |
When I looked into this a year ago, I came to the conclusion that it was not possible. It's worth noting that many Microsoft-supplied MSI files come in separate x86 and x64 flavors -- and presumably, they'd only deliver a single file if that were possible. |
I think PHP commonly runs as the user "nodody". Not sure about on Mac though. If Mac has whoami you could try <code>echo exec('whoami');</code> to find out. |
Consider two tables for People and their addresses:
People (pid, prefix, firstName, lastName, suffix, DOB, ... primaryAddressTag )
AddressBook (pid, tag, address1, address2, city, stateProv, postalCode, ... )
The Primary Key (that uniquely identifies each and every row) of People is `pid`. The PK of ... |
The non-generic collections are so obsolete that they've been removed from the CoreCLR used in Silverlight and Live Mesh. |
If I remember correctly from CS-class
Preconditions define on what conditions the output of your function is defined. If you make your function handle errorconditions your function is defined for those condition and you don't need the assert statement.
So I agree. Usually you don't need both. |
If I remember correctly from CS-class
Preconditions define on what conditions the output of your function is defined. If you make your function handle errorconditions your function is defined for those condition and you don't need the assert statement.
So I agree. Usually you don't need both.
As Rik commented ... |
Going forward only generic collections should be used. There is also the benefit of avoiding boxing/unboxing of types in the collection. This is ineffecient, especially when you have a collection of value types that are converted to System.Object when stored on the collection, hence storing the values on the heap inste... |
Why would you want to clone? Creating a new list usually makes more sense.
List<String> strs;
...
List<String> newStrs = new ArrayList<String>(strs);
Job done. |
I'm waiting for an IDE or an editor that always saves source code using some baseline formatting rules, but allows each individual developer to display and edit the code in their own preferred format. That way I can put my open curly brace at the beginning of the next line and not at the end of the current line where ... |
Also, keep in mind that there are different classes of iterators in C++. See the iterators concept in the [SGI Documentation](http://www.sgi.com/tech/stl/table_of_contents.html).
* Trivial Iterator
* Input Iterator
* Output Iterator
* Forward Iterator
* Bidirectional Iterator
* Random Access Iterator
These a... |
Yes, there is a large conceptual difference. C++ utilizes different "classes" of iterators. Some are used for random access (unlike Java), some are used for forward access (like java). While even others are used for writing data (for use with, say, `transform`).
See the iterators concept in the [SGI Documentation](... |
The three solutions you stated each cover very different needs.
**Manual parsing** (simple text search) is the most flexible and the most adaptable, however, it very quickly becomes a real pain in the ass as the parsing required is more complicated.
**Regex** are a middle ground, and probably your best bet here. ... |
Part of learning a new programming language is learning to read code in that language. A crutch like this may make it easier to read your own code, but it's going to impede the process of learning how to read anyone else's Python code. I really think you'd be better off getting rid of the end of block comments and ge... |
Good link from Prakash (I wasn't aware RCNr stuff - I thought those bytes were part of the facility - but that's only true in 16 bit windows it seems)
Often these unknown codes are specific to the interface/component you're using. The facility would be set to FACILITY_ITF. I have an old program HRPlus ([link?][1]) ... |
I've found the msdn xml best practices helpful for working with xml blob columns, might provide some inspiration...
http://msdn.microsoft.com/en-us/library/ms345115.aspx#sql25xmlbp_topic4 |
If you really need to do this from code, then an ORM is probably the way to go to try to keep it clean.
But I'd like to offer an alternative that works well and could avoid the performance problems that accompany dynamic queries, due to changing SQL that requires new query plans to be created, with different demands... |
The solution below uses the Win32 API. OnSessionLock is called when the workstation is locked, and OnSessionUnlock is called when it is unlocked.
[DllImport("wtsapi32.dll")]
private static extern bool WTSRegisterSessionNotification(IntPtr hWnd,
int dwFlags);
[DllImport("wtsapi32.dll")]
... |