qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
347,463
<p>I made a code that translate strings to match each word from the array 0ne to the array two and its showing the right results. But how to let the compiler take the number in the string and print it out as it is, ummmm see the code i wrote</p> <hr> <pre><code>class Program { public static string[] E = {...
[ { "answer_id": 347466, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 3, "selected": true, "text": "<p>Change your regex to <code>[a-zA-Z0-9]+</code></p>\n\n<p>By the way, why don't you use <code>String.Split</code> method inst...
2008/12/07
[ "https://Stackoverflow.com/questions/347463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I made a code that translate strings to match each word from the array 0ne to the array two and its showing the right results. But how to let the compiler take the number in the string and print it out as it is, ummmm see the code i wrote --- ``` class Program { public static string[] E = { "i", "go", "sc...
Change your regex to `[a-zA-Z0-9]+` By the way, why don't you use `String.Split` method instead of Regex?
347,472
<p>I'm building a website in ASP.Net, using MVC, and need to list a set of results. Both of the following work as I want them to but I'm wondering which is faster, cleaner and/or better - or if another option entirely would be more appropriate?</p> <p>Note: <code>ViewData.Model</code> is of type <code>IEnumerable&lt;T...
[ { "answer_id": 347474, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 4, "selected": true, "text": "<p><code>foreach</code> is definitely faster, if you don't specifically screw up something. <code>Repeater</code> is cleaner of...
2008/12/07
[ "https://Stackoverflow.com/questions/347472", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40079/" ]
I'm building a website in ASP.Net, using MVC, and need to list a set of results. Both of the following work as I want them to but I'm wondering which is faster, cleaner and/or better - or if another option entirely would be more appropriate? Note: `ViewData.Model` is of type `IEnumerable<Thing>` and I need to display ...
`foreach` is definitely faster, if you don't specifically screw up something. `Repeater` is cleaner of course, and more neatly separates UI and logic. Sometimes you need more conditions (other than different look even and odd rows) to render your stuff properly which makes `foreach` the only choice. I personally prefe...
347,497
<p>I am writing a web-framework for Python, of which the goal is to be as "small" as possible (currently under 100 lines of code).. You can see the current code <a href="http://github.com/dbr/pyerweb/tree/master" rel="nofollow noreferrer">on github</a></p> <p>Basically it's written to be as simple to use as possible. ...
[ { "answer_id": 347509, "author": "gimel", "author_id": 6491, "author_profile": "https://Stackoverflow.com/users/6491", "pm_score": 1, "selected": false, "text": "<p>You should reconsider the notion of returning <a href=\"http://en.wikipedia.org/wiki/Html\" rel=\"nofollow noreferrer\">HTM...
2008/12/07
[ "https://Stackoverflow.com/questions/347497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/745/" ]
I am writing a web-framework for Python, of which the goal is to be as "small" as possible (currently under 100 lines of code).. You can see the current code [on github](http://github.com/dbr/pyerweb/tree/master) Basically it's written to be as simple to use as possible. An example "Hello World" like site: ``` from p...
Look at [PEP 333](http://www.python.org/dev/peps/pep-0333/) for an excellent design pattern for a very lightweight web server. If your server has this exact API, you can reuse it in a lot of context with a lot of other products. PEP 333 (WSGI) suggests that you don't directly return the page, but you provide the HTML ...
347,502
<p>I'm seeing some wierd behaviour when throwing exceptions and catching them in the <code>Application.ThreadException</code> event handler.</p> <p>Basically whats happening in the sample below is that an exception is thrown in the <code>DoWork</code> event handler of a <code>BackgroundWorker</code>. The <code>RunWork...
[ { "answer_id": 347928, "author": "liggett78", "author_id": 19762, "author_profile": "https://Stackoverflow.com/users/19762", "pm_score": 1, "selected": false, "text": "<pre><code> if (e.Error != null)\n {\n throw new Exception(\"worker_RunWorkerCompleted\", new E...
2008/12/07
[ "https://Stackoverflow.com/questions/347502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/966/" ]
I'm seeing some wierd behaviour when throwing exceptions and catching them in the `Application.ThreadException` event handler. Basically whats happening in the sample below is that an exception is thrown in the `DoWork` event handler of a `BackgroundWorker`. The `RunWorkerCompleted` event handler rethrows a new except...
The RunWorkerCompleted event is marshaled from the BGW thread to the UI thread by the WF plumbing that makes Control.Invoke() work. Essentially, there's a queue with delegates that is emptied by the message loop. The code that does this, Control.InvokeMarshaledCallbacks(), you'll see it on the call stack, has a catch (...
347,512
<p>I have an element with an <strong>onclick</strong> method.</p> <p>I would like to activate that method (or: fake a click on this element) within another function.</p> <p>Is this possible?</p>
[ { "answer_id": 347517, "author": "Ben", "author_id": 36522, "author_profile": "https://Stackoverflow.com/users/36522", "pm_score": 6, "selected": false, "text": "<p>Once you have selected an element you can call click()</p>\n\n<pre><code>document.getElementById('link').click();\n</code><...
2008/12/07
[ "https://Stackoverflow.com/questions/347512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1011/" ]
I have an element with an **onclick** method. I would like to activate that method (or: fake a click on this element) within another function. Is this possible?
If you're using JQuery you can do: ``` $('#elementid').click(); ```
347,524
<p>I'm having trouble with <code>TryUpdateModel()</code>. My form fields are named with a prefix but I am using - as my separator and not the default dot.</p> <pre><code>&lt;input type="text" id="Record-Title" name="Record-Title" /&gt; </code></pre> <p>When I try to update the model it does not get updated. If i chan...
[ { "answer_id": 347594, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "<p>Not unless you implement your own ModelBinder. If you look at the source code for the DefaultModelBinder on <a href...
2008/12/07
[ "https://Stackoverflow.com/questions/347524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44085/" ]
I'm having trouble with `TryUpdateModel()`. My form fields are named with a prefix but I am using - as my separator and not the default dot. ``` <input type="text" id="Record-Title" name="Record-Title" /> ``` When I try to update the model it does not get updated. If i change the name attribute to `Record.Title` it ...
Another thing to note is that the prefix is to help reflection find the proper field(s) to update. For instance if I have a custom class for my ViewData such as: ``` public class Customer { public string FirstName {get; set;} public string LastName {get; set;} } public class MyCustomViewData { public Cust...
347,528
<p>I'm fairly new to ASP.NET MVC, and I'm having a little trouble with scripts... in particular, I want to use jQuery in most pages, so it makes sense to put it in the master page. However, if I do (from my <code>~/Views/Shared/Site.Master</code>):</p> <pre><code>&lt;script src="../../Scripts/jquery-1.2.6.js" type="te...
[ { "answer_id": 347537, "author": "OJ.", "author_id": 611, "author_profile": "https://Stackoverflow.com/users/611", "pm_score": 3, "selected": false, "text": "<p>Why not just point your master page at <a href=\"http://googleajaxsearchapi.blogspot.com/2008/05/speed-up-access-to-your-favori...
2008/12/07
[ "https://Stackoverflow.com/questions/347528", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23354/" ]
I'm fairly new to ASP.NET MVC, and I'm having a little trouble with scripts... in particular, I want to use jQuery in most pages, so it makes sense to put it in the master page. However, if I do (from my `~/Views/Shared/Site.Master`): ``` <script src="../../Scripts/jquery-1.2.6.js" type="text/javascript"></script> ``...
I have a AppHelper class with some methods for adding script references: ``` public static string ReferenceScript(string scriptFile) { var filePath = VirtualPathUtility.ToAbsolute("~/Scripts/" + scriptFile); return "<script type=\"text/javascript\" src=\"" + filePath + "\"></script>"; } ``` so in your maste...
347,535
<p>I know that MSTest doesn't support <code>RowTest</code> and similar tests.</p> <p>What do <code>MSTests</code> users do? How is it possible to live without <code>RowTest</code> support? </p> <p>I've seen <code>DataDriven</code> test features but sounds like too much overhead, is there any 3rd party patch or tool w...
[ { "answer_id": 1205297, "author": "Tormod", "author_id": 80577, "author_profile": "https://Stackoverflow.com/users/80577", "pm_score": 5, "selected": false, "text": "<pre><code>[TestMethod]\nTest1Row1\n{\n Test1(1,4,5);\n}\n\n[TestMethod]\nTest1Row2\n{\n Test1(1,7,8);\n}\n\nprivate...
2008/12/07
[ "https://Stackoverflow.com/questions/347535", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40322/" ]
I know that MSTest doesn't support `RowTest` and similar tests. What do `MSTests` users do? How is it possible to live without `RowTest` support? I've seen `DataDriven` test features but sounds like too much overhead, is there any 3rd party patch or tool which allow me to do `RowTest` similar tests in `MSTest`?
``` [TestMethod] Test1Row1 { Test1(1,4,5); } [TestMethod] Test1Row2 { Test1(1,7,8); } private Test1(int i, int j, int k) { //all code and assertions in here } ```
347,551
<p>Given a file tree - a directory with directories in it etc, how would you write a script to create a diagram of the file-tree as a graphic file that I can embed in a word processor document. I prefer vector (SVG, EPS, EMF...) files. The tool must run on Windows, but preferably cross-platform. The tool may be commer...
[ { "answer_id": 347568, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 3, "selected": false, "text": "<p>Why could you not just make a file structure on the Windows file system and populate it with your desired names, then...
2008/12/07
[ "https://Stackoverflow.com/questions/347551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33427/" ]
Given a file tree - a directory with directories in it etc, how would you write a script to create a diagram of the file-tree as a graphic file that I can embed in a word processor document. I prefer vector (SVG, EPS, EMF...) files. The tool must run on Windows, but preferably cross-platform. The tool may be commercial...
Copying and pasting from the MS-DOS `tree` command might also work for you. Examples: **tree** ``` C:\Foobar>tree C:. ├───FooScripts ├───barconfig ├───Baz │ ├───BadBaz │ └───Drop ... ``` **tree /F** ``` C:\Foobar>tree C:. ├───FooScripts │ foo.sh ├───barconfig │ bar.xml ├───Baz │ ├───BadBaz │ │ ba...
347,553
<p>With the JavaFX 1.0 release I am trying to layout some SwingButton instances in a HBox such that they are aligned to the right. A lot of the tutorials on the net (admittedly pre 1.0 release) talk about layout classes (FlowPanel et. al) which dont seem to be in this release. Whats the simplest way to achieve this see...
[ { "answer_id": 347568, "author": "paxdiablo", "author_id": 14860, "author_profile": "https://Stackoverflow.com/users/14860", "pm_score": 3, "selected": false, "text": "<p>Why could you not just make a file structure on the Windows file system and populate it with your desired names, then...
2008/12/07
[ "https://Stackoverflow.com/questions/347553", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5193/" ]
With the JavaFX 1.0 release I am trying to layout some SwingButton instances in a HBox such that they are aligned to the right. A lot of the tutorials on the net (admittedly pre 1.0 release) talk about layout classes (FlowPanel et. al) which dont seem to be in this release. Whats the simplest way to achieve this seemin...
Copying and pasting from the MS-DOS `tree` command might also work for you. Examples: **tree** ``` C:\Foobar>tree C:. ├───FooScripts ├───barconfig ├───Baz │ ├───BadBaz │ └───Drop ... ``` **tree /F** ``` C:\Foobar>tree C:. ├───FooScripts │ foo.sh ├───barconfig │ bar.xml ├───Baz │ ├───BadBaz │ │ ba...
347,564
<p>I have a problem with simple c++ programs... </p> <p>I would like to install a program, but always have the error like "c++ compiler is unable to create executables"...</p> <p>Now I tried to compile a simple "hello world" program, but I get errors as I would if I compile a c++ program with a c compiler ("`cout' un...
[ { "answer_id": 347595, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>Did you try calling g++ directly? If you run:</p>\n\n<pre><code>g++\n</code></pre>\n\n<p>and it isn't installed, you should...
2008/12/07
[ "https://Stackoverflow.com/questions/347564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a problem with simple c++ programs... I would like to install a program, but always have the error like "c++ compiler is unable to create executables"... Now I tried to compile a simple "hello world" program, but I get errors as I would if I compile a c++ program with a c compiler ("`cout' undeclared"... alth...
Did you try calling g++ directly? If you run: ``` g++ ``` and it isn't installed, you should get the usual *invalid command* message, but if it is installed you should see something like: ``` g++: no input files ``` If you see that, then try running this: ``` g++ -o output-file input-file ``` replacing output-...
347,574
<p>This is a follow-up to a <a href="https://stackoverflow.com/questions/347109/how-do-i-concisely-implement-multiple-similar-unit-tests-in-the-python-unittest">previous question</a> of mine.</p> <p>In the previous question, methods were explored to implement what was essentially the same test over an entire family of...
[ { "answer_id": 366620, "author": "ionelmc", "author_id": 23658, "author_profile": "https://Stackoverflow.com/users/23658", "pm_score": 1, "selected": false, "text": "<p>You could try to generate the testcase classes with type()</p>\n\n<pre><code>class UnderTest_MixIn(object):\n\n def ...
2008/12/07
[ "https://Stackoverflow.com/questions/347574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37984/" ]
This is a follow-up to a [previous question](https://stackoverflow.com/questions/347109/how-do-i-concisely-implement-multiple-similar-unit-tests-in-the-python-unittest) of mine. In the previous question, methods were explored to implement what was essentially the same test over an entire family of functions, ensuring ...
Nose has a "test generator" feature for stuff like this. You write a generator function that yields each "test case" function you want it to run, along with its args. Following your previous example, this could check each of the functions in a separate test: ``` import unittest import numpy from somewhere import the_...
347,592
<p>The title pretty much says it all. I'm using a TClientDataset to store an array of objects, and one of the objects has a member defined as a <strong>set of</strong> an enumerated type. As I understand it, Delphi sets are bitfields whose size can vary from 1 to 32 bytes depending on how much data they contain, and D...
[ { "answer_id": 347604, "author": "Andreas Hausladen", "author_id": 44005, "author_profile": "https://Stackoverflow.com/users/44005", "pm_score": 5, "selected": true, "text": "<p>You could use a TBytesField or a TBlobField</p>\n\n<p>ClientDataSet1MySet: TBytesField, Size=32</p>\n\n<pre><c...
2008/12/07
[ "https://Stackoverflow.com/questions/347592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32914/" ]
The title pretty much says it all. I'm using a TClientDataset to store an array of objects, and one of the objects has a member defined as a **set of** an enumerated type. As I understand it, Delphi sets are bitfields whose size can vary from 1 to 32 bytes depending on how much data they contain, and Delphi doesn't def...
You could use a TBytesField or a TBlobField ClientDataSet1MySet: TBytesField, Size=32 ``` var MySet: set of Byte; Bytes: array of Byte; begin MySet := [1, 2, 4, 8, 16]; // Write Assert(ClientDataSet1MySet.DataSize >= SizeOf(MySet), 'Data field is too small'); SetLength(Bytes, ClientDataSet1MySet.DataSiz...
347,606
<p>I was curious as to what other shops are doing regarding base application frameworks? I look at an application framework as being able to provide additional or extended functionality to improve the quality of applications built from it.</p> <p>There are a variety of out of the box frameworks, such as Spring (or Sp...
[ { "answer_id": 347604, "author": "Andreas Hausladen", "author_id": 44005, "author_profile": "https://Stackoverflow.com/users/44005", "pm_score": 5, "selected": true, "text": "<p>You could use a TBytesField or a TBlobField</p>\n\n<p>ClientDataSet1MySet: TBytesField, Size=32</p>\n\n<pre><c...
2008/12/07
[ "https://Stackoverflow.com/questions/347606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15906/" ]
I was curious as to what other shops are doing regarding base application frameworks? I look at an application framework as being able to provide additional or extended functionality to improve the quality of applications built from it. There are a variety of out of the box frameworks, such as Spring (or Spring.NET), ...
You could use a TBytesField or a TBlobField ClientDataSet1MySet: TBytesField, Size=32 ``` var MySet: set of Byte; Bytes: array of Byte; begin MySet := [1, 2, 4, 8, 16]; // Write Assert(ClientDataSet1MySet.DataSize >= SizeOf(MySet), 'Data field is too small'); SetLength(Bytes, ClientDataSet1MySet.DataSiz...
347,614
<p>For a WPF application which will need 10 - 20 small icons and images for illustrative purposes, is storing these in the assembly as embedded resources the right way to go?</p> <p>If so, how do I specify in XAML that an Image control should load the image from an embedded resource?</p>
[ { "answer_id": 347805, "author": "ema", "author_id": 19520, "author_profile": "https://Stackoverflow.com/users/19520", "pm_score": 6, "selected": false, "text": "<p>Yes, it is the right way.</p>\n\n<p>You could use the image in the resource file just using the path:</p>\n\n<pre><code>&lt...
2008/12/07
[ "https://Stackoverflow.com/questions/347614", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13627/" ]
For a WPF application which will need 10 - 20 small icons and images for illustrative purposes, is storing these in the assembly as embedded resources the right way to go? If so, how do I specify in XAML that an Image control should load the image from an embedded resource?
If you will use the image in multiple places, then it's worth loading the image data only once into memory and then sharing it between all `Image` elements. To do this, create a [`BitmapSource`](http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapsource.aspx) as a resource somewhere: ```xml <Bi...
347,617
<p>I have a string that has angle brackets in it like this:</p> <pre><code>&lt;element1&gt;my text here&lt;/element1&gt; </code></pre> <p>The string literally looks like this when I write it to console or my dataGridView or anywhere else. However, I'm trying to write this as part of an XML document. </p> <p>Everyt...
[ { "answer_id": 347637, "author": "Turnkey", "author_id": 13144, "author_profile": "https://Stackoverflow.com/users/13144", "pm_score": 0, "selected": false, "text": "<p>That is being written as <a href=\"http://en.wikipedia.org/wiki/Character_encodings_in_HTML\" rel=\"nofollow noreferrer...
2008/12/07
[ "https://Stackoverflow.com/questions/347617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44004/" ]
I have a string that has angle brackets in it like this: ``` <element1>my text here</element1> ``` The string literally looks like this when I write it to console or my dataGridView or anywhere else. However, I'm trying to write this as part of an XML document. Everything is fine except that in the xml file that i...
If you want to keep it as a string without escaping all the elements, use a CDATA block: ``` <xml><![CDATA[<element1>my text here</element1>]]></xml> ```
347,620
<p>How do I find out which directories are responsible for chewing up all my inodes?</p> <p>Ultimately the root directory will be responsible for the largest number of inodes, so I'm not sure exactly what sort of answer I want..</p> <p>Basically, I'm running out of available inodes and need to find a unneeded directo...
[ { "answer_id": 347633, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 5, "selected": true, "text": "<p>So basically you're looking for which directories have a lot of files? Here's a first stab at it:</p>\n\n<pre><code>...
2008/12/07
[ "https://Stackoverflow.com/questions/347620", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31092/" ]
How do I find out which directories are responsible for chewing up all my inodes? Ultimately the root directory will be responsible for the largest number of inodes, so I'm not sure exactly what sort of answer I want.. Basically, I'm running out of available inodes and need to find a unneeded directory to cull. Than...
So basically you're looking for which directories have a lot of files? Here's a first stab at it: ``` find . -type d -print0 | xargs -0 -n1 count_files | sort -n ``` where "count\_files" is a shell script that does (thanks Jonathan) ``` echo $(ls -a "$1" | wc -l) $1 ```
347,624
<p>I have a simple problem when querying the SQL Server 2005 database. I have tables called Customer and Products (1->M). One customer has most 2 products. Instead of output as</p> <p>CustomerName, ProductName ...</p> <p>I like to output as </p> <p>CustomerName, Product1Name, Product2Name ...</p> <p>Could anybody h...
[ { "answer_id": 347639, "author": "chagel", "author_id": 43997, "author_profile": "https://Stackoverflow.com/users/43997", "pm_score": 1, "selected": false, "text": "<p>in sql2005, there are functions called \"PIVOT\" and \"UNPIVOT\" which can be used to transform between rows and columns...
2008/12/07
[ "https://Stackoverflow.com/questions/347624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31689/" ]
I have a simple problem when querying the SQL Server 2005 database. I have tables called Customer and Products (1->M). One customer has most 2 products. Instead of output as CustomerName, ProductName ... I like to output as CustomerName, Product1Name, Product2Name ... Could anybody help me? Thanks!
Like others have said, you can use the PIVOT and UNPIVOT operators. Unfortunately, one of the problems with both PIVOT and UNPIVOT are that you need to know the values you will be pivoting on in advance or else use dynamic SQL. It sounds like, in your case, you're going to need to use dynamic SQL. To get this working ...
347,625
<p>What do you recommend as minimum specs for a Windows laptop running Vista, an IDE, and Apache, MySQL, and PHP?</p>
[ { "answer_id": 347639, "author": "chagel", "author_id": 43997, "author_profile": "https://Stackoverflow.com/users/43997", "pm_score": 1, "selected": false, "text": "<p>in sql2005, there are functions called \"PIVOT\" and \"UNPIVOT\" which can be used to transform between rows and columns...
2008/12/07
[ "https://Stackoverflow.com/questions/347625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What do you recommend as minimum specs for a Windows laptop running Vista, an IDE, and Apache, MySQL, and PHP?
Like others have said, you can use the PIVOT and UNPIVOT operators. Unfortunately, one of the problems with both PIVOT and UNPIVOT are that you need to know the values you will be pivoting on in advance or else use dynamic SQL. It sounds like, in your case, you're going to need to use dynamic SQL. To get this working ...
347,642
<p>I have a problem. One of the datatable colums value is a string value '001200' for example. When the Excel document creats the value became '1200'. How can I keep a data format as is? I'm working with ASP.NET 1.1.</p> <p>The part of the code is:</p> <pre><code>private void lnkExport_Click( object sender, System.Ev...
[ { "answer_id": 347645, "author": "Turnkey", "author_id": 13144, "author_profile": "https://Stackoverflow.com/users/13144", "pm_score": 1, "selected": false, "text": "<p>Have you tried simply reformatting the cell in Excel? It's probably just that the Excel is choosing a different format...
2008/12/07
[ "https://Stackoverflow.com/questions/347642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a problem. One of the datatable colums value is a string value '001200' for example. When the Excel document creats the value became '1200'. How can I keep a data format as is? I'm working with ASP.NET 1.1. The part of the code is: ``` private void lnkExport_Click( object sender, System.EventArgs e ) { Respo...
Add an apostrophe (single quote) to the start - that should fix it. It forces Excel to treat the cell as text instead of a number. Edit: just to be clear - the apostrophe thing is a built-in feature of an Excel, not just a random character I picked. Can't seem to find a link for it though.
347,656
<p>I have a table of data sorted by date, from which a user can select a set of data by supplying a start and end date. The data itself is non-continuous, in that I don't have data for weekends and public holidays. </p> <p>I would like to be able to list all the days that I don't have data for in the extracted dataset...
[ { "answer_id": 347663, "author": "Nerdfest", "author_id": 7855, "author_profile": "https://Stackoverflow.com/users/7855", "pm_score": 1, "selected": false, "text": "<p>You should be able to create a filtered iterator that provides this. Perhaps have the method for the iterator accept the...
2008/12/07
[ "https://Stackoverflow.com/questions/347656", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3410/" ]
I have a table of data sorted by date, from which a user can select a set of data by supplying a start and end date. The data itself is non-continuous, in that I don't have data for weekends and public holidays. I would like to be able to list all the days that I don't have data for in the extracted dataset. Is there...
You could create a temp list and x it as needed. (Not actual Java. Sorry, my memory of it is horrible.) ``` dates = [...]; // list you have now; // build list unused = []; for (Date i = startdate; i < enddate; i += day) { unused.push(i); } // remove used dates for (int j = 0; j < dates.length; j += 1) { if ...
347,659
<p>I looked at SQL Server dateformat codes but I couldn't find dd.mm.yyyy hh:mm format in the list. German Date Format(Code is 4) works for me but it doesn't contain hh:mm. Does someone know this format's code?</p>
[ { "answer_id": 347670, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": true, "text": "<p>Assuming your column is named [datefield]</p>\n\n<pre><code>CONVERT(varchar,[datefield],104)\n + ' '\n + SUBS...
2008/12/07
[ "https://Stackoverflow.com/questions/347659", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I looked at SQL Server dateformat codes but I couldn't find dd.mm.yyyy hh:mm format in the list. German Date Format(Code is 4) works for me but it doesn't contain hh:mm. Does someone know this format's code?
Assuming your column is named [datefield] ``` CONVERT(varchar,[datefield],104) + ' ' + SUBSTRING(CONVERT(varchar,[datefield],108),1,5) ```
347,661
<p>How would I handle something like the below uri using ASP.NET MVC's routing capability:</p> <pre><code>http://localhost/users/{username}/bookmarks/ - GET http://localhost/users/{username}/bookmark/{bookmarkid} - PUT </code></pre> <p>Which lists the bookmarks for the user in {username}.</p> <p>Thanks</p>
[ { "answer_id": 347726, "author": "Pablo Retyk", "author_id": 30729, "author_profile": "https://Stackoverflow.com/users/30729", "pm_score": 3, "selected": true, "text": "<p>first you need to create a new route in global.aspx</p>\n\n<pre><code>routes.MapRoute(\"Bookmarks\", \"{controller}/...
2008/12/07
[ "https://Stackoverflow.com/questions/347661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33764/" ]
How would I handle something like the below uri using ASP.NET MVC's routing capability: ``` http://localhost/users/{username}/bookmarks/ - GET http://localhost/users/{username}/bookmark/{bookmarkid} - PUT ``` Which lists the bookmarks for the user in {username}. Thanks
first you need to create a new route in global.aspx ``` routes.MapRoute("Bookmarks", "{controller}/{user}/{action}/{id}"); ``` then add a new action ``` public class UsersController : Controller { [AcceptVerbs("Post")] public void Bookmarks(string user, int? id) { //add your bookmark } } `...
347,664
<p>Is it possible to use something like:</p> <pre><code>require 'serialport.o' </code></pre> <p>with Shoes? serialport.o is compiled c code as a ruby extension.</p> <p>When I attempt to run the following code in shoes, I see no visible output to the screen and shoes crashes on OS X.</p> <p>Thank you</p> <p>CODE:<...
[ { "answer_id": 347701, "author": "Moss Collum", "author_id": 13210, "author_profile": "https://Stackoverflow.com/users/13210", "pm_score": 1, "selected": false, "text": "<p>You've probably already checked this, but does the same thing work if you aren't using Shoes? For example:</p>\n\n<...
2008/12/07
[ "https://Stackoverflow.com/questions/347664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Is it possible to use something like: ``` require 'serialport.o' ``` with Shoes? serialport.o is compiled c code as a ruby extension. When I attempt to run the following code in shoes, I see no visible output to the screen and shoes crashes on OS X. Thank you CODE: ``` require "serialport.o" port = "/dev/tty.us...
You've probably already checked this, but does the same thing work if you aren't using Shoes? For example: ``` require "serialport.o" port = "/dev/tty.usbserial-A1001O0o" sp = SerialPort.new( port, 9600, 8, 1, SerialPort::NONE) sp.write( "1" ) sp.close ```
347,675
<p>I have a class like this:</p> <pre><code>public class myClass { public List&lt;myOtherClass&gt; anewlist = new List&lt;myOtherClass&gt;; public void addToList(myOtherClass tmp) { anewList.Add(tmp); } } </code></pre> <p>So I call "addToList" a hundred times, each adding a unique item to the list. I'v...
[ { "answer_id": 347679, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 1, "selected": false, "text": "<p>Try iterating through the list using foreach rather than by index. I suspect that the problem is in the code that y...
2008/12/07
[ "https://Stackoverflow.com/questions/347675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44004/" ]
I have a class like this: ``` public class myClass { public List<myOtherClass> anewlist = new List<myOtherClass>; public void addToList(myOtherClass tmp) { anewList.Add(tmp); } } ``` So I call "addToList" a hundred times, each adding a unique item to the list. I've tested my items to show that before I...
Given the signature of your addToList method: ``` public void addToList(myOtherClass tmp) { anewList.Add(tmp); } ``` Is is possible that in the consumer of that method, you aren't actually creating a new instance? You said that you are calling addToList 100 times. Presumably, that is in a loop. At each loop...
347,693
<p>The target machine is running Ububtu server 8.04.<br> Here's the tramp output:</p> <pre><code>tramp: Opening connection for nungu@ip.ip.ip.ip using nil...&lt;br&gt; tramp: Waiting for prompts from remote shell&lt;br&gt; tramp: Waiting 60s for prompt from remote shell&lt;br&gt; tramp: Sending password&lt;br&gt; tram...
[ { "answer_id": 348287, "author": "genehack", "author_id": 39933, "author_profile": "https://Stackoverflow.com/users/39933", "pm_score": 1, "selected": false, "text": "<p><em>see buffer tramp/plink nungu@ip.ip.ip.ip'</em></p>\n\n<p>Well, what's in that buffer?</p>\n\n<p><strong>edit</stro...
2008/12/07
[ "https://Stackoverflow.com/questions/347693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3945/" ]
The target machine is running Ububtu server 8.04. Here's the tramp output: ``` tramp: Opening connection for nungu@ip.ip.ip.ip using nil...<br> tramp: Waiting for prompts from remote shell<br> tramp: Waiting 60s for prompt from remote shell<br> tramp: Sending password<br> tramp: Found remote shell prompt.<br> tramp...
Same problem; and a fix Working: NTEmacs-22.1 - Tramp Version: 2.0.55 Failing: NTEmacs-22.3.1 - Tramp Version: 2.0.58-pre See comment - neither 2.0.\* release worked on emacs-22.3.1 Upgraded to tramp 2.1.14 - emacs 22/3/1 works great Recommend you try upgrading from [Savannah](http://savannah.gnu.org/projects/tram...
347,721
<p>I'm looking to perform a perspective transform on a UIView (such as seen in coverflow)</p> <p>Does anyonew know if this is possible? </p> <p>I've investigated using <code>CALayer</code> and have run through all the pragmatic programmer Core Animation podcasts, but I'm still no clearer on how to create this kind of...
[ { "answer_id": 347815, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 3, "selected": false, "text": "<p>You can only use Core Graphics (Quartz, 2D only) transforms directly applied to a UIView's transform property. To ge...
2008/12/07
[ "https://Stackoverflow.com/questions/347721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1221378/" ]
I'm looking to perform a perspective transform on a UIView (such as seen in coverflow) Does anyonew know if this is possible? I've investigated using `CALayer` and have run through all the pragmatic programmer Core Animation podcasts, but I'm still no clearer on how to create this kind of transform on an iPhone. An...
As Ben said, you'll need to work with the `UIView's` layer, using a `CATransform3D` to perform the `layer's` `rotation`. The trick to get perspective working, as [described here](http://watchingapple.com/2008/04/core-animation-3d-perspective/), is to directly access one of the matrix `cells` of the `CATransform3D` (m34...
347,734
<p>I need some help calculating Pi. I am trying to write a python program that will calculate Pi to X digits. I have tried several from the python mailing list, and it is to slow for my use. I have read about the <a href="http://en.wikipedia.org/wiki/Gauss-Legendre_algorithm" rel="noreferrer">Gauss-Legendre Algorithm<...
[ { "answer_id": 347749, "author": "jfs", "author_id": 4279, "author_profile": "https://Stackoverflow.com/users/4279", "pm_score": 6, "selected": true, "text": "<ol>\n<li><p>You forgot parentheses around <code>4*t</code>:</p>\n\n<pre><code>pi = (a+b)**2 / (4*t)\n</code></pre></li>\n<li><p>...
2008/12/07
[ "https://Stackoverflow.com/questions/347734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42584/" ]
I need some help calculating Pi. I am trying to write a python program that will calculate Pi to X digits. I have tried several from the python mailing list, and it is to slow for my use. I have read about the [Gauss-Legendre Algorithm](http://en.wikipedia.org/wiki/Gauss-Legendre_algorithm), and I have tried porting i...
1. You forgot parentheses around `4*t`: ``` pi = (a+b)**2 / (4*t) ``` 2. You can use `decimal` to perform calculation with higher precision. ``` #!/usr/bin/env python from __future__ import with_statement import decimal def pi_gauss_legendre(): D = decimal.Decimal with decimal.localcontext() as ctx: ...
347,741
<p>Why don't we get compile errors on inline code errors in asp.net mvc views f.eks</p> <pre><code>&lt;h1&gt;&lt;%= ViewData.Model.Title.Tostrig() %&gt;&lt;/h1&gt; </code></pre> <p>The code above will build just fine. Wrong spelling in webform controls will give you an error so I can't see why this isn't supported in...
[ { "answer_id": 347757, "author": "Jason Whitehorn", "author_id": 27860, "author_profile": "https://Stackoverflow.com/users/27860", "pm_score": 5, "selected": true, "text": "<p>The ASPX files in both ASP.NET and ASP.NET MVC are not compiled from the Visual Studio IDE. This is often the ca...
2008/12/07
[ "https://Stackoverflow.com/questions/347741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29519/" ]
Why don't we get compile errors on inline code errors in asp.net mvc views f.eks ``` <h1><%= ViewData.Model.Title.Tostrig() %></h1> ``` The code above will build just fine. Wrong spelling in webform controls will give you an error so I can't see why this isn't supported in asp.net mvc EDIT: Luckily there seem to be...
The ASPX files in both ASP.NET and ASP.NET MVC are not compiled from the Visual Studio IDE. This is often the cause for "false positives" as you have pointed out. I often add the [aspnet\_compiler](http://msdn.microsoft.com/en-us/library/ms229863(VS.80).aspx) as a post build action to find those errors. You will add ...
347,798
<p>I need to change an element's ID using jQuery. </p> <p>Apparently these don't work:</p> <pre><code>jQuery(this).prev("li").attr("id")="newid" jQuery(this).prev("li")="newid" </code></pre> <p>I found out that I can make it happen with the following code:</p> <pre><code>jQuery(this).prev("li")show(function() { ...
[ { "answer_id": 347802, "author": "Tim Knight", "author_id": 43043, "author_profile": "https://Stackoverflow.com/users/43043", "pm_score": 3, "selected": false, "text": "<p>I'm not sure what your goal is, but might it be better to use addClass instead? I mean an objects ID in my opinion s...
2008/12/07
[ "https://Stackoverflow.com/questions/347798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1011/" ]
I need to change an element's ID using jQuery. Apparently these don't work: ``` jQuery(this).prev("li").attr("id")="newid" jQuery(this).prev("li")="newid" ``` I found out that I can make it happen with the following code: ``` jQuery(this).prev("li")show(function() { this.id="newid"; }); ``` But that doesn't...
Your syntax is incorrect, you should pass the value as the second parameter: ``` jQuery(this).prev("li").attr("id","newId"); ```
347,804
<p>I'm building a web application that guides my users through the configuration and installation of an application. It builds a set of configuration files dynamically, then sends them in an archive (.ZIP file) along with an installer for the application. The web page is generated from a linux shell script (sorry), a...
[ { "answer_id": 347817, "author": "Pim Jager", "author_id": 35197, "author_profile": "https://Stackoverflow.com/users/35197", "pm_score": 2, "selected": false, "text": "<p>You Can't really do that I think.<br>\nYou can force the file download through the following headers but as far is I ...
2008/12/07
[ "https://Stackoverflow.com/questions/347804", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29157/" ]
I'm building a web application that guides my users through the configuration and installation of an application. It builds a set of configuration files dynamically, then sends them in an archive (.ZIP file) along with an installer for the application. The web page is generated from a linux shell script (sorry), and fo...
A friend supplied the magic: use an `<iframe>` tag to create an "invisible" frame that contains only the file to download: ``` <iframe id="file_download" width="0" height="0" scrolling="no" frameborder="0" src=/cgi-bin/my/scripts/sendfiles?file=$filename.zip> You need a browser that supports frames. </iframe>` ...
347,812
<p>Is there a way to be <strong>sure</strong> that a page is coming from cache on a production server and on the development server as well?</p> <p>The solution <strong>shouldn't</strong> involve caching middleware because not every project uses them. Though the solution itself might <strong>be</strong> a middleware.<...
[ { "answer_id": 348079, "author": "ironfroggy", "author_id": 19687, "author_profile": "https://Stackoverflow.com/users/19687", "pm_score": 3, "selected": false, "text": "<p>Mock the view, hit the page, and see if the mock was called. if it was not, the cache was used instead.</p>\n" }, ...
2008/12/07
[ "https://Stackoverflow.com/questions/347812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42188/" ]
Is there a way to be **sure** that a page is coming from cache on a production server and on the development server as well? The solution **shouldn't** involve caching middleware because not every project uses them. Though the solution itself might **be** a middleware. Just checking if the data is stale is not a very...
We do a lot of component caching and not all of them are updated at the same time. So we set host and timestamp values in a universally included context processor. At the top of each template fragment we stick in: ``` <!-- component_name {{host}} {{timestamp}} --> ``` The component\_name just makes it easy to do a V...
347,818
<p>It is my understanding that I can test that a method call will occur if I call a higher level method, i.e.:</p> <pre><code>public abstract class SomeClass() { public void SomeMehod() { SomeOtherMethod(); } internal abstract void SomeOtherMethod(); } </code></pre> <p>I want to test that...
[ { "answer_id": 347907, "author": "Paul", "author_id": 41301, "author_profile": "https://Stackoverflow.com/users/41301", "pm_score": 9, "selected": true, "text": "<p>You can see if a method in something you have mocked has been called by using Verify, e.g.:</p>\n\n<pre><code>static void M...
2008/12/07
[ "https://Stackoverflow.com/questions/347818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/425/" ]
It is my understanding that I can test that a method call will occur if I call a higher level method, i.e.: ``` public abstract class SomeClass() { public void SomeMehod() { SomeOtherMethod(); } internal abstract void SomeOtherMethod(); } ``` I want to test that if I call `SomeMethod()` ...
You can see if a method in something you have mocked has been called by using Verify, e.g.: ``` static void Main(string[] args) { Mock<ITest> mock = new Mock<ITest>(); ClassBeingTested testedClass = new ClassBeingTested(); testedClass.WorkMethod(mock.Object); mock.Verify(m => m.Method...
347,837
<p>I'm working on a problem that requires caching paginated "search" results: <a href="https://stackoverflow.com/questions/347277/paginating-very-large-datasets">Paginating very large datasets</a></p> <p>The search works as follows: given an item_id, I find the matching item_ids and their rank.</p> <p>I'm willing t...
[ { "answer_id": 347841, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 3, "selected": true, "text": "<p>MySQL can handle this many rows, and there are several techniques to scale when you are starting to hit the wall. ...
2008/12/07
[ "https://Stackoverflow.com/questions/347837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43005/" ]
I'm working on a problem that requires caching paginated "search" results: [Paginating very large datasets](https://stackoverflow.com/questions/347277/paginating-very-large-datasets) The search works as follows: given an item\_id, I find the matching item\_ids and their rank. I'm willing to concede not showing my use...
MySQL can handle this many rows, and there are several techniques to scale when you are starting to hit the wall. [Partioning](http://dev.mysql.com/doc/refman/5.1/en/partitioning.html) and [replication](http://dev.mysql.com/doc/refman/5.1/en/replication.html) are the main solutions for this scenario. You can also chec...
347,851
<p>The project I'm working on has two type of accounts, "<code>people</code>" and "<code>companies</code>". </p> <p>I hold a single "<code>users</code>" table with all the accounts and just the basic info needed for login (email, pass, etc), and two other tables "<code>user_profiles</code>" (regular people) and "<code...
[ { "answer_id": 347858, "author": "mson", "author_id": 36902, "author_profile": "https://Stackoverflow.com/users/36902", "pm_score": 4, "selected": true, "text": "<pre><code>select\n u.user_id, u.user_type, concat_ws(profile_first_name + profile_last_name) as full_name\nfrom \n users u, u...
2008/12/07
[ "https://Stackoverflow.com/questions/347851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44126/" ]
The project I'm working on has two type of accounts, "`people`" and "`companies`". I hold a single "`users`" table with all the accounts and just the basic info needed for login (email, pass, etc), and two other tables "`user_profiles`" (regular people) and "`company_profiles`" (companies) that hold more specific col...
``` select u.user_id, u.user_type, concat_ws(profile_first_name + profile_last_name) as full_name from users u, user_profiles up where u.key = up.key and u.user_type = 'user' union select u.user_id, u.user_type, concat_ws(profile_first_name + profile_last_name) as full_name from users u, company_profiles cp wh...
347,856
<p>I have created a form to add a user to a database and make user available for login.</p> <p>Now I have two password fields (the second is for validation of the first). How can I add a validator for this kind of validation to zend_form?</p> <p>This is my code for the two password fields:</p> <pre><code> $passwo...
[ { "answer_id": 348782, "author": "Irmantas", "author_id": 43182, "author_profile": "https://Stackoverflow.com/users/43182", "pm_score": 1, "selected": false, "text": "<p>here is how i done this :)</p>\n\n<p>create first pass input then crate second pass input and add Identical validator ...
2008/12/07
[ "https://Stackoverflow.com/questions/347856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42111/" ]
I have created a form to add a user to a database and make user available for login. Now I have two password fields (the second is for validation of the first). How can I add a validator for this kind of validation to zend\_form? This is my code for the two password fields: ``` $password = new Zend_Form_Element_...
When I was looking for the same, I found this very well working generic Validator for Identical Fields. I don't find it now so I just post the code... ``` <?php class Zend_Validate_IdenticalField extends Zend_Validate_Abstract { const NOT_MATCH = 'notMatch'; const MISSING_FIELD_NAME = 'missingFieldName'; const...
347,871
<p>I found a bug in Delphi 2009's implementation of TFields and wrote a quick patch. I copied DB.pas to my projects folder and added it to the project's file list, but now I can't get it to compile. The first two error messages don't even make any sense when I go to the indicated places in the code.</p> <p>Surely if...
[ { "answer_id": 348257, "author": "Andreas Hausladen", "author_id": 44005, "author_profile": "https://Stackoverflow.com/users/44005", "pm_score": 4, "selected": true, "text": "<p>Does it help if you add the following line at the top of the DB.pas unit.</p>\n\n<p>{$A8,B-,C+,D+,E-,F-,G+,H+,...
2008/12/07
[ "https://Stackoverflow.com/questions/347871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32914/" ]
I found a bug in Delphi 2009's implementation of TFields and wrote a quick patch. I copied DB.pas to my projects folder and added it to the project's file list, but now I can't get it to compile. The first two error messages don't even make any sense when I go to the indicated places in the code. Surely if anything ca...
Does it help if you add the following line at the top of the DB.pas unit. {$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N-,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1} If it works after using this line, then your project options are not compatible with the settings that CodeGear used to compile the RTL/VCL. BTW: Line 2536 is a l...
347,889
<p>i have got an 32bit (hexadecimal)word 0xaabbccdd and have to swap the 2. and the 3. byte. in the end it should look like 0xaaccbbdd</p> <p>how can i "mask" the 2nd and the 3rd byte to first load them up to register r1 and r2 and the swap them.. i also know that i have to work with lsl and lsr commands but dont know...
[ { "answer_id": 348009, "author": "Nils Pipenbrinck", "author_id": 15955, "author_profile": "https://Stackoverflow.com/users/15955", "pm_score": 3, "selected": false, "text": "<p>That's not a simple task in ARM assembly because you can't easily use 32 bit constants. You have to break up a...
2008/12/07
[ "https://Stackoverflow.com/questions/347889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30954/" ]
i have got an 32bit (hexadecimal)word 0xaabbccdd and have to swap the 2. and the 3. byte. in the end it should look like 0xaaccbbdd how can i "mask" the 2nd and the 3rd byte to first load them up to register r1 and r2 and the swap them.. i also know that i have to work with lsl and lsr commands but dont know how to st...
That's not a simple task in ARM assembly because you can't easily use 32 bit constants. You have to break up all your operations that mask out bytes to use 8 bit constants each (also these constants can be rotated). You mask out byte2 and 3 using the AND instruction and do the shift later. in ARM-assembler you have wi...
347,897
<p>I need to use <code>FtpWebRequest</code> to put a file in a FTP directory. Before the upload, I would first like to know if this file exists. </p> <p>What method or property should I use to check if this file exists?</p>
[ { "answer_id": 348334, "author": "user42467", "author_id": 42467, "author_profile": "https://Stackoverflow.com/users/42467", "pm_score": 8, "selected": true, "text": "<pre><code>var request = (FtpWebRequest)WebRequest.Create\n (\"ftp://ftp.domain.com/doesntexist.txt\");\nrequest.Crede...
2008/12/07
[ "https://Stackoverflow.com/questions/347897", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38940/" ]
I need to use `FtpWebRequest` to put a file in a FTP directory. Before the upload, I would first like to know if this file exists. What method or property should I use to check if this file exists?
``` var request = (FtpWebRequest)WebRequest.Create ("ftp://ftp.domain.com/doesntexist.txt"); request.Credentials = new NetworkCredential("user", "pass"); request.Method = WebRequestMethods.Ftp.GetFileSize; try { FtpWebResponse response = (FtpWebResponse)request.GetResponse(); } catch (WebException ex) { Ft...
347,918
<p>I would like to generate some JavaScript on the server side in ASP.Net MVC. Is there a view engine that supports this? Ideally I would like to be able to get JavaScript from an url like: </p> <pre><code>http://myapp/controller/action.js </code></pre> <p>I've looked at the MonoRail project, and they seem to have th...
[ { "answer_id": 347946, "author": "Jennifer", "author_id": 22360, "author_profile": "https://Stackoverflow.com/users/22360", "pm_score": 1, "selected": false, "text": "<p>I had to do something very similar, and I used the nvelocity view engine from <a href=\"http://www.codeplex.com/MVCCon...
2008/12/07
[ "https://Stackoverflow.com/questions/347918", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22107/" ]
I would like to generate some JavaScript on the server side in ASP.Net MVC. Is there a view engine that supports this? Ideally I would like to be able to get JavaScript from an url like: ``` http://myapp/controller/action.js ``` I've looked at the MonoRail project, and they seem to have this feature, but it's very ...
I wanted to extend this idea to not only allow Javascript views, but more or less any type of document. To use it, you just put the views for \*.js urls in a subfolder of your controller's view folder: ``` \Views +-\MyController +-\js | +-Index.aspx <- This view will get rendered if you request /MyController/Index...
347,949
<p>How can I convert an <code>std::string</code> to a <code>char*</code> or a <code>const char*</code>?</p>
[ { "answer_id": 347952, "author": "Mark Ransom", "author_id": 5987, "author_profile": "https://Stackoverflow.com/users/5987", "pm_score": 5, "selected": false, "text": "<p>Use the <code>.c_str()</code> method for <code>const char *</code>.</p>\n\n<p>You can use <code>&amp;mystring[0]</cod...
2008/12/07
[ "https://Stackoverflow.com/questions/347949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37875/" ]
How can I convert an `std::string` to a `char*` or a `const char*`?
If you just want to pass a [`std::string`](http://en.cppreference.com/w/cpp/string/basic_string) to a function that needs `const char *`, you can use [`.c_str()`](https://en.cppreference.com/w/cpp/string/basic_string/c_str): ``` std::string str; const char * c = str.c_str(); ``` And if you need a non-const `char *`,...
347,954
<p>How can I do a script to catch strings as input and open them on a Firefox document? Each link would go to a different window or tab. Any ideas would be much appreciated.</p> <p>I just want to be able to take some links and open them. For example I have 50 Links. And copying and parsing those 50 Links take a really...
[ { "answer_id": 349403, "author": "Aaron Digulla", "author_id": 34088, "author_profile": "https://Stackoverflow.com/users/34088", "pm_score": 0, "selected": false, "text": "<p>Write this to a file names \"links.html\" on your hard disk:</p>\n\n<pre><code>&lt;html&gt;\n&lt;head&gt;&lt;titl...
2008/12/07
[ "https://Stackoverflow.com/questions/347954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How can I do a script to catch strings as input and open them on a Firefox document? Each link would go to a different window or tab. Any ideas would be much appreciated. I just want to be able to take some links and open them. For example I have 50 Links. And copying and parsing those 50 Links take a really long time...
if i got you right, i guess you could do something like this. This will open the four urls listed but it will probably be blocked by the popup blocker. ``` <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Documento sin t&iacute;tulo</title> <meta http-equiv="Content-Type" content="t...
348,021
<p>By means of a regular expression and Greasemonkey I have an array of results that looks like:<br> <code>choice1, choice2, choice3, choice3, choice1, etc..</code></p> <p>My question is how do I tally up the choices so I know how many times choice1 is in the array, choice2 is in the array, etc. if I do not know e...
[ { "answer_id": 348032, "author": "Ryan Cook", "author_id": 43029, "author_profile": "https://Stackoverflow.com/users/43029", "pm_score": 1, "selected": false, "text": "<p>Not 100% sure what your looking for, but I think this is it. </p>\n\n<pre><code> // Original data\n var choices ...
2008/12/07
[ "https://Stackoverflow.com/questions/348021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44133/" ]
By means of a regular expression and Greasemonkey I have an array of results that looks like: `choice1, choice2, choice3, choice3, choice1, etc..` My question is how do I tally up the choices so I know how many times choice1 is in the array, choice2 is in the array, etc. if I do not know exactly how many choices th...
One technique would be to iterate over the choices and increment a counter associated to each unique choice in an object property. Example: ``` var choiceCounts = {}; for (var iLoop=0; iLoop < aChoices.length; iLoop++) { var keyChoice = aChoices[iLoop]; if (!choiceCounts[keyChoice]) { choiceCounts[keyChoice] ...
348,022
<p>I'm trying to implement a Load / Save function for a Windows Forms application.</p> <p>I've got following components:</p> <ul> <li>A tree view</li> <li>A couple of list views</li> <li>A couple of text boxes</li> <li>A couple of objects (which holds a big dictionarylist)</li> </ul> <p>I want to implement a way to ...
[ { "answer_id": 348024, "author": "Marc Gravell", "author_id": 23354, "author_profile": "https://Stackoverflow.com/users/23354", "pm_score": 3, "selected": false, "text": "<p>Ideally, you shouldn't be persisting the UI state; you should be persisting the state of some object model represe...
2008/12/07
[ "https://Stackoverflow.com/questions/348022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40322/" ]
I'm trying to implement a Load / Save function for a Windows Forms application. I've got following components: * A tree view * A couple of list views * A couple of text boxes * A couple of objects (which holds a big dictionarylist) I want to implement a way to save all of this into a file, and resume/load it later o...
Here's an example that binds an object and some ancestors to the UI; the use of C# 3.0 here is purely for brevity - everything would work with C# 2.0 too. Most of the code here is setting up the form, and/or dealing with property-change notifications - importantly, there isn't any code devoted to updating the UI from ...
348,037
<p>I have a problem with the following code:</p> <pre><code>for(i = 0;(i - 1)&lt; n;i++) { char* b; sprintf(b, "%d", i); } </code></pre> <p>It compiles fine but when I run it it give me the infamous "0XC0000005 Access Violation" error. I have tried setting b to NULL, "", "0", 0 and a bunch of other stuff but then I g...
[ { "answer_id": 348042, "author": "Uri", "author_id": 23072, "author_profile": "https://Stackoverflow.com/users/23072", "pm_score": 1, "selected": false, "text": "<p>Umm... Your pointer to b contains garbage since you haven't initialized it or allocated space.\nSpringtf requires you to ha...
2008/12/07
[ "https://Stackoverflow.com/questions/348037", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37875/" ]
I have a problem with the following code: ``` for(i = 0;(i - 1)< n;i++) { char* b; sprintf(b, "%d", i); } ``` It compiles fine but when I run it it give me the infamous "0XC0000005 Access Violation" error. I have tried setting b to NULL, "", "0", 0 and a bunch of other stuff but then I get the "0XC0000005 Access Vio...
`sprintf` writes data into an existing buffer, which you pass into it as the first parameter. Currently you're not specifying a value for b at all, which means (IIRC in C) the value could be anything. If you set it to NULL or 0, `sprintf` is going to try to write into memory starting at address 0. You need to create a...
348,093
<p>Can someone please let me know how do I implement "Did you mean" feature in Lucene.net?</p> <p>Thanks!</p>
[ { "answer_id": 348117, "author": "jishi", "author_id": 33663, "author_profile": "https://Stackoverflow.com/users/33663", "pm_score": 3, "selected": false, "text": "<p>AFAIK Lucene supports proximity-search, meaning that if you use something like:</p>\n\n<p>field:stirng~0.5</p>\n\n<p>(it ...
2008/12/07
[ "https://Stackoverflow.com/questions/348093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40907/" ]
Can someone please let me know how do I implement "Did you mean" feature in Lucene.net? Thanks!
You should look into the [SpellChecker](https://svn.apache.org/repos/asf/lucene/lucene.net/trunk/C%23/contrib/SpellChecker.Net/) module in the contrib dir. It's a port of Java lucene's [SpellChecker](https://lucene.apache.org/core/6_3_0/suggest/index.html?org/apache/lucene/search/spell/SpellChecker.html) module, so its...
348,109
<p>Is hashing a password twice before storage any more or less secure than just hashing it once?</p> <p>What I'm talking about is doing this:</p> <pre><code>$hashed_password = hash(hash($plaintext_password)); </code></pre> <p>instead of just this:</p> <pre><code>$hashed_password = hash($plaintext_password); </code>...
[ { "answer_id": 348114, "author": "Rich Bradshaw", "author_id": 16511, "author_profile": "https://Stackoverflow.com/users/16511", "pm_score": 3, "selected": false, "text": "<p>Yes - it reduces the number of possibly strings that match the string.</p>\n\n<p>As you have already mentioned, s...
2008/12/07
[ "https://Stackoverflow.com/questions/348109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1288/" ]
Is hashing a password twice before storage any more or less secure than just hashing it once? What I'm talking about is doing this: ``` $hashed_password = hash(hash($plaintext_password)); ``` instead of just this: ``` $hashed_password = hash($plaintext_password); ``` If it is less secure, can you provide a good ...
Hashing a password once is insecure ----------------------------------- No, multiple hashes are not less secure; they are an essential part of secure password use. Iterating the hash increases the time it takes for an attacker to try each password in their list of candidates. You can easily increase the time it takes...
348,127
<p>I have the following situation:</p> <p>I have a certain function that runs a loop and does stuff, and error conditions may make it exit that loop. I want to be able to check whether the loop is still running or not.</p> <p>For this, i'm doing, for each loop run:</p> <pre><code>LastTimeIDidTheLoop = new Date(); </...
[ { "answer_id": 348133, "author": "rob", "author_id": 43927, "author_profile": "https://Stackoverflow.com/users/43927", "pm_score": 4, "selected": true, "text": "<p>what about:</p>\n\n<pre><code>newDate = new Date()\nnewDate.setSeconds(newDate.getSeconds()-30);\nif (newDate &gt; LastTimeI...
2008/12/07
[ "https://Stackoverflow.com/questions/348127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3314/" ]
I have the following situation: I have a certain function that runs a loop and does stuff, and error conditions may make it exit that loop. I want to be able to check whether the loop is still running or not. For this, i'm doing, for each loop run: ``` LastTimeIDidTheLoop = new Date(); ``` And in another function,...
what about: ``` newDate = new Date() newDate.setSeconds(newDate.getSeconds()-30); if (newDate > LastTimeIDidTheLoop) { alert("oops"); } ```
348,128
<p>This is silly, but I haven't found this information. If you have names of concepts and suitable references, just let me know.</p> <p>I'd like to understand how should I validate a given named id for a generic entity, like, say, an email login, just like Yahoo, Google and Microsoft do.</p> <p>I mean... If you do ha...
[ { "answer_id": 348133, "author": "rob", "author_id": 43927, "author_profile": "https://Stackoverflow.com/users/43927", "pm_score": 4, "selected": true, "text": "<p>what about:</p>\n\n<pre><code>newDate = new Date()\nnewDate.setSeconds(newDate.getSeconds()-30);\nif (newDate &gt; LastTimeI...
2008/12/07
[ "https://Stackoverflow.com/questions/348128", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39261/" ]
This is silly, but I haven't found this information. If you have names of concepts and suitable references, just let me know. I'd like to understand how should I validate a given named id for a generic entity, like, say, an email login, just like Yahoo, Google and Microsoft do. I mean... If you do have an user named ...
what about: ``` newDate = new Date() newDate.setSeconds(newDate.getSeconds()-30); if (newDate > LastTimeIDidTheLoop) { alert("oops"); } ```
348,170
<p>I mistakenly added files to Git using the command:</p> <pre><code>git add myfile.txt </code></pre> <p>I have not yet run <code>git commit</code>. How do I undo this so that these changes will not be included in the commit?</p>
[ { "answer_id": 348234, "author": "genehack", "author_id": 39933, "author_profile": "https://Stackoverflow.com/users/39933", "pm_score": 15, "selected": true, "text": "<p>Undo <code>git add</code> for uncommitted changes with:</p>\n<pre><code>git reset &lt;file&gt;\n</code></pre>\n<p>That...
2008/12/07
[ "https://Stackoverflow.com/questions/348170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14069/" ]
I mistakenly added files to Git using the command: ``` git add myfile.txt ``` I have not yet run `git commit`. How do I undo this so that these changes will not be included in the commit?
Undo `git add` for uncommitted changes with: ``` git reset <file> ``` That will remove the file from the current index (the "about to be committed" list) without changing anything else. --- To unstage all changes for all files: ``` git reset ``` --- In old versions of Git, the above commands are equivalent to ...
348,187
<p>I am trying to use the range property of the jQuery slider so that the slider control displays two handles from which the user can select a price range for real estate. The code I have is:</p> <pre><code>$("#price").slider({ range: true, minValue: 0, maxValue: 2000000, change: function(e, ui) { var range = ...
[ { "answer_id": 348273, "author": "Brian Fisher", "author_id": 43816, "author_profile": "https://Stackoverflow.com/users/43816", "pm_score": 4, "selected": true, "text": "<p>To access the slider handle values in a double handled slider you need to access them from the <a href=\"http://doc...
2008/12/07
[ "https://Stackoverflow.com/questions/348187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27294/" ]
I am trying to use the range property of the jQuery slider so that the slider control displays two handles from which the user can select a price range for real estate. The code I have is: ``` $("#price").slider({ range: true, minValue: 0, maxValue: 2000000, change: function(e, ui) { var range = (Math.round(ui...
To access the slider handle values in a double handled slider you need to access them from the [slider( "value", index )](http://docs.jquery.com/UI/Slider/slider#slider.28.C2.A0.22value.22.2C.C2.A0index_.29) function. Try the following code: ``` $(document).ready(function(){ $("#price").slider( { range: true...
348,196
<p>I'm trying to create a Python script that opens several databases and compares their contents. In the process of creating that script, I've run into a problem in creating a list whose contents are objects that I've created.</p> <p>I've simplified the program to its bare bones for this posting. First I create a new...
[ { "answer_id": 348214, "author": "joel.neely", "author_id": 3525, "author_profile": "https://Stackoverflow.com/users/3525", "pm_score": 3, "selected": false, "text": "<p>Create a new instance each time, where each new instance has the correct state, rather than continually modifying the ...
2008/12/07
[ "https://Stackoverflow.com/questions/348196", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I'm trying to create a Python script that opens several databases and compares their contents. In the process of creating that script, I've run into a problem in creating a list whose contents are objects that I've created. I've simplified the program to its bare bones for this posting. First I create a new class, cre...
You demonstrate a fundamental misunderstanding. You never created an instance of SimpleClass at all, because you didn't call it. ``` for count in xrange(4): x = SimpleClass() x.attr = count simplelist.append(x) ``` Or, if you let the class take parameters, instead, you can use a list comprehension. ```...
348,201
<p>Is there any way I can specify a standard or custom numeric format string to always output the sign, be it +ve or -ve (although what it should do for zero, I'm not sure!)</p>
[ { "answer_id": 348242, "author": "gcores", "author_id": 40256, "author_profile": "https://Stackoverflow.com/users/40256", "pm_score": 9, "selected": true, "text": "<p>Yes, you can. \nThere is conditional formatting. See <a href=\"http://msdn.microsoft.com/en-us/library/0c899ak8.aspx\" re...
2008/12/07
[ "https://Stackoverflow.com/questions/348201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14537/" ]
Is there any way I can specify a standard or custom numeric format string to always output the sign, be it +ve or -ve (although what it should do for zero, I'm not sure!)
Yes, you can. There is conditional formatting. See [Conditional formatting in MSDN](http://msdn.microsoft.com/en-us/library/0c899ak8.aspx) eg: ``` string MyString = number.ToString("+0;-#"); ``` Where each section separated by a semicolon represents positive and negative numbers or: ``` string MyString = number...
348,202
<p>I want to warn users of Internet Explorer 6 using my site, that IE6 has had serious compatibility issues with my site in the past. What is the best way to do this?</p> <p>Ideally, I want to have a message appear (not a new window, but a message box, if possible) that warns IE6 users of the issues and reccommends th...
[ { "answer_id": 348211, "author": "chriscena", "author_id": 32671, "author_profile": "https://Stackoverflow.com/users/32671", "pm_score": -1, "selected": false, "text": "<p>My suggestion would be to fix your site ;) No seriously, I would use a small banner on top of the page, like the sma...
2008/12/07
[ "https://Stackoverflow.com/questions/348202", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5509/" ]
I want to warn users of Internet Explorer 6 using my site, that IE6 has had serious compatibility issues with my site in the past. What is the best way to do this? Ideally, I want to have a message appear (not a new window, but a message box, if possible) that warns IE6 users of the issues and reccommends they update ...
If you want to determine if it's anything other than support browsers, you might want to use jQuery's browser detection, something like: ``` <script type="text/javascript"> // check if browser is IE6 (when IE) or not FF6 (when FF) if (($.browser.msie && $.browser.version.substr(0,1) == '6') || ($.browser.mozilla &...
348,256
<p>I want to match a block of code <em>multiple</em> times in a file but can't work out the regular expression to do this. An example of the code block is:</p> <pre><code>//@debug ... // code in here ... //@end-debug (possibly more comments here on same line) </code></pre> <p>Each code block I'm trying to match will ...
[ { "answer_id": 348261, "author": "Dustin Getz", "author_id": 20003, "author_profile": "https://Stackoverflow.com/users/20003", "pm_score": 0, "selected": false, "text": "<p>what language? python regular expressions (i guess they're == to perl5 regexps) have the concept of 'greedy' vs 'n...
2008/12/07
[ "https://Stackoverflow.com/questions/348256", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40754/" ]
I want to match a block of code *multiple* times in a file but can't work out the regular expression to do this. An example of the code block is: ``` //@debug ... // code in here ... //@end-debug (possibly more comments here on same line) ``` Each code block I'm trying to match will start with `//@debug` and stop at...
Basically your regular expression is greedy. This means the wildcard operators grab as much as they possibly can with the results you've seen. Just change it to non-greedy where appropriate. In your case use: /(/{2}\@debug)(.|\s)\*?(/{2}\@end-debug).\*/
348,260
<p>I am writing a Firefox extension. I would like to search the current webpage for a set of words, and count how many times each occurs. This activity is only performed when the user asks, but it must still happen reasonably quickly.</p> <p>I am currently using indexOf on the BODY tag's innerHTML element, but am find...
[ { "answer_id": 348302, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 2, "selected": false, "text": "<p>I would select all the text nodes in the document, iterate through them (splitting the contents on whitespace), and ...
2008/12/07
[ "https://Stackoverflow.com/questions/348260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42974/" ]
I am writing a Firefox extension. I would like to search the current webpage for a set of words, and count how many times each occurs. This activity is only performed when the user asks, but it must still happen reasonably quickly. I am currently using indexOf on the BODY tag's innerHTML element, but am finding it too...
I'm not sure if it is the fastest but the following worked pretty quickly for me. ``` var words = document.body.innerHTML.replace(/<.*?>/g,'').split(/\s+/); var i = words.length; var keywordCounts = {'keyword': 0, 'javascript': 0, 'today': 0}; var keywords = []; var keywordMatcher = ''; var word; for (word in keywordC...
348,268
<p>I have a procedure that is run for a lot of items, skipping over certain items who don't meet a criterion. However, I then go back and run it for some of the individuals who were missed in the first pass. I currently do this by manually re-running the procedure for each individual person, but would ideally like a ...
[ { "answer_id": 348329, "author": "rob", "author_id": 43927, "author_profile": "https://Stackoverflow.com/users/43927", "pm_score": 0, "selected": false, "text": "<p>You can iterate on it in this way:</p>\n\n<pre>\nset rgList = Range(\"name_of_range\") \nFor i = 1 To rgList.Rows.Count\...
2008/12/07
[ "https://Stackoverflow.com/questions/348268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27290/" ]
I have a procedure that is run for a lot of items, skipping over certain items who don't meet a criterion. However, I then go back and run it for some of the individuals who were missed in the first pass. I currently do this by manually re-running the procedure for each individual person, but would ideally like a solut...
My eventual solution was to import the list as an external data query that I then named nicely and referenced as a range. So: ``` For each item in Sheets("Sheet1").Range("Range1") Do stuff Next item ```
348,282
<p>I'm working on a site with multiple subdomains, some of which should get their own session.</p> <p>I think I've got it worked out, but have noticed something about cookie handling that I don't understand. I don't see anything in the docs that explains it, so thought I would see if anyone here has some light to she...
[ { "answer_id": 348336, "author": "Brian Fisher", "author_id": 43816, "author_profile": "https://Stackoverflow.com/users/43816", "pm_score": 6, "selected": true, "text": "<p>PHP's cookie functions automatically prefix the $domain with a dot. If you don't want this behavior you could use ...
2008/12/07
[ "https://Stackoverflow.com/questions/348282", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27580/" ]
I'm working on a site with multiple subdomains, some of which should get their own session. I think I've got it worked out, but have noticed something about cookie handling that I don't understand. I don't see anything in the docs that explains it, so thought I would see if anyone here has some light to shed on the qu...
PHP's cookie functions automatically prefix the $domain with a dot. If you don't want this behavior you could use the [header](http://us2.php.net/header) function. For example: ``` header("Set-Cookie: cookiename=cookievalue; expires=Tue, 06-Jan-2009 23:39:49 GMT; path=/; domain=subdomain.example.net"); ```
348,304
<p>I am developing a State Machine Workflow using C# and WF in visual studio 2008. On one of my states I need to wait for multiple events to happen until the workflow can transition to the next state. As an example think of a unanimous voting scenario. I cannot find a way to do this. Does anyone have a solution or ...
[ { "answer_id": 348336, "author": "Brian Fisher", "author_id": 43816, "author_profile": "https://Stackoverflow.com/users/43816", "pm_score": 6, "selected": true, "text": "<p>PHP's cookie functions automatically prefix the $domain with a dot. If you don't want this behavior you could use ...
2008/12/07
[ "https://Stackoverflow.com/questions/348304", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22769/" ]
I am developing a State Machine Workflow using C# and WF in visual studio 2008. On one of my states I need to wait for multiple events to happen until the workflow can transition to the next state. As an example think of a unanimous voting scenario. I cannot find a way to do this. Does anyone have a solution or workaro...
PHP's cookie functions automatically prefix the $domain with a dot. If you don't want this behavior you could use the [header](http://us2.php.net/header) function. For example: ``` header("Set-Cookie: cookiename=cookievalue; expires=Tue, 06-Jan-2009 23:39:49 GMT; path=/; domain=subdomain.example.net"); ```
348,305
<p>I have a program that needs to do a <strong>compile time checkable</strong> map from one known set of values to another known set of values:</p> <pre> in out ------------ 8 37 10 61 12 92 13 1/4 109 15 1/4 151 etc </pre> <p>This would be easy if the inputs were either integers or evenly spac...
[ { "answer_id": 348344, "author": "David Norman", "author_id": 34502, "author_profile": "https://Stackoverflow.com/users/34502", "pm_score": 0, "selected": false, "text": "<p>Sounds like you want to want to use something like a sorted binary tree. Both lookup and iteration are fast and t...
2008/12/07
[ "https://Stackoverflow.com/questions/348305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1343/" ]
I have a program that needs to do a **compile time checkable** map from one known set of values to another known set of values: ``` in out ------------ 8 37 10 61 12 92 13 1/4 109 15 1/4 151 etc ``` This would be easy if the inputs were either integers or evenly spaced. I'm going to be iterat...
Can't you use a hash map?
348,342
<p>I'm currently trying to read text from a file and append it to a element in my html page using the DOM and Javascript. I can't get the text to format though. I've tried using innerHtml but isn't formating at all( no line breaks ).</p> <p>Here is the javascript:</p> <pre><code>http = new XMLHttpRequest(); http.open...
[ { "answer_id": 348343, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 1, "selected": false, "text": "<p>You might have luck wrapping the text in a <code>&lt;pre&gt;</code> tag. What's in the response? If it's XML, you might w...
2008/12/07
[ "https://Stackoverflow.com/questions/348342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44160/" ]
I'm currently trying to read text from a file and append it to a element in my html page using the DOM and Javascript. I can't get the text to format though. I've tried using innerHtml but isn't formating at all( no line breaks ). Here is the javascript: ``` http = new XMLHttpRequest(); http.open("GET",FILE,false); h...
You might have luck wrapping the text in a `<pre>` tag. What's in the response? If it's XML, you might want to use `responseXML`. ``` http = new XMLHttpRequest(); http.open("GET",FILE,false); http.send(); document.getElementById("tbody").appendChild(http.responseXML); ```
348,371
<p>I've got MS Access database with linked tables, whenever each table is linked to a table in the same SQL Server database. I have a query inside Access that joins two tables (in particular I'm updating a table based on another using a join).</p> <p>The question is does Access "download" all the table data before doi...
[ { "answer_id": 348409, "author": "Fionnuala", "author_id": 2548, "author_profile": "https://Stackoverflow.com/users/2548", "pm_score": 2, "selected": false, "text": "<p>According to Albert D. Kallal (Access MVP), Access does not pull the whole tables, except for complex views, where thin...
2008/12/08
[ "https://Stackoverflow.com/questions/348371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10793/" ]
I've got MS Access database with linked tables, whenever each table is linked to a table in the same SQL Server database. I have a query inside Access that joins two tables (in particular I'm updating a table based on another using a join). The question is does Access "download" all the table data before doing a join?...
I've looked at SQL Profiler (unfortunately i don't have the actual log handy) and here's what i found: * it selects all records from both tables * for each record in one table calls an UPDATE So this will be slow.
348,392
<p>How can I receive and send email in python? A 'mail server' of sorts.</p> <p>I am looking into making an app that listens to see if it receives an email addressed to foo@bar.domain.com, and sends an email to the sender.</p> <p>Now, am I able to do this all in python, would it be best to use 3rd party libraries? </...
[ { "answer_id": 348403, "author": "Bullines", "author_id": 27870, "author_profile": "https://Stackoverflow.com/users/27870", "pm_score": 2, "selected": false, "text": "<p>poplib and smtplib will be your friends when developing your app.</p>\n" }, { "answer_id": 348423, "author...
2008/12/08
[ "https://Stackoverflow.com/questions/348392", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2592/" ]
How can I receive and send email in python? A 'mail server' of sorts. I am looking into making an app that listens to see if it receives an email addressed to foo@bar.domain.com, and sends an email to the sender. Now, am I able to do this all in python, would it be best to use 3rd party libraries?
Here is a very simple example: ``` import smtplib server = 'mail.server.com' user = '' password = '' recipients = ['user@mail.com', 'other@mail.com'] sender = 'you@mail.com' message = 'Hello World' session = smtplib.SMTP(server) # if your SMTP server doesn't need authentications, # you don't need the following line...
348,408
<p>I'm a little new to the Java 5 annotations and I'm curious if either of these are possible:</p> <p>This annotation would generate a simple getter and setter for you.</p> <pre><code>@attribute private String var = ""; </code></pre> <p>The <code>@NotNull</code> annotation indicates that a variable connot be null so...
[ { "answer_id": 348468, "author": "McDowell", "author_id": 304, "author_profile": "https://Stackoverflow.com/users/304", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>Is there a way to use annotations in\n Java to replace accesssors?</p>\n</blockquote>\n\n<p>In short, no,...
2008/12/08
[ "https://Stackoverflow.com/questions/348408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42994/" ]
I'm a little new to the Java 5 annotations and I'm curious if either of these are possible: This annotation would generate a simple getter and setter for you. ``` @attribute private String var = ""; ``` The `@NotNull` annotation indicates that a variable connot be null so you don't have to write that boilerplate co...
Annotation processing occurs on the abstract syntax tree. This is a structure that the parser creates and the compiler manipulates. The current specification (link to come) says that annotation processors cannot alter the abstract syntax tree. One of the consequences of this is that it is not suitable to do code gener...
348,410
<p>Is it possible in PHP to do something like this? How would you go about writing a function? Here is an example. The order is the most important thing.</p> <pre><code>$customer['address'] = '123 fake st'; $customer['name'] = 'Tim'; $customer['dob'] = '12/08/1986'; $customer['dontSortMe'] = 'this value doesnt need to...
[ { "answer_id": 348418, "author": "Eran Galperin", "author_id": 10585, "author_profile": "https://Stackoverflow.com/users/10585", "pm_score": 7, "selected": false, "text": "<p>There you go:</p>\n\n<pre><code>function sortArrayByArray(array $array, array $orderArray) {\n $ordered = arra...
2008/12/08
[ "https://Stackoverflow.com/questions/348410", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31671/" ]
Is it possible in PHP to do something like this? How would you go about writing a function? Here is an example. The order is the most important thing. ``` $customer['address'] = '123 fake st'; $customer['name'] = 'Tim'; $customer['dob'] = '12/08/1986'; $customer['dontSortMe'] = 'this value doesnt need to be sorted'; ...
Just use [`array_merge`](https://www.php.net/manual/en/function.array-merge.php) or [`array_replace`](https://www.php.net/manual/en/function.array-replace.php). `array_merge` works by starting with the array you give it (in the proper order) and overwriting/adding the keys with data from your actual array: ``` $custom...
348,417
<p>Some time ago I wrote a piece of code to update multiple rows in a database table. The code was like this</p> <pre><code>var db = new MyDataContext(); db.Execute("UPDATE Details SET IsActive = 0 WHERE MasterId = 1"); </code></pre> <p>Then the other day when I got the latest version of the file I saw that somebody ...
[ { "answer_id": 348426, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "<p>I'd say it depends on whether efficiency or abstraction from the database is more important to you. The SQL way is ...
2008/12/08
[ "https://Stackoverflow.com/questions/348417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24293/" ]
Some time ago I wrote a piece of code to update multiple rows in a database table. The code was like this ``` var db = new MyDataContext(); db.Execute("UPDATE Details SET IsActive = 0 WHERE MasterId = 1"); ``` Then the other day when I got the latest version of the file I saw that somebody changed the code to someth...
Check the approach used in this article: * [Batch Updates and Deletes with LINQ to SQL](https://terryaney.wordpress.com/2008/04/14/batch-updates-and-deletes-with-linq-to-sql/)
348,419
<p>I have a sorted list that contains the column headers, how do I rearrange my datagridview so it is in the same order as my sorted list?</p> <p>I've tried the code below but this doesn't always work, some columns are not sorted correctly. Thanks for any help with this.</p> <pre><code>sortedColumnNames.Sort(); ...
[ { "answer_id": 348470, "author": "BFree", "author_id": 15861, "author_profile": "https://Stackoverflow.com/users/15861", "pm_score": 0, "selected": false, "text": "<p>Seems like that should work. I just wrote a quick app to test and it worked fine. Can you nail down exactly when it's wor...
2008/12/08
[ "https://Stackoverflow.com/questions/348419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a sorted list that contains the column headers, how do I rearrange my datagridview so it is in the same order as my sorted list? I've tried the code below but this doesn't always work, some columns are not sorted correctly. Thanks for any help with this. ``` sortedColumnNames.Sort(); foreach (DataGridView...
I can't tell if your problem is that `SortedColumnNames` isn't sorted properly (which it's not), or if the columns are being assigned a different order than what appears in the list. If it's the latter, it could *conceivably* be because you're modifying the order of items in the collection as you're iterating over it....
348,421
<p>I am having problems running my Junit tests via Ant. I can't seem to get Ant to see the properties file it needs to load a dll my project needs. All my tests work using the Junit GUI in Elcipse, so I'm pretty sure it's not a problem with the tests themselves. I think my problem is something classpath-related, but...
[ { "answer_id": 349029, "author": "Staale", "author_id": 3355, "author_profile": "https://Stackoverflow.com/users/3355", "pm_score": 2, "selected": false, "text": "<p>Try and use getResource to see which URL is returned in eclipse, and also see if you can get a url to show in the unit tes...
2008/12/08
[ "https://Stackoverflow.com/questions/348421", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am having problems running my Junit tests via Ant. I can't seem to get Ant to see the properties file it needs to load a dll my project needs. All my tests work using the Junit GUI in Elcipse, so I'm pretty sure it's not a problem with the tests themselves. I think my problem is something classpath-related, but I can...
Try and use getResource to see which URL is returned in eclipse, and also see if you can get a url to show in the unit test. Maybe you need to pass the name of the actual class file to get that ``` clazz.getResource(clazz.getName()+".class") ``` Check that files are copied before you run unit test, so the files are ...
348,440
<p>Is there an easy way to move around controls on a form exactly the same way as the tab key? This includes moving around cells on a datagridview etc.</p>
[ { "answer_id": 348492, "author": "Marioh", "author_id": 24293, "author_profile": "https://Stackoverflow.com/users/24293", "pm_score": 3, "selected": true, "text": "<p>using winforms you should set the Form KeyPreview property to true</p>\n\n<p>and in the keypress event for the form you s...
2008/12/08
[ "https://Stackoverflow.com/questions/348440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29823/" ]
Is there an easy way to move around controls on a form exactly the same way as the tab key? This includes moving around cells on a datagridview etc.
using winforms you should set the Form KeyPreview property to true and in the keypress event for the form you should have ``` private void Form1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) GetNextControl(ActiveControl, true).Focus(); } ```
348,465
<p>I have the following code that I need to run over a matrix with over 20000 rows. It takes several minutes to run and the datenum and str2double functions appear to be the bottlenecks. Since no calculation depends on previous ones is there a way to break the loop into multiple parts and have them execute in parallel?...
[ { "answer_id": 471420, "author": "Jason S", "author_id": 44330, "author_profile": "https://Stackoverflow.com/users/44330", "pm_score": 2, "selected": true, "text": "<p>Hmm. I'm more of a MATLAB person than Octave but maybe I can help (if you are still looking for a solution) </p>\n\n<p>T...
2008/12/08
[ "https://Stackoverflow.com/questions/348465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14744/" ]
I have the following code that I need to run over a matrix with over 20000 rows. It takes several minutes to run and the datenum and str2double functions appear to be the bottlenecks. Since no calculation depends on previous ones is there a way to break the loop into multiple parts and have them execute in parallel? An...
Hmm. I'm more of a MATLAB person than Octave but maybe I can help (if you are still looking for a solution) This looks like the I'm-reading-in-a-file-but-I-need-to-do-something-different-than-the-tool-provides problem (otherwise you could get away with dlmread which should be pretty fast). If there were no alternati...
348,491
<p>I have a code igniter project, and I wanted to try debugging it using Zend Studio. WHen I start debugging, I immediately run ino</p> <p>"The URI you submitted has disallowed characters."</p> <p>Does anyone have any idea?</p>
[ { "answer_id": 348548, "author": "Cody Caughlan", "author_id": 25398, "author_profile": "https://Stackoverflow.com/users/25398", "pm_score": 5, "selected": false, "text": "<p>(Assuming you are using the latest version of CodeIgniter (CI) which is 1.7.0)</p>\n\n<p>CI is pretty strict abou...
2008/12/08
[ "https://Stackoverflow.com/questions/348491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a code igniter project, and I wanted to try debugging it using Zend Studio. WHen I start debugging, I immediately run ino "The URI you submitted has disallowed characters." Does anyone have any idea?
(Assuming you are using the latest version of CodeIgniter (CI) which is 1.7.0) CI is pretty strict about what characters it allows in URLs. You can modify the regex that is used to filter URLs. In system/config/config.php on line 126 is ``` $config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-'; ``` The comment above ...
348,502
<p>I have created an application that writes some data to the root folder of the directory in which it was installed (in Program Files). But under Windows Vista, the program is unable to write to the directory because the UAC restricts administrative privileges.</p> <p>I need to be able to do the following</p> <ol> <...
[ { "answer_id": 348510, "author": "JoelFan", "author_id": 16012, "author_profile": "https://Stackoverflow.com/users/16012", "pm_score": 0, "selected": false, "text": "<p>Your best bet is to not write any files under \"Program Files\". Whatever you're trying to write there is better writt...
2008/12/08
[ "https://Stackoverflow.com/questions/348502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33052/" ]
I have created an application that writes some data to the root folder of the directory in which it was installed (in Program Files). But under Windows Vista, the program is unable to write to the directory because the UAC restricts administrative privileges. I need to be able to do the following 1. Write a file in t...
It sounds like the title of your question asks how to make the installer run with administrative privileges but your explanation asks how to make the program run with administrative privileges so it can write to Program Files at runtime. Which one is it? If you really just want the installer to run with administrative...
348,530
<p>I have an asp:DropDownList on a page that, due to the 1024x768 development standard can truncate some of the text values in the dropdown (not enough of them, apparently, to redesign the layout ), so I need to display a tooltip of the selected value <em>when</em> a dropdown item is being selected (i.e. when the dropd...
[ { "answer_id": 348668, "author": "BenAlabaster", "author_id": 40650, "author_profile": "https://Stackoverflow.com/users/40650", "pm_score": 0, "selected": false, "text": "<p>Add the \"Title\" attribute to your list items with your tooltip info in there. It's not an existing item in the ...
2008/12/08
[ "https://Stackoverflow.com/questions/348530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5302/" ]
I have an asp:DropDownList on a page that, due to the 1024x768 development standard can truncate some of the text values in the dropdown (not enough of them, apparently, to redesign the layout ), so I need to display a tooltip of the selected value *when* a dropdown item is being selected (i.e. when the dropdown is sho...
``` foreach (ListItem _listItem in this.DropDownList1.Items) { _listItem.Attributes.Add("title", _listItem.Text); } ``` // add a tooltip for the selected item also ``` DropDownList1.Attributes.Add("onmouseover", this.title=this.options[this.selectedIndex].title"); ```
348,562
<p>I have a messy function that needs refactoring, it has too many nested IF's and it makes me nervous just to look at it!</p> <p><b>Please ignore what the functions are doing, I'm more concerned with the structure/flow and how it can be refactored so it has less nested IF statements</b></p> <p>The basic flow is as f...
[ { "answer_id": 348575, "author": "Andrew Kennan", "author_id": 22506, "author_profile": "https://Stackoverflow.com/users/22506", "pm_score": 3, "selected": false, "text": "<p>I would be tempted to go as far as:</p>\n\n<pre><code> private static bool CanMoveToSafeFolder(string filename...
2008/12/08
[ "https://Stackoverflow.com/questions/348562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a messy function that needs refactoring, it has too many nested IF's and it makes me nervous just to look at it! **Please ignore what the functions are doing, I'm more concerned with the structure/flow and how it can be refactored so it has less nested IF statements** The basic flow is as follows: ``` public ...
I would be tempted to go as far as: ``` private static bool CanMoveToSafeFolder(string filename) { return IsValidFileFormat(filename) && GetFolderIDFromFilename(filename) > 0 && HasNoViruses(filename) && VerifyFileSize(filename); } public static void HandleU...
348,606
<p>As you can see below, in the constructor I'm instantiating a validation object so I can validate a user's email in a set method. Is this architecture best practice or flawed? Can I avoid making my User class directly dependent on my Validation class?</p> <pre><code>Class User { Private Email //constructor User()...
[ { "answer_id": 348613, "author": "Tim Lesher", "author_id": 14942, "author_profile": "https://Stackoverflow.com/users/14942", "pm_score": 1, "selected": false, "text": "<p>I would:</p>\n<ol>\n<li><p>Break the coupling to the concrete Validation object via dependency injection: define an...
2008/12/08
[ "https://Stackoverflow.com/questions/348606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/26180/" ]
As you can see below, in the constructor I'm instantiating a validation object so I can validate a user's email in a set method. Is this architecture best practice or flawed? Can I avoid making my User class directly dependent on my Validation class? ``` Class User { Private Email //constructor User() { Validatio...
The proposals so far all seem to be way overkill, especially with all the IOC and AOP stuff. 1. The `User` class needs an email address, so create an `EmailAddress` class and have the `User` class accept one via a property and/or its constructor. That validation can be as simple as whether the input `EmailAddress` ref...
348,630
<p>How do I connect to Gmail and determine which messages have attachments? I then want to download each attachment, printing out the Subject: and From: for each message as I process it.</p>
[ { "answer_id": 348649, "author": "Jeroen Landheer", "author_id": 44056, "author_profile": "https://Stackoverflow.com/users/44056", "pm_score": 3, "selected": false, "text": "<p>I'm not an expert on Perl, but what I do know is that GMail supports IMAP and POP3, 2 protocols that are comple...
2008/12/08
[ "https://Stackoverflow.com/questions/348630", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
How do I connect to Gmail and determine which messages have attachments? I then want to download each attachment, printing out the Subject: and From: for each message as I process it.
Hard one :-) ``` import email, getpass, imaplib, os detach_dir = '.' # directory where to save attachments (default: current) user = raw_input("Enter your GMail username:") pwd = getpass.getpass("Enter your password: ") # connecting to the gmail imap server m = imaplib.IMAP4_SSL("imap.gmail.com") m.login(user,pwd) m...
348,646
<p>I have 4 <code>&lt;select&gt;&lt;/select&gt;</code> elements in my form. Usually when submitting the form you would get this in the url, e.g.</p> <pre><code>index.html?day=01&amp;month=01&amp;year=1999&amp;reporter=Joe+Blogs </code></pre> <p>However in my interface users are switching between the date picker and t...
[ { "answer_id": 348648, "author": "Daniel", "author_id": 43465, "author_profile": "https://Stackoverflow.com/users/43465", "pm_score": 1, "selected": false, "text": "<p>Use the .attr(\"disabled\",\"disabled\") in jQuery.</p>\n" }, { "answer_id": 348869, "author": "kender", ...
2008/12/08
[ "https://Stackoverflow.com/questions/348646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43465/" ]
I have 4 `<select></select>` elements in my form. Usually when submitting the form you would get this in the url, e.g. ``` index.html?day=01&month=01&year=1999&reporter=Joe+Blogs ``` However in my interface users are switching between the date picker and the person picker. Is it possible to only send the values on t...
Why you disable this in javascript though? You should make a server-side decision anyway, what if server gets the both person and date parameters (e.g. someone who has javascript disabled or just jquery blocked...)
348,657
<p>I have a string from which I wish to extract a single word, but with a numerical appended to it, which might be different in each line:</p> <pre><code>This is string1 this is string This is string11 This is string6 and it is in this line </code></pre> <p>I want to parse this file and get the values of &quot;stringX...
[ { "answer_id": 348670, "author": "Nathan Fellman", "author_id": 1084, "author_profile": "https://Stackoverflow.com/users/1084", "pm_score": 5, "selected": true, "text": "<p>you need to capture it:</p>\n\n<pre><code>while ($pattern =~/(string(100|\\d{1,2}))/g) {\n print $1;\n}\n</code>...
2008/12/08
[ "https://Stackoverflow.com/questions/348657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35416/" ]
I have a string from which I wish to extract a single word, but with a numerical appended to it, which might be different in each line: ``` This is string1 this is string This is string11 This is string6 and it is in this line ``` I want to parse this file and get the values of "stringXXX", starting from 0 to 100 ...
you need to capture it: ``` while ($pattern =~/(string(100|\d{1,2}))/g) { print $1; } ``` Explanation: * the parentheses capture what's in them into $1. If you have more than one set of parens, the 1st captures into $1, the 2nd into $2 etc. In this case $2 will have the actual number. * \d{1,2} captures between...
348,680
<p>I am working with a wrapper class for <code>CFHTTPMessage</code>, which contains a <code>CFHTTPMessageRef</code> object to which is added the method (GET), the URL of the web application server, and a few custom headers containing the date and an authentication nonce.</p> <p>I'm having some problems getting the met...
[ { "answer_id": 351170, "author": "Matt Gallagher", "author_id": 36103, "author_profile": "https://Stackoverflow.com/users/36103", "pm_score": 0, "selected": false, "text": "<p>The only reason why you should be getting an EXC_BAD_ACCESS when accessing the bytes is if the messageData is NU...
2008/12/08
[ "https://Stackoverflow.com/questions/348680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19410/" ]
I am working with a wrapper class for `CFHTTPMessage`, which contains a `CFHTTPMessageRef` object to which is added the method (GET), the URL of the web application server, and a few custom headers containing the date and an authentication nonce. I'm having some problems getting the method and URL to return certain da...
The following worked well: ``` NSData *d = (NSData *)CFHTTPMessageCopySerializedMessage(messageRef); NSLog(@"%@",[[[NSString alloc] initWithBytes:[d bytes] length:[d length] encoding:NSUTF8StringEncoding] autorelease]); ``` Hope this is helpful to others.
348,684
<p>I've got an NSBrowser hooked up to an NSTreeController bound to an array of NSTreeNode objects. It's easy enough to get the text portion working by setting the Content and Content Value bindings to properly reference the tree controller, but how do I set the image for each cell using bindings?</p>
[ { "answer_id": 351170, "author": "Matt Gallagher", "author_id": 36103, "author_profile": "https://Stackoverflow.com/users/36103", "pm_score": 0, "selected": false, "text": "<p>The only reason why you should be getting an EXC_BAD_ACCESS when accessing the bytes is if the messageData is NU...
2008/12/08
[ "https://Stackoverflow.com/questions/348684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
I've got an NSBrowser hooked up to an NSTreeController bound to an array of NSTreeNode objects. It's easy enough to get the text portion working by setting the Content and Content Value bindings to properly reference the tree controller, but how do I set the image for each cell using bindings?
The following worked well: ``` NSData *d = (NSData *)CFHTTPMessageCopySerializedMessage(messageRef); NSLog(@"%@",[[[NSString alloc] initWithBytes:[d bytes] length:[d length] encoding:NSUTF8StringEncoding] autorelease]); ``` Hope this is helpful to others.
348,689
<p>I'm doing some simple tests (in preparation for a larger project) to call an ASP.NET WebMethod using JQuery AJAX. In my example, my WebMethod returns a simple string. However, when I attempt to call it using JQuery, I get the entire HTML page content returned instead of just my string. What am I missing?</p> <p>Cli...
[ { "answer_id": 348726, "author": "rajesh pillai", "author_id": 34644, "author_profile": "https://Stackoverflow.com/users/34644", "pm_score": 2, "selected": false, "text": "<p>Try changing the last parameter \"html\" to \"text\". This parameter specifies the type of data to be returned.<...
2008/12/08
[ "https://Stackoverflow.com/questions/348689", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44197/" ]
I'm doing some simple tests (in preparation for a larger project) to call an ASP.NET WebMethod using JQuery AJAX. In my example, my WebMethod returns a simple string. However, when I attempt to call it using JQuery, I get the entire HTML page content returned instead of just my string. What am I missing? Client Side :...
Check out this link. I used some of his other posts to calll WCF service with success. Be sure to check out the related articles: <http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/> Read through the article but its essentially: ``` $("#Result").click(function() { $.ajax({ ...
348,690
<p>How do I compare two dates in Lingo? To be specific, I want to know if today's date is after some fixed date. I know I can create the fixed date by using:</p> <pre><code>date("20090101") </code></pre> <p>and I can get the current date using:</p> <pre><code>_system.date() </code></pre> <p>but I can't seem to dire...
[ { "answer_id": 348712, "author": "Elie", "author_id": 23249, "author_profile": "https://Stackoverflow.com/users/23249", "pm_score": 0, "selected": false, "text": "<p>I ended up doing the following. Inelegant, but it works:</p>\n\n<pre><code> if (_system.date().char[1..2] &gt;= 01 and _s...
2008/12/08
[ "https://Stackoverflow.com/questions/348690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23249/" ]
How do I compare two dates in Lingo? To be specific, I want to know if today's date is after some fixed date. I know I can create the fixed date by using: ``` date("20090101") ``` and I can get the current date using: ``` _system.date() ``` but I can't seem to directly compare the two. Do I have to parse the \_sy...
Instead of \_system.date(), try \_movie.systemDate(), it will return a date object that you can safely compare with another one. if \_movie.systemDate() > date("20090101") then ``` --do something ``` end if regards
348,708
<p>Ok, what I'm trying to do is build a web app that allows students to visually organize their class calendar using drag and drop. but They have to be able to drag and drop to specific locations (when those classes are available), not just anywhere.</p> <p>This would be a 'fixed week' calendar. I was considering usin...
[ { "answer_id": 348874, "author": "Tuminoid", "author_id": 40657, "author_profile": "https://Stackoverflow.com/users/40657", "pm_score": 3, "selected": true, "text": "<p>How about using <a href=\"http://dojotoolkit.org/\" rel=\"nofollow noreferrer\">Dojo toolkit</a> to implement the heavy...
2008/12/08
[ "https://Stackoverflow.com/questions/348708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43510/" ]
Ok, what I'm trying to do is build a web app that allows students to visually organize their class calendar using drag and drop. but They have to be able to drag and drop to specific locations (when those classes are available), not just anywhere. This would be a 'fixed week' calendar. I was considering using a table,...
How about using [Dojo toolkit](http://dojotoolkit.org/) to implement the heavy lifting? They have a [class](http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/drag-and-drop) for it. From this [example documentation](http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/...
348,724
<p>I have a situation where I'm populating a gridview with a bound data source, and want two additional rows at the very bottom; one to show the sum of values in the columns and one to show the average of values in the columns. I can quite easily calculate these values by aggregating information taken from the rowData...
[ { "answer_id": 348762, "author": "Samiksha", "author_id": 29515, "author_profile": "https://Stackoverflow.com/users/29515", "pm_score": 2, "selected": false, "text": "<p>You can use the Footer just like you use Headers in gridview. Another solution is use a query in such way:</p>\n\n<p>q...
2008/12/08
[ "https://Stackoverflow.com/questions/348724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I have a situation where I'm populating a gridview with a bound data source, and want two additional rows at the very bottom; one to show the sum of values in the columns and one to show the average of values in the columns. I can quite easily calculate these values by aggregating information taken from the rowDataBoun...
You can use the Footer just like you use Headers in gridview. Another solution is use a query in such way: query 1 : your original query ``` UNION ``` query 2 : your query which contains sum (This applies only if you don't apply paging to your grid)
348,730
<p>What does the "class" part of a template statement do?</p> <p>Example:</p> <pre><code>template &lt;class T&gt; class Something { public: Something(const T &amp;something); } </code></pre> <p>And what else can go there? I usually only see "class".</p>
[ { "answer_id": 348740, "author": "AlfaZulu", "author_id": 44060, "author_profile": "https://Stackoverflow.com/users/44060", "pm_score": 4, "selected": true, "text": "<p>The <code>class</code> keyword means the same thing as the <code>typename</code> keyword for the most part. They both i...
2008/12/08
[ "https://Stackoverflow.com/questions/348730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43496/" ]
What does the "class" part of a template statement do? Example: ``` template <class T> class Something { public: Something(const T &something); } ``` And what else can go there? I usually only see "class".
The `class` keyword means the same thing as the `typename` keyword for the most part. They both indicates that T is a type. The only difference between the keywords `class` and `typename` is that `class` can be used to provide class template template arguments to a template, whereas `typename` can't. Consider: ``` te...
348,760
<p>What is the simplest way to get the machine's time zone as a positive or negative UTC offset, preferably using some time of shell command?</p>
[ { "answer_id": 348789, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>I figure that if worse comes to worse I can just send a request to an NTP server and take the difference of it and the curr...
2008/12/08
[ "https://Stackoverflow.com/questions/348760", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
What is the simplest way to get the machine's time zone as a positive or negative UTC offset, preferably using some time of shell command?
For all Unix-ish operating systems, when using the GNU date command: `date +%z` Example, for Eastern European Time (my timezone): ``` [moocha@helium ~]$ date +%z +0200 ```
348,763
<p>I have a template class like below.</p> <pre><code>template&lt;int S&gt; class A { private: char string[S]; public: A() { for(int i =0; i&lt;S; i++) { . . } } int MaxLength() { return S; } }; </code></pre> <p>If i instantiate the above class with different values of S, w...
[ { "answer_id": 348768, "author": "Jim Buck", "author_id": 2666, "author_profile": "https://Stackoverflow.com/users/2666", "pm_score": 1, "selected": false, "text": "<p>Wherever S is used, a separate version of that function will get compiled into your code for each different S you instan...
2008/12/08
[ "https://Stackoverflow.com/questions/348763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39615/" ]
I have a template class like below. ``` template<int S> class A { private: char string[S]; public: A() { for(int i =0; i<S; i++) { . . } } int MaxLength() { return S; } }; ``` If i instantiate the above class with different values of S, will the compiler create different i...
The template will be instantiated for each different values of S. If you move the method implementations to a different file, you'll need to #include that file. (Boost for instance uses the `.ipp` convention for such source files that need to be #included). If you want to minimise the amount of code that is generated...
348,792
<p>How do you tell if caps lock is on using JavaScript?</p> <p>One caveat though: I did google it and the best solution I could find was to attach an <code>onkeypress</code> event to every input, then check each time if the letter pressed was uppercase, and if it was, then check if shift was also held down. If it wasn...
[ { "answer_id": 348802, "author": "rajesh pillai", "author_id": 34644, "author_profile": "https://Stackoverflow.com/users/34644", "pm_score": 8, "selected": true, "text": "<p>You can give it a try.. Added a working example. When focus is on input, turning on caps lock makes the led go r...
2008/12/08
[ "https://Stackoverflow.com/questions/348792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9021/" ]
How do you tell if caps lock is on using JavaScript? One caveat though: I did google it and the best solution I could find was to attach an `onkeypress` event to every input, then check each time if the letter pressed was uppercase, and if it was, then check if shift was also held down. If it wasn't, therefore caps lo...
You can give it a try.. Added a working example. When focus is on input, turning on caps lock makes the led go red otherwise green. (Haven't tested on mac/linux) NOTE: Both versions are working for me. Thanks for constructive inputs in the comments. OLD VERSION: <https://jsbin.com/mahenes/edit?js,output> Also, here ...
348,807
<p>I have defined a new dialog and its controls in an already existing resource file. I have also created a new file which will handle the events being generated from this dialog. But I am not sure how to connect these two. </p> <p>Is the statement <code>enum { IDD=IDD_NEW_DIALOG };</code> all that is required to conn...
[ { "answer_id": 348809, "author": "yesraaj", "author_id": 22076, "author_profile": "https://Stackoverflow.com/users/22076", "pm_score": 0, "selected": false, "text": "<p>Use class wizard to create a class for newly created dialog. ctrl+w is the shortcut key from UI resource view.</p>\n" ...
2008/12/08
[ "https://Stackoverflow.com/questions/348807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/41518/" ]
I have defined a new dialog and its controls in an already existing resource file. I have also created a new file which will handle the events being generated from this dialog. But I am not sure how to connect these two. Is the statement `enum { IDD=IDD_NEW_DIALOG };` all that is required to connect the two? Or shoul...
The way this is usually done in MFC is to define a dialog template in the resource editor (as you've done), then in C++ derive a class from CDialog and associate it with the dialog template (which it sounds like you've done - it's not entirely clear). What actually associates the two is the constructor for your CDialo...
348,821
<p>This question is coded in pseudo-PHP, but I really don't mind what language I get answers in (except for Ruby :-P), as this is purely hypothetical. In fact, PHP is quite possibly the worst language to be doing this type of logic in. Unfortunately, I have never done this before, so I can't provide a real-world exampl...
[ { "answer_id": 348829, "author": "eplawless", "author_id": 1370, "author_profile": "https://Stackoverflow.com/users/1370", "pm_score": 2, "selected": false, "text": "<p>The problem with PHP's \"associative arrays\" is that they aren't arrays at all, they're <a href=\"http://en.wikipedia....
2008/12/08
[ "https://Stackoverflow.com/questions/348821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10839/" ]
This question is coded in pseudo-PHP, but I really don't mind what language I get answers in (except for Ruby :-P), as this is purely hypothetical. In fact, PHP is quite possibly the worst language to be doing this type of logic in. Unfortunately, I have never done this before, so I can't provide a real-world example. ...
Some good answers to this question, which reflect on the relative experience on the answerers. Thank you very much — they proved very educational. I posted this question nearly three years ago. In hindsight, I can see my knowledge in that area was *severely* lacking. The biggest problem I had was that I was coming fro...
348,833
<p>If I generate an exception on my own, I can include any info into the exception: a number of code line and name of source file. Something like this:</p> <pre><code>throw std::exception("myFile.cpp:255"); </code></pre> <p>But what's with unhandled exceptions or with exceptions that were not generated by me?</p>
[ { "answer_id": 348840, "author": "Marcin Gil", "author_id": 5731, "author_profile": "https://Stackoverflow.com/users/5731", "pm_score": 1, "selected": false, "text": "<p>I think that a stack trace should get you to the point.</p>\n" }, { "answer_id": 348841, "author": "Johann...
2008/12/08
[ "https://Stackoverflow.com/questions/348833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44217/" ]
If I generate an exception on my own, I can include any info into the exception: a number of code line and name of source file. Something like this: ``` throw std::exception("myFile.cpp:255"); ``` But what's with unhandled exceptions or with exceptions that were not generated by me?
It seems everyone is trying to improve your code to throw exceptions in your code, and no one is attempting the actual question you asked. Which is because it can't be done. If the code that's throwing the exception is only presented in binary form (e.g. in a LIB or DLL file), then the line number is gone, and there's...
348,849
<p>I am writing a batch file, in which I call an EXE to execute. Now, statements after the call to the EXE should not execute till the EXE completes its execution. How can I do it in the batch file (on Windows)?</p>
[ { "answer_id": 348851, "author": "Dean Rather", "author_id": 14966, "author_profile": "https://Stackoverflow.com/users/14966", "pm_score": 0, "selected": false, "text": "<p>You can use</p>\n\n<pre><code>PAUSE\n</code></pre>\n\n<p>In batch scripting, but I don't understand your question.<...
2008/12/08
[ "https://Stackoverflow.com/questions/348849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I am writing a batch file, in which I call an EXE to execute. Now, statements after the call to the EXE should not execute till the EXE completes its execution. How can I do it in the batch file (on Windows)?
``` START /WAIT First.exe START /WAIT Second.exe ```
348,853
<p>Inspired by <a href="https://stackoverflow.com/questions/40845/how-do-f-units-of-measurement-work">Units of Measure in F#</a>, and despite asserting (<a href="https://stackoverflow.com/questions/39492/where-can-f-actually-save-time-and-money#71112">here</a>) that you couldn't do it in C#, I had an idea the other day...
[ { "answer_id": 348868, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 4, "selected": false, "text": "<p>Using separate classes for different units of the same measure (e.g., cm, mm, and ft for Length) seems kind of weird....
2008/12/08
[ "https://Stackoverflow.com/questions/348853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11410/" ]
Inspired by [Units of Measure in F#](https://stackoverflow.com/questions/40845/how-do-f-units-of-measurement-work), and despite asserting ([here](https://stackoverflow.com/questions/39492/where-can-f-actually-save-time-and-money#71112)) that you couldn't do it in C#, I had an idea the other day which I've been playing ...
You are missing dimensional analysis. For example (from the answer you linked to), in F# you can do this: ``` let g = 9.8<m/s^2> ``` and it will generate a new unit of acceleration, derived from meters and seconds (you can actually do the same thing in C++ using templates). In C#, it is possible to do dimensional a...
348,867
<p>can anyone think of a better way to do this?</p> <pre><code> [AcceptVerbs(HttpVerbs.Post)] public ActionResult SaveAction() { NameValueDeserializer value = new NameValueDeserializer(); // selected messages MemberMessageSaveAction[] messages = (MemberMessageSaveAction[])value.Dese...
[ { "answer_id": 348870, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 2, "selected": false, "text": "<p>The first step will be making different methods for each action.</p>\n\n<p>Next is to remove the negative logic. <...
2008/12/08
[ "https://Stackoverflow.com/questions/348867", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43380/" ]
can anyone think of a better way to do this? ``` [AcceptVerbs(HttpVerbs.Post)] public ActionResult SaveAction() { NameValueDeserializer value = new NameValueDeserializer(); // selected messages MemberMessageSaveAction[] messages = (MemberMessageSaveAction[])value.Deserialize(Reques...
I think you can also leverage the mvc framework for most of your code. Correct me if I'm wrong because I'm gonna make a few assumptions about your classes because I can't deduct it from your post. My assumptions: * Request.Form["action"] is a single value selectbox * Request.Form["value"] is a multy value selectbox...
348,880
<p>Is it possible to create an sql statement that selects the week number (NOT the day of week - or the day number in a week). I'm creating a view to select this extra information along with a couple of other fields and thus can not use a stored procedure. I'm aware that it's possible to create a UDF to do the trick, b...
[ { "answer_id": 348894, "author": "Gishu", "author_id": 1695, "author_profile": "https://Stackoverflow.com/users/1695", "pm_score": 2, "selected": false, "text": "<p>Looks like the <a href=\"http://doc.ddart.net/mssql/sql70/da-db_8.htm\" rel=\"nofollow noreferrer\">DATEPART mssql function...
2008/12/08
[ "https://Stackoverflow.com/questions/348880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11619/" ]
Is it possible to create an sql statement that selects the week number (NOT the day of week - or the day number in a week). I'm creating a view to select this extra information along with a couple of other fields and thus can not use a stored procedure. I'm aware that it's possible to create a UDF to do the trick, but ...
Be aware that there are differences in what is regarded the correct week number, depending on the culture. Week numbers depend on a couple of assumptions that differ from country to country, see [Wikipedia article on the matter](http://en.wikipedia.org/wiki/Week#Week_number). There is an [ISO standard](http://en.wikipe...
348,892
<p>I normally in my projects use such these code:</p> <pre><code>If user.IsInRole("Admin") Then deleteButton.Visible = True else deleteButton.Visible = False </code></pre> <p>But I want to control roles, which can see this button in database.</p> <p>For this purpose how should database design be?</p> <p>Than...
[ { "answer_id": 348901, "author": "Vilx-", "author_id": 41360, "author_profile": "https://Stackoverflow.com/users/41360", "pm_score": 1, "selected": false, "text": "<p>Make the design whatever you want to be, but in ASP.NET side implement your own MembershipProvider. This will translate y...
2008/12/08
[ "https://Stackoverflow.com/questions/348892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/439507/" ]
I normally in my projects use such these code: ``` If user.IsInRole("Admin") Then deleteButton.Visible = True else deleteButton.Visible = False ``` But I want to control roles, which can see this button in database. For this purpose how should database design be? Thanks.
Assuming you're using .NET, one way to do this is to implement your own Role and Membership Providers. Then, you could add functionality by implementing an interface that contained the items you wanted (I've just knocked this sample up off the top of my head, so I apologize if it seems a bit rough): ``` public interfa...
348,900
<p>There are a few questions on SO already regarding LINQ pivots and while a couple of them outline my exact problem, I can't successfully translate them to a working solution. I feel that this is mostly due to a join in my tables.</p> <p>So for the benefit of all the LINQ junkies out there who love a problem, here's...
[ { "answer_id": 348901, "author": "Vilx-", "author_id": 41360, "author_profile": "https://Stackoverflow.com/users/41360", "pm_score": 1, "selected": false, "text": "<p>Make the design whatever you want to be, but in ASP.NET side implement your own MembershipProvider. This will translate y...
2008/12/08
[ "https://Stackoverflow.com/questions/348900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15609/" ]
There are a few questions on SO already regarding LINQ pivots and while a couple of them outline my exact problem, I can't successfully translate them to a working solution. I feel that this is mostly due to a join in my tables. So for the benefit of all the LINQ junkies out there who love a problem, here's another pu...
Assuming you're using .NET, one way to do this is to implement your own Role and Membership Providers. Then, you could add functionality by implementing an interface that contained the items you wanted (I've just knocked this sample up off the top of my head, so I apologize if it seems a bit rough): ``` public interfa...
348,920
<p>I am new to php. I made a member registration on login page and adm too. So inside admin I wanted to get the list of the members and delete the members I dont want. So I took the a code from a sample code for phone book from <a href="http://localhost/xamp" rel="nofollow noreferrer">http://localhost/xamp</a> and edi...
[ { "answer_id": 348941, "author": "OIS", "author_id": 36175, "author_profile": "https://Stackoverflow.com/users/36175", "pm_score": 1, "selected": false, "text": "<ol>\n<li>This should be a POST via a FORM not a href link (GET).</li>\n<li>$TEXT is obviously an array holding the text you w...
2008/12/08
[ "https://Stackoverflow.com/questions/348920", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40975/" ]
I am new to php. I made a member registration on login page and adm too. So inside admin I wanted to get the list of the members and delete the members I dont want. So I took the a code from a sample code for phone book from <http://localhost/xamp> and editted it to my requirement I am able to retrieve the members but ...
1. This should be a POST via a FORM not a href link (GET). 2. $TEXT is obviously an array holding the text you want printed. 3. You need to replace `&amp;member_1d` in the href with a real & and a real i as `&member_id`.
348,928
<p>Parser Error Message: The entry 'SiteSqlServer' has already been added.</p> <p>Source Error:</p> <blockquote> <pre><code>Line 23: providerName="System.Data.SqlClient"/&gt; --&gt; Line 24: &lt; ! -- Connection String for SQL Server 2000/2005 --&gt; Line 25: &lt;add name="SiteSqlServer" connectionString="Server=(l...
[ { "answer_id": 348943, "author": "M4N", "author_id": 19635, "author_profile": "https://Stackoverflow.com/users/19635", "pm_score": 1, "selected": false, "text": "<p>It seems there are two connection strings named \"SiteSqlServer\" in your web.config file.\nCan you post the complete sect...
2008/12/08
[ "https://Stackoverflow.com/questions/348928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/29515/" ]
Parser Error Message: The entry 'SiteSqlServer' has already been added. Source Error: > > > ``` > Line 23: providerName="System.Data.SqlClient"/> --> > > Line 24: < ! -- Connection String for SQL Server 2000/2005 --> > > Line 25: <add name="SiteSqlServer" connectionString="Server=(local); > > ``` > > abase=Dot...
Here is the work around which i followed yesterday to solve my problem: If there is an application at the root of the site that already defines the 'SiteSqlServer' key, then that is why you are getting the error. You could try and change the connectionString section to look like this: ``` <connectionStrings> <remov...
348,953
<p>I am extending a template class using C++ in Visual Studio 2005. It is giving me an error when I try to extend the template base class with:</p> <pre><code>template &lt;class K, class D&gt; class RedBlackTreeOGL : public RedBlackTree&lt;K, D&gt;::RedBlackTree // Error 1 { public: RedBlackTreeOGL(); ~RedBlackT...
[ { "answer_id": 348955, "author": "Sandeep Datta", "author_id": 39648, "author_profile": "https://Stackoverflow.com/users/39648", "pm_score": 1, "selected": false, "text": "<p>Does <code>RedBlackTree&lt;K, D&gt;::RedBlackTree</code> have a default constructor? C++ doesnt define a default ...
2008/12/08
[ "https://Stackoverflow.com/questions/348953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40002/" ]
I am extending a template class using C++ in Visual Studio 2005. It is giving me an error when I try to extend the template base class with: ``` template <class K, class D> class RedBlackTreeOGL : public RedBlackTree<K, D>::RedBlackTree // Error 1 { public: RedBlackTreeOGL(); ~RedBlackTreeOGL(); ``` and a seco...
The code is trying to inherit a constructor, not a class :-) The start of the class declaration should be ``` template <class K, class D> class RedBlackTreeOGL : public RedBlackTree<K, D> ```