instruction stringlengths 0 30k ⌀ |
|---|
Here's my test code:
function test1() {
for (var i = 0; i < 1000000; ++i) {
myFunc();
}
}
function test2() {
for (var i = 0; i < 1000000; ++i) {
(function() {
var x = 0;
x++;
})();
}
... |
Here's my test code:
var dummyVar;
function test1() {
for (var i = 0; i < 1000000; ++i) {
dummyVar = myFunc;
}
}
function test2() {
for (var i = 0; i < 1000000; ++i) {
dummyVar = function() {
var x = 0;
x++;
... |
[http://www.codeplex.com/csparser][1]
[1]: http://www.codeplex.com/csparser |
I'm not sure what version of Oracle you are running. On older version of Oracle (pre 9i Advanced Security) some DBA's would `CREATE USER OPS$SCOTT IDENTIFIED BY EXTERNALLY` and set `REMOTE_OS_AUTHENT` to true.
This would mean that your remote sun machine could authenticate you as SCOTT and then your Oracle DB would ... |
The reason the nested block doesn't get replaced is because the match, for [b], places the position after [/b]. Thus, everything that ((.){1,}?) matches is then ignored.
It is possible to write a recursive parser in server-side -- Perl uses [qr//][1] and Ruby probably has something similar.
Though, you don't nece... |
Start off simple. Do not not scare her with an IDE! They are overwhelming at first and are not core to developing software. I learnt rudimentary Java with [Crimson Editor][1].
If I started again I'd probably go for [Notepad++][2].
[1]: http://www.crimsoneditor.com/
[2]: http://notepad-plus.sourceforge.net/ |
It's not in general possible to know the amount of data you can read from a pipe just from the pipe handle alone. The data may be coming in across a network, or being dynamically generated by another process. If you need to know up front, you should arrange for the information to be sent to you - through the pipe, or o... |
Just iterate over a list of files:
files=( frame-*.jpg )
i=0
while [[ $i -lt ${#files} ]] ; do
cur_file=${files[$i]}
mungle_frame $cur_file
i=$( expr $i + 4 )
done
|
There is no generic, portable way to tell how much data is available in a pipe without reading it. At least not under POSIX specifications.
Pipes are not seekable, and neither is it possible to put the data back into the reading end of a pipe.
Platform-specific tricks might be possible, though. If your question i... |
I don't think it is possible, isn't the point of a pipe to provide interprocess communication between the two ends (in one direction). If I'm correct in that assertion, the send may not yet have finished pushing data into the pipe -- so it'd be impossible to determine the length.
What platform are you using? |
Unfortunately the system cannot always know the size of a pipe - for example if you are piping a long-running process into another command, the source process may not have finished running yet. In this case there is no possible way (even in theory) to know how much more data is going to come out of it.
If you want t... |
It's been a while since I've had to do this, but I seem to recall having to use a javascript snippet to execute the carrage return as opposed to using the Selenium keypress function. |
For the fixed function pipeline, the lights position and direction are set in world space. The docs for the light structures do tell you that, but I'm not surprised that you missed it in the docs. There's not much information on the fixed function pipeline anymore as the focus has to programmable shaders. |
In my experience TFS can track renames, as long as you do all the renaming within the SourceControlExplorer (TFS).
The problems tend to occur when you have other people making changes to the original files while someone else is doing massive renames/moves, while someone else is editing the renamed version.
Wher... |
@[Jeff Hubbard]:
> What's happening is my code crashes under a debug compilation, but succeeds under a release compilation. I've checked it under a debugger and my pointers are getting set to 0xFEEEFEEE after I call delete on them. Again, same code on release doesn't crash and behaves as expected.
This is very st... |
WPF enables you to do some amazing things, and I LOVE it... but I always feel obligated to qualify my recommendations, whenever developers ask me whether I think they should be moving to the new technology.
Are your developers willing (preferrably, EAGER) to spend the time it takes to learn to use WPF effectively? ... |
First thing you should ask yourself is, "Do I really need to make my own?"
Depending on what you want to use it for, you are probably better off using a common format and some pre-made libraries which already handle one of those formats very well.
Good places to start:
http://www.destructor.de/libtar/index.htm ... |
I have attempted this before and in the end you do need to rewrite it as Biri has said.
I did quite a bit of this work when our company was upgrading from Windows NT to Windows XP. I often found that it is easier not to look at the old code at all and start again from scratch. You can spend so much time trying to ... |
I have attempted this before and in the end you do need to rewrite it as Biri has said.
I did quite a bit of this work when our company was upgrading from Windows NT to Windows XP. I often found that it is easier not to look at the old code at all and start again from scratch. You can spend so much time trying to ... |
For Russian-speaking community is definitely:
http://it4business.ru/forum/index.php?showforum=192
But I think everybody knows that :) |
J2EE App Server Hollo World |
|jakarta-ee|java|getting-started| |
I am fairly comfortable with standalone Java app development, but will soon be working on a project using a J2EE application server.
Does anyone know of a straightforward how-to tutorial to getting a hello-world type application working in an application server? I'm (perhaps naievly) assuming that the overall approa... |
J2EE App Server Hello World |
|java|jakarta-ee|getting-started| |
DDL statements are inherently database-vendor specific. Although they have the same basic structure, each vendor has their own take on how to define types, indexes, constraints, etc.
DML statements on the other hand are fairly portable. Therefore I suggest:
* Dump the database without any data (mysqldump --no-da... |
You can also, derive the TextBox class and grab the keypad event and ensure nothing other than numbers is written.
If it were a Web page, the same would have been done to an html text box using Javascript. |
NetTiers is very good for generating a heavy and robust DAL, and we use it internally for core libraries and frameworks.
As I see it, LINQ (in all its incarnations, but specifically as I think you're asking to SQL) is fantastic for quick data access, and we generally use it for more agile cases.
Both technologies... |
You will find the answers to this in <a href="http://www.faqs.org/rfcs/rfc1918.html">RFC 1918</a>. Though, I have listed them below for you.
10.0.0.0 - 10.255.255.255 (10/8 prefix)
172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
192.168.0.0 - 192.168.255.255 (192.168/16 pref... |
You will find the answers to this in <a href="http://www.faqs.org/rfcs/rfc1918.html">RFC 1918</a>. Though, I have listed them below for you.
10.0.0.0 - 10.255.255.255 (10/8 prefix)
172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
192.168.0.0 - 192.168.255.255 (192.168/16 pref... |
Enabling single sign-on between Desktop Application and Website |
|.net|asp.net| |
We have a client/server application with a rich client front end (in .Net) and also an administration portal (Asp.Net). Currently users have to sign on in both the rich client and on the website. We'd like to enable them to sign into the rich client, but not have to sign on to the website if they launch it from within... |
> The sizeof(1) is presumably the size of an integer on the platform you are compiling on, probably either 4 or 8 bytes.
Note that I'm NOT taking sizeof(1), which is effectively sizeof(int). Look close, I'm taking sizeof(f.x = 1), which should effectively be sizeof(bitfield_type).
I'd like to see a reference to s... |
If you know the window's title, you can use the Win32 call, FindWindow, through P/Invoke.
You can find the signature [here][1] on pinvoke.net
[1]: http://pinvoke.net/default.aspx/user32/FindWindow.html |
frameworks exist to encapsulate common functionality; this will never change
and what makes you think moore's law is dead? with MIT students growing bacteria that self-assemble nanowire circuits, moore's not dead yet... |
Latest version of Geany supports it (only on Linux, though) |
What you're looking for regardin the files in use is the "<a href="http://msdn.microsoft.com/en-us/library/bb968832(VS.85).aspx" title="MSDN - Volume Shadow Copy Service">Volume Shadow Copy Service</a>" which is available on Windows XP, Server 2003 and above. This will allow you to copy files even when they ... |
What you're looking for regarding the files in use is the "<a href="http://msdn.microsoft.com/en-us/library/bb968832(VS.85).aspx" title="MSDN - Volume Shadow Copy Service">Volume Shadow Copy Service</a>" which is available on Windows XP, Server 2003 and above. This will allow you to copy files even when they... |
gdb -tui works okay if you want something GUI-ish, but still character based. |
Test framework for black box regression testing |
|embedded|test|regression-test| |
I am looking for a tool for regression testing a suite of equipment we are building.
The current concept is that you create an input file (text/csv) to the tool specifying inputs to the system under test. The tool then captures the outputs from the system and records the inputs and outputs to an output file.
The... |
|embedded|test|regression-test| |
I am looking for a tool for regression testing a suite of equipment we are building.
The current concept is that you create an input file (text/csv) to the tool specifying inputs to the system under test. The tool then captures the outputs from the system and records the inputs and outputs to an output file.
The... |
http://us3.php.net/reset
Only available in php version 5. |
How does your company manage credentials? |
|authentication|passwords|credentials| |
This is a call for suggestions and even possible solutions. I haven't been at a company that really seemed to get credential management 'right'.
I've seen excel/word documents and even post-it note 'solutions'.
But my main question is what is the right way to do it?
I have initially thought it would revolve ar... |
While it was more logic than programming per se, one I really enjoyed back in elementary school was [Rocky's Boots][1]. It had sensors, AND gates, OR gates, NOT gates, wires, timers, and all sorts of other stuff. Fantastic program for teaching a kid logic.
Go to the link and you can still play it!
[1]: http:/... |
I haven't used VB.NET since moving to C# 3.0, but it seems like it could be a type inference issue. The error is a bit odd since List implements IList, so the assignment should work. You can say "p.ID = 123" for the lambda and things seem to work.
For anyone else interested in looking into it, here is code that you... |
Opening sockets in python is pretty simple. You really just need something like this:
import socket
sock = socket.socket()
sock.connect((address, port))
and then you can send() and receive() like any other socket
|
Another vote for Oracle SQL Developer. It's free, it's stable and it does all the basics that I require. |
In a [recent episode of DotNetRocks!][1] Brian Randell and Martin Woodward are of the opinion that in adopting a new Source Control / SCM system you're probably better off starting from a clean slate (begin with the most recent release and don't try to migrate history, and use the original system for read-only viewing ... |
.NET Framework versions |
|.net|installation|framework| |
I've had a little search and I was wondering if there is back compatibility for the .NET framework.
The real question is, if there's a program that uses .NET Framework 1.1, can I install 3.5 and be done, or do I have to install 1.1 and then if something uses 3.5 I have to install 3.5 as well? |
For Java, BlueJ is an excellent teaching IDE. It doesn't confuse the new student with a lot of advanced functionality (stuff they won't use for years to come). Eclipse is a great IDE, but there is a LOT of stuff there they could drown in. The same is true for Visual Studio, but I don't know of a simpler IDE for .NET... |
The best, most documented, IDE that is free in my opinion is Visual Studio Express. There are tons of blogs, howtos, videos, training, etc. You can find more information about them here:
<http://www.microsoft.com/Express/>
Also, if you are a student, Microsoft provides an entire stack of software free to student... |
the simple way
Change to DB directory:
cd /var/lib/mysql/
Shut down SQL...this is important!
/etc/init.d/mysql stop
Rename Database:
mv old-name new-name
...or the table...
cd database/
mv old-name.frm new-name.frm
mv old-name.MYD new-name.MYD
mv old-name.MYI new-name.MYI
Res... |
the simple way
Change to DB directory:
cd /var/lib/mysql/
Shut down SQL...this is important!
/etc/init.d/mysql stop
Okay,this way doesn't work for InnoDB or BDB-Databases
Rename Database:
mv old-name new-name
...or the table...
cd database/
mv old-name.frm new-name.frm
mv old-na... |
minifying and gzipping commonly called scripts and style sheets is totally worthwhile - the file size reduction speaks for itself. That's something that you can do through your webserver, without the help of another product.
However, merging scripts and styles and serving them together is an interesting idea from a ... |
I would suggest using [SubSonic][1] to generate your data access code and scaffold your screens.
[1]: http://subsonicproject.com/ |
All of these solutions check that two arrays are equal. They don't check that they are the same object. The only way I know to do that in native CF is to change the object in some way and see if both references have the change in.
I also think that you should be wary of relying on CF implementing certain java class... |
[Mono][1] (open source) includes C# compiler (and of course parser)
[1]: http://www.mono-project.com/ |
As so many people have listed Head First Design Patterns, which I agree is a very good book, I would like to see if so many people aware of a title called [Design Patterns Explained: A New Perspective on Object-Oriented Design][1].
This title deals with design patterns excellently. The first half of the book is ver... |
[SharpDevelop][1], an open source IDE, comes with a visitor-based code parser which works really well. It can be used independently of the IDE.
[1]: http://www.icsharpcode.net/OpenSource/SD/ |
If the only difference between the existing dataset and the new one is an added field then you can "upgrade" them by writing out the old ones and XML and then reading that into the new ones. The value of the added field will be DBNull.
MyDataSet myDS = new MyDataSet();
MyDataSet.MyTableRow ... |
If You want a even faster cursor than FAST FORWARD then use a STATIC cursor. They are faster than FAST FORWARD. Not extremely faster but can make a difference. |
How do I get my c# program to sleep for 50 msec? |
|c#| |
This might seem an easy question, but Im having a temporary brain failure moment! |
Most of the time I test Servlets and JSP's via 'Integration Tests' rather than pure Unit Tests. There are a large number of add-ons for JUnit/TestNG available including:
- HttpUnit (the oldest and best known, very low level which can be good or bad depending on your needs)
- HtmlUnit (higher level than HttpUn... |
The JavaEE (they dropped the 2) space is pretty big. A good tutorial to start is [the one from Sun][1]. For a simple hello world application, the web container only would suffice. A well known servlet jsp container is tomcat. See [here][2] for installation instructions. Try installing it with eclipse and create a web p... |
##Recursively in Inform 7
(it reminds you of COBOL because it's for writing text adventures; proportional font is deliberate):
> To decide what number is the factorial of (n - a number):
> if n is zero, decide on one;
> otherwise decide on the factorial of (n minus one) times n;
If you want to actually call th... |
Here is my own solution
<pre><code>
class CoordGenerator
{
public:
CoordGenerator(int _from, int _to, int _step)
:from(_from), to(_to), step(_step), pos(_from){}
virtual POINT GetPoint00() const = 0;
virtual POINT GetPoint01() const = 0;
bool Next()
{
if(pos > step) return false;
pos += step;
... |
Elegant method for drawing hourly bar chart from time-interval data? |
|sql|excel|charts| |
I have a list of timesheet entries that show a start and stop time. This is sitting in a MySQL database. I need to create bar charts based on this data with the 24 hours of the day along the bottom and the amount of man-hours worked for each hour of the day.
For example, if Alice worked a job from 15:30 to 19:30 and... |
I have a list of timesheet entries that show a start and stop time. This is sitting in a MySQL database. I need to create bar charts based on this data with the 24 hours of the day along the bottom and the amount of man-hours worked for each hour of the day.
For example, if Alice worked a job from 15:30 to 19:30 and... |
Thanks folks.
I got things to work by using **[prototype][1]** and changing **document.getElementById(oldkey)**
to **$(oldkey)**
<script src="j/prototype.js" type="text/javascript"></script>
var newBox;
var sourceBox = $(oldkey);
if (sourceBox.cloneNode)
newBox = ... |
I would definately recommend EJB3 over spring. We find that it's more streamlined, nicer to code in, and better supported. I have in the past used Spring and found it to be very confusing, and not as well documented as EJB3 (or JPA I guess at the end of the day)
1. As of EJB3 you no longer have to deal with external... |
HttpUtility.ParseQueryString will work as long as you are in a web app or don't mind including a dependency on System.Web. Another way to do this is:
NameValueCollection queryParameters = new NameValueCollection();
string[] querySegments = queryString.Split('&');
foreach(string segment in querySegments... |
Most USB chipsets come with drivers. [Silicon Labs][1] has one.
[1]: https://www.silabs.com/products/mcu/usb/Pages/default.aspx |
You might be able to do it manually, but you'd just be implementing the same algorithm that's already there for you. It's generally a bad idea to disable the ViewState validation on a page. |
In addition to need to be aware of a gotcha. Any class that you pass around as the DataObject in the drag/drop operation has to be Serializable. So if you try and pass an object and it is not working ensure it can be serialized as that is almost certainly the problem. This has caught me out a couple of times! |
It's probably not a recommended practice to do so: see http://msdn.microsoft.com/en-us/library/ms229017(VS.85).aspx |
phone.dial() +1.
What is the variant state or behavior of a PhoneNumber? The only thing that comes to mind are "dialing rules" (dial country code if outside, dial "9" to get outside line, etc.). That context seems well suited to the Phone.
If your object model doesn't require variance -- a number is just a sequ... |
What about something like this?
strings = %w(Tony Tiny Tory Tily)
positions = Hash.new { |h,k| h[k] = Hash.new { |h,k| h[k] = 0 } }
strings.each { |str|
0.upto(str.length-1) { |i|
positions[i][str[i,1]]+=1
}
}
At the end of execution, the result will be:
positio... |
##Recursively in Inform 7
(it reminds you of COBOL because it's for writing text adventures; proportional font is deliberate):
> To decide what number is the factorial of (n - a number):<br>
> if n is zero, decide on one;<br>
> otherwise decide on the factorial of (n ... |
System.Threading.Thread.Sleep(50);
Remember though, that doing this in the main GUI thread will block your GUI from updating (it will feel "sluggish") |
Use this code
using System.Threading;
// ...
Thread.Sleep(50);
|
Java is not significantly different from C#. On a purely syntactic level, here are some pointers that may get you through the day:
1. In Java you have two families of exceptions: <tt>java.lang.Exception</tt> and everything that derives from it, and <tt>RuntimeException</tt>. This is meaningful because in Java except... |
If you're using Sun Java 6, then the most recent JDK releases come with [JVisualVM][1] in the bin directory. This is a capable monitoring and profiling tool that will require very little effort to use - you don't even need to start your program with special parameters - JVisualVM simply lists all the currently running... |
Best way to validate drag/drop operations for a TreeView in C# |
|c#|validation|user-controls|treeview| |
I want to verify a drag & drop operation is allowed. A valid item can come from another one of our "controls", or internally from within the custom treeview. Currently I have this:
bool CanDrop(DragEventArgs e)
{
bool allow = false;
Point point = tree.PointToClient(new Point(e.X, e.Y));
... |
If the only difference between the existing dataset and the new one is an added field then you can "upgrade" them by writing out the old ones to XML and then reading that into the new ones. The value of the added field will be DBNull.
MyDataSet myDS = new MyDataSet();
MyDataSet.MyTableRow r... |
You could add a token, to identify them, to the URL which opens the site.
You'll have to add some security to the token: TTL, a hash, a salt |
How about (something based on) the Algorithm pattern?
One superclass knows how to rip apart the class hierarchy, but relies on its subclasses to actually do something useful with it. |