instruction
stringlengths
0
30k
How do I see the list of open files within emacs? Or browse a directory within emacs?
|emacs|
Most text editors have a navigation pane that lets you see all the files you currently have open. Or a pane that lets you browse a file directory. How do I do this in emacs?
As far as I know, all classes in C# (not sure about the others) are reference types.
We will need more info to resolve this.. What you're saying here appears correct to me. You're using the Socket class to send data though, not ByteArray. Are you sure data is not being sent? How are you receiving the response? It may be that it's working fine but you're just not aware of it? As i said, tell us more ...
If I understand the question right, you're asking whether it's a good practice to mix markup with back-end code. No. While this is commonly done, it's still a bad idea. You should read up on the [MVC][1] paradigm, as well as on existing questions on the matter, such as [What is the best way to migrate an existing me...
How would you refactor this LINQ code?
|c#|.net|linq|linq-to-sql|
I've got a lot of ugly code that looks like this: if (!string.IsNullOrEmpty(ddlFileName.SelectedItem.Text)) results = results.Where(x => x.FileName.Contains(ddlFileName.SelectedValue)); if (chkFileName.Checked) results = results.Where(x => string.IsNullOrEmpty(x.FileName)); if (!str...
If you are doing one write and a lot of reads, take the parsing hit at write time, and get that data into some format that is more query-able. A first suggestion would be to parse them into a related but separate table, with name/value/contactID columns.
Hair pulling, screaming at VSS for lost source code, etc. Seriously though, it is a very different model (optimistic locking) so you will probably lose some productivity for the first little while. I would probably look at using TortoiseCVS and "Open Folder In Windows Explorer" right-click or the [Visual Studio Explo...
query.UniqueResult<T>() returns just one T
CAPTCHA's check if you are human or computer. The problem is that after that a computer needs to judge whether you are human so a solution would be to let one user fill out a captcha and let the next user check it. The problem is of course the time gap
All of .net is available in the .net SDK, so in theory you will not need Visual Studio at all. Now, there are some things that Express will not do. For example, the Database Designer is not very comprehensive and adding different remote databases is not or only very hardly possible. Still, in code you can connect to...
On general tips; We are implementing a process of 1) Business Requirements Statement (BRS) 2) Functional Specification 3) Technical specification The BRS covers what the business problems are, and what the requirements are around solutions, testing, security, reliability and delivery. This defines wha...
As far as I know a process doesn't have an explicit list of its children's PIDs, but it can easily be built, since a process should know which child processes it spawns. For example the UNIX fork() call returns the child PID in the parent process and 0 in the child process, CreateProcess() on Windows returns (IIRC) the...
If you're using Linux or anything which implements the Unix APIs, when a process calls fork() to create a child process the parent receives the child PID as the return code, or -1 if the fork failed. The child process gets a zero return code.
Getting the array key in a foreach loop
|c#|array|
Bear in mind I'm very new to C#. I'm trying to get the key of the current element in a foreach loop. I know how to do this in PHP but I'm clueless with C#. For example: foreach($array as $key => $value) { echo("$value is assigned to key: $key"); } What I'm trying to do in C#: in...
|c#|arrays|
@Paul Lalonde The app's installer is wrapped within a custom InnoSetup Installer. The InnoSetup installer, in turn, is manually executed by the logged in user. That said, the uninstall is trigged by a service running under the Local System account. Apparently, you were on to something. I put together a quick te...
http://www.xheo.com/products/codeveil/Default.aspx Done the job for me in the past.
Thanks to those offering help. This is a permissions issue. I have updated my service to run under an Administrator account and it was able to successfully uninstall the third-party application. To Orion's point, though the Local System account is a powerful account that has full access to the system -- http://technet....
Thanks to those offering help. This appears to be a permissions issue. I have updated my service to run under an Administrator account and it was able to successfully uninstall the third-party application. To Orion's point, though the Local System account is a powerful account that has full access to the system -- http...
For the method/assembly to figure out US Holidays, basically just figure out all the major holidays and the "formula" that they use. For the ones that never change, like Christmas, it's easy - December 25th. For the ones that do change somewhat, there's usually a formula - like the third Monday in February bein...
the topic is covered in [django tutorials][1] [1]: http://www.djangoproject.com/documentation/
I'd say that anyone that finds the answer should keep it to themselves, and instead of posting it should just add a note that you can go read a particular url to find it, or send someone an email or something if they want to know the answer to it. At the time when Channel9 says its broken or posts the answer themselves...
How do you parse an IP address string in C#?
|networking|winapi|iphelper|
I'm writing C# code that uses the windows IP Helper API. One of the functions I'm trying to call is "[GetBestInterface][1]" that takes a 'uint' representation of an IP. What I need is to parse a textual representation of the IP to create the 'uint' representation. I've found some examples via Google, like [this one]...
Zack, if I understand right you want unlimited depth of the subcategories. No biggie, since MVC Preview 3 (I think 3 or 4) this has been solved. Just define a route like "{controller}/{action}/{*categoryPath}" for an url such as : http://example.com/shop/products/household/kitchen/cookware/cooksets/nonstick...
How do you create objects in Perl?
|oop|perl|syntax|
Perl has OOP features, but they are somewhat rarely used. How do you create and use Perl objects with methods and properties?
|perl|oop|syntax|
High-pass: high-frequency (detailed information) can pass. Low-pass: low-frequency (coarse/rough information) can pass.
**High-pass** filter lets *high*-frequency (detailed/local information) *pass*. **Low-pass** filter lets *low*-frequency (coarse/rough/global information) *pass*.
Id say your best bet is have a Direct3D/OpenGL app running on the server (without stopping). THen making the server page send a request to the rendering app, and have the rendering app snend a jpg/png/whatever back. * If Direct3D/OpenGL is to slow to render the scene in hardware, then any software solution will be w...
There are icon packs available at http://iconpacks.mozdev.org/ that work by installing an extension. If you want to use your own icon, extensions are just zipped files so change the extension from xpi to zip and examine the source code and images it contains to customize it. If you do customize it, I suggest changing...
Well, and this stretching, you need to debug your tests. Also, there is a certain cost in time for writing the tests, though most people agree that it's an up-front investment that pays off over the lifetime of the application in both time saved debugging and in stability. The biggest problem I've personally had wit...
Be warned, running aspnet_regiis -i will remap all of your IIS websites to 2.0. If you have existing 1.1 applications that you want to keep, run aspnet_regiis -ir instead. This will set 2.0 to be the default runtime for IIS, but it won't change the script mappings for existing sites.
JVisualVM from the bin directory in the JDK distribution. Monitoring and even profiling any java application, even one you didn't launch with any special parameters. Only in recent versions of the Java 6SE JDK.
You can use the underbar prefix on your ivars and still use the non-underbar name for your properties. For synthesized accessors, just do this: @synthesize foo = _foo; This tells the compiler to synthesize the foo property using the_foo ivar. If you write your own accessors, then you just use the underbar ...
I second the answer about initial development time. You also lose the ability to confortably work without the safety of tests. I've also been described as a TDD nutbar, so you could lose a few friends ;)
It's percieved as slower. Long term that's not true in terms of the grief it will save you down the road, but you'll end up writing more code so arguably you're spending time on "testing not coding". It's a flawed argument, but you did ask!
The problem with using public field access is the same problem as using new instead of a factory method - if you change your mind later, all existing callers are broken. So, from an API evolution point of view, it's usually a good idea to bite the bullet and use getters/setters. One place where I go the other way i...
Visual Studio is just an IDE, you can do all your .NET development with the SDK and notepad if you choose. In fact there is something to be said for learning it that way so you understand better how the pieces fit together! Microsoft have a [version comparison matrix][1] available so you can see exactly what is inc...
Visual Studio is the IDE and does not include the platform. IIS and SQL Server are separate products. IIS is available as part of the windows install and the version is different depending on what version of Windows you are using. SQL Server also has an express product which is not as full featured as the Full ve...
Table driven designs can be effective. Steve Maguire had few nice examples in _Writing_ _Solid_ _Code_ . They are also a great way to capture tests, see [fit](http://fit.c2.com/) . In your case something like: Field1ReadonlyRules = { 'user class 1' : True, 'user class 2' : False } ...
Visual Studio is just the IDE. You could theoretically create every file in Notepad and compile manually with just the .net framework. IIS is an operating system feature, and SQL Server has different flavors with different capabilites.
[SharpDevelop][1] is a Open Source IDE for C# and VB.net [1]: http://sharpdevelop.net/OpenSource/SD/
ASP.NET ObjectDataSource Binding Automatically to Repeater - Possible?
|asp.net|repeater|bind|objectdatasource|
I have a Question class: class Question { public int QuestionNumber { get; set; } public string Question { get; set; } public string Answer { get; set; } } Now I make an ICollection of these available through an ObjectDataSource, and display them using a Repeater bound to the D...
I've got a lot of ugly code that looks like this: if (!string.IsNullOrEmpty(ddlFileName.SelectedItem.Text)) results = results.Where(x => x.FileName.Contains(ddlFileName.SelectedValue)); if (chkFileName.Checked) results = results.Where(x => x.FileName == null); if (!string.IsNullOrEm...
|c#|.net|linq|linq-to-sql|
linq to sql stack overflow with self-referencing entity
|linq-to-sql|lazy-loading|
I have an entity that contains many of itself, how do I map this in LINQ to SQl such that it does not do an infinite loop of getting e1 then all its children then their parents (e1) then its children and repeat? Now I know I can do this if I set the child property to false, however that is the most important property (...
|linq-to-sql|lazy-loading|
printf( "Player %d", i ); (Downvote my answer all you like, I still hate the C++ IO operators.) :-P
In LINQ to SQL how can I make it so I can add items to a collection of an entity without saving the entity first?
|linq-to-sql|
var e1 = new E1(); e1.e2s.Add(new e2()); //e2s is null until e1 is saved, i want to save them all at the same time context.e1s.imsertonsubmit(e1); context.submitchanges();
|linq-to-sql|
The following link has an example of search and replace using a pure batch file [BatchFindAndReplace][1]. It uses a combination of FOR, FIND and CALL SET. [1]: http://www.dostips.com/DtCodeBatchFiles.php#Batch_FindAndReplace
Well, if you use cout you can just write the integer directly to it, as in std::cout << text << i; The C++ way of converting all kinds of objects to strings is through streams. If you don't have one handy, just create one. `#include &lt;sstream> std::ostringstream oss; oss << text << i; std::cout << oss.s...
Download cygwin (free) and use unix-like commands in msdos.
There's a web service at [http://www.holidaywebservice.com][1] which will provide dates of holidays for the USA, Republic of Ireland, England and Scotland. They also sell a DLL and source code. As for details of algorithms, you could do worse than check out the excellent [Calendrical Calculations][2] book (third edi...
There's a web service at [http://www.holidaywebservice.com][1] which will provide dates of holidays for the USA, Republic of Ireland, England and Scotland. They also sell a DLL and source code. As for details of algorithms, you could do worse than check out the excellent [Calendrical Calculations][2] book (third edi...
So basically you want to determine the number of digits after the decimal point for each number. This would be rather easier if you had the binary representation of the number. Are the numbers being converted from rationals or scientific notation earlier in your program? If so, you could skip the earlier convers...
My first guess would be Client Tool corruption. I've occasionally had to uninstall my client tools and reinstall them. Boot after uninstall.
As well as having third party libraries in your repository, it's worth doing it in such a way that makes it easy to track and merge in future updates to the library easily (for example, security fixes etc.). If you are using Subversion using a proper [vendor branch](http://svnbook.red-bean.com/en/1.4/svn-book.html#svn....
A good example of doing this without using Ajax is given [at CodeProject by Nilesh Thakkar][1]. [1]: http://www.codeproject.com/KB/aspnet/Simple_Progress_bar.aspx
I cringe every time I use `create_function()` in php. Parameters are a coma separated string, the whole function body in a string... Argh... I think they could not have made it uglier even if they tried. Unfortunately, it is the only choice when creating a named function is not worth the trouble.
Not sure there is anything perfect for this. MyXAML was kicking about a few years ago that enabled you to add forms in XML as opposed to embedding them into the binary. Not sure if that project is dead or not. WinForm does have the flow layout control already However if you want to do this kind of thing proper...
You may also want to consider using Windows Presentation Foundation (WPF) instead of WinForms - WPF has an XML declarative markup language (XAML) that works well for defining scalable UI.
If there's no hope of changing the canonical names, you could alias the getters and setters manually: def variable_name send 'variable.name' end def variable_name=(value) send 'variable.name=', value end
Years ago an wise old programmer taught me the evils of [Hungarian notation][1], this was a real legacy system, Microsoft adopted it some what in the Windows SDK, and later in MFC. It was designed around loose typed languages like C, and not for strong typed languages like C++. At the time I was programming Windows 3.0...
+1 for Visual Assist And I will add [VLH][1] (Visual Local History) wich provide a kind of local source control system. Every time you save a file, the plugin add a copy in the local repository, and you can see diff between local revision. [1]: http://www.codeplex.com/VLH2005
+1 for Visual Assist And I will add [VLH][1] (Visual Local History) which provides a kind of local source control system. Every time you save a file, the plugin add a copy in the local repository. [1]: http://www.codeplex.com/VLH2005
Never used xUnit, so I can't tell you if the frameworks are good/bad comparativly, but [here](http://github.com/dbr/tvdb_api/tree/master/tvdb_api.py#L518-575) is a script I wrote which uses the unittest framework (to check the API works as it should), and the doctest (to check the examples I've given work) My only p...
[Antlr][1] supports C# code generation, though it is LL(k) not technically LALR. Its tree rewriting rules are an interesting feature though. [1]: http://antlr.org/
I currently am working on a codebase where two of the people working on it blindly subscribe to the "single point of exit" theory and I can tell you that from experience, it's a horrible horrible practice. It makes code extremely difficult to maintain and I'll show you why. With the "single point of exit" theory, y...
I would add : Provide real unsubscription upon click on "Unsubscribe". I've seen real newsletters providing a dummy unsubscription link that upon click shows "<my@email.com> has been unsubscribed successfully" but I will still receive further newsletters.
@Motti's answer doesn't ignore ADVER lines, but you easily pipe the results of that grep to another: grep -Ev "^\$.*\*[0-9A-Fa-f]{2}$" a.txt |grep -v ADVER
Flash, used well, allows easy localization and internationalization. Furthermore, it is much easier to use Flash in an accessible manner; you can feed screen readers the right text, instead of having them iterate over all of the possible form elements.
What is the best way to avoid getting "Emacs Pinky"?
|emacs|keyboard|
I just started using GNU Emacs as my text editor and I am concerned about getting afflicted with "[Emacs Pinky][1]" by having to constantly press the control key with my pinky finger as is required when using Emacs. How can I avoid potentially getting this type of repetitive strain injury? [1]: http://en.wikiped...
When I'm not able to use C# 3.0, I use a helper function that translates a set of parameters into a dictionary. public IDictionary<KeyType, ValueType> Dict<KeyType, ValueType>(params object[] data) { Dictionary<KeyType, ValueType> dict = new Dictionary<KeyType, ValueType>((data == null ? 0 :data.Le...
Making caps lock another control key is a good place to start. Invest in an ergonomic keyboard. Some emacs users even go as far as to get foot pedal things for control and meta...
Patterns for the overlap of two objects
|pattern|intersection|object|
I'm sure this has already been asked and answered so I apologize in advance for that but I'm not figuring out the correct keywords to search for. Searching for "Pattern" hits way too many Q & A's to be useful. I'm working on a regression testing app. I'm displaying a form on the screen and according to which user ...
Another minor difference, between using * and a specific column, is that in the column case you can add the keyword DISTINCT, and restrict the count to distinct values: select column_name, count(distinct column_name) from table group by column_name having count(column_name) > 1;
Another minor difference, between using * and a specific column, is that in the column case you can add the keyword DISTINCT, and restrict the count to distinct values: select column_a, count(distinct column_b) from table group by column_a having count(distinct column_b) > 1;
[Grauenwolf's way][1] is the most straightforward and performant way of doing this with an array: > Either use a for loop or create a temp variable that you increment on each pass. Which would of course look like this: int[] values = { 5, 14, 29, 49, 99, 150, 999 }; for (int key = 0; key < values.Le...
I suggest starting with a plain old c project that reads and parses NMEA from a serial port. You can do this in Windows or Linux. I usually break down any project like this into a set of smaller projects like: 1. read and parse NMEA from serial port 2. establish a serial / network link from the...