instruction
stringlengths
0
30k
To get a rough estimate, you could always run `find . -type f -exec cat {} \; | wc -l` in the project directory if you're using Mac OS X.
Zoom for a form in C#
|c#|vba|
Is there an easy way to set the zoom level for a form in C#? In VBA there was a zoom property of the form.
Zoom for a windows form in C#
|c#|winforms|vba|
Is there an easy way to set the zoom level for a windows form in C#? In VBA there was a zoom property of the form.
Stack Overflow This Week in Tech Security Now As I learn more about programming I'll add more to my list. Adding 43 folders now.
<p>A "race condition" exists when multithreaded (or otherwise parallel) code that would access a shared resource could do so in such as way as to cause to unexpected results.</p> Take this example: <pre><code> for ( int i = 0; i &lt; 10000000; i++ ) { x = x + 1; } </code></pre> <p>If you had 5 threa...
Don't you just want: ",".join(l) Obviously it gets more complicated if you need to quote/escape commas etc in the values. In that case I would suggest looking at the csv module in the standard library: [http://docs.python.org/lib/module-csv.html][1] [1]: http://docs.python.org/lib/module-csv.html
Maybe something like this? const std::vector<mydata>& getData() { return _myPrivateData; }
Maybe something like this? const std::vector<mydata>& getData() { return _myPrivateData; } The benefit here is that it's very, very simple, and as safe as you getin C++. You can cast this, like RobQ suggests, but there's nothing you can do that would prevent someone from that if you're not c...
How can I determine whether a given date is in Daylight Saving Time for a given timezone in .NET 2.0?
|.net-2.0|timezone|medium-trust|
I'm on .NET 2.0, running under Medium Trust (so [TimeZoneInfo][1] and the Registry are not allowed options). I'm asking the user for two dates and a time zone, and would really love to be able to automatically determine whether I need to adjust the time zone for DST. This probably isn't even a valid scenario unle...
What you want is read-only access without copying the entire blob of data. You have a couple options. Firstly, you could just return a const refererence to whatever your data container is, like suggested above: const std::vector<T>& getData() { return mData; } This has the disadvantage of concreteness: you...
With a six word character password, he may have been brute forced. That is more likely than his ftp being intercepted, but it could be that too.
With a six word character password, he may have been brute forced. That is more likely than his ftp being intercepted, but it could be that too. Start with a stronger password. (8 characters is still fairly weak) See if this link to an internet [security blog][1] is helpful. [1]: http://blog.modsecurity.o...
> And if it matters at all, apache@localhost is not the name of the user account that I use to get into the database. I don't have any user accounts with the name apache in them at all for that matter. If it is saying 'apache@localhost' the username is not getting passed correctly to the MySQL connection. 'apache' i...
Try and gather as much information as you can. See if the host can give you a log showing all the FTP connections that were made to your account. You can use those to see if it was even an FTP connection that was used to make the change and possibly get an IP address. If you're using a prepacked software like Wordpr...
Is the site just plain static HTML? i.e. he hasn't managed to code himself an upload page that permits anyone driving by to upload compromised scripts/pages? Why not ask webhost4life if they have any FTP logs available and report the issue to them. You never know, they may be quite receptive and find out for you exa...
I use pico or nano as my "casual" text editor in Linux/Solaris/etc. It's easy to come to grips with, and whilst you lose a couple of rows of text to the menu, at least it's easy to see how to exit, etc. You can even extend nano, I think, and add syntax highlighting.
Since python is installed on nearly every non-Windows OS by default now, the only thing you really need to make sure of is that all of the non-standard libraries you use are installed. Having said that, it is possible to build executables that include the python interpreter, and any libraries you use. This is likel...
One advantage of both @Shog9's and @RichQ's solutions is that they de-couple the client from the collection implementation. If you decide th change your collection type to something else, your clients will still work.
Traditionally, JS was intended for short, quick-running pieces of code. If you had major calculations going on, you did it on a server - the idea of a JS+HTML *app* that ran in your browser for long periods of time doing non-trivial things was absurd. Of course, now we have that. But, it'll take a bit for browsers t...
Traditionally, JS was intended for short, quick-running pieces of code. If you had major calculations going on, you did it on a server - the idea of a JS+HTML *app* that ran in your browser for long periods of time doing non-trivial things was absurd. Of course, now we have that. But, it'll take a bit for browsers t...
You'll have to hide the last value in a HiddenField or ViewState or somewhere like that...
If you need to change images to the next in the sequence if you hit the F5 or similar refresh button, then you need to store the last image id or something in a server-side storage, or in a cookie. Use a Session variable or similar.
Is this an intranet environment? If so they shouldn't have to login anyways. If sharepoint is setup using "Integrated Authentication" and the site is listed as a trusted site in IE, the browser will use there network cred for auto login. This can be setup on [firefox][1] as well. [1]: http://www.cauldwell.net...
I've always wondered how costly it is to *always* assume that invoke is required... private void OnCoolEvent(CoolObjectEventArgs e) { BeginInvoke((o,e) => /*do work here*/, new object[] {this, e}); }
I've always wondered how costly it is to *always* assume that invoke is required... private void OnCoolEvent(CoolObjectEventArgs e) { BeginInvoke((o,e) => /*do work here*/,this, e); }
Doing anything with RTF is pretty difficult unless you're using the windows forms. As stated above, using forms is the easiest way to go. You could write something yourself, but the RTF spec is pretty complicated. http://www.biblioscape.com/rtf15_spec.htm Or you could use a conversion DLL / ActiveX object of w...
[jQuery inline search plugin][1] [1]: http://vision-media.ca/resources/jquery/jquery-inline-search-plugin
If I understand your question, you are asking if it is possible to allow a user to type in a query that will search the text of page they are on? You can certainly do that. I would suggest looking into one of the javascript libraries, [jQuery][1] is my library of choice, for your functionality. It has a rich selec...
Are you sure you need do this mail queuing yourself? Just deliver all mail to the local machine's mail transfer agent (sendmail...) and let that take care of the queuing and sending. After all, that's what was designed for. In other words: don't worry about it!
Use the read(1) command to read one line at a time from standard input, then output the line prepended with the date in the format of your choosing using date(1). $ cat timestamp #!/bin/sh while read line do echo `date` $line done $ cat somefile.txt | ./timestamp
Python is easy for new developers to learn. You don't get tangled up in the specifics of memory management and type definition. [Dive Into Python][1] is a good beginners guide to python programming. When my sister wanted to learn programing I pointed her to the "Head Start" line of books which she found very easy to re...
My regex is matching too much. How do I make it stop?
|regex|
I have to second the comment by @Phil Bennett as I try to approach these integration tests with a rollback solution. I have a very detailed post about integration testing your data access layer [here][1] I show not only the sample data access class, base class, and sample DB transaction fixture class, but a full ...
I have to second the comment by @Phil Bennett as I try to approach these integration tests with a rollback solution. I have a very detailed post about integration testing your data access layer [here][1] I show not only the sample data access class, base class, and sample DB transaction fixture class, but a full ...
int num = 1; if(Session["ImageNumber"] != null) { num = Convert.ToInt32(Session["ImageNumber"]) + 1; } Session["ImageNumber"] = num;
You can store data in your page's `ViewState` dictionary So in your Page_Load you could write something like... var lastPicNum = (int)ViewState["lastPic"]; lastPicNum++; MainPic.ImageUrl = string.Format("{0}.jpg", lastPicNum); ViewState["lastPic"] = lastPicNum; you should get the idea.
You can store data in your page's [`ViewState`][1] dictionary So in your Page_Load you could write something like... var lastPicNum = (int)ViewState["lastPic"]; lastPicNum++; MainPic.ImageUrl = string.Format("~/Images/{0}.jpg", lastPicNum); ViewState["lastPic"] = lastPicNum; you should ...
It depends on how long you want it to persist (remember) the last viewed value. My preferred choice would be the SESSION.
I do a lot of simplifying of configuration. That is I wrap the generation/management of configuration values inside a UI. The primary benefit is I can control work flow and presentation to make it simpler for non-techie users to configure apps/sites/services.
Well, if you can invoke the tools programmatically without the command line, that would probably be your best option. Otherwise, you could potentially execute the command line tool via a user that has absolutely no access to do anything (except perhaps a single directory that they can't do any harm with)... though tha...
I have one setup using the Ruby Tinder library that I send to a campfire room, if anyone wants the script I can post or send the code to you. Other common ones I've seen are posts to bug tracking systems and email notifications.
I must say i find the other question very interesting. There is one serious problem though - parse this: 08/07/06! If you limit yourself on a subset of expected formats, you could probably solve problem by playing around with regexps, you could build up bunch of expected patterns, and then break Strings on spaces or wh...
Flex and ADO.NET Data Services...anyone done it?
|apache-flex|ado.net|
Has anyone used ADO.NET Data Services as a data source for Adobe Flex applications? If so, any success stories or tragedies to avoid? If you did use it, how did you handle security?
In Python, there is a difference between functions and bound methods. >>> def foo(): ... print "foo" ... >>> class A: ... def bar( self ): ... print "bar" ... >>> a = A() >>> foo <function foo at 0x00A98D70> >>> a.bar <bound method A.bar of <...
I've heard good things about [clang static analyzer][1], which IIRC uses LLVM as it's backend. If that's implemented on your platform, that might be a good choice. From what I understand, it does a bit more than just syntax analysis. "Automatic Bug Finding", for instance. [1]: http://clang.llvm.org/StaticAnal...
I assume you're trying to make the command interface as forgiving as possible. If this is the case, I suggest you use an algorithm similar to this: 1. Read in the string - Split the string into tokens - Use a dictionary to convert synonyms to a common form - For example, convert "hit", "punch", "strike", a...
In our databases we use an enum that ensures we pass it either TRUE or FALSE. If you do it either of the first two ways it is too easy to either start adding new meaning to the integer without going through a proper design, or ending up with that char field having Y, y, N, n, T, t, F, f values and having to remember w...
I found [this][1] link useful. [1]: http://articles.techrepublic.com.com/5100-10878_11-5229553.html
Monitoring files - how to know when a file is complete
|.net|filesystems|
We have several .NET applications that monitor a directory for new files, using FileSystemWatcher. The files are copied from another location, uploaded via FTP, etc. When they come in, the files are processed in one way or another. However, one problem that I have never seen a satisfactory answer for is: for large file...
Have discovered that this only occurs when the script is run on a different drive to the one where the EXE is located. As a work around for this I have simply moved the scripts execution. Apparently the DLL relates to SSL, which isn't relevant to what I'm doing, so this is a suitable workaround. I'm guessing that ...
Unless the developers you are working with are familiar with MVC pattern I wouldn't. At a minimum I'd talk with them first before making such a big change.
I believe UIApplication has an openURL method, that will perform the normal iPhone magical URL reinterpretation. so [someUIApplication openURL:[[NSURL alloc] initWithString: @"http://maps.google.com/maps?g=London"]] should invoke the Google maps app. (This info is available from the unoffical SDK documenta...
How to know if a line intersects a plane in C#? - Basic 2D geometry
|c#|2d|
my school maths are very rusty and I think this is a good opportunity to take advance of this community :D I have two points (a line) and a rectangle, I would like to know how to calculate if the line intersects the rectangle, my first approach had so many "if" statements that the compiler sent me a link to this sit...
Sacha Barber has a great series of articles on WPF for Beginners over at Codeproject that you can check out. - [An Introduction to the WPF Layout System][1] - [An introduction into XAML / code and WPF resources][2] - [An introduction into RoutedEvents / RoutedCommands][3] - [An introduction into WPF Depen...
I have to second the comment by @Phil Bennett as I try to approach these integration tests with a rollback solution. I have a very detailed post about integration testing your data access layer [here][1] I show not only the sample data access class, base class, and sample DB transaction fixture class, but a full ...
Any way to have an ActionScript 3 (Flex/AIR) project print to standard output?
|apache-flex|flash|actionscript-3|adobe|
Is there any way to have a binary compiled from an ActionScript 3 project print stuff to *stdout* when executed? From what I've gathered, people have been going around this limitation by writing hacks that rely on local socket connections and AIR apps that write to files in the local filesystem, but that's pretty mu...
Struct like objects in Java
I like Justin's suggestion, but I'll add to it: this solution is great for learning a language. If you don't rely on something like code-completion, then it forces you to learn the language better. (If you are working with something with a huge API, like Java or Cocoa, then you'll want the code completion, however!) ...
Bringing Window to the Front in C# using Win32 API
|c#|winapi|
I am writing an application that needs to bring window of an external app to the foreground, and not necessarily steal focus (there is a setting the user can toggle to steal/not steal focus). What is the best way to go about this using the win32 API? I have tried SetForeground() but it always steals focus and does ...
SetForegroundWindow is supposed to steal focus and there are certain cases where it will fail. > The SetForegroundWindow function puts the thread that created the specified window into the foreground and activates the window. Keyboard input is directed to the window Try capturing the focus with [SetCapture](http:...
Reverse DNS in Ruby?
|ruby|sockets|dns|nslookup|
I'm in an environment with a lot of computers that haven't been properly inventoried. Basically, no one knows which IP goes with which mac address and which hostname. So I wrote the following: # This script goes down the entire IP range and attempts to # retrieve the Hostname and mac address and outputs t...
<p>A "race condition" exists when multithreaded (or otherwise parallel) code that would access a shared resource could do so in such as way as to cause unexpected results.</p> Take this example: <pre><code> for ( int i = 0; i &lt; 10000000; i++ ) { x = x + 1; } </code></pre> <p>If you had 5 threads ...
You've probably got the right code, but you also need to add CODE_ANALYSIS as a precompiler defined symbol in the project properties. I think those SuppressMessage attributes are only left in the compiled binaries if CODE_ANALYSIS is defined.
Excluding FxCop rule in source.
|fxcop|initializecomponent|suppression|
In a project I'm working on FxCop shows me lots of (and I mean more than 400) errors on the InitializeComponent() methods generated by the Windows Forms designer. Most of those errors are just the assignment of the Text property of labels. I'd like to suppress those methods in source, so I copied the suppression cod...
In a project I'm working on FxCop shows me lots of (and I mean more than 400) errors on the InitializeComponent() methods generated by the Windows Forms designer. Most of those errors are just the assignment of the Text property of labels. I'd like to suppress those methods in source, so I copied the suppression cod...
Well, since `TimeZoneInfo` is excluded, you're probably not going to find a solution in the framework itself (but don't quote me on that). In which case, have you considered reflectoring the `TimeZoneInfo` class and using what you find there?
General programming translates terribly to GPUs. GPUs are dedicated to performing fairly simple tasks on streams of data at a massive rate, with massive parallelism. They do not deal well with the rich data and control structures of general programming, and there's no point trying to shoehorn that into them.
Well, I think the reason this is the case is because "qwerty = 4" is ambiguous. Are you defining a new variable called "qwerty" or calling the accessor? Ruby resolves this ambiguity by saying it will create a new variable, thus the "self." is required. Here is another case where you need "self.": class A ...
Well, I think the reason this is the case is because "qwerty = 4" is ambiguous... are you defining a new variable called "qwerty" or calling the setter? Ruby resolves this ambiguity by saying it will create a new variable, thus the "self." is required. Here is another case where you need "self.": class A ...
Hmmm... It sounds like you have a list of valid commands that the users are able to execute. But you don't want them to execute them all. You could try to take the actual command line and verify the file exists in the "safe" location at least. You could also solve the problem with more interface, provide a dro...
Here's an (untested) theory, the details of which will greatly depend on what types of authentication the Sharepoint site will accept. I'll tackle [Basic][1], since it's the easiest. You'll write out some JavaScript that uses XMLHttpRequest to submit a request to the Sharepoint site, and add their username and passw...
|java|design|struct|
Is it completely against the Java way to create struct like objects? class SomeData1 { public int x; public int y; } I can see a class with accessors and mutators being more Java like. class SomeData2 { int getX(); void setX(int x); int getY()...
|java|design|oop|struct|
Using Django time/date widgets in custom form
|django|
How can i use the nifty js date and time widgets that the default admin uses with my custom view? I have looked through http://www.djangoproject.com/documentation/forms/ , and it brefly mentions django.contrib.admin.widgets, but i don't know how to use it? Here is my template that i want it applied on. <fo...
|python|django|
I solved this exact same problem just two days ago. First, I moved the code that set the SelectedValue to a PreRender handler for the DropDownList. Then, I add logic to first check to see if the value is in the drop down list. If not, I add it. Here's my code. ddSpecialty is my drop-down list, populated with "specia...