instruction stringlengths 0 30k ⌀ |
|---|
I need the name of the current logged in user in my Air/Flex application. The application will only be deployed on Windows machines. I think I could attain this by regexing the User directory, but am open to other ways. |
Personally I think curses is overkill in this case. While the curses lib is nice (and I frequently use it myself) it's a PITA to relearn every time I haven't needed it for 12 months which has to be the sign of a bad interface design.
If for some reason you can't get on with [the progress bar lib Joey suggested][1] ... |
Here is a solution that works in XP / Vista, but is definitely expandable to OSX, linux, I'd still be interested in another way.
public static function GetCurrentOSUser():String{
// XP & Vista only.
var userDirectory:String = File.userDirectory.resolvePath("").nativePath;
var startIndex:Number = userDi... |
Use [Robocopy][1], it has the ability to copy files in "restartable mode", plus it should respect the file attributes. And it comes with Vista and Server 2008, and you can download it for older OS's. Plus you can set it to retry on failed copies, to pick up files that are temporarily in use by another process.
... |
What are the current best options for parallelizing a CPU-intensive .NET app? |
|.net|parallel-processing| |
This is an open-ended question. What approaches should I consider? |
Also I would try:
File.userDirectory.name
But I don't have Air installed so I can't really test this... |
I don't disagree with Dan (although a better choice may just be not to answer)...but...
Unit testing is the process of writing code to test the behavior and functionality of your system.
Obviously tests improve the quality of your code, but that's just a superficial benefit of unit testing. The real benefit are t... |
+1 for [Zen garden.][1]
I like the resources at [inobscuro.com][2]
[1]: http://www.csszengarden.com/
[2]: http://inobscuro.com/ |
As for Linux, I know that Pidgin has to determine idle time to change your status to away after a certain amount of time. You might open the source and see if you can find the code that does what you need it to do. |
Check out this, I know it works in 2005 ([MSDN Doc](http://msdn.microsoft.com/en-us/library/ms174397.aspx)):
Here is is for the pubs DB
<pre><code>
select *
from pubs.sys.database_files
</pre></code>
Returns the size and max_size. |
At my current job, my predecessor did not use any kind of version control. There are just mountains of folders in at least 3 different places where he kept all of his projects. Any random project folder can be expected to find at least one folder name "project (OLD)" and one named "project"
With version control, you... |
[The Open Design Community][1] is a great resource.
[1]: http://www.opendesigns.org/ |
I second Luke's answer.
I can Recommend [Confluence][1] and here is why:
I tested extensively many commercial and free Wiki based solutions. Not a single one is a winner on all accounts, including confluence. Let me try to make your quest a little shorter by summarizing what I have learned to be a pain and what is ... |
The [plugin from Microsoft's Mikhail Arkhipov][1] does HTML and Comments, I don't believe it does C# strings, though. I use the [Agent Smith][2] plugin for [ReSharper][3] for that.
[1]: http://blogs.msdn.com/mikhailarkhipov/archive/2007/12/31/spell-checker-update-2-1-a-few-bug-fixes-and-couple-of-new-features.a... |
You need to be using an uni-directional hash algorithm like SHA-1 suggested above with a salt. I would suggest this site for more information. It includes some sample code / implementation.
http://www.obviex.com/samples/hash.aspx
|
OS X InputManager, anything similar on Windows |
|windows|macos|apple|windows-api| |
Is there anything similar on Windows what would achieve the same as the InputManager on OS X? |
As mk says, SHA1 or MD5 are the standard ones, along with SHA2.
What you want is more generally called a cryptographic hash function. Cryptographic hashes are designed to be one-way (given the resulting hash, you shouldn't be able to derive the original input). Also, the likelihood of two arbitrary strings having th... |
To clarify the answer, the solution was to open up the tcp ports from 1024-65535.
The iptables looked liked this:
<code>
[root@MYSERVER ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- 0.0.0.0/0 ... |
Is just not accepting any connections on port 80 an option? I'm a complete web server noob so I don't know if the server can operate without an unsecured listen port but if the server can operate only listen on port 443 that would seem to be simplest option.
Another option would be a redirect from the unsecure port... |
Try using the [UIElement.SnapsToDevicePixels][1] property on the UI elements of your window. People tend to report it works best for [graphics and lines][2], but I've noticed improvment in text rendering with it as well.
[1]: http://msdn.microsoft.com/en-us/library/system.windows.uielement.snapstodevicepixels.a... |
InputManagers are still available on Leopard, *except*:
- they need to be in the Local domain (`/Library/InputManagers`); you cannot install them per-user any more,
- they need to have appropriate privileges,
- in 64-bit, they won't get loaded at all.
[The Leopard AppKit Release Notes have more specific deta... |
Here is one that does the rotation in place instead of using a completely new array to hold the result. I've left off initialization of the array and printing it out. This only works for square arrays but they can be of any size. Memory overhead is equal to the size of one element of the array so you can do the rota... |
Order an Array like another Array in C# |
|c#|array| |
I'm looking for the best algorithm to take array A {0,1,2,3} and make order it like array B {3,1,0,2}. Any ideas? |
|c#|arrays| |
It's pretty tricky and interesting. I'm sure I have the details wrong, but the overview is this:
The program's can already talk to each other through Joel's server, so they can exchange information with each other and Joel's server. Further, Joel has their external IP addresses, and they give joel information abou... |
It's pretty tricky and interesting. I'm sure I have some details wrong, but the overview is this:
The programs can already talk to each other through Joel's server, so they can exchange information with each other and Joel's server. Further, Joel has their external IP addresses, and they give joel information abou... |
There are some parallel extensions to .NET that are currently in testing and available at Microsoft's [Parallel Computing Developer Center][1]. They have a few interesting items that you would expect like Parallel foreach and a parallel version of LINQ called PLINQ. Some of the best information about the extensions is ... |
Unit testing is, roughly speaking, testing bits of your code in isolation with test code. The immediate advantages that come to mind are:
- Running the tests becomes automate-able and repeatable
- You can test at a much more granular level than point-and-click testing via a GUI
Note that if your test code writes... |
Unit testing is, roughly speaking, testing bits of your code in isolation with test code. The immediate advantages that come to mind are:
- Running the tests becomes automate-able and repeatable
- You can test at a much more granular level than point-and-click testing via a GUI
Note that if your test code writes... |
Have a look at #ziplib (www.icsharpcode.com). It's GPL, but you can use it in closed-source, commercial applications. They don't say anything specifically on their page about using it with the Compact Framework, so you'd have to give it a test yourself (that said, it's pure C# without any external dependencies, so the ... |
Something I didn't see mentioned is [PCMag Radio][1]. That's a more consumer tech-oriented show, but they do geek out fairly often, and the chatter is always interesting.
[1]: http://www.pcmag.com/category2/0,2806,2007098,00.asp |
If you need your linebreaks preserved, use a CDATA block, as [tweakt said](http://stackoverflow.com/questions/7277/is-it-bad-practice-to-be-sensitive-to-linebreaks-in-xml-documents#7280)
Otherwise beware. Most of the time, the linebreaks will be preserved by XML software, but sometimes they won't, and you really don... |
What about using attributes to store the data, rather than text nodes:
<Address Street="15 Sample St" City="Example Bay" State="" Country="Some Country"/>
I know the use of attributes vs. text nodes is an often debated subject, but I've stuck with attributes 95% of the time, and haven't had any troubles becau... |
PDF Editing in PHP? |
|php|pdf| |
Does anyone know of a good method for editing PDFs in PHP? Preferably open-source/zero-license cost methods. :)
I am thinking along the lines of opening a PDF file, replacing text in the PDF and then writing out the modified version of the PDF?
I have programmatically created PDF files in the past using FPDF, but... |
Visual Studio - new "default" property values for inherited controls |
|c#|.net|visual-studio|vb.net| |
I'm looking for help setting a new default property value for an inherited control in Visual Studio:
class NewCombo : System.Windows.Forms.ComboBox
{
public NewCombo() { DropDownItems = 50; }
}
The problem is that the base class property "DropDownItems" has a 'default' attribute set on it tha... |
We use [pdflib](http://www.pdflib.com/pdflib-gmbh/) to create PDF files from our rails apps. It has bindings for PHP, and a ton of other languages.
We use the commmercial version, but they also have a [free/open source version](http://www.pdflib.com/download/pdflib-family/pdflib-lite/) which has some limitations.
... |
TortoiseSVN works great. You don't even need a Subversion server, you can create a local repository through the tool. Since it integrates right into Windows Explorer, it makes it easy to work with in a variety of scenarios. You also then have the option to work with remote Subversion servers or Team Foundation Serve... |
You can use [assembla.com][1] to host your project. They offer subversion, git and mercurial hosting. I personally use their subversion hosting for a free and private one-man project. As an added bonus, you also get a wiki and a ticketing system. Which can help you manage your stuff.
And the best thing is that you d... |
I prefer distributed version control for personal projects, because they eliminate the need for a server. **Mercurial** is the one I try to use most of the time, but I've been hearing good things about **git** as well. |
[Git][1] is very lightweight and is just as suitable for personal projects as it is for huge projects like the Linux kernel. There is lots of tutorial documentation available on its web site that will get you started. Example:
git init
git add .
git commit -m "my first commit!"
[1]: http://git.o... |
[Git][1] is very lightweight and is just as suitable for personal projects as it is for huge projects like the Linux kernel. There is lots of tutorial documentation available on its web site that will get you started. Example:
git init
git add .
git commit -m "my first commit!"
If you are keen on Vi... |
Choosing a multiplier for a (string) hash function |
|performance|algorithm| |
Do you have any advice/rules on selecting a multiplier to use in a (multiplicative) hash function. The function is computing the hash value of a string. |
I use [Perforce][1] at work and at home for hobby projects. It is easy enough to set up, and allows two users and five workspaces without having to pay for a license. Also has a Visual Studio integration plugin.
[1]: http://www.perforce.com |
If you are using a framework like [django][1], the framework can easily do this for you using standard filters. In fact, I'm pretty sure django automatically does it unless you tell it not to.
Otherwise, I would recommend using some sort of regex validation before accepting inputs from forms. I don't think there's... |
ASP .Net Custom Client-Side Validation |
|asp.net|javascript|validation| |
I have a custom validation function in JavaScript in a user control on a .Net 2.0 web site which checks to see that the fee paid is not in excess of the fee amount due.
I've placed the validator code in the ascx file, and I have also tried using Page.ClientScript.RegisterClientScriptBlock() and in both cases the va... |
If you're using .Net 2.0 and Ajax - you should use:
ScriptManager.RegisterClientScriptBlock
It will work better in Ajax environments then the old Page.ClientScript version. |
You can relocate it by editing the **DocumentRoot** setting in XAMPP\apache\conf\httpd.conf.
It should currently be:
> C:/xampp/htdocs
Change it to:
> C:/projects/transitCalculator/trunk |
I would look into IMAP
http://us3.php.net/imap |
How can I get the authenticated user name under Apache using plain HTTP authentication and PHP? |
|php|apache|authentication| |
First, let's get the security considerations out of the way. I'm using simple authentication under Apache for a one-off, internal use only, non-internet connected lan, php web app.
How can get I the HTTP authenticated user name in PHP? |
Try changing the argument names to "sender" and "args". And, after you have it working, switch the call over to ScriptManager.RegisterClientScriptBlock, regardless of AJAX use. |
I'm sure you could write a small app that takes an XSD file and parses it into a SQL script. I've never seen code out there to do it though, but that's not saying it doesn't exist. |
You can set Apache to serve pages from anywhere with any restrictions but it's normally distributed in a more secure form.
Editing your apache files (http.conf is one of the more common names) will allow you to set any folder so it appears in your webroot. |
You can set Apache to serve pages from anywhere with any restrictions but it's normally distributed in a more secure form.
Editing your apache files (http.conf is one of the more common names) will allow you to set any folder so it appears in your webroot.
EDIT:
alias myapp c:\myapp\
I've edited my answer t... |
I second Luke's answer.
I can Recommend [Confluence][1] and here is why:
I tested extensively many commercial and free Wiki based solutions. Not a single one is a winner on all accounts, including confluence. Let me try to make your quest a little shorter by summarizing what I have learned to be a pain and what is ... |
I second Luke's answer.
I can Recommend [Confluence][1] and here is why:
I tested extensively many commercial and free Wiki based solutions. Not a single one is a winner on all accounts, including confluence. Let me try to make your quest a little shorter by summarizing what I have learned to be a pain and what is ... |
I've used InnoSetup several years ago, before Vista, and was very happy with it then. I only had a few files to install and a Start menu icon. It worked great, and was easy to learn. |
Ensure that you're modifying the modelview matrix by putting the following before the glRotatef call:
glMatrixMode(GL_MODELVIEW);
Otherwise, you may be modifying either the projection or a texture matrix instead. |
Do you get a 1 unit straight line? It seems that 90deg rot. around Y is going to have you looking at the side of a triangle with no depth.
You should try rotating around the Z axis instead and see if you get something that makes more sense.
OpenGL has two matrices related to the display of geometry, the ModelVie... |
The latest version of .Net 3.5 SP1 now allows you to run managed executables over a network share without using CasPol.
See this [post][1]
[1]: http://blogs.msdn.com/brada/archive/2008/08/13/net-framework-3-5-sp1-allows-managed-code-to-be-launched-from-a-network-share.aspx |
Update: I found a much more elegant solution:
class MyCompositeObject
{
DateTime CreatedDate;
string SomeAttribute;
Object Obj1;
{
class MyCompositeObjects : List<MyCompositeObject> { }
I found that due to reflection, the specific type stored in Obj1 is r... |
#Perl 6:Procedural#
sub factorial ( int $n ){
my $result = 1;
loop ( ; $n > 0; $n-- ){
$result *= $n;
}
return $result;
} |
C:
Edit: Actually C++ I guess, because of the variable declaration in the for loop.
int factorial(int x) {
int product = 1;
for (int i = x; i > 0; i--) {
product *= i;
}
return product;
} |
OpenGL Rotation |
|opengl|c++| |
I'm trying to do a simple rotation in OpenGL but must be missing the point.
I'm not looking for a specific fix so much as a quick explanation or link that explains OpenGL rotation more generally.
At the moment I have code like this:
glPushMatrix();
glRotatef(90.0, 0.0, 1.0, 0.0);
glBegin(GL_TRI... |
It sounds to me that you'll want to handle two events:
OnFocus: Will trigger when the textbox gains focus. You can store the initial value of the box.
OnBlur: Will trigger when the textbox loses focus. At this point you can do your validation and decide if you want to roll back or not. |
It sounds to me that you'll want to handle two events:
GotFocus: Will trigger when the textbox gains focus. You can store the initial value of the box.
LostFocus: Will trigger when the textbox loses focus. At this point you can do your validation and decide if you want to roll back or not. |
I always hate to answer "don't", but you'd be better off indexing with something like Lucene ([PyLucene][1]). That and storing the paths in the database rather than the file contents is almost always recommended.
To add to that, none of those database engines will store LOBs in a separate dataspace (they'll be emb... |
Dependency injection is what you're looking for. Rather than have those functions go out and look for their dependencies, inject the dependencies into the functions. That is, when you call the functions pass the data they want to them. That way it's easy to put a testing framework around a class because you can simply ... |
Go to the table row's BackgroundColor property and choose "Expression..."
Use this expression:
=IIf(RowNumber(Nothing) Mod 2 = 0, "Silver", "Transparent")
This trick can be applied to many areas of the report.
Not looking for rep--I just researched this question myself and thought I'd share. |
Why store the files in the database at all? Simply store your meta-data and a filename. If you need to copy them to a new location for some reason, just do that as a file system copy.
Once you remove the file contents then any competent database will be able to handle the meta-data for a few hundred thousand files... |
Here's one way to do it:
import inspect
def get_subclasses(mod, cls):
"""Yield the classes in module ``mod`` that inherit from ``cls``"""
for name, obj in inspect.getmembers(mod):
if hasattr(obj, "__bases__") and cls in obj.__bases__:
yield obj
|
There is possible merit in testing private methods of a class, particularly with <a href="http://en.wikipedia.org/wiki/Test-driven_development">test driven development</a>, where you would like to design small tests before you write any code.
Creating a test with access to private members and methods can test areas... |
I think the SCM policies and procedures a team adopts are going to be very dependent on the development process they are using. If you've got a team of 50 with several people working on major changes simultaneously and releases only occurring every 6 months, it makes a lot of sense for everyone to have his own branch ... |
I can't comment on other source control software but after using VSS 6.0 , StarTeam, Vault and SVN I cannot rate SVN + Tortoise more highly. AnkhSVN is a free plug-in for Visual studio which I personally didn't warm to. Apparently Visual SVN is much better but costs money.
|
The xUnit family are the mainstay of unit testing. They are integrated into the likes of Netbeans, Eclipse and many other IDEs. They offer a simple, structured solution to unit testing.
One thing I always try and do when writing a test is to minimise external code usage. By that I mean: I try to minimise the setup a... |
The so-called [xUnit][1] framework is widely used. It was originally developed for Smalltalk as SUnit, evolved into JUnit for Java, and now has many other implementations such as NUnit for .Net. It's almost a de facto standard - if you say you're using unit tests, a majority of other developers will assume you mean xUn... |
> What about external dependencies such a the AJAXTookit or some other 3rd party extension that's used on several projects?
Source control is for source code, not binaries. Keep any 3rd party assemblies/jars in a separate repository. If you're working in the Java world try something like Maven or Ivy. For .Net pr... |
In PHP, I'm using this one and I'll appreciate every comment about it :
function quote_smart($valeur)
{
if (get_magic_quotes_gpc())
$valeur = stripslashes($valeur);
if (!is_numeric($valeur))
$valeur = mysql_real_escape_string($valeur);
... |
<http://www.opensourcetemplates.org/> has nice designs, just not enough selection. |
A great thing to use in PHP is the [PDO][1]. It takes a lot of the guesswork out of dealing with securing your SQL (and all of your SQL stuff in general). It supports prepared statements, which go a long way towards thwarting SQL Injection Attacks.
A great primer on PDO is included in the book [The PHP Anthology 101... |
To retrieve the number of widgets from each widget category that has more than 5 widgets, you could do this:
<pre><code>
SELECT WidgetCategory, count(*)
FROM Widgets
GROUP BY WidgetCategory
HAVING count(*) > 5
</code></pre>
The "having" clause is something people often forget about, instead opting to retriev... |
I was wrestling with this problem several years ago (2004 I think). We ran into the problem that Firefox doesn't allow scripts to read the clipboard by default (but you can [grant access to the clipboard][1]).
There's other ways of reading the clipboard data as well...Flash, for instance, can read the clipboard. T... |
For maximum security, performance, and correctness use prepared statements.
Here's how to do this with lots of examples in different languages, including PHP:
<http://stackoverflow.com/questions/1973/what-is-the-best-way-to-avoid-sql-injection-attacks> |