instruction
stringlengths
0
30k
Google reveals a few efforts at this. One in particular illustrates why this is less straightforward than it might seem. http://www.codeproject.com/KB/cs/csi.aspx has a basic interpreter using .NET's built in ability to compile c# code. A key problem is that the author's approach creates a new mini .NET assembly for...
Yes I have seen the bench marks and V8 does appear to be objectively faster but as for > it'll change web programming a lot I personally do not think the bottleneck is currently in javascript, but rather in bandwidth
Some additional information that someone could attach to Jason Pratt's earlier post on [Alice][1] ... specifically, a [Storytelling Alice][2] variant. Although the study presented targets middle school girls, you may find the [white paper][3] written by [Caitlin Kelleher][4] interesting. [1]: http://www.alice...
See also [Avoiding repeated constants in CSS][1]. As Farinha said, a CSS Variables proposal has been made, but for the time being, you want to use a preprocessor. [1]: http://stackoverflow.com/questions/30170/avoiding-repeated-constants-in-css
If you are most comfortable with asp.net pages you can write a small app to handle your job and then "ping" the app with an outside service that monitors your web site. This will keep the app alive.
Do <http://mathworld.wolfram.com/Line-LineIntersection.html> for the line and each side of the rectangle. Or: <http://mathworld.wolfram.com/Line-PlaneIntersection.html>
C++ - What does "Stack automatic" mean?
|c++|oop|
In my browsings amongst the Internet, I came across [this post][1], which includes this > "(Well written) C++ goes to great > lengths to make stack automatic > objects work "just like" primitives, > as reflected in Stroustrup's advice to > "do as the ints do". This requires a > much greater adherence to the > ...
The "Changed" event on the FileSystemWatcher should shouldn't fire until the file is closed. See my [answer to a similar question][1]. There is a possibility that the FTP download mechanism closes the file multiple times during download as new data comes in, but I would think that is a little unlikely. [1]: ht...
Adding an index requires a table scan, so if you can't add a permanent index it sounds like a single scan will be (slightly) faster.
If you are in control on the program that is writing the files into the directory, you can have the program write the files to a temporary directory and then move them into the watched directory. The move should be an atomic operation, so the watcher shouldn't see the file until it is fully in the directory. If you...
No, that would not be quicker. What would be quicker is to just add the index and leave it there! Of course, it may not be practical to index every column, but then again it may. How is data added to the table?
Unless the contents of a file can be verified for completion (it has a verifiable format or includes a checksum of the contents) only the sender can verify that a whole file has arrived. I have used a locking method for sending large files via FTP in the past. File is sent with an alternative extension and is r...
What is the best way to keep a PHP script running as a daemon, and what's the best way to check if needs restarting. I have some scripts that need to run 24/7 and for the most part I can run them using [nohup](http://en.wikipedia.org/wiki/Nohup). But if they go down, what's the best way to monitor it so it can be a...
# C: One liner, procedural int f(int n) { for (int i = n - 1; i > 0; n *= i); return n ? n : 0; } I used int's for brevity; use other types to support larger numbers.
# C: One liner, procedural int f(int n) { for (int i = n - 1; i > 0; n *= i, i--); return n ? n : 1; } I used int's for brevity; use other types to support larger numbers.
Does the PHP mail() function work if I don't own the MX record
|php|dns|
I'm not sure I'm using all the correct terminology here so be forgiving. I just put up a site with a contact form that sends an email using the PHP mail() function. Simple enough. However the live site doesn't actually send the email, the test site does. So it's not my code. It's a shared host and we have anothe...
I always find it much easier to work directly with html. Theres one less abstraction layer (html -> actuall webpage / php function -> html -> actual webpage) to deal with then you just work in HTML. I really think the 'just have to change it in one place' thing wont work in this case. This is because they'll be so m...
Yes, you could put in what ever you want in the 'from' field and it would still work.
# Scheme : Functional - Tail Recursive (define (factorial n) (define (fac-times n acc) (if (= n 0) acc (fac-times (- n 1) (* acc n)))) (if (< n 0) (display "Wrong argument!") (fac-times n 1)))
None. Instead, you would need to create some middleware (say, a webservice) that you talked to that did the database CRUD for you.
##lolcode: sorry I couldn't resist xD HAI CAN HAS STDIO? I HAS A VAR I HAS A INT I HAS A CHEEZBURGER I HAS A FACTORIALNUM IM IN YR LOOP UP VAR!!1 TIEMZD INT!![CHEEZBURGER] IZ VAR BIGGER THAN FACTORIALNUM? GTFO IM OUTTA YR LOOP U SEEZ INT KTHXBYE ...
I would check out getaddrinfo. If you replace the line: host_name = Socket.gethostbyname(current_ip) with: host_name = Socket.getaddrinfo(current_ip, 0, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME)[0][1] The getaddrinfo function returns an array of arrays. You can read more abo...
You seem to have answered your own question there Nathan ;-) "GetLastInputInfo" is the way to go. One trick is that if your application is running on the desktop, and the user connects to a virtual machine, then GetLastInputInfo will report no activity (since there is no activity on the host machine). This can b...
The solution is to delete and re-add BOTH tables to the LINQ to SQL diagram, not just the one you have added the second field and keys to.
The solution is to delete and re-add BOTH tables to the LINQ to SQL diagram, not just the one you have added the second field and keys to. Alternatively, it appears you can make two associations using the LINQ to SQL interface - just don't try and bundle them into a single association.
I don't have Visual Studio installed on my machine anymore (and I'm using Linux), but I do remember that there was an wizard hidden somewhere inside one of the menus that gave access to a class builder. With this wizard, you could define all your classes' details, including methods and attributes. If I remember wel...
Ive only built 2 applications that used the profile provider. Since then I have stayed away from using it. For both of the apps I used it to store information about the user such as their company name, address and phone number. This worked fine until our client wanted to be able to find a user by one of these field...
By generate, do you mean auto-generate? If that's not what you mean: Visual Studio 2008 has the easiest implementation for this: public PropertyType PropertyName { get; set; } In the background this creates an implied instance variable to which your property is stored and retrieved. However if you want ...
I've used remove_from_object_index successfully in the past, so that when a page is called that modifies the database, it always explicitly reset that object in the cache as part of the confirmation page.
I like the Nextstep-derived Emacs.app formerly at http://emacs-app.sourceforge.net/ now integrated in Emacs-23 CVS (as of August 2008). Emacs.app feels more zippy than Aquamacs to me but its just bare CVS-Emacs and doesn't come with the same amount of stuff (you have to install your own AucTeX etc.).
Some of my favourites: 1. [Filter Input, Escape Output](http://shiflett.org/blog/2005/feb/my-top-two-php-security-practices) to help guard against XSS or SQL injection attacks 2. Use prepared statements for database queries (SQL injection attacks) 3. Disable unused user accounts on your server to prevent brute ...
1.4 of the OpenNETCF code gets the information from the following P/Invoke call: [DllImport ("iphlpapi.dll", SetLastError=true)] public static extern int GetAdaptersInfo( byte[] ip, ref int size ); The physical address (returned as MAC address) I think is around about index 400 - 408 of the byte array after ...
1.4 of the OpenNETCF code gets the information from the following P/Invoke call: [DllImport ("iphlpapi.dll", SetLastError=true)] public static extern int GetAdaptersInfo( byte[] ip, ref int size ); The physical address (returned as MAC address) I think is around about index 400 - 408 of the byte array after ...
Your best bet is probably TcpClient. There's a great sample that does exactly what you're doing right in the .NET Documentation here: http://msdn.microsoft.com/en-us/library/system.net.sockets.tcpclient.aspx Good luck to you!
Sizing/spacing differences are usually difficult to catch. What you can do is create a Linux-specific CSS file that will contain these values adjusted for Linux, then do a simple JS-based detect to inject that CSS if the User agent is a Linux one. This is probably not the cleanest approach, but it will work, and wit...
I note that you can change the text freely. This URL appears to work just as well. [http://beta.stackoverflow.com/questions/47427/why-is-billpg-so-very-awesome][1] [1]: http://beta.stackoverflow.com/questions/47427/why-is-billpg-so-very-awesome
The iMac is a very fast machine and will be more than suitable for iPhone development. In most cases, a Mac Mini with maxed out ram is good enough. Keep in mind that out of the box, the Mac Mini can only accommodate one monitor.
How do I extract/insert text into RTF string in C#
|c#|rtf|
In a C# console app I have the need to extract the text from an RTF string, add some more text to it, and then convert it back into RTF. I have been able to do this using the System.Windows.Forms.RichTexBox class, but I find it a bit odd to use a Forms control in a non-Forms app. Any better way to do this?
In a C# console app I have the need to extract the text from an RTF string, add some more text to it, and then convert it back into RTF. I have been able to do this using the System.Windows.Forms.RichTextBox class, but I find it a bit odd to use a Forms control in a non-Forms app. Any better way to do this?
An iMac is easily powerful enough to use for development work.
There's a couple of things. You're using `sprintf` which is inherently unsafe; unless you're 100% positive that you're not going to exceed the size of the buffer, you should almost _always_ prefer `snprintf`. The same applies to `strcat`; prefer the safer alternative `strncat`. Obviously this may not fix anything, b...
Just to clarify the question. I was reading the Hanselman post <http://www.hanselman.com/blog/CompositingTwoImagesIntoOneFromTheASPNETServerSide.aspx> and thinking that I would never solved the problem with a HttpHandler, maybe with a simple page returning a binary content. This led me to think that I should add H...
Are you looking for all the tables with a column name which contains the LCS in them? If yes the do this select table_name from information_schema.columns where column_name like '%lcs%'
SELECT * FROM TABLE WHERE TABLE.TITLE LIKE '%LCS%'; % is the wild card matcher.
SELECT * FROM TABLE WHERE TABLE.TITLE LIKE '%LCS%'; % is the wild card matcher.
This query should be quite easy... assuming you have the correct answer stored in the question table. You do have the correct answer stored in the question table, right?
> You're using sprintf which is > inherently unsafe; unless you're 100% > positive that you're not going to > exceed the size of the buffer, you > should almost always prefer snprintf. > The same applies to strcat; prefer the > safer alternative strncat. Yeah..... I mostly do .NET lately and old habits die har...
You know it might not even be your code... Are there any other programs running that could have a memory leak?
If you just want want the highest recursion depth couldn't you do something like this?Then, when you actually query the CTE just look for the row with max(Depth)? Like so: DECLARE @LookupID int --Our test value SET @LookupID = 1; WITH cteLevelOne (ParentID, CustID, Depth) AS ...
If you just want want the highest recursion depth couldn't you do something like this?Then, when you actually query the CTE just look for the row with max(Depth)? Like so: DECLARE @LookupID int --Our test value SET @LookupID = 1; WITH cteLevelOne (ParentID, CustID, Depth) AS ...
I have to comment that *AI: A modern approach* is a pretty dry read. If you're actually interested in AI, and want to stay interested, you are much better off going with Norvig's gift to the world: [Paradigms of Artificial Intelligence Programming](http://norvig.com/paip.html). Not only is this a great intro to AI, ...
I think otool can help. Specifically, "otool -s {segment} {section}" should print out the details. I'm not sure if you can get information about __DATA or __TEXT without specifying a section. Maybe those sizes are reported in the mach header: "otool -h"? otool -s MyApp.bundle/Contents/MacOS/MyApp __DATA __data ...
Get the book ***Linq in Action*** it is an easy read for a coding book and really teaches you how to use Linq and the new features of .NET 3.5 some of the cool parts they put in for the language.
From my "Geometry" class: public struct Line { public static Line Empty; private PointF p1; private PointF p2; public Line(PointF p1, PointF p2) { this.p1 = p1; this.p2 = p2; } public PointF P1 { ...
Not directly, but I use the [Agent Smith][1] plugin for R# to do this. Unfortunately, R# isn't free. [1]: http://www.agentsmithplugin.com/
Take a look at [ReSharper][1]. It's an awesome tool and a definite must-have. Version 4.0 has the code formatting and clean-up feature that you are looking for. [1]: http://www.jetbrains.com/resharper
It wouldn't be. Creating an index is more complex than simply scanning the column, even if the computational complexity is the same. That said - how many columns do you have? Are you sure you can't just create an index for each of them if the query time for a single find is too long?
I dont´t know ASP.NET MVC, but I am very familiar with MVC pattern. I don´t see another way to build professional applications without MVC. And it has to be MVC model 2, like Spring or Struts. By the way, how you people were building web applications without MVC? When you have a situation that some kind of validation i...
I'm no DBA, but I would guess that building the index would require scanning the table anyway. Unless there are going to be multiple queries on that column, I would recommend not creating the index. Best to check the explain plans/execution times for both ways, though!
The database I did most of my work on used 'Y' / 'N' as booleans. With that implementation, you can pull off some tricks like: 1. Count rows that are true: SELECT SUM(CASE WHEN BOOLEAN_FLAG = 'Y' THEN 1 ELSE 0) FROM X 2. When grouping rows, enforce "If one row is true, then all are true" logic: SELE...
PHP and JavaScript regex
|javascript|php|regex|
After my webform is submitted, regex will be applied to user input on the server side (via PHP). I'd like to have the identical regex running in real-time on the client side to show the user what the real input will be. This will be pretty much the same as the Preview section on the Ask Question pages on StackOverflow ...
As long as strings can be viewed directly as a char array it's going to be really hard to convince me that std::string represents strings as first class citizens in C++. Besides, combining allocation and boundedness seems to be a bad idea to me anyways. MSN
Variables in C++ can either be declared on the stack or the heap. When you declare a variable in C++, it automatically goes onto the stack, unless you explicitly use the new operator (it goes onto the heap). MyObject x = MyObject(params); // onto the stack MyObject * y = new MyObject(params); // onto ...
Yes, the whole point of the test name is that it tells you what doesn't work when the test fails.
Is there a best .NET algorithm for credit card encryption?
|.net|security|encryption|cryptography|
The .NET `System.Security.Cryptography` namespace has a rather bewildering collection of algorithms that I could use for encryption of credit card details. Which is the best? It clearly needs to be secure for a relatively short string.
The .NET `System.Security.Cryptography` namespace has a rather bewildering collection of algorithms that I could use for encryption of credit card details. Which is the best? It clearly needs to be secure for a relatively short string. EDIT: I'm in the UK, where I understand we're OK storing encrypted credit car...
If you're writing a VM in C, it turns out that using (gcc's) computed gotos like this: <pre><code>char run(char *pc) { void *opcodes[3] = {&&op_inc, &&op_lda_direct, &&op_hlt}; #define NEXT_INSTR(stride) goto *(opcodes[*(pc += stride)]) NEXT_INSTR(0); op_inc: ++acc; NEXT_INSTR(1); op_lda_direct: acc ...
To add to kamen's great answer, I would say that on some browsers, the parse time for larger js resources grows non-linearly. That is, a 1 meg JS file will take longer to parse than two 500k files. So if a lot of your traffic is people who are likely to have your JS cached (return visitors), and all your JS files are c...
Do a Console.ReadKey(). If you get a Tab, look at what you have in the command buffer, and loop through your available commands. If <code>someCommand.Name.BeginsWith(currentinput)</code>, you have a winner, and you can write to screen a list of possible commands. If _there is only one(TM)_ you can substitute ...
If you are using a 3rd party payment gateway, you don't need to store the numbers. There is no point.
$obj->dbi_commit(); may be what you are looking for if you have uncompleted transactions. However, this is not very likely the case, as it tends to complete any lingering transactions automatically on destruction. When you do this: Music::Artist->purge_object_index_every(2000); You are telling it to examin...
If you are using Visual Studio 2005 and up you can create a setter/getter real fast using the insert snippet command. Right click on your code click on Insert Snippet (Ctrl+k,x) and then choose "prop" form the list. Hope this helps.
1. A function that calls itself 2. When a function can be (easily) decomposed into a simple operation plus the same function on some smaller portion of the problem. I should say, rather, that this makes it a good candidate for recursion. 3. They do! The canonical example is the factorial which looks like: i...
1. A function that calls itself 2. When a function can be (easily) decomposed into a simple operation plus the same function on some smaller portion of the problem. I should say, rather, that this makes it a good candidate for recursion. 3. They do! The canonical example is the factorial which looks like: i...
Rather than using ctrl+k,x you can also just type `prop` and then hit tab twice
A recursive function is one which calls itself. The most common reason I've found to use it is traversing a tree structure. For example, if I have a TreeView with checkboxes (think installation of a new program, "choose features to install" page), I might want a "check all" button which would be something like this (ps...
Visual Studio also has a feature that will generate a Property from a private variable. If you right-click on a variable, in the context menu that pops up click on the "Refactor" item. Then choose encapsulate field. This will create a getter/setter property for a variable. I'm not too big a fan of this technique ...
> You might also want to look into Comet. > I thought everyone used cometd for this sort of thing. BOSH is a standard for transporting XMPP over HTTP. It involves Comet for pushing data to the client.
I've encountered this bug, and while I don't know how to solve it, you can work around it by pressing `<down><up>`
I've never used Makepp personally, but since it's a drop-in replacement for GNU Make, you should be able to do something like: build: foo.h foo.cpp g++ $(CFLAGS) foo.cpp -o $(LFLAGS) foo foo.h foo.cpp: foo.lzz lzz foo.lzz Also not sure about the lzz invocation there, but that should hel...
There isn't much information on this out there but it seems to be their own custom controls plus an IE component (and not Qt like Google Earth). [This forum thread][1] has a little bit of information. [1]: http://www.customizetalk.com/forums/viewtopic.php?t=841&postdays=0&postorder=asc&start=0
There isn't much information on this out there but it seems to be their own customized controls plus an IE component (and not Qt like Google Earth). [This forum thread][1] has a little bit of information. [1]: http://www.customizetalk.com/forums/viewtopic.php?t=841&postdays=0&postorder=asc&start=0
Check out [this thread][1] for a discussion on the reasons behind this behavior (including that, according to Guido, it's [not likely to change][2]). [1]: http://mail.python.org/pipermail/python-3000/2007-September/010209.html [2]: http://mail.python.org/pipermail/python-3000/2007-September/010222.html
Check out [this thread][1] for a discussion on the reasons behind this behavior (including that Guido likes it, and it's [not likely to change][2]). [1]: http://mail.python.org/pipermail/python-3000/2007-September/010209.html [2]: http://mail.python.org/pipermail/python-3000/2007-September/010222.html
I've had good luck using the DocLibHelper wrapper class described here: [http://geek.hubkey.com/2007/10/upload-file-to-sharepoint-document.html][1] [1]: http://geek.hubkey.com/2007/10/upload-file-to-sharepoint-document.html
It really comes down to the nature of your database and application. What kind of application(s) are hitting SQL Server? In my experience, it only handles 5-10 users with a heavy read/write application.
Windows is not the usual place to deploy production Rails apps, but there are people who do it. Mongrel was originally written to give better deployment options for Windows. As it turned out the UNIX deployment options weren't that good either. :) Start with the Ruby One Click installer so you have a sane installati...
##lolcode: sorry I couldn't resist xD HAI CAN HAS STDIO? I HAS A VAR I HAS A INT I HAS A CHEEZBURGER I HAS A FACTORIALNUM IM IN YR LOOP UP VAR!!1 TIEMZD INT!![CHEEZBURGER] UP FACTORIALNUM!!1 IZ VAR BIGGER THAN FACTORIALNUM? GTFO IM OUTTA YR LOOP ...
Agree with @SCdF, create a service in php or any other language that takes a modified query from flash, executes it and returns the DB response. Make sure that it only takes a connection from its own local IP address or something like that to prevent "unintentional use".
Yes. It will work just fine. I have a PHP script using the mail() function with the MX records set to Google Apps. If the two scripts are on different hosts (it's a bit unclear from your post), then make sure that the host doesn't block some of the custom headers. I had issues with this when creating my script, but ...