instruction stringlengths 0 30k ⌀ |
|---|
|sql|tree| |
I need to sum points on each level earned by a tree of users. Level 1 is the sum of users' points of the users 1 level below the user. Level 2 is the Level 1 points of the users 2 levels below the user, etc...
What would the SQL look like to do it?
If you're confused, don't worry, I am as well!
User table:
... |
I need to sum points on each level earned by a tree of users. Level 1 is the sum of users' points of the users 1 level below the user. Level 2 is the Level 1 points of the users 2 levels below the user, etc...
The calculation happens once a month on a non production server, no worries about performance.
What woul... |
Your major issue is going to be that these are **Distributed** SCMs, and as such require a bit of a change to the user's mindset. Once people get used to the idea the technical details and usage patterns will fall into place, but don't underestimate that initial hurdle, especially in a corporate setting. Remember, all ... |
This is the fastest in-place method I've found (assuming a large proportion of duplicates):
def unique(l):
s = set(); n = 0
for x in l:
if x not in s: s.add(x); l[n] = x; n += 1
del l[n:]
This is 10% faster than Allen's implementation, on which it is based (timed with t... |
I have limited experience with Stingray.
However, I want to suggest trying CodeJock's Xtreme Toolkit Pro (http://www.codejock.com). Its GUI is very good and its supported very well. |
Are they defined in .cpp file as well? Roughly, it should look like:
struct Format
{
[...]
static Format gFmt128;
};
// Format.cpp
Format Format::gFmt128 = { 0, 128, 0 } |
The cleanest and simplest way is to use wxFileConfig class. |
VB.Net: I would use a [WaitOne][1] event handle.
VB 6.0: I've seen a DoEvents Loop.
Do
If isSomeCheckCondition() Then Exit Do
DoEvents
Loop
Finally, You could just sleep:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sleep 10000
[1]:... |
Have you tried just bypassing the queue altogether? (In CF Admin, under Mail Spool settings, uncheck "Spool mail messages for delivery.")
|
What tools and techniques do you use to fix browser memory leaks? |
|internet-explorer|memory|leaks| |
I am trying to fix memory leaks in IE 7. Using Drip for investigations but it is not helping much when most dynamically generated DOM elements do not have unique ids.
Tips? |
|javascript|memory|internet-explorer| |
How do I modify a ReadOnly Linq property |
|vb.net|linq-to-sql| |
I have a LINQ to SQL generated class with a readonly property:
<Column(Name:="totalLogins", Storage:="_TotalLogins", DbType:="Int", UpdateCheck:=UpdateCheck.Never)> _
Public ReadOnly Property TotalLogins() As System.Nullable(Of Integer)
Get
Return Me._TotalLogins
End Get
End Propert... |
I just realized that 3.5 SP1 includes new information in the exception that let me pin in down.
>SQL Server Compact timed out waiting for a lock. The default lock time is 2000ms for devices and 5000ms for desktops. The default lock timeout can be increased in the connection string using the ssce: default lock timeout ... |
You appear to not have any control over the thread that is rendering the screen but you do appear to have control of the spinner component. I would disable the spinner while the thread is rendering the screen. This way the user at least has some feedback relating to their actions. |
IANAL, But...
Java and C# are closed-source, and thus have terms in the EULA that say more-or-less "It's not our fault if you use this somewhere you're not supposed to". They also have teams of lawyers to protect themselves and enforce that clause.
Most open-source licenses do not have similar langauge, and even ... |
Static prevents another compilation unit from externing that variable so that the compiler can just "inline" the variable's value where it is used and not create memory storage for it.
In your second example, the compiler cannot assume that some other source file won't extern it, so it must actually store that value... |
Noel Llopis of *Games From Within* is the author of [Exploring the C++ Unit Testing Framework Jungle][1], a comprehensive (but now dated) evaluation of the various C++ Unit Testing frameworks, as well as a book on game programming. He used CppUnitLite for quite a while, fixing various things, but eventually joined for... |
Don't leave all the "boring" bits to the end - make sure that each component works, with regression tests and documentation, as early as possible in the project.
That said, the last few weeks are still going to involve chasing down the really elusive bugs, dealing with last-second requirements changes, finalising th... |
Don't leave all the "boring" bits to the end - make sure that each component works, with regression tests and documentation, as early as possible in the project.
That said, the last few weeks are still going to involve chasing down the really elusive bugs, dealing with last-second requirements changes, finalising th... |
WS-Security specifications are not typically contained in a WSDL (never in a WSE WSDL). So wsdl2java does not know that WS-Security is even required for this service. The fact that security constraints are not present in a WSE WSDL is a big disappointment to me (WCF will include WS-Trust information in a WSDL).
On t... |
Maybe the Frechet Distance is what your looking for?
http://www.cim.mcgill.ca/~stephane/cs507/Project.html
http://delaunay.tem.uoc.gr/~mkaravel/ewcg06/papers/25.pdf
|
we solved this problem by not asking for proxy passwords on rpm, apt or other similar updates (virus databases, windows stuff etc)
That's a small whitelist of known repositories to add to the proxy. |
the question has three subquestions:
1) choosing the secure transfer protocol
The secure version of old FTP exists - it's called FTP/SSL (plain old FTP over SSL encrypted channel). Maybe you can still use your old deployment infrastructure - just check whether it supports the FTPS or FTP/SSL.
You can check det... |
A better question is - why would you want to? If you are developing on your localhost then just use a relative path, if you're developing on an internet facing server - stick the dojo files on that.
Also - make sure you're not falling foul of the [same origin policy][1]
[1]: http://developer.mozilla.org/En/Sa... |
An additional benefit for Jython, at least for some, is <a href="http://zyasoft.com/pythoneering/2008/06/realizing-jython-25.html">it lacks the GIL</a> (the Global Interpreter Lock) and uses Java's native threads. This means that you can run pure Python code in parallel, something not possible with the GIL. |
Because of the braces around the anchor tag, that part is interpreted as a capture group. This causes only the capture group to be returned, and not the whole regex match.
Put the entire regex in braces and you'll see the right matches showing up as the first element in the returned tuples.
But indeed, you should... |
I don't know how to compare the files individually, since they are binary, but how about making a program that talks to MS Word, copying the contents of the files to a pure-text file? Then you could compare the plain-text files. |
Look at other libraries that were ported over to the PSP. Doing diffs between a linux version of a library, and a PSP version should show you.
Also, try to get to know how POSIX compatible the PSP is, that will tell you how big the job of porting the library over is. |
[Dev-C++][1] is a complete stand alone debugger compiler and linker, and also offers "IntelliSense". If you want to break away from VS (that also includes VS express) i suggest using this tool.
[1]: http://www.bloodshed.net/devcpp.html |
Have you looked at CONSTRAINT ... UNIQUE? |
[Versionate](http://www.versionate.com/) might do the trick. |
Okay, you got me working. The hard part is trying to match the exact usage pattern of C# events. If you skip that, there are MUCH easier ways to do what you're asking. (My co-worker Jason uses a Notifier object all over the place.) Anyway, here's the incredibly boring code which does what you want. Unfortunately, ... |
How do I use .Net Generics to inherit a template parameter? |
|c#|.net|generics| |
**I want to be able to do this.**
MyInterface interface = new ServiceProxyHelper<ProxyType>();
**Here's the object structure**
MyTypeThatImplementsMyInterface : MyInterface
**Will this work?**
public class ProxyType : MyInterface {}
public class ServiceProxyHelper<ProxyType> : IDispo... |
My preferred method is to use MSBuild, if you right click on a project and click 'unload' a new menu option will pop up that says 'edit <project name>'. Select that and it'll open up the project file so you can edit it, scroll down until you find a commented out section that is called "AfterBuild".
You can then add ... |
I've tried CPPunit and it's not very user friendly.
The only alternative I know is using C++.NET to wrap your C++ classes and writing unit tests with one of .NET unit testing frameworks (NUnit, MBUnit etc.) |
You need to declare your Format objects as **extern** not **static** |
If you are just starting out then I would change as little as possible (especially since you are the only developer), so stick with Sourcesafe. There is absolutely nothing wrong with it in your situation.
Later down the line, you might look towards the MS Team System, or perhaps go for other 3rd Party tools.
Pers... |
Thread.Sleep(50);
The thread will not be scheduled for execution by the operating system for the amount of time specified. This method changes the state of the thread to include WaitSleepJoin.
This method does not perform standard COM and SendMessage pumping.
If you need to sleep on a thread that has STAThr... |
There is no set literal so use what's easiest for you. For most people, that's either a string of the UTC output or an long-integer of the UTC-centered timecode.
Read this for a bit more background: http://msdn.microsoft.com/en-us/library/bb299886.aspx |
Check out Kenji Arisawa's [Pegasus](http://plan9.aichi-u.ac.jp/netlib/pegasus/) ([paper](http://lsub.org/iwp9/cready/pegasus-5.pdf)) webserver for Plan 9.
Plan 9 may have a reputation for being C-only, but several langauges, including Scheme, Ruby, Python, and Perl have been ported. Check out the [Contrib Index](htt... |
[UnitTest++][1], small & simple.
[1]: http://unittest-cpp.sourceforge.net/ |
One thing I like to do is create a bind function in JS (like what you can find in the prototype library) specifically for events, so that it passes the "event" object along to the bound function. Now, if you were to do this, you could simply throw in a trace call that will be invoked for every handler that uses it. And... |
Don't leave all the "boring" bits to the end - make sure that each component works, with regression tests and documentation, as early as possible in the project.
That said, the last few weeks are still going to involve chasing down the really elusive bugs, dealing with last-second requirements changes, finalising th... |
C# is the language of choice for Windows development, for me. I came from the same kind of background as you, and I found C# incredibly refreshing. I really love this language, and .NET is now my platform of choice. Plus, it's easy to keep in touch with your Unix roots via Mono development. Really, .NET is a great plat... |
Yes.
.Net 3.5 is mostly re-packaging and marketing. The .Net core within .Net 3.5 is actually .Net 2.0.
So any utility that you find for .Net 2.0 you can also apply to .Net 3.5.
For NUnit this means that the .Net 2 version is the one that you want. |
To answer your original question: Sessions are keyed to an id that is placed in a cookie. This id is generated using some random number crypto routines. It is not guaranteed to be unique but it is highly unlikely that it will ever be duplicated in the span of the life of a session. Even if your sessions run for full... |
Yes, .NET has the Common Language Runtime (CLR) which is the .NET equivalent to the JVM. Microsoft does not support it on as many platforms as Java but with the help of the [Mono project][1] it is possible to achive cross platform applications with the usual caveats.
Bear in mind that .NET is more than just the CLR.... |
Idiomatic code is code that does a common task in the common way for your language. It's similar to a design pattern, but at a much smaller scale. Idioms differ widely by language. One idiom in C# might be to use an iterator to iterate through a collection rather than looping through it. Other languages without ite... |
If the tables are connected by a foreign key, you can easily reference both tables as they will be joined by linq automatically (you can see easily if you look in your dbml and there is an arrow connecting the tables) - if not, see if you can add one.
To do that, you can just use something like this:
<%#... |
SELECT * FROM Items WHERE column LIKE '%foo%' OR column LIKE '%bar%' order by
( IF (column LIKE '%foo%',1,0) + IF (column LIKE '%bar%',1,0)) DESC
The syntax for if is
`IF ( condition, true_value, false_value )` |
SELECT * FROM Items WHERE column LIKE '%foo%' OR column LIKE '%bar%'
ORDER BY
(IF(column LIKE '%foo%',1,0) + IF(column LIKE '%bar%',1,0))
DESC
The syntax for if is
`IF ( condition, true_value, false_value )` |
PDB files are generated when you build your project. They contain information reltating the the built binaries which visual studio can interept and is able to link the call stack back to source.
When a program crashes and it generates a crash report, visual studio is able to take that report and link it back to sour... |
PDB files are generated when you build your project. They contain information reltating to the built binaries which visual studio can interept and is able to link the call stack back to source.
When a program crashes and it generates a crash report, and visual studio is able to take that report and link it back to s... |
Instead of tracking it yourself, I would encourage you to use a service like [FeedBurner][1]. Even if you don't want to use a 3rd party service it will give you an idea of what other people track for RSS feeds.
[1]: http://www.feedburner.com/ |
You could approach this by tokenizing a candidate string into <a href="http://en.wikipedia.org/wiki/Bigram">bigrams</a>—pairs of adjascent letters—and checking each bigram against a table of English bigram frequencies.
- Simple: if any bigram is sufficiently low on the frequency table (or outright abse... |
Batch source-code aware spell check |
|spell-checking| |
What is a tool or technique that can be used to perform spell checks upon a whole source code base and its associated resource files?
The spell check should be *source code aware* meaning that it would stick to checking string literals in the code and not the code itself. Bonus points if the spell checker understan... |
Passing parameters to start as a console or GUI application? |
|c#| |
Try this:
WebRequest request = WebRequest.CreateDefault(RequestUrl);
request.Method = "GET";
WebResponse response;
try { response = request.GetResponse(); }
catch (WebException exc) { response = exc.Response; }
if (response == null)
throw new HttpException((int)HttpStatusCod... |
Windows Forms is **by far** the nicest of those. However, using windows forms from C++ will just confuse you more if you don't already know what you're doing, because then you're really using C++/CLI, which might just as well be a completely different language. Better off going C# if you want to go that route.
MFC... |
how are you so sure that *all* URL longer than N is invalid? If you can be sure, then it shouldn't hurt to limit it just as a sanity check - but don't let this fool you into thinking you've prevented a class of exploit. |
as a PHP programmer, the way I see it, an Interface is basically used as a contract. It lets you say that everything which uses this interface MUST implement a given set of functions.
I dunno if that's all that useful, but I found it a bit of a stumbling block when trying to understand what Interfaces were all about... |
Ryan P [wrote](#79295):
> In this case the file is actually unlocked for a short period of time while the file is reopened.
So don’t do that. Instead, `open` a the file for read/write:
open my $fh, '+<', 'test.dat'
or die "Couldn’t open test.dat: $!\n";
When you are ready to write the counter, ... |
Ryan P [wrote](#79295):
> In this case the file is actually unlocked for a short period of time while the file is reopened.
So don’t do that. Instead, `open` the file for read/write:
open my $fh, '+<', 'test.dat'
or die "Couldn’t open test.dat: $!\n";
When you are ready to write the counter, ju... |
Google recently released their own library for unit testing C++ apps.
[Google test@google.code](http://code.google.com/p/googletest/) |
It doesn't matter, as long as you subscribe to the mailing list(wiki/irc/online-community-site) for the associated community. It's probably worth taking a look at the list description and archives to be sure you are in the right one.
Most of these are friendly and welcoming to newcomers, so don't be afraid to ask.
... |
Don't use the static keyword on global declarations. [Here is an article explain the visibility of variables with/without static](http://msdn.microsoft.com/en-us/library/s1sb61xd.aspx). The static gives globals internal linkage, that is, only visible in the translation unit they are declared in.
Skizz |
when reimporting your keys from the old keyring, you need to specify the command:
gpg --allow-secret-key-import --import <keyring>
otherwise it will only import the public keys, not the private keys. |
One thing to mention: Be a 100% sure that you understand what the program's doing and what's it supposed to do, before doing any changes. A 'bad' softwer often turns out to be 'not that bad' after understanding the whole situation.
Sourcesafe can be ok, especially for one person, but when there'll be more and more p... |
you can if you dont use the default alert boxes. Try using a javascript modal window which is just normal div markup that you can control the styling of. Look at blockui for jquery (there are loads of others) |
Export variable from C++ static library |
|c++|export| |
I have a static library written in C++ and I have a structure describing data format, i.e.<br><br>
<code>
struct Format{<br>
long fmtId;<br>
long dataChunkSize;<br>
long headerSize;<br>
bool operator==(Format const & other) const;<br>
};<br>
</code>
Some of d... |
I have a static library written in C++ and I have a structure describing data format, i.e.<br><br>
<code>
struct Format{<br>
long fmtId;<br>
long dataChunkSize;<br>
long headerSize;<br>
Format(long, long, long);<br>
bool operator==(Format const & ot... |
I have a console application that will be kicked off with a scheduler. If for some reason, part of that file is not able to be built I need a GUI front end so we can run it the next day with specific input.
Is there as way pass parameters to the application entry point to start the console application or the GUI ap... |
In the US the important law is [ITAR](http://www.pmddtc.state.gov/itar_index.htm). |
You should look into binary serialization and sending it over a TCP socket.
Good explanation on different types of serialization:
http://www.dotnetspider.com/resources/408-XML-serialization-Binary-serialization.aspx
Good primer on TCP Client/Server in C#:
http://www.codeproject.com/KB/IP/tcpclientserver.asp... |
I would say at least 8 *per core*, not per CPU. And I think 8 is a little low given modern CPU cores, I would say at least 12. |
There are not that much differences. Both are intermediate formats of the code you wrote. When executed, the Virtual machines will execute the intermediate language managed that means that the Virtual Machine controls the variables and calls. There is even a language which I don't remeber right now that can run at .Net... |
There are not that much differences. Both are intermediate formats of the code you wrote. When executed, the Virtual machines will execute the intermediate language managed that means that the Virtual Machine controls the variables and calls. There is even a language which I don't remeber right now that can run at .Net... |
Not sure exactly what you need. Below is an extract from one of my lo4net.config files:
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<param name="File" value="App_Data\log"/>
<param name="DatePattern" value=".yyyy-MM-dd-tt".log""/>
<param name=... |
I agree, FeedBurner is probably your best option, almost all large sites use it. |
WYSIWYG!!! I can't for the life of me get our designers to stop using nested DIVS and styled by elementID css in templates that are supposed to be used by clients in CMS projects. That's the whole point of a WYSIWYG online editor. You are controlling both the content and the layout at the same time! There is no separ... |
Be careful with hash_map though. begin() is not constant. |
Web Scripting for Java |
|java|scripting|jsp| |
What is a good way to render data produced by a Java process in the browser?
I've made extensive use of JSP and the various associated frameworks ([JSTL][1], [Struts][2], [Tapestry][3], etc), as well as more comprehensive frameworks not related to JSP ([GWT][4], [OpenLaszlo][5]). None of the solutions have ever bee... |
Is this related to the Configuration Manager? There you can select which projects in your solution build. Not sure if this helps. |
Further to ceejayoz's comment, you can also use ActionMailer to catch the replies that are sent back, and act on them - you'll need some form of unique id in a place that will be included in the reply though. |
Guido's explanation is <a href="http://mail.python.org/pipermail/python-3000/2006-November/004643.html">here</a>:
> First of all, I chose len(x) over x.len() for HCI reasons (def \_\_len\_\_() came much later). There are two intertwined reasons actually, both HCI:
> (a) For some operations, prefix notation just r... |
calling echo on an array will always output "Array".
print_r (from the PHP manual) prints human-readable information about a variable. |