instruction stringlengths 0 30k ⌀ |
|---|
Most services that have a GUI component are run as a named user, and are allowed access to the desktop. This lets you access it via COM or .NET but only locally (unless you want to get complicated)
Personally, I open an ordinary old socket on the service - its cross platform, allows multiple clients, allows any app ... |
I quite like John Resig's [Simple JavaScript Inheritance][1].
var MyWidget = Class.extend({
init: function(widget_name){
this.widget_name = widget_name;
},
doSomething: function() {
alert('my name is ' + this.widget_name);
}
});
[1]: http://ejohn.org/... |
I quite like John Resig's [Simple JavaScript Inheritance][1].
var MyWidget = Class.extend({
init: function(widget_name){
this.widget_name = widget_name;
},
doSomething: function() {
alert('my name is ' + this.widget_name);
}
});
NB: The "Class" object d... |
sudo echo "something" >> /etc/privilegedFile doesn't work... is there an alternative? |
|linux|permissions|console| |
This is a pretty simple question, atleast it seems like it should be, about sudo permissions in linux.
There is a lot of times when I just want to append something to say /etc/hosts or similar file but end up not being able to because both > and >> are not allowed, even with root.
Is there someway to make this ... |
This is a pretty simple question, at least it seems like it should be, about sudo permissions in linux.
There are a lot of times when I just want to append something to /etc/hosts or a similar file but end up not being able to because both > and >> are not allowed, even with root.
Is there someway to make this ... |
|linux|shell|console|permissions| |
For memory-safety reasons, you shouldn't expose a reference to an object or that object's fields to another thread from within its constructor. Assuming that your custom thread has instance variables, by starting it form within the constructor, you are guaranteed to violate the Java Memory Model guidelines. See [Bria... |
Use a library, I recommend [Box2D][1]
[1]: http://www.box2d.org/ |
My problem was when learning this we learned clisp right along with it. I couldn't keep the two strait to save my life.
What I did learn from them though was how to write better c and java code. This is simply because of the different programming style I learned. I have adapted more of the functional style into some... |
I usually try to fit the class into one of the oo [design patterns.][1]
[1]: http://en.wikipedia.org/wiki/Design_pattern_(computer_science) |
My favorite is this:
// what does this do?
x = x++; |
My favorite is this:
// what does this do?
x = x++;
To answer some comments, it is undefined behaviour according to the standard. Seeing this, the compiler is allowed to do anything up to and including format your hard drive.
See for example [this comment here][1]. The point is not that you can see ther... |
My favorite is this:
// what does this do?
x = x++;
To answer some comments, it is undefined behaviour according to the standard. Seeing this, the compiler is allowed to do anything up to and including format your hard drive.
See for example [this comment here][1]. The point is not that you can see ther... |
My favorite is this:
// what does this do?
x = x++;
To answer some comments, it is undefined behaviour according to the standard. Seeing this, the compiler is allowed to do anything up to and including format your hard drive.
See for example [this comment here][1]. The point is not that you can see ther... |
Any good tutorial with source that will demonstrate how to develop neural network (step bay step for dummies ;-)) |
Neural Network example in .NET |
|.net|artificial-intelligence|neural-networks| |
An interesting tutorial is available [here][1]. Hopefully it will act as an introduction for you.
[1]: http://www.codeproject.com/KB/recipes/neural_dot_net.aspx |
CTRL+SHIFT+V will cycle through your clipboard, Visual Studio keeps a history of copies. |
I have used JetBrains dotTrace and Redgate ANTS extensively. They are fairly similar in features and price. They both offer useful performance profiling and quite basic memory profiling.
dotTrace integrates with Resharper, which is really convenient, as you can profile the performance of a unit test with one click f... |
This is one thing (I could remember) that i fell into when I was in my hibernate days.
When you delete (several) child object from a collection (in a parent entity) and then adding new entities to the same collection in one transaction without flushing in the middle, hibernate will do "insert" before "delete". If the ... |
I use the AnyEdit plugin to auto-convert tabs to spaces on the save of a file. I also configure the base text editor (from which pretty much all the others derive) to insert spaces instead of tabs. This sounds redundant, but what it does is ensure that I don't insert any tabs, and any file that I edit that already has ... |
I think there are two aspects to your question:
The design of the system to be extendable (the design patterns, inversion of control and other architectural aspects) (http://www.martinfowler.com/articles/injection.html). And, at least to me, yes these patterns/techniques are platform/language independent and can be... |
I've hit this in the past and found no working solution except the "nuclear option" (i.e. delete the directory and re-checkout).
Not sure if this is your problem, but my corruption was being caused by an on-access virus scanner on the same machine as SVN server. |
[w3.org checklink][1]
[1]: http://validator.w3.org/checklink |
SELECT t.name as 'table',i.name as 'index',it.xtype,
(select c.name from syscolumns c inner join sysindexkeys k on k.indid=i.indid and c.colid = k.colid and c.id=t.id and k.keyno=1 and k.id=t.id)as 'column1',
(select c.name from syscolumns c inner join sysindexkeys k on k.indid=i.indid and c.colid = k.colid and c... |
There could be any number of namespaces in a given assembly, and nothing requires them to all start from a common root. The best you could do would be to reflect over all the types in an assembly and build up a list of unique namespaces contained therein.
|
If the ID field you test is part of a common initial sequence of fields shared by all the structs, then using a union guarantees that the access will work:
#include <stdio.h>
typedef struct
{
int id;
int junk1;
} Foo;
typedef struct
{
int id;
long ... |
Try onkeypress instead of onblur. Also, on the onfocus of field two is where you should be sending to three. I'm assuming you don't want them typing in two if one is 123 so you can just check that on two's onfocus and send on to three. |
How can I turn a single object into something that is Enumerable in ruby. |
|ruby| |
I have a method that can return either a single object or a collection of objects. I want to be able to run object.collect on the result of that method whether or not it is a single object or a collection already. How can i do this?
profiles = ProfileResource.search(params)
output = profiles.collect do | pr... |
I asked this question before to experience Linux users and they always say Vim and automake. I use Vim as my default editor in Linux and after a while it becomes intuitive. I learned it by working through some small examples while learning C++ so I could learn both at the same time. |
A Multi-Tasking Operating System would be an OS that allows for the simultaneous execution of multiple (more than 1) processes. Operating Systems that you are used to, like Unix, Windows and OSX are multi-tasking operating systems.
An example of a non-multi-tasking operating system would be MS-DOS. Although you coul... |
Multi tasking operating systems is:
The perception of 2 or more tasks running at the same time by dividing system resources amongst one or more processes. And switching between the processes while they are executing.
Yes there are non multi tasking operating systems, dos, commodore 64's OS (Commodore BASIC 2.0).... |
A multi tasking operating systems is:
The perception of 2 or more tasks/jobs/processes running at the same time by dividing system resources amongst one or more of these tasks/jobs/processes. And switching between the tasks/jobs/processes while they are executing.
Yes there are non multi tasking operating system... |
A multi tasking operating systems is:
An operating system that gives you the perception of 2 or more tasks/jobs/processes running at the same time. It does this by dividing system resources amongst these tasks/jobs/processes. And switching between the tasks/jobs/processes while they are executing very fast over an... |
The const keyword on a member function marks the *this* parameter as constant. The function can still mute global data (so can't be cached), but not object data (allowing for calls on const objects). |
If you're strictly following MVC, your model (entities) won't have any inherent behavior. I do however include whatever helper methods allow the easiest management of the entities persistence, including methods that help with maintaining its relationship to other entities. |
There are a plethora of ways to detect collision detection. The methods you use will be slightly altered if depending on if your using a 2d or 3d environment. Also remember when instituting a collision detection system, to take into account any physics you may want to implement in the game (needed for most descent 3d... |
In this context, a `const` member function means that `this` is treated as a `const` pointer also. In practical terms, it means you aren't allowed to modify the state of `this` inside a `const` member function.
For no-side-effect functions (i.e., what you're trying to achieve), GCC has a "function attribute" called ... |
Any decent 2D graphics library will provide collision detection functions for everything from aligned sprites to polygons to pixels. Your choice of engine/library/framework should dictate your collision detection choices, as they are likely far more optimized than what you could produce alone. |
Any decent 2D graphics library will either provide its own collision detection functions for everything from aligned sprites to polygons to pixels, or have one or more good third party libraries to perform those functions. Your choice of engine/library/framework should dictate your collision detection choices, as they... |
No. If you use them and an exception is thrown that you did not specify, either by your code or code called by your code, then the default behavior is to promptly terminate your program.
Also, I believe their use has been deprecated in current drafts of the C++0x standard.
|
As far as I know [Debugbar][1] is currently the most sophisticated debugging tool for IE. It's definitely better than IE developer, but it's still not quite as slick as firebug.
[1]: http://www.debugbar.com/ |
This is really a hard question to answer -- all browsers? Does this mean all versions? Mobile browsers? Just the "mainline" ones (opera, firefox, ie and safari)?
You won't find even full compliance on CSS level 1 stuff, so there are going to be some tweaks you're going to have to make. In my experience opera, ... |
Test your CSS on all the browsers as you go. It's awful to get it pixel perfect in your pet browser only to find that it's way off in other browsers.
Taking this approach will ease you into an understanding of what will work on all the major browsers. |
For formatting/pretty-fying SQL, I've had success with **<http://www.sqlinform.com/>** - free online version you can try out, and a desktop version available too.
>_SQLinForm is an automatic SQL code formatter for all major databases ( ORACLE, SQL Server, DB2 / UDB, Sybase, Informix, PostgreSQL, MySQL etc) with many... |
A lot of times some quick task comes up that isn't part of the main software you are developing. Sometimes the task is one off ie compare this file to the database and let me know the differences. It is a lot easier to do text parsing in Perl/Ruby/Python than it is in Java or C# (partially because it is a lot easier ... |
sudo sh -c "echo 127.0.0.1 localghost >> /etc/hosts" |
sudo sh -c "echo 127.0.0.1 localghost >> /etc/hosts"
|
I tend to find that identical looking CSS comes about if I use floats to layout the page in boxes. The flow model works as you think it should, and they're faithfully rendered in all major browsers.
I know some would tell me that the use of a lot of floats is wrong, but it works surprisingly well. |
Hessian. http://hessian.caucho.com. Implementations in multiple languages (including ObjC), super light weight, and doesn't require reliance on dom/xml parsers for translation from wire to object models. Once we found Hessian, we forgot we ever knew XML. |
Hopefully, as we get closer to release, http://asp.net/mvc will be the one stop shop for ASP.NET MVC related issues. |
As noted, the Composite Pattern may be a good solution.
If that doesn't work for you, it may be simpler - if appropriate - to define Root as an Interface, and apply that as needed.
Of course, that doesnt let you provide any implementation for Root...
If Root must have implementation, you can use the Decorato... |
I've had success using the Eric Meyer CSS reset available [here][1]. It basically overrides a bunch of browser CSS styles that are default. Having said that, there are still a lot of differences (probably some of the ones that are troubling you like box model differences, etc. In that case, it might be better to use [B... |
Visual Studio has a relatively obscure feature that lets you add existing items as links, which should accomplish what you're looking for. Check out [Derik Whittaker's post][1] on this topic for more detail.
Visual Studio really should make this option more visible. Nobody really thinks to click on that little arr... |
If you know which folder has the damaged .svn directory, you can just delete that one directory and run an svn update again. You may have to delete the whole directory including its current contents. Of course, if the folder with the damaged .svn directory is the one containing a gigabyte, then you're back where you st... |
Assemblies don't necessarily have a root namespace. Namespaces and Assemblies are orthogonal.
What you may be looking for instead, is to find a type within that Assembly, and then find out what its namespace is.
You should be able to accomplish this by using the GetExportedTypes() member and then using the Names... |
Use sed or a similar tool to translate the #lines to something else not interpreted by the compiler, so you get C error messages on the real line, but have a reference to the original input file nearby. |
I like [Robocopy][1] ("Robust File Copy"). It is a command-line directory replication command. It was available as part of the Windows Resource Kit, and is introduced as a standard feature of Windows Vista and Windows Server 2008.
[1]: http://en.wikipedia.org/wiki/Robocopy |
Using Validation in WPF With Dependency Property and Style Triggers |
|wpf| |
I am trying to use Validation in WPF. I created a NotNullOrEmptyValidationRule as shown below:
public class NotNullOrEmptyValidationRule : ValidationRule
{
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
if (String.IsNul... |
The Team Build has a "bootstrap" phase where everything in the Team Build Configuration folder (the folder with TFSBuild.proj) is downloaded from version control. This is performed by the build agent before the build agent calls MSBuild.exe telling it to run TFSBuild.proj.
If you move your targets file from under S... |
Windows specific:
There is the macro `_countof()` supplied by the CRT exactly for this purpose.
[A link to the doc at MSDN][1]
[1]: http://msdn.microsoft.com/en-us/library/ms175773(VS.80).aspx |
I think you would waste less time by sticking to XCode rather than looking for another IDE if you want to develop for the Mac (or iPhone).
Apple made a lot of effort to kill any competitor in that area to make sure any developer wanting to develop for the Mac plateform use XCode and only XCode.
It might not be th... |
I think you would waste less time by sticking with XCode rather than looking for another IDE if you want to develop for the Mac (or iPhone).
Apple made a lot of effort to kill any competitor in that area to make sure any developer wanting to develop for the Mac plateform use XCode and only XCode.
It might not be ... |
Should I impose a maximum length on passwords? |
|security|encryption|passwords| |
I can understand that imposing a minimum length on passwords makes a lot of sense (to save users from themselves), but my **bank** has a requirement that passwords are between 6 and 8 characters long, and I started wondering...
- Wouldn't this just make it easier for brute force attacks? (Bad)
- Does this imply... |
It depends on what kind of entity they are -- but the term "entity" implies, to me at least, business entities, in which case they should have behavior.
A "Business Entity" is a modeling of a real world object, and it should encapsulate all of the business logic (behavior) and properties/data that the object represe... |
How to Naturally/Numerically Sort a DataView? |
|.net|asp.net|icomparable| |
I am wondering how to naturally sort a DataView... I really need help on this. I found articles out there that can do lists with IComparable, but I need to sort the numbers in my dataview.
They are currently alpha sorted because they are numbers with 'commas' in them. Please help me out.
I would like to find s... |
Honestly, I like having my compiled SASS stylesheets in version control. They're small, only change when your .sass files change, and having them deploy with the rest of your app means the SASS compiler doesn't ever need to fire in production.
The other advantage (albeit a small one) is that if you're not using page... |
Preallocating file space in C#? |
|c#|file|file-io| |
I am creating a downloading application and I wish to preallocate room on the harddrive for the files before they are actually downloaded as they could potentially be rather large, and noone likes to see "This drive is full, please delete some files and try again." So, in that light, I wrote this.
// Quick, and ... |
How can I prevent deformation when rotating about the line-of-sight in OpenGL? |
|c|opengl| |
I've drawn an ellipse in the XZ plane, and set my perspective slightly up on the Y-axis and back on the Z, looking at the center of ellipse from a 45-degree angle, using gluPerspective() to set my viewing frustrum.
<a href="http://www.flickr.com/photos/rampion/2863703051/" title="ellipse by rampion, on Flickr"><img ... |
[Wikipedia][1] has a pretty good lowdown on multitasking.
[1]: http://en.wikipedia.org/wiki/Computer_multitasking |
You could also use [Firebug Lite][1] - which will work in IE & Opera. It's an external lib that will help you track down problems. It's sometimes more convenient than dealing with the MS Script Debugger.
[1]: http://getfirebug.com/lite.html |
Fields that are diverse, highly specific, or unique make good indexes. Such as dates and timestamps, unique incrementing numbers (commonly used as primary keys), person's names, license plate numbers, etc...
A counterexample would be gender - there are only two common values, so the index doesn't really help reduce... |
SQL Text Searching, AND Ordering |
|sql|search|query| |
I have a query:
SELECT *
FROM Items
WHERE column LIKE '%foo%'
OR column LIKE '%bar%'
how do I order the results?
lets say I have rows that match 'foo' and rows that match 'bar' but I also have a row with 'foobar'
how do I order the returned rows so that the first results are the ones that matched more LI... |
Throw away early, refactor later
--------------------------------
Throwing away is OK for small systems, but if the size of the system is huge, you simply do not have the resources to do so.
You could, however, create a small pilot project that implements only the very essential features of the actual project. ... |
Replying to myself, I'd like to give the answer that someone gave me on IRC:
<pre>
(gdb) apropos pending
actions -- Specify the actions to be taken at a tracepoint
set breakpoint -- Breakpoint specific settings
set breakpoint pending -- Set debugger's behavior regarding pending breakpoints
show breakpoint -- Br... |
If you're ok with using ruby, you want <a href="http://coderay.rubychan.de/">coderay</a>.
|
It takes two arrayrefs and returns a new arrayref with the contents of the second array rearranged such that the second part comes before the first part, split at a point based on the memory location of the first array. When the second array is empty or contains one item, just returns a copy of the second array. Equiva... |
Thus far, I've been pretty content with the quality of Perl answers I've seen here. Many of the most experienced Perl programmers I know from conferences, Perlmonks, use.perl.org, etc. seem to be present here and answering questions seriously and clearly. In cases where an answer has been wrong or simply bad in a sense... |
Check out the HID Manager, especially the new [HID Manager APIs in Leopard][1]. It's somewhat verbose, but the essence of it is that you can get callbacks when devices are attached and detached, and get callbacks when events from those devices are enqueued.
If you're working with Cocoa, [Dave Dribin][2] has [DDHidL... |
Make a selection with ALT pressed - selects a square of text instead of whole lines. |
Have you tried the [hoard allocator][1]? It provides better performance than the default allocator on many systems.
[1]: http://www.hoard.org/ |
On *nix, you likely have the "whereis" command, which searches your $PATH looking for a binary with a given name. If $0 doesn't contain the full path name, running whereis $scriptname and saving the result into a variable should tell you where the script is located. |
Using CSS Reset will give everything the same starting point, but won't do much to help with the changes you make beyond that starting point. I can't say there's really any easy way. One solution is to stick to a limited set of CSS that you know works well in all browser you want to support. You may not be able to d... |