qid int64 4 19.1M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
387,806 | <p>I would like to map a many-to-many in Hibernate using a link table. I have two classes, Parent and Child class, for example:</p>
<pre><code>public class Parent{
private List<Child> _children;
//...getters and setters
}
</code></pre>
<p>I use a link table (link_table) with three columns <code>link_id</code>, <code>parent_id</code>, and <code>child_id</code>. The database is SQL server and id types are uniqueidentifier. So, I usually use guid for the id fields.</p>
<p>How can you implement this using the <strong><code><list /></code></strong> tag if this is the correct tag to use? Do you know of any good documentation to accomplish this?</p>
<p>I am currently getting a ConstraintViolationException but have not been able to find any good documentation or examples of this.</p>
<p><strong>I think a main issue is: how to specify the <code>link_id</code> to be automatically generated in the link table.</strong></p>
| [
{
"answer_id": 387926,
"author": "Matt Lewis",
"author_id": 28987,
"author_profile": "https://Stackoverflow.com/users/28987",
"pm_score": 3,
"selected": false,
"text": "@Entity\npublic class Employer implements Serializable {\n @ManyToMany(\n targetEntity=org.hibernate.test.met... | 2008/12/22 | [
"https://Stackoverflow.com/questions/387806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23133/"
] |
387,829 | <p>The problem domain features a large population of named snarks. Some of the snarks are boojums. </p>
<p>There are at least two ways to model this:</p>
<pre>
// as a property:
class Snark {
string name;
bool is_boojum;
};
// as a list:
class Snark {
typedef long Id;
Id id;
string name;
};
tree<Snark::Id> boojums;
</pre>
<p>It seems intuitive that if we determined that snarks come in male and female, we would add a "sex" property to the snark class definition; and if we determined that all but five snarks were vanquished subjects, we would make a list of royals.</p>
<p>Are there principles one can apply, or is it a matter of architectural preference?</p>
| [
{
"answer_id": 387860,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 0,
"selected": false,
"text": "is_boojum Snarks SELECT * FROM Snarks WHERE is_boojum = 1\n"
},
{
"answer_id": 387869,
"author": "Shog9",
... | 2008/12/23 | [
"https://Stackoverflow.com/questions/387829",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29403/"
] |
387,830 | <p>I'm using the UPS service to monitor the state of my UPS from an application -- the key at HKLM\SYSTEM\CCS\Services\UPS\Status has all the information you can get from the Power control panel. BUT -- I'd like to be able to tell the UPS to shut down from my app as well. I know that the service can tell the UPS to shut down -- for instance, after running a set number of minutes on battery -- and I'm wondering if there's some kind of command I can send to the service to initiate a shutdown manually.</p>
<p>I'm having trouble searching for this information -- people tend to misspell "Uninterruptible" (hrm, Firefox red-lined that but doesn't have an alternative) and "UPS" just gets hits for the shipping service. Maybe I can do something through System.ServiceController, or WMI?</p>
<p>CLARIFICATION: Yes, I am talking about powering down the physical UPS device. I know how to stop the service. I figured it would be a common problem -- I want my UPS to turn off with the PC. I had an idea I'm going to try, based on <a href="http://msdn.microsoft.com/en-us/library/ms789319.aspx" rel="nofollow noreferrer">this page</a>. You see, APC (and everybody else) has to supply a DLL for the UPS service to call, and since the function calls are well documented, there's no reason I shouldn't be able to P/Invoke them. I'll re-edit this once I know whether or not it worked.</p>
<p>Update: I tried invoking UPSInit, then UPSTurnOff, and nothing happens. I'll tinker with it some more, but the direct call to apcups.dll might be a dead end.</p>
| [
{
"answer_id": 387862,
"author": "Hernán",
"author_id": 48026,
"author_profile": "https://Stackoverflow.com/users/48026",
"pm_score": -1,
"selected": false,
"text": "OpenService (hServMgr, TEXT(\"\\\\UPS_SERVICE_0\"), SC_MANAGER_ALL_ACCESS);\n\nSERVICE_STATUS stat;\nControlService (hUpsS... | 2008/12/23 | [
"https://Stackoverflow.com/questions/387830",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26286/"
] |
387,850 | <p>I'm building a site where users can track their collection of figures for Dungeons & Dragons (www.ddmdb.com). The models/relationships involved in this funcitonality are the following:</p>
<p><strong>User:</strong></p>
<ul>
<li>id</li>
<li>login (username)</li>
<li><em>a bunch of other fields</em></li>
</ul>
<p><strong>Miniature:</strong></p>
<ul>
<li>id</li>
<li>name</li>
<li>number (# in the set, not count)</li>
<li>release_id (foreign key)</li>
<li><em>a bunch of other fields and foreign keys</em></li>
</ul>
<p><strong>Ownership:</strong></p>
<ul>
<li>id (is this really even needed?)</li>
<li>user_id</li>
<li>miniature_id</li>
<li>have_count</li>
<li>favorite (boolean)</li>
</ul>
<p>The pertinent relationships I have set up are as follows:</p>
<p><strong>User:</strong></p>
<ul>
<li>has_many :ownerships</li>
<li>has_many :miniatures, :through => :ownerships, :uniq => true, :conditions => "ownerships.have_count > 0"</li>
<li>has_many :favorites, :through => :ownerships, :source => :miniature, :uniq => true, :conditions => "ownerships.favorite = true"</li>
</ul>
<p><strong>Miniatures:</strong></p>
<ul>
<li>has_many :ownerships</li>
<li>has_many :owners, :through => :ownerships, :source => :user, :uniq => true, :conditions => "ownerships.have_count > 0"</li>
</ul>
<p><strong>Ownership:</strong></p>
<ul>
<li>belongs_to :user</li>
<li>belongs_to :miniature</li>
</ul>
<p>I have a page where user's can both view and update their collection, as well as view other user's collections. It contains a list of all the miniatures on the site and a text box next to each where the user can enter how many of each miniature they have. This functionality also exists in sub-lists of miniatures (filtered by type, release, size, rarity, etc.)</p>
<p>When a user creates an account they have no entries in the ownership. When they use the collection page or sub-list of miniatures to update their collection, I create entries in the ownership table for only the miniatures on the submitting page. So if it's the full Collection list I update all minis (even if the count is 0) or if it's a sub-list, I only update those miniatures. So at any time a particular user I may have:
- no entries in ownership
- entries for some of the miniatures
- entries for all the miniatures.</p>
<p>The problem I'm having is that I don't know how to query the database with a LEFT JOIN using a "Rails method" so that if a user doesn't have an entry for a miniature in Ownerships it defaults to a have_count of 0. Currently I query for each user_id/miniature_id combination individually as I loop through all miniatures and it's obviously really inefficient.</p>
<p><strong>View:</strong></p>
<pre><code><% for miniature in @miniatures %>
<td><%= link_to miniature.name, miniature %></td>
<td><%= text_field_tag "counts[#{miniature.id}]", get_user_miniature_count(current_user, miniature), :size => 2 %></td>
<% end %>
</code></pre>
<p><strong>Helper:</strong></p>
<pre><code>def get_user_miniature_count(user, miniature)
ownerships = user.ownerships
ownership = user.ownerships.find_by_miniature_id(miniature.id)
if ownership.nil?
return 0
else
return ownership.have_count
end
end
</code></pre>
<p>An alternate solution would be creating entries for all miniatures when a user signs up, but then I would also have to add a 0 have_count for all users when a new miniature is added to the database after they sign up. That seems like it could get a bit complex, but perhaps it's the right way to go?</p>
<p>Is there a way to do the join and supply a default value for miniatures where there's no entries in the Ownership table for that particular user?</p>
| [
{
"answer_id": 387874,
"author": "frankodwyer",
"author_id": 42404,
"author_profile": "https://Stackoverflow.com/users/42404",
"pm_score": 0,
"selected": false,
"text": "<% ownerships=current_user.ownerships %> \n<% for miniature in @miniatures %>\n <td><%= link_to miniature.name, minia... | 2008/12/23 | [
"https://Stackoverflow.com/questions/387850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8252/"
] |
387,879 | <p>I am currently working on a project that spans accross multiple domains. What I want is for the user to be able to login on one site and be logged in on all the others at the same time.</p>
<p>The users session is stored in the database, the cookies that I set on each domain contain the session id.</p>
<p>So basically when a user logs in to example.com a cookie is created with their session id, the session data is stored in the database. Once this is done a cookie needs to be created on all the other domains with this unique session id so that as the user travels from site to site they will automatically be logged in.</p>
<p>Now I have found a way to do this in Firefox (using image tags that executes PHP scripts on the other domains, essentially creating the different cookies on the different domains) but this method doesn't work in IE (havn't tested Opera or Safari etc. yet).</p>
<p>Does anyone have any ideas about how I can get this to work in IE?</p>
| [
{
"answer_id": 389004,
"author": "suitedupgeek",
"author_id": 42428,
"author_profile": "https://Stackoverflow.com/users/42428",
"pm_score": -1,
"selected": false,
"text": "setcookie(A, $sessid, expire, path, domainA.com);\nsetcookie(B, $sessid, expire, path, domainB.com);\nsetcookie(C, $... | 2008/12/23 | [
"https://Stackoverflow.com/questions/387879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48526/"
] |
387,893 | <p>I can use write(&stName,sizeof(stName),&FileName) and define a same struct in other program to read the file(XXX.h) when i use C, But I want do the same use C# and I should not use the unsafe mode. How do to solve the problem?</p>
<p><strong>Edit:</strong></p>
<p>thanks all. I will to try them</p>
<p><strong>Edit:</strong></p>
<p>Now if I want to use C write the Struct to file.h and use C# to read the struct from file.h, may I have chance solve that and not to count the offset? Because count the offset is not a good answer when I want to add some variable or other struct in the struct.</p>
| [
{
"answer_id": 387977,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 1,
"selected": false,
"text": "read(in, &structure, sizeof(structure));\nwrite(out, &structure, sizeof(structure));\n"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/387893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
387,895 | <p>Consider following example :</p>
<pre><code>public class SomeBusinessLayerService : DataService<MyEntityContainer>
{
[WebInvoke]
void DoSomething(string someParam)
{
}
}
</code></pre>
<p>I can not find example or any help on how can I pass parameter to the function!
Using WebClient (or goofinfg around with fiddler) I can trigger the function call, but no matter what I try the parameter someParam is always null
What's worse - if I change the type to int - all my attempts end in following error:</p>
<pre><code><?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code></code>
<message xml:lang="en-US">Bad Request - Error in query syntax.</message>
</error>
</code></pre>
<p>Can anyone please help with working example of POST content on how I can call it ?</p>
<p>NOTE: This is DataService, and not WCF service. I can get it working with WCF service same method without any problems. </p>
<p>EDIT: Also I need example of POST and not embedding parameter in URI because URI has size limit and requirement to sanitize the string.</p>
| [
{
"answer_id": 1571728,
"author": "Andrei Rînea",
"author_id": 1796,
"author_profile": "https://Stackoverflow.com/users/1796",
"pm_score": 0,
"selected": false,
"text": "var y = ctx.Execute<bool>(new Uri(\"ReportExists?id=guid'\" + Guid.NewGuid() + \"'\", UriKind.Relative));\n"
},
{
... | 2008/12/23 | [
"https://Stackoverflow.com/questions/387895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44838/"
] |
387,912 | <p>I'm working with a CMS, Joomla, and there's a core class which renders a set of parameters to a form, JParameter. Basically it has a <code>render()</code> function which outputs some table-laden HTML which is not consistent with the rest of my site.</p>
<p>For issues of maintainability, and because I have no idea where else this is being used, I don't want to change the core code. What would be ideal would to be able to define a new class which extends JParameter and then cast my $params object down to this new sub class.</p>
<pre><code>// existing code --------------------
class JParameter {
function render() {
// return HTML with tables
}
// of course, there's a lot more functions here
}
// my magical class -----------------
class MyParameter extends JParameter {
function render() {
// return HTML which doesn't suck
}
}
// my code --------------------------
$this->params->render(); // returns tables
$this->params = (MyParameter) $this->params; // miracle occurs here?
$this->params->render(); // returns nice html
</code></pre>
| [
{
"answer_id": 387967,
"author": "Sean McSomething",
"author_id": 39413,
"author_profile": "https://Stackoverflow.com/users/39413",
"pm_score": 3,
"selected": true,
"text": "$this->params->render() MyParamRenderer::render($this->params)"
},
{
"answer_id": 388528,
"author": "m... | 2008/12/23 | [
"https://Stackoverflow.com/questions/387912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
387,921 | <p>I'm wondering how I can get the URL from the browser in ASP.NET.</p>
<p>I have a page that I use with globalization/localization, and I am redirecting (via server not code) from <code>www.spanishversion.com</code> to <code>www.englishversion.com</code>, but the URL is masked to still say <code>www.spanishversion.com</code>. I want to get what the browser's URL is but when I try things like:</p>
<ul>
<li><code>Request.Url.ToString()</code> </li>
<li><code>Request.Url.OriginalUrl</code> </li>
<li><code>Request.Path Request.RawUrl</code> </li>
<li><code>Request.ServerVariables["SERVER_NAME"]</code></li>
</ul>
<p>It always comes back as <code>www.englishversion.com</code>. Is there a way that I can explicitly read the URL from the browser?</p>
| [
{
"answer_id": 387967,
"author": "Sean McSomething",
"author_id": 39413,
"author_profile": "https://Stackoverflow.com/users/39413",
"pm_score": 3,
"selected": true,
"text": "$this->params->render() MyParamRenderer::render($this->params)"
},
{
"answer_id": 388528,
"author": "m... | 2008/12/23 | [
"https://Stackoverflow.com/questions/387921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19840/"
] |
387,937 | <p>According to FXCop, List should not be exposed in an API object model. Why is this considered bad practice?</p>
| [
{
"answer_id": 387973,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 7,
"selected": true,
"text": "List<T> IList<T> List<T> AddRange() List<T> IList<T> IEnumerable<T>"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/387937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19799/"
] |
387,943 | <p>I am new to the REST architecural design, however I think I have the basics of it covered.</p>
<p>I have a problem with returning objects from a RESTful call. If I make a request such as <a href="http://localhost/" rel="noreferrer">http://localhost/</a>{type A}/{id} I will return an instance of A from the database with the specified id.</p>
<p>My question is what happens when A contains a collection of B objects? At the moment the XML I generate returns A with a collection of B objects inside of it. As you can imagine if the B type has a collection of C objects then the XML returned will end up being a quite complicated object graph.</p>
<p>I can't be 100% sure but this feels to be against the RESTful principles, the XML for A should return the fields etc. for A as well as a collection of URI's to the collection of B's that it owns. </p>
<p>Sorry if this is a bit confusing, I can try to elaborate more. This seems like a relatively basic question, however I can't decide which approach is "more" RESTful.</p>
<p>Cheers,</p>
<p>Aidos </p>
| [
{
"answer_id": 388029,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 3,
"selected": false,
"text": "/flat/A/id/ /flat/B/id/ /flat/C/id/ /deep/A/id/ /deep/B/id/ /deep/C/id/ /deep/A/id/ /flat/A/id/"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/387943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12040/"
] |
387,944 | <p>I was reading the <a href="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js" rel="noreferrer">jQuery source</a> and I was wondering why the entire source file was wrapped in an anonomous function.</p>
<pre><code>(function(){
...
})();
</code></pre>
<p>Is this something which helps not to pollute the global namespace? Why is it there and how does it work?</p>
| [
{
"answer_id": 387958,
"author": "olliej",
"author_id": 784,
"author_profile": "https://Stackoverflow.com/users/784",
"pm_score": 5,
"selected": true,
"text": "(function (){\n var someConstantValue = ...;\n myCoolFunction = function(){ return someConstantValue * 5; }\n})();\n\nmyCo... | 2008/12/23 | [
"https://Stackoverflow.com/questions/387944",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42413/"
] |
387,959 | <p>Let's say I have a class called <code>SomeClass</code> with a <code>string</code> property name:</p>
<pre><code>@interface SomeClass : NSObject
{
NSString* name;
}
@property (nonatomic, retain) NSString* name;
@end
</code></pre>
<p>I understand that name may be assigned a <code>NSMutableString</code> in which case this may lead to errant behavior. </p>
<ul>
<li>For strings in general, is it <em>always</em> a good idea to use the <code>copy</code> attribute instead of <code>retain</code>? </li>
<li>Is a "copied" property in any way less efficient than such a "retain-ed" property?</li>
</ul>
| [
{
"answer_id": 388002,
"author": "Chris Hanson",
"author_id": 714,
"author_profile": "https://Stackoverflow.com/users/714",
"pm_score": 10,
"selected": true,
"text": "NSCopying copy @property retain NSMutableString *someName = [NSMutableString stringWithString:@\"Chris\"];\n\nPerson *p =... | 2008/12/23 | [
"https://Stackoverflow.com/questions/387959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2288585/"
] |
388,024 | <p>How does one copy resource files (config/data/image) files to an applictions home directory on the iPhone.</p>
<p>A related question <a href="https://stackoverflow.com/questions/317959/loading-data-files-on-iphone">Loading Data Files on iPhone?</a>, received an answer "just add them to your project; Xcode will copy them to the .app bundle when it builds your application".</p>
<p>How does one do this? (If this is a simple question, a manual reference/page# is fine)</p>
<p>I want to be able to copy a file onto the iPhone simulator and open it at runtime. I have tried to do this by adding 'copy file' targets, although I havent been able to find the files at runtime.</p>
<p>I know using property list, or sql lite database is prefered over file io, but I would still like to understand how to achieve this.</p>
| [
{
"answer_id": 388054,
"author": "frankodwyer",
"author_id": 42404,
"author_profile": "https://Stackoverflow.com/users/42404",
"pm_score": 4,
"selected": true,
"text": "NSString *dbFilePath = [[NSBundle mainBundle] \n pathForResource:@\"dictionary\" \n ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40175/"
] |
388,034 | <p>Hannuka, Chanukah, Hanukkah...Due to transliteration from another language and character set, there are many ways to spell the name of this holiday. How many legitimate spellings can you come up with?</p>
<p>Now, write a regular expression that will recognise all of them.</p>
| [
{
"answer_id": 388045,
"author": "chaos",
"author_id": 47529,
"author_profile": "https://Stackoverflow.com/users/47529",
"pm_score": 1,
"selected": false,
"text": " /^[ck]?hann?ukk?ah?$/i\n"
},
{
"answer_id": 388048,
"author": "Charlie Martin",
"author_id": 35092,
"a... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19512/"
] |
388,053 | <p>If I have a point, and a road network, how do I find the nearest point ON the road? i.e. this is like snapping the point to a line/road.</p>
<p>I am using ArcGis server 9.3 with Java 5 and Oracle 10g. I am using the ST functions and NetworkAnalyst via the java api.</p>
<p>Thanks.</p>
| [
{
"answer_id": 388045,
"author": "chaos",
"author_id": 47529,
"author_profile": "https://Stackoverflow.com/users/47529",
"pm_score": 1,
"selected": false,
"text": " /^[ck]?hann?ukk?ah?$/i\n"
},
{
"answer_id": 388048,
"author": "Charlie Martin",
"author_id": 35092,
"a... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20242/"
] |
388,057 | <p>While dabbling in Clojure I've written a very basic program to echo whatever the user types into it. However, it doesn't run in a way that I'm perceiving to be natural. Here's the code:</p>
<pre><code>(defn goo []
(print "echo> ")
(def resp (read-line))
(print resp)
)
</code></pre>
<p>I would expect the code to run like this (for me typing in <code>foo</code> as the input to <code>read-line</code>):</p>
<pre><code>user=> (goo)
echo> foo
foonil
</code></pre>
<p>But instead, the echo and read-line is switched:</p>
<pre><code>user=> (goo)
foo
echo> foonil
</code></pre>
<p>Why does this happen? Is there a subtlety I'm missing?</p>
<p>EDIT: From Joe's answer, the updated correct solution is:</p>
<pre><code>(defn goo []
(print "echo> ")
(flush)
(def resp (read-line))
(print resp)
(flush)
)
</code></pre>
<p>Also, the flushes aren't necessary if you use <code>println</code> instead of <code>print</code>.</p>
| [
{
"answer_id": 388065,
"author": "jmucchiello",
"author_id": 44065,
"author_profile": "https://Stackoverflow.com/users/44065",
"pm_score": 5,
"selected": true,
"text": "(defn goo []\n (print \"echo> \")\n (flush )\n (def resp (read-line))\n (print resp)\n)\n"
},
{
"answer_id"... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/422/"
] |
388,066 | <p>Whats the simplest way to get a barebones linux server installed?
barebones = just enough to get ssh and package manager.</p>
<p>Current I've been using CentOS with server install and removing any packages that I know i do not want installed.</p>
<p>But is there a better way? I just want a simple ssh shell + package management to start with. Hardware is irrelevant since everything is happening in a VM.</p>
| [
{
"answer_id": 404681,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "su -c 'pacman -S sshd'\n"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/388066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48545/"
] |
388,069 | <p>How do you gracefully handle failed future feature imports? If a user is running using Python 2.5 and the first statement in my module is:</p>
<pre><code>from __future__ import print_function
</code></pre>
<p>Compiling this module for Python 2.5 will fail with a:</p>
<pre><code> File "__init__.py", line 1
from __future__ import print_function
SyntaxError: future feature print_function is not defined
</code></pre>
<p>I'd like to inform the user that they need to rerun the program with Python >= 2.6 and maybe provide some instructions on how to do so. However, to quote <a href="http://www.python.org/dev/peps/pep-0236/" rel="nofollow noreferrer">PEP 236</a>:</p>
<blockquote>
<p>The only lines that can appear before
a future_statement are:</p>
<ul>
<li>The module docstring (if any).</li>
<li>Comments.</li>
<li>Blank lines.</li>
<li>Other future_statements.</li>
</ul>
</blockquote>
<p>So I can't do something like:</p>
<pre><code>import __future__
if hasattr(__future__, 'print_function'):
from __future__ import print_function
else:
raise ImportError('Python >= 2.6 is required')
</code></pre>
<p>Because it yields:</p>
<pre><code> File "__init__.py", line 4
from __future__ import print_function
SyntaxError: from __future__ imports must occur at the beginning of the file
</code></pre>
<p>This snippet from the PEP seems to give hope of doing it inline:</p>
<blockquote>
<p>Q: I want to wrap future_statements
in try/except blocks, so I can use
different code depending on which
version of Python I'm running. Why
can't I?</p>
<p>A: Sorry! try/except is a runtime
feature; future_statements are
primarily compile-time gimmicks, and
your try/except happens long after the
compiler is done. That is, by the
time you do try/except, the semantics
in effect for the module are already a
done deal. Since the try/except
wouldn't accomplish what it <em>looks</em>
like it should accomplish, it's simply
not allowed. We also want to keep
these special statements very easy to
find and to recognize.</p>
<p>Note that you <em>can</em> import __future__
directly, and use the information in
it, along with sys.version_info, to
figure out where the release you're
running under stands in relation to a
given feature's status.</p>
</blockquote>
<p>Ideas?</p>
| [
{
"answer_id": 388083,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 7,
"selected": true,
"text": "import sys\nmajor, minor, micro, releaselevel, serial = sys.version_info\nif (major,minor) <= (2,5):\n # provide advice o... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] |
388,082 | <p>Why 4? I know its in the documentation as 4, but that just seems strange.</p>
| [
{
"answer_id": 388143,
"author": "Jason Jackson",
"author_id": 13103,
"author_profile": "https://Stackoverflow.com/users/13103",
"pm_score": 1,
"selected": false,
"text": "namespace System\n{\n public delegate void Action<T1, T2, T3, T4, T5>(T1 arg1, T2 arg2, \n ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2512607/"
] |
388,088 | <p>I've got a cocoa app that's got a TableView with bindings to a model through an NSArrayController.</p>
<p>The app works as I want, but the default sort order of the table is wrong.</p>
<p><a href="http://public.west.spy.net/BuildWatch.png" rel="nofollow noreferrer">buildwatch http://public.west.spy.net/BuildWatch.png</a></p>
<p>I typically start the program and click on the last header twice to get it sorting the right way. Is there a way in the nib/bindings/whatever to specify the default sort order, or to programatically tell it to do what would happen if I clicked there twice? Or even just remember the previous sort order?</p>
| [
{
"answer_id": 388214,
"author": "sbooth",
"author_id": 31520,
"author_profile": "https://Stackoverflow.com/users/31520",
"pm_score": 3,
"selected": false,
"text": "NSWindowController NSSortDescriptor *buildETASortDescriptor = [[NSSortDescriptor alloc] initWithKey:@\"buildETA\" ascending... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39975/"
] |
388,099 | <p>I have a ListBox with a StackPanel that contains an image and label.</p>
<pre><code><ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" IsItemsHost="True" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<Image Source="{Binding Image}" Cursor="Hand" Tag="{Binding Link}" MouseLeftButtonDown="Image_MouseLeftButtonDown" ToolTip="Click to see this product on adidas.com" VerticalAlignment="Top" HorizontalAlignment="Left" />
<Label Content="{Binding Name}" Cursor="Hand" Tag="{Binding Link}" MouseLeftButtonDown="Label_MouseLeftButtonDown" VerticalAlignment="Bottom" Foreground="White" Style="{StaticResource Gotham-Medium}" FontSize="8pt" HorizontalAlignment="Center" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</code></pre>
<p>I want to show a third image (glow.png) behind the currently moused over image. I can't seem to add a second image to the stack panel, and set it's visibility to hidden. I haven't even tackled the mouseover part yet.</p>
<p>Is adding another image inside the stack panel, and then setting it's visibility to visible the right approach on mouseenter, and then swapping back on mouseleave?</p>
<p>Thanks.</p>
| [
{
"answer_id": 388122,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 3,
"selected": true,
"text": "<StackPanel Orientation=\"Vertical\">\n <Grid>\n <Image Source=\"...\" />\n <Image Source=\"{Binding Ima... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22451/"
] |
388,123 | <p>I have a flash movie that loads images dynamically from an xml file. I want to re-use this .swf file on different pages, however the images on page1 are all 400 x 200 and the images on page2 are all 745 x 422. When i try to reuse this on another page, the loaded images are shrunken (resized) - i would like them to match whats defined in the width/height, but they get scaled depending on how the stage is scaled.</p>
<p>im using a loader (AS3) for the image that places them on a container(sprite)</p>
<pre><code>slideLoader.load(new URLRequest(xmlSlideshow..image[intCurrentSlide].@src));
</code></pre>
<p>I have tried making the stage various sizes to start, but i would really like it to be irrelavant if possible - ie: 50 x 50. Then in html the width/height would be set to the width/height of the images being loaded.</p>
<p>Im not a flash wizard so please forgive me if im not clear, i'll try to give more insight if needed.</p>
| [
{
"answer_id": 388141,
"author": "jerebear",
"author_id": 42979,
"author_profile": "https://Stackoverflow.com/users/42979",
"pm_score": 0,
"selected": false,
"text": "fscommand(\"allowscale\",\"false\");\n"
},
{
"answer_id": 388157,
"author": "ifunk",
"author_id": 48554,
... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26685/"
] |
388,154 | <p>I keep a cache of transactions to flush (to persistent storage) on the event of a watermark or object finalization. Since <code>__del__</code> is <a href="http://docs.python.org/reference/datamodel.html?highlight=__del__#object.__del__" rel="nofollow noreferrer">no longer guaranteed to be called</a> on every object, is the appropriate approach to hook a similar function (or <code>__del__</code> itself) into <code>atexit.register</code> (during initialization)?</p>
<p>If I'm not mistaken, this <em>will</em> cause the object to which the method is bound to hang around until program termination. This isn't likely to be a problem, but maybe there's a more elegant solution?</p>
<p>Note: I know using <code>__del__</code> is non-ideal because <a href="http://docs.python.org/reference/datamodel.html?highlight=__del__#object.__del__" rel="nofollow noreferrer">it can cause uncatchable exceptions</a>, but I can't think of another way to do this short of cascading <code>finalize()</code> calls all the way through my program. TIA!</p>
| [
{
"answer_id": 388224,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "close() finalize() with weakref __del__()"
},
{
"answer_id": 388323,
"author": "Community",
"author_id": -1,
... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] |
388,163 | <p>How can I easily implement queries in Zend framework?</p>
| [
{
"answer_id": 388170,
"author": "Brian Fisher",
"author_id": 43816,
"author_profile": "https://Stackoverflow.com/users/43816",
"pm_score": 0,
"selected": false,
"text": "$sql = 'SELECT * FROM bugs WHERE bug_id = ?';\n\n$result = $db->fetchAll($sql, 2);\n"
},
{
"answer_id": 37353... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
388,172 | <p>Are there any scientific packages for Lua comparable to Scipy?</p>
| [
{
"answer_id": 388587,
"author": "nosklo",
"author_id": 17160,
"author_profile": "https://Stackoverflow.com/users/17160",
"pm_score": 3,
"selected": false,
"text": "> require(\"python\")\n> numpy = python.import(\"numpy\")\n> numpy.array ... etc ..\n"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/388172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41718/"
] |
388,173 | <p>Is there a way to tidy-up the following code, rather than a series of nested try/except statements?</p>
<pre><code>try:
import simplejson as json
except ImportError:
try:
import json
except ImportError:
try:
from django.utils import simplejson as json
except:
raise "Requires either simplejson, Python 2.6 or django.utils!"
</code></pre>
| [
{
"answer_id": 388360,
"author": "Soviut",
"author_id": 46914,
"author_profile": "https://Stackoverflow.com/users/46914",
"pm_score": 4,
"selected": true,
"text": "def module_exists(module_name):\n try:\n mod = __import__(module_name)\n except ImportError:\n return Fa... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/745/"
] |
388,180 | <p>I have a div 200 x 200 px. I want to place a 50 x 50 px image right in the middle of the div. </p>
<p>How can it be done?</p>
<p>I am able to get it centered horizontally by using <code>text-align: center</code> for the div. But vertical alignment is the issue..</p>
| [
{
"answer_id": 388186,
"author": "Kenan Banks",
"author_id": 43089,
"author_profile": "https://Stackoverflow.com/users/43089",
"pm_score": 3,
"selected": false,
"text": "line-height"
},
{
"answer_id": 388190,
"author": "Tim Knight",
"author_id": 43043,
"author_profile... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48557/"
] |
388,187 | <p>Given a data structure (e.g. a hash of hashes), what's the clean/recommended way to make a deep copy for immediate use? Assume reasonable cases, where the data's not particularly large, no complicated cycles exist, and readability/maintainability/etc. are more important than speed at all costs.</p>
<p>I know that I can use <a href="http://search.cpan.org/~ams/Storable-2.39/Storable.pm" rel="noreferrer">Storable</a>, <a href="http://search.cpan.org/~garu/Clone-0.34/Clone.pm" rel="noreferrer">Clone</a>, Clone::More, <a href="http://search.cpan.org/~wazzuteke/Clone-Fast-0.97/lib/Clone/Fast.pm" rel="noreferrer">Clone::Fast</a>, <a href="http://search.cpan.org/~smueller/Data-Dumper-2.139/Dumper.pm" rel="noreferrer">Data::Dumper</a>, etc. What's the current best practice?</p>
| [
{
"answer_id": 388196,
"author": "chaos",
"author_id": 47529,
"author_profile": "https://Stackoverflow.com/users/47529",
"pm_score": 4,
"selected": false,
"text": "Storable::dclone()"
},
{
"answer_id": 390699,
"author": "Community",
"author_id": -1,
"author_profile": ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31100/"
] |
388,192 | <p>I've been looking for a while how to play sound on the iphone, and I think it's something along the lines of:</p>
<pre><code>[[NSSound soundNamed:@"cat.mp3"] play];
</code></pre>
<p>But the NSSound is on the AppKit ... any suggestions ? I know there is a really simple answer to this, but today my searches are not rendering any result ...</p>
| [
{
"answer_id": 388198,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 3,
"selected": false,
"text": "// Initialize\nCFBundleRef mainBundle;\nmainBundle = CFBundleGetMainBundle ();\n\n// Init each sound\nCFURLRef tapU... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23238/"
] |
388,200 | <p>I've done quite a bit of programming on Windows but now I have to write my first Linux app. </p>
<p>I need to talk to a hardware device using UDP. I have to send 60 packets a second with a size of 40 bytes. If I send less than 60 packets within 1 second, bad things will happen.
The data for the packets may take a while to generate. But if the data isn't ready to send out on the wire, it's ok to send the same data that was sent out last time.
The computer is a command-line only setup and will only run this program.</p>
<p>I don't know much about Linux so I was hoping to get a general idea how you might set up an app to meet these requirements.
I was hoping for an answer like:</p>
<p>Make 2 threads, one for sending packets and the other for the calculations.</p>
<p>But I'm not sure it's that simple (maybe it is). Maybe it would be more reliable to make some sort of daemon that just sent out packets from shared memory or something and then have another app do the calculations? If it is some multiple process solution, what communication mechanism would you recommend?
Is there some way I can give my app more priority than normal or something similar?</p>
<p>PS: The more bulletproof the better!</p>
| [
{
"answer_id": 388235,
"author": "Andrew Edgecombe",
"author_id": 11694,
"author_profile": "https://Stackoverflow.com/users/11694",
"pm_score": 1,
"selected": false,
"text": "pipe()"
},
{
"answer_id": 388305,
"author": "Artelius",
"author_id": 31945,
"author_profile":... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48556/"
] |
388,201 | <p>I'm not sure if memory is the culprit here. I am trying to instantiate a GD image from data in memory (it previously came from a database). I try a call like this:</p>
<pre><code>my $image = GD::Image->new($image_data);
</code></pre>
<p><code>$image</code> comes back as <code>undef</code>. The POD for GD says that the constructor will return <code>undef</code> for cases of insufficient memory, so that's why I suspect memory.</p>
<p>The image data is in PNG format. The same thing happens if I call newFromPngData.</p>
<p>This works for very small images, like under 30K. However, slightly larger images, like ~70K will cause the problem. I wouldn't think that a 70K image should cause these problems, even after it is deflated.</p>
<p>This script is running under CGI through Apache 2.0, on OS 10.4, if that matters at all.</p>
<p>Are there any memory limitations imposed by Apache by default? Can they be increased?</p>
<p>Thanks for any insight!</p>
<p><strong>EDIT:</strong> For clarification, the GD::Image object never gets created, so clearing out the <code>$image_data</code> from memory isn't really an option.</p>
| [
{
"answer_id": 388250,
"author": "jerebear",
"author_id": 42979,
"author_profile": "https://Stackoverflow.com/users/42979",
"pm_score": 0,
"selected": false,
"text": "$src_img = imagecreatefromstring($userfile2);\nimagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_width,$thumb_height,$o... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388201",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4257/"
] |
388,208 | <p>Is there a way to set the default buffer size for JSPs in Tomcat? I know I can set them on every page, but am hoping there's a global option somewhere.</p>
| [
{
"answer_id": 388402,
"author": "Olaf Kock",
"author_id": 13447,
"author_profile": "https://Stackoverflow.com/users/13447",
"pm_score": 2,
"selected": false,
"text": "<%@ taglib uri=\"http://java.sun.com/jstl/core_rt\" prefix=\"c\" %>\n<%@ taglib uri=\"http://java.sun.com/jstl/fmt_rt\" ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48560/"
] |
388,223 | <p>I have a page with this HTML:</p>
<pre><code><p>
<img src="images/ih01.jpg" width="80" height="110" align="left" />
This course overs basic human anatomy and physiology, including the major
body systems and their functions. When you have completed this course you
will be able to identify major body components and their core physiological
functions.
</p>
</code></pre>
<p>And this is how it displays in Firefox 3, Chrome 1.0 and IE7: (Click for full size)</p>
<p><a href="http://fisher.spadgos.com/stuff/ie-align-fail.png" rel="nofollow noreferrer">http://fisher.spadgos.com/stuff/ie-align-fail.png</a></p>
<p>You can see that IE is not wrapping the text around the image even though it's aligned left. Any ideas?</p>
| [
{
"answer_id": 388226,
"author": "recursive",
"author_id": 44743,
"author_profile": "https://Stackoverflow.com/users/44743",
"pm_score": 4,
"selected": true,
"text": "<img src=\"images/ih01.jpg\" style=\"float: left; height: 110px; width: 80px; \" >\n"
},
{
"answer_id": 388230,
... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
388,233 | <p>I have a Question model & Form, one of the fields in this model is <strong>userid=ForeignKey(User)</strong>, this Works perfectly well on the Question Model, am able to pick the user from a drop down. </p>
<p>But kind a tricky when i want to list the question from the model, which is the best way to <strong>lookup</strong> the user name from the Users table? becouse at this point i cant have the dropdown!</p>
<p>I want to have a simple thing e.g.</p>
<p>Question Title
asked by:<strong>lookup user Name</strong> </p>
| [
{
"answer_id": 388296,
"author": "ayaz",
"author_id": 23191,
"author_profile": "https://Stackoverflow.com/users/23191",
"pm_score": 0,
"selected": false,
"text": "Question User user_name questions = Question.objects.filter( userid__username='user_name' )\n User user Question questions = ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20894/"
] |
388,237 | <p>Let's say I have the following code:</p>
<pre><code>IBOutlet UITextField* nameTextField;
IBOutlet UILabel* greetingLabel;
</code></pre>
<p>I'd like the <code>greetingLabel</code> to read "Hello [nameTextField]" as soon as the user presses any key.</p>
<p>What I need basically is the iPhone equivalent of the Cocoa delegate method <code>controlTextDidChange</code>.</p>
<p>The <code>textField:shouldChangeCharactersInRange:</code> delegate method is called each time a keystroke occurs:</p>
<pre><code>- (BOOL) textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)string
</code></pre>
<p>The string argument returns the character that is pressed. The actual <code>textField</code>'s value (<code>nameTextField.text</code>) remains blank however. </p>
<p>What am I missing here? (I'd like <code>nameTextField</code> to reflect the exact string that the user has entered so far).</p>
| [
{
"answer_id": 388395,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 7,
"selected": false,
"text": "[nameTextField addTarget:self action:@selector(updateLabelUsingContentsOfTextField:) forControlEvents:UIControlEventEditingCha... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2288585/"
] |
388,238 | <p>this seems so silly - i must be missing something obvious. I have the following code (just as a test):</p>
<pre><code><%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void page_load(object o, EventArgs e)
{
Response.Write(new string(' ', 255));
Response.Flush();
for (int i = 0; i < 10; i++)
{
Response.Write(i + "<BR>");
Response.Flush();
System.Threading.Thread.Sleep(500);
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
main div
</div>
</form>
</body>
</html>
</code></pre>
<p>when i test this locally (vista x64, cassini), i get the desired output.. 1, then 2, then 3, etc are all sent non-buffered to the browser. when i try this on the dev server (2003, iis6) it just buffers it all and sends it all at once. is there something obvious i'm missing?? I've also tried putting buffer=false at the top but that also doesn't change this behaviour.</p>
<p>to further clarify, i've done a test with fiddler to compare two servers. the first server is a local server on the LAN, the second is a public server. fiddler found no discernible difference between the two, except for the host name. the LAN server did not write out the response until the page had finished loading, the public server wrote the response as it happened. i can also confirm this behaviour happens in both firefox and ie.</p>
| [
{
"answer_id": 388251,
"author": "Dave Markle",
"author_id": 24995,
"author_profile": "https://Stackoverflow.com/users/24995",
"pm_score": 2,
"selected": false,
"text": "Response.BufferOutput = false;\n"
},
{
"answer_id": 1563813,
"author": "eidylon",
"author_id": 80209,
... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31902/"
] |
388,258 | <p>In my Dev C++, I am trying to create a 2D Array class that acts like a Grid.
But one of the problem is I am unsure what do for the constructor.</p>
<p>When I try to compile, I get the following errors:
In constructor 'Grid::Grid(int,int)':
'sqaures' is not a type
'yPos' cannot appear in a constant-expression
[Build Error] [grid.o] Error 1</p>
<p>Here is the Header File:</p>
<pre><code>#ifndef GRID_H
#define GRID_H
using namespace std;
class Grid
{
public:
Grid(int xPos, int yPos);
// Constructor
// POST: Creates the squares of grid; (x,y) coordinates
private:
int squares;
//2D Array
//the squares; (x,y) coordinates of the grids
};
#endif
</code></pre>
<p>And heres the .cpp file for the functions of grid.h</p>
<pre><code>#include <iostream>
#include "grid.h"
using namespace std;
Grid::Grid(int xPos, int yPos)
{
squares = new squares[xPos][yPos];
//Trying to make squares into a 2D array, and turn the values into the arguments
//into the the x,y coordinates
}
</code></pre>
<p>My constructor in the .cpp files doesn't work and I'm unsure what to do. Does anyone have any solutions?</p>
| [
{
"answer_id": 388272,
"author": "grepsedawk",
"author_id": 14388,
"author_profile": "https://Stackoverflow.com/users/14388",
"pm_score": 2,
"selected": false,
"text": "using namespace std;"
},
{
"answer_id": 388278,
"author": "David Norman",
"author_id": 34502,
"auth... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
388,264 | <p>I recently switched over to a MacBook Pro so I'm still really new at Mac software ecosystem. What is the best guide or what tips do you have to quickly get adept at using Mac for developing on both Mac/Unix and MS platforms (*.NET, SharePoint, SQL Server, etc) using VMWare Fusion? For example, I've setup NetBeans, FlexBuilder, Eclipse, TextMate, VMWare Fusion, OpenOffice, FireFox, dragged Terminal.app to my dock, upgraded the Ruby installation and related gems and so on... Things I've not done but looking at (based on other's experiences) include QuickSilver (is it all that different than SpotLight?), MacPorts (or Fink?), getting started with iPhone, Android, and so on. You can tell from my inexperience that I don't know what the best ways of doing things are yet, and don't want to get in the habit of just installing things and then leave files and stuff laying around slowing the system down. If you have any really cool tips about setting up a developer's Mac please share them!</p>
<p><strong>Update:</strong> The nature of my job is I'm always working with new/different technologies, some Windows/MS based, some not, and with the Mac (and Fusion) even the MS based stuff is more enjoyable to me.</p>
| [
{
"answer_id": 388271,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 4,
"selected": false,
"text": "sudo port install package-name\n"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/388264",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47110/"
] |
388,268 | <p>Is there any way to change Visual Studio Auto formatting options? Like VS by default uses close bracket format for Javascripts. </p>
| [
{
"answer_id": 22997653,
"author": "Habib",
"author_id": 961113,
"author_profile": "https://Stackoverflow.com/users/961113",
"pm_score": 5,
"selected": false,
"text": "Tools -> Options -> Text Editor -> JavaScript \n Tools -> Options -> Text Editor -> JavaScript -> Formatting -> New Line... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1312208/"
] |
388,295 | <p>Python, C++, Scheme, and others all let you define functions that take a variable number of arguments at the end of the argument list...</p>
<pre><code>def function(a, b, *args):
#etc...
</code></pre>
<p>...that can be called as followed:</p>
<pre><code>function(1, 2)
function(1, 2, 5, 6, 7, 8)
</code></pre>
<p>etc... Are there any languages that allow you to do variadic functions with the argument list somewhere else? Something like this:</p>
<pre><code>def function(int a, string... args, int theend) {...}
</code></pre>
<p>With all of these valid:</p>
<pre><code>function(1, 2)
function(1, "a", 3)
function(1, "b", "c", 4)
</code></pre>
<p>Also, what about optional arguments anywhere in the argument list?</p>
<pre><code>def function(int a, int? b, int c, int... d) {}
function(1, 2) //a=1, c=2, b=undefined/null/something, d=[]
function(1,2,3) //a=1, b=2, c=3,d=[]
function(1,2,3,4,5) //a=1, b=2, c=3, d=[4,5]
</code></pre>
| [
{
"answer_id": 388310,
"author": "jmucchiello",
"author_id": 44065,
"author_profile": "https://Stackoverflow.com/users/44065",
"pm_score": 0,
"selected": false,
"text": "function foo() {\n $args = func_get_args(); // returns an array of args\n}\n"
},
{
"answer_id": 388314,
... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388295",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15055/"
] |
388,302 | <p>It is possible because PageRank was a form of eigenvalue and that is why MapReduce introduced. But there seems problems in actual implementation, such as every slave computer have to maintain a copy of the matrix?</p>
| [
{
"answer_id": 390451,
"author": "Gavin Miller",
"author_id": 33226,
"author_profile": "https://Stackoverflow.com/users/33226",
"pm_score": 3,
"selected": false,
"text": "for (int i = 0; i < m[].length; i++)\n{\n for (int j = 0; j < m[i].length; j++)\n {\n m[i][j]++; \n }... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
388,304 | <p>When programming C++ we used to create copy constructors when needed (or so we were taught). When switching to Java a few years ago, I noticed that the Cloneable interface is now being used instead. C# followed the same route defining the ICloneable interface. It seems to me that cloning is part of the definition of OOP. But I wonder, why were these interfaces created, and the copy constructor seems to have been dropped?</p>
<p>When I thought about it, I came to the thought that a copy constructor would not be useful if one needs to make a copy of an object whose type is not known (as in having a reference to a base type). This seems logical. But I wonder whether there are other reasons that I do not know of, for which the Cloneable interfaces have been favored over copy constructors?</p>
| [
{
"answer_id": 388317,
"author": "jmucchiello",
"author_id": 44065,
"author_profile": "https://Stackoverflow.com/users/44065",
"pm_score": 2,
"selected": false,
"text": "SomeClass x = new SomeClass();\n SomeClass* x = new SomeClass();\n *x = *another_x;\n"
},
{
"answer_id": 38832... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41283/"
] |
388,312 | <p>I'm trying to code what I think is a fairly routine AJAX pattern using TreeViews and UpdatePanels. My situation is this:</p>
<p>I have a TreeView within an UpdatePanel. I have a Literal within another UpdatePanel. When the user clicks on a node within the TreeView, the contents of the Literal are updated. Now, since the whole thing is asynchronous, there is of course a time lag between the click and the update of the Literal contents. During this time, I'd like to do two things:</p>
<p>1) Show an UpdateProgress, and</p>
<p>2) Clear the contents of the Literal</p>
<p>This is so that the user doesn't have to stare at the old contents while the new text is getting loaded asynchronously.</p>
<p>I can't seem to figure out an easy way to accomplish (2). I've been reading up on client side callbacks and using GetCallbackEventReference, but it seems like a very complicated approach to what is seemingly a simple problem.</p>
<p>Ideally, I would like to leave TreeView alone to do it's work. I don't want to get the contents myself and add them to the TreeView using JS. I'd just like to detect the node change event at the client side, clear up the Literal, and let TreeView go about with its normal operation.</p>
<p>Is this possible? Or are client call backs my only option?</p>
| [
{
"answer_id": 388386,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 2,
"selected": true,
"text": "PageRequestManager BeginRequest EndRequest AsyncPostbackTrigger"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/388312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34985/"
] |
388,321 | <p>I hear a lot about map/reduce, especially in the context of Google's massively parallel compute system. What exactly is it?</p>
| [
{
"answer_id": 388329,
"author": "coobird",
"author_id": 17172,
"author_profile": "https://Stackoverflow.com/users/17172",
"pm_score": 7,
"selected": true,
"text": "map reduce map"
},
{
"answer_id": 388550,
"author": "Daniel Earwicker",
"author_id": 27423,
"author_pro... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8946/"
] |
388,328 | <p>Ok, let me explain more... the goal is to make the checkbox checked if there's a change on select. The actual code was:</p>
<pre><code>function checkit(date)
{
document.forms[0].date.checked = true;
}
<input type="checkbox" name="date[]" value="2008-08-14">Aug 14, 2008<br>
<select name="slot[]" size="1" onchange="checkit(date[]);"/>
<option value="2008-08-15;0900;1700">9am to 5pm</option>
<option value="2008-08-15;1330;1730">1:30pm to 5:30pm</option>
</select>
<input type="checkbox" name="date[]" value="2008-08-15">Aug 14, 2008<br>
<select name="slot[]" size="1" onchange="checkit(date[]);"/>
<option value="2008-08-15;0900;1700">9am to 5pm</option>
<option value="2008-08-15;1330;1730">1:30pm to 5:30pm</option>
</select>
<input type="checkbox" name="date[]" value="2008-08-16">Aug 14, 2008<br>
<select name="slot[]" size="1" onchange="checkit(date[]);"/>
<option value="2008-08-15;0900;1700">9am to 5pm</option>
<option value="2008-08-15;1330;1730">1:30pm to 5:30pm</option>
</select>
</code></pre>
<p>In PHP, if it sees a variable with [ ], it automatically creates an array. In Javascript, I expected that Javascript would recognize the [] and execute based on the current element. For example, if I select a value in the second checkbox, it should fire an event to check that element box. I don't want to name the variable like date1, date2, date3, date4... I hope this clarifies more. I know I am missing out something... I tried "this" keyword to make it "this current element" but it doesn't seem to work but it could be that I used the improper syntax. </p>
<p>What I expected was that onchange event, it should fire its argument which is "date[]" but I would assume that Javascript should know which element in date[] it will use instead of expliciting calling it date[1] and so on. The checkit function gets the "date[]" name and checks that date[] checkbox. </p>
<p>BTW, many thanks for the supplementary answers (I learned something new!) </p>
| [
{
"answer_id": 388339,
"author": "Andreas Grech",
"author_id": 44084,
"author_profile": "https://Stackoverflow.com/users/44084",
"pm_score": 1,
"selected": false,
"text": "function checkit(date)\n {\n var date = document.getElementById(date);\n date.checked = true;\n }\n<input ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47301/"
] |
388,344 | <p>I am modifying a Nant build script to run some unit tests. I have different targets for locally run tests and tests to be run on team city.</p>
<pre><code><target name="run-unit-tests">
<property name="test.executable" value="tools\nunit\nunit-console.exe"/>
<call target="do-unit-tests"/>
</target>
<target name="run-unit-tests-teamcity">
<property name="test.executable" value="${teamcity.dotnet.nunitlauncher}"/>
<call target="do-unit-tests"/>
</target>
</code></pre>
<p>in the target <strong>do-unit-tests</strong> I set up which test assemblies are run by setting a property and calling for NCover to do a code coverage run as follows:</p>
<pre><code><target name="do-unit-test">
<property name="test.assemblies" value="MyProject.dll">
<call target="do-unit-test-coverage" />
</target>
<target name="do-unit-test-coverage">
<ncover <!--snip -->
commandLineArgs="${test.args}"
<!--snip-->
</ncover>
</target>
</code></pre>
<p>As you can see in the ncover part I need a property called <em>"test.args"</em>. This property depends on <em>"test.assemblies"</em></p>
<p>ie: <code><property name="test.args" value="${test.assemblies} <!--snip -->" /></code></p>
<p>test.args needs to be <em>set up differently between the locally run unit test and the one on team city</em>...so I'm trying to figure out how to set this up.</p>
<p>if i put the property for test.args in "do-unit-test" after the property "test.assemblies" I can't specify one test.args if do-unit-test is called by run-unit-tests and another for run-unit-tests-teamcity.</p>
<p>I've been trying to do something like the following in "do-unit-test":</p>
<pre><code><if test="${target::exists('run-unit-tests-teamcity')}">
<property name="test.args" value="..." />
</if>
</code></pre>
<p>but obviously that doesn't work because the target will always exist.</p>
<p>What I'd like then is to test if my current target <strong>do-unit-test</strong> has been called by <strong>run-unit-tests-teamcity</strong></p>
<p>Is this possible? I can't see it in the Nant documentation? Since its not there it either means that it will be a feature in the future or that I'm not understanding how things are specified in a Nant build script.</p>
| [
{
"answer_id": 388425,
"author": "Stobor",
"author_id": 43452,
"author_profile": "https://Stackoverflow.com/users/43452",
"pm_score": 3,
"selected": true,
"text": "<target name=\"run-unit-tests\">\n <property name=\"test.executable\" value=\"tools\\nunit\\nunit-console.exe\"/>\n <pro... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39532/"
] |
388,353 | <p>I am working on an application that allows users to input Japanese language characters. I am trying to come up with a way to determine whether the user's input is a Japanese kana (hiragana, katakana, or kanji).</p>
<p>There are certain fields in the application where entering Latin text would be inappropriate and I need a way to limit certain fields to kanji-only, or katakana-only, etc.</p>
<p>The project uses UTF-8 encoding. I don't expect to accept JIS or Shift-JIS input.</p>
<p>Ideas?</p>
| [
{
"answer_id": 784775,
"author": "Assembler",
"author_id": 5503,
"author_profile": "https://Stackoverflow.com/users/5503",
"pm_score": 2,
"selected": false,
"text": "$pattern = '/[^\\wぁ-ゔァ-ヺー\\x{4E00}-\\x{9FAF}_\\-]+/u';\n"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/388353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18265/"
] |
388,356 | <p>What is the recommended way of including a Javascript file from another Javascript file?</p>
| [
{
"answer_id": 388363,
"author": "Ben",
"author_id": 11522,
"author_profile": "https://Stackoverflow.com/users/11522",
"pm_score": 0,
"selected": false,
"text": "<script type=\"text/javascript\">\n// Function to allow one JavaScript file to be included by another.\n// Copyright (C) 2006-... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388356",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48557/"
] |
388,357 | <p>I have a JfreeReport Application which run under Tomcat inside a jar. In the report template (which exists outside the jar) I have the following:
file:///var/lib/tomcat5.5/webapps/Reports/images/logo.gif
But then I get exception:
org.jfree.report.modules.ModuleInitializeException: Unable to create the specified directory.
Then I tried to use relative path but got FileNotFoundException.
I can't give a HTTP link for the file.
Any idea how to use relative path or file URL?</p>
| [
{
"answer_id": 388363,
"author": "Ben",
"author_id": 11522,
"author_profile": "https://Stackoverflow.com/users/11522",
"pm_score": 0,
"selected": false,
"text": "<script type=\"text/javascript\">\n// Function to allow one JavaScript file to be included by another.\n// Copyright (C) 2006-... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
388,358 | <p>I've been using HInclude (<a href="http://www.mnot.net/javascript/hinclude/" rel="nofollow noreferrer">http://www.mnot.net/javascript/hinclude/</a>) for sometime now and its working great, but there is one problem though. The part of my site which is fetched using HInclude doesn't get refreshed everytime I hit the back button in Internet Exploer (6.x + and 7.0 also). It works fine on other browsers. I've tried setting the cache-control and pragma controls in header to "no-Cache". but even that is not working. I want HInclude to pick up new content everytime a user clicks back button or re-visits a page with hx content on it. How do I do that?</p>
| [
{
"answer_id": 388363,
"author": "Ben",
"author_id": 11522,
"author_profile": "https://Stackoverflow.com/users/11522",
"pm_score": 0,
"selected": false,
"text": "<script type=\"text/javascript\">\n// Function to allow one JavaScript file to be included by another.\n// Copyright (C) 2006-... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44916/"
] |
388,359 | <p>The only distributed revision control system I've used on my projects is bazaar. I don't know much about git and mercurial except how to do checkouts. The reason I like bazaar is the automv plugin. It detects when I've moved/deleted files manualy (from command line/ide etc.) which I tend to do alot when I'm in a hurry. But bazaar is really slow and I'm thinking of moving to git. Does git have something similar to this functionality? </p>
| [
{
"answer_id": 388374,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 4,
"selected": true,
"text": "abc123... abc123..."
},
{
"answer_id": 389092,
"author": "Jörg W Mittag",
"author_id": 2988,
"author_p... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7883/"
] |
388,365 | <p>I'm trying to POST to the HTTP gateway of an SMS provider (Sybase 365) using CURL from a Linux shell script.</p>
<p>I need to pass the following data (note the [ ] and LF characters)</p>
<pre><code>[MSISDN]
List=+12345678
[MESSAGE]
Text=Hello
[END]
</code></pre>
<p>If I submit a file using the -F parameter, CURL removes the LF e.g.</p>
<pre><code>curl -F @myfile "http://www.sybase.com/..."
</code></pre>
<p>results in this at the server (which is rejected)</p>
<pre><code>[MSISDN]List=+12345678[MESSAGE]Text=Hello[END]
</code></pre>
<p>Is there anything I can do to avoid this or do I need an alternative tool?</p>
<p>I'm using a file containing my data for testing but I'd like to avoid that in practice and POST directly from the script.</p>
| [
{
"answer_id": 388373,
"author": "Athena",
"author_id": 17846,
"author_profile": "https://Stackoverflow.com/users/17846",
"pm_score": 4,
"selected": false,
"text": "--data-binary -d(ata-ascii) --data-binary"
},
{
"answer_id": 388488,
"author": "Robin Minto",
"author_id": ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1456/"
] |
388,375 | <p>Is it necessary to use "Nothing" keyword to initialize a DataSet in VB.NET?</p>
| [
{
"answer_id": 388391,
"author": "ChrisA",
"author_id": 24867,
"author_profile": "https://Stackoverflow.com/users/24867",
"pm_score": 2,
"selected": false,
"text": "Dim ds as New DataSet\n ds.Tables.Clear\n Dim ds as Dataset = nothing\n Dim ds as DataSet\n ds = Nothing\n"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/388375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48581/"
] |
388,394 | <p>I am writing a JSR-168 portlet that can be added to a container multiple times. Each container (Liferay, JBoss, etc.) has its own internal way of differentiating between multiple instantiations of the same portlet.</p>
<p>I, however, would like to uniquely identify my portlet instance inside the <code>doView()</code> method itself.</p>
<p>Is there any standard, JSR-168 mechanism to retrieve some unique identifier that's different for each instance of my portlet? I've seen various solutions where people <a href="http://mus.purplecloud.net/portlets/portlet_messaging_1/documentation.php" rel="nofollow noreferrer">randomly</a> <a href="http://www.archivum.info/jetspeed-dev@portals.apache.org/2008-08/msg00003.html" rel="nofollow noreferrer">generate</a> unique IDs and save them in the session, but I'd prefer a standard mechanism if one exists.</p>
| [
{
"answer_id": 388418,
"author": "Arne Burmeister",
"author_id": 12890,
"author_profile": "https://Stackoverflow.com/users/12890",
"pm_score": 0,
"selected": false,
"text": "javax.portlet.PortletRequest#getPortletSession() portlet.xml javax.servlet.http.HttpSession java.lang.System#ident... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5309/"
] |
388,434 | <p>How do i unset a already set flag using fcntl?</p>
<p>For e.g. I can set the socket to nonblocking mode using </p>
<pre><code>fcntl(sockfd, F_SETFL, flags | O_NONBLOCK)
</code></pre>
<p>Now, i want to unset the O_NONBLOCK flag.</p>
<p>I tried fcntl(sockfd, F_SETFL, flags | ~O_NONBLOCK). It gave me error EINVAL</p>
| [
{
"answer_id": 388441,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 4,
"selected": true,
"text": "int oldfl;\noldfl = fcntl(sockfd, F_GETFL);\nif (oldfl == -1) {\n /* handle error */\n}\nfcntl(sockfd, F_SETFL, oldfl & ~O... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39615/"
] |
388,436 | <p>I have some jQuery code. I have called an Ajax function file, file.php, that has some fields, like:</p>
<pre><code><input type="radio" value="plz">Milk</input>.
</code></pre>
<p>Will I assign into again jQuery function? If so, how do I do it? I attached a sample file:</p>
<pre><code><html>
<head>
<LINK REL=StyleSheet HREF="examples.css" TITLE="Contemporary" TYPE="text/css">
<script src="jquery-1.2.6.js" type="text/javascript"></script>
<script src="jquery-impromptu.1.6.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$.ajax({
type:"GET",
url:"file.php",
data:id,
success:function(){
var txt=id;
$.prompt( txt,{ opacity: 0.2 });
},
error:function(){
window.location("ERRoR");
}
});
});
</script>
<body>
</body>
</html>
</code></pre>
| [
{
"answer_id": 388450,
"author": "Athena",
"author_id": 17846,
"author_profile": "https://Stackoverflow.com/users/17846",
"pm_score": 5,
"selected": true,
"text": "success $(document).ready(\n function(){ $.ajax({\n type:\"GET\",\n url:\"file.php\",\n data:id,\n ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/44984/"
] |
388,439 | <p>Java 5 introduced generics, and they were added to many interfaces in the <code>java.lang</code> package. However, <code>Cloneable</code> did not get generics. I wonder why?</p>
<hr>
<p><strong>Edit:</strong> In reply to the answers of @Jon and @litb, and the comment of @Earwicker, I was thinking <code>Cloneable</code> might be:</p>
<pre><code>public interface Cloneable<T> {
public T clone();
}
</code></pre>
<p>Here <code>T clone();</code> overrides <code>Object.clone()</code>, giving it a covariant type. I believe this would still be backwards compatible and increase type safety. So why not?</p>
<hr>
<p><strong>Edit 2:</strong> As can be seen in the answers (and comments) below, the interface suggested above would break backwards-compatibility. Since <code>Object.clone()</code> is <code>protected</code>, rewriting it in the interface would force all implementers to provide a <code>public</code> implementation, which class designers might not want to (i.e. they might opt to keep it <code>protected</code>).</p>
| [
{
"answer_id": 388449,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 3,
"selected": false,
"text": "java.lang.Cloneable if(!(this instanceof Cloneable))\n throw...;\n"
},
{
"answer_id": 392002,
... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388439",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41283/"
] |
388,461 | <p>Is there some easy way to pad Strings in Java?</p>
<p>Seems like something that should be in some StringUtil-like API, but I can't find anything that does this.</p>
| [
{
"answer_id": 388476,
"author": "GaryF",
"author_id": 1035,
"author_profile": "https://Stackoverflow.com/users/1035",
"pm_score": 9,
"selected": true,
"text": "StringUtils leftPad rightPad center repeat String.format() Formatter"
},
{
"answer_id": 388479,
"author": "Miserabl... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15355/"
] |
388,464 | <p>I'm creating a function where I need to pass an object so that it can be modified by the function. What is the difference between:</p>
<pre><code>public void myFunction(ref MyClass someClass)
</code></pre>
<p>and</p>
<pre><code>public void myFunction(out MyClass someClass)
</code></pre>
<p>Which should I use and why?</p>
| [
{
"answer_id": 388465,
"author": "Ruben Bartelink",
"author_id": 11635,
"author_profile": "https://Stackoverflow.com/users/11635",
"pm_score": 5,
"selected": false,
"text": "out"
},
{
"answer_id": 388467,
"author": "Rune Grimstad",
"author_id": 30366,
"author_profile"... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388464",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1816/"
] |
388,468 | <p>I am using the ListView Control with the following datasource <code>List<MyObject></code></p>
<p>On my listview control i have an OnItemDataBound</p>
<p></p>
<p>My question is how do get the current value of MyObject. Ie myObj[5].FirstName</p>
<p>protected void ItemsListViewDataBound(object sender, ListViewItemEventArgs e)
{
// I want to do some kind of a cast here </p>
<p>}</p>
| [
{
"answer_id": 388509,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 5,
"selected": true,
"text": "protected void MyListView_DataBind(object sender, ListViewItemEventArgs e){\n if(e.Item.ItemType == ListViewItemType.... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/461880/"
] |
388,483 | <p>I'm trying to use the <code>Html.DropDownList</code> extension method but can't figure out how to use it with an enumeration.</p>
<p>Let's say I have an enumeration like this:</p>
<pre><code>public enum ItemTypes
{
Movie = 1,
Game = 2,
Book = 3
}
</code></pre>
<p>How do I go about creating a dropdown with these values using the <code>Html.DropDownList</code> extension method?</p>
<p>Or is my best bet to simply create a for loop and create the Html elements manually?</p>
| [
{
"answer_id": 388590,
"author": "Garry Shutler",
"author_id": 6369,
"author_profile": "https://Stackoverflow.com/users/6369",
"pm_score": 3,
"selected": false,
"text": "Enum.GetValues"
},
{
"answer_id": 388704,
"author": "Ash",
"author_id": 31128,
"author_profile": "... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1574/"
] |
388,490 | <p>We have a project in Team Foundation Server (TFS) that has a non-English character (š) in it. When trying to script a few build-related things we've stumbled upon a problem - we can't pass the <strong>š</strong> letter to the command-line tools. The command prompt or what not else messes it up, and the <strong>tf.exe</strong> utility can't find the specified project.</p>
<p>I've tried different formats for the .bat file (ANSI, UTF-8 with and without <a href="http://en.wikipedia.org/wiki/Byte_order_mark" rel="noreferrer">BOM</a>) as well as scripting it in JavaScript (which is Unicode inherently) - but no luck. How do I execute a program and pass it a <strong>Unicode</strong> command line?</p>
| [
{
"answer_id": 388500,
"author": "kgiannakakis",
"author_id": 24054,
"author_profile": "https://Stackoverflow.com/users/24054",
"pm_score": 9,
"selected": false,
"text": "chcp 65001\n"
},
{
"answer_id": 3556411,
"author": "vanna",
"author_id": 429520,
"author_profile"... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41360/"
] |
388,492 | <p>When I visually scale an image, Firefox 3 blurs it. Firefox 2 and other browsers don't, which is the behavior I expect. This is especially lame for creating a web based game using png or gif sprites.</p>
<p>For example, when showing a 100x100 image in Firefox 3 like this:</p>
<pre><code><img src="sprite.gif" width="200" />
</code></pre>
<p>or</p>
<pre><code><img src="sprite.gif" style="width:200px; height:200px;" />
</code></pre>
<p>it looks blurred in FF3, not in IE.</p>
<p>Any ideas on how to prevent this?</p>
| [
{
"answer_id": 767664,
"author": "Martin Kool",
"author_id": 48595,
"author_profile": "https://Stackoverflow.com/users/48595",
"pm_score": 6,
"selected": true,
"text": "image-rendering: -moz-crisp-edges;\n"
},
{
"answer_id": 3173765,
"author": "Jan Goyvaerts",
"author_id"... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48595/"
] |
388,493 | <p>How can we avoid Master Page from posting back the whole page?</p>
| [
{
"answer_id": 388966,
"author": "BenAlabaster",
"author_id": 40650,
"author_profile": "https://Stackoverflow.com/users/40650",
"pm_score": 2,
"selected": false,
"text": "<asp:UpdatePanel id=\"MyUpdatePanel\" runat=\"server\" ChildrenAsTriggers=\"True\">\n <ContentTemplate>\n ...Stuf... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48581/"
] |
388,497 | <pre><code>select
(Case Remark01
When 'l1' then type1
when 'l2' then type2
end) AS [?] --Remark .....want to switch name in here
from mytable
</code></pre>
<p>Example ....</p>
<pre><code>select
(Case level
When 'l1' then type1 ('l1' mean check constant string)
when 'l2' then type2(('l2' mean check constant string))
end) AS <b>(Case when 'l1' then [type01] Else [type02])</b>
from mytable
</pre>
<pre>select level,type1,type2 from mytable
</code></pre>
<p>I using two program this mytable<br>
one program is want to show menu only type1 only<br>
one program is want to show menu only type2 only<br>
I using one view using two program..</p>
| [
{
"answer_id": 388966,
"author": "BenAlabaster",
"author_id": 40650,
"author_profile": "https://Stackoverflow.com/users/40650",
"pm_score": 2,
"selected": false,
"text": "<asp:UpdatePanel id=\"MyUpdatePanel\" runat=\"server\" ChildrenAsTriggers=\"True\">\n <ContentTemplate>\n ...Stuf... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
388,506 | <p>I'd like to display splash screen while the application is loading. However some 3rd party components block main thread during initilization for several seconds, which causes all forms not to update. Is it possible to have splash screen with own thread so it would update also when main thread is busy?</p>
<p>The application is win32 and Delphi version 2007.</p>
<p>Edit: I'm trying to avoid "undrawn splash screen" effect, which happens if some other windows (from other applications) are on the top of splash screen, eg alt-tabbing to another application and back.</p>
| [
{
"answer_id": 388826,
"author": "Jim McKeeth",
"author_id": 255,
"author_profile": "https://Stackoverflow.com/users/255",
"pm_score": 2,
"selected": false,
"text": "begin\n Application.Initialize;\n SplashForm := TSplashForm.Create(nil);\n try\n SplashForm.FormStyle := fsStayOnTop... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7735/"
] |
388,510 | <p>Is there any possiblity to read a .config file in a dll assembly? At the moment I use OpenExeConfiguration on a Assembly.Location Property which seems to work. But I want to create separate .config files for different usages like ConfigModuleA.config, ConfigModuleB.config etc. </p>
<p>Any idea? </p>
| [
{
"answer_id": 388520,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 1,
"selected": false,
"text": "configSource"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/388510",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43913/"
] |
388,517 | <p>Is there a way to configure the directory where all the configuration files are stored by IntelliJ IDEA (version 8.0.1)?</p>
<p>By default, these files are stored in <em>%home%</em>\.IntelliJIdea80... (or .IdeaIC12 etc.), but I want to define another location...</p>
| [
{
"answer_id": 388536,
"author": "krosenvold",
"author_id": 23691,
"author_profile": "https://Stackoverflow.com/users/23691",
"pm_score": 6,
"selected": true,
"text": "%idea installation directory%\\bin\\idea.properties %home%"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/388517",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26457/"
] |
388,554 | <p>Is there any possibility how to enumerate AppDomains within Process?</p>
| [
{
"answer_id": 388582,
"author": "Brann",
"author_id": 47341,
"author_profile": "https://Stackoverflow.com/users/47341",
"pm_score": 7,
"selected": true,
"text": "using System.Runtime.InteropServices;\n// Add the following as a COM reference - C:\\WINDOWS\\Microsoft.NET\\Framework\\vXXXX... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43178/"
] |
388,555 | <p>in a script when error comes i am just using "EXITGLOBALITERATION" command but its not going to the next iteration ....Is there any other alternative for this??</p>
| [
{
"answer_id": 389015,
"author": "Tester101",
"author_id": 38695,
"author_profile": "https://Stackoverflow.com/users/38695",
"pm_score": 0,
"selected": false,
"text": "\nOn Error Resume Next\nFor i = 0 To 10\n 'Command1\n If Err.Number = 0 Then\n 'Command2\n If Err.Number = 0 Th... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46565/"
] |
388,556 | <p>I have an action method that that returns a PagedList<> after a form's POST request.<br>
I would like to add paging to this page, but all paging scenarios only seem to work with GET requests.</p>
<p>Currently the only way of adding paging controls is adding a bunch of forms with one button for navigating the page. This will look but ugly (all form buttons) and impose a lot of overhead because each of the forms will need a bunch of hidden fields (about 10) to transfer the needed parameters.</p>
<p>Is there a clean way to add about 12 optional parameters to a GET request?
Or maybe there is an even better way?</p>
| [
{
"answer_id": 389549,
"author": "Todd Smith",
"author_id": 31624,
"author_profile": "https://Stackoverflow.com/users/31624",
"pm_score": 1,
"selected": false,
"text": "function GoToPage(pageNumber)\n{\n // submit form along with pageNumber\n\n return false;\n}\n\n<a href=\"javascr... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11333/"
] |
388,557 | <p>I like .NET webcontrols and you manipulate things, that's common consensus, but XML and XSL is so great, because you have UI logic that is platform & language-independent, so one day I change the app to php, java or whatever and i can reuse all the presentation logic.
Moreover, XSL has the possibility to call .NET (or whatever) methods before rendering.</p>
<p>When do you use XML/XSL normally? why no to use it more frequently?</p>
| [
{
"answer_id": 388605,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "<%=foo.Name%> <xsl:value-of select=\"Name\"/>"
},
{
"answer_id": 388626,
"author": "annakata",
"autho... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31791/"
] |
388,561 | <p>thank you. here is the correct question:</p>
<pre><code>{
"VID":"60",
"name":"\u4f1a\u9634",
"requireLevel":"20",
"levelMax":"5",
"venationRequirement":"0",
"description":"\u6c14\u6d77\u4e0a\u9650\u63d0\u9ad8[Affect1]\u70b9",
"cost":{"1":"240","2":"360","3":"400","4":"600","5":"720"},
"difficult":{"1":"1024","2":"973","3":"921","4":"870","5":"819"},
"affect":{"1":"200","2":"500","3":"900","4":"1400","5":"2000"},
"descriptions":{
"1":"\u6c14\u6d77\u4e0a\u9650\u63d0\u9ad8200\u70b9",
"2":"\u6c14\u6d77\u4e0a\u9650\u63d0\u9ad8500\u70b9",
"3":"\u6c14\u6d77\u4e0a\u9650\u63d0\u9ad8900\u70b9",
"4":"\u6c14\u6d77\u4e0a\u9650\u63d0\u9ad81400\u70b9",
"5":"\u6c14\u6d77\u4e0a\u9650\u63d0\u9ad82000\u70b9"
}
}
</code></pre>
<p>i used json_encode() in php ,and ajax request to get the response text.</p>
<h2>but when i use eval() to parse the response text. it's wrong.</h2>
<p>moonshadow and james gregory has answered this question at the comments below.thank you again.</p>
| [
{
"answer_id": 388568,
"author": "James Gregory",
"author_id": 27206,
"author_profile": "https://Stackoverflow.com/users/27206",
"pm_score": 2,
"selected": false,
"text": "var s = '{\"first\": {\"a\":1}, \"second\": {\"b\":2}}';\n"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/388561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
388,565 | <p>We have some web pages which have two frames, with one frame in the IE 6 search bar (created using the <code>open("path.htm", "_search");</code> call). The page shown in the frame on the search bar contains buttons, on click of which we update the right frame. On migration to IE 7, both frames open in their own windows, i.e, I now have two windows open.</p>
<p>On searching the Net, I found that IE 7 has disabled the IE search bar because of security concerns. I guess this is because they now have moved the search text box to the top right, <em>à la</em> Firefox.</p>
<p>My question is, I still need the two frames. So what should I do - I have been toying with the idea of using <code><frameset></code> tags, but just thought I'd post to the community to see what other options there are.</p>
<p>NOTE: I <em>did</em> search the Internet, but couldn't really come up with other options.</p>
| [
{
"answer_id": 388568,
"author": "James Gregory",
"author_id": 27206,
"author_profile": "https://Stackoverflow.com/users/27206",
"pm_score": 2,
"selected": false,
"text": "var s = '{\"first\": {\"a\":1}, \"second\": {\"b\":2}}';\n"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/388565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9195/"
] |
388,585 | <p>I have quite a few RewriteRules in my .htaccess that looks like this</p>
<pre><code>RewriteRule ^something/(\d+)/start /index.php?ix=$1
RewriteRule ^embed/something/(\d+)/start /index.php?ix=$1&fEmbed=1
</code></pre>
<p>The only difference between these two is the leading "embed/", so I was thinking it would be beneficial to combine these into a single RewriteRule. My attempts are stuck at</p>
<pre><code>RewriteRule ^(embed/)?something/(\d+)/start /index.php?ix=$2&fEmbed=$1
</code></pre>
<p>Which sets "&fEmbed=embed/", which really is not what I want. I want to evaluate the contents of $1, and output something different (namely "1").</p>
<p>Any ideas of how to approach this while combining the first two RewriteRules into a single RewriteRule?</p>
| [
{
"answer_id": 388603,
"author": "PEZ",
"author_id": 44639,
"author_profile": "https://Stackoverflow.com/users/44639",
"pm_score": 2,
"selected": true,
"text": "RewriteRule ^(embed/)?something/(\\d+)/start$ /index.php?ix=$2\nRewriteRule ^embed/(.*) $1&fEmbed=1\n RewriteRule ^embed/... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1606/"
] |
388,591 | <p>In my application data is stored in a .config file,(in XML format). User is able to set date on which he wants mail (like reminder through mail). So there should be a scheduler which will execute daily to send mails on target date to users. As there is no database interaction how is it possible to run scheduler?</p>
<p>I am totally blank about this task. Can anyone help me? </p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 389423,
"author": "user48691",
"author_id": 48691,
"author_profile": "https://Stackoverflow.com/users/48691",
"pm_score": 1,
"selected": false,
"text": "<code>\n<%@ Application Language=\"C#\" %>\n\n<script runat=\"server\">\n\n private const string DeliveryPageUrl = \"... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/43886/"
] |
388,595 | <p>What advantages do either method offer for html, css and javascript files served by a LAMP server. Are there better alternatives?</p>
<p>The server provides information to a map application using Json, so a high volume of small files.</p>
<p><strong>See also <a href="https://stackoverflow.com/questions/211284/is-there-any-performance-hit-involved-in-choosing-gzip-over-deflate-for-http-co">Is there any performance hit involved in choosing gzip over deflate for http compression?</a></strong></p>
| [
{
"answer_id": 777444,
"author": "aidan",
"author_id": 71062,
"author_profile": "https://Stackoverflow.com/users/71062",
"pm_score": -1,
"selected": false,
"text": "a2enmod deflate\n/etc/init.d/apache2 force-reload\n"
},
{
"answer_id": 9856879,
"author": "Sam Saffron",
"a... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20074/"
] |
388,599 | <p>When transmitting data, the Hamming code apparently allows you to recreate data that has been corrupted over the wire (an error correcting code).</p>
<p>How does this work and what are its limitations, if any?</p>
<p>Are there any better solutions for error correction (as opposed to retransmission)? Are there circumstances where retransmission is better?</p>
| [
{
"answer_id": 388669,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 6,
"selected": true,
"text": "000 --------001\n | \\ | \\\n | 100---------101\n | | | |\n | | | |\n010-|-------011 |\n \... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14860/"
] |
388,615 | <p>If i need to find out the size of a tcp packet on BSD.....what do we need to do?</p>
<p>Is there some utility which allows for this?</p>
| [
{
"answer_id": 388647,
"author": "Can Berk Güder",
"author_id": 2119,
"author_profile": "https://Stackoverflow.com/users/2119",
"pm_score": 1,
"selected": false,
"text": "tcpdump"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/388615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35416/"
] |
388,624 | <p>I am trying to implement a ListView data control for displaying and editing lookup table/ application level variables. There are multiple entity classes which can be bound to the ListView, so the ItemTemplate needs to be dynamically bound to the selected entity object.</p>
<p>For example i have: </p>
<pre><code>AddressType { AddressTypeId, AddressTypeDescription},
PhoneType { PhoneTypeId, PhoneType},
MarriageStatusType { MarriageStatusId, marriageStatusType}
</code></pre>
<p>Those generated entity objects prevent me from simply doing something like the following snippet, because the ID and Type properties are different on each business object.</p>
<pre><code><ListView>
...
<itemTemplate>
<tr>
<td runat="server" id="tdId"> <%# Eval("ID") %> </td>
<td runat="server" id="tdType"> <%# Eval("TypeNameDescription") %> </td>
</tr>
</itemTemplate>
...
</ListView>
</code></pre>
<p>I am trying to discover :
1. How to iterate over the ListView Items to insert the appropriate property value into the server side html td tags.
2. How to use Databinder.Eval on the ListView items to insert that property value.</p>
<p>Thanks in advance!</p>
| [
{
"answer_id": 388684,
"author": "flesh",
"author_id": 27805,
"author_profile": "https://Stackoverflow.com/users/27805",
"pm_score": 3,
"selected": true,
"text": "<asp:ListView ID=\"parentList\" runat=\"server\">\n <ItemTemplate>\n <asp:Repeater ID=\"childData\" runat=\"server\" D... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35286/"
] |
388,642 | <p>I have a repeater that should show a bound field value only if it exists. Having read <a href="https://stackoverflow.com/questions/368169/conditional-logic-in-aspnet-page">this post</a> I decided to do it by using a literal within my repeater and using the OnItemDatabound trigger to populate my literal but my literal doesn't seem to be accessible from the c# code behind and I don't understand why!</p>
<p>Heres the aspx page</p>
<pre><code> <asp:Repeater runat="server" ID="rpt_villaresults" OnItemDataBound="checkForChildren">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
//.................MORE CODE HERE......................
<div class="sleeps"><h4>To Sleep</h4><h5><%#Eval("sleeps")%> <asp:Literal ID="sleepsChildrenLit" runat="server" /> </h5></div>
//.............MORE CODE HERE........................
</code></pre>
<p>And the code behind</p>
<pre><code>public void checkForChildren(object sender, RepeaterItemEventArgs e)
{
Literal childLit = e.Item.FindControl("sleepsChildrenLit") as Literal;
//this is null at runtime
String str = e.Item.DataItem.ToString();
if (e.Item.DataItem != null)
{
if (Regex.IsMatch(str, "[^0-9]"))
{
if (Convert.ToInt32(str) > 0)
{
childLit.Text = " + " + str;
}
}
}
}
</code></pre>
| [
{
"answer_id": 388684,
"author": "flesh",
"author_id": 27805,
"author_profile": "https://Stackoverflow.com/users/27805",
"pm_score": 3,
"selected": true,
"text": "<asp:ListView ID=\"parentList\" runat=\"server\">\n <ItemTemplate>\n <asp:Repeater ID=\"childData\" runat=\"server\" D... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40623/"
] |
388,646 | <p>Is there a way to debug javascript using Safari 3.2 in Windows Vista? </p>
<p>I found a <a href="http://pietschsoft.com/post/2007/12/Safari-3-for-Windows-Enable-JavaScript-Debugging.aspx" rel="noreferrer">link</a> to a debugger named Drosera but I can't get it to work because the information seams to be outdated. </p>
| [
{
"answer_id": 7388732,
"author": "RYFN",
"author_id": 21200,
"author_profile": "https://Stackoverflow.com/users/21200",
"pm_score": 4,
"selected": false,
"text": "develop menu Show Web Inspector"
},
{
"answer_id": 45484182,
"author": "kenorb",
"author_id": 55075,
"au... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25960/"
] |
388,650 | <p>I want to check the following with regular expression</p>
<pre><code>{Today,Format}
</code></pre>
<p>Today - will be remains as it is.
In the place of Format, we can allow the digits from 0 to 12.</p>
<p>for example: we have to allow</p>
<pre><code>{Today,0}
{Today,1}
{Today,2}
...
{Today,12}
</code></pre>
<p>and also have to allow </p>
<pre><code>{Today,}
{Today,Format}
</code></pre>
<p>Please help me and also refer me to some site to develop my regular expression skills.</p>
| [
{
"answer_id": 388663,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 4,
"selected": false,
"text": "\\{Today,(\\d|1[012]|Format)?\\}\n"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/388650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38172/"
] |
388,673 | <p>What is the best (date format independent way) in PHP to calculate difference in days between two dates in specified format.</p>
<p>I tried the following function:</p>
<pre><code>function get_date_offset($start_date, $end_date)
{
$start_time = strtotime($start_date);
$end_time = strtotime($end_date);
return round(($end_time-$start_time)/(3600*24));
}
</code></pre>
<p>It works ok on linux box, but when running under windows strtotime returns ''.</p>
<p><strong>EDIT</strong>:</p>
<p>Input date is in <strong>mm/dd/yyyy</strong> format, but I would like to make it accept $format as a parameter.</p>
<p>I need only difference in days.</p>
| [
{
"answer_id": 388884,
"author": "Ole Helgesen",
"author_id": 21892,
"author_profile": "https://Stackoverflow.com/users/21892",
"pm_score": 2,
"selected": false,
"text": "// example printing difference in days\nrequire('Zend/Date.php');\n\n$date1 = new Zend_Date();\n$date1->set(2, Zend_D... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31141/"
] |
388,677 | <p>I have a multi-browser page that shows vertical text.</p>
<p>As an ugly hack to get text to render vertically in all browsers I've created a custom page handler that returns a PNG with the text drawn vertically.</p>
<p>Here's my basic code (C#3, but small changes to any other version down to 1):</p>
<pre><code>Font f = GetSystemConfiguredFont();
//this sets the text to be rotated 90deg clockwise (i.e. down)
StringFormat stringFormat = new StringFormat { FormatFlags = StringFormatFlags.DirectionVertical };
SizeF size;
// creates 1Kx1K image buffer and uses it to find out how bit the image needs to be to fit the text
using ( Image imageg = (Image) new Bitmap( 1000, 1000 ) )
size = Graphics.FromImage( imageg ).
MeasureString( text, f, 25, stringFormat );
using ( Bitmap image = new Bitmap( (int) size.Width, (int) size.Height ) )
{
Graphics g = Graphics.FromImage( (Image) image );
g.FillRectangle( Brushes.White, 0f, 0f, image.Width, image.Height );
g.TranslateTransform( image.Width, image.Height );
g.RotateTransform( 180.0F ); //note that we need the rotation as the default is down
// draw text
g.DrawString( text, f, Brushes.Black, 0f, 0f, stringFormat );
//make be background transparent - this will be an index (rather than an alpha) transparency
image.MakeTransparent( Color.White );
//note that this image has to be a PNG, as GDI+'s gif handling renders any transparency as black.
context.Response.AddHeader( "ContentType", "image/png" );
using ( MemoryStream memStream = new MemoryStream() )
{
image.Save( memStream, ImageFormat.Png );
memStream.WriteTo( context.Response.OutputStream );
}
}
</code></pre>
<p>This creates an image that looks how I want it to, except that the transparency is index based. As I'm returning a PNG it could support a proper alpha transparency.</p>
<p>Is there any way to do this in .net?</p>
<hr>
<p>Thanks to Vlix (see comments) I've made some changes, though it still isn't right:</p>
<pre><code>using ( Bitmap image = new Bitmap( (int) size.Width, (int) size.Height, PixelFormat.Format32bppArgb ) )
{
Graphics g = Graphics.FromImage( (Image) image );
g.TranslateTransform( image.Width, image.Height );
g.RotateTransform( 180.0F ); //note that we need the rotation as the default is down
// draw text
g.DrawString( text, f, Brushes.Black, 0f, 0f, stringFormat );
//note that this image has to be a PNG, as GDI+'s gif handling renders any transparency as black.
context.Response.AddHeader( "ContentType", "image/png" );
using ( MemoryStream memStream = new MemoryStream() )
{
//note that context.Response.OutputStream doesn't support the Save, but does support WriteTo
image.Save( memStream, ImageFormat.Png );
memStream.WriteTo( context.Response.OutputStream );
}
}
</code></pre>
<p>Now the alpha appears to work, but the text appears blocky - as if it still has the jaggie edges but against a black background.</p>
<p>Is this some bug with .Net/GDI+? I've already found that it fails for even index transparencies for gifs, so I don't have much confidence it it.</p>
<p>This image shows the two ways this goes wrong:</p>
<p><img src="https://i.stack.imgur.com/ONFOT.png" alt="vertical text comparison"></p>
<p>The top image shows it with no white background or <code>MakeTransparent</code> call. The second with the background filled with white and then <code>MakeTransparent</code> called to add the index transparency.</p>
<p>Neither of these is correct - the second image has white aliasing jaggies that I don't want, the first appears to be solidly aliased against black.</p>
| [
{
"answer_id": 820410,
"author": "pmcilreavy",
"author_id": 88289,
"author_profile": "https://Stackoverflow.com/users/88289",
"pm_score": 5,
"selected": true,
"text": "g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;\n Graphics g = Graphics.FromImage( (Image)... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/905/"
] |
388,686 | <p>private int DBUpdate()
{</p>
<pre><code>DAL dal = new DAL();
string upd = "UPDATE [RPform] SET [ProjectName] = '@pname', [ProjectCode] = '@pcode', [Country] = @cnt, ";
upd += "[StartDate] = '@startdate', [FinishDate] = '@finishdate', [TotalParticipants] = @totpart, [ArrivalDate] = '@arrivedate', ";
upd += "[AirportTransfer] = @airtran, [AirportDate] = '@airdate', [AirportHours] = @airhour, [AirportMinutes] = @airmin, ";
upd += "[Problems] = '@problems', [FirstDayActivities] = '@fdayact' ";
upd += "WHERE [UserID]=@usid";
OleDbParameter[] parm = new OleDbParameter[] {
new OleDbParameter("@pname",projname.Text),
new OleDbParameter("@pcode",projcode.Text),
new OleDbParameter("@cnt",countries.SelectedIndex),
new OleDbParameter("@startdate",datestart.Text),
new OleDbParameter("@finishdate",datefinish.Text),
new OleDbParameter("@totpart",totalparticipants.Text),
new OleDbParameter("@arrivedate",datearrival.Text),
new OleDbParameter("@airtran",RadioButtonList1.SelectedValue),
new OleDbParameter("@airdate",dateairport.Text),
new OleDbParameter("@airhour",airporthours.SelectedIndex),
new OleDbParameter("@airmin",airportminutes.SelectedIndex),
new OleDbParameter("@problems",problems.Value),
new OleDbParameter("@fdayact",firstday.Value),
new OleDbParameter("@usid",user.ID)
};
return (dal.UpdateRow(upd,false,parm));
}
</code></pre>
<p>/// It causes no exceptions, but returns 0 rows affected. When same query executed from within MS Access it works fine. Hence I suppose the problem is sth with the handling of parameters ... but what? Thank you</p>
<hr>
<p>Sergio: is this OK, for setting OleDbTypes explicitly?</p>
<pre><code>///whatever ...
new OleDbParameter("@problems",problems.Value),
new OleDbParameter("@fdayact",firstday.Value),
new OleDbParameter("@usid",user.ID)
};
//then telling each one what they will be ...
parm[0].OleDbType = OleDbType.VarWChar;
parm[1].OleDbType = OleDbType.VarWChar;
///
return (dal.UpdateRow(upd,false,parm));
</code></pre>
| [
{
"answer_id": 388712,
"author": "Nelson Reis",
"author_id": 29544,
"author_profile": "https://Stackoverflow.com/users/29544",
"pm_score": 3,
"selected": false,
"text": "[StartDate] = '@startdate'\n"
},
{
"answer_id": 388771,
"author": "sgwill",
"author_id": 1204,
"au... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
388,687 | <p>I have a database for an E-commerce storefront. MSSQL 2008.</p>
<p>I have a table called Products and a table called Tags. This is a many to many relationship that is bound together by a table called ProductTags.</p>
<p>Products:<br>
id, name, price</p>
<p>Tags:<br>
id, name, sortorder, parentid(allow nulls)</p>
<p>ProductTags:<br>
productid, tagid</p>
<p>I'm trying to create a View in SQL, but I just completely suck at writing SQL.</p>
<p>The View should consist of:<br>
Tags.id, Tags.Name, Tags.sortorder, Tags.parentid, ProductCount, ChildTagCount</p>
<p>ProductCount is the number of products associated to this Tag.
ChildTagCount is the number of Tags that has this Tag's id as its parentid.</p>
| [
{
"answer_id": 388695,
"author": "Frans Bouma",
"author_id": 44991,
"author_profile": "https://Stackoverflow.com/users/44991",
"pm_score": 1,
"selected": false,
"text": "Select T.id, T.Name, T.sortorder, T.parentid, \n(select count(*) from productstags where tagid=T.TagId) as ProductCoun... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2972/"
] |
388,699 | <p>I am doing some research on .NET security. The most of sources just describe .NET security mechanisms but no even a word of possible vulnerabilities or things to be kept in mind. Do you know any security problems on .NET platform?</p>
| [
{
"answer_id": 5360069,
"author": "RandomNickName42",
"author_id": 67819,
"author_profile": "https://Stackoverflow.com/users/67819",
"pm_score": 0,
"selected": false,
"text": "delegate void AnotherDelegate(Union1 u2); \n\n static Union1 TypeSystemHole(Union2 u2)\n {\n Union1 u... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
388,708 | <p>I have a method which is given the parameter "bool sortAscending". Now I want to use LINQ to create sorted list depending on this parameter. I got then this:</p>
<pre><code>var ascendingQuery = from data in dataList
orderby data.Property ascending
select data;
var descendingQuery = from data in dataList
orderby data.Property descending
select data;
</code></pre>
<p>As you can see, both queries differ only in "ascending" resp. "descending". I'd like to merge both queries, but I don't know how. Does anyone have the answer?</p>
| [
{
"answer_id": 388716,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 5,
"selected": false,
"text": "var qry = from .... // or just dataList.AsEnumerable()/AsQueryable()\n\nif(sortAscending) {\n qry = qry.OrderBy(x=... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48621/"
] |
388,715 | <p>How do you transfer a worksheet from one excel app(1) to another(2) if you have two excel apps open using VBA?</p>
<p>The problem is, the programmer uses JavaScript, and when you click on the button that transfers the web data to a xl workbook, it opens a new Excel app.</p>
<p>I know part of the code would be:</p>
<pre><code>Workbooks.Add
ActiveSheet.Paste
' Once I returned to the original , i.e. excel app(1).
</code></pre>
| [
{
"answer_id": 388750,
"author": "Stewart Johnson",
"author_id": 6408,
"author_profile": "https://Stackoverflow.com/users/6408",
"pm_score": 3,
"selected": false,
"text": "Dim sourceSheet As Worksheet\nDim destSheet As Worksheet\n\n'' copy from the source\nWorkbooks.Open Filename:=\"c:\\... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
388,718 | <p>I have two implementations of a method, one for value types and another for reference types:</p>
<pre><code>public static Result<T> ImplRef(T arg) where T : class {...}
public static Result<T> ImplVal(T arg) where T : struct {...}
</code></pre>
<p>I want to write a method which calls the correct implementation like this</p>
<pre><code>public static Result<T> Generic(T arg) {
if (typeOf(T).IsValueType)
return ImplVal(arg);
else
return ImplRef(arg);
}
</code></pre>
<p>Obviously, the above implementation doesn't compile. How can I do this with minimum of reflection?</p>
| [
{
"answer_id": 388723,
"author": "Stewart Johnson",
"author_id": 6408,
"author_profile": "https://Stackoverflow.com/users/6408",
"pm_score": 0,
"selected": false,
"text": "typeof"
},
{
"answer_id": 388726,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9204/"
] |
388,748 | <p>I'm using SSRS 2005 to produce a report, and one of the columns in my report is a simple mean calculation. I don't want to divide by zero, so for the textbox value I have put: </p>
<p><code>=Switch(Fields!Count.Value=0,0,Fields!Count.Value>0,Fields!Sum.Value/Fields!Count.Value)</code></p>
<p>This still evaluates the second expression.</p>
<p>And so does:</p>
<p><code>=IIF(Fields!Count.Value=0,0,Fields!Sum.Value/Fields!Count.Value)</code></p>
<p>I don't want my report to display errors. How can I overcome this issue?</p>
| [
{
"answer_id": 388938,
"author": "HectorMac",
"author_id": 1400,
"author_profile": "https://Stackoverflow.com/users/1400",
"pm_score": 2,
"selected": false,
"text": "Public Function GetMeanValue(ByVal Sum as Decimal, ByVal Count As Int) As Decimal\n 'your logic in plain old vb syntax ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1116/"
] |
388,763 | <p>I have a relationship between two tables, authors and styles.
Every author is associated with a style, with the special case where an author doesn't have a style (IS NULL).</p>
<p>There's no problem in setting the reference to NULL, but there's a problem doing a query to select the authors and styles.</p>
<p>For example, the query: </p>
<pre><code>SELECT "authors"."id", "authors"."name", "styles"."name", "authors"."comments" FROM
"authors" , "styles" WHERE "authors"."style" = "styles"."id"
</code></pre>
<p>just ignores the authors that have a NULL style (as expected).</p>
<p>I need to do a select that also lists authors with NULL style, like a left join would do (I can't use LEFT JOIN fo some reasons).</p>
<p>There's a solution that doesn't include explicit joins? </p>
| [
{
"answer_id": 388770,
"author": "DanSingerman",
"author_id": 43965,
"author_profile": "https://Stackoverflow.com/users/43965",
"pm_score": 3,
"selected": true,
"text": "SELECT \"authors\".\"id\", \"authors\".\"name\", \"styles\".\"name\", \"authors\".\"comments\" FROM \n\"authors\" , \"... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18403/"
] |
388,775 | <p>I know I could have an attribute but that's more work than I want to go to... and not general enough.</p>
<p>I want to do something like </p>
<pre><code>class Whotsit
{
private string testProp = "thingy";
public string TestProp
{
get { return testProp; }
set { testProp = value; }
}
}
...
Whotsit whotsit = new Whotsit();
string value = GetName(whotsit.TestProp); //precise syntax up for grabs..
</code></pre>
<p>where I'd expect value to equal "TestProp"</p>
<p>but I can't for the life of me find the right reflection methods to write the GetName method...</p>
<p>EDIT: Why do I want to do this? I have a class to store settings read from a 'name', 'value' table. This is populated by a generalised method based upon reflection. I'd quite like to write the reverse...</p>
<pre><code>/// <summary>
/// Populates an object from a datatable where the rows have columns called NameField and ValueField.
/// If the property with the 'name' exists, and is not read-only, it is populated from the
/// valueField. Any other columns in the dataTable are ignored. If there is no property called
/// nameField it is ignored. Any properties of the object not found in the data table retain their
/// original values.
/// </summary>
/// <typeparam name="T">Type of the object to be populated.</typeparam>
/// <param name="toBePopulated">The object to be populated</param>
/// <param name="dataTable">'name, 'value' Data table to populate the object from.</param>
/// <param name="nameField">Field name of the 'name' field'.</param>
/// <param name="valueField">Field name of the 'value' field.</param>
/// <param name="options">Setting to control conversions - e.g. nulls as empty strings.</param>
public static void PopulateFromNameValueDataTable<T>
(T toBePopulated, System.Data.DataTable dataTable, string nameField, string valueField, PopulateOptions options)
{
Type type = typeof(T);
bool nullStringsAsEmptyString = options == PopulateOptions.NullStringsAsEmptyString;
foreach (DataRow dataRow in dataTable.Rows)
{
string name = dataRow[nameField].ToString();
System.Reflection.PropertyInfo property = type.GetProperty(name);
object value = dataRow[valueField];
if (property != null)
{
Type propertyType = property.PropertyType;
if (nullStringsAsEmptyString && (propertyType == typeof(String)))
{
value = TypeHelper.EmptyStringIfNull(value);
}
else
{
value = TypeHelper.DefaultIfNull(value, propertyType);
}
property.SetValue(toBePopulated, System.Convert.ChangeType(value, propertyType), null);
}
}
}
</code></pre>
<p>FURTHER EDIT: I am just in code, have an instance of Whotsit and I want to get the text string of the 'TestProp' property. It seems kind of weird I know, I can just use the literal "TestProp" - or in the case of my class to datatable function I'd be in a foreach loop of PropertyInfos. I was just curious... </p>
<p>The original code had string constants, which I found clumsy.</p>
| [
{
"answer_id": 388791,
"author": "Stewart Johnson",
"author_id": 6408,
"author_profile": "https://Stackoverflow.com/users/6408",
"pm_score": -1,
"selected": false,
"text": "Type t = whotsit.GetType();\nPropertyInfo[] pis = t.GetProperties();\n"
},
{
"answer_id": 388793,
"auth... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41557/"
] |
388,776 | <p>I recently had to write some code which parsed a file to set data in an object. As there were several objects and corresponding files involved here, I decided to separate the parsing code out.</p>
<p>So I then had one class for parsing the files, <code>CommandFileParser</code>, and two classes per file/object type: one for the actual object itself and one for the possible commands that may be used to set the data in the object. e.g. <code>VectorDrawing</code> and <code>VectorDrawingCommands</code>. The latter's methods would be called by <code>CommandFileParser</code> using reflection as it found them in the input file, and applied data to the former.</p>
<p>But to me this seems like a really messy way of doing it. I ended up repeating loads of boilerplate code doing stuff like <code>dataobject.value = value</code> in all the of <code>-Commands</code> classes. And I don't like having an auxillary class per main data class just to set the data.</p>
<p>Can anyone suggest any ideas for cleaner and more appropriately OO ways of doing this?</p>
| [
{
"answer_id": 388794,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 1,
"selected": false,
"text": "dataobject.value = value"
},
{
"answer_id": 393196,
"author": "joel.neely",
"author_id": 3525,
"author_... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
388,778 | <p>i have a field in sql named as address which is of 80 char.
i want to put this field into 2 fields addr1 and addr2 of 40 char each.
how do i do it.</p>
| [
{
"answer_id": 388786,
"author": "Mladen Prajdic",
"author_id": 31345,
"author_profile": "https://Stackoverflow.com/users/31345",
"pm_score": 2,
"selected": false,
"text": "declare @yourVar varchar(80)\nselect substring(@yourVar, 1, 40), substring(@yourVar, 40, 40)\n"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/388778",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
388,799 | <p>I have a Master Detail relationship configured. The hbm file is below. When I run some code like this</p>
<pre><code>Favourite favourite = favourites.Find(f => f.Id== id);
user.Favourites.Remove(favourite);
m_UserRepository.Save(ref user);
</code></pre>
<p>I get the error message</p>
<p><strong>NHibernate.Exceptions.GenericADOException: could not delete collection rows: [Model.Entities.User.Favourites#249][SQL: SQL not available] ---> System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'UserId', table 'BE.Favourite'; column does not allow nulls. UPDATE fails.</strong></p>
<p>Any suggestions on what this means please help.</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="Model.Entities" schema="BE" assembly="Model" default-lazy="false">
<class name="Model.Entities.User, Model" table="Users" >
<id name="UserId" column="UserId" type="int" unsaved-value="0">
<generator class="native" />
</id>
<property name="UserName" column="UserName" type="string" />
<bag name="Favourites" cascade="all" lazy="true">
<key column="UserId"/>
<one-to-many class="Model.Entities.Favourite, Model"/>
</bag>
</class>
</hibernate-mapping>
</code></pre>
| [
{
"answer_id": 388824,
"author": "Elie",
"author_id": 23249,
"author_profile": "https://Stackoverflow.com/users/23249",
"pm_score": 1,
"selected": false,
"text": "<bag name=\"Favourites\" cascade=\"all,delete-orphan\" lazy=\"true\">\n <key column=\"UserId\" not-null=\"true\"/>\n <one-t... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388799",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27294/"
] |
388,800 | <p>For example I can point the <code>url '^/accounts/password/reset/$'</code> to <code>django.contrib.auth.views.password_reset</code> with my template filename in the context but I think need to send more context details.</p>
<p>I need to know exactly what context to add for each of the password reset and change views.</p>
| [
{
"answer_id": 388811,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 1,
"selected": false,
"text": "form form next site_name"
},
{
"answer_id": 388858,
"author": "Aaron Maenpaa",
"author_id": 2603,
"auth... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15890/"
] |
388,814 | <p>What is best way to show Date Picker for iPhone based Web Application. Can we show something like iPhone native date picker like shown below in web application:</p>
<p><img src="https://i.stack.imgur.com/ms5tX.png" alt="iOS Date Picker"></p>
| [
{
"answer_id": 8774756,
"author": "Kyle",
"author_id": 826668,
"author_profile": "https://Stackoverflow.com/users/826668",
"pm_score": 8,
"selected": true,
"text": "<input type=\"date\" />\n"
},
{
"answer_id": 14643080,
"author": "Christian BUISSON",
"author_id": 2031936,... | 2008/12/23 | [
"https://Stackoverflow.com/questions/388814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.