instruction stringlengths 0 30k ⌀ |
|---|
|c#|.net|winforms| |
I'm developing a WinForms application (.Net 3.5, no WPF) where I want to be able to display foreign key lookups in a databound datagridview.
An example of the sort of relationship is that I have a table of orderlines. Orderslines have a foreign key relationship to Products and Products in turn have a foreign key r... |
How do you get the filename of a tempfile to use in Linux? |
|tempfile|linux|c| |
Let's say I'm creating a program in C that needs to use a tempfile. Creating an ad hoc tempfile in /tmp is probably not a good idea. Is there a function or OS call to supply me with a tempfile name so that I can begin to write and read from it? |
|c|linux| |
You can use the [`mkstemp(3)`][1] function for this purpose. Another alternative is the [`tmpfile(3)`][2] function.
Which one of them you choose depends on whether you want the file to be opened as a C library file stream (which `tmpfile` does), or a direct file descriptor (`mkstemp`). The `tmpfile` function also dele... |
Absolutely: man mkstemp.
The man page has example usage.
|
@dragonmantank
In Xinc's case, I hope you used PEAR to install it.
pear list-files xinc/Xinc
This should do it, and show you where your Xinc install put its files. So even though Xinc is "just" one big PHP script, it's still spread out into rc scripts and all those other things which are necessary to make ... |
If your willing to use JQuery, I would use [Set Hover Class for Anything][1] technique.
[1]: http://www.learningjquery.com/2007/02/quick-tip-set-hover-class-for-anything |
designing Panels without a parent Form in VS? |
|visual-studio| |
Does anyone know of any tools/plugins that allow you to design a Panel independently of a Form (Windows, not Web Form) within Visual Studio?
I've been using the designer and manually extracting the bits I want from the source, but surely there is a nicer way. |
You could just write the code by hand! |
> I've found a few bits of software that suggest they might do this - but they either
> refuse to compile, or don't seem to work properly. Has anyone got any suggestions?
Write one. You're best off picking a nice, simple instruction set (Z80 should be perfect). I remember doing this as a first-year undergraduate ex... |
Either 1/0 or Y/N with a check constraint on it. ether way is fine. I personally prefer 1/0 as I do alot of work in perl, and it makes it really easy to do perl Boolean operations on database fields.
If you want a really in depth discussion of this question with one of Oracles head honchos, check out what Tom Kyte h... |
Another alternative that will fix many more issues in one go is to use [IE7.js][1].
[1]: http://code.google.com/p/ie7-js/ |
You could do all the design work inside of a UserControl.
If you go that route, instead of just copying the bits out of the user control, simply use the user control itself. |
I'd strongly recommend saving each request to some file.
--
This way, you can always go back to the actual contents of it later. You can thank me later, when you find that hostile-endian, koi-8 encoded, [...], whatever it was that stumped your parser... |
How to enable multisampling for a wxWidgets OpenGL application? |
|opengl|wxwidgets|multisampling| |
**[Multisampling][1]** is a way of applying **full screen anti-aliasing** (FSAA) in 3D applications. I need to use multisampling in my OpenGL application, which is currently embedded in a **wxWidgets** GUI. Is there a way to do this? Please respond only if you know the detailed steps to achieve this.
I'm aware that ... |
**[Multisampling][1]** is a way of applying **full screen anti-aliasing** (FSAA) in 3D applications. I need to use multisampling in my OpenGL application, which is currently embedded in a **wxWidgets** GUI. Is there a way to do this? Please respond only if you know the detailed steps to achieve this.
I'm aware of en... |
How to enable multisampling for a wxWidgets OpenGL program? |
**[Multisampling][1]** is a way of applying **full screen anti-aliasing** (FSAA) in 3D applications. I need to use multisampling in my OpenGL program, which is currently embedded in a **wxWidgets** GUI. Is there a way to do this? Please respond only if you know the detailed steps to achieve this.
I'm aware of enabli... |
There is a good article from 4 guys about [Encrypting Configuration Information in ASP.NET 2.0 Applications][1]
Hope this helps
[1]: https://web.archive.org/web/20211029043331/https://aspnet.4guysfromrolla.com/articles/021506-1.aspx |
mktime(...)
mktime(tuple) -> floating point number
Convert a time tuple in local time to seconds since the Epoch.
local time... fancy that.
The time tuple:
The other representation is a tuple of 9 integers giving local time.
The tuple items are:
year (four digits... |
Theoretically, no, they are not unique. It's possible to generate an identical guid over and over. However, the chances of it happening are so low that you can assume they are unique.
I've read before that the chances are so low that you really should stress about something else--like your server spontaneously combu... |
I haven't tried it myself, but [Huagati DBML/EDMX Tools][1] is recommended by other people.
> Huagati DBML/EDMX Tools is an add-in
> for Visual Studio that adds
> functionality to the Linq2SQL/DBML
> diagram designer in Visual Studio
> 2008, and to the ADO.NET Entity
> Framework designer in Visual Studio
> 200... |
@e-bartek, I think that window[functionName] won't work if you in some closure, and the function name is local to that closure. For example:
function foo() {
var bar = function () {
alert('hello world');
};
var s = 'bar';
window[s](); // this won't work
}
... |
Here are a few resources that might help you in your quest to create browser helper objects (BHO).
[http://petesearch.com/wiki/][1]
[http://www.hackszine.com/blog/archive/2007/06/howto_port_firefox_extensions.html][2]
[http://msdn.microsoft.com/en-us/library/ms182554(VS.80).aspx][3]
http://www.codeplex.com/... |
We have also used UTL_HTTP in a manner similar to what you have described. I don't have any direct experience with UTL_DBWS, so I hope you can follow up with any information/experience you can gather.
@kogus, no it's a quite good design for many applications. PL/SQL is a full-fledged programming language that has b... |
One thing that comes to mind is that you could have each thread writing to its own log file and then do a daily batch run to combine them.
If you are logging to database you probably need to do some tuning and optimization, especially if the DB will be across the network. At the least you will need to be reusing the... |
Not sure about anything in a C lib, but you can do this at the shell with [mktemp][1].
[1]: http://linux.die.net/man/1/mktemp |
> I'm starting to think it can't be done that way since there doesn't seem to be a way to maintain the offset counter between calls. Is that right, or is there something I'm missing.
You aren't missing anything; SQL Server does not support global variables, and it doesn't support data modification within UDFs. And ... |
welcome to StackOverflow :)
Normally what you would do is base the information in the drop down on two values [ValueMember and DisplayMember](http://windowsclient.net/blogs/faqs/archive/2006/07/12/what-are-the-displaymember-and-valuemember.aspx).
The ValueMember is the source of the actual controls value (this wi... |
How to catch SQLServer timeout exceptions |
|c#|.net|sql-server|error-handling| |
I need to specifically catch SQL server timeout exceptions so that they can be handled differently. I know I could catch the SqlException and then check if the message string Contains "Timeout" but was wondering if there is a better way to do it?
try
{
//some code
}
catch (SqlException e... |
Free Wavetable Synthesizer? |
|audio|microcontroller|arm|synth| |
I need to implement a [wavetable synthesizer][1] in an ARM Cortex-M3 core. I'm looking for any code or tools to help me get started.
I'm aware of [this AVR implementation][2]. I actually converted it to a PIC a while back. Now I am looking for something similar, but a little better sounding.
ANSI C code would be ... |
It should just fine. However some spam filters will do a reverse lookup on the originating IP address and see if it's assigned to the domain name the email claims to be from, and some may check to see if the IP is an actual MX for the domain.
So the downside is that some recipients may never get the email, and you m... |
In C, C++ and Java, the statement:
<code><pre>
if (condition1 | condition2) {
...
}
</code></pre>
will evaluate both conditions every time and only be true if the entire expression is true.
The statement:
<pre><code>
if (condition1 || condition2) {
...
}
</pre></code>
will evaluate <code>condi... |
I have seen this once before when one of my models was not mapped correctly (wasn't using nullable types correctly). May you please paste your model and mapping? |
This puzzle is explained at [http://www.math.princeton.edu/~wwong/blog/blog200608191813.shtml][1] and that person does a much better job of explaining the problem.
The "all prisoners are killed" statement is wrong.
The "you can save 30+ on average" is also wrong, the [article][1] says that 30% of the time you can s... |
One of the common linking errors I've run into is when a function is used differently from how it's defined. If you see such an error you should make sure that every function you use is properly declared in some .h file.
You should also make sure that all the relevant source files are compiled into the same lib fil... |
The name "lambda" is just a historical artifact. All we're talking about is an expression whose value is a function.
A simple example (using Scala for the next line) is:
args.foreach(arg => println(arg))
where the argument to the `foreach` method is an expression for an anonymous function. The above line i... |
You should probably target the Windows Mobile platform. The Palm platform is rather archaic and no longer widely used. The development environment is also rather spartan, while Microsoft has full IDEs available for Windows Mobile development. You might also consider the iPhone/iPod touch platform - I have a feeling the... |
The new v8 engine which [should come out][1] today supports it (i think)
[1]: http://googleblog.blogspot.com/2008/09/fresh-take-on-browser.html |
You can use SQLMetal.exe to generate your dbml and or cs/vb file. Use a pre-build script to start it and target the directory where your datacontext project belongs. |
You can use SQLMetal.exe to generate your dbml and or cs/vb file. Use a pre-build script to start it and target the directory where your datacontext project belongs.
C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64\sqlmetal.exe
/server:<SERVER>
/database:<database>
/code:"path\Solu... |
How do I create a database programatically in SQL Server? |
|.net|sql-server| |
I would like to create a new database from my C# application.
How can I do that?
I'm assuming once I create it, I can simply generate a connection string on the fly and connect to it, and the issue all the CREATE TABLE statements. |
I'm with @Shaun Austin - try wrapping the try with the fully qualified name
catch (System.Exception)
and see if that helps.Does the ANTLR doc say what Exceptions should be thrown? |
There is a tool in Ant called a classfileset. You specify the list of root classes that you know you need, and then the classfileset recursively analyzes their code to find all dependencies.
Alternatively, you could develop a good test suite that exercises all of the functions that you need, then run your tests unde... |
You should probably at least evaluate the Apple [iPod Touch][1]. It certainly meets your basic "touch screen + WiFi" spec, and your users presumably won't object to all the the other nice features that will come along for the ride.
I don't know what your cutoff for "cheap" is, but $299 for the base model seems pret... |
[KB307283][1] explains how to create a database using ADO.NET.
From the article:
String str;
SqlConnection myConn = new SqlConnection ("Server=localhost;Integrated security=SSPI;database=master");
str = "CREATE DATABASE MyDatabase ON PRIMARY " +
"(NAME = MyDatabase_Data, " +
... |
There are some libraries, such as MDB2 in PEAR that make querying a bit easier and safer.
Unfortunately, they can be a bit wordy to set up, and you sometimes have to pass them the same info twice. I've used MDB2 in a couple of projects, and I tended to write a thin veneer around it, especially for specifying the ty... |
There are some libraries, such as MDB2 in PEAR that make querying a bit easier and safer.
Unfortunately, they can be a bit wordy to set up, and you sometimes have to pass them the same info twice. I've used MDB2 in a couple of projects, and I tended to write a thin veneer around it, especially for specifying the ty... |
Whats the value for the SqlException.ErrorCode property? Can you work with that?
Seems like [this guy](http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1919880&SiteID=1&pageid=0) is having timeouts, may be worth checking the code for **-2146232060**.
I would set this up as a static const in your data code. |
The interesting question, should you decide to log to the database, is where do you log database connection errors?
If I'm logging to a database, I always have a secondary log location (file, event log, etc) in case there are communication errors. It really does make it easier to diagnose issues later on. |
I prefer keeping all data **access** logic in the program code, in which the data access layer executes straight SQL queries. On the other hand, data **management** logic I put in the database in the form of triggers, stored procedures, custom functions and whatnot. An example of something I deem worthy of database-ify... |
I've used [Bakefile][1] before with some success. It's fairly simple and seems to work well.
[1]: http://www.bakefile.org/index.html |
These days I hardly ever use stored procedures. I only use them for complicated sql queries that can't easily be done in code.
One of the main reasons is because stored procedures do not work as well with OR mappers.
These days I think you need a very good reason to write a business application / information sy... |
[Source][1] for Matt's answer.
I can get it to run by double-clicking a file by creating a batch file with the following in it:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe LocationOfPS1File
[1]: http://www.microsoft.com/technet/scriptcenter/topics/winpsh/manual/run.mspx#ECEAC |
Maybe the [Jack][1] sourcecode may help too. It's a sound driver for Posix compatible systems with a lot of possibilites and supports USB and Firewire audio devices.
[1]: http://jackaudio.org/ |
Suppress NTLM dialog box after unauthorized request |
|asp.net|javascript|sharepoint| |
In a recent sharepoint project, I implemented an authentication webpart which should replace the NTLM authentication dialog box. It works fine as long as the user provides valid credentials. Whenever the user provides invalid credentials, the NTLM dialog box pops up in Internet Explorer.
My javscript code which does... |
A quick google search gave me this forum <http://board.flashkit.com/board/showthread.php?t=715062> where they state that Flash is unable to handle 5.1 audio and the alternative is to use another application that can communicate with Flash to handle the audio side of things.
I also found this blog entry from Summit P... |
Tools for finding memory corruption in managed c++ code? |
|.net|managed-c++| |
I have a .NET application, which is using an open source C++ compression library for compressing images. We are accessing the C++ library via managed C++. I'm seeing heap corruption during compression. A call to _CrtIsValidHeapPointer is finding an error on a call to free() when cleaning up after compression.
M... |
<a href="http://www-01.ibm.com/software/awdtools/purifyplus/win/">Rational Purify for Windows</a> supports .NET, so I guess that could be used? |
Finding your own number in a box |
|puzzle|algorithm| |
100 (or some even number 2N :-) ) prisoners are in a room A. They are numbered from 1 to 100.
One by one (from prisoner #1 to prisoner #100, in order), they will be let into a room B in which 100 boxes (numbered from 1 to 100) await them. Inside the (closed) boxes are numbers from 1 to 100 (the numbers inside the bo... |
100 (or some even number 2N :-) ) prisoners are in a room A. They are numbered from 1 to 100.
One by one (from prisoner #1 to prisoner #100, in order), they will be let into a room B in which 100 boxes (numbered from 1 to 100) await them. Inside the (closed) boxes are numbers from 1 to 100 (the numbers inside the bo... |
I use message flags for my "action folders" and shunt everything into one big Archive folder after I process it (use the Ctrl+Shift+V shortcut to do this). As an example, I might flag a received message with a red flag (reply), a blue flag (pending, meaning I have to do something about it first), or maybe a green flag... |
Why is the subprocess.Popen class not named Subprocess? |
|python|subprocess| |
The primary class in the `subprocess` module is name `Popen`, and represents a subprocess. `Popen` sounds like someone was trying to force the name to follow some function naming format, rather than chosing a name that actually represents what the object is. Does anyone know why it was chosen over something simple lik... |
Detecting font in javascript |
|javascript|css| |
Suppose I have the following css rule in my html
<pre>body { font-family:Calibri,Trebuchet MS,Helvetica,sans-serif; }</pre>
How can I detect which one of the defined fonts was used in the user's browser? |
|javascript|css|font| |
Suppose I have the following css rule in my html
<pre>body { font-family:Calibri,Trebuchet MS,Helvetica,sans-serif; }</pre>
How can I detect which one of the defined fonts was used in the user's browser?
Edit for people wondering why I want to do this: The font I am detecting contains glyphs not available in o... |
|javascript|css|fonts| |
|javascript|html|css|fonts| |
Why does this C code produce a double instead of a float? |
|c|types| |
<code>celsius = (5.0/9.0) * (fahr-32.0);</code>
Is it just a development choice that the C developers decided upon or is there a reason to this? I believe a float is smaller than a double, so it might be to prevent overflows caused by not knowing what decimal format to use. Is that the reason, or am I overlooking so... |
In bash:
if ps aux | grep really_long_script.rb | grep -vq grep
then
echo Script already running
else
ruby really_long_script.rb
fi |
It depends a _lot_ on the database you're using as a back-end. I've had [rather terrible experiences with MySQL as a back-end](http://stackoverflow.com/questions/5842/issues-using-ms-access-as-a-front-end-to-a-mysql-database-back-end#9200). Make sure the ODBC link you're using is actively developed, stable and complete... |
Interesting. I don't know, but I did try this:
>>> now = time.mktime((2008, 8, 22, 11 ,17, -1, -1, -1, -1))
>>> tomorrow = time.mktime((2008, 8, 23, 11 ,17, -1, -1, -1, -1))
>>> tomorrow - now
86400.0
which is what you expected. My guess? Maybe some time correction was done since the epoch. Thi... |
Short answer: Because of timezones.
The Epoch is in UTC.
For example, I'm on IST (Irish Stsandard Time) or GMT+1. time.mktime() is relative to my timezone, so on my system this refers to
>>> time.mktime((2009, 1, 31, 0, 0, 0, 5, 31, -1))
1233360000.0
Because you got the result 1233378000, that woul... |
- Click on the web site node in the solution explorer.
- Press F4 to see the properties window.
- Change the virtual path from **/projectname** to **/** |
- Click on the web site node in the solution explorer.
- Press F4 to see the properties window.
- Change the virtual path from **/projectname** to **/**
Bear in mind that this has an impact on how you expect the application/web site to be deployed. If it is ever used outside the root of a web server, the URL... |