qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
238,004 | <p>I have an access database with 3 tables.</p>
<ul>
<li>People </li>
<li>Gifts</li>
<li>PeopleGifts</li>
</ul>
<p>Using VS 2008, what is the quickest way to get a page up and running which allows me to run queries against these tables and do basic inserts.</p>
<p>I want to have comboboxs bound to fields in the table so a user can click on a person and click on a gift and they click "Add".</p>
| [
{
"answer_id": 238033,
"author": "Tim Scott",
"author_id": 29493,
"author_profile": "https://Stackoverflow.com/users/29493",
"pm_score": 0,
"selected": false,
"text": "public interface IOleDbDataGateway\n{\n void ExecuteNonQuery(string sql, params object[] args);\n object ExecuteSc... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
238,008 | <p>For a simple linked list in which random access to list elements is not a requirement, are there any significant advantages (performance or otherwise) to using <code>std::list</code> instead of <code>std::vector</code>? If backwards traversal is required, would it be more efficient to use <code>std::slist</code> and <code>reverse()</code> the list prior to iterating over its elements?</p>
| [
{
"answer_id": 238023,
"author": "Motti",
"author_id": 3848,
"author_profile": "https://Stackoverflow.com/users/3848",
"pm_score": 7,
"selected": true,
"text": "vector"
}
] | 2008/10/26 | [
"https://Stackoverflow.com/questions/238008",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17035/"
] |
238,010 | <p>How is it done? What steps do I need to take and what pitfalls and gotchas are there to consider?</p>
| [
{
"answer_id": 238018,
"author": "Nils Pipenbrinck",
"author_id": 15955,
"author_profile": "https://Stackoverflow.com/users/15955",
"pm_score": 4,
"selected": false,
"text": "inline int saturate_to_255 (int a)\n{\n int y;\n asm (\"usat %0, #8, %1\\n\\t\" : \"=r\"(y) : \"r\"(a));\n ret... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8683/"
] |
238,013 | <p>I have an application running only on Windows and a batch file that launches it.
I want to invoke this batch file from Linux, meaning something like Linux batch will launch the windows batch with parameters and this in its turn run my application.</p>
<p>Can I do that? How?</p>
| [
{
"answer_id": 238021,
"author": "dsm",
"author_id": 7780,
"author_profile": "https://Stackoverflow.com/users/7780",
"pm_score": 5,
"selected": true,
"text": "ssh user@windows-box c:/path/to/batch.cmd\n"
}
] | 2008/10/26 | [
"https://Stackoverflow.com/questions/238013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9855/"
] |
238,036 | <p>I'm working on an app which scrapes data from a website and I was wondering how I should go about getting the data. Specifically I need data contained in a number of div tags which use a specific CSS class - Currently (for testing purposes) I'm just checking for </p>
<pre><code>div class = "classname"
</code></pre>
<p>in each line of HTML - This works, but I can't help but feel there is a better solution out there. </p>
<p>Is there any nice way where I could give a class a line of HTML and have some nice methods like:</p>
<pre><code>boolean usesClass(String CSSClassname);
String getText();
String getLink();
</code></pre>
| [
{
"answer_id": 238063,
"author": "dave",
"author_id": 14355,
"author_profile": "https://Stackoverflow.com/users/14355",
"pm_score": 3,
"selected": false,
"text": "Parser parser = new Parser(htmlInput);\nCssSelectorNodeFilter cssFilter = \n new CssSelectorNodeFilter(\"DIV.targetClassNa... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15075/"
] |
238,050 | <p>I am trying to issue a SQL update statement with nHibernate (2.0.1GA) like this:</p>
<pre><code>sqlstring = string.Format("set nocount on;update myusers set geo=geography::Point({0}, {1}, 4326) where userid={2};", mlat, mlong, userid);
_session.CreateSQLQuery(sqlstring).ExecuteUpdate();
</code></pre>
<p>However I receive the following error: 'geography@p0' is not a recognized built-in function name.</p>
<p>I thought CreateSQLQuery would just pass the SQL I gave it and execute it...guess not. Any ideas on how I can do that within the context of nHibernate?</p>
| [
{
"answer_id": 650451,
"author": "Chris Shaffer",
"author_id": 6744,
"author_profile": "https://Stackoverflow.com/users/6744",
"pm_score": 3,
"selected": true,
"text": "set nocount on;update myusers set geo=geography@p0({0}, {1}, 4326) where userid={2};\n"
},
{
"answer_id": 15247... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1975/"
] |
238,071 | <p>What is the simplest, fastest way to complete the PHP code below such that the output is in a user-friendly format (for example, "October 27, 2006")?</p>
<pre><code>$result = mysql_query("SELECT my_timestamp FROM some_table WHERE id=42", $DB_CONN);
$row = mysql_fetch_array($result);
$formatted_date = ???($row['my_timestamp']);
echo $formatted_date;
</code></pre>
| [
{
"answer_id": 238077,
"author": "Aron Rotteveel",
"author_id": 11568,
"author_profile": "https://Stackoverflow.com/users/11568",
"pm_score": 6,
"selected": true,
"text": "$result = mysql_query(\"SELECT DATE_FORMAT(my_timestamp, '%M %d, %Y) AS my_timestamp FROM some_table WHERE id=42\", ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2659/"
] |
238,073 | <p>When scripting in bash or any other shell in *NIX, while running a command that will take more than a few seconds, a progress bar is needed.</p>
<p>For example, copying a big file, opening a big tar file.</p>
<p>What ways do you recommend to add progress bars to shell scripts?</p>
| [
{
"answer_id": 238094,
"author": "Mitch Haile",
"author_id": 28807,
"author_profile": "https://Stackoverflow.com/users/28807",
"pm_score": 11,
"selected": true,
"text": "\\r"
},
{
"answer_id": 238140,
"author": "Diomidis Spinellis",
"author_id": 20520,
"author_profile... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13523/"
] |
238,081 | <p>So, when playing with the development I can just set <code>settings.DEBUG</code> to <code>True</code> and if an error occures I can see it nicely formatted, with good stack trace and request information.</p>
<p>But on kind of production site I'd rather use <code>DEBUG=False</code> and show visitors some standard error 500 page with information that I'm working on fixing this bug at this moment ;)<br>
At the same time I'd like to have some way of logging all those information (stack trace and request info) to a file on my server - so I can just output it to my console and watch errors scroll, email the log to me every hour or something like this.</p>
<p>What logging solutions would you recomend for a django-site, that would meet those simple requirements? I have the application running as <code>fcgi</code> server and I'm using apache web server as frontend (although thinking of going to lighttpd).</p>
| [
{
"answer_id": 238111,
"author": "James Bennett",
"author_id": 28070,
"author_profile": "https://Stackoverflow.com/users/28070",
"pm_score": 8,
"selected": true,
"text": "DEBUG = False"
},
{
"answer_id": 6395837,
"author": "EMP",
"author_id": 20336,
"author_profile": ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4172/"
] |
238,102 | <p>I want to do some pattern matching on lists in Python. For example, in Haskell, I can do something like the following:</p>
<pre><code>fun (head : rest) = ...
</code></pre>
<p>So when I pass in a list, <code>head</code> will be the first element, and <code>rest</code> will be the trailing elements.</p>
<p>Likewise, in Python, I can automatically unpack tuples:</p>
<pre><code>(var1, var2) = func_that_returns_a_tuple()
</code></pre>
<p>I want to do something similar with lists in Python. Right now, I have a function that returns a list, and a chunk of code that does the following:</p>
<pre><code>ls = my_func()
(head, rest) = (ls[0], ls[1:])
</code></pre>
<p>I wondered if I could somehow do that in one line in Python, instead of two.</p>
| [
{
"answer_id": 238124,
"author": "James Bennett",
"author_id": 28070,
"author_profile": "https://Stackoverflow.com/users/28070",
"pm_score": 7,
"selected": true,
"text": "split_list = lambda lst: (lst[0], lst[1:])\nhead, rest = split_list(my_func())\n"
},
{
"answer_id": 238126,
... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28804/"
] |
238,110 | <p>I am trying to get the signature on the method below to work. As this is an Anonymous Type I have some trouble, any help would be great.</p>
<p>When I looked at sortedGameList.ToList() in a QuickWatch window I get the signature </p>
<pre><code>System.Collections.Generic.List<<>f__AnonymousType0<System.DateTime,System.Linq.IGrouping<System.DateTime,DC.FootballLeague.Web.Models.Game>>>
</code></pre>
<p>Many Thanks</p>
<p>Donald</p>
<pre><code> public List<IGrouping<DateTime, Game>> getGamesList(int leagueID)
{
var sortedGameList =
from g in Games
group g by g.Date into s
select new { Date = s.Key, Games = s };
return sortedGameList.ToList();
}
</code></pre>
| [
{
"answer_id": 238127,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 3,
"selected": false,
"text": "public class GamesWithDate {\n public DateTime Date { get; set; }\n public List<Game> Games { get; set; }\n}\n"
... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17584/"
] |
238,173 | <p>Similar to <a href="https://stackoverflow.com/questions/233030/worst-php-practice-found-in-your-experience">this question</a>...</p>
<p>What are the worst practices you actually found in Java code?</p>
<p>Mine are:</p>
<ul>
<li>using instance variables in servlets (it's not just bad practice but bug, actually)</li>
<li>using Collection implementations like HashMap, and not using the appropriate interfaces</li>
<li>using seemingly cryptic class names like SmsMaker (SmsFactory) or CommEnvironment (CommunicationContext)</li>
</ul>
| [
{
"answer_id": 238189,
"author": "Claudiu",
"author_id": 15055,
"author_profile": "https://Stackoverflow.com/users/15055",
"pm_score": 4,
"selected": false,
"text": "if (expensiveFunction() > aVar)\n aVar = expensiveFunction();\nfor (int i=0; i < expensiveFunction(); ++i)\n System.... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/686/"
] |
238,178 | <p>I need the "Select Data Source" dialog added to my application so that the user can manually select a range (or ranges) in Excel and the range is pasted in my text box. This functionality is everywhere in Excel (most notably when selecting a range for a chart). How can I easily do this?</p>
| [
{
"answer_id": 238932,
"author": "dbb",
"author_id": 25675,
"author_profile": "https://Stackoverflow.com/users/25675",
"pm_score": 0,
"selected": false,
"text": "Dim myRange As Range\n On Error Resume Next\n Set myRange = Application.InputBox(prompt:=\"Select the cells you want\", Type... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16794/"
] |
238,183 | <p>Every time I do an <code>hg diff file.ext</code> I end up using a console diff application. I would like to use Kdiff3 or WinMerge (I'm using Windows).</p>
<p>Is there a way to change that? I can't find a reference in Mercurial documentation (<strong>I'm not talking about merge!</strong>). </p>
| [
{
"answer_id": 241018,
"author": "Tute",
"author_id": 4386,
"author_profile": "https://Stackoverflow.com/users/4386",
"pm_score": 7,
"selected": true,
"text": "[extensions]\nhgext.extdiff=\n\n[extdiff]\ncmd.vdiff = kdiff3\n"
},
{
"answer_id": 1445060,
"author": "Marcus Leon",... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4386/"
] |
238,184 | <p>My application uses measurement instruments that are connected to the PC. I want to make it possible to use similar instruments from different vendors. </p>
<p>So I defined an interface: </p>
<pre><code>interface IMeasurementInterface
{
void Initialize();
void Close();
}
</code></pre>
<p>So far so good. Before a measurement I need to setup the instrument and this means for different instruments very different parameters. So I want to define a method that takes parameters that can have different structures:</p>
<pre><code>interface IMeasurementInterface
{
void Initialize();
void Close();
void Setup(object Parameters);
}
</code></pre>
<p>I will then cast the object to whatever I need. Is this the way to go?</p>
| [
{
"answer_id": 238210,
"author": "Eoin Campbell",
"author_id": 30155,
"author_profile": "https://Stackoverflow.com/users/30155",
"pm_score": 4,
"selected": false,
"text": "public interface IMeasurement<PARAMTYPE> where PARAMTYPE : Parameters\n{\n void Init();\n void Close();\n v... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238184",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30507/"
] |
238,194 | <p>I use <a href="http://www.crockford.com/javascript/jsmin.html" rel="nofollow noreferrer">jsmin</a> to compress my javascript files before uploading them to production.</p>
<p>Since I tend to have one "code-behind" javascript file per page, I wind up doing this a lot.</p>
<p>I installed a Windows Powertoy that adds a context menu item in Windows Explorer, so I can "Open Command Window Here". When I click that, the command prompt opens up in the right directory. That saves a little bit of typing.</p>
<p>However, I still have to type something like:</p>
<pre><code>jsmin <script.js> script.min.js
</code></pre>
<p>To get it to work. This is a hassle.</p>
<p>I'd like to create a context menu item that will allow me to right-click on a *.js file and select "jsmin-compress this file." Then jsmin would be invoked, and the original file would be compressed into "original_filename.<b>min</b>.js"</p>
<p>How can I do this?</p>
| [
{
"answer_id": 238204,
"author": "Andrew Cox",
"author_id": 27907,
"author_profile": "https://Stackoverflow.com/users/27907",
"pm_score": 0,
"selected": false,
"text": "jsmin %1 script.min.js\n"
},
{
"answer_id": 238216,
"author": "Nescio",
"author_id": 14484,
"author... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28118/"
] |
238,196 | <p>I have an XML that needs to be databound to a <strong>WPF TreeView</strong>. Here the XML can have different structure. The TreeView should be databound generic enough to load any permutation of hierarchy. However an <strong>XAttribute</strong> on the nodes (called <strong>Title</strong>) should be databound to the TreeViewItem's <strong>header text</strong> and <strong>not the nodename</strong>.</p>
<p>XML to be bound:</p>
<pre><code><Wizard>
<Section Title="Home">
<Loop Title="Income Loop">
<Page Title="Employer Income"/>
<Page Title="Parttime Job Income"/>
<Page Title="Self employment Income"/>
</Loop>
</Section>
<Section Title="Deductions">
<Loop Title="Deductions Loop">
<Page Title="Travel spending"/>
<Page Title="Charity spending"/>
<Page Title="Dependents"/>
</Loop>
</Section>
</Wizard>
</code></pre>
<p>XAML:</p>
<pre><code><Window x:Class="Wpf.DataBinding.TreeViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Wpf.DataBinding"
Title="TreeViewer" Height="300" Width="300">
<Window.Resources>
<HierarchicalDataTemplate ItemsSource="{Binding Path=Elements}" x:Key="TVTemplate">
<TreeViewItem Header="{Binding Path=Name}"/>
</HierarchicalDataTemplate>
</Window.Resources>
<StackPanel>
<TreeView x:Name="_treeView" Style="{StaticResource TVallExpanded}"
ItemsSource="{Binding Path=Root.Elements}"
ItemTemplate="{StaticResource TVTemplate}" />
</StackPanel>
</Window>
</code></pre>
<p>XAML's codebehind that loads XML to XDocument and binds it to TreeView</p>
<pre><code>public partial class TreeViewer : Window
{
public TreeViewer()
{
InitializeComponent();
XDocument doc = XDocument.Parse(File.ReadAllText(@"C:\MyWizard.xml"));
_treeView.DataContext = doc;
}
}
</code></pre>
<p>So in the XAML markup we are binding Name to TreeViewItem's header.</p>
<pre><code><TreeViewItem Header="{Binding Path=Name}"/>
</code></pre>
<p>However, I want to bind it to <strong>Title</strong> attribute of Section, Loop and Page in the Xml above. I read that it's not possible to use XPath while binding XDocument. But there has to be a way to bind the <strong>Title</strong> attribute to TreeViewItem's Header text. I tried using @Title, .[@Title] etc. But none seemed to work.</p>
<p>This <a href="http://social.msdn.microsoft.com/forums/en-US/wpf/thread/edd843b7-b378-4c2d-926f-c053dbd7b340" rel="nofollow noreferrer">thread on MSDN Forums</a> has a similar discussion.</p>
<p>Any pointers would be greatly helpful.</p>
| [
{
"answer_id": 238253,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<XmlDataProvider\n x:Key=\"rxPartData\"\n XPath=\"RegexParts\">\n <x:XData>\n <RegexParts\n xmlns=\... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1747/"
] |
238,223 | <p>I'm matching identifiers, but now I have a problem: my identifiers are allowed to contain unicode characters. Therefore the old way to do things is not enough:</p>
<pre><code>t_IDENTIFIER = r"[A-Za-z](\\.|[A-Za-z_0-9])*"
</code></pre>
<p>In <a href="http://freehg.org/u/cheery/aml/" rel="nofollow noreferrer">my markup language</a> parser I match unicode characters by allowing all the characters except those I explicitly use, because my markup language only has two or three of characters I need to escape that way.</p>
<p>How do I match all unicode characters with python regexs and ply? Also is this a good idea at all?</p>
<p>I'd want to let people use identifiers like Ω » « ° foo² väli π as an identifiers (variable names and such) in their programs. Heck! I want that people could write programs in their own language if it's practical! Anyway unicode is supported nowadays in wide variety of places, and it should spread.</p>
<p>Edit: POSIX character classes doesnt seem to be recognised by python regexes.</p>
<pre><code>>>> import re
>>> item = re.compile(r'[[:word:]]')
>>> print item.match('e')
None
</code></pre>
<p>Edit: To explain better what I need. I'd need a regex -thing that matches all the unicode printable characters but not ASCII characters at all.</p>
<p>Edit: r"\w" does a bit stuff what I want, but it does not match « », and I also need a regex that does not match numbers.</p>
| [
{
"answer_id": 238293,
"author": "Cheery",
"author_id": 21711,
"author_profile": "https://Stackoverflow.com/users/21711",
"pm_score": 1,
"selected": false,
"text": "symbols = re.escape(''.join([chr(i) for i in xrange(33, 127) if not chr(i).isalnum()]))\nsymnums = re.escape(''.join([chr(i... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21711/"
] |
238,260 | <p>I have given a location defined by latitude and longitude.
Now i want to calculate a bounding box within e.g. 10 kilometers of that point.</p>
<p>The bounding box should be defined as latmin, lngmin and latmax, lngmax.</p>
<p>I need this stuff in order to use the <a href="http://www.panoramio.com/api/" rel="noreferrer">panoramio API</a>.</p>
<p>Does someone know the formula of how to get thos points?</p>
<p><strong>Edit:</strong> Guys i am looking for a formula/function which takes lat & lng as input and returns a bounding box as latmin & lngmin and latmax & latmin.
Mysql, php, c#, javascript is fine but also pseudocode should be okay.</p>
<p><strong>Edit:</strong> I am not looking for a solution which shows me the distance of 2 points</p>
| [
{
"answer_id": 238278,
"author": "jcoby",
"author_id": 2884,
"author_profile": "https://Stackoverflow.com/users/2884",
"pm_score": 3,
"selected": false,
"text": "location"
},
{
"answer_id": 238558,
"author": "Federico A. Ramponi",
"author_id": 18770,
"author_profile":... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21672/"
] |
238,267 | <p>I have seen various rules for naming stored procedures. </p>
<p>Some people prefix the sproc name with usp_, others with an abbreviation for the app name, and still others with an owner name. You shouldn't use sp_ in SQL Server unless you really mean it.</p>
<p>Some start the proc name with a verb (Get, Add, Save, Remove). Others emphasize the entity name(s).</p>
<p>On a database with hundreds of sprocs, it can be very hard to scroll around and find a suitable sproc when you think one already exists. Naming conventions can make locating a sproc easier.</p>
<p>Do you use a naming convention? Please describe it, and explain why you prefer it over other choices.</p>
<p><strong>Summary of replies:</strong> </p>
<ul>
<li>Everybody seems to advocate consistency of naming, that it might be more important for everyone to use the same naming convention than which particular one is used.</li>
<li>Prefixes: While a lot of folks use usp_ or something similar (but rarely sp_), many others use database or app name. One clever DBA uses gen, rpt and tsk to distinguish general CRUD sprocs from those used for reporting or tasks.</li>
<li>Verb + Noun seems to be slightly more popular than Noun + Verb. Some people use the SQL keywords (Select, Insert, Update, Delete) for the verbs, while others use non-SQL verbs (or abbreviations for them) like Get and Add. Some distinguish between singluar and plural nouns to indicate whether one or many records are being retrieved.</li>
<li>An additional phrase is suggested at the end, where appropriate. GetCustomerById, GetCustomerBySaleDate.</li>
<li>Some people use underscores between the name segments, and some avoid underscores. app_ Get_Customer vs. appGetCustomer -- I guess it's a matter of readability.</li>
<li>Large collections of sprocs can be segregated into Oracle packages or Management Studio (SQL Server) solutions and projects, or SQL Server schemas.</li>
<li>Inscrutable abbreviations should be avoided.</li>
</ul>
<p><strong>Why I choose the answer I did:</strong> There are SO many good responses. Thank you all! As you can see, it would be very hard to choose just one. The one I chose resonated with me. I have followed the same path he describes -- trying to use Verb + Noun and then not being able to find all of the sprocs that apply to Customer. </p>
<p>Being able to locate an existing sproc, or to determine if one even exists, is very important. Serious problems can arise if someone inadvertently creates a duplicate sproc with another name. </p>
<p>Since I generally work on very large apps with hundreds of sprocs, I have a preference for the easiest-to-find naming method. For a smaller app, I might advocate Verb + Noun, as it follows the general coding convention for method names.</p>
<p>He also advocates prefixing with app name instead of the not very useful usp_. As several people pointed out, sometimes the database contains sprocs for multiple apps. So, prefixing with app name helps to segregate the sprocs AND helps DBAs and others to determine which app the sproc is used for.</p>
| [
{
"answer_id": 238295,
"author": "driis",
"author_id": 13627,
"author_profile": "https://Stackoverflow.com/users/13627",
"pm_score": 1,
"selected": false,
"text": "shopGetCategories\nshopUpdateItem\n"
},
{
"answer_id": 238330,
"author": "ConcernedOfTunbridgeWells",
"autho... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27637/"
] |
238,284 | <p>I'm building an Android app and I want to copy the text value of an EditText widget. It's possible for the user to press <code>Menu+A</code> then <code>Menu+C</code> to copy the value, but how would I do this programmatically?</p>
| [
{
"answer_id": 238297,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 10,
"selected": true,
"text": "ClipboardManager#setPrimaryClip"
},
{
"answer_id": 7953397,
"author": "ayrina",
"author_id": 1017908,
"a... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9128/"
] |
238,314 | <p>Let's say I have the following ruby code :</p>
<pre><code>
def use_object(object)
puts object.some_method
end
</code></pre>
<p>and , this will work on any object that responds to <strong>some_method</strong>,right?</p>
<p>Assuming that the following java interface exists :</p>
<pre><code>
interface TestInterface {
public String some_method();
}
</code></pre>
<p>Am I right to presume that interfaces are java's way to achieving the same thing ( with the only difference that the parameter's type would be <strong>TestInterface</strong> ) ?</p>
| [
{
"answer_id": 238327,
"author": "Fabian Buch",
"author_id": 28968,
"author_profile": "https://Stackoverflow.com/users/28968",
"pm_score": 1,
"selected": false,
"text": "interface TestInterface {\n public String some_method();\n}\n"
}
] | 2008/10/26 | [
"https://Stackoverflow.com/questions/238314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31610/"
] |
238,317 | <p>I have a route</p>
<pre><code>// Sample URL: /Fixtures/Team/id
routes.MapRoute(
"Fixtures-by-TeamID",
"Fixtures/Team/{teamId}",
new { controller = "Fixtures", action = "GetByTeamID", },
new { teamId = @"\d{1,3}" }
);
</code></pre>
<p>and I am trying to use ActionLink in ASP.net MVC p5. </p>
<pre><code><%= Html.ActionLink(g.HomeTeam.TeamName, "Team", new { teamId = g.HomeTeam.TeamID })%>
</code></pre>
<p>However it is not working and giving me </p>
<pre><code><a href="/Fixtures/Team?teamId=118">Team A</a>
</code></pre>
<p>If I use Url.RouteUrl i get the correct link.</p>
<pre><code><a href="<%=Url.RouteUrl("Fixtures-by-TeamID", new { teamId = g.HomeTeam.TeamID })%>"><%=g.HomeTeam.TeamName%></a>
<a href="/Fixtures/Team/118">Team A</a>
</code></pre>
<p>Any help would be great? Will this change in ASP.net MVC beta?</p>
<p>Thanks</p>
<p>Donald</p>
| [
{
"answer_id": 238339,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": 1,
"selected": false,
"text": "<a href=\"<%= Url.FixturesByTeam(g.HomeTeam.TeamID) %>\"><%= g.HomeTeam.TeamName %></a>\n"
},
{
"answer_id": 238... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17584/"
] |
238,328 | <p>I am trying to figure out the best way to model a spreadsheet (from the database point of view), taking into account :</p>
<ul>
<li>The spreadsheet can contain a variable number of rows.</li>
<li>The spreadsheet can contain a variable number of columns.</li>
<li>Each column can contain one single value, but its type is unknown (integer, date, string).</li>
<li>It has to be easy (and performant) to generate a CSV file containing the data.</li>
</ul>
<p>I am thinking about something like :</p>
<pre><code>class Cell(models.Model):
column = models.ForeignKey(Column)
row_number = models.IntegerField()
value = models.CharField(max_length=100)
class Column(models.Model):
spreadsheet = models.ForeignKey(Spreadsheet)
name = models.CharField(max_length=100)
type = models.CharField(max_length=100)
class Spreadsheet(models.Model):
name = models.CharField(max_length=100)
creation_date = models.DateField()
</code></pre>
<p>Can you think about a better way to model a spreadsheet ? My approach allows to store the data as a String. I am worried about it being too slow to generate the CSV file.</p>
| [
{
"answer_id": 238397,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 2,
"selected": false,
"text": "Spreadsheet <-->> Cell : RowId, ColumnId, ValueType, Contents\n"
}
] | 2008/10/26 | [
"https://Stackoverflow.com/questions/238328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12388/"
] |
238,340 | <p>I have a C# collection of strings. Each string is a sentence that can appear on a page. I also have a collection of page breaks which is a collection of int's. representing the index where the collection of strings are split to a new page.</p>
<p>Example: Each 10 items in the string collection is a page so the collection of page breaks would be a collection of int's with the values of 10, 20, 30. ...</p>
<p>So if there are 2 pages of strings then there will be 1 item in the page break collection and if there is 1 page then the page break collection would have zero items.</p>
<p>I am trying to create the following function:</p>
<pre><code>List<string> GetPage(List<string> docList, List<int> pageBreakList, int pageNum)
{
// This function returns a subset of docList - just the page requested
}
</code></pre>
<p>I've taken a few stabs at writing this function and keep on coming up with complex if and switch statements to take into account single and two page documents and page numbers being requested outside the range (e.g. last page should be returned if page number is greater than number of pages and first page if page number is 0 or less).</p>
<p>My struggle with this problem leads me to ask the question: Is there a well known pattern or algorithm to address this type of subset query?</p>
| [
{
"answer_id": 238369,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "List<string> strings = ...\nint pageNum = ...\nint pageSze = ...\n\nif (pageNum < 1) pageNum = 1;\nif (pageSize < 1) pa... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] |
238,343 | <p>I am trying to place a big number in a C++ variable. The number is 600851475143</p>
<p>I tried unsigned long long int but got an error saying it the constant was too big.
I then tried a bigInt library called BigInt -> <a href="http://mattmccutchen.net/bigint/" rel="nofollow noreferrer">http://mattmccutchen.net/bigint/</a></p>
<p>The problem is I can't compile the code as I get many errors regarding the lib.</p>
<p>undefined reference to `BigInteger::BigInteger(int)' <-- lot's of these.</p>
<p>Here is my code so far:</p>
<pre><code>#include "string"
#include "iostream"
#include "bigint/NumberlikeArray.hh"
#include "bigint/BigUnsigned.hh"
#include "bigint/BigInteger.hh"
#include "bigint/BigIntegerAlgorithms.hh"
#include "bigint/BigUnsignedInABase.hh"
#include "bigint/BigIntegerUtils.hh"
using namespace std;
int main() {
//unsigned long int num = 13195;
//unsigned long long int num = 600851475143;
BigInteger num = 13195;
int divider = 2;
//num = 600851475143;
while (1) {
if ((num % divider) == 0) {
cout << divider << '\n';
num /= divider;
}
else
divider++;
if (num == 1)
break;
}
}
</code></pre>
<p>If I put a smaller number and don't use the BigInt lib this program runs fine.
Any help will be appreciated :D</p>
| [
{
"answer_id": 238345,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 6,
"selected": true,
"text": "#include <iostream>\n\nint main()\n{\n long long num = 600851475143LL;\n\n std::cout << num;\n}\n"
},
{
"... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8715/"
] |
238,349 | <p>Below is the code that i cannot get to work. I know i have established a connection to the database but this returns nothing. What am i doing wrong?</p>
<pre><code>$result = "SELECT * FROM images WHERE path = ?";
$params = array("blah");
$row = sqlsrv_query($conn, $result, $params);
$finished = sqlsrv_fetch_array($row);
if($finished)
{
echo "blach";
}
</code></pre>
| [
{
"answer_id": 238502,
"author": "Tom Haigh",
"author_id": 22224,
"author_profile": "https://Stackoverflow.com/users/22224",
"pm_score": 0,
"selected": false,
"text": "$result = \"SELECT * FROM images WHERE path = ?\";\n$params = array(\"blah\");\n$row = sqlsrv_query($conn, $result, $par... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238349",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
238,358 | <p>I'm trying to get authentication working to my liking in a CakePHP app and running into a snag. </p>
<p>I want to let the user login from either the home page or from a dedicated login page. I'm using the Auth component to manage login and right now the login itself works. I am submitting the form on the home page to /Users/Login and it does log them in and create session. The problem is it then redirects the user back to the home page. I'd rather they redirect to the location specified in loginRedirect. </p>
<p>If i login from /users/login directly it does forward to loginRedirect. I think the problem has something to do with posting the form from one page to another page instead of to itself, auth automatically thinks you want to go back to the previous page. </p>
<p>Any thoughts?</p>
| [
{
"answer_id": 374106,
"author": "nanoman",
"author_id": 46993,
"author_profile": "https://Stackoverflow.com/users/46993",
"pm_score": 0,
"selected": false,
"text": "$this->Session->del('Auth.redirect');\n"
},
{
"answer_id": 474358,
"author": "Community",
"author_id": -1,... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7018/"
] |
238,376 | <p>I am writing my own Joomla component (MVC), its based heavily on the newsflash module, because I want to display the latest 5 content items in a sliding tabbed interface, all the hard work is done, but I am having real difficult getting content out of the for loop.</p>
<p>Here is the code I have so far
default.php</p>
<pre><code><ul id="handles" class="tabs">
<?php for ($i = 0, $n = count($list); $i < $n; $i ++) :
modSankeSlideHelper::getTabs($list[$i]);
endfor; ?>
<li class="end"></li>
</ul>
</code></pre>
<p>helper.php</p>
<pre><code>function getTabs(&$item)
{
global $mainframe;
$item->created = $item->created;
list($year, $month, $day) = split("-", $item->created);
$tabdate = date('d\/m\/y', mktime(0, 0, 0, $month, $day, $year));
require(JModuleHelper::getLayoutPath('mod_sankeslide', '_tab'));
}
</code></pre>
<p>_tab.php</p>
<pre><code><li><a href="#tab"><span><?php echo 'Shout ' . $tabdate; ?></span><b></b></a></li>
</code></pre>
<p>The first item needs to have different value and a class item added to the a: item, so I need to be able to identify which is the first item and do something during that loop.</p>
<p>I tried to use if $i = 0 else statement in the default.php, but it resulted in a page timeout for some reason!</p>
<p>Any ideas?</p>
| [
{
"answer_id": 238389,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 3,
"selected": true,
"text": "if $i = 0"
},
{
"answer_id": 238753,
"author": "enobrev",
"author_id": 14651,
"author_profil... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28241/"
] |
238,379 | <p>How would I even go about forking a child process using Haskell in the first place?</p>
<p>Also, if pipes are an obvious solution to the data sharing question - is there any other way to do it besides using pipes? I'm familiar with the use of shared memory segments in C (the shmget, *shmat, shmdt and shmctl functions). Could Haskell be able to imitate this? If so, how?</p>
<p>I'd be very grateful for any help you could spare.</p>
<p>I must admit I'm very much new to functional programming languages, even more so when it comes to Haskell. So forgive me (and please correct me) if I said something silly.</p>
| [
{
"answer_id": 21931154,
"author": "Edward Z. Yang",
"author_id": 23845,
"author_profile": "https://Stackoverflow.com/users/23845",
"pm_score": 0,
"selected": false,
"text": "forkProcess"
}
] | 2008/10/26 | [
"https://Stackoverflow.com/questions/238379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
238,380 | <p>When there are one of more columns that reference another, I'm struggling for the best way to update that column while maintaining referential integrity. For example, if I have a table of labels and descriptions and two entries:</p>
<pre><code>Label | Description
------------------------------------
read | This item has been read
READ | You read this thing already
</code></pre>
<p>Now, I don't want these duplicates. I want to add a constraint to the column that doesn't allow values that are case-insensitively duplicates, as in the example. However, I have several rows of several other tables referencing 'READ', the one I want to drop.</p>
<p>I know Postgres knows which fields of other rows are referencing this, because I can't delete it as long as they are there. So, how could I get any field referencing this to update to 'read'? This is just an example, and I actually have a few places I want to do this. Another example is actually an int primary key for a few tables, where I want to add a new table as a sort of 'base table' that the existing ones extend and so they'll all need to have unique IDs now, which means updating the ones they have.</p>
<p>I am open to recipes for functions I can add to do this, tools I can utilize, or anything else.</p>
| [
{
"answer_id": 238390,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 2,
"selected": true,
"text": "select TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME,\nREFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME from \nINFORMATION_SCHEM... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19687/"
] |
238,413 | <p>I am trying to use Lambda Expressions in a project to map to a third party query API. So, I'm parsing the Expression tree by hand.</p>
<p>If I pass in a lambda expression like:</p>
<pre><code>p => p.Title == "title"
</code></pre>
<p>everything works.</p>
<p>However, if my lambda expression looks like:</p>
<pre><code>p => p.Title == myaspdropdown.SelectedValue
</code></pre>
<p>Using the .NET debugger, I don't see the actual value of that funciton. Instead I see something like:</p>
<pre><code>p => p.Title = (value(ASP.usercontrols_myaspusercontrol_ascx).myaspdropdown.SelectedValue)
</code></pre>
<p>What gives? And when I try to grab the right side of the expression as a string, I get <code>(value(ASP.usercontrols_myaspusercontrol_ascx).myaspdropdown.SelectedValue)</code> instead of the actual value. <strong>How do I get the actual value?</strong></p>
| [
{
"answer_id": 239359,
"author": "Bevan",
"author_id": 30280,
"author_profile": "https://Stackoverflow.com/users/30280",
"pm_score": 5,
"selected": true,
"text": "public class Class1\n{\n public string Selection { get; set; }\n\n public void Sample()\n {\n Selection = \"E... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49611/"
] |
238,430 | <p>I think I know the answer, but I would like to bounce around some ideas.</p>
<p>I would like to pass several (in this instance 2) somewhat different pieces of data to a View. My initial thought is simply to wrap-up the various objects into a containing object and pass them along that way. Then from the View, I'd have something like </p>
<pre><code>var objContainer = ViewData.Model;
var thisObject = objContainer.ThisObject;
var thatObject = objContainer.ThatObject;
</code></pre>
<p>and these could be used independently in the Master Page and View Page.</p>
<p>Is that the "best" way?</p>
| [
{
"answer_id": 238447,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "public class Duo<TFirst,TSecond> { /*...*/ }\npublic class Trio<TFirst,TSecond, TThird> { /*...*/ }\n"
},
{
"answer_id... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017/"
] |
238,437 | <p>In ASP.NET MVC, you can mark up a controller method with <code>AuthorizeAttribute</code>, like this:</p>
<pre><code>[Authorize(Roles = "CanDeleteTags")]
public void Delete(string tagName)
{
// ...
}
</code></pre>
<p>This means that, if the currently logged-in user is not in the "CanDeleteTags" role, the controller method will never be called.</p>
<p>Unfortunately, for failures, <code>AuthorizeAttribute</code> returns <code>HttpUnauthorizedResult</code>, which always returns HTTP status code 401. This causes a redirection to the login page.</p>
<p>If the user isn't logged in, this makes perfect sense. However, if the user is <em>already</em> logged in, but isn't in the required role, it's confusing to send them back to the login page.</p>
<p>It seems that <code>AuthorizeAttribute</code> conflates authentication and authorization.</p>
<p>This seems like a bit of an oversight in ASP.NET MVC, or am I missing something?</p>
<p>I've had to cook up a <code>DemandRoleAttribute</code> that separates the two. When the user isn't authenticated, it returns HTTP 401, sending them to the login page. When the user is logged in, but isn't in the required role, it creates a <code>NotAuthorizedResult</code> instead. Currently this redirects to an error page.</p>
<p>Surely I didn't have to do this?</p>
| [
{
"answer_id": 705485,
"author": "Alan Jackson",
"author_id": 72995,
"author_profile": "https://Stackoverflow.com/users/72995",
"pm_score": 5,
"selected": false,
"text": "// User was redirected here because of authorization section\nif (User.Identity != null && User.Identity.IsAuthentica... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8446/"
] |
238,441 | <p>I have worked on projects for embedded systems in the past where we have rearranged the order of declaration of stack variables to decrease the size of the resulting executable. For instance, if we had:</p>
<pre><code>void func()
{
char c;
int i;
short s;
...
}
</code></pre>
<p>We would reorder this to be:</p>
<pre><code>void func()
{
int i;
short s;
char c;
...
}
</code></pre>
<p>Because of alignment issues the first one resulted in 12 bytes of stack space being used and the second one resulted in only 8 bytes.</p>
<p>Is this standard behavior for C compilers or just a shortcoming of the compiler we were using? </p>
<p>It seems to me that a compiler should be able to reorder stack variables to favor smaller executable size if it wanted to. It has been suggested to me that some aspect of the C standard prevents this, but I haven't been able to find a reputable source either way.</p>
<p>As a bonus question, does this also apply to C++ compilers?</p>
<p><strong>Edit</strong></p>
<p>If the answer is yes, C/C++ compilers can rearrange stack variables, can you give an example of a compiler that definitely does this? I'd like to see compiler documentation or something similar that backs this up.</p>
<p><strong>Edit Again</strong></p>
<p>Thanks everybody for your help. For documentation, the best thing I've been able to find is the paper <a href="http://mirror-fpt-telecom.fpt.net/gcc/summit/2003/Optimal%20Stack%20Slot%20Assignment.pdf" rel="noreferrer">Optimal Stack Slot Assignment in GCC</a>(pdf), by Naveen Sharma and Sanjiv Kumar Gupta, which was presented at the GCC summit proceedings in 2003.</p>
<p>The project in question here was using the ADS compiler for ARM development. It is mentioned in the documentation for that compiler that ordering declarations like I've shown can improve performance, as well as stack size, because of how the ARM-Thumb architecture calculates addresses in the local stack frame. That compiler didn't automatically rearrange locals to take advantage of this. The paper linked here says that as of 2003 GCC also didn't rearrange the stack frame to improve locality of reference for ARM-Thumb processors, but it implies that you could.</p>
<p>I can't find anything that definitely says this was ever implemented in GCC, but I think this paper counts as proof that you're all correct. Thanks again.</p>
| [
{
"answer_id": 243740,
"author": "Malkocoglu",
"author_id": 31152,
"author_profile": "https://Stackoverflow.com/users/31152",
"pm_score": 0,
"selected": false,
"text": "#pragma pack(push, 16)\n\ntypedef struct _S_speedy_struct{\n\n double fval[4];\n int64 lval[4];\n int32 ival[8];\n\n}... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238441",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13728/"
] |
238,449 | <p>How do I configure SSRS/Windows Server 2003, so that I can setup email delivery via a remote SMTP server that requires username and password.</p>
<p>I can configure SSRS with an SMTP address and other parameters, but nowhere is it possible to configure it with smtp username and password. </p>
<p>I have hunted around, but can only find vague reference to setting up some sort of relay, to cover up the bizarre lack of smtp functionality that SSRS has out of the box. </p>
<p>Any ideas?</p>
| [
{
"answer_id": 511691,
"author": "Tom Willwerth",
"author_id": 3334,
"author_profile": "https://Stackoverflow.com/users/3334",
"pm_score": 3,
"selected": false,
"text": "<SMTPServer>x.x.x.x</SMTPServer>"
}
] | 2008/10/26 | [
"https://Stackoverflow.com/questions/238449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1982/"
] |
238,451 | <p>I'm trying to set up Eclipse for php web development. What I would like to do is preview a php web page from within Eclipse, but I cannot figure out how to do this. Is there an integrated web server of some sort that allows this, or do I have to set up IIS/Apache to do it? If so, do I have to have my php files in the web servers path, or does Eclipse auto deploy the files to the local web server? Any information or links would be very much appreciated.</p>
| [
{
"answer_id": 238593,
"author": "acrosman",
"author_id": 24215,
"author_profile": "https://Stackoverflow.com/users/24215",
"pm_score": 2,
"selected": false,
"text": "http://localhost/project_name/file.php\n"
}
] | 2008/10/26 | [
"https://Stackoverflow.com/questions/238451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3291/"
] |
238,452 | <p>I am familiar with C++ RTTI, and find the concept interesting.</p>
<p>Still there exist a lot of more ways to abuse it than to use it correctly (the RTTI-switch dread comes to mind). As a developer, I found (and used) only two viable uses for it (more exactly, one and a half).</p>
<p><strong>Could you share some of the ways RTTI is a viable solution to a problem, with example code/pseudo-code included?</strong></p>
<p>Note: The aim is to have a repository of viable examples a junior developer can consult, criticize and learn from.</p>
<p><strong>Edit:</strong> You'll find below code using C++ RTTI</p>
<pre><code>// A has a virtual destructor (i.e. is polymorphic)
// B has a virtual destructor (i.e. is polymorphic)
// B does (or does not ... pick your poison) inherits from A
void doSomething(A * a)
{
// typeid()::name() returns the "name" of the object (not portable)
std::cout << "a is [" << typeid(*a).name() << "]"<< std::endl ;
// the dynamic_cast of a pointer to another will return NULL is
// the conversion is not possible
if(B * b = dynamic_cast<B *>(a))
{
std::cout << "a is b" << std::endl ;
}
else
{
std::cout << "a is NOT b" << std::endl ;
}
}
</code></pre>
| [
{
"answer_id": 238509,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 3,
"selected": false,
"text": "this"
},
{
"answer_id": 238515,
"author": "KeyserSoze",
"author_id": 14116,
"author_profile": "... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14089/"
] |
238,460 | <p>When I use the default model binding to bind form parameters to a complex object which is a parameter to an action, the framework remembers the values passed to the first request, meaning that any subsequent request to that action gets the same data as the first. The parameter values and validation state are persisted between unrelated web requests.</p>
<p>Here is my controller code (<code>service</code> represents access to the back end of the app):</p>
<pre><code> [AcceptVerbs(HttpVerbs.Get)]
public ActionResult Create()
{
return View(RunTime.Default);
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(RunTime newRunTime)
{
if (ModelState.IsValid)
{
service.CreateNewRun(newRunTime);
TempData["Message"] = "New run created";
return RedirectToAction("index");
}
return View(newRunTime);
}
</code></pre>
<p>My .aspx view (strongly typed as <code>ViewPage<RunTime</code>>) contains directives like: </p>
<pre><code><%= Html.TextBox("newRunTime.Time", ViewData.Model.Time) %>
</code></pre>
<p>This uses the <code>DefaultModelBinder</code> class, which is <a href="http://weblogs.asp.net/scottgu/archive/2008/10/16/asp-net-mvc-beta-released.aspx#three" rel="nofollow noreferrer">meant to autobind my model's properties</a>.</p>
<p>I hit the page, enter valid data (e.g. time = 1). The app correctly saves the new object with time = 1. I then hit it again, enter different valid data (e.g. time = 2). However the data that gets saved is the original (e.g. time = 1). This also affects validation, so if my original data was invalid, then all data I enter in the future is considered invalid. Restarting IIS or rebuilding my code flushes the persisted state.</p>
<p>I can fix the problem by writing my own hard-coded model binder, a basic naive example of which is shown below. </p>
<pre><code> [AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create([ModelBinder(typeof (RunTimeBinder))] RunTime newRunTime)
{
if (ModelState.IsValid)
{
service.CreateNewRun(newRunTime);
TempData["Message"] = "New run created";
return RedirectToAction("index");
}
return View(newRunTime);
}
internal class RunTimeBinder : DefaultModelBinder
{
public override ModelBinderResult BindModel(ModelBindingContext bindingContext)
{
// Without this line, failed validation state persists between requests
bindingContext.ModelState.Clear();
double time = 0;
try
{
time = Convert.ToDouble(bindingContext.HttpContext.Request[bindingContext.ModelName + ".Time"]);
}
catch (FormatException)
{
bindingContext.ModelState.AddModelError(bindingContext.ModelName + ".Time", bindingContext.HttpContext.Request[bindingContext.ModelName + ".Time"] + "is not a valid number");
}
var model = new RunTime(time);
return new ModelBinderResult(model);
}
}
</code></pre>
<p>Am I missing something? I don't think it's a browser session problem as I can reproduce the problem if the first data is entered in one browser and the second in another.</p>
| [
{
"answer_id": 240829,
"author": "Eilon",
"author_id": 31668,
"author_profile": "https://Stackoverflow.com/users/31668",
"pm_score": 2,
"selected": false,
"text": "[AcceptVerbs(HttpVerbs.Get)]\npublic ActionResult Create() {\n return View(RunTime.Default);\n}\n\n[AcceptVerbs(HttpVerbs... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12006/"
] |
238,465 | <p>Back in the 90s when I first started out with MFC I used to dynamically link my apps and shipped the relevant MFC DLLs. This caused me a few issues (DLL hell!) and I switched to statically linking instead - not just for MFC, but for the CRT and ATL. Other than larger EXE files, statically linking has never caused me any problems at all - so are there any downsides that other people have come across? Is there a good reason for revisiting dynamic linking again? My apps are mainly STL/Boost nowadays FWIW.</p>
| [
{
"answer_id": 238493,
"author": "xtofl",
"author_id": 6610,
"author_profile": "https://Stackoverflow.com/users/6610",
"pm_score": 1,
"selected": false,
"text": "p = new LibClass()"
}
] | 2008/10/26 | [
"https://Stackoverflow.com/questions/238465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9236/"
] |
238,466 | <p>How do you access the items collection of a combo box in a specific row in a DataGridView?</p>
<p>I'm populating the combo as follows:</p>
<pre><code> Dim VATCombo As New DataGridViewComboBoxColumn
With VATCombo
.HeaderText = "VAT Rate"
.Name = .HeaderText
Dim VATCol As New JCVATRateCollection
VATCol.LoadAll(EntitySpaces.Interfaces.esSqlAccessType.StoredProcedure)
For Each Rate As JCVATRate In VATCol
.Items.Add(Rate.str.VATRate)
Next
.Sorted = True
VATCol = Nothing
.ToolTipText = "Select VAT Rate"
.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
.CellTemplate.Style.BackColor = Color.Honeydew
.DisplayIndex = 8
.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
End With
.Columns.Add(VATCombo)
VATCombo = Nothing
</code></pre>
<p>I want to be able to set a default value for each new line added to the grid, I also want to be able to change the values in the combo based on other business logic. I realise I can just set the cell value directly but I want to avoid hard-coding the values into the system and rely on the database to populate.</p>
<p>I'm sure it must be straight-forward but it's eluding me.....</p>
| [
{
"answer_id": 255989,
"author": "CestLaGalere",
"author_id": 6684,
"author_profile": "https://Stackoverflow.com/users/6684",
"pm_score": 2,
"selected": true,
"text": "Imports System.Collections.Generic\nImports System.Drawing\nImports System.Windows.Forms\n\nFriend Class ComboEditingCon... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20048/"
] |
238,473 | <p>I want to make a really simple iphone app: one screen with a single button... when the button is tapped a new screen appears. That's it. No animations, nothing,</p>
<p>I've tried endlessly to make the NavBar sample project do this... and it works but only if I use a UINavigationController with a table that I can tap etc. I've tried all the skeleton projects in XCode too.</p>
<p>I thought I was done when I did this:</p>
<pre><code>[[self navigationController] presentModalViewController:myViewController animated:YES];
</code></pre>
<p>But I couldn't do it without the UINavigationController. I just want a simple example.</p>
<p>Thanks so much!</p>
| [
{
"answer_id": 238477,
"author": "kdbdallas",
"author_id": 26728,
"author_profile": "https://Stackoverflow.com/users/26728",
"pm_score": 4,
"selected": true,
"text": "LoginView *login = [[LoginView alloc] initWithFrame: rect];\n[mainView addSubview: login];\n"
},
{
"answer_id": 2... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22471/"
] |
238,504 | <p>Is it possible to load child entities in a <strong><em>single</em></strong> query without using DataLoadOptions?</p>
<p>I am using one data context per request in an asp.net web application and trying to get around the linq to sql limitation of not being able to change dataloadoptions once a query has been executed.</p>
<p>Thanks.</p>
| [
{
"answer_id": 238696,
"author": "bh213",
"author_id": 28912,
"author_profile": "https://Stackoverflow.com/users/28912",
"pm_score": 0,
"selected": false,
"text": "from a in Albums join o in Users on a.Owner equals o select new {a, o}\n"
},
{
"answer_id": 238761,
"author": "... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24358/"
] |
238,517 | <p>I have intermittent crashes occurring in my ActiveMQ libraries due to the way I'm using the activemq-cpp API. It'd be much easier to debug the issue if I could observe every function being called leading up to the crash. Are there any quick ways to trace the entry and exit of functions in a Visual Studio 2005 c++ multithreaded program?</p>
<p>Thanks in advance!</p>
| [
{
"answer_id": 238522,
"author": "Dima",
"author_id": 13313,
"author_profile": "https://Stackoverflow.com/users/13313",
"pm_score": 3,
"selected": true,
"text": "\nclass Tracer\n{\npublic:\n Tracer(const char *functionName) : functionName_(functionName)\n {\n cout << \"Entering func... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238517",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191808/"
] |
238,523 | <p>If I want to move to C++ and SDL in the future, is Python and pygame a good way to learn SDL?</p>
| [
{
"answer_id": 239464,
"author": "ulukyn",
"author_id": 31748,
"author_profile": "https://Stackoverflow.com/users/31748",
"pm_score": 2,
"selected": false,
"text": "import pygame, sys,os\nfrom pygame.locals import * \n\npygame.init() \n\nwindow = pygame.display.set_mode((468, 60)) \npyga... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
238,525 | <p>I've been running the built-in <a href="http://ant.apache.org/" rel="nofollow noreferrer">Ant</a> from the command line on a Macintosh (10.5.5) and have run into some trouble with the <strong>Mail</strong> task. Running the Mail task produces the following message:</p>
<pre><code>[mail] Failed to initialise MIME mail: org.apache.tools.ant.taskdefs.email.MimeMailer
</code></pre>
<p>This is most likely due to a missing ant-javamail.jar file in the /usr/share/ant/lib directory. I see a "ant-javamail-1.7.0.pom" file in this directory but not the appropriate jar file. Anyone know why this jar file might be missing and what the best way to resolve the problem is?</p>
| [
{
"answer_id": 239516,
"author": "npellow",
"author_id": 2767300,
"author_profile": "https://Stackoverflow.com/users/2767300",
"pm_score": 1,
"selected": false,
"text": "ant -f fetch all\n"
},
{
"answer_id": 265270,
"author": "Ken",
"author_id": 31629,
"author_profile... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31629/"
] |
238,535 | <p>Is it more efficient for a class to access member variables or local variables? For example, suppose you have a (callback) method whose sole responsibility is to receive data, perform calculations on it, then pass it off to other classes. Performance-wise, would it make more sense to have a list of member variables that the method populates as it receives data? Or just declare local variables each time the callback method is called?</p>
<p>Assume this method would be called hundreds of times a second...</p>
<p>In case I'm not being clear, here's some quick examples:</p>
<pre><code>// use local variables
class thisClass {
public:
void callback( msg& msg )
{
int varA;
double varB;
std::string varC;
varA = msg.getInt();
varB = msg.getDouble();
varC = msg.getString();
// do a bunch of calculations
}
};
// use member variables
class thisClass {
public:
void callback( msg& msg )
{
m_varA = msg.getInt();
m_varB = msg.getDouble();
m_varC = msg.getString();
// do a bunch of calculations
}
private:
int m_varA;
double m_varB;
std::string m_varC;
};
</code></pre>
| [
{
"answer_id": 238568,
"author": "peterchen",
"author_id": 31317,
"author_profile": "https://Stackoverflow.com/users/31317",
"pm_score": 7,
"selected": true,
"text": "// stack variable: load into eax\nmov eax, [esp+10]\n\n// member variable: load into eax\nmov ecx, [adress of object]\nmo... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238535",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
238,537 | <p>I am new to Access. I have a table full of records. I want to write a function to check if any id is null or empty. If so, I want to update it with xxxxx.
The check for id must be run through all tables in a database.
Can anyone provide some sample code?</p>
| [
{
"answer_id": 238551,
"author": "Daren Thomas",
"author_id": 2260,
"author_profile": "https://Stackoverflow.com/users/2260",
"pm_score": 1,
"selected": false,
"text": "update TABLE set FIELD = 'xxxxxx' where ID is null\n"
},
{
"answer_id": 238709,
"author": "micahwittman",
... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
238,547 | <p>I would like to be able to fetch a web page's html and save it to a <code>String</code>, so I can do some processing on it. Also, how could I handle various types of compression.</p>
<p>How would I go about doing that using Java?</p>
| [
{
"answer_id": 238634,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 8,
"selected": true,
"text": "public static void main(String[] args) {\n URL url;\n InputStream is = null;\n BufferedReader br;\n Strin... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2598/"
] |
238,555 | <p>How do I get the value of a <code>MemberInfo</code> object? <code>.Name</code> returns the name of the variable, but I need the value. </p>
<p>I think you can do this with <code>FieldInfo</code> but I don't have a snippet, if you know how to do this can you provide a snippet??</p>
<p>Thanks!</p>
| [
{
"answer_id": 238562,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": false,
"text": "using System;\nusing System.Reflection;\n\npublic class Test\n{\n // public just for the sake of a short example.\n ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49611/"
] |
238,603 | <p>How can I find out the size of a file I opened with an application written in C ?
I would like to know the size, because I want to put the content of the loaded file into a string, which I allocate using <code>malloc()</code>. Just writing <code>malloc(10000*sizeof(char));</code> is IMHO a bad idea. </p>
| [
{
"answer_id": 238607,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 10,
"selected": true,
"text": "fseek(fp, 0L, SEEK_END);\nsz = ftell(fp);\n"
},
{
"answer_id": 238609,
"author": "Greg Hewgill",
"author_... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25017/"
] |
238,606 | <p>I'm trying to make a simple C# web server that, at this stage, you can access via your browser and will just do a "Hello World". </p>
<p>The problem I'm having is that the server can receive data fine - I get the browser's header information - but the browser doesn't receive anything I send. Furthermore, I can only connect to the server by going to localhost (or 127.0.0.1). I can't get to it by going to my IP and it's not a network setting because Apache works fine if I run that instead. Also, I'm using a port monitoring program and after I attempt a connection from a browser, the process's port gets stuck in a TIME_WAIT state even though I told the connection to close and it should be back to LISTEN.</p>
<p>Here's the relevant code. A couple calls might not make sense but this is a piece of a larger program.</p>
<pre><code>class ConnectionHandler
{
private Server server;
private TcpListener tcp;
private ArrayList connections;
private bool listening;
private Thread listeningThread;
public Server getServer()
{
return server;
}
private void log(String s, bool e)
{
server.log("Connection Manager: " + s, e);
}
private void threadedListen()
{
while (listening)
{
try
{
TcpClient t = tcp.AcceptTcpClient();
Connection conn = new Connection(this, t);
}
catch (NullReferenceException)
{
log("unable to accept connections!", true);
}
}
log("Stopped listening", false);
}
public void listen()
{
log("Listening for new connections", false);
tcp.Start();
listening = true;
if (listeningThread != null && listeningThread.IsAlive)
{
listeningThread.Abort();
}
listeningThread = new Thread(new ThreadStart(
this.threadedListen));
listeningThread.Start();
}
public void stop()
{
listening = false;
if (listeningThread != null)
{
listeningThread.Abort();
log("Forced stop", false);
}
log("Stopped listening", false);
}
public ConnectionHandler(Server server)
{
this.server = server;
tcp = new TcpListener(new IPEndPoint(
IPAddress.Parse("127.0.0.1"), 80));
connections = new ArrayList();
}
}
class Connection
{
private Socket socket;
private TcpClient tcp;
private ConnectionHandler ch;
public Connection(ConnectionHandler ch, TcpClient t)
{
try
{
this.ch = ch;
this.tcp = t;
ch.getServer().log("new tcp connection to "
+ this.tcp.Client.RemoteEndPoint.ToString(), false);
NetworkStream ns = t.GetStream();
String responseString;
Byte[] response;
Int32 bytes;
responseString = String.Empty;
response = new Byte[512];
bytes = ns.Read(response, 0, response.Length);
responseString =
System.Text.Encoding.ASCII.GetString(response, 0, bytes);
ch.getServer().log("Received: " + responseString);
String msg = "<html>Hello World</html>";
String fullMsg = "HTTP/1.x 200 OK\r\n"
+ "Server: Test Server\r\n"
+ "Content-Type: text/html; "
+ "charset=UTF-8\r\n"
+ "Content-Length: " + msg.Length + "\r\n"
+ "Date: Sun, 10 Aug 2008 22:59:59 GMT"
+ "\r\n";
nsSend(fullMsg, ns);
nsSend(msg, ns);
ns.Close();
tcp.Close();
}
catch (ArgumentNullException e)
{
ch.getServer().log("connection error: argument null exception: " + e);
}
catch (SocketException e)
{
ch.getServer().log("connection error: socket exception: " + e);
}
}
private void nsSend(String s, NetworkStream ns)
{
Byte[] data = System.Text.Encoding.ASCII.GetBytes(s);
ns.Write(data, 0, data.Length);
ns.Flush();
ch.getServer().log("Sent: " + s);
}
}
</code></pre>
<p>Does anyone have any ideas? It feels like it's gotta be something stupid on my part but I just don't know what. I'd really appreciate any insight</p>
| [
{
"answer_id": 238640,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": true,
"text": "HttpListener"
}
] | 2008/10/26 | [
"https://Stackoverflow.com/questions/238606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19696/"
] |
238,608 | <p>I'm using TortoiseHg 0.5 (which includes Mercurial 1.0.2) on Vista64. My understanding from the <a href="http://hgbook.red-bean.com/hgbookch7.html#x11-1530007.7" rel="noreferrer">Mercurial Book</a> is that Mercurial should handle filenames in a case-insensitive manner on a case-insensitive filesystem (such as NTFS, which is what I'm on). However I find that my installation of Mercurial is in fact sensitive to case:</p>
<pre><code>>hg status -A foo
C foo
>hg status -A FOO
? FOO
</code></pre>
<p>Could this be a bug in Mercurial, a bug in the TortoiseHg build of Mercurial, or is it something else? How can I achieve case-insensitive filename handling from Mercurial on Windows?</p>
| [
{
"answer_id": 245867,
"author": "Ry4an Brase",
"author_id": 8992,
"author_profile": "https://Stackoverflow.com/users/8992",
"pm_score": 3,
"selected": false,
"text": "hg status -A FOO"
},
{
"answer_id": 529728,
"author": "Mentat",
"author_id": 30198,
"author_profile"... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30198/"
] |
238,615 | <p>I have a quite old templating system written on top of ERB. It relies on ERB templates stored in database. Those are read and rendered. When I want to pass data from one template to another I use the :locals parameter to Rails render method. For setting default variables of those variables in some templates I use the defined? method which simply tells me if local variable has been defined and if not I initialize it with default value like this: </p>
<pre><code>unless defined?(perex)
perex = true
end
</code></pre>
<p>I am upgrading the app to latest Rails and I see some weird behavior. Basically this sometimes works (sometimes perex is undefined) and sometimes it does not (perex is defined and set to nil). This happens without anything else changing.</p>
<p>I have two questions:
Is there any better way other than using defined? which is proving unreliable (was reliable for several years on top Rails 1.6)? Such a way should not result in me rewriting all the templates.
I have been going through Ruby docs and was not able to find anything about defined? method. Was it deprecated or am I just plain blind?</p>
<p><em>Edit:</em> The actual issue was caused by what seems to be a Ruby/eRB bug. Sometimes the <em>unless</em> statement would work, but sometimes not. The weird thing is that even if the second line got executed <em>perex</em> stil stayed nil to the rest of the world. Removing defined? resolved that.</p>
| [
{
"answer_id": 238715,
"author": "Rômulo Ceccon",
"author_id": 23193,
"author_profile": "https://Stackoverflow.com/users/23193",
"pm_score": 6,
"selected": true,
"text": "defined?"
},
{
"answer_id": 633927,
"author": "mislav",
"author_id": 11687,
"author_profile": "ht... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8621/"
] |
238,620 | <p>I have a subclass "s" of UIView. I want to put some buttons and labels on s. How do I associate my UIView subclass with a nib file?</p>
| [
{
"answer_id": 238806,
"author": "Colin Barrett",
"author_id": 23106,
"author_profile": "https://Stackoverflow.com/users/23106",
"pm_score": 6,
"selected": true,
"text": "-[NSBundle loadNibNamed:owner:options:]"
},
{
"answer_id": 18748065,
"author": "djibouti33",
"author_... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22471/"
] |
238,625 | <p>I have a Visual Studio 2008 solution with two projects (a Word-Template project and a VB.Net console application for testing). Both projects reference a database project which opens a connection to an MS-Access 2007 database file and have references to System.Data.OleDb. In the database project I have a function which retrieves a data table as follows</p>
<pre><code> private class AdminDatabase
' stores the connection string which is set in the New() method
dim strAdminConnection as string
public sub New()
...
adminName = dlgopen.FileName
conAdminDB = New OleDbConnection
conAdminDB.ConnectionString = "Data Source='" + adminName + "';" + _
"Provider=Microsoft.ACE.OLEDB.12.0"
' store the connection string in strAdminConnection
strAdminConnection = conAdminDB.ConnectionString.ToString()
My.Settings.SetUserOverride("AdminConnectionString", strAdminConnection)
...
End Sub
' retrieves data from the database
Public Function getDataTable(ByVal sqlStatement As String) As DataTable
Dim ds As New DataSet
Dim dt As New DataTable
Dim da As New OleDbDataAdapter
Dim localCon As New OleDbConnection
localCon.ConnectionString = strAdminConnection
Using localCon
Dim command As OleDbCommand = localCon.CreateCommand()
command.CommandText = sqlStatement
localCon.Open()
da.SelectCommand = command
da.Fill(dt)
getDataTable = dt
End Using
End Function
End Class
</code></pre>
<p>When I call this function from my Word 2007 Template project everything works fine; no errors. But when I run it from the console application it throws the following exception</p>
<blockquote>
<p>ex = {"The 'Microsoft.ACE.OLEDB.12.0'
provider is not registered on the
local machine."}</p>
</blockquote>
<p>Both projects have the same reference and the console application did work when I first wrote it (a while ago) but now it has stopped work. I must be missing something but I don't know what. Any ideas?</p>
| [
{
"answer_id": 1894000,
"author": "Pescadore",
"author_id": 230087,
"author_profile": "https://Stackoverflow.com/users/230087",
"pm_score": 3,
"selected": false,
"text": "VC# Express"
},
{
"answer_id": 21455784,
"author": "TechSpud",
"author_id": 1368849,
"author_prof... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4612/"
] |
238,631 | <p>I have Visual Studio 2008 and the Windows SDK for Windows Server 2008 and .NET Framework 3.5
installed. I believe that is the latest platform SDK.</p>
<p>I'm trying to build a signed dll to be installed in SxS.
All the tutorials explain to use a tool called pktextract.exe which is part of the SDK, but I can't seem to find the tool. All the other tools such as makecert, mt, makecat exist.</p>
<p>Was pktextract replaced by some other tool in the latest version of the sdk?</p>
<p>Thanks for the help.</p>
| [
{
"answer_id": 1894000,
"author": "Pescadore",
"author_id": 230087,
"author_profile": "https://Stackoverflow.com/users/230087",
"pm_score": 3,
"selected": false,
"text": "VC# Express"
},
{
"answer_id": 21455784,
"author": "TechSpud",
"author_id": 1368849,
"author_prof... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4697/"
] |
238,660 | <p>When you attempt to declare an unsigned variable in C#.NET with a value outside its value range it is flagged as a compiler error, but if you produce a negative value at runtime and assign it to that variable at runtime the value wraps.</p>
<pre><code>uint z = -1; // Will not compile
uint a = 5;
uint b = 6;
uint c = a - b; // Will result in uint.MaxValue
</code></pre>
<p>Is there a good reason why unsigned variables wrap in such a situation instead of throwing an exception?</p>
<p>Thanks.</p>
| [
{
"answer_id": 238669,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 6,
"selected": true,
"text": "uint z;\n"
},
{
"answer_id": 238672,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": ... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27765/"
] |
238,662 | <pre><code>string[] filesOfType1 = GetFileList1();
string[] filesOfType2 = GetFileList2();
var cookieMap = new Dictionary<string, CookieContainer>();
Action<string, Func<string, KeyValuePair<string, CookieContainer>>> addToMap = (filename, pairGetter) =>
{
KeyValuePair<string, CookieContainer> cookiePair;
try
{
cookiePair = pairGetter(filename);
}
catch
{
Console.WriteLine("An error was encountered while trying to read " + file + ".");
return;
}
if (cookieMap.ContainsKey(cookiePair.Key))
{
if (cookiePair.Value.Count > cookieMap[cookiePair.Key].Count)
{
cookieMap[cookiePair.Key] = cookiePair.Value;
}
}
else
{
cookieMap.Add(cookiePair.Key, cookiePair.Value);
}
};
foreach (string file in filesOfType1)
{
addToMap(file, GetType1FileCookiePair);
}
foreach (string file in filesOfType2)
{
addToMap(file, GetType2FileCookiePair);
}
</code></pre>
<p>Salient features that must be preserved:</p>
<ul>
<li>Files of type 1 are more important than files of type 2; i.e. if a file of type 1 maps to a (key, value1) combination and a file of type 2 maps to a (key, value2) combination, then we add (key, value1) to cookieMap and <em>not</em> (key, value2). <strong>Edit: as pointed out by Bevan, this is not satisfied by my original procedural code.</strong></li>
<li>Secondarily, <code>CookieContainer</code>s with a higher <code>Count</code> have higher priority, i.e. if there are two (key, value) combos for the same key and both from the same filetype, we choose the one with higher <code>value.Count</code>.</li>
<li>Per-case exception handling is a must; screwing up a single file-reading should just allows us to note that and continue.</li>
</ul>
<p>My best attempt started like this:</p>
<pre><code>var cookieMap = (filesOfType1.Select(file => GetType1FileCookiePair(file))
.Concat(filesOfType2.Select(file => GetType2FileCookiePair(file))))
.GroupBy(pair => pair.Key)
.Select(/* some way of selecting per the above bullets */)
.ToDictionary(pair => pair.Key, pair => pair.Value);
</code></pre>
<p>But it's inelegant and filling in that comment block seems like a bitch. Right now I'm happy to stay procedural, but I thought that it might be a fun challenge to see if people can come up with something really clever.</p>
| [
{
"answer_id": 238729,
"author": "Omer van Kloeten",
"author_id": 4979,
"author_profile": "https://Stackoverflow.com/users/4979",
"pm_score": 1,
"selected": false,
"text": "var cookieMap = (from pair in\n (from f1 in filesOfType1\n select Swallow(... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3191/"
] |
238,665 | <p>Is there a mechanism to inject dependencies into Linq to Sql or entity framework entities? If so would it be a sensible approach?</p>
| [
{
"answer_id": 238689,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "XmlMappingSource"
}
] | 2008/10/26 | [
"https://Stackoverflow.com/questions/238665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29547/"
] |
238,675 | <p>Im looking to build a thread manager for an application.</p>
<p>I have already started threading and it works entirely fine but I would like to be able to programatically kill them or get information on them.</p>
<p>Does anyone have ideas?</p>
| [
{
"answer_id": 238681,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "Thread.Abort"
},
{
"answer_id": 239018,
"author": "Jon B",
"author_id": 27414,
"author_profile": "ht... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31642/"
] |
238,684 | <p>I have a Ruby DateTime which gets filled from a form. Additionally I have n hours from the form as well. I'd like to subtract those n hours from the previous DateTime. (To get a time range).</p>
<p>DateTime has two methods "-" and "<<" to subtract day and month, but not hour. (<a href="https://ruby-doc.org/stdlib-2.5.1/libdoc/date/rdoc/DateTime.html" rel="noreferrer">API</a>). Any suggestions how I can do that?</p>
| [
{
"answer_id": 238690,
"author": "Matthias Winkelmann",
"author_id": 4494,
"author_profile": "https://Stackoverflow.com/users/4494",
"pm_score": 3,
"selected": false,
"text": "> Time.now - 12.hours\n=> 2019-08-19 05:50:43 +0200\n"
},
{
"answer_id": 238718,
"author": "Mike Spr... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31644/"
] |
238,702 | <p>In my database, Concessions have a many-to-one relationship with Firms (each Concession has a FirmID). SqlMetal has captured this relationship and generated the appropriate classes, so that each Concession has a Firm element. I'm binding against a query (simplified here) that returns a list of Concessions along with information about the corresponding Firm:</p>
<pre><code>From c as Concession in Db.Concessions _
Select _
c.ConcessionID, _
c.Title, _
c.Firm.Title
</code></pre>
<p>The problem is that in some cases a Concession has not been assigned to a Firm (c.FirmID is null), so c.Firm is nothing and I get <code>Object not set to an instance</code> etc.</p>
<p>I can get around this by doing a join as follows:</p>
<pre><code>From c As Concession In Db.Concessions _
Join f As Firm In Db.Firms On f.FirmID Equals c.FirmID _
Select _
c.ConcessionID, _
c.Title, _
Firm_Title = f.Title
</code></pre>
<p>This doesn't throw an error when FirmID is null (Firm_Title is just an empty string), but it's not elegant: it's not object-oriented, and it doesn't leverage all of the relational intelligence that Linq to SQL has already captured. </p>
<p>Is there a more graceful way to deal with this situation?</p>
| [
{
"answer_id": 238717,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 2,
"selected": false,
"text": "from c in Db.Concessions\nselect \n{ \n c.ConcessionID, \n c.Title, \n Title = c.Firm.Title ?? \"\"\n}\... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/239663/"
] |
238,724 | <p>I need advice for rendering an undirected graph with 178,000 nodes and 500,000 edges. I've tried Neato, Tulip, and Cytoscape. Neato doesn't even come remotely close, and Tulip and Cytoscape claim they can handle it but don't seem to be able to. (Tulip does nothing and Cytoscape claims to be working, and then just stops.)</p>
<p>I'd just like a vector format file (ps or pdf) with a remotely reasonable layout of the nodes.</p>
| [
{
"answer_id": 5093458,
"author": "Anthony Liekens",
"author_id": 361178,
"author_profile": "https://Stackoverflow.com/users/361178",
"pm_score": 5,
"selected": false,
"text": "sfdp"
},
{
"answer_id": 11093000,
"author": "MRocklin",
"author_id": 616616,
"author_profil... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
238,733 | <p>I want to "remove" a UIView from a superview and add it again at the end... but at the "bottom" of the rest of the UIviews that belong to the superview. </p>
<p>Is this possible?</p>
<p>Any help is very appreciated!</p>
| [
{
"answer_id": 238758,
"author": "Max Stewart",
"author_id": 18338,
"author_profile": "https://Stackoverflow.com/users/18338",
"pm_score": 5,
"selected": true,
"text": "- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;\n"
},
{
"answer_id": 238796,
"author": "Gu12... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23695/"
] |
238,738 | <p>I'm not sure how to look for this online... I think they might be called something different in C++</p>
<p>I want to have a simple event system, somthing like</p>
<pre><code>event myCustomEvent;
myCustomEvent.subscribe( void myHandler(string) );
myCustomEvent.fire("a custom argument");
// myHandler prints out the string passed in the first argument
event myNewCustomEvent;
myNewCustomEvent.subscribe( void myNewHandler(int) );
myNewCustomEvent.fire(10);
// myHandler prints 10
</code></pre>
<p>I can do this pretty easily with a simple class -- but when i want to have an event that passes a different type or amount of arguments to the subscriber i have to write, and define an entirely new event class.. I figure there has to be some library, or maybe even something native in Visual C++ 2008 that will work something similar to this. It's basicly just an implementation of the Observer pattern, so it can't be too impossible to do in C++</p>
<p>This really makes me appreciate how nice it is in JavaScript not to have to worry about the arguments you are passing.</p>
<p>Tell me if this is a stupid question.</p>
| [
{
"answer_id": 238963,
"author": "Eclipse",
"author_id": 8701,
"author_profile": "https://Stackoverflow.com/users/8701",
"pm_score": 3,
"selected": false,
"text": "[event_source(native)]\nclass CSource {\npublic:\n __event void MyEvent(int nValue);\n};\n\n[event_receiver(native)]\nclas... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1825034/"
] |
238,748 | <p>We have a 3D application that retrieves keyboard presses via the IDirectInputDevice8. Is there any way, when we retrive keyboard events via the win32 API winproc loop back that we can send these commands to the DirectInputDevice?</p>
| [
{
"answer_id": 238774,
"author": "jussij",
"author_id": 14738,
"author_profile": "https://Stackoverflow.com/users/14738",
"pm_score": 0,
"selected": false,
"text": "WM_SYSKEYDOWN\nWM_SYSKEYUP\nWM_KEYDOWN\nWM_KEYUP \nWM_CHAR \n"
}
] | 2008/10/26 | [
"https://Stackoverflow.com/questions/238748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
238,765 | <p>I am parsing an Expression Tree. Given a NodeType of ExpressionType.MemberAccess, how do I get the value of that Field? </p>
<p>From C# MSDN docs:
MemberAccess is A node that represents reading from a field or property. </p>
<p>A code snippet would be incredibly, incredibly helpful. Thanks in advance!!!</p>
<p>My code looks something like this: </p>
<pre><code>public static List<T> Filter(Expression<Func<T, bool>> filterExp)
{
//the expression is indeed a binary expression in this case
BinaryExpression expBody = filterExp.Body as BinaryExpression;
if (expBody.Left.NodeType == ExpressionType.MemberAccess)
//do something with ((MemberExpressionexpBody.Left).Name
//right hand side is indeed member access. in fact, the value comes from //aspdroplist.selectedvalue
if (expBody.Right.NodeType == ExpressionType.MemberAccess)
{
//how do i get the value of aspdroplist.selected value?? note: it's non-static
}
//return a list
}
</code></pre>
| [
{
"answer_id": 238798,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 7,
"selected": true,
"text": "Expression"
},
{
"answer_id": 238945,
"author": "Keith Fitzgerald",
"author_id": 49611,
"author_pr... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49611/"
] |
238,768 | <p>I would to change the menuitems in the default context menu provided in the Web Browser Control. I have already tried: webbrowser.contextmenu = mycontextmenu.
Nothing changed. Is there a way to do this?</p>
| [
{
"answer_id": 1151160,
"author": "Marco Luglio",
"author_id": 14263,
"author_profile": "https://Stackoverflow.com/users/14263",
"pm_score": 1,
"selected": false,
"text": "using System.Windows;\nusing System.Runtime.InteropServices;\nusing mshtml;\n"
}
] | 2008/10/26 | [
"https://Stackoverflow.com/questions/238768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
238,784 | <p>I wrote a class/function to send xml over https via PHP4/cURL, just wondering if this is the correct approach, or if there's a better one.</p>
<p>Note that PHP5 is not an option at present.</p>
<pre><code>/**
* Send XML via http(s) post
*
* curl --header "Content-Type: text/xml" --data "<?xml version="1.0"?>...." http://www.foo.com/
*
*/
function sendXmlOverPost($url, $xml) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
// For xml, change the content-type.
curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // ask for results to be returned
if(CurlHelper::checkHttpsURL($url)) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
}
// Send to remote and return data to caller.
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
</code></pre>
<p>cheers!</p>
| [
{
"answer_id": 238790,
"author": "Nick Stinemates",
"author_id": 4960,
"author_profile": "https://Stackoverflow.com/users/4960",
"pm_score": -1,
"selected": false,
"text": "$soap = new SoapClient(\"http://some.url/service/some.wsdl\");\n$args = array(\"someTypeName\" => \"someTypeValue\"... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29854/"
] |
238,792 | <p>I cannot seem to programmatcally scroll in WPF
in a normal Windows Form I would use the code below
but that property does not exist in WPF.</p>
<pre><code>HtmlDocument doc = this.webBrowser1.Document;
doc.Body.ScrollTop = 800;
return;
</code></pre>
<p>Is there an alternative to doing this? </p>
| [
{
"answer_id": 50808320,
"author": "Kyle Delaney",
"author_id": 2122672,
"author_profile": "https://Stackoverflow.com/users/2122672",
"pm_score": 0,
"selected": false,
"text": "if (wb.Document is mshtml.HTMLDocument htmlDoc)\n{\n htmlDoc.parentWindow.scrollTo(0, 0);\n}\n"
}
] | 2008/10/26 | [
"https://Stackoverflow.com/questions/238792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
238,800 | <p>I have a query:</p>
<p>UPDATE choices SET votes = votes + 1 WHERE choice_id = '$user_choice'</p>
<p>But when I execute it in my script, the votes field is updated twice, so the votes will go from 4 to 6 instead to 5. It doesn't seem that it is getting called twice because I echo out stuff to test this and only get one echo. Is there a way to have it so PHP will only execute this query once per page "refresh"?</p>
<p><strong>EDIT</strong>: Thanks for the responses, I'm using regular MySQL, no MySQLi or PDO. Another thing I found is that when doing the query, it works when you start out with 0 and update to 1, but then after that it goes 3, 5, 7, ...</p>
| [
{
"answer_id": 238808,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 2,
"selected": false,
"text": "$pdo = new PDO(...options...);\n$stmt = $pdo->query('UPDATE ...'); // executes once\n$stmt->execute(); // executes a s... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
238,812 | <p>I have a server dropdownlist in an <a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" rel="noreferrer">Ajax</a> updatepanel. When I use the mouse to click on an item it fires the postback but when I click the up/down arrow to change entries, this is not firing. What could be reason?</p>
| [
{
"answer_id": 238864,
"author": "Paul Prewett",
"author_id": 15751,
"author_profile": "https://Stackoverflow.com/users/15751",
"pm_score": 0,
"selected": false,
"text": "onKeyDown"
},
{
"answer_id": 238934,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
238,814 | <p>I'm trying to build an in-game Tell A Friend form like in AppStore. Does anybody know if it can be found anywhere in the SDK? I wouldn't like to reinvent the sliced bread.</p>
<p>Thanks!</p>
| [
{
"answer_id": 239375,
"author": "Chris Samuels",
"author_id": 30342,
"author_profile": "https://Stackoverflow.com/users/30342",
"pm_score": 3,
"selected": false,
"text": "NSURL *url = [[NSURL alloc] initWithString: @\"mailto:gilm@myopenid.com?subject=subject&body=body\"];\n[[UIApplicati... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31515/"
] |
238,815 | <p>I currently have a couple of SVN repositories hosted at Unfuddle and I'd like to have a local copy of the repositories as a backup. Ideally, it would be a "live" backup so my local repository would "ping" the remote repository, and if any changes were detected, the changes would be applied to my local repository.</p>
<p>Has anyone tried this before? If so, what tools were used to accomplish the job?</p>
<p>Thanks.</p>
| [
{
"answer_id": 238853,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 0,
"selected": false,
"text": "svnadmin dump"
},
{
"answer_id": 238866,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https:... | 2008/10/26 | [
"https://Stackoverflow.com/questions/238815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3440/"
] |
238,824 | <p>How do I call a url in order to process the results?</p>
<p>I have a stand-alone reporting servlet which I link to for reports. I want to email these reports now, if I were doing this in the browser, I could just use an xhttprequest, and process the results - I basically want to do the same thing in Java, but I'm not sure how to go about it.</p>
<p><strong>UPDATE</strong>: I'm looking to get a file back from the url (whether that be a pdf or html etc).</p>
<p><strong>UPDATE</strong>: This will be running purely on the server - there is no request that triggers the emailing, rather it is a scheduled email.</p>
| [
{
"answer_id": 238845,
"author": "Vincent Ramdhanie",
"author_id": 27439,
"author_profile": "https://Stackoverflow.com/users/27439",
"pm_score": 1,
"selected": false,
"text": "RequestDispatcher dispatcher =\n getServletContext().getRequestDispatcher(\"/url of other resource\");\nif (di... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/943/"
] |
238,878 | <p>I am still very new to Ruby (reading through the Pickaxe and spending most of my time in <code>irb</code>), and now that I know it's possible to patch classes in Ruby, I'm wondering when it's acceptable to do so, specifically whether it's acceptable to patch Ruby's base classes. For example: I answered another Ruby question <a href="https://stackoverflow.com/questions/238684/subtract-n-hours-from-a-datetime-in-ruby#238718">here</a> where the poster wanted to know how to subtract hours from a <code>DateTime</code>. Since the <code>DateTime</code> class doesn't seem to provide this functionality, I posted an answer that patches the <code>DateTime</code> and <code>Fixnum</code> classes as a possible solution. This is the code I submitted:</p>
<pre><code>require 'date'
# A placeholder class for holding a set number of hours.
# Used so we can know when to change the behavior
# of DateTime#-() by recognizing when hours are explicitly passed in.
class Hours
attr_reader :value
def initialize(value)
@value = value
end
end
# Patch the #-() method to handle subtracting hours
# in addition to what it normally does
class DateTime
alias old_subtract -
def -(x)
case x
when Hours; return DateTime.new(year, month, day, hour-x.value, min, sec)
else; return self.old_subtract(x)
end
end
end
# Add an #hours attribute to Fixnum that returns an Hours object.
# This is for syntactic sugar, allowing you to write "someDate - 4.hours" for example
class Fixnum
def hours
Hours.new(self)
end
end
</code></pre>
<p>I patched the classes because I thought in this instance it would result in a clear, concise syntax for subtracting a fixed number of hours from a <code>DateTime</code>. Specifically, you could do something like this as a result of the above code:</p>
<pre><code>five_hours_ago = DateTime.now - 5.hours
</code></pre>
<p>Which seems to be fairly nice to look at and easy to understand; however, I'm not sure whether it's a good idea to be messing with the functionality of <code>DateTime</code>'s <code>-</code> operator.</p>
<p>The only alternatives that I can think of for this situation would be:</p>
<p><strong>1. Simply create a new <code>DateTime</code> object on-the-fly, computing the new hour value in the call to <code>new</code></strong>
<br/></p>
<pre><code>new_date = DateTime.new(old_date.year, old_date.year, old_date.month, old_date.year.day, old_date.hour - hours_to_subtract, date.min, date.sec)
</code></pre>
<p><br/>
<strong>2. Write a utility method that accepts a <code>DateTime</code> and the number of hours to subtract from it</strong>
<br/></p>
<p>Basically, just a wrapper around method (1):</p>
<pre><code>def subtract_hours(date, hours)
return DateTime.new(date.year, date.month, date.day, date.hour - hours, date.min, date.sec)
end
</code></pre>
<p><br/>
<strong>3. Add a new method to <code>DateTime</code> instead of changing the existing behavior of <code>#-()</code></strong></p>
<p>Perhaps a new <code>DateTime#less</code> method that could work together with the <code>Fixnum#hours</code> patch, to allow syntax like this:</p>
<pre><code>date.less(5.hours)
</code></pre>
<hr/>
<p>However, as I already mentioned, I took the patching approach because I thought it resulted in a much more expressive syntax.</p>
<p>Is there anything wrong with my approach, or should I be using one of the 3 alternatives (or another one I haven't thought of) in order to do this? I have the feeling that patching is becoming my new 'hammer' for problems in Ruby, so I'd like to get some feedback on whether I'm doing things the "Ruby way" or not.</p>
| [
{
"answer_id": 238917,
"author": "glenn mcdonald",
"author_id": 7919,
"author_profile": "https://Stackoverflow.com/users/7919",
"pm_score": 3,
"selected": false,
"text": "class MyDateTime < DateTime\n alias...\n def...\n"
}
] | 2008/10/27 | [
"https://Stackoverflow.com/questions/238878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17862/"
] |
238,894 | <p>I am trying to design a 4-bit adder subtracter in verilog. This is only the second thing I have ever written in verilog, and I don't know all the correct syntax yet. This is the module I have so far:</p>
<pre><code>module Question3(carryin, X, Y, Z, S, carryout, overflow);
parameter n = 4;
input carryin, Z;
input [n-1:0]X, Y;
output reg [n-1:0]S;
output reg carryout, overflow;
if(Z==0)
begin
Y = not(y) + 4'b0001;
end
always @(X, Y, carryin)
begin
{carryout, S} = X + Y + carryin;
overflow = carryout ^ X[n-1]^Y[n-1]^S[n-1];
end
endmodule
</code></pre>
<p>My compiler (xilinx 10.1), keeps saying "Syntax error near if." I have tried many different ways of doing the conversion, including just using a Case that takes Y as an argument, then checks all the possible 4-bit combinations, and converts them to two's complement.</p>
<p>Z is what determines if the adder does subtraction or addition. If it's 0, it means subtraction, and I want to convert y to two's complement, then just do regular addition. I'm sure the rest of the adder is correct, I just do not know what is wrong with the part where I'm trying to convert.</p>
| [
{
"answer_id": 1005430,
"author": "Steve K",
"author_id": 121394,
"author_profile": "https://Stackoverflow.com/users/121394",
"pm_score": 4,
"selected": true,
"text": "reg [n-1:0] Y_compl;\n\nalways @( Z, Y, X, carryin ) begin\n Y_ = ( ~Y + 4'b0001 );\n if ( Z == 1'b0 ) begin\n {car... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23323/"
] |
238,898 | <p>Has anyone noticed that if you retrieve HTML from the clipboard, it gets the encoding wrong and injects weird characters?</p>
<p>For example, executing a command like this:</p>
<pre><code>string s = (string) Clipboard.GetData(DataFormats.Html)
</code></pre>
<p>Results in stuff like:</p>
<pre><code><FONT size=-2>Â Â <A href="/advanced_search?hl=en">Advanced
Search</A><BR>Â Â <A href="/preferences?hl=en">Preferences</A><BR>Â Â <A
href="/language_tools?hl=en">Language
Tools</A></FONT>
</code></pre>
<p><em>Not sure how MarkDown will process this, but there are weird characters in the resulting markup above.</em></p>
<p>It appears that the bug is with the .NET framework. What do you think is the best way to get correctly-encoded HTML from the clipboard?</p>
| [
{
"answer_id": 19068371,
"author": "Julo",
"author_id": 2826535,
"author_profile": "https://Stackoverflow.com/users/2826535",
"pm_score": 2,
"selected": false,
"text": "byte[] data = Encoding.Default.GetBytes(text);\ntext = Encoding.UTF8.GetString(data);\n"
},
{
"answer_id": 2966... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31015/"
] |
238,915 | <p>I've got a UserControl that contains an UpdatePanel. When I put that on a page, it throws the following error:</p>
<blockquote>
<p>Cannot unregister UpdatePanel with ID
'ReviewContentUpdatePanel' since it
was not registered with the
ScriptManager. This might occur if the
UpdatePanel was removed from the
control tree and later added again,
which is not supported. Parameter
name: updatePanel</p>
</blockquote>
<p><code>ReviewContentUpdatePanel</code> is the name of the update panel & it's not being removed or added in code, it exists in the aspx page and isn't removed. Has anyone come across this before?</p>
| [
{
"answer_id": 19006245,
"author": "Steve",
"author_id": 1571391,
"author_profile": "https://Stackoverflow.com/users/1571391",
"pm_score": 2,
"selected": false,
"text": "protected override void OnInit(EventArgs e)\n{\n ScriptManager sm = ScriptManager.GetCurrent(this.Page);\n Metho... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2975/"
] |
238,918 | <p>I have been having some problems trying to get my PHP running. When I try and run any scripts they appear in the source and do not run properly. This is the htaccess file:</p>
<pre><code># Use PHP5 as default
AddHandler application/x-httpd-php5 .php
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
</code></pre>
<p>Could this be the error?</p>
| [
{
"answer_id": 238926,
"author": "noob source",
"author_id": 29838,
"author_profile": "https://Stackoverflow.com/users/29838",
"pm_score": 3,
"selected": true,
"text": "AddHandler application/x-httpd-php5 .php"
}
] | 2008/10/27 | [
"https://Stackoverflow.com/questions/238918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31677/"
] |
238,920 | <p>What's a simple/easy way to access the system clock using Java, so that I can calculate the elapsed time of an event?</p>
| [
{
"answer_id": 238924,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 3,
"selected": false,
"text": "java.lang.System.currentTimeMillis()"
},
{
"answer_id": 238943,
"author": "jjnguy",
"author_id": 2598,
... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22371/"
] |
238,931 | <p>I am developing some client side Javascript that is using some JSON web services on a different domain. I have read that some browsers do not allow cross-domain scripting and that I should create a proxy on my local server to serve the data.</p>
<p>Can someone please point me to a simple example of how to do this in ASP.Net?</p>
| [
{
"answer_id": 238953,
"author": "eyelidlessness",
"author_id": 17964,
"author_profile": "https://Stackoverflow.com/users/17964",
"pm_score": 0,
"selected": false,
"text": "SomeAjaxAbstraction.Request('proxyScript', {\n parameters: {\n address: 'http://somewhere.com/someapi?som... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10589/"
] |
238,941 | <p><strong>UPDATE:</strong> Thanks to everyone for the responses. I didn't realize document.write() was deprecated. Add a another notch to the learning column. I'll be taking the advice posted here, but leave the original question so that the answers given make sense in context of the original question.</p>
<hr>
<p>I'm in the process of coding some rather long write() arguments and am trying to decide which of the following examples would be the best to follow, considering syntax, readability and performance. Should I</p>
<p>a. Keep them all on one line:</p>
<pre><code><script>
var someVariable = "(<a href=\"http://www.example.com\">Link<\/a>)";
document.write("<p>Supergroovalisticprosifunkstication and Supercalifragilisticexpialidocious are very long words.</p>" + someVariable + "<p>Dociousaliexpisticfragilicalirepus is Supercalifragilisticexpialidocious spelled backwards.</p>" + someVariable);
</script>
</code></pre>
<p>b. Break them up by adding line breaks for somewhat improved readability:</p>
<pre><code><script>
var someVariable = "(<a href=\"http://www.example.com\">Link<\/a>)";
document.write("<p>Supergroovalisticprosifunkstication and Supercalifragilisticexpialidocious are very long words.</p>"
+ someVariable
+ "<p>Dociousaliexpisticfragilicalirepus is Supercalifragilisticexpialidocious spelled backwards.</p>"
+ someVariable);
</script>
</code></pre>
<p>c. Break them up by using multiple variables:</p>
<pre><code><script>
var someVariable = "(<a href=\"http://www.example.com\">Link<\/a>)";
var partOne = "<p>Supergroovalisticprosifunkstication and Supercalifragilisticexpialidocious are very long words.</p>";
var partTwo = "<p>Dociousaliexpisticfragilicalirepus is Supercalifragilisticexpialidocious spelled backwards.</p>";
document.write(partOne + someVariable + partTwo + someVariable);
</script>
</code></pre>
<p>Thanks in advance.</p>
| [
{
"answer_id": 238957,
"author": "eyelidlessness",
"author_id": 17964,
"author_profile": "https://Stackoverflow.com/users/17964",
"pm_score": 3,
"selected": true,
"text": "var longVar = 'asdfasdf asdf asdf asdfasdf asdfasdf asdf asdfasdf' +\n ' fasdf s9d0af asdf asdf0s,dv z-xcfva-sdfm... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
238,949 | <p>If this is possible, please provide a sample query or two so I can see how it would work. Both tables will be in the same database.</p>
<p>Thanks!</p>
| [
{
"answer_id": 238952,
"author": "Andrew",
"author_id": 826,
"author_profile": "https://Stackoverflow.com/users/826",
"pm_score": 5,
"selected": true,
"text": "insert into <target-table>\n( <column-list> )\nselect <columns>\n from <source-table>\n"
},
{
"answer_id": 239003,
... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1572436/"
] |
238,956 | <p>On the latest Ubuntu, I have a functioning PHP 5.2.4 installation. I want to use a remote Oracle server from PHP using OCI.</p>
<p>I've downloaded the <em>"Instant Client Package - Basic Lite"</em> (<a href="http://www.oracle.com/technology/software/tech/oci/instantclient/htdocs/linuxsoft.html" rel="nofollow noreferrer">Link</a>). I've unzipped the package containing the OCI libraries to a dir but I have no idea how to tell PHP that I want to use these libraries. Predictably, I get</p>
<blockquote>
<p>Fatal error: Call to undefined function oci_connect() in...</p>
</blockquote>
<p>when running this code:</p>
<pre><code><?php
$conn = oci_connect('hr', 'hrpw', 'someremotehost');
?>
</code></pre>
<p>I don't want to recompile PHP with Oracle support. What's the fastest way to wire up PHP so that I can use Oracle? Do I need any other libaries, like the Oracle client if I want to connect to a remote Oracle instance?</p>
| [
{
"answer_id": 238979,
"author": "Till",
"author_id": 2859,
"author_profile": "https://Stackoverflow.com/users/2859",
"pm_score": 2,
"selected": false,
"text": "(sudo) pecl install oci8\n"
}
] | 2008/10/27 | [
"https://Stackoverflow.com/questions/238956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3401/"
] |
238,977 | <p>How do i take a HTML site that currently has no doctype declaration and make it W3C compliant?</p>
| [
{
"answer_id": 240021,
"author": "Mr. Shiny and New 安宇",
"author_id": 7867,
"author_profile": "https://Stackoverflow.com/users/7867",
"pm_score": 0,
"selected": false,
"text": "<div height=\"100\" width=\"100\" style=\"border: 1px solid red\"></div>\n"
}
] | 2008/10/27 | [
"https://Stackoverflow.com/questions/238977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
238,980 | <p>I began an iPhone project the other day with a silly development code name, and now I want to change the name of the project since it's nearly finished. </p>
<p>But I'm not sure how to do this with Xcode, trying the obvious of changing the application's name in the info.plist file, causes the signing process to go wrong (I think...) and my app won't launch giving me a Launcher error.</p>
<p>I guess I could make a new project and copy paste everything over, but it seems so primitive that I'm hoping for a more civilized solution.</p>
| [
{
"answer_id": 239006,
"author": "Giao",
"author_id": 14099,
"author_profile": "https://Stackoverflow.com/users/14099",
"pm_score": 11,
"selected": true,
"text": "Targets"
},
{
"answer_id": 27418699,
"author": "Jeffrey Neo",
"author_id": 1856717,
"author_profile": "ht... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15124/"
] |
238,996 | <p>I've never had a reason to put a label element inside of a legend element (never really thought about it or seen it done). But with the design I'm implementing, it's tempting to do so.</p>
<p>Here's what I'm tempted to do:</p>
<pre><code><fieldset>
<legend><label for="formInfo">I would like information on</label></legend>
<select id="formInfo">
<option value="Cats">Cats</option>
<option value="Dogs">Dogs</option>
<option value="Lolz">Lolz</option>
</select>
</fieldset>
</code></pre>
<p>It works as expected (clicking the label focuses the corresponding input) in Firefox3, Safari, Opera, and IE6/7 and it passes validation, but I'm just wondering if there are any known reasons (accessibility? semantics? browser issues) why this shouldn't be done</p>
| [
{
"answer_id": 239011,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 0,
"selected": false,
"text": "legend"
},
{
"answer_id": 239190,
"author": "joelhardi",
"author_id": 11438,
"author_profile": "https://St... | 2008/10/27 | [
"https://Stackoverflow.com/questions/238996",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17252/"
] |
239,002 | <p>Is there a simple way to duplicate all child components under parent component, including their published properties?</p>
<p>For example:</p>
<ul>
<li>TPanel
<ul>
<li>TLabel</li>
<li>TEdit</li>
<li>TListView</li>
<li>TSpecialClassX</li>
</ul></li>
</ul>
<p>Of course the most important factor, it should duplicate any new component which I drop on the TPanel without modifying the code under normal circumstances.</p>
<p>I've heard of the RTTI, but never used it actually. Any ideas?</p>
| [
{
"answer_id": 239056,
"author": "Kluge",
"author_id": 8752,
"author_profile": "https://Stackoverflow.com/users/8752",
"pm_score": 0,
"selected": false,
"text": "for (i = 0; i < ComponentCount; ++i) {\n TControl *Comp = dynamic_cast<TControl *>(Components[i]);\n if (Comp) {\n ... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30787/"
] |
239,004 | <p>We use GNU Make for our system. At the end of our makefiles, we have an include called Makedepends which generates a bunch of .d files using -MM switch on gcc. We then include the .d file for each .cc file using an include $(CXXFILES:.cc=.d) line. But when we delete file or move files, the dependancies step breaks and we have to manually delete the .d files (even a make clean doesn't work because the dependencies fail)</p>
<p>Is there a way to generate these dependency .d files or include these dependency .d files which will gracefully handle a file deletion or relocation?</p>
<p>EDIT: For example: I have serial.cc and the makefiles generate a serial.d file which has a dependency on buffer.h but then I change it so I don't need buffer.h any more and I delete buffer.h. Next time I run make, it will choke because it includes the .d file which still makes serial.o depend on buffer.h.</p>
| [
{
"answer_id": 239024,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": "https://Stackoverflow.com/users/29157",
"pm_score": 0,
"selected": false,
"text": ".SUFFIXES: .d\n\n%.d::\n makedepend_command_here\n"
},
{
"answer_id": 16016596,
"author": "Daniel",
"a... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20889/"
] |
239,009 | <p>I need to update data to a mssql 2005 database so I have decided to use adodbapi, which is supposed to come built into the standard installation of python 2.1.1 and greater.</p>
<p>It needs pywin32 to work correctly and the open office python 2.3 installation does not have pywin32 built into it. It also seems like this built int python installation does not have adodbapi, as I get an error when I go import adodbapi. </p>
<p>Any suggestions on how to get both pywin32 and adodbapi installed into this open office 2.4 python installation?</p>
<p>thanks </p>
<hr>
<p>oh yeah I tried those ways. annoyingly nothing. So i have reverted to jython, that way I can access Open Office for its conversion capabilities along with decent database access.</p>
<p>Thanks for the help.</p>
| [
{
"answer_id": 239179,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 0,
"selected": false,
"text": "tools / COM Makepy utility"
}
] | 2008/10/27 | [
"https://Stackoverflow.com/questions/239009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21537/"
] |
239,020 | <p>I have a third-party product, a terminal emulator, which provides a DLL that can be linked to a C program to basically automate the driving of this product (send keystrokes, detect what's on the screen and so forth).</p>
<p>I want to drive it from a scripting language (I'm comfortable with Python and slightly less so with Perl) so that we don't have to compile and send out executables to our customers whenever there's a problem found.</p>
<p>We also want the customers to be able to write their own scripts using ours as baselines and they won't entertain the idea of writing and compiling C code.</p>
<p>What's a good way of getting Python/Perl to interface to a Windows DLL. My first thought was to write a server program and have a Python script communicate with it via TCP but there's got to be an easier solution.</p>
| [
{
"answer_id": 239041,
"author": "albertb",
"author_id": 26715,
"author_profile": "https://Stackoverflow.com/users/26715",
"pm_score": 5,
"selected": true,
"text": ">>> from ctypes import *\n>>> windll.user32.MessageBoxA(None, \"Hello world\", \"ctypes\", 0);\n"
}
] | 2008/10/27 | [
"https://Stackoverflow.com/questions/239020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14860/"
] |
239,023 | <p>I have a dependency that I need to inject into one of my classes. This dependency will be lifestyle of <code>Transient</code>. It in-turn has a dependency of type <code>Type</code>. This type should be the type of the original class. I was just wondering if anyone has any idea how I might go about conducting this registration.</p>
<p>See example:</p>
<pre><code>public interface ICustomer
{
.....
}
public class Customer : ICustomer
{
public Customer(IRegister register)
{ .... }
}
public interface IRegister
{
.....
}
public class Register
{
public Register(Type partentType)
{ .... }
}
public class TestExample
{
public static void TestMe()
{
//If i was creating all this manually it would look
// something like this
IRegister myRegister = new Register(typeof(Customer));
ICustomer myCustomer = new Customer(myRegister);
}
}
</code></pre>
<p>Now I know I could call <code>Container.Resolve</code> when ever I want a <code>Customer</code> and then inject <code>Register</code> manually. But I need to inject <code>Register</code> into most of my classes so this isn't really that feasible. Hence I need a way of doing it via the config or via <code>container.Register</code>.</p>
| [
{
"answer_id": 239033,
"author": "jonnii",
"author_id": 4590,
"author_profile": "https://Stackoverflow.com/users/4590",
"pm_score": 0,
"selected": false,
"text": "public interface IRegister{\n RegisterResult MyMethod(object thing);\n}\n"
},
{
"answer_id": 329420,
"author":... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30572/"
] |
239,059 | <p>I am trying to mock out HttpContext so that I can unit test my controller's Request.IsAuthenicated call. I am using the <a href="http://www.hanselman.com/blog/ASPNETMVCSessionAtMix08TDDAndMvcMockHelpers.aspx" rel="noreferrer">code that I found at Scott Hanselman's</a> blog to simulate HttpContext using rhino.mocks.
so i have this unit test piece:</p>
<pre><code>PostsController postsController = new PostsController(postDL);
mocks.SetFakeControllerContext(postsController);
Expect.Call(postsController.Request.IsAuthenticated).Return(true);
</code></pre>
<p>In my controller action, I have something like
<code>if(Request.IsAuthenticated)....</code>
when I try to run the unit test, the test fails throwing a null exception, and when I try to debug the unit test, I see that the HttpContext is never assigned to the controller.
any ideas?</p>
| [
{
"answer_id": 239418,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 0,
"selected": false,
"text": "interface IAuthenticationChecker\n{\n bool IsAuthenticated { get; }\n}\n\npublic class MockAuthenticationChecker : IAuth... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31699/"
] |
239,063 | <p>I came across an article about Car remote entry system at <a href="http://auto.howstuffworks.com/remote-entry2.htm" rel="nofollow noreferrer">http://auto.howstuffworks.com/remote-entry2.htm</a> In the third bullet, author says,</p>
<blockquote>
<p>Both the transmitter and the receiver use the same pseudo-random number generator. When the transmitter sends a 40-bit code, it uses the pseudo-random number generator to pick a new code, which it stores in memory. On the other end, when the receiver receives a valid code, it uses the same pseudo-random number generator to pick a new one. In this way, the transmitter and the receiver are synchronized. The receiver only opens the door if it receives the code it expects.</p>
</blockquote>
<p>Is it possible to have two PRNG functions producing same random numbers at the same time? </p>
| [
{
"answer_id": 239066,
"author": "Erik Forbes",
"author_id": 16942,
"author_profile": "https://Stackoverflow.com/users/16942",
"pm_score": 5,
"selected": true,
"text": "// Provide the same seed value for both generators:\nSystem.Random r1 = new System.Random(1);\nSystem.Random r2 = new S... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15474/"
] |
239,082 | <p>I'm working on a simple javascript login for a site, and have come up with this:</p>
<pre><code><form id="loginwindow">
<strong>Login to view!</strong>
<p><strong>User ID:</strong>
<input type="text" name="text2">
</p>
<p><strong>Password:</strong>
<input type="password" name="text1"><br>
<input type="button" value="Check In" name="Submit" onclick=javascript:validate(text2.value,"username",text1.value,"password") />
</p>
</form>
<script language = "javascript">
function validate(text1,text2,text3,text4)
{
if (text1==text2 && text3==text4)
load('album.html');
else
{
load('failure.html');
}
}
function load(url)
{
location.href=url;
}
</script>
</code></pre>
<p>...which works except for one thing: hitting enter to submit the form doesn't do anything. I have a feeling it's cause I've used "onclick" but I'm not sure what to use instead. Thoughts?</p>
<hr>
<p>Okay yeah so I'm well aware of how flimsy this is security-wise. It's not for anything particularly top secret, so it's not a huge issue, but if you guys could elaborate on your thoughts with code, I'd love to see your ideas. the code i listed is literally all I'm working with at this point, so I can start from scratch if need be.</p>
| [
{
"answer_id": 239086,
"author": "keparo",
"author_id": 19468,
"author_profile": "https://Stackoverflow.com/users/19468",
"pm_score": 6,
"selected": true,
"text": "<input type=\"submit\".../> \n"
},
{
"answer_id": 239092,
"author": "Vincent Ramdhanie",
"author_id": 27439,... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27171/"
] |
239,103 | <p>I have a char in c#:</p>
<pre><code>char foo = '2';
</code></pre>
<p>Now I want to get the 2 into an int. I find that Convert.ToInt32 returns the actual decimal value of the char and not the number 2. The following will work:</p>
<pre><code>int bar = Convert.ToInt32(new string(foo, 1));
</code></pre>
<p>int.parse only works on strings as well. </p>
<p>Is there no native function in C# to go from a char to int without making it a string? I know this is trivial but it just seems odd that there's nothing native to directly make the conversion.</p>
| [
{
"answer_id": 239107,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 8,
"selected": false,
"text": "int"
},
{
"answer_id": 239109,
"author": "sontek",
"author_id": 17176,
"author_profile": "https://Stac... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26854/"
] |
239,122 | <p>Just to clarify, I'm running Sybase 12.5.3, but I am lead to believe that this holds true for SQL Server 2005 too. Basically, I'm trying to write a query that looks a little like this, I've simplified it as much as possible to highlight the problem:</p>
<pre><code>DECLARE @a int, @b int, @c int
SELECT
@a = huzzah.a
,@b = huzzah.b
,@c = huzzah.c
FROM (
SELECT
1 a
,2 b
,3 c
) huzzah
</code></pre>
<p>This query gives me the following error: <em>"Error:141 A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations."</em></p>
<p>The only work around that I've got for this so far, is to insert the derived-table data into a temporary table and then select it right back out again. Which works fine, but the fact that this doesn't work irks me. Is there a better way to do this?</p>
| [
{
"answer_id": 239407,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "DECLARE @a int, @b int, @c int\n\nSELECT\n @a = huzzah.a\n ,@b = huzzah.b\n ,@c = huzzah.c\nFROM (\n SELECT\n ... | 2008/10/27 | [
"https://Stackoverflow.com/questions/239122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1030/"
] |
239,127 | <p>What is the exact use of an Abstract class? Is not possible to do the same things in an ordinary class as it is an an abstract class? </p>
| [
{
"answer_id": 239156,
"author": "Jay Bazuzi",
"author_id": 5314,
"author_profile": "https://Stackoverflow.com/users/5314",
"pm_score": 1,
"selected": false,
"text": "abstract"
}
] | 2008/10/27 | [
"https://Stackoverflow.com/questions/239127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.