instruction stringlengths 0 30k ⌀ |
|---|
You might also consider taking a look at the [ActionMailer](http://wiki.rubyonrails.org/rails/pages/ActionMailer) component that ships as part of, but is not dependent on Rails. |
I'd multiply by something sufficiently large (100,000,000 for 8 decimal places), then divide by the [GCD](http://en.wikipedia.org/wiki/Greatest_common_divisor) of the resulting numbers. You'll end up with a pile of smallest integers that you can feed to the other algorithm. After getting the result, reverse the process... |
If you want to manipulate the camera directly from your code, you must use the QuickTime Capture APIs or the [Cocoa QTKit Capture](http://developer.apple.com/documentation/QuickTime/Conceptual/QTKitCaptureProgrammingGuide/Introduction/chapter_1_section_1.html) wrapper (much better).
The only caveat is: if you use a ... |
For pure elegance, a typical recursive functional-language solution is quite nice. This isn't in an actual language syntax but you get the idea (it's also hardcoded to use comma separator):
join([]) = ""
join([x]) = "x"
join([x, rest]) = "x," + join(rest)
In reality there are much more generic ways to writ... |
For pure elegance, a typical recursive functional-language solution is quite nice. This isn't in an actual language syntax but you get the idea (it's also hardcoded to use comma separator):
join([]) = ""
join([x]) = "x"
join([x, rest]) = "x," + join(rest)
In reality you would write this in a more generic w... |
If you don't want to use [ActionMailer][1] you can use [Net::SMTP][2] (for the actual sending) together with [tmail][3] for easily creating emails (with multiple parts, etc.).
[1]: http://wiki.rubyonrails.org/rails/pages/ActionMailer
[2]: http://www.ruby-doc.org/stdlib/libdoc/net/smtp/rdoc/index.html
[3]: ... |
As far as I can tell the solutions given by Ryan Fox ([58343](http://stackoverflow.com/questions/58306/graph-algorithm-to-find-all-connections-between-two-arbitrary-vertices#58343), Christian ([58444](http://stackoverflow.com/questions/58306/graph-algorithm-to-find-all-connections-between-two-arbitrary-vertices#58444))... |
Here is an example of sending back a pdf.
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
header('Content-Transfer-Encoding: binary');
readfile($filename);
[@Swish](http://stackoverflow.com/questions/40943/how-to-automa... |
My take is the former becauase you can only have 1 window.onload function, while inline script blocks you have an *n* number.
|
You can store backup (.bak file) of you database rather than .MDF & .LDF files.
You can restore your db easily using following script:
use master
go
if exists (select * from master.dbo.sysdatabases where name = 'your_db')
begin
alter database your_db set SINGLE_USER with rollback I... |
You can store backup (.bak file) of you database rather than .MDF & .LDF files.
You can restore your db easily using following script:
use master
go
if exists (select * from master.dbo.sysdatabases where name = 'your_db')
begin
alter database your_db set SINGLE_USER with rollback I... |
if this is something that is going to happen on a regular basis perhaps modifying the data to be all one format and then setup the search form to strip out any non-alphanumeric (if you allow numbers like 310-BELL) would be a good idea. Having data in an easily searched format is half the battle.
|
that format doesn't exists you need to do a combo of two things
select convert(varchar(4),getdate(),100) + convert(varchar(4),year(getdate())) |
Add horizontal scroll to asp.net listbox control |
|asp.net|listbox|scroll| |
How can I add horizontal scroll capabilities to the asp.net listbox control? |
How do I return a 403 Forbidden in Spring MVC? |
|java|spring| |
I want my controller to return the right HTTP response code when the user lacks permission to view a particular page. |
Paragraph widths larger than your display make a web site completely unusable. You have to jiggle the horizontal scrollbar back and forth for every single line you read. I'm doing a web design subject at university and the textbook calls the designs which adapt to your screen width <i>fluid layout</i>.<p>
I'm designin... |
If you mean you want them back as a string, in that format;
select CONVERT(CHAR(4), date_of_birth, 100) + CONVERT(CHAR(4), date_of_birth, 120) from customers
[Here are the other format options][1]
[1]: http://msdn.microsoft.com/en-us/library/ms187928.aspx |
Wacom tablet Python interface |
|python|wacom|interface| |
If possible I want to catch pressure sensitive input from a Wacom tablet in Python. Are there any Python libraries available that can do this?
Regards,
Menno |
|python|interface|wacom| |
I can only assume it's a bug in Eclipse. It only happens with *@see* tags, it happens also for all 3 builtin code formatter settings.
There are some interesting bugs reported already in the neighbourhood, but I couldn't find this specific one. See for example a search for *@see* in the [Eclipse Bugzilla][1].
... |
How to get browser IP or hostname? |
|asp.net|visual-studio| |
I have a web application that should behave differently for internal users than external ones. The web application is available over the Internet, and therefore obviously to the internal users as well.
All the users are anonymous, not authenticated, but the page should render differently for internal users than exte... |
If you are compiling Apache2 for a particular location but want your clients to be able to install it somewhere else (and I'm assuming they have the same architecture and OS as your build machine) then you can do it but the apachectl script will need some after-market hacking.
I just tested these steps:
1. Unpack... |
If you are on a unix system you could just do a
find /target-folder -name \*.class | xargs file | grep "version 50\.0"
(my version of file says "compiled Java class data, version 50.0" for java6 classes). |
@wcm - actually to nit pick the Table Variable isn't Ram only - it can be partially stored on disk.
A temp table can have indexes, whereas a table variable can only have a primary index. If speed is an issue Table variables can be faster, but obviously if there are a lot of records, or the need to search the temp ta... |
I would actually be inclined to disagree with everyone that is advocating the use of the [ObsoleteAttribute][1] as the MSDN documentation says that:
> Marking an element as obsolete informs the users that the element will be removed in future versions of the product.
Since the generic constructors for XML seriali... |
What is the recomended tutorial on tracing in C#? |
|c#|trace| |
I want to introduce some tracing to a C# application I am writing. Sadly, I can never really remember how it works and would like a tutorial with reference qualities to check up on every now and then. It should include:
- App.config / Web.config stuff to add for registering TraceListeners
- how to set it up in ... |
If using SQL Server 2000 or greater, you could use the **table datatype** to avoid creating a normal or temporary table. Then use the normal table operations on it.
With this solution you have essentially a table structure in memory that you can use almost like a real table, but much more performant.
I found a go... |
Most languages nowadays - e.g. perl (mention by Jon Ericson), php, javascript - have a join() function or method, and this is by far the most elegant solution. Less code is better code.
In response to Mendelt Siebenga, if you do require a hand-rolled solution, I'd go with the ternary operator for something like:
... |
This is going to be a bit of a weird answer but I'm a big fan of Windows 2008 and Hyper-V, as a workstation (I know). Essentially I'll only install Office like software on my workstation and all the development will be in Virtual Machines.
Assuming there's no Win2k8/Hyper-V availiable I'd gladly settle for some old ... |
As far as the man page for cp on a FreeBSD box goes, there's no need for a -t switch. cp will assume the last argument on the command line to be the target directory if more than two names are passed. |
In C# how can you find the mime type of a file based on the file signature not the extension. |
|c#|mime-types|mime| |
I am looking for a simple way to get a mime type where the file extension is incorrect or not given, something similar to [this][1] question only in .Net.
[1]: http://stackoverflow.com/questions/51438/getting-a-files-mime-type-in-java |
|c#|mime|mime-types| |
I am looking for a simple way to get a mime type where the file extension is incorrect or not given, something similar to [this question][1] only in .Net.
[1]: http://stackoverflow.com/questions/51438/getting-a-files-mime-type-in-java |
When you close form in WinForms it disposes all of it's children. So it's not a good idea. You need to do it asynchronously, for example you can sending a message to parent form. |
When you close form in WinForms it disposes all of it's children. So it's not a good idea. You need to do it asynchronously, for example you can send a message to parent form. |
The default behavior of TreeView is that when the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.checkboxes(VS.80).aspx">Checkboxes</a> property is set to true, that checkboxes will be shown for all TreeNodes.
The behavior that you are looking for - to disable or hide some checkboxes ... |
The default behavior of TreeView is that when the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.checkboxes%28VS.80%29.aspx">Checkboxes</a> property is set to true, that checkboxes will be shown for all TreeNodes.
The behavior that you are looking for - to disable or hide some checkbo... |
Send the following headers before outputting the file:
header("Content-Disposition: attachment; filename=\"" . basename($File) . "\"");
header("Content-Type: application/force-download");
header("Content-Length: " . filesize($File));
header("Connection: close"); |
Send the following headers before outputting the file:
header("Content-Disposition: attachment; filename=\"" . basename($File) . "\"");
header("Content-Type: application/force-download");
header("Content-Length: " . filesize($File));
header("Connection: close");
@grom: Interesting about the 'ap... |
In Perl, I just use the **join** command:
$ echo "Alpha
Beta
Gamma" | perl -e 'print(join(", ", map {chomp; $_} <> ))'
Alpha, Beta, Gamma
(The **map** stuff is mostly there to create a list.)
In languages that don't have a built in, like C, I use simple iteration (untested):
for (i = ... |
In Perl, I just use the **join** command:
$ echo "Alpha
Beta
Gamma" | perl -e 'print(join(", ", map {chomp; $_} <> ))'
Alpha, Beta, Gamma
(The **map** stuff is mostly there to create a list.)
In languages that don't have a built in, like C, I use simple iteration (untested):
for (i = ... |
If you taking about using enum flags() there is a good article [here][1].
[1]: http://www.codeguru.com/vb/sample_chapter/article.php/c12963 "VB flags" |
If I understand your question correctly you want to combine different enum types. So one variable can store a value from one of two different enum's right? If you're asking about storing combining two different values of one enum type you can look at Dave Arkell's explanation
Enums are just integers with some syntac... |
The key to combine enums is to make sure that the value is a power of two (0, 2, 4, 8) so that you can perform bit operations on them (|= &=). Those enums can be be tagged with a flags attribute. The Anchor property on Windows Forms controls is an example of such a control. If it's marked as a flag Visual Studio will l... |
I'm going to tackle it from a TDD/BDD perspective, where the tests are driving the designs.
First off it depends what style of design you buy into, because remember this is about design first. As Martin Fowler discusses in this excellent article [Mocks Aren't Stubs][1] there are two school of thoughts and they do p... |
If you wish to connect directly to the exchange server you will need to research at extended MAPI.
You could use the Outlook API but this is a way of automating outlook rather than connecting to exchange directly. I have previously taken this approach in a c# application and it does work although can be buggy.
In... |
If you wish to connect directly to an exchange server I guess you will be researching extended MAPI.
You could use the Outlook API but this is a way of automating outlook rather than connecting to exchange directly. I have previously taken this approach in a c# application and it does work although can be buggy.
... |
If you wish to connect directly to an exchange server I guess you will be researching extended MAPI.
You could use the Outlook API but this is a way of automating outlook rather than connecting to exchange directly. I have previously taken this approach in a c# application and it does work although can be buggy.
... |
If you wish to connect directly to an exchange server I guess you will be researching extended MAPI.
In the past I have used the Outlook.exe but this is a way of automating outlook rather than connecting to exchange directly and like the aouther I have found it can be buggy.
Now I use this wrapper to make the cal... |
Calling process.Start on the [Mailto: protocol][1] will give you basic functionality but not attachments.
The with attachment paths option only works with some old version of outlook such as 98.
[1]: http://msdn.microsoft.com/en-us/library/aa767737(VS.85).aspx |
Calling process.Start on the [Mailto: protocol][1] (as shown below) will give you basic functionality but not attachments.
Process.Start("mailto:name@domain.com?subject=TestCode&Body=Test Text");
You can do this approach with attachment paths but this option only works with some old version of outlook such as... |
If you wish to connect directly to an exchange server I guess you will be researching extended MAPI.
In the past I have used the Outlook.exe as mentioned in the articles but this is a way of automating outlook rather than connecting to exchange directly and like the writer I have found it can be buggy.
Now I use ... |
We can put this list box inside a DIV and set the style for DIV to overflow which will automatically show the scroll bar whenever necessary.
Your aspx page has the following DIV:
<div id='hello' style="Z-INDEX: 102; LEFT: 13px; OVERFLOW:
auto; WIDTH: 247px; POSITION: absolute; TOP: 62px; HEI... |
From my perspective, I guess the answer is 'it depends'.
There is an argument that manipulation of the data belongs in the database layer, so that the business logic does not need to be overly concerned about how the manipulation happens, it just knows that it has.
Another very good reason to process data on the ... |
As mentioned it is better to choose the Document Literal over RPC encoded whenever possible.
It is true that the old java libraries (Axis1, Glue and other prehistoric stuff) support only RPC encoded, however in today's most modern Java SOAP libs just does not support it (e.x. AXIS2, XFire, CXF).
Therefore try to exp... |
There might be a firewall that is doing some sort of NAT, to enable inside clients to use the external dns-name to reach the server.
Is the IP-number you get on customer site the same at the external customer-server ip? In that case you can hard code for that one IP-address. All internal computers behind that firewa... |
It looks like you're being returned a public facing IP Address. Get the user to go to http://www.myipaddress.com . If this is the same as the IP Address returned to your software, then this is definitely the case.
The only solution I can see to get around this is to either get them to connect to the machine holding... |
I'm going to tackle it from a TDD/BDD perspective, where the tests are driving the designs.
First off it depends what style of design you buy into, because remember this is about design first. As Martin Fowler discusses in this excellent article [Mocks Aren't Stubs][1] there are two school of thoughts and they do p... |
You should look into continuous integration and having some kind of centralised build process. I can only imagine the kind of hell you're going through with your current approach.
Obviously that doesn't help with the keeping your local files in sync, but I think you have bigger problems with your process. |
I'd probably take a look at rsync.
Just create a .CMD file that contains the call to rsync with all the correct parameters and let people call that. rsync is very smart in deciding what part of files need to be transferred, so it'll be very fast even when large files are involved.
What rsync doesn't do though is ... |
Earlier on (like 2 years ago when I last tried), AnkhSVN and Tortoise used in parallel with the same working copy caused some kind of working copy corruption where Ankh and Tortoise somehow lost track of the state the other tool left the working copy in.
It was as if one of the tools stored additional metadata not c... |
If you are looking to build libraries which wont be recompiled, but want to provide a logging interface then perhaps a good way is to allow the user (of the library) to provide a callback.
On initialising logging with your library, they would need to specify the callback, and then the glue-code is up to them to make... |
I'd say that I see the improved Javascript engine being the major contribution as far as web applications go. And hopefully will cause a new look for the other browsers and possibly make Javascript implementations a bit more standardized. |
How to use chrome to login to same site twice with different credentials ? |
|testing|website|google-chrome| |
Even though it runs tabs as different processes it appears to not support this... any ideas / documentation I might have missed ? |
onLoad because it is far easier to tell what code runs when the page loads up than having to read down through scads of html looking for script tags that might execute. |
I wonder whether plugins/addons will ever be a big focus for Chrome. It seems to be very much focused on providing a fast, clean environment that puts the focus on the web rather than the browser. I suspect that in order to keep it nimble and stable, they may keep the extension capabilities fairly limited (plus, they w... |
It's really speedy. Visibly so. I was pretty impressed with its performance compared with Firefox 3. Already made it my default browser. |
Yes, V8 is extremely fast on Vista x86 -- up to 50 times as fast as IE 7 for most benchmarks I tried. More impressively, GMail running under Chrome had one-quarter the memory footprint of GMail running under IE 7. This can probably be attributed in large part to V8. |
@[The Geek](#41005)
> I'm pretty sure that window.onload will be called again when a user hits the back button in IE, but doesn't get called again in Firefox. (Unless they changed it recently).
In Firefox, `onload` is called when the DOM has finished loading regardless of how you navigated to a page. |
What does Google Chrome mean to web developers? |
|google|chrome| |
From a web developer point of view, what changes are expected in the development arena when Google Chrome is released?
Are the developments powerful enough to make another revolution in the web? Will the way we see web programming change?
Or is it just another web browser? |
can you use response.setStatus(403) ?
[http://forum.springframework.org/archive/index.php/t-20877.html][1]
[1]: http://forum.springframework.org/archive/index.php/t-20877.html |
Try Request.UserHostAddress, which returns the client's IP address. Assuming your internal network uses IP addresses reserved for LANs, it should be relatively simple to check if an IP is internal or external. |
If you really, really need it, one idea would be to create a custom
ListBox class whose HTML looks like this: sets the width of the SELECT
to that of your widest value's width (the max width of the scrollbar,
for example). Now wrap that SELECT inside of a DIV of the 'constrained'
size and let it scroll on overflow.... |
If you really, really need it, one idea would be to create a custom
ListBox class whose HTML looks like this: sets the width of the SELECT
to that of your widest value's width (the max width of the scrollbar,
for example). Now wrap that SELECT inside of a DIV of the 'constrained'
size and let it scroll on overflow.... |
What is the best method of getting Int32 from first four bytes of GUID? |
Greg: Nice solution but won't calculating a GCD that's common in an array of 100+ numbers get a bit expensive? And how would you go about that? Its easy to do GCD for two numbers but for 100 it becomes more complex (I think).
Evil Andy: I'm programing in .Net and the solution you pose is pretty much a match for what... |
With jQuery, the the actual DOM element is at index zero, this should work
$('#a')[0].className = $('#a')[0].className.replace(/\bbg.*?\b/g, '');
|
The client vs. server OS issue is only relevant on MS platforms. And even there it depends on what you're developing for.
As far as I understand for Sharepoint development you need a server OS to run your code
If you're just doing vanilla ASP.Net stuff then it's mostly personal taste. |
The client vs. server OS issue is only relevant on MS platforms. And even there it depends on what you're developing for.
As far as I understand for Sharepoint development you need a server OS to run your code
If you're just doing vanilla ASP.Net stuff then it's mostly personal taste.
*Edit*
As Tyler commented... |
You can use the FlagsAttribute to decorate an Enum like so which will let you combine the Enum:
<FlagsAttribute> _
Public Enumeration SecurityRights
None = 0
Read = 1
Write = 3
Execute = 4
And then call them like so (class UserPriviltes):
Public Sub New ( _
options As ... |
Versioning library like SQLite database library? |
|version-control|opensource| |
I like how SQLite library can be included into an application and the application has a full-fledged database to use.
Similarly, is there an open source versioning library that I can include into my application so that I can save versions of files as well as do diffs and merges? |
|c#|.net|guid| |