qid
int64 4
19.1M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
284,904
|
<p>When I compile an application with VS2008 I sometimes end up with 2 identical config files:</p>
<ul>
<li>*.exe.config</li>
<li>*.vshost.exe.config</li>
</ul>
<p>What is the latter one for?</p>
|
[
{
"answer_id": 7253559,
"author": "robvon",
"author_id": 473704,
"author_profile": "https://Stackoverflow.com/users/473704",
"pm_score": 2,
"selected": false,
"text": "var s = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/284904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1463/"
] |
284,906
|
<p>What are some key UI design tips that every developer should know?</p>
<p>While there are a number of UI resources for developers (for example, Joel Spolsky's <a href="https://rads.stackoverflow.com/amzn/click/com/1893115941" rel="noreferrer" rel="nofollow noreferrer">User Interface Design for Programmers</a>), I'm interested in more of a bullet list that can be communicated in 1 to 2 pages.</p>
<p>I'm interested in more tactical, <b>day-to-day UI tips</b>, as opposed to overarching UI design goals that would be covered in a UI design meeting (presumably attended by at least one person with a good UI sense). A collection of these tips might cover about 80% of the cases that an everyday programmer would come across.</p>
|
[
{
"answer_id": 285044,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 0,
"selected": false,
"text": "[Ok, Please Cancel my subscription ], [ Please do not cancel my subscription ] \n Cancel my subscription?\n[ OK ] [ Cancel ] \n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/284906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2197/"
] |
284,921
|
<p>I want to start using dependency injection in my WPF application, largely for better unit testability. My app is mostly constructed along the M-V-VM pattern.
I'm looking at <a href="https://code.google.com/p/autofac/" rel="nofollow noreferrer">Autofac</a> for my IoC container, but I don't think that matters too much for this discussion.</p>
<p>Injecting a service into the start window seems straightforward, as I can create the container and resolve from it in App.xaml.cs.</p>
<p>What I'm struggling with is how I can DI ViewModels and Services into User Controls? The user controls are instantiated via XAML markup, so there's no opportunity to <code>Resolve()</code> them.</p>
<p>The best I can think of is to place the container in a Singleton, and have the user controls resolve their ViewModels from the global container. This feels like a half-way solution, at best, as it still required my components to have a dependency on a ServiceLocator.</p>
<p>Is full IoC possible with WPF?</p>
<p>[edit] - Prism has been suggested, but even evaluating Prism seems like a big investment. I'm hoping for something smaller.</p>
<p>[edit] here's a code fragment where I'm stopped</p>
<pre class="lang-cs prettyprint-override"><code>//setup IoC container (in app.xaml.cs)
var builder = new ContainerBuilder();
builder.Register<NewsSource>().As<INewsSource>();
builder.Register<AViewModel>().FactoryScoped();
var container = builder.Build();
// in user control ctor -
// this doesn't work, where do I get the container from
VM = container.Resolve<AViewModel>();
// in app.xaml.cs
// this compiles, but I can't use this uc,
//as the one I want in created via xaml in the primary window
SomeUserControl uc = new SomeUserControl();
uc.VM = container.Resolve<AViewModel>();
</code></pre>
|
[
{
"answer_id": 286024,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "public class MyDotNetcomponent<T> : SomeDotNetcomponent \n{\n // Inversion of Control Loader…\n // Next step add the Inversion of control manager plus\n // some MockObject feature to work under design time\n public T View {Get;}\n}\n <ObjectDataProvider ObjectType=\"{x:Type CP:IFooView}\" />\n<!-- Work in Blend -->\n<!—- IOC Issue: we need to use a concrete type and/or static Method there no way to achive a load on demande feature in a easy way -->\n <CWD:ServiceObjectDataProvider ObjectType=\"{x:Type CP:IFooView}\" />\n<!-- Cannot inherit from ObjectDataProvider to achive the right behavior everything is private-->\n <CWD:ServiceObjectDataProvider ObjectType=\"{x:Type CP:IFooView }\" />\n<!-- Not working in Blend, quite obvious-->\n <CWM:ServiceMarkup MetaView=\"{x:Type CP:IFooView}\"/>\n<!-- Not working in Blend -->\n"
},
{
"answer_id": 292281,
"author": "Glenn Block",
"author_id": 18419,
"author_profile": "https://Stackoverflow.com/users/18419",
"pm_score": 4,
"selected": false,
"text": "this.DataContext = value; View.Model = this;"
},
{
"answer_id": 311560,
"author": "user30493",
"author_id": 30493,
"author_profile": "https://Stackoverflow.com/users/30493",
"pm_score": 3,
"selected": false,
"text": "// For WPF\npublic Foo() : this(Global.Container.Resolve<IBar>()) {}\n\n// For the rest of the world\npublic Foo(IBar bar) { .. }\n"
},
{
"answer_id": 19664136,
"author": "Ben Stabile",
"author_id": 2892067,
"author_profile": "https://Stackoverflow.com/users/2892067",
"pm_score": 1,
"selected": false,
"text": "xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \nxmlns:d=\"http://schemas.microsoft.com/expression/blend/2008\"\nmc:Ignorable=\"d\" \nd:DataContext=\"{d:DesignInstance Type=local:MyViewModelMock, IsDesignTimeCreatable=True}\"\n private IMyViewModel ViewModel { get { return (IMyViewModel) DataContext; } }\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/284921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25201/"
] |
284,939
|
<h1>UPDATE</h1>
<p>So it turns out internet exploder's stranglehold on "security" to "make up" for being so bad at security was causing my problems. I should have checked that out first haha. Thanks everyone for the input, it has given me ideas on how to optimize my application :D</p>
<hr>
<p>I am writing a web app (in ASP.NET 3.5) that integrates with a platform app. The platform app takes the user's credentials and puts them into an "empty" HTML page that consists of a form with hidden items containing said credentials and POSTS to the webapp (<strong><code>default.aspx</code></strong>):</p>
<pre><code><HTML>
<HEAD>
<SCRIPT LANGUAGE=JSCRIPT>
function OnLoad(){
try {
document.form1.submit();
}
catch(e){
}
}
</SCRIPT>
</HEAD>
<BODY OnLoad="OnLoad()">
<FORM ACTION="http://localhost:51816/gs_ontheweb/default.aspx" METHOD=POST NAME=form1 TARGET="_NEW">
<INPUT TYPE="HIDDEN" NAME="ClientID" VALUE="123456">
<INPUT TYPE="HIDDEN" NAME="Password" VALUE="2830088828">
<INPUT TYPE="HIDDEN" NAME="PracType" VALUE="051">
<INPUT TYPE="HIDDEN" NAME="Encrypt" VALUE="12345620081111">
</FORM>
</BODY>
</HTML>
</code></pre>
<p>When my <strong><code>default.aspx</code></strong> page gets loaded up, it calls the following function:</p>
<pre><code>Dim ClientID As String = Request.Form("ClientID")
Dim PassWord As String = Request.Form("Password")
Dim PracType As String = Request.Form("PracType")
</code></pre>
<p>Each one of them result in empty strings. Any ideas on why this is happening? Thanks in advance.</p>
<p>EDIT: Is there something I need to configure in my <strong><code>web.config</code></strong> file to make this work properly? Request.Params("<code><param name></code>") does not work.</p>
|
[
{
"answer_id": 285528,
"author": "Moose",
"author_id": 19032,
"author_profile": "https://Stackoverflow.com/users/19032",
"pm_score": 0,
"selected": false,
"text": "System.Net.WebClient wc = new System.Net.WebClient();\nbyte[] b;\nbyte[] res;\nstring formdata = \"text=test text&password=secret&checkbox=on&textarea=a longer text sentence&submit=submit\";\n\n// encode the form data string into a byte array \nb = System.Text.Encoding.ASCII.GetBytes(formdata);\n\n// set the content type for a form \nwc.Headers.Add(\"Content-Type\", \"application/x-www-form-urlencoded\");\n\n// POST and get data\nres = wc.UploadData(\"http://localhost:51816/gs_ontheweb/default.aspx\", b);\n\n//convert the return page from byte[] to ascii\nstring s = System.Text.Encoding.ASCII.GetString(res);\n"
},
{
"answer_id": 286003,
"author": "Adrian Clark",
"author_id": 148,
"author_profile": "https://Stackoverflow.com/users/148",
"pm_score": 3,
"selected": true,
"text": "<html>\n <head>\n <title>Test JS Post</title>\n <script type=\"text/javascript\" language=\"javascript\">\n <!--\n function OnLoad(){\n try\n {\n alert(\"Posting...\");\n document.form1.submit();\n }\n catch(e)\n {\n alert(\"ERROR!\");\n alert(e);\n }\n }\n //-->\n </script>\n</head>\n<body onload=\"OnLoad()\">\n\n <form action=\"http://localhost:49684/Default.aspx\" method=\"post\" name=\"form1\">\n\n <input type=\"hidden\" name=\"ClientID\" value=\"123456\" />\n <input type=\"hidden\" name=\"Password\" value=\"2830088828\" />\n <input type=\"hidden\" name=\"PracType\" value=\"051\" />\n <input type=\"hidden\" name=\"Encrypt\" value=\"12345620081111\" />\n\n <h1>This is in the form. Submit me here:</h1><input type=\"submit\" value=\"foo\" />\n\n </form>\n\n</body>\n</html>\n Default.aspx Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init\n\n For Each value As String In Request.Form.Keys\n Debug.WriteLine(String.Format(\"{0} = \"\"{1}\"\"\", value, Request.Form.Item(value)))\n Next\n\nEnd Sub\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/284939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25515/"
] |
284,947
|
<p>Is there a simple way to retrieve the length of an associative array (implemented as an <code>Object</code>) in ActionScript 3.0?</p>
<p>I understand that there are two primary ways of creating associative arrays in AS3:</p>
<ol>
<li>Use a <code>Dictionary</code> object; especially handy when the key does not need to be a <code>string</code></li>
<li>Use an <code>Object</code>, and simply create properties for each desired element. The property name is the key, and the value is, well, the value.</li>
</ol>
<p>My application uses approach #2 (using the <code>Object</code> class to represent associative arrays). </p>
<p>I am hoping there is something more native than my <code>for</code> loop, which manually counts up all the elements.</p>
|
[
{
"answer_id": 286647,
"author": "Iain",
"author_id": 11911,
"author_profile": "https://Stackoverflow.com/users/11911",
"pm_score": 3,
"selected": false,
"text": "var things:Array = [];\nthings.push(\"hi!\");\ntrace(things.length);\n// traces 1\ntrace(things);\n// traces hi!\n var things:Array = [];\nthings[\"thing\"] = \"hi!\";\ntrace(things.length);\n// traces 0\ntrace(things);\n// traces an empty string\ntrace(things[\"thing\"]);\n// traces hi!\n"
},
{
"answer_id": 288541,
"author": "RickDT",
"author_id": 5421,
"author_profile": "https://Stackoverflow.com/users/5421",
"pm_score": 2,
"selected": false,
"text": "var count:int; \nvar key:String; \n\nfor (key in myObject)\n{ \n count++; \n} \n\ntrace (\"myObject has this many keys in it: \" + count);\n for each (var o:* in myObject)\n{\n count++;\n}\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/284947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/863/"
] |
284,950
|
<p>I finally got my group to switch from SourceSafe to Subversion. Unfortunately, my manager still wants to use exclusive locks on every single file. So I set the svn:needs-lock property on every file and created a pre-commit hook to make sure the property stays set.</p>
<p>We are running Subversion on a Linux server. Most of us use Windows machines and a few use Macs. We are using various SVN clients (TortoiseSVN, SmartSVN, Subclipse, etc.). </p>
<p>What we now need is a good/easy method to see all the files that are currently locked in the entire repository (and who has them locked). I have poked around a little in Tortoise and Subclipse, but haven't found what I am looking for. Our projects have many subdirectories that are multiple levels deep, so it would be too time consuming to look at each individual directory. </p>
<p>What I would like is a single report I can run that lists everything that is currently locked and who has it locked. What is the best way to get this type of information?</p>
|
[
{
"answer_id": 284966,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 6,
"selected": true,
"text": "svnadmin lslocks svn:needs-lock"
},
{
"answer_id": 9785504,
"author": "ashirley",
"author_id": 6950,
"author_profile": "https://Stackoverflow.com/users/6950",
"pm_score": 5,
"selected": false,
"text": "svn status --show-updates O $ svn status --show-updates\n O 279532 LockedFile\n? UncommittedFile\nM 279532 ModifiedFile\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/284950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37036/"
] |
284,952
|
<p>I am working on an embedded application where the device is controlled through a command interface. I mocked the command dispatcher in VC and had it working to my satisfaction; but when I then moved the code over to the embedded environment, I found out that the compiler has a broken implementation of pointer-to-func's.</p>
<p>Here's how I originally implemented the code (in VC):</p>
<pre><code>/* Relevant parts of header file */
typedef struct command {
const char *code;
void *set_dispatcher;
void *get_dispatcher;
const char *_description;
} command_t;
#define COMMAND_ENTRY(label,dispatcher,description) {(const char*)label, &set_##dispatcher, &get_##dispatcher, (const char*)description}
/* Dispatcher data structure in the C file */
const command_t commands[] = {
COMMAND_ENTRY("DH", Dhcp, "DHCP (0=off, 1=on)"),
COMMAND_ENTRY("IP", Ip, "IP Address (192.168.1.205)"),
COMMAND_ENTRY("SM", Subnet, "Subunet Mask (255.255.255.0)"),
COMMAND_ENTRY("DR", DefaultRoute, "Default router (192.168.1.1)"),
COMMAND_ENTRY("UN", Username, "Web username"),
COMMAND_ENTRY("PW", Password, "Web password"),
...
}
/* After matching the received command string to the command "label", the command is dispatched */
if (pc->isGetter)
return ((get_fn_t)(commands[i].get_dispatcher))(pc);
else
return ((set_fn_t)(commands[i].set_dispatcher))(pc);
}
</code></pre>
<p>Without the use of function pointers, it seems like my only hope is to use switch()/case statements to call functions. But I'd like to avoid having to manually maintain a large switch() statement. </p>
<p>What I was thinking of doing is moving all the COMMAND_ENTRY lines into a separate include file. Then wraps that include file with varying #define and #undefines. Something like:</p>
<pre><code>/* Create enum's labels */
#define COMMAND_ENTRY(label,dispatcher,description) SET_##dispatcher, GET_##dispatcher
typedef enum command_labels = {
#include "entries.cinc"
DUMMY_ENUM_ENTRY} command_labels_t;
#undefine COMMAND_ENTRY
/* Create command mapping table */
#define COMMAND_ENTRY(label,dispatcher,description) {(const char*)label, SET_##dispatcher, GET_##dispatcher, (const char*)description}
const command_t commands[] = {
#include "entries.cinc"
NULL /* dummy */ };
#undefine COMMAND_ENTRY
/*...*/
int command_dispatcher(command_labels_t dispatcher_id) {
/* Create dispatcher switch statement */
#define COMMAND_ENTRY(label,dispatcher,description) case SET_##dispatcher: return set_##dispatcher(pc); case GET_##dispatcher: return get_##dispatcher(pc);
switch(dispatcher_id) {
#include "entries.cinc"
default:
return NOT_FOUND;
}
#undefine COMMAND_ENTRY
}
</code></pre>
<p>Does anyone see a better way to handle this situation? Sadly, 'get another compiler' is not a viable option. :(</p>
<p>--- Edit to add:
Just to clarify, the particular embedded environment is broken in that the compiler is <em>supposed</em> to create a "function-pointer table" which is then used by the compiler to resolve calls to functions through a pointer. Unfortunately, the compiler is broken and doesn't generate a correct function-table.</p>
<p>So I don't have an easy way to extract the func address to invoke it.</p>
<p>--- Edit #2:
Ah, yes, the use of void *(set|get)_dispatcher was my attempt to see if the problem was with the typedefine of the func pointers. Originally, I had</p>
<pre><code>typedef int (*set_fn_t)(cmdContext_t *pCmdCtx);
typedef int (*get_fn_t)(cmdContext_t *pCmdCtx);
typedef struct command {
const char *code;
set_fn_t set_dispatcher;
get_fn_t get_dispatcher;
const char *_description;
} command_t;
</code></pre>
|
[
{
"answer_id": 284987,
"author": "xtofl",
"author_id": 6610,
"author_profile": "https://Stackoverflow.com/users/6610",
"pm_score": 1,
"selected": false,
"text": "&getenv ; function call\npush [arg1]\npush [arg2]\ncall [command+8] ; at the 4th location, the setter is stored\nret\n extern void*"
},
{
"answer_id": 284992,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 4,
"selected": true,
"text": "struct command typedef struct command {\n const char *code;\n set_fn_t set_dispatcher;\n get_fn_t get_dispatcher;\n const char *_description;\n} command_t;\n"
},
{
"answer_id": 284995,
"author": "Steve Jessop",
"author_id": 13005,
"author_profile": "https://Stackoverflow.com/users/13005",
"pm_score": 2,
"selected": false,
"text": "switch(dispatcher_id) {\n<% for c in commands %>\n case SET_<% c.dispatcher %>: return set_<% c.dispatcher %>(pc); \n case GET_<% c.dispatcher %>: return get_<% c.dispatcher %>(pc);\n<% end %>\ndefault:\n return NOT_FOUND;\n}\n"
},
{
"answer_id": 285759,
"author": "AShelly",
"author_id": 10396,
"author_profile": "https://Stackoverflow.com/users/10396",
"pm_score": 0,
"selected": false,
"text": "unsigned long addr_get_dhcp = 0x1111111;\nunsigned long addr_set_dhcp = 0x2222222; //make these unique numbers.\n\n/* Relevant parts of header file */\ntypedef struct command {\n const char *code;\n unsigned long set_dispatcher;\n unsigned long get_dispatcher;\n const char *_description;\n} command_t;\n\n#define COMMAND_ENTRY(label,dispatcher,description) {(const char*)label, \n addr_set_##dispatcher, addr_get_##dispatcher, (const char*)description} \n"
},
{
"answer_id": 337948,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "typedef struct command {\n const char *code;\n void *set_dispatcher; //IMO, it does not look like a function pointer...\n void *get_dispatcher; //more like a pointer to void\n const char *_description;\n} command_t;\n //a function pointer type definition\ntypedef int (*genericDispatcher)(int data);\n int set_DhcpDispatcher(int data) { return data; }\nint get_DhcpDispatcher(int data) { return 2*data; }\n typedef struct command {\n const char *code;\n genericDispatcher set_dispatcher; \n genericDispatcher get_dispatcher; \n const char *_description;\n} command_t;\n #define COMMAND_ENTRY(label,dispatcher,description) \\\n{ (const char*)label, \\\n set_##dispatcher##Dispatcher, \\\n get_##dispatcher##Dispatcher, \\\n (const char*)description } \n int main(int argc, char **argv)\n{\n int value1 = 0, value2 = 0;\n\n const command_t commands[] = {\n COMMAND_ENTRY(\"DH\", Dhcp, \"DHCP (0=off, 1=on)\")\n };\n\n value1 = commands[0].set_dispatcher(1);\n value2 = commands[0].get_dispatcher(2);\n\n printf(\"value1 = %d, value2 = %d\", value1, value2);\n\n return 0;\n}\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/284952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22329/"
] |
284,984
|
<p>Let's say we have these tables;</p>
<p>table user:<br>
- id<br>
- username<br>
- email</p>
<p>table user2group:<br>
- userid<br>
- groupid</p>
<p>table group:<br>
- id<br>
- groupname</p>
<p>How do I make one query that returns all users, and the groups they belong to (as an array in the resultset or something..)</p>
|
[
{
"answer_id": 284988,
"author": "Eric Z Beard",
"author_id": 1219,
"author_profile": "https://Stackoverflow.com/users/1219",
"pm_score": 3,
"selected": false,
"text": "select u.id, u.username, u.email, g.groupid, g.groupname\nfrom user u \njoin user2group ug on u.userid=ug.userid\njoin group g on g.groupid=ug.groupid\norder by u.userid\n"
},
{
"answer_id": 285183,
"author": "ichiban",
"author_id": 37081,
"author_profile": "https://Stackoverflow.com/users/37081",
"pm_score": 2,
"selected": false,
"text": "SELECT \n u.id, \n u.username, \n u.email, \n g.groupid, \n g.groupname\nFROM \n user u \n LEFT JOIN user2group ug ON u.userid = ug.userid\n LEFT JOIN group g ON g.groupid = ug.groupid\nORDER BY \n u.userid\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/284984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
284,985
|
<p>I would like to do something like add a nice-to-Excel-functions <code>Name</code> property to the <code>WorkBook</code> class. Is there a good way to do this?</p>
<p>More detailed problem: In VBA you can assign a formula to a range in an Excel worksheet. I want to do so, and I want my formula to refer to a second workbook, which is an object called <code>wb</code> in my code. I then use <code>wb.Name</code> in assigning a formula to a range. </p>
<p>The problem arises when <code>wb.Name</code> has a single-quote in it. Then you wind up with something like this:</p>
<pre><code>=MONTH('[Ryan's WB]Sheet1'A1)
</code></pre>
<p>in the spreadsheet, which fails because the single-quote in the workbook name matches to the first single-quote.</p>
<p>What I would like is a <code>FunName</code> property for the <code>WorkBook</code> class that replaces all single-quotes in the <code>Name</code> property with two single-quotes and returns that. Then the above formula would properly wind up looking like</p>
<pre><code>=MONTH('[Ryan''s WB]Sheet1'A1)
</code></pre>
|
[
{
"answer_id": 285069,
"author": "DJ.",
"author_id": 10492,
"author_profile": "https://Stackoverflow.com/users/10492",
"pm_score": 1,
"selected": false,
"text": "WorksheetName = Replace(WB.Name, \"'\", \"''\")\n"
},
{
"answer_id": 285615,
"author": "dbb",
"author_id": 25675,
"author_profile": "https://Stackoverflow.com/users/25675",
"pm_score": 1,
"selected": false,
"text": "Dim WithEvents WB As Workbook\n\nPublic Sub SetWB(W As Workbook)\n Set WB = W\nEnd Sub\n\nPublic Property Get FunName() As String\n FunName = Replace(WB.Name, \"'\", \"''\")\nEnd Property\n\nPrivate Sub WB_SheetCalculate(ByVal Sh As Object)\n 'this runs when WB calculates\nEnd Sub\n Dim WB As New wbClass\nWB.SetWB ActiveWorkbook\nCleanedName = WB.FunName\n"
},
{
"answer_id": 285761,
"author": "Ryan Shannon",
"author_id": 15041,
"author_profile": "https://Stackoverflow.com/users/15041",
"pm_score": 1,
"selected": false,
"text": "Function FormulaWorkName(ByVal aName As String) As String\n FormulaWorkName = Replace(aName, \"'\", \"''\")\nEnd Function\n"
},
{
"answer_id": 382437,
"author": "Dick Kusleika",
"author_id": 4280,
"author_profile": "https://Stackoverflow.com/users/4280",
"pm_score": 3,
"selected": true,
"text": "Public Property Get FunName() As String\n\n FunName = Replace(Me.Name, \"'\", \"''\")\n\nEnd Property\n ThisWorkbook.FunName"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/284985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15041/"
] |
285,005
|
<p>I have to sort a number of integers, which can have values between 30.000.000 and 350.000.000. There will be between 0 and 65.535 integers, with the average count being 20.000. RAM usage is irrelevant and speed only is important.</p>
<p>Later on i will also have to split them into groups, with the divide always being set whenever the gap between two of these values is >65.535, which is what i need the algorithm for.</p>
<p>If it makes any difference, the algorithm will be used in a Perl script.</p>
<p>Edit: After thinking it over and reading the answers i've come to realize something: I don't actually care about the data itself. As i really only want to find the start and end values of groups with small gaps, the sorting only needs to create buckets and can discard the data.</p>
<p>Edit2: After some testing and trying out the answers provided, the fastest way i found was this:</p>
<pre><code>my @sort = sort {$a <=> $b} @item_offsets;
my @buckets;
my $start = shift @sort;
push @buckets, [$start,$start];
for my $item ( @sort ) {
if ( $item < $buckets[$#buckets][1]+$gap ) {
$buckets[$#buckets][1] = $item;
}
else {
push @buckets, [$item,$item];
}
}
say $#buckets;
</code></pre>
|
[
{
"answer_id": 285025,
"author": "warren",
"author_id": 4418,
"author_profile": "https://Stackoverflow.com/users/4418",
"pm_score": 0,
"selected": false,
"text": "while(morenumbers)\n sorted[[unsorted[number]]++\n number++\n"
},
{
"answer_id": 285038,
"author": "Michael Carman",
"author_id": 8233,
"author_profile": "https://Stackoverflow.com/users/8233",
"pm_score": 4,
"selected": false,
"text": "sort @numbers = sort {$a <=> $b} @numbers;\n use sort '_quicksort';\nuse sort '_mergesort';\n my $prev = shift @numbers; # already sorted\nmy @group = [$prev];\nmy $i = 0;\n\nforeach my $n (@numbers) {\n $i++ if ($n - $prev > 65535);\n push @{$group[$i]}, $n;\n $prev = $n;\n}\n"
},
{
"answer_id": 285110,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 1,
"selected": false,
"text": "my @sorted = map { unpack \"N\" } sort map { pack \"N\" } @unsorted;\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/145119/"
] |
285,015
|
<p>I'm working on a Linux machine through SSH (Putty). I need to leave a process running during the night, so I thought I could do that by starting the process in background (with an ampersand at the end of the command) and redirecting stdout to a file.</p>
<p>To my surprise, that doesn't work. As soon as I close the Putty window, the process is stopped.</p>
<p>How can I prevent that from happening??</p>
|
[
{
"answer_id": 285040,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 6,
"selected": false,
"text": "nohup disown -h > help disown\ndisown: disown [-h] [-ar] [jobspec ...]\n By default, removes each JOBSPEC argument from the table of active jobs.\n If the -h option is given, the job is not removed from the table, but is\n marked so that SIGHUP is not sent to the job if the shell receives a\n SIGHUP. The -a option, when JOBSPEC is not supplied, means to remove all\n jobs from the job table; the -r option means to remove only running jobs.\n"
},
{
"answer_id": 285057,
"author": "Brian Knoblauch",
"author_id": 15689,
"author_profile": "https://Stackoverflow.com/users/15689",
"pm_score": 5,
"selected": false,
"text": "nohup blah &\n"
},
{
"answer_id": 285066,
"author": "jcodeninja",
"author_id": 7362,
"author_profile": "https://Stackoverflow.com/users/7362",
"pm_score": 3,
"selected": false,
"text": "nohup /bin/sh -c \"echo \\$\\$ > $pidfile; exec $FOO_BIN $FOO_CONFIG \" > /dev/null\n"
},
{
"answer_id": 285109,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 4,
"selected": false,
"text": "Usage: daemonize [-abchptxV][-d dir][-e err][-i in][-o out][-s sigs][-k fds][-m umask] -- command [args...]\n -V print version and exit\n -a output files in append mode (O_APPEND)\n -b both output and error go to output file\n -c create output files (O_CREAT)\n -d dir change to given directory\n -e file error file (standard error - /dev/null)\n -h print help and exit\n -i file input file (standard input - /dev/null)\n -k fd-list keep file descriptors listed open\n -m umask set umask (octal)\n -o file output file (standard output - /dev/null)\n -s sig-list ignore signal numbers\n -t truncate output files (O_TRUNC)\n -p print daemon PID on original stdout\n -x output files must be new (O_EXCL)\n daemonize daemonize-1.10.tgz"
},
{
"answer_id": 285124,
"author": "Will Hartung",
"author_id": 13663,
"author_profile": "https://Stackoverflow.com/users/13663",
"pm_score": 4,
"selected": false,
"text": "$ batch\n> mycommand -x arg1 -y arg2 -z arg3\n> ^D\n"
},
{
"answer_id": 9646251,
"author": "anthonyrisinger",
"author_id": 404019,
"author_profile": "https://Stackoverflow.com/users/404019",
"pm_score": 5,
"selected": false,
"text": "# ((exec sleep 30)&)\n# grep PPid /proc/`pgrep sleep`/status\nPPid: 1\n# jobs\n# disown\nbash: disown: current: no such job\n #!/bin/bash\n\nIFS=\n\nrun_in_coproc () {\n echo \"coproc[$1] -> main\"\n read -r; echo $REPLY\n}\n\n# dynamic-coprocess-generator. nice.\n_coproc () {\n local i o e n=${1//[^A-Za-z0-9_]}; shift\n exec {i}<> <(:) {o}<> >(:) {e}<> >(:)\n. /dev/stdin <<COPROC \"${@}\"\n ((\"\\$@\")&) <&$i >&$o 2>&$e\n $n=( $o $i $e )\nCOPROC\n}\n\n# pi-rads-of-awesome?\nfor x in {0..5}; do\n _coproc COPROC$x run_in_coproc $x\n declare -p COPROC$x\ndone\n\nfor x in COPROC{0..5}; do\n. /dev/stdin <<RUN\n read -r -u \\${$x[0]}; echo \\$REPLY\n echo \"$x <- main\" >&\\${$x[1]}\n read -r -u \\${$x[0]}; echo \\$REPLY\nRUN\ndone\n # ./coproc.sh \ndeclare -a COPROC0='([0]=\"21\" [1]=\"16\" [2]=\"23\")'\ndeclare -a COPROC1='([0]=\"24\" [1]=\"19\" [2]=\"26\")'\ndeclare -a COPROC2='([0]=\"27\" [1]=\"22\" [2]=\"29\")'\ndeclare -a COPROC3='([0]=\"30\" [1]=\"25\" [2]=\"32\")'\ndeclare -a COPROC4='([0]=\"33\" [1]=\"28\" [2]=\"35\")'\ndeclare -a COPROC5='([0]=\"36\" [1]=\"31\" [2]=\"38\")'\ncoproc[0] -> main\nCOPROC0 <- main\ncoproc[1] -> main\nCOPROC1 <- main\ncoproc[2] -> main\nCOPROC2 <- main\ncoproc[3] -> main\nCOPROC3 <- main\ncoproc[4] -> main\nCOPROC4 <- main\ncoproc[5] -> main\nCOPROC5 <- main\n sleep 1 : command true . /dev/stdin <<EOF\n[...]\nEOF\n"
},
{
"answer_id": 10813427,
"author": "THESorcerer",
"author_id": 1414912,
"author_profile": "https://Stackoverflow.com/users/1414912",
"pm_score": 2,
"selected": false,
"text": "screen will background your process without losing interactive control to it\n"
},
{
"answer_id": 11065075,
"author": "janv",
"author_id": 1460855,
"author_profile": "https://Stackoverflow.com/users/1460855",
"pm_score": 2,
"selected": false,
"text": "daemon"
},
{
"answer_id": 18236495,
"author": "tbc0",
"author_id": 650264,
"author_profile": "https://Stackoverflow.com/users/650264",
"pm_score": 2,
"selected": false,
"text": "$ ssh myhost 'sleep 30 >&- 2>&- <&- &'\n# ssh returns right away, and your sleep job is running remotely\n$\n"
},
{
"answer_id": 22189326,
"author": "Adeel Ahmad",
"author_id": 2172800,
"author_profile": "https://Stackoverflow.com/users/2172800",
"pm_score": 3,
"selected": false,
"text": "nohup screen yum install screen screen man screen"
},
{
"answer_id": 38165810,
"author": "RAM",
"author_id": 6542814,
"author_profile": "https://Stackoverflow.com/users/6542814",
"pm_score": 3,
"selected": false,
"text": "# ((mycommand &)&)\n # ((sleep 30 &)&)\n# exit\n # ps aux | grep sleep\n sleep 30 nohup nohup screen"
},
{
"answer_id": 42063790,
"author": "haccks",
"author_id": 2455888,
"author_profile": "https://Stackoverflow.com/users/2455888",
"pm_score": 2,
"selected": false,
"text": "sudo apt-get install npm\n sudo yum install npm\n npm install pm2@latest -g\n $ pm2 start app.js # Start, Daemonize and auto-restart application (Node)\n$ pm2 start app.py # Start, Daemonize and auto-restart application (Python)\n $ pm2 list # List all processes started with PM2\n$ pm2 monit # Display memory and cpu usage of each app\n$ pm2 show [app-name] # Show all informations about application\n $ pm2 stop <app_name|id|'all'|json_conf>\n$ pm2 restart <app_name|id|'all'|json_conf>\n$ pm2 delete <app_name|id|'all'|json_conf>\n $HOME/.pm2/logs #contain all applications logs\n \"exec_interpreter\" : \"node\" \"exec_interpreter\" : \"none\". #include <stdio.h>\n#include <unistd.h> //No standard C library\nint main(void)\n{\n printf(\"Hello World\\n\");\n sleep (100);\n printf(\"Hello World\\n\");\n\n return 0;\n}\n gcc -o hello hello.c \n pm2 start ./hello\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25700/"
] |
285,031
|
<p>It is possible to get stacktrace using System.Diagnostics.StackTrace, but thread has to be suspended. Suspend and Resume function are obsolete, so I expect that better way exists.</p>
|
[
{
"answer_id": 285321,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 2,
"selected": false,
"text": "http://blogs.msdn.com/jmstall/archive/2005/11/07/views_on_cordbg_and_mdbg.aspx http://geekswithblogs.net/johnsPerfBlog/archive/2008/10/13/mdbg-a-managed-wrapper-around-icordebug.aspx"
},
{
"answer_id": 9595704,
"author": "Joe Albahari",
"author_id": 46223,
"author_profile": "https://Stackoverflow.com/users/46223",
"pm_score": 5,
"selected": false,
"text": "StackTrace GetStackTrace (Thread targetThread)\n{\n StackTrace stackTrace = null;\n var ready = new ManualResetEventSlim();\n\n new Thread (() =>\n {\n // Backstop to release thread in case of deadlock:\n ready.Set();\n Thread.Sleep (200);\n try { targetThread.Resume(); } catch { }\n }).Start();\n\n ready.Wait();\n targetThread.Suspend();\n try { stackTrace = new StackTrace (targetThread, true); }\n catch { /* Deadlock */ }\n finally\n {\n try { targetThread.Resume(); }\n catch { stackTrace = null; /* Deadlock */ }\n }\n\n return stackTrace;\n}\n Suspend Resume DataTarget.AttachToProcess using Microsoft.Diagnostics.Runtime;\nusing System.Diagnostics;\nusing System.Reflection;\n\nif (args.Length == 3 &&\n int.TryParse (args [0], out int pid) &&\n int.TryParse (args [1], out int threadID) &&\n int.TryParse (args [2], out int sampleInterval))\n{\n // We're being called from the Process.Start call below.\n ThreadSampler.Start (pid, threadID, sampleInterval);\n}\nelse\n{\n // Start ThreadSampler in another process, with 100ms sampling interval\n var startInfo = new ProcessStartInfo (\n Path.ChangeExtension (Assembly.GetExecutingAssembly().Location, \".exe\"),\n Process.GetCurrentProcess().Id + \" \" + Thread.CurrentThread.ManagedThreadId + \" 100\")\n {\n RedirectStandardOutput = true,\n CreateNoWindow = true\n };\n\n var proc = Process.Start (startInfo);\n\n proc.OutputDataReceived += (sender, args) =>\n Console.WriteLine (args.Data != \"\" ? \" \" + args.Data : \"New stack trace:\");\n\n proc.BeginOutputReadLine();\n\n // Do some work to test the stack trace sampling\n Demo.DemoStackTrace();\n\n // Kill the worker process when we're done.\n proc.Kill();\n}\n\nclass Demo\n{\n public static void DemoStackTrace()\n {\n for (int i = 0; i < 10; i++)\n {\n Method1();\n Method2();\n Method3();\n }\n }\n\n static void Method1()\n {\n Foo();\n }\n\n static void Method2()\n {\n Foo();\n }\n\n static void Method3()\n {\n Foo();\n }\n\n static void Foo() => Thread.Sleep (100);\n}\n\nstatic class ThreadSampler\n{\n public static void Start (int pid, int threadID, int sampleInterval)\n {\n DataTarget target = DataTarget.AttachToProcess (pid, false);\n ClrRuntime runtime = target.ClrVersions [0].CreateRuntime();\n\n while (true)\n {\n // Flush cached data, otherwise we'll get old execution info.\n runtime.FlushCachedData();\n\n foreach (ClrThread thread in runtime.Threads)\n if (thread.ManagedThreadId == threadID)\n {\n Console.WriteLine(); // Signal new stack trace\n\n foreach (var frame in thread.EnumerateStackTrace().Take (100))\n if (frame.Kind == ClrStackFrameKind.ManagedMethod)\n Console.WriteLine (\" \" + frame.ToString());\n\n break;\n }\n\n Thread.Sleep (sampleInterval);\n }\n }\n}\n"
},
{
"answer_id": 14935378,
"author": "Andreas",
"author_id": 941546,
"author_profile": "https://Stackoverflow.com/users/941546",
"pm_score": 4,
"selected": false,
"text": "private static StackTrace GetStackTrace(Thread targetThread) {\nusing (ManualResetEvent fallbackThreadReady = new ManualResetEvent(false), exitedSafely = new ManualResetEvent(false)) {\n Thread fallbackThread = new Thread(delegate() {\n fallbackThreadReady.Set();\n while (!exitedSafely.WaitOne(200)) {\n try {\n targetThread.Resume();\n } catch (Exception) {/*Whatever happens, do never stop to resume the target-thread regularly until the main-thread has exited safely.*/}\n }\n });\n fallbackThread.Name = \"GetStackFallbackThread\";\n try {\n fallbackThread.Start();\n fallbackThreadReady.WaitOne();\n //From here, you have about 200ms to get the stack-trace.\n targetThread.Suspend();\n StackTrace trace = null;\n try {\n trace = new StackTrace(targetThread, true);\n } catch (ThreadStateException) {\n //failed to get stack trace, since the fallback-thread resumed the thread\n //possible reasons:\n //1.) This thread was just too slow (not very likely)\n //2.) The deadlock ocurred and the fallbackThread rescued the situation.\n //In both cases just return null.\n }\n try {\n targetThread.Resume();\n } catch (ThreadStateException) {/*Thread is running again already*/}\n return trace;\n } finally {\n //Just signal the backup-thread to stop.\n exitedSafely.Set();\n //Join the thread to avoid disposing \"exited safely\" too early. And also make sure that no leftover threads are cluttering iis by accident.\n fallbackThread.Join();\n }\n}\n}\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28912/"
] |
285,042
|
<p>I'm trying to copy both an image from a file and text from a file to the clipboard. My intention is to then open a word document or an outlook email and paste both the text and the image in one standard paste command (CTRL-V for example). I can do both separately easily enough, but doing them both in one operation doesn't seem to work.</p>
<p>This is how I've got the two working as separate operations (only relevant code lines of course, with try/catch stripped out etc.):</p>
<p>Add Image to Clipboard:</p>
<p>...</p>
<pre><code>Bitmap imageToAdd = new Bitmap(imageFilePath);
Clipboard.SetImage(imageToAdd);
</code></pre>
<p>...</p>
<p>Add Text to Clipboard:</p>
<p>...</p>
<pre><code>StreamReader rdr = new StreamReader(textFilePath);
string text = rdr.ReadToEnd();
Clipboard.SetText(text);
</code></pre>
<p>...</p>
<p>I'm using c# and .net 2.0 framework and targeting Windows XP (and likely Vista in the near future).</p>
<p>TIA</p>
|
[
{
"answer_id": 61739796,
"author": "Markus",
"author_id": 1332129,
"author_profile": "https://Stackoverflow.com/users/1332129",
"pm_score": 0,
"selected": false,
"text": "// Load a bitmap without locking it.\nprivate Bitmap LoadBitmapUnlocked(string path)\n{\n using (Bitmap bm = new Bitmap(path))\n {\n return new Bitmap(bm);\n }\n}\n string path = \n@\"C:\\Windows\\Web\\Wallpaper\\Architecture\\img13.jpg\"; \nDataObject dataObj = new DataObject();\ndataObj.SetData(DataFormats.Bitmap, true, LoadBitmapUnlocked(path));\ndataObj.SetData(DataFormats.UnicodeText, path);\nClipboard.SetDataObject(dataObj);\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285042",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9732/"
] |
285,061
|
<p>Suppose I have a python object <code>x</code> and a string <code>s</code>, how do I set the attribute <code>s</code> on <code>x</code>? So:</p>
<pre><code>>>> x = SomeObject()
>>> attr = 'myAttr'
>>> # magic goes here
>>> x.myAttr
'magic'
</code></pre>
<p>What's the magic? The goal of this, incidentally, is to cache calls to <code>x.__getattr__()</code>. </p>
|
[
{
"answer_id": 285076,
"author": "Ali Afshar",
"author_id": 28380,
"author_profile": "https://Stackoverflow.com/users/28380",
"pm_score": 10,
"selected": true,
"text": "setattr(x, attr, 'magic')\n >>> help(setattr)\nHelp on built-in function setattr in module __builtin__:\n\nsetattr(...)\n setattr(object, name, value)\n \n Set a named attribute on an object; setattr(x, 'y', v) is equivalent to\n ``x.y = v''.\n object"
},
{
"answer_id": 285086,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 6,
"selected": false,
"text": "class XClass( object ):\n def __init__( self ):\n self.myAttr= None\n\nx= XClass()\nx.myAttr= 'magic'\nx.myAttr\n setattr getattr object >>> a= object()\n>>> setattr( a, 'hi', 'mom' )\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nAttributeError: 'object' object has no attribute 'hi'\n class YClass( object ):\n pass\n\ny= YClass()\nsetattr( y, 'myAttr', 'magic' )\ny.myAttr\n"
},
{
"answer_id": 19637635,
"author": "vijay shanker",
"author_id": 1906494,
"author_profile": "https://Stackoverflow.com/users/1906494",
"pm_score": 5,
"selected": false,
"text": "x.attr_name = s \nsetattr(x, 'attr_name', s)\n"
},
{
"answer_id": 63630201,
"author": "d.raev",
"author_id": 1621821,
"author_profile": "https://Stackoverflow.com/users/1621821",
"pm_score": 2,
"selected": false,
"text": "def update_property(self, property, value):\n setattr(self, property, value)\n"
},
{
"answer_id": 73149871,
"author": "Coder100",
"author_id": 19502453,
"author_profile": "https://Stackoverflow.com/users/19502453",
"pm_score": -1,
"selected": false,
"text": "import sys\n\nfilename = sys.argv[1]\n\nfile = open(filename, 'r')\n\ncontents = file.read()\n print() import sys\n\narg = sys.argv[1]\n\narg1config = print(arg1config)\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5222/"
] |
285,068
|
<p>Is there a way to make OpenGL transform a general vector I give it with the current modelview matrix and get the result back?</p>
<p>The obvious way is to query the modelview matrix and do the multiplication myself but
I am almost sure there should be a way to make OpenGL do this for me.</p>
|
[
{
"answer_id": 285265,
"author": "Judge Maygarden",
"author_id": 1491,
"author_profile": "https://Stackoverflow.com/users/1491",
"pm_score": 2,
"selected": false,
"text": "float modelview[16];\nglGetFloatv(GL_MODELVIEW_MATRIX, modelview);\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9611/"
] |
285,074
|
<p>I'm using the <a href="http://docs.jquery.com/UI/Sortables" rel="noreferrer">jQuery UI sortables</a> plugin to allow re-ordering of some list items. Inside each list item, I've got a couple of radio buttons which allow the item to be enabled or disabled.</p>
<p>When the item is dragged, both radio buttons get deselected, which doesn't seem like it should be happening. Is this correct behavior, and if not, what is the best way to work around this?</p>
<p>Here is a code sample demonstrating this problem:</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>jQuery Sortables Problem</title>
<script src="jquery-1.2.6.min.js" type="text/javascript"></script>
<script src="jquery-ui.min.js" type="text/javascript"></script>
<style type="text/css">
.items
{
margin-top: 30px;
margin-left: 0px;
padding-left: 25px;
cursor: move;
}
.items li
{
padding: 10px;
font-size: 15px;
border: 1px solid #666;
background: #eee;
width: 400px;
margin-bottom: 15px;
float: left;
clear:both;
}
</style>
</head>
<body>
<ol id="itemlist" class="items">
<li id="1" class="item">
Item 1
<input name="status_1" type="radio" value="1" checked="checked" />enabled
<input name="status_1" type="radio" value="0" />disabled
</li>
<li id="2" class="item">
Item 2
<input name="status_2" type="radio" value="1" checked="checked" />enabled
<input name="status_2" type="radio" value="0" />disabled
</li>
<li id="3" class="item">
Item 3
<input name="status_3" type="radio" value="1" checked="checked" />enabled
<input name="status_3" type="radio" value="0" />disabled
</li>
<li id="4" class="item">
Item 4
<input name="status_4" type="radio" value="1" checked="checked" />enabled
<input name="status_4" type="radio" value="0" />disabled
</li>
</ol>
<script type="text/javascript">
$('#itemlist').sortable();
</script>
</body>
</html>
</code></pre>
<p>As soon as a list item is grabbed with the mouse, both the radio buttons get deselected.</p>
<p>If this is a bug, one workaround would be to automatically select the 'enabled' radio button when the item is moved, so any advice on how to achieve this would also be most appreciated.</p>
<p>Update: I've tested this in FireFox 3, Internet Explorer 7, Opera 9.5, and Safari 3.1.2, all on Windows XP x64, and this issue occurs in all of them.</p>
|
[
{
"answer_id": 290738,
"author": "Ben Koehler",
"author_id": 11996,
"author_profile": "https://Stackoverflow.com/users/11996",
"pm_score": 1,
"selected": false,
"text": "$('#itemlist').sortable();\n $('#itemlist').sortable({placeholder: \".items li\"});\n"
},
{
"answer_id": 295153,
"author": "Serxipc",
"author_id": 34009,
"author_profile": "https://Stackoverflow.com/users/34009",
"pm_score": 1,
"selected": false,
"text": "$('#itemlist li').clone().appendTo(\"#itemlist\"); $('#itemlist').sortable({helper: function(){\n return $(\"<li>\").css({border: \"1px solid red\", background: \"transparent\"}).appendTo(\"#itemlist\")[0];\n}});\n"
},
{
"answer_id": 26284023,
"author": "Randy Shelford",
"author_id": 1845994,
"author_profile": "https://Stackoverflow.com/users/1845994",
"pm_score": 0,
"selected": false,
"text": "// global script for commentluv premium settings pages\n// workaround for bug that causes radio inputs to lose settings when meta box is dragged.\n// http://core.trac.wordpress.org/ticket/16972\njQuery(document).ready(function(){\n // listen for drag drop of metaboxes , bind mousedown to .hndle so it only fires when starting to drag\n jQuery('.hndle').mousedown(function(){\n // set event listener for mouse up on the content .wrap and wait a tick to give the dragged div time to settle before firing the reclick function\n jQuery('.wrap').mouseup(function(){store_radio(); setTimeout('reclick_radio();',50);});\n })\n});\n/**\n* stores object of all radio buttons that are checked for entire form\n*/\nfunction store_radio(){\n var radioshack = {};\n jQuery('input[type=\"radio\"]').each(function(){\n if(jQuery(this).is(':checked')){\n radioshack[jQuery(this).attr('name')] = jQuery(this).val();\n }\n jQuery(document).data('radioshack',radioshack);\n });\n}\n/**\n* detect mouseup and restore all radio buttons that were checked\n*/\nfunction reclick_radio(){\n // get object of checked radio button names and values\n var radios = jQuery(document).data('radioshack');\n //step thru each object element and trigger a click on it's corresponding radio button\n for(key in radios){\n jQuery('input[name=\"'+key+'\"]').filter('[value=\"'+radios[key]+'\"]').trigger('click');\n }\n // unbind the event listener on .wrap (prevents clicks on inputs from triggering function)\n jQuery('.wrap').unbind('mouseup');\n}\n"
},
{
"answer_id": 40921771,
"author": "Rodrigo",
"author_id": 3178803,
"author_profile": "https://Stackoverflow.com/users/3178803",
"pm_score": 0,
"selected": false,
"text": "// First, create a function to store the properties.\n\n// Store the checked radio properties\n function gravaSelecoes() {\n $(\"tbody.linhasConf\").find(\"input:radio\").each(function () {\n if ($(this).prop(\"checked\"))\n $(this).attr(\"data-checked\", \"true\");\n else\n $(this).attr(\"data-checked\", \"false\");\n });\n }\n\n// Then, create a function that restore the properties\n\n// Restore the checked radio properties\n function atualizaSelecoes() {\n $(\"tbody.linhasConf\").find(\"input:radio\").each(function () {\n if ($(this).attr(\"data-checked\") == \"true\")\n $(this).prop(\"checked\", true);\n else\n $(this).prop(\"checked\", false);\n });\n }\n\n// And when declaring sortables, refer to those functions\n\n $('tbody.linhasConf').sortable({\n start: gravaSelecoes,\n stop: atualizaSelecoes\n }).disableSelection();\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/775/"
] |
285,083
|
<p>I'm writing a custom JSP tag using the JSP 2 tag files. Inside my tag I would like to know which page called the tag in order to construct URLs. Is this possible with out passing it through an attribute?</p>
|
[
{
"answer_id": 288438,
"author": "timdisney",
"author_id": 14481,
"author_profile": "https://Stackoverflow.com/users/14481",
"pm_score": 2,
"selected": false,
"text": "<form action=\"${pageContext.request.requestURI}\">\n <form action=\"<%=request.requestURI%>\">\n <form action=\"<%=pageContext.request.requestURI%>\">\n"
},
{
"answer_id": 288516,
"author": "Johann Zacharee",
"author_id": 24290,
"author_profile": "https://Stackoverflow.com/users/24290",
"pm_score": 1,
"selected": false,
"text": "pageContext public class YourTag extends TagSupport {\n public int doStartTag() throws JspException {\n HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();\n String pathInfo = req.getPathInfo();\n"
},
{
"answer_id": 289328,
"author": "Yoni",
"author_id": 36071,
"author_profile": "https://Stackoverflow.com/users/36071",
"pm_score": 0,
"selected": false,
"text": "<form action=\"<%= pageContext.getRequest().getRequestURI() %>\">\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14481/"
] |
285,095
|
<p>Given a week-day (1-7), how can I calculate what that week-day's last date was?</p>
<p><strong>Example:</strong> Today is <strong>Wednesday</strong>, 2008/11/12, and I want to know what last <strong>Friday's</strong> date was.</p>
|
[
{
"answer_id": 285113,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": true,
"text": "today days_since_friday = (((today - 1) + 7) - (6 - 1)) % 7\n days_since_friday days_since_friday = ((today + 7) - 5) % 7\n days_since_friday = (today + 2) % 7\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15884/"
] |
285,104
|
<p>For some reason sql server 2008 is not allowing me to add columns to an existing table.</p>
<p>The table is empty btw.</p>
<p>Is there a setting that prevents modifying tables in sql 2008?</p>
|
[
{
"answer_id": 285113,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": true,
"text": "today days_since_friday = (((today - 1) + 7) - (6 - 1)) % 7\n days_since_friday days_since_friday = ((today + 7) - 5) % 7\n days_since_friday = (today + 2) % 7\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,107
|
<p>Trying to create several layers of folders at once C:\pie\applepie\recipies\
without using several different commands, is there an easy way similar to Directory.CreateDirectory()</p>
|
[
{
"answer_id": 285131,
"author": "George Mastros",
"author_id": 1408129,
"author_profile": "https://Stackoverflow.com/users/1408129",
"pm_score": 4,
"selected": true,
"text": "Public Sub MakePath(ByVal Folder As String)\n\n Dim arTemp() As String\n Dim i As Long\n Dim FSO As Scripting.FileSystemObject\n Dim cFolder As String\n\n Set FSO = New Scripting.FileSystemObject\n\n arTemp = Split(Folder, \"\\\")\n For i = LBound(arTemp) To UBound(arTemp)\n cFolder = cFolder & arTemp(i) & \"\\\"\n If Not FSO.FolderExists(cFolder) Then\n Call FSO.CreateFolder(cFolder)\n End If\n Next\n\nEnd Sub\n"
},
{
"answer_id": 28992846,
"author": "Rui Manso",
"author_id": 4565386,
"author_profile": "https://Stackoverflow.com/users/4565386",
"pm_score": 2,
"selected": false,
"text": "Public Sub MkPath(ByVal sPath As String)\n Dim Splits() As String, CurFolder As String\n Dim i As Long\n Splits = Split(sPath, \"\\\")\n For i = LBound(Splits) To UBound(Splits)\n CurFolder = CurFolder & Splits(i) & \"\\\"\n If Dir(CurFolder, vbDirectory) = \"\" Then MkDir CurFolder\n Next i\nEnd Sub\n"
},
{
"answer_id": 65372524,
"author": "Rui Manso",
"author_id": 4565386,
"author_profile": "https://Stackoverflow.com/users/4565386",
"pm_score": 0,
"selected": false,
"text": "Public Sub MakePath(ByVal Path As String)\n On Error Resume Next\n Shell \"cmd /c mkdir \"\"\" & Path & \"\"\"\"\nEnd Sub\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,139
|
<p>I'm trying to duplicate the effect used in the Firefox search box where, if the search field does not have focus ( the user has not clicked inside of it ), it just says <i>Google</i> in gray text. Then, when the user clicks in the box, the text is removed and they can fill in their search term.</p>
<p>I want to use this to provide example field data for a web form.</p>
<p>JQuery syntax would be preferable to plain javascript, but plain JS would be fine too.</p>
<p>Thanks SO Hive Mind!</p>
|
[
{
"answer_id": 285173,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 4,
"selected": true,
"text": "<style type='text/css'>\n input #ghost { color: #CCC; }\n input #normal { color: #OOO; }\n</style>\n\n<script type='text/javascript'> \n function addTextHint(elem, hintText)\n { \n if (elem.value == '') \n { \n elem.value = hintText;\n elem.style.className = 'ghost';\n }\n\n elem.onfocus = function ()\n { \n if (elem.value == hintText) \n {\n elem.value = '';\n elem.className = 'normal';\n }\n }\n\n elem.onblur = function ()\n {\n if (elem.value == '')\n {\n elem.value = hintText;\n elem.className = 'ghost';\n }\n } \n }\n\n addTextHint(document.getElementById('foobar'),'Google');\n</script>\n"
},
{
"answer_id": 12960470,
"author": "mikeswright49",
"author_id": 1747217,
"author_profile": "https://Stackoverflow.com/users/1747217",
"pm_score": 2,
"selected": false,
"text": "<input type=\"text\" id = \"textField\" value=\"Google\" class=\"RegularText GhostText\" />\n\n<style>\n.GhostText{color:#DDD}\n.RegularText{color:#CCC}\n</style>\n\n<script type=\"text/javascript\" language=\"javascript\">\n$(\"#textField\").blur(function(e){\n if ($.trim(e.target.value) == \"\") {\n e.target.value = e.target.defaultValue;\n e.target.toggleClass(\"GhostText\");\n }\n});\n$(\"#textField\").focus(function(e){\n if ($.trim(e.target.value) == e.target.defaultValue) {\n e.target.value = \"\";\n e.target.toggleClass(\"GhostText\");\n }\n});\n</script>\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,148
|
<p>I've written a rails app that follows the regular directory structure (model code in models, controller code in controllers).</p>
<p>But I'm now working on a new feature and for that I have written some (what I would call) "service" code.<br>
The new feature is to import some data into the system, at the moment it's two classes to do the importing but could expand to more.</p>
<p>I don't believe the new code belongs in model as it's not modelling any object (it's not directly related to any single object either.
I certainly don't think it belongs in controller either as it's not presentation logic.</p>
<p>So, I've created a "app/services" directory and put it in there.
I've also created a "test/services" directory where I have put my tests.</p>
<p>All well and good I thought but when I run 'rake:test' or 'autotest' my new services tests are not run.<br>
Now I expect there is a way to make rake pick them up but is this a warning flag that I have done something wrong?<br>
Is there some other place the code should live or am I somehow not doing things "the Rails way"?</p>
<p>Generally whenever I've hit a problem like this before I've usually found that rails had a solution already, but I was not aware of the convention.
Is this one of those cases?</p>
|
[
{
"answer_id": 285152,
"author": "Gareth",
"author_id": 31582,
"author_profile": "https://Stackoverflow.com/users/31582",
"pm_score": 6,
"selected": true,
"text": "class MyFoo\nend\n lib/my_foo.rb MyFoo.new\n require 'my_foo'"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/151/"
] |
285,154
|
<p>How can I access options that I set in a jQuery Datepicker?</p>
<pre><code>$("#testDatePicker").datepicker({
minDate: new Date(2005, 0, 26),
showOn: 'button',
buttonImage: 'js/themes/default/images/calendar.gif',
buttonImageOnly: true
});
var minDate = $("#testDatePicker").?????;
</code></pre>
|
[
{
"answer_id": 285302,
"author": "Mauricio Scheffer",
"author_id": 21239,
"author_profile": "https://Stackoverflow.com/users/21239",
"pm_score": 2,
"selected": true,
"text": "var dpOptions = {minDate: new Date(2005, 0, 26), ...};\n$('#testDatePicker').datepicker(dpOptions);\n.\n.\n.\nvar minDate = dpOptions.minDate;\n"
},
{
"answer_id": 287589,
"author": "Serxipc",
"author_id": 34009,
"author_profile": "https://Stackoverflow.com/users/34009",
"pm_score": 1,
"selected": false,
"text": " $.data($('#testDatePicker')[0], 'datepicker').settings\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10976/"
] |
285,177
|
<p>Is it possible to call a constructor from another (within the same class, not from a subclass)? If yes how? And what could be the best way to call another constructor (if there are several ways to do it)?</p>
|
[
{
"answer_id": 285184,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 13,
"selected": true,
"text": "public class Foo {\n private int x;\n\n public Foo() {\n this(1);\n }\n\n public Foo(int x) {\n this.x = x;\n }\n}\n super this"
},
{
"answer_id": 285187,
"author": "Josh",
"author_id": 2204759,
"author_profile": "https://Stackoverflow.com/users/2204759",
"pm_score": 8,
"selected": false,
"text": "this(args) public class Cons {\n\n public Cons() {\n // A no arguments constructor that sends default values to the largest\n this(madeUpArg1Value,madeUpArg2Value,madeUpArg3Value);\n }\n\n public Cons(int arg1, int arg2) {\n // An example of a partial constructor that uses the passed in arguments\n // and sends a hidden default value to the largest\n this(arg1,arg2, madeUpArg3Value);\n }\n\n // Largest constructor that does the work\n public Cons(int arg1, int arg2, int arg3) {\n this.arg1 = arg1;\n this.arg2 = arg2;\n this.arg3 = arg3;\n }\n}\n public class Cons {\n public static Cons newCons(int arg1,...) {\n // This function is commonly called valueOf, like Integer.valueOf(..)\n // More recently called \"of\", like EnumSet.of(..)\n Cons c = new Cons(...);\n c.setArg1(....);\n return c;\n }\n} \n super(someValue)"
},
{
"answer_id": 15348070,
"author": "Christian Fries",
"author_id": 231397,
"author_profile": "https://Stackoverflow.com/users/231397",
"pm_score": 8,
"selected": false,
"text": "this() this public class MyClass {\n\n public MyClass(double argument1, double argument2) {\n this(argument1, argument2, 0.0);\n }\n\n public MyClass(double argument1, double argument2, double argument3) {\n this.argument1 = argument1;\n this.argument2 = argument2;\n this.argument3 = argument3;\n }\n}\n this public class MyClass {\n\n public MyClass(double argument1, double argument2) {\n this(argument1, argument2, getDefaultArg3(argument1, argument2));\n }\n\n public MyClass(double argument1, double argument2, double argument3) {\n this.argument1 = argument1;\n this.argument2 = argument2;\n this.argument3 = argument3;\n }\n\n private static double getDefaultArg3(double argument1, double argument2) {\n double argument3 = 0;\n\n // Calculate argument3 here if you like.\n\n return argument3;\n\n }\n\n}\n"
},
{
"answer_id": 16180692,
"author": "Kaamel",
"author_id": 2295938,
"author_profile": "https://Stackoverflow.com/users/2295938",
"pm_score": 5,
"selected": false,
"text": "class MyClass {\n int field;\n\n\n MyClass() {\n init(0);\n } \n MyClass(int value) {\n if (value<0) {\n init(0);\n } \n else { \n init(value);\n }\n }\n void init(int x) {\n field = x;\n }\n}\n class MyClass {\n int field;\n\n MyClass(int value) {\n if (value<0)\n field = 0;\n else\n field = value;\n }\n MyClass() {\n this(0);\n }\n}\n"
},
{
"answer_id": 30112975,
"author": "olovb",
"author_id": 147808,
"author_profile": "https://Stackoverflow.com/users/147808",
"pm_score": 4,
"selected": false,
"text": "this(…) this super"
},
{
"answer_id": 30462394,
"author": "amila isura",
"author_id": 4395148,
"author_profile": "https://Stackoverflow.com/users/4395148",
"pm_score": 5,
"selected": false,
"text": "this public class Rectangle {\n private int x, y;\n private int width, height;\n\n public Rectangle() {\n this(1, 1);\n }\n public Rectangle(int width, int height) {\n this( 0,0,width, height);\n }\n public Rectangle(int x, int y, int width, int height) {\n this.x = x;\n this.y = y;\n this.width = width;\n this.height = height;\n }\n\n}\n"
},
{
"answer_id": 33963435,
"author": "ABHISHEK RANA",
"author_id": 5182313,
"author_profile": "https://Stackoverflow.com/users/5182313",
"pm_score": 3,
"selected": false,
"text": "class This1\n{\n This1()\n {\n this(\"Hello\");\n System.out.println(\"Default constructor..\");\n }\n This1(int a)\n {\n this();\n System.out.println(\"int as arg constructor..\"); \n }\n This1(String s)\n {\n System.out.println(\"string as arg constructor..\"); \n }\n\n public static void main(String args[])\n {\n new This1(100);\n }\n}\n"
},
{
"answer_id": 39462961,
"author": "Akash Manngroliya",
"author_id": 5089473,
"author_profile": "https://Stackoverflow.com/users/5089473",
"pm_score": 3,
"selected": false,
"text": "this() class Example{\n private int a = 1;\n Example(){\n this(5); //here another constructor called based on constructor argument\n System.out.println(\"number a is \"+a); \n }\n Example(int b){\n System.out.println(\"number b is \"+b);\n }\n"
},
{
"answer_id": 40637000,
"author": "Utsav",
"author_id": 2106934,
"author_profile": "https://Stackoverflow.com/users/2106934",
"pm_score": 4,
"selected": false,
"text": "this() this() this this() this(args) Class Test {\n Test() {\n this(10); // calls the constructor with integer args, Test(int a)\n }\n Test(int a) {\n this(10.5); // call the constructor with double arg, Test(double a)\n }\n Test(double a) {\n System.out.println(\"I am a double arg constructor\");\n }\n}\n"
},
{
"answer_id": 40721089,
"author": "Py-Coder",
"author_id": 5340833,
"author_profile": "https://Stackoverflow.com/users/5340833",
"pm_score": 3,
"selected": false,
"text": "class ConstructorDemo \n{\n ConstructorDemo()//Default Constructor\n {\n System.out.println(\"D.constructor \");\n }\n\n ConstructorDemo(int k)//Parameterized constructor\n {\n this();//-------------(1)\n System.out.println(\"P.Constructor =\"+k); \n }\n\n public static void main(String[] args) \n {\n //this(); error because \"must be first statement in constructor\n new ConstructorDemo();//-------(2)\n ConstructorDemo g=new ConstructorDemo(3);---(3) \n }\n } \n"
},
{
"answer_id": 41521892,
"author": "S R Chaitanya",
"author_id": 4543733,
"author_profile": "https://Stackoverflow.com/users/4543733",
"pm_score": 4,
"selected": false,
"text": "public class Product {\n private int productId;\n private String productName;\n private double productPrice;\n private String category;\n\n public Product(int id, String name) {\n this(id,name,1.0);\n }\n\n public Product(int id, String name, double price) {\n this(id,name,price,\"DEFAULT\");\n }\n\n public Product(int id,String name,double price, String category){\n this.productId=id;\n this.productName=name;\n this.productPrice=price;\n this.category=category;\n }\n}\n public Product(int id, String name, double price) {\n System.out.println(\"Calling constructor with price\");\n this(id,name,price,\"DEFAULT\");\n}\n public class SuperClass {\n public SuperClass() {\n System.out.println(\"Inside super class constructor\");\n }\n}\npublic class SubClass extends SuperClass {\n public SubClass () {\n //Even if we do not add, Java adds the call to super class's constructor like \n // super();\n System.out.println(\"Inside sub class constructor\");\n }\n}\n"
},
{
"answer_id": 42575098,
"author": "Akshay Gaikwad",
"author_id": 6069781,
"author_profile": "https://Stackoverflow.com/users/6069781",
"pm_score": 3,
"selected": false,
"text": "class MyConstructorDemo extends ConstructorDemo\n{\n MyConstructorDemo()\n {\n this(\"calling another constructor\");\n }\n MyConstructorDemo(String arg)\n {\n System.out.print(\"This is passed String by another constructor :\"+arg);\n }\n}\n super()"
},
{
"answer_id": 47274985,
"author": "Rodney P. Barbati",
"author_id": 1588303,
"author_profile": "https://Stackoverflow.com/users/1588303",
"pm_score": 3,
"selected": false,
"text": "class LambdaInitedClass {\n\n public LamdaInitedClass(Consumer<LambdaInitedClass> init) {\n init.accept(this);\n }\n}\n new LambdaInitedClass(l -> { // init l any way you want });\n"
},
{
"answer_id": 47414995,
"author": "GetBackerZ",
"author_id": 2576702,
"author_profile": "https://Stackoverflow.com/users/2576702",
"pm_score": 3,
"selected": false,
"text": "public class SomeClass{\n\n private int number;\n private String someString;\n\n public SomeClass(){\n number = 0;\n someString = new String();\n }\n\n public SomeClass(int number){\n this(); //set the class to 0\n this.setNumber(number); \n }\n\n public SomeClass(int number, String someString){\n this(number); //call public SomeClass( int number )\n this.setString(someString);\n }\n\n public void setNumber(int number){\n this.number = number;\n }\n public void setString(String someString){\n this.someString = someString;\n }\n //.... add some accessors\n}\n public SomeOtherClass extends SomeClass {\n public SomeOtherClass(int number, String someString){\n super(number, someString); //calls public SomeClass(int number, String someString)\n }\n //.... Some other code.\n}\n"
},
{
"answer_id": 48415573,
"author": "Negi Rox",
"author_id": 5483580,
"author_profile": "https://Stackoverflow.com/users/5483580",
"pm_score": 2,
"selected": false,
"text": " import java.util.*;\n import java.lang.*;\n\n class Test\n { \n public static void main(String args[])\n {\n Dog d = new Dog(); // Both Calling Same Constructor of Parent Class i.e. 0 args Constructor.\n Dog cs = new Dog(\"Bite\"); // Both Calling Same Constructor of Parent Class i.e. 0 args Constructor.\n\n // You need to Explicitly tell the java compiler to use Argument constructor so you need to use \"super\" key word\n System.out.println(\"------------------------------\");\n Cat c = new Cat();\n Cat caty = new Cat(\"10\");\n\n System.out.println(\"------------------------------\");\n // Self s = new Self();\n Self ss = new Self(\"self\");\n }\n }\n\n class Animal\n {\n String i;\n\n public Animal()\n {\n i = \"10\";\n System.out.println(\"Animal Constructor :\" +i);\n }\n public Animal(String h)\n {\n i = \"20\";\n System.out.println(\"Animal Constructor Habit :\"+ i);\n }\n }\n\n class Dog extends Animal\n {\n public Dog()\n {\n System.out.println(\"Dog Constructor\");\n }\n public Dog(String h)\n {\n System.out.println(\"Dog Constructor with habit\");\n }\n }\n\n class Cat extends Animal\n {\n public Cat()\n {\n System.out.println(\"Cat Constructor\");\n }\n public Cat(String i)\n {\n super(i); // Calling Super Class Paremetrize Constructor.\n System.out.println(\"Cat Constructor with habit\");\n }\n }\n\n class Self\n {\n public Self()\n {\n System.out.println(\"Self Constructor\");\n }\n public Self(String h)\n {\n this(); // Explicitly calling 0 args constructor. \n System.out.println(\"Slef Constructor with value\");\n }\n }\n"
},
{
"answer_id": 50728250,
"author": "Omar Faroque Anik",
"author_id": 3254692,
"author_profile": "https://Stackoverflow.com/users/3254692",
"pm_score": 2,
"selected": false,
"text": " public Omar(){};\n public Omar(a){};\n public Omar(a,b){};\n public Omar(a,b,c){};\n public Omar(a,b,c,d){};\n ...\n"
},
{
"answer_id": 51576459,
"author": "John McClane",
"author_id": 9772691,
"author_profile": "https://Stackoverflow.com/users/9772691",
"pm_score": 3,
"selected": false,
"text": "this(...) super(...)"
},
{
"answer_id": 55583536,
"author": "rogerdpack",
"author_id": 32453,
"author_profile": "https://Stackoverflow.com/users/32453",
"pm_score": 1,
"selected": false,
"text": "{ \n System.out.println(\"this is shared constructor code executed before the constructor\");\n field1 = 3;\n}\n"
},
{
"answer_id": 56663443,
"author": "ansh sachdeva",
"author_id": 7500651,
"author_profile": "https://Stackoverflow.com/users/7500651",
"pm_score": 1,
"selected": false,
"text": " class User {\n private long id;\n private String username;\n private int imageRes;\n\n public User() {\n init(defaultID,defaultUsername,defaultRes);\n }\n public User(String username) {\n init(defaultID,username, defaultRes());\n }\n\n public User(String username, int imageRes) {\n init(defaultID,username, imageRes);\n }\n\n public User(long id, String username, int imageRes) {\n init(id,username, imageRes);\n\n }\n\n private void init(long id, String username, int imageRes) {\n this.id=id;\n this.username = username;\n this.imageRes = imageRes;\n }\n}\n"
},
{
"answer_id": 57314267,
"author": "Soni K",
"author_id": 6505685,
"author_profile": "https://Stackoverflow.com/users/6505685",
"pm_score": 3,
"selected": false,
"text": "public class Animal {\n private int animalType;\n\n public Animal() {\n this(1); //here this(1) internally make call to Animal(1);\n }\n\n public Animal(int animalType) {\n this.animalType = animalType;\n }\n}\n"
},
{
"answer_id": 65745848,
"author": "Anil Nivargi",
"author_id": 8450064,
"author_profile": "https://Stackoverflow.com/users/8450064",
"pm_score": 4,
"selected": false,
"text": " public class Example {\n \n private String name;\n \n public Example() {\n this(\"Mahesh\");\n }\n\n public Example(String name) {\n this.name = name;\n }\n\n }\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33203/"
] |
285,197
|
<p>I have a database table (sql server 2008) that I want to view data for, what is the quickest way of displaying this data?</p>
<p>(if it could have paging that would be perfect).</p>
<p>Would it be a gridview or ?</p>
<p>query: select * from testData</p>
|
[
{
"answer_id": 285203,
"author": "Kon",
"author_id": 22303,
"author_profile": "https://Stackoverflow.com/users/22303",
"pm_score": 2,
"selected": false,
"text": "gridview.DataSource = yourDataTable;\ngridview.DataBind();\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,205
|
<p>We are looking to improve our marketing email list by preventing fake emails from entering in the first place. We want to confirm that an email address exists (and that there is actually a mailbox for that email address). </p>
<p>Does anyone know of any services or components to validate an email address? </p>
|
[
{
"answer_id": 285222,
"author": "Adam Alexander",
"author_id": 33164,
"author_profile": "https://Stackoverflow.com/users/33164",
"pm_score": 0,
"selected": false,
"text": "(\\w+@[a-zA-Z_]+?\\.[a-zA-Z]{2,6})\n"
},
{
"answer_id": 2795881,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": " \n\n // Create a new instance of the EmailValidator class.\n EmailValidator em = new EmailValidator();\n em.MessageLogging += em_MessageLogging;\n em.EmailValidated += em_EmailValidationCompleted;\n try\n {\n string[] list = new string[3] { \"test1@testdomain.com\", \"test2@testdomain.com\", \"test3@testdomain.com\" };\n em.ValidateEmails(list);\n }\n catch (EmailValidatorException exc2)\n {\n Console.WriteLine(\"EmailValidatorException: \" + exc2.Message);\n }\n\n\n "
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21579/"
] |
285,214
|
<p>I'm embedding an IE control into my C++ application. The problem is that although system-wide, ClearType is disabled, IE7 has its own separate setting, and unless I specifically disable that too, text inside the IE control will be antialiased while the rest of the app will not.</p>
<p>The same goes for IE7's font size setting.</p>
<p>It wouldn't be a problem for me to set up IE7 accordingly, but it would affect the experience of users of my app. Can the IE control's cleartype usage and font size be programmatically controlled?</p>
|
[
{
"answer_id": 285222,
"author": "Adam Alexander",
"author_id": 33164,
"author_profile": "https://Stackoverflow.com/users/33164",
"pm_score": 0,
"selected": false,
"text": "(\\w+@[a-zA-Z_]+?\\.[a-zA-Z]{2,6})\n"
},
{
"answer_id": 2795881,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": " \n\n // Create a new instance of the EmailValidator class.\n EmailValidator em = new EmailValidator();\n em.MessageLogging += em_MessageLogging;\n em.EmailValidated += em_EmailValidationCompleted;\n try\n {\n string[] list = new string[3] { \"test1@testdomain.com\", \"test2@testdomain.com\", \"test3@testdomain.com\" };\n em.ValidateEmails(list);\n }\n catch (EmailValidatorException exc2)\n {\n Console.WriteLine(\"EmailValidatorException: \" + exc2.Message);\n }\n\n\n "
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285214",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9665/"
] |
285,227
|
<p><strong>SQL Server 2000:</strong> Is there a way to find out server memory / CPU parameters in Query Analyzer?</p>
|
[
{
"answer_id": 285798,
"author": "Mladen Prajdic",
"author_id": 31345,
"author_profile": "https://Stackoverflow.com/users/31345",
"pm_score": 0,
"selected": false,
"text": "perfmon"
},
{
"answer_id": 285806,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": -1,
"selected": false,
"text": "SELECT *\nFROM sys.dm_os_sys_info\n xp_cmdshell sp_OA"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,228
|
<p>We have a system where customers, mainly European enter texts (in UTF-8) that has to be distributed to different systems, most of them accepting UTF-8, but now we must also distribute the texts to a US system which only accepts US-Ascii 7-bit</p>
<p>So now we'll need to translate all European characters to the nearest US-Ascii. Is there any Java libraries to help with this task?</p>
<p>Right now we've just started adding to a translation table, where Å (swedish AA)->A and so on and where we don't find any match for an entered character, we'll log it and replace with a question mark and try and fix that for the next release, but it seems very inefficient and somebody else must have done something similair before.</p>
|
[
{
"answer_id": 285247,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 0,
"selected": false,
"text": "CharsetEncoder nio String.getBytes(Charset) ByteArrayOutputStream"
},
{
"answer_id": 1483057,
"author": "Rob",
"author_id": 179699,
"author_profile": "https://Stackoverflow.com/users/179699",
"pm_score": -1,
"selected": false,
"text": "private synchronized static String utftoasci(String s){\n final StringBuffer sb = new StringBuffer( s.length() * 2 );\n\n final StringCharacterIterator iterator = new StringCharacterIterator( s );\n\n char ch = iterator.current();\n\n while( ch != StringCharacterIterator.DONE ){\n if(Character.getNumericValue(ch)>0){\n sb.append( ch );\n }else{\n boolean f=false;\n if(Character.toString(ch).equals(\"Ê\")){sb.append(\"E\");f=true;}\n if(Character.toString(ch).equals(\"È\")){sb.append(\"E\");f=true;}\n if(Character.toString(ch).equals(\"ë\")){sb.append(\"e\");f=true;}\n if(Character.toString(ch).equals(\"é\")){sb.append(\"e\");f=true;}\n if(Character.toString(ch).equals(\"è\")){sb.append(\"e\");f=true;}\n if(Character.toString(ch).equals(\"è\")){sb.append(\"e\");f=true;}\n if(Character.toString(ch).equals(\"Â\")){sb.append(\"A\");f=true;}\n if(Character.toString(ch).equals(\"ä\")){sb.append(\"a\");f=true;}\n if(Character.toString(ch).equals(\"ß\")){sb.append(\"ss\");f=true;}\n if(Character.toString(ch).equals(\"Ç\")){sb.append(\"C\");f=true;}\n if(Character.toString(ch).equals(\"Ö\")){sb.append(\"O\");f=true;}\n if(Character.toString(ch).equals(\"º\")){sb.append(\"\");f=true;}\n if(Character.toString(ch).equals(\"Ó\")){sb.append(\"O\");f=true;}\n if(Character.toString(ch).equals(\"ª\")){sb.append(\"\");f=true;}\n if(Character.toString(ch).equals(\"º\")){sb.append(\"\");f=true;}\n if(Character.toString(ch).equals(\"Ñ\")){sb.append(\"N\");f=true;}\n if(Character.toString(ch).equals(\"É\")){sb.append(\"E\");f=true;}\n if(Character.toString(ch).equals(\"Ä\")){sb.append(\"A\");f=true;}\n if(Character.toString(ch).equals(\"Å\")){sb.append(\"A\");f=true;}\n if(Character.toString(ch).equals(\"ä\")){sb.append(\"a\");f=true;}\n if(Character.toString(ch).equals(\"Ü\")){sb.append(\"U\");f=true;}\n if(Character.toString(ch).equals(\"ö\")){sb.append(\"o\");f=true;}\n if(Character.toString(ch).equals(\"ü\")){sb.append(\"u\");f=true;}\n if(Character.toString(ch).equals(\"á\")){sb.append(\"a\");f=true;}\n if(Character.toString(ch).equals(\"Ó\")){sb.append(\"O\");f=true;}\n if(Character.toString(ch).equals(\"É\")){sb.append(\"E\");f=true;}\n if(!f){\n sb.append(\"?\");\n }\n }\n ch = iterator.next();\n }\n return sb.toString();\n }\n"
},
{
"answer_id": 2413228,
"author": "Simon Lieschke",
"author_id": 2766,
"author_profile": "https://Stackoverflow.com/users/2766",
"pm_score": 5,
"selected": false,
"text": "public static String decompose(String s) {\n return java.text.Normalizer.normalize(s, java.text.Normalizer.Form.NFD).replaceAll(\"\\\\p{InCombiningDiacriticalMarks}+\",\"\");\n}\n"
},
{
"answer_id": 5312826,
"author": "code_monk",
"author_id": 977083,
"author_profile": "https://Stackoverflow.com/users/977083",
"pm_score": -1,
"selected": false,
"text": "<?php\nfunction remove_accent($str) {\n# http://www.php.net/manual/en/function.preg-replace.php#96586\n$a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'Ā', 'ā', 'Ă', 'ă', 'Ą', 'ą', 'Ć', 'ć', 'Ĉ', 'ĉ', 'Ċ', 'ċ', 'Č', 'č', 'Ď', 'ď', 'Đ', 'đ', 'Ē', 'ē', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę', 'ę', 'Ě', 'ě', 'Ĝ', 'ĝ', 'Ğ', 'ğ', 'Ġ', 'ġ', 'Ģ', 'ģ', 'Ĥ', 'ĥ', 'Ħ', 'ħ', 'Ĩ', 'ĩ', 'Ī', 'ī', 'Ĭ', 'ĭ', 'Į', 'į', 'İ', 'ı', 'IJ', 'ij', 'Ĵ', 'ĵ', 'Ķ', 'ķ', 'Ĺ', 'ĺ', 'Ļ', 'ļ', 'Ľ', 'ľ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'Ń', 'ń', 'Ņ', 'ņ', 'Ň', 'ň', 'ʼn', 'Ō', 'ō', 'Ŏ', 'ŏ', 'Ő', 'ő', 'Œ', 'œ', 'Ŕ', 'ŕ', 'Ŗ', 'ŗ', 'Ř', 'ř', 'Ś', 'ś', 'Ŝ', 'ŝ', 'Ş', 'ş', 'Š', 'š', 'Ţ', 'ţ', 'Ť', 'ť', 'Ŧ', 'ŧ', 'Ũ', 'ũ', 'Ū', 'ū', 'Ŭ', 'ŭ', 'Ů', 'ů', 'Ű', 'ű', 'Ų', 'ų', 'Ŵ', 'ŵ', 'Ŷ', 'ŷ', 'Ÿ', 'Ź', 'ź', 'Ż', 'ż', 'Ž', 'ž', 'ſ', 'ƒ', 'Ơ', 'ơ', 'Ư', 'ư', 'Ǎ', 'ǎ', 'Ǐ', 'ǐ', 'Ǒ', 'ǒ', 'Ǔ', 'ǔ', 'Ǖ', 'ǖ', 'Ǘ', 'ǘ', 'Ǚ', 'ǚ', 'Ǜ', 'ǜ', 'Ǻ', 'ǻ', 'Ǽ', 'ǽ', 'Ǿ', 'ǿ'); \n$b = array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o'); \nreturn str_replace($a, $b, $str); \n}\n\nfunction SEOify($i){\n# http://php.ca/manual/en/function.preg-replace.php#90316\n$o = $i;\n$o = html_entity_decode($o,ENT_COMPAT,'UTF-8');\n$o = remove_accent(trim($o)); \n$patterns = array( \"([\\40])\" , \"([^a-zA-Z0-9_-])\", \"(-{2,})\" ); \n$replacers = array(\"-\", \"\", \"-\"); \n$o = preg_replace($patterns, $replacers, $o);\nreturn $o;\n}\n?>\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30354/"
] |
285,238
|
<p>Firstly I'm extending an existing class structure and cannot alter the original, with that caveat:</p>
<p>I would like to do this:</p>
<pre><code>class a
{
int val;
... // usual constructor, etc...
public int displayAlteredValue(int inp)
{
return (val*inp);
}
}
class b extends a
{
... // usual constructor, etc...
public in displayAlteredValue(int inp1, int inp2)
{
return (val*inp1*inp2);
}
}
</code></pre>
<p>As I said before I cannot alter <code>class a</code> and I want to maintain the function name <code>displayAlteredValue</code> rather than making a new function.
If this can be done I only have to change a few instantiations of <code>a</code> to instantiations of <code>b</code>. I don't want to spend a lot of time replacing the many function calls to <code>displayAlteredValue</code>. (And yes I do realise there are such things as search and replace however for other reasons, doing that would be problematic).</p>
<p>Any ideas?</p>
|
[
{
"answer_id": 285258,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 1,
"selected": false,
"text": "public int displayAlteredValue(int inp)\n{\n return super.displayAlteredValue(inp);\n}\n"
},
{
"answer_id": 285295,
"author": "Feet",
"author_id": 18340,
"author_profile": "https://Stackoverflow.com/users/18340",
"pm_score": 2,
"selected": false,
"text": "public class DerivedOverload {\n\n /**\n * @param args\n */\n public static void main(String[] args) {\n A classA = new A(); \n\n B classB = new B();\n\n System.out.println(\"DerivedOverload.main() classA.displayAlteredValue(2) : \" + classA.displayAlteredValue(2));\n\n System.out.println(\"DerivedOverload.main() classA.displayAlteredValue(2) : \" + classB.displayAlteredValue(2,2));\n }\n\n\n\n}\n\n\nclass A\n{\n int val = 2;\n\n A(){\n\n }\n\n public int displayAlteredValue(int inp)\n {\n return (val*inp);\n }\n}\n\nclass B extends A\n{\n B(){\n\n }\n\n public int displayAlteredValue(int inp1, int inp2)\n {\n return (val*inp1*inp2);\n }\n}\n"
},
{
"answer_id": 285303,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 2,
"selected": false,
"text": "// this works because b is a subclass of a\na anObject = new b();\n\n// this will not compile because the declared type of anObject is a\nint x = anObject.getValue( 1, 2 );\n"
},
{
"answer_id": 285346,
"author": "Elie",
"author_id": 23249,
"author_profile": "https://Stackoverflow.com/users/23249",
"pm_score": 0,
"selected": false,
"text": "public int displayAlteredValue(int inp) \n{\n return -1;\n}\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,251
|
<p>I maintain the build system at my company, which is currently using CVS. This build system is used across multiple projects and multiple CVS repositories.</p>
<p>Whenever we have a release milestone, we create a tag. In CVS, this is easy:</p>
<pre><code>$ cvs tag TAG_NAME
</code></pre>
<p>That command works regardless of the CVS module or repository, as long as it is executed in a CVS working directory.</p>
<p>In order to do the same thing in subversion though, it looks like I will first have to parse the output of <code>svn info</code> to get the repository root. Then I can create the tag with:</p>
<pre><code>svn cp . $REPO_ROOT/tags/TAG_NAME -m"Created tag TAG_NAME"
</code></pre>
<p>This of course assumes that the svn repository has the recommended "trunk, tags, branches" directory structure. So to be safe I'll probably need to verify this first.</p>
<p>That seems like a lot of work just to map a revision number to a symbolic name. Is there a better way?</p>
|
[
{
"answer_id": 285411,
"author": "bendin",
"author_id": 33412,
"author_profile": "https://Stackoverflow.com/users/33412",
"pm_score": 3,
"selected": false,
"text": "svnurl .../PROJECTNAME/trunk\n tags\n branches\n svnurl -tl # gives a list of tags for the current project \nsvnurl -tlu # the same as full urls\nsvnurl -t 1.1 # the url for the tag 1.1 of the current project\n# analagous functions for branches\nsvnurl -ru # the url of the \"root\" of the current working copy\n # eg svn://.../PROJECTNAME/branches/foo\nsvnurl -T # the url of the trunk of the current project\nsvnurl -pn # the name of the current project, `PROJECTNAME`\n# ...\n $ svn cp $(svnurl -T) $(svnurl -t 1.1.1) # tag trunk as 1.1.1\n"
},
{
"answer_id": 344722,
"author": "Jason Day",
"author_id": 737,
"author_profile": "https://Stackoverflow.com/users/737",
"pm_score": 4,
"selected": true,
"text": "<!-- First, we need to get the svn repository root URL by parsing\nthe output of 'svn info'. -->\n<exec executable=\"svn\" failonerror=\"yes\">\n <arg line=\"info\"/>\n\n <redirector outputproperty=\"svninfo.out\" errorproperty=\"svninfo.err\">\n <outputfilterchain>\n <linecontains>\n <contains value=\"Repository Root: \"/>\n </linecontains>\n\n <tokenfilter>\n <replacestring from=\"Repository Root: \" to=\"\"/>\n </tokenfilter>\n </outputfilterchain>\n </redirector>\n</exec>\n\n<echo level=\"verbose\" message=\"Root from svn info: ${svninfo.out}\"/>\n\n<!-- Set the svn.root property from the svn info output, and append\nthe module prefix if it exists. The module prefix allows multiple\nprojects to use the same repository root. -->\n<condition property=\"svn.root\" value=\"${svninfo.out}/${svn.module.prefix}\">\n <isset property=\"svn.module.prefix\"/>\n</condition>\n<!-- Note that the next line will have no effect if the property was\nset in the condition above, since ant properties are immutable. The\neffect is an \"else\", if the condition above is NOT true. -->\n<property name=\"svn.root\" value=\"${svninfo.out}\"/>\n<echo level=\"verbose\" message=\"Root: ${svn.root}\"/>\n\n<!-- Verify the tags directory exists. -->\n<exec executable=\"svn\"\n failonerror=\"no\"\n outputproperty=\"null\"\n errorproperty=\"svn.ls.error\">\n <arg line=\"ls ${svn.root}/tags\"/>\n</exec>\n<fail>\nCannot find 'tags' subdirectory.\n\n${svn.ls.error}\n\nThe subversion repository is expected to have 'trunk', 'branches', and 'tags'\nsubdirectories. The tag '${tag}' will need to be manually created.\n <condition>\n <not>\n <equals arg1=\"${svn.ls.error}\" arg2=\"\" trim=\"yes\"/>\n </not>\n </condition>\n</fail>\n\n<!-- Finally, do the actual tag (copy in subversion). -->\n<exec executable=\"svn\" failonerror=\"yes\">\n <arg line=\"cp . ${svn.root}/tags/${tag} -m 'Created tag ${tag}'\"/>\n</exec>\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/737/"
] |
285,276
|
<p>SAP HR apparently has several models for describing the relationship between Position (S), Job (C), Organization (O) and Person (P) objects that the Organizational Management (OM) module is used to maintain.</p>
<p>P (Person) objects are usually Holders of Positions (S).</p>
<p>There is the S-S relationship model, which I am told is called Supervisory model. That is each Position reports to another position, and one of the positions is considered a manager.</p>
<p>There is another model whose name I am trying to locate, where the structure of Organizational reporting is between O objects first, in a tree structure. At each node, the S objects belong to the O object, with one of them flagged as the Manager. </p>
<p>No doubt there are other models, and if you know what they are called, and how they work, that would be very useful! </p>
<p>My perspective on this question is while trying to implement a Novell Identity Manager driver from SAP HR into an eDirectory identity vault, from there to provision users into Active Directory and Lotus Notes.</p>
<p>One of the key drivers for the project is the manager and directReports structure, so that Managers can all be identified, and the reporting structure visualized. Thus the importance of the SAP HR relationship modelling.</p>
|
[
{
"answer_id": 397516,
"author": "PATRY Guillaume",
"author_id": 49804,
"author_profile": "https://Stackoverflow.com/users/49804",
"pm_score": 4,
"selected": true,
"text": "SELECT * from HRP1001 where OTYPE = 'S' \n AND RELAT = '012' \n and RSIGN = 'A' \n and begda <= sy-datum \n and endda >= sy-datum \n and sclass = 'O'.\n...\n 'RH_STRUC_GET'"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32247/"
] |
285,277
|
<p>I have some program settings that are currently stored in HKEY_LOCAL_MACHINE. Due to Vista and locked down users, some users don't have permission to HKEY_LOCAL_MACHINE, and those values don't really belong to HKEY_LOCAL_USER either (it has to be the same for all users), what's the best alternative location for storing these?</p>
<p>Majority of settings are stored in the DB already, but there are some that the program needs to know about before connecting to the DB. Ideally I'll like a way to implement this without needing to check what operating system is running.</p>
<p>This is for a desktop app written in Delphi.</p>
|
[
{
"answer_id": 286027,
"author": "Rômulo Ceccon",
"author_id": 23193,
"author_profile": "https://Stackoverflow.com/users/23193",
"pm_score": 6,
"selected": true,
"text": "HKEY_CURRENT_USER CSIDL_APPDATA CSIDL_LOCAL_APPDATA HKEY_LOCAL_MACHINE CSIDL_COMMON_APPDATA CSIDL_*"
},
{
"answer_id": 864969,
"author": "Ian Boyd",
"author_id": 12597,
"author_profile": "https://Stackoverflow.com/users/12597",
"pm_score": 1,
"selected": false,
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\"> \n <assemblyIdentity \n version=\"1.0.0.0\"\n processorArchitecture=\"X86\"\n name=\"IsUserAdmin\"\n type=\"win32\"/> \n\n <description>Description of your application</description> \n\n <!-- Identify the application security requirements. -->\n <trustInfo xmlns=\"urn:schemas-microsoft-com:asm.v3\">\n <security>\n <requestedPrivileges>\n <requestedExecutionLevel\n level=\"requireAdministrator\"\n uiAccess=\"false\"/>\n </requestedPrivileges>\n </security>\n </trustInfo>\n</assembly>\n"
},
{
"answer_id": 13696910,
"author": "twdlewis",
"author_id": 1843971,
"author_profile": "https://Stackoverflow.com/users/1843971",
"pm_score": 1,
"selected": false,
"text": "2048 byte"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26305/"
] |
285,286
|
<p>I have a number of string arrays. The string in every array are ordered the same way, according the same criteria. However, some string may be missing from some arrays, and there may be no array that has a complete set of strings. Moreover, the criteria used to compare the strings is not available to me: outside of the context of the array, I cannot tell which string should precede another.</p>
<p>I need a way to produce a complete set of strings, properly ordered. Or fail when the arrays do not have enough information for me to do so.</p>
<p>Is anyone familiar with this kind of problem? What is the proper algorithm?</p>
<p>Examples:</p>
<pre><code>A B D
A C D
</code></pre>
<p>Can't order correctly, can't decide the order of B and C </p>
<pre><code>A B D
A B C
A C D
</code></pre>
<p>This has enough information to order ABCD correctly.</p>
|
[
{
"answer_id": 285447,
"author": "FallenAvatar",
"author_id": 36965,
"author_profile": "https://Stackoverflow.com/users/36965",
"pm_score": 3,
"selected": false,
"text": "A B D\nA B C\nA C D\n A B D C\n enum Type\n{\n Unknown = 0,\n Greater = 1,\n Equal = 2,\n Less = 3,\n}\n 0 0 0 0\n0 0 0 0\n0 0 0 0\n0 0 0 0\n A B D C\nA 0 0 0 0\nB 0 0 0 0\nD 0 0 0 0\nC 0 0 0 0\n 2 0 0 0\n0 2 0 0\n0 0 2 0\n0 0 0 2\n for(int i=0; i<len(arr)-1; i++)\n{\n char c1 = arr[i], c2 = arr[i+1];\n int i1,i2;\n //get indices of characters in array and put in i1, and i2 respectively\n matrix[i1][i2] = Type.Less;\n matrix[i2][i1] = Type.Greater\n}\n"
},
{
"answer_id": 285460,
"author": "Jay Kominek",
"author_id": 32878,
"author_profile": "https://Stackoverflow.com/users/32878",
"pm_score": 0,
"selected": false,
"text": "A B\nA C\nB C\nC C\nC D\n B\nC\n C\n C\nD\n"
},
{
"answer_id": 285814,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "A B D\nA B C\nA C D\n table = {A -> B, C\n B -> C, D\n C -> D}\n countUnique = 4\n main()\n{\n foreach (s in table.keys)\n {\n stack.push(s)\n searchForPath()\n stack.pop()\n }\n}\n\nsearchForPath()\n{\n if (table.hasKey(stack.peek))\n {\n // we're not at the end yet\n foreach (s in table[stack.peek])\n {\n // avoid infinite recursion\n if (stack.contains(s)\n continue\n\n stack.push(s)\n searchForPath()\n stack.pop()\n }\n }\n else\n {\n if (stack.size == countUnique)\n {\n // solution found\n captureSolution()\n }\n }\n}\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,289
|
<p>I got a message saying <code>script xyz.py returned exit code 0</code>. What does this mean?</p>
<p>What do the exit codes in Python mean? How many are there? Which ones are important?</p>
|
[
{
"answer_id": 285326,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 9,
"selected": true,
"text": "sys.exit()"
},
{
"answer_id": 285451,
"author": "Eigir",
"author_id": 37007,
"author_profile": "https://Stackoverflow.com/users/37007",
"pm_score": 7,
"selected": false,
"text": "sys.exit $? me@mini:~$ python -c \"\"; echo $?\n0\nme@mini:~$ python -c \"import sys; sys.exit(0)\"; echo $?\n0\nme@mini:~$ python -c \"import sys; sys.exit(43)\"; echo $?\n43\n /usr/include/asm-generic/errno.h"
},
{
"answer_id": 286444,
"author": "Oli",
"author_id": 22035,
"author_profile": "https://Stackoverflow.com/users/22035",
"pm_score": 5,
"selected": false,
"text": "errno import errno, sys\n\nif can_access_resource():\n do_something()\nelse:\n sys.exit(errno.EACCES)\n"
},
{
"answer_id": 30776037,
"author": "laffuste",
"author_id": 1297812,
"author_profile": "https://Stackoverflow.com/users/1297812",
"pm_score": 6,
"selected": false,
"text": "import sys, os\n\ntry:\n config()\nexcept:\n sys.exit(os.EX_CONFIG) \ntry:\n do_stuff()\nexcept:\n sys.exit(os.EX_SOFTWARE)\nsys.exit(os.EX_OK) # code 0, all ok\n"
},
{
"answer_id": 37757298,
"author": "phoenix",
"author_id": 1398841,
"author_profile": "https://Stackoverflow.com/users/1398841",
"pm_score": 3,
"selected": false,
"text": "exitstatus $ pip install exitstatus\n import sys\nfrom exitstatus import ExitStatus\n\nsys.exit(ExitStatus.success)\n"
},
{
"answer_id": 41836217,
"author": "FlipMcF",
"author_id": 82114,
"author_profile": "https://Stackoverflow.com/users/82114",
"pm_score": 4,
"selected": false,
"text": "python script.py && echo 'OK' || echo 'Not OK'\n sys.exit(0) sys.exit(1)"
},
{
"answer_id": 42719261,
"author": "vidstige",
"author_id": 363437,
"author_profile": "https://Stackoverflow.com/users/363437",
"pm_score": -1,
"selected": false,
"text": "exit(0) sys.exit()"
},
{
"answer_id": 48748946,
"author": "weakcamel",
"author_id": 3690758,
"author_profile": "https://Stackoverflow.com/users/3690758",
"pm_score": 3,
"selected": false,
"text": "SystemExit"
},
{
"answer_id": 62695973,
"author": "Lukasz Dynowski",
"author_id": 2095676,
"author_profile": "https://Stackoverflow.com/users/2095676",
"pm_score": 4,
"selected": false,
"text": "exit(0) exit(1) sys"
},
{
"answer_id": 74303223,
"author": "Christophe Moustier",
"author_id": 20407766,
"author_profile": "https://Stackoverflow.com/users/20407766",
"pm_score": 0,
"selected": false,
"text": "with open(\"error_code.log\", 'w') as file:\n file.write('2') # this will trigger a warning\n .step_name:\n variables:\n # my vars\n script:\n - python my_code.py arg1 arg2\n - exit `cat error_code.log`\n allow_failure:\n exit_codes:\n - 2\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19731/"
] |
285,290
|
<p>I'm having trouble sending out a simple HTTP request using Actionscript 3's Socket() object. My onConnect listener is below:</p>
<pre><code>function sConnect(e:Event):void {
trace('connected');
s.writeUTFBytes('GET /outernet/client/rss/reddit-feeds HTTP/1.1\r\n');
s.writeUTFBytes('Host: 208.43.71.50:8080\r\n');
s.writeUTFBytes('Connection: Keep-alive\r\n');
s.flush();
}
</code></pre>
<p>Using a packet sniffer, I can see the request does indeed get sent to the server, but the packet sniffer doesn't identify the protocol as HTTP like it does with other HTTP services. When I run this, the server just eventually disconnects me. I have tried to connect to other simple Apache Servers and just get a malformed request error.</p>
<p>What am I missing here?</p>
|
[
{
"answer_id": 285350,
"author": "Mike Keen",
"author_id": 14182,
"author_profile": "https://Stackoverflow.com/users/14182",
"pm_score": 1,
"selected": false,
"text": "function sConnect(e:Event):void {\n trace('connected');\n s.writeUTFBytes('GET /outernet/client/rss/reddit-feeds HTTP/1.1\\r\\n');\n s.writeUTFBytes('Host: 208.43.71.50:8080\\r\\n');\n s.writeUTFBytes('Connection: Keep-alive\\r\\n\\r\\n');\n s.flush();\n}\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14182/"
] |
285,292
|
<p>I have just started to look at .NET 3.5 so please forgive me if this type of question have been asked before. I am struggling with a decent usage for extension methods, in that I have just downloaded suteki shop an MVC ecommerce offering. In this project there is a pretty standard Repository pattern that extends IRepository. </p>
<p>In order to extend the basic functionality exposed by this interface, extention methods are used i.e.:</p>
<pre><code>public static class CategoryRepositoryExtensions
{
public static Category GetRootCategory(this IRepository<Category> categoryRepository)
{
return categoryRepository.GetById(1);
}
}
</code></pre>
<p>Now this is all well and good, but Interfaces, as far as I am concerned act as contracts to the objects that implement them. </p>
<p>The fact that the repository has been interfaced out suggests an attempt at a data layer agnostic approach. That said, if I were to create my own data layer I would be confused as to what extension methods I would have to create to ensure I have fulfilled the contractual requirement I have to the classes that implement my repository classes.</p>
<p>It seems that the older way of creating an IRepository and then extending that allows a much better visibility of what is required e.g.</p>
<pre><code>ICategoryRepoitory : IRepository<Category>
{
Category GetRootCategory();
}
</code></pre>
<p>So I guess my question is does this use of Extention methods seem wrong to anyone else? If not, why? Should I not be moaning about this?</p>
<p>EDIT:</p>
<p>The above example does seem to be a good example of why extention methods can be very helpful. </p>
<p>I suppose my issue is if data access specific implementations were stuck in the extention method in the data access mechanisms assembly. </p>
<p>That way if I were to swap it out for another mechanism I would have to create a similar extention method in that assembly. </p>
|
[
{
"answer_id": 285368,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": true,
"text": "IRepository<T> IRepository<Category> IRepository<Category>"
},
{
"answer_id": 285375,
"author": "Sunlight",
"author_id": 33650,
"author_profile": "https://Stackoverflow.com/users/33650",
"pm_score": 1,
"selected": false,
"text": "using CategoryRepositoryExtensions;\n...\nCategory c = r.GetRootCategory();\n Category c = CategoryRepositoryExtensions.GetRootCategory(r);\n"
},
{
"answer_id": 285450,
"author": "user35559",
"author_id": 35559,
"author_profile": "https://Stackoverflow.com/users/35559",
"pm_score": 0,
"selected": false,
"text": "<IEnumerable> orders1Enumerable = OrderRepository.GetAllOrders()\n .ContainingProductCode(x);\n <IEnumerable> orders2Enumerable = OrderRepository.GetAllOrders()\n .ContainingProductCode(x)\n .WithShippingZipCode(y);\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/425/"
] |
285,313
|
<p>I have a field in a database that is nearly unique: 98% of the time the values will be unique, but it may have a few duplicates. I won't be doing many searches on this field; say twice a month. The table currently has ~5000 records and will gain about 150 per month.</p>
<p>Should this field have an index?</p>
<p>I am using MySQL.</p>
|
[
{
"answer_id": 285342,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 4,
"selected": true,
"text": "select"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] |
285,314
|
<p>I'm building a tool that automates a process then runs some tests on it's own results then goes to do some other stuff.</p>
<p>In trying to clean up my code I have created a separate file that just has the test cases class. Now before I can run these tests, I have to pass the class a couple of parameters/objects before they can be run. Now the problem is that I can't seem to find a way to pass a parameter/object to the test class.</p>
<p>Right now I am thinking to generate a Yaml file and read it in the test class but it feels "wrong" to use a temporary file for this. If anyone has a nicer solution that would be great!</p>
<p>**************Edit************</p>
<p>Example Code of what I am doing right now:</p>
<pre><code>#!/usr/bin/ruby
require 'test/unit/ui/console/testrunner'
require 'yaml'
require 'TS_SampleTestSuite'
automatingSomething()
importantInfo = getImportantInfo()
File.open('filename.yml', 'w') do |f|
f.puts importantInfo.to_yaml
end
Test::Unit::UI::Console::TestRunner.run(TS_SampleTestSuite)
</code></pre>
<p>Now in the example above TS_SampleTestSuite needs importantInfo, so the first "test case" is a method that just reads in the information from the Yaml file filname.yml. </p>
<p>I hope that clears up some confusion.</p>
|
[
{
"answer_id": 285342,
"author": "Orion Edwards",
"author_id": 234,
"author_profile": "https://Stackoverflow.com/users/234",
"pm_score": 4,
"selected": true,
"text": "select"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37080/"
] |
285,320
|
<p>I need your advice with converting plain text to an URL.</p>
<p>The scenario will be this: The user will select some entry and then click a "convert to link" button. </p>
<p>The entry text the user selected will convert to <code>(link: selected_text)</code>. I do it with JavaScript. And after that, when he clicks the Save button to save all his entry, I don't know how to store <code>(link: selected_text)</code> in tha database.</p>
<p>The URL will be like this: <code>www.mysite.aspx?t=selected_text</code>. </p>
<p>I can convert <code>(link: selected_text)</code> by using replace function in code-behind. But then I don't know how to show user as clickable and also by not showing <code><a href="www.mysite.aspx?t=selected_text"></code></p>
<p>It can be difficult to understand therefore I will show some of my codes to explain.</p>
<pre><code>Private Sub Save(ByVal Entry As String) ' Entry Comes from entry textbox '
Dim elected As String
selected = Entry.Replace("(link: ", "<a href http://www.mysite.com?link=")
selected = Entry.Replace(")", ">")
' then here starts save but not necessary to show '
End Sub
</code></pre>
|
[
{
"answer_id": 286456,
"author": "Serhat Ozgel",
"author_id": 31505,
"author_profile": "https://Stackoverflow.com/users/31505",
"pm_score": 1,
"selected": false,
"text": "(link: here)\n (link: <a href=\"http://www.mysite.com?t=here\">here</a>)\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,323
|
<p>I have an <code>ICollection<T></code> called <code>foos</code> in my class which I want to expose as read-only (see <a href="https://stackoverflow.com/questions/284090/how-to-get-a-readonlycollectiont-of-the-keys-in-a-dictionaryt-s">this question</a>). I see that the interface defines a property <code>.IsReadOnly</code>, which seems appropriate... My question is this: how do I make it obvious to the consumer of the class that <code>foos</code> is read-only? </p>
<p>I don't want to rely on them remembering to query <code>.IsReadOnly</code> before trying a not-implemented method such as <code>.Add()</code>. Ideally, I would like to expose <code>foos</code> as a <code>ReadOnlyCollection<T></code>, but it does not implement <code>IList<T></code>. Should I expose <code>foo</code> via a method called, for example, <code>GetReadOnlyFooCollection</code> rather than via a property? If so, would this not confuse someone who then expects a <code>ReadOnlyCollection<T></code>? </p>
<p>This is C# 2.0, so extension methods like <code>ToList()</code> are not available...</p>
|
[
{
"answer_id": 285360,
"author": "bruno conde",
"author_id": 31136,
"author_profile": "https://Stackoverflow.com/users/31136",
"pm_score": 4,
"selected": false,
"text": "ReadOnlyCollection<T> readOnlyCollection = foos.ToList<T>().AsReadOnly();\n class FooContainer\n {\n private ICollection<Foo> foos;\n public ReadOnlyCollection<Foo> ReadOnlyFoos { get { return foos.ToList<Foo>().AsReadOnly();} }\n\n }\n"
},
{
"answer_id": 285389,
"author": "Juanma",
"author_id": 3730,
"author_profile": "https://Stackoverflow.com/users/3730",
"pm_score": -1,
"selected": false,
"text": "private ICollection<T> items;\n\npublic T[] Items\n{\n get { return new List<T>(items).ToArray(); }\n}\n"
},
{
"answer_id": 538731,
"author": "AwesomeTown",
"author_id": 59397,
"author_profile": "https://Stackoverflow.com/users/59397",
"pm_score": 0,
"selected": false,
"text": "IEnumerable<T> Add Remove Clear Count Contains IEnumerable List<T>"
},
{
"answer_id": 1204866,
"author": "Mank",
"author_id": 23217,
"author_profile": "https://Stackoverflow.com/users/23217",
"pm_score": 1,
"selected": true,
"text": "public IEnumerable<Foose> GetFooseList() {\n foreach(var foos in Collection) {\n yield return foos.Clone();\n }\n}\n"
},
{
"answer_id": 25952559,
"author": "supercat",
"author_id": 363751,
"author_profile": "https://Stackoverflow.com/users/363751",
"pm_score": 2,
"selected": false,
"text": "IReadOnlyCollection<T> IReadOnlyCollection<T> List<T> T[][] ICloneable"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6091/"
] |
285,343
|
<p>I've got an SQL query that looks like this:</p>
<pre><code>INSERT INTO DB..incident
(
incident_number --nvarchar(10)
)
VALUES
(
N'I?'
)
</code></pre>
<p>What does the ? do in the value statement?</p>
<p>EDIT:: Turns out there's some funny business via triggers and custom datatypes that occur on insert (we've got a bit of a messed up DB.) Given normal settings I've marked the answer appropriately.</p>
|
[
{
"answer_id": 285366,
"author": "TGnat",
"author_id": 25121,
"author_profile": "https://Stackoverflow.com/users/25121",
"pm_score": 4,
"selected": true,
"text": "DECLARE @TestTable TABLE (test NVARCHAR(10))\n\nINSERT INTO @TestTable (\n test\n) VALUES ( \n N'I?' ) \n\n\nSELECT * \nFROM @TestTable\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33226/"
] |
285,345
|
<p>This exception is consistently thrown on a SOAP Request which takes almost three minutes to receive and is 2.25 megs in size. </p>
<p>When scouring the web I find all sorts of posts which all seem to be about setting headers on the Request, some want me to not send the "Expect:" header, some want me to send the "Keep-Alive:" header, but irregardless of the headers I send I still get this pesky error. I don't believe that setting any headers is my answer, because <em>I can recreate the exact same request using "curl" and a response does eventually come back with no problems what-so-ever</em>. </p>
<p>My <code><httpRuntime maxRequestLength="409600" executionTimeout="900"/></code>. </p>
<p>I feel as if I'm running out of options. If anyone can provide any assistance I would be most grateful. A few other things to note would be that the server I'm Requesting data from is out of my hands, also these requests are over https and other requests with smaller responses work flawlessly.</p>
<p>Thanks</p>
|
[
{
"answer_id": 285542,
"author": "Robert Wagner",
"author_id": 10784,
"author_profile": "https://Stackoverflow.com/users/10784",
"pm_score": 4,
"selected": false,
"text": "<system.serviceModel>\n <bindings>\n <basicHttpBinding>\n <binding name=\"BasicHttpBinding\" maxBufferSize=\"2147483647\" maxReceivedMessageSize=\"2147483647\">\n <readerQuotas maxDepth=\"32\" maxStringContentLength=\"8388608\" maxArrayLength=\"16384\" maxBytesPerRead=\"4096\" maxNameTableCharCount=\"16384\" />\n </binding>\n </basicHttpBinding>\n </bindings>\n <client>\n <endpoint address=\"http://localhost:1602/EndPoint.svc\" binding=\"basicHttpBinding\" bindingConfiguration=\"BasicHttpBinding\" contract=\"IEndPointContract\" name=\"EndPoint\" behaviorConfiguration=\"EndpointBehaviour\" /> \n </client>\n <behaviors>\n <endpointBehaviors>\n <behavior name=\"EndpointBehaviour\">\n <dataContractSerializer maxItemsInObjectGraph=\"2147483647\" />\n </behavior>\n </endpointBehaviors>\n </behaviors>\n </system.serviceModel>\n"
},
{
"answer_id": 1003930,
"author": "Boris Modylevsky",
"author_id": 91714,
"author_profile": "https://Stackoverflow.com/users/91714",
"pm_score": 3,
"selected": false,
"text": "[ServiceKnownType(typeof(ReturnClass))]"
},
{
"answer_id": 7482121,
"author": "Isaac",
"author_id": 928394,
"author_profile": "https://Stackoverflow.com/users/928394",
"pm_score": 2,
"selected": false,
"text": "[DataMember]\npublic bool HasValue\n{\n get { return true; }\n set { }//adding this line made the solution.\n}\n"
},
{
"answer_id": 8862879,
"author": "aatdark",
"author_id": 539654,
"author_profile": "https://Stackoverflow.com/users/539654",
"pm_score": 2,
"selected": false,
"text": "[DataContract]\npublic class Rating\n{\n private Customer _customer;\n //[DataMember] // <- EITHER HERE \n public Customer Customer\n {\n get { return _customer; }\n set { _customer = value; }\n }\n}\n\n\n[DataContract]\npublic class Customer\n{\n private long _customerID;\n [DataMember]\n public long CustomerID\n {\n get { return _customerID; }\n set { _customerID = value; }\n }\n\n [DataMember] // <- OR HERE\n public Rating Rating\n {\n get { return _rating; }\n set { _rating = value; }\n }\n}\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21909/"
] |
285,372
|
<p>Is there a way to have the compile deduce the template parameter automatically?</p>
<pre><code>template<class T>
struct TestA
{
TestA(T v) {}
};
template<class T>
void TestB(T v)
{
}
int main()
{
TestB (5);
}
</code></pre>
<p>Test B works fine, however when i change it to TestA it will not compile with the error " use of class template requires template argument list"</p>
|
[
{
"answer_id": 285380,
"author": "Sunlight",
"author_id": 33650,
"author_profile": "https://Stackoverflow.com/users/33650",
"pm_score": 5,
"selected": true,
"text": "make_ template<class T> TestA<T> make_TestA(T v)\n{\n return TestA<T>(v);\n}\n std::pair std::make_pair auto someVariable = make_TestA(5);\n"
},
{
"answer_id": 285533,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 0,
"selected": false,
"text": "TestA(5);\n TestA<int>(5);\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,383
|
<p>Given my current .htaccess file, how would I modify it to check for an additional URL path like '/src/pub/<em>' and rewrite it to '/</em>' without affecting the current rewrite?</p>
<p>Here's the original .htaccess file:</p>
<pre><code>RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]
</code></pre>
<p>and here's my recent attempt (which doesn't work):</p>
<pre><code>RewriteEngine on
RewriteRule ^/src/pub/(.*)$ /$1 [R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]
</code></pre>
<p><strong>Edit:</strong> Here are some examples of what I want to accomplish:</p>
<p>New Additional Rule:</p>
<pre><code>From: http://www.mysite.com/src/pub/validfile.php
To: http://www.mysite.com/validfile.php
From: http://www.mysite.com/src/pub/user/detail/testuser
To: http://www.mysite.com/user/detail/testuser
</code></pre>
<p>Existing Rule (already working):</p>
<pre><code>From: http://www.mysite.com/user/detail/testuser
To: http://www.mysite.com/index.php?route=user/detail/testuser
</code></pre>
|
[
{
"answer_id": 285420,
"author": "TimB",
"author_id": 4193,
"author_profile": "https://Stackoverflow.com/users/4193",
"pm_score": 4,
"selected": true,
"text": "RewriteRule ^/src/pub/(.*)$ /$1 [R,L]\n"
},
{
"answer_id": 285433,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 2,
"selected": false,
"text": "RewriteRule ^src/pub/(.*)$ /$1 [R]\n httpd.conf L RewriteRule ^src/pub/(.*)$ /$1 [L,R]\n // using ^/src/pub/(.*)$ - leading slash will not work in .htaccess context!\n(1) pass through /home/test/src\n\n// using ^src/pub/(.*)$\n(2) rewrite 'src/pub/testme' -> '/testme'\n(2) explicitly forcing redirect with http://test/testme\n(1) escaping http://test/testme for redirect\n(1) redirect to http://test/testme [REDIRECT/302]\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] |
285,400
|
<p>The Win32 API call <a href="http://msdn.microsoft.com/en-us/library/ms221570.aspx" rel="noreferrer">RegisterTypeLib()</a> is used to create the registry keys necessary to register a type library.</p>
<p>Unfortunatly, on Windows XP, it tries to write those registry key entries to </p>
<pre><code>HKEY_CLASSES_ROOT\TypeLib
</code></pre>
<p>rather than </p>
<pre><code>HKEY_CURRENT_USER\Software\Classes\TypeLib
</code></pre>
<p>Meaning that a standard user will not be able to run an ActiveX.</p>
<p>In May 2008 Microsoft released a <a href="http://support.microsoft.com/kb/935200" rel="noreferrer">hotfix for Vista</a> to correct this issue - but the problem remains on Windows XP.</p>
<p>What's a standard-user friendly developer to do?</p>
<hr>
<h2>Answer 1</h2>
<p>Use the API call that is designed for it:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms221504.aspx" rel="noreferrer">RegisterTypeLibraryForUser()</a></p>
<h2>Answer 2</h2>
<p>If you can't fix it, hack it:</p>
<pre><code>//begin hack
HKEY key;
RegOpenKeyW(HKEY_CURRENT_USER, @"Software\Classes", out key);
RegOverridePredefKey(HKEY_CLASSES_ROOT, key);
//do original work
RegisterTypeLibrary(...)
//stop hacking
RegOverridePredefKey(HKEY_CLASSES_ROOT, null);
RegCloseKey(key);
</code></pre>
|
[
{
"answer_id": 285454,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 4,
"selected": true,
"text": "RegOverridePredefKey() HKEY_CLASSES_ROOT HKEY_CURRENT_USER\\Software\\Classes http://msdn.microsoft.com/en-us/library/ms724901.aspx"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12597/"
] |
285,408
|
<p>I'm looking for a Python module that would take an arbitrary block of text, search it for something that looks like a date string, and build a DateTime object out of it. Something like <a href="http://search.cpan.org/~sartak/Date-Extract-0.03/lib/Date/Extract.pm" rel="noreferrer">Date::Extract</a> in Perl</p>
<p>Thank you in advance.</p>
|
[
{
"answer_id": 285677,
"author": "Brian",
"author_id": 9493,
"author_profile": "https://Stackoverflow.com/users/9493",
"pm_score": 5,
"selected": true,
"text": ">>> from dateutil.parser import parse\n>>> parse(\"Wed, Nov 12\")\ndatetime.datetime(2008, 11, 12, 0, 0)\n >>> parse(\"the date was the 1st of December 2006 2:30pm\", fuzzy=True)\ndatetime.datetime(2006, 12, 1, 14, 30)\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37089/"
] |
285,421
|
<p>I've asked a few <a href="https://stackoverflow.com/questions/150513/html-input-style-to-hide-the-box-but-show-the-contents">other questions</a> here about this system, so I'll try to avoid repeating a lot of detail.</p>
<p>The short version is that I have many html pages, each with a form that accepts input, but never saves the input anywhere- they are only ever printed out for mailing. A previously developer who had never heard of <code>@media print</code> did the initial work on most of them, and so he came up with some... <em>odd</em> solutions to hide the ugly text boxes on the printed page, usually resulting in two completely separate copies of nearly the same html. Unfortunately, that broke the back button in many cases, and so now I must go back and fix them. </p>
<hr>
<p>In some cases, these html forms really are form letters, with text inputs in the middle of the text. I can style the text inputs so that the box doesn't show, but they are still the wrong size. This results in a bunch of extra ugly whitespace where it doesn't belong. How can make the inputs fit the text entered by the user?</p>
<p>The best I can come up with at the moment is to have a hidden <span> next to each input that is styled to show instead of the input when printing, and use javascript to keep it in sync. But this is ugly. I'm looking for something better.</p>
<p><strong>Update:</strong><br>
Most of our users are still in IE6, but we have some IE7 and firefox out there.</p>
<p><strong>Update2:</strong><br>
I re-thought this a little to use a label rather than a span. I'll maintain the relationship using the label's <code>for</code> attribute. See <a href="https://stackoverflow.com/questions/285522/find-html-label-associated-with-a-given-input">this question</a> for my final code.</p>
|
[
{
"answer_id": 285677,
"author": "Brian",
"author_id": 9493,
"author_profile": "https://Stackoverflow.com/users/9493",
"pm_score": 5,
"selected": true,
"text": ">>> from dateutil.parser import parse\n>>> parse(\"Wed, Nov 12\")\ndatetime.datetime(2008, 11, 12, 0, 0)\n >>> parse(\"the date was the 1st of December 2006 2:30pm\", fuzzy=True)\ndatetime.datetime(2006, 12, 1, 14, 30)\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3043/"
] |
285,422
|
<p>When editing really long code blocks (which should definitely be refactored anyway, but that's beyond the scope of this question), I often long for the ability to collapse statement blocks like one can collapse function blocks. That is to say, it would be great if the minus icon appeared on the code outline for everything enclosed in braces. It seems to appear for functions, classes, regions, namespaces, usings, but not for conditional or iterative blocks. It would be fantastic if I could collapse things like ifs, switches, foreaches, that kind of thing!</p>
<p>Googling into that a bit, I discovered that apparently C++ outlining in VS allows this but C# outlining in VS does not. I don't really get why. Even notepad++ will so these collapses if I select the C# formatting, so I don't get why Visual Studio doesn't.</p>
<p>Does anyone know of a VS2008 add-in that will enable this behavior? Or some sort of hidden setting for it?</p>
<p>Edited to add: inserting regions is of course an option and it did already occur to me, but quite frankly, I shouldn't have to wrap things in a region that are already wrapped in braces... if I was going to edit the existing code, I would just refactor it to have better separation of concern anyway. ("wrapping" with new methods instead of regions ;)</p>
|
[
{
"answer_id": 285430,
"author": "Kon",
"author_id": 22303,
"author_profile": "https://Stackoverflow.com/users/22303",
"pm_score": 4,
"selected": false,
"text": "foreach (Item i in Items)\n{\n #region something big happening here\n ...\n #endregion\n\n #region something big happening here too\n ...\n #endregion\n\n #region something big happening here also\n ...\n #endregion\n}\n"
},
{
"answer_id": 285439,
"author": "Chris Marisic",
"author_id": 37055,
"author_profile": "https://Stackoverflow.com/users/37055",
"pm_score": 2,
"selected": false,
"text": "#region Won't work\nfor(int i = 0; i<Count; i++)\n{\n//do something\n#endregion\n}\n\nfor(int i=0; i<Count; i++)\n{\n#region Works fine\n//do lots of stuff\n#endregion\n}\n"
},
{
"answer_id": 23005763,
"author": "M at",
"author_id": 1454173,
"author_profile": "https://Stackoverflow.com/users/1454173",
"pm_score": 2,
"selected": false,
"text": "(ctrl+m,ctrl+h)"
},
{
"answer_id": 64520736,
"author": "逍遥子k",
"author_id": 3905082,
"author_profile": "https://Stackoverflow.com/users/3905082",
"pm_score": 0,
"selected": false,
"text": "catch finally switch case default comments"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12975/"
] |
285,428
|
<p>I am trying to make the <a href="http://docs.jquery.com/Plugins/Validation" rel="nofollow noreferrer">Validation plugin</a> work. It works fine for individual fields, but when I try to include the demo code for the error container that contains all of the errors, I have an issue. The problem is that it shows the container with all errors when I am in all fields, but I would like to display the error container only when the user presses the submit button (but still show inline errors beside the control when losing focus).</p>
<p>The problem is the message in the container. When I took off the code as mentioned in the answer below for the container, the container output just displays the number of errors in plain text. </p>
<p>What is the trick to get a list of detailed error messages? What I would like is to display "ERROR" next to the control in error when the user presses the tab button, and to have a summary of everything at the end when he presses submit. Is that possible?</p>
<p><strong>Code with all input from here:</strong></p>
<pre><code> $().ready(function() {
var container = $('div.containererreurtotal');
// validate signup form on keyup and submit
$("#frmEnregistrer").bind("invalid-form.validate", function(e, validator) {
var err = validator.numberOfInvalids();
if (err) {
container.html("THERE ARE "+ err + " ERRORS IN THE FORM")
container.show();
} else {
container.hide();
}
}).validate({
rules: {
nickname_in: {
required: true,
minLength: 4
},
prenom_in: {
required: true,
minLength: 4
},
nom_in: {
required: true,
minLength: 4
},
password_in: {
required: true,
minLength: 4
},
courriel_in: {
required: true,
email: true
},
userdigit: {
required: true
}
},
messages: {
nickname_in: "ERROR",
prenom_in: "ERROR",
nom_in: "ERROR",
password_in: "ERROR",
courriel_in: "ERROR",
userdigit: "ERROR"
}
,errorPlacement: function(error, element){
container.append(error.clone());
error.insertAfter(element);
}
});
});
</code></pre>
|
[
{
"answer_id": 285799,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "<div id=\"container\" style=\"display:none;\"></div>\n jQuery('#formId').onsubmit(function() {\n // This will be called before the form is submitted\n jQuery('#container').show();\n});\n"
},
{
"answer_id": 286032,
"author": "user19264",
"author_id": 19264,
"author_profile": "https://Stackoverflow.com/users/19264",
"pm_score": 3,
"selected": false,
"text": "$(\"#frmEnregistrer\").bind(\"invalid-form.validate\", function(e, validator) {\n var err = validator.numberOfInvalids();\n if (err) {\n container.html(\"THERE ARE \"+ err + \" ERRORS IN THE FORM\")\n container.show();\n } else {\n container.hide();\n }\n}).validate({ ... })\n"
},
{
"answer_id": 286788,
"author": "Serxipc",
"author_id": 34009,
"author_profile": "https://Stackoverflow.com/users/34009",
"pm_score": 5,
"selected": true,
"text": "errorPlacement ...\n courriel_in: \"ERROR\",\n userdigit: \"ERROR\"\n }\n ,errorContainer: container\n\n ,errorPlacement: function(error, element){\n var errorClone = error.clone();\n container.append(errorClone);\n error.insertAfter(element) \n }\n\n // We don't need this options\n //,errorLabelContainer: $(\"ol\", container)\n //,wrapper: 'li'\n //,meta: \"validate\"\n });\n ...\n error <label> element jQuery.aop.before({target: jQuery.fn, method: \"hide\"},\n function(){\n this.trigger(\"hide\");\n });\n ...\n ,errorPlacement: function(error, element){\n var errorClone = error.clone();\n container.append(errorClone);\n error.insertAfter(element).bind(\"hide\", function(){\n errorClone.hide();\n });\n }\n ...\n"
},
{
"answer_id": 953434,
"author": "FerrousOxide",
"author_id": 65717,
"author_profile": "https://Stackoverflow.com/users/65717",
"pm_score": 4,
"selected": false,
"text": " $().ready(function() {\n\n $('div#containererreurtotal').hide();\n\n // validate signup form on keyup and submit\n $(\"#frmEnregistrer\").validate({\n errorLabelContainer: \"#containererreurtotal\",\n wrapper: \"p\",\n errorClass: \"error\",\n rules: {\n nickname_in: { required: true, minLength: 4 },\n prenom_in: { required: true, minLength: 4 },\n nom_in: { required: true, minLength: 4 },\n password_in: { required: true, minLength: 4 },\n courriel_in: { required: true, email: true },\n userdigit: { required: true }\n },\n messages: { \n nickname_in: { required: \"Nickname required!\", minLength: \"Nickname too short!\" },\n prenom_in: { required: \"Prenom required!\", minLength: \"Prenom too short!\" },\n nom_in: { required: \"Nom required!\", minLength: \"Nom too short!\" },\n password_in: { required: \"Password required!\", minLength: \"Password too short!\" },\n courriel_in: { required: \"Courriel required!\", email: \"Courriel must be an Email\" },\n userdigit: { required: \"UserDigit required!\" }\n },\n invalidHandler: function(form, validator) {\n $(\"#containererreurtotal\").show();\n },\n unhighlight: function(element, errorClass) {\n if (this.numberOfInvalids() == 0) {\n $(\"#containererreurtotal\").hide();\n }\n $(element).removeClass(errorClass);\n } \n\n });\n });\n"
},
{
"answer_id": 5339599,
"author": "user664378",
"author_id": 664378,
"author_profile": "https://Stackoverflow.com/users/664378",
"pm_score": 2,
"selected": false,
"text": "jQuery(document).ready(function() {\n var submitted = false;\n var validator = jQuery(\"#emailForm\").validate({ \n showErrors: function(errorMap, errorList) {\n if (submitted) {\n var summary = \"\";\n jQuery.each(errorList, function() {\n summary += \"<li><label for='\"+ this.element.name;\n summery += \"' class='formError'>\" + this.message + \"</label></li>\"; });\n jQuery(\"#errorMessageHeader\").show();\n jQuery(\"#errorMessageHeader\").children().after().html(summary);\n submitted = false;\n }\n this.defaultShowErrors();\n }, \n invalidHandler: function(form, validator) { submitted = true; },\n onfocusout: function(element) { this.element(element); },\n errorClass: \"formError\",\n rules: { \n //some validation rules \n },\n messages: { \n //error messages to be displayed\n } \n }); \n}); \n"
},
{
"answer_id": 13659556,
"author": "Oliver Krah",
"author_id": 1868643,
"author_profile": "https://Stackoverflow.com/users/1868643",
"pm_score": 2,
"selected": false,
"text": "errorElement: \"td\",\nerrorPlacement: function (error, element) {\n error.insertAfter(element.parent());\n} \n <table>\n <tr>\n <td>Name:</td>\n <td><input type=\"text\" name=\"name\"></td>\n </tr>\n</table>\n <td> <input>"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13913/"
] |
285,429
|
<p>Under normal circumstances, a VB.NET application of mine can check the ClientName environmental variable to get the name of the workstation the user is connecting from.</p>
<p>So when WorkstationX RDPs into ServerA:</p>
<ul>
<li>ComputerName=ServerA</li>
<li>ClientName=WorkstationX</li>
</ul>
<p>That works fine.</p>
<p>If I right-click on the application and choose Run As Administrator, the ClientName variable is not set.</p>
<p>Does anyone know of a way of easily getting the workstation name of the client connected to the terminal server, even when the application is launched via "Run As Administrator"?</p>
|
[
{
"answer_id": 732558,
"author": "Dan Ports",
"author_id": 88885,
"author_profile": "https://Stackoverflow.com/users/88885",
"pm_score": 2,
"selected": false,
"text": "New Cassia.TerminalServicesManager().CurrentSession.ClientName\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3743/"
] |
285,440
|
<p>In a .NET CF application I wrote, one of the features is to acquire frames from remote cameras. Frames are acquired as single jpeg images and displayed on the screen when available.</p>
<p>It was a good enough solution, but I don't like the fact that the time needed to convert the stream into an <code>Image</code> object, with the <code>Bitmap()</code> constructor, is <em>far far far larger</em> than the time needed to download the stream.</p>
<p>When I surfed some blogs to search about this issue, I found that some developers were using the <code>Image.FromStream()</code> method which has a <code>validateImageData</code> flag that seems to control some validation code. When <code>validateImageData</code> is false, the conversion gets dramatically faster.</p>
<p>Good, I thought .... but the Compact Framework does not implement this method !</p>
<p>Anyone knows how to get around it, or at least how to convert a stream into an <code>Image</code> without unnecessary delays ?</p>
|
[
{
"answer_id": 732558,
"author": "Dan Ports",
"author_id": 88885,
"author_profile": "https://Stackoverflow.com/users/88885",
"pm_score": 2,
"selected": false,
"text": "New Cassia.TerminalServicesManager().CurrentSession.ClientName\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36728/"
] |
285,445
|
<p>Simple yes or no question, and I'm 90% sure that it is no... but I'm not sure.</p>
<p>Can a Base64 string contain tabs?</p>
|
[
{
"answer_id": 285457,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 0,
"selected": false,
"text": "Convert.FromBase64String() string xxx = \"ABCD\\tDEFG\"; //simulated Base64 encoded string w/added tab\nConsole.WriteLine(xxx);\nbyte[] xx = Convert.FromBase64String(xxx); // convert string back to binary\nConsole.WriteLine(BitConverter.ToString(xx));\n ABCD DEFG\n00-10-83-0C-41-46\n"
},
{
"answer_id": 285515,
"author": "Tim Jarvis",
"author_id": 10387,
"author_profile": "https://Stackoverflow.com/users/10387",
"pm_score": 1,
"selected": false,
"text": "private void button2_Click(object sender, EventArgs e)\n{\n StringBuilder sb = new StringBuilder();\n string test = \"The rain in spain falls \\t mainly on the plain\";\n sb.AppendLine(test);\n UTF8Encoding enc = new UTF8Encoding();\n byte[] b = enc.GetBytes(test);\n string cvtd = Convert.ToBase64String(b);\n sb.AppendLine(cvtd);\n byte[] c = Convert.FromBase64String(cvtd);\n string backAgain = enc.GetString(c);\n sb.AppendLine(backAgain);\n MessageBox.Show(sb.ToString());\n}\n"
},
{
"answer_id": 497806,
"author": "John",
"author_id": 59754,
"author_profile": "https://Stackoverflow.com/users/59754",
"pm_score": 0,
"selected": false,
"text": "Data: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\nURLs: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285445",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16794/"
] |
285,446
|
<p>I've got a Windows Forms application with two ListBox controls on the same form.
They both have their SelectionMode set to 'MultiExtended'. </p>
<p>When I change the selection of one the selection of the other changes.</p>
<p>Now I thought I'd done something stupid with my SelectedIndexChanged handlers so I removed them and re-wrote them from scratch, and got the problem.</p>
<p>So I created a brand new WinForms app and dragged two ListBoxes onto the forms surface.</p>
<p>In the constructor I populated them both with the following.</p>
<pre><code>List<Thing> data = new List<Thing>();
for ( int i = 0; i < 50; i++ ) {
Thing temp = new Thing();
temp.Letters = "abc " + i.ToString();
temp.Id = i;
data.Add(temp);
}
listBox1.DataSource = data;
listBox1.DisplayMember = "Letters";
listBox1.ValueMember = "Id";
List<Thing> data2 = new List<Thing>();
for ( int i = 0; i < 50; i++ ) {
Thing temp = new Thing();
temp.Letters = "abc " + i.ToString();
temp.Id = i;
data2.Add(temp);
}
listBox2.DataSource = data2;
listBox2.DisplayMember = "Letters";
listBox2.ValueMember = "Id";
</code></pre>
<p>And then I built and ran the app.</p>
<p>Started selecting some values to see if the symptoms were present.
And they were!</p>
<p>This is literally all the code I added to the form,I had not added any event handlers, I have tried it with the SelectionMode set to 'One' and 'MultiExtended'.</p>
<p>Can anyone give me a clue as to why this is happening.</p>
<p>Cheers</p>
|
[
{
"answer_id": 285488,
"author": "Shaun Bowe",
"author_id": 1514,
"author_profile": "https://Stackoverflow.com/users/1514",
"pm_score": 0,
"selected": false,
"text": "public partial class Form1 : Form\n{\npublic Form1()\n{\n InitializeComponent();\n}\n\nprivate class Thing\n{\n public String Letters { get; set; }\n public Int32 Id { get; set; }\n}\nprivate void Form1_Load(object sender, EventArgs e)\n{\n List<Thing> data = new List<Thing>();\n\n for (int i = 0; i < 50; i++)\n {\n Thing temp = new Thing();\n temp.Letters = \"abc \" + i.ToString();\n temp.Id = i;\n data.Add(temp);\n }\n\n listBox1.DataSource = data;\n listBox1.DisplayMember = \"Letters\";\n listBox1.ValueMember = \"Id\";\n\n\n List<Thing> data2 = new List<Thing>();\n\n for (int i = 0; i < 50; i++)\n {\n Thing temp = new Thing();\n temp.Letters = \"abc \" + i.ToString();\n temp.Id = i;\n data2.Add(temp);\n }\n\n listBox2.DataSource = data2;\n listBox2.DisplayMember = \"Letters\";\n listBox2.ValueMember = \"Id\";\n}\n"
},
{
"answer_id": 289562,
"author": "Greg B",
"author_id": 1741868,
"author_profile": "https://Stackoverflow.com/users/1741868",
"pm_score": 1,
"selected": false,
"text": "theListBox.DataSource = _contacts.Take(_contacts.Count).ToList();\n"
},
{
"answer_id": 289571,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "CurrencyManager BindingContext DataSource CurrencyManager CurrencyManager .ToList() List<T> BindingContext control.BindingContext = new BindingContext();\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1741868/"
] |
285,455
|
<p>I have some global variables in a Python script. Some functions in that script call into C - is it possible to set one of those variables while in C and if so, how?</p>
<p>I appreciate that this isn't a very nice design in the first place, but I need to make a small change to existing code, I don't want to embark on major refactoring of existing scripts.</p>
|
[
{
"answer_id": 285498,
"author": "Sherm Pendley",
"author_id": 27631,
"author_profile": "https://Stackoverflow.com/users/27631",
"pm_score": 5,
"selected": true,
"text": "PyObject *m = PyImport_AddModule(\"__main__\");\nPyObject *v = PyObject_GetAttrString(m,\"foobar\");\n\nint foobar = PyInt_AsLong(v);\n\nPy_DECREF(v);\n"
},
{
"answer_id": 285606,
"author": "Alex Coventry",
"author_id": 1941213,
"author_profile": "https://Stackoverflow.com/users/1941213",
"pm_score": 0,
"selected": false,
"text": "pyrex"
},
{
"answer_id": 287695,
"author": "orip",
"author_id": 37020,
"author_profile": "https://Stackoverflow.com/users/37020",
"pm_score": 0,
"selected": false,
"text": "my_global = my_c_func(...)"
},
{
"answer_id": 25907027,
"author": "Praxeolitic",
"author_id": 1128289,
"author_profile": "https://Stackoverflow.com/users/1128289",
"pm_score": 3,
"selected": false,
"text": "PyObject* PyEval_GetGlobals()\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22517/"
] |
285,456
|
<p>Given the following, how could I insert rows in my db? (Or what should I correct in my schema?)</p>
<p>Models:</p>
<pre><code>class Item < ActiveRecord::Base
has_many :tran_items
has_many :transactions, :through => :tran_items
end
class TranItem < ActiveRecord::Base
belongs_to :item
belongs_to :transaction
end
class Transaction < ActiveRecord::Base #answer: rename Transaction
has_many :tran_items
has_many :items, :through => :tran_items
end
</code></pre>
<p>Schema:</p>
<pre><code>create_table :items do |t|
t.references :tran_items #answer: remove this line
t.string :name
end
create_table :tran_items do |t|
t.belongs_to :items, :transactions, :null => false #answer: unpluralize
t.integer :quantity
end
create_table :transactions do |t|
t.references :tran_items #answer: remove this line
t.decimal :profit
end
</code></pre>
<p>I lost a few hours trying to insert records, using the rails console to test things out.</p>
|
[
{
"answer_id": 285471,
"author": "tamersalama",
"author_id": 7693,
"author_profile": "https://Stackoverflow.com/users/7693",
"pm_score": 1,
"selected": false,
"text": "item = Item.new(:name => \"item\")\nitem.transactions.build(:name => \"transaction\")\nitem.save!\n"
},
{
"answer_id": 285883,
"author": "Mike Breen",
"author_id": 22346,
"author_profile": "https://Stackoverflow.com/users/22346",
"pm_score": 4,
"selected": true,
"text": "create_table :items do |t|\n t.string :name\nend\ncreate_table :tran_items do |t|\n t.belongs_to :item, :transaction, :null => false\n t.integer :quantity\nend\ncreate_table :transactions do |t|\n t.decimal :profit, :default => 0\nend\n >> i = Item.create(:name => 'My Item') \n=> #<Item id: 2, name: \"My Item\">\n>> t = Transaction.create(:profit => 100)\n=> #<Transaction id: 2, profit: #<BigDecimal:2411d2c,'0.1E3',4(8)>>\n>> t.tran_items.create(:item => i)\n=> #<TranItem id: nil, item_id: 2, transaction_id: 2, quantity: nil>\n"
},
{
"answer_id": 288069,
"author": "Mike Breen",
"author_id": 22346,
"author_profile": "https://Stackoverflow.com/users/22346",
"pm_score": 2,
"selected": false,
"text": " create_table :items do |t|\n t.string :name\n end\n create_table :purchase_items do |t|\n t.belongs_to :item, :purchase, :null => false\n t.integer :quantity\n end\n create_table :purchases do |t|\n t.decimal :profit, :default => 0\n end\n class Purchase < ActiveRecord::Base\n has_many :purchase_items\n has_many :items, :through => :purchase_items\nend \n\nclass Item < ActiveRecord::Base\n has_many :purchase_items\n has_many :purchases, :through => :purchase_items\nend\n\nclass PurchaseItem < ActiveRecord::Base\n belongs_to :item\n belongs_to :purchase\nend\n >> i = Item.create(:name => 'Item One')\n=> #<Item id: 1, name: \"Item One\">\n>> p = Purchase.create(:profit => 100)\n=> #<Purchase id: 1, profit: #<BigDecimal:2458cf4,'0.1E3',4(8)>>\n>> p.purchase_items.create(:item => i)\n=> #<PurchaseItem id: 1, item_id: 1, purchase_id: 1, quantity: nil>\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25167/"
] |
285,465
|
<p>Hi Guys I'm very new to regex, can you help me with this.</p>
<p>I have a string like this <code>"<input attribute='value' >"</code> where <code>attribute='value'</code> could be anything and I want to get do a <code>preg_replace</code> to get just <code><input /></code></p>
<p>How do I specify a wildcard to replace any number of any characters in a srting?</p>
<p>like this? <code>preg_replace("/<input.*>/",$replacement,$string);</code></p>
<p>Many thanks</p>
|
[
{
"answer_id": 285479,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 3,
"selected": false,
"text": ".*\n [^>]+\n .*?\n <foo attr=\">\"> \n '<foo attr=\" ' with following text of '\">' \n `<[a-zA-Z]+( [a-zA-Z]+=['\"][^\"']['\"])*)> etc etc \n <foo attr=\"'>\\'\\\"\">\n"
},
{
"answer_id": 285483,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 0,
"selected": false,
"text": "preg_replace(\"<input[^>]*>\", $replacement, $string); \n// [^>] means \"any character except the greater than symbol / right tag bracket\"\n"
},
{
"answer_id": 285634,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile": "https://Stackoverflow.com/users/11917",
"pm_score": 1,
"selected": false,
"text": "preg_replace(\"<input[^>]*>\", $replacement, $string);\n preg_replace(\"<input[^>]*?>\", $replacement, $string);\n"
},
{
"answer_id": 287505,
"author": "Jan Goyvaerts",
"author_id": 33358,
"author_profile": "https://Stackoverflow.com/users/33358",
"pm_score": 0,
"selected": false,
"text": "preg_replace(\"/<input.*>/\",$replacement,$string);\n preg_replace(\"/(<input).*(>)/\",\"$1$2\",$string);\n preg_replace(\"/<input [^>]*>/\",\"<input />\",$string);\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,474
|
<p>If I have 2 DataTables (dtOne and dtTwo) and I want to merge them and put them in another DataTable (dtAll). How can I do this in C#? I tried the Merge statement on the datatable, but this returns void. Does Merge preserve the data? For example, if I do:</p>
<pre><code> dtOne.Merge(dtTwo);
</code></pre>
<p>Does dtOne change or does dtTwo change and if either one changes, do the changes preserve?</p>
<p>I know I can't do this because Merge returns void, but I want to be able to store the Merger of both dtOne and dtTwo in dtAll:</p>
<pre><code>//Will Not work, How do I do this
dtAll = dtOne.Merge(dtTwo);
</code></pre>
|
[
{
"answer_id": 285500,
"author": "Jeromy Irvine",
"author_id": 8223,
"author_profile": "https://Stackoverflow.com/users/8223",
"pm_score": 8,
"selected": true,
"text": "Merge dtAll = dtOne.Copy();\ndtAll.Merge(dtTwo);\n"
},
{
"answer_id": 454453,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "dtAll = dtOne.Copy();\ndtAll.Merge(dtTwo,true);\n"
},
{
"answer_id": 4659253,
"author": "rami220",
"author_id": 571454,
"author_profile": "https://Stackoverflow.com/users/571454",
"pm_score": 1,
"selected": false,
"text": "DataTable dtAll = new DataTable();\nDataTable dt= new DataTable();\nforeach (int id in lst)\n{\n dt.Merge(GetDataTableByID(id)); // Get Data Methode return DataTable\n}\ndtAll = dt;\n"
},
{
"answer_id": 14397873,
"author": "SNag",
"author_id": 979621,
"author_profile": "https://Stackoverflow.com/users/979621",
"pm_score": 5,
"selected": false,
"text": "dtAll = dtOne.Copy(); DataTable dtAll = new DataTable();\n...\ndtAll.Merge(dtOne);\ndtAll.Merge(dtTwo);\ndtAll.Merge(dtThree);\n...\n DataTable dtAllItems = new DataTable();\n\nforeach(var item in items)\n{\n DataTable dtItem = getDataTable(item); // some function that returns a data table\n dtAllItems.Merge(dtItem);\n}\n"
},
{
"answer_id": 39221823,
"author": "anandd360",
"author_id": 4575768,
"author_profile": "https://Stackoverflow.com/users/4575768",
"pm_score": 0,
"selected": false,
"text": " DataTable dtTemp=new DataTable();\n for (int k = 0; k < GridView2.Rows.Count; k++)\n {\n string roomno = GridView2.Rows[k].Cells[1].Text;\n DataTable dtx = GetRoomDetails(chk, roomno, out msg);\n if (dtx.Rows.Count > 0)\n {\n dtTemp.Merge(dtx);\n dtTemp.AcceptChanges();\n\n }\n }\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33690/"
] |
285,477
|
<p>This is something that comes up so often I almost stopped thinking about it but I'm almost certain that I'm not doing this the best way.</p>
<p>The question: Suppose you have the following table</p>
<pre><code>CREATE TABLE TEST_TABLE
(
ID INTEGER,
TEST_VALUE NUMBER,
UPDATED DATE,
FOREIGN_KEY INTEGER
);
</code></pre>
<p>What is the best way to select the TEST_VALUE associated with the most recently updated row where FOREIGN_KEY = 10?</p>
<p><strong>EDIT:</strong> Let's make this more interesting as the answers below simply go with my method of sorting and then selecting the top row. Not bad but for large returns the order by would kill performance. So bonus points: how to do it in a scalable manner (ie without the unnecessary order by).</p>
|
[
{
"answer_id": 285485,
"author": "George Mauer",
"author_id": 5056,
"author_profile": "https://Stackoverflow.com/users/5056",
"pm_score": 1,
"selected": false,
"text": "SELECT TEST_VALUE\nFROM TEST_TABLE\nWHERE ID = (\n SELECT ID\n FROM (\n SELECT ID\n FROM TEST_TABLE\n WHERE FOREIGN_KEY = 10\n ORDER BY UPDATED DESC\n )\n WHERE ROWNUM = 1\n)\n"
},
{
"answer_id": 285489,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 2,
"selected": false,
"text": "WHERE updated = (SELECT MAX(updated) ...)\n ORDER BY updated DESC\n SELECT \n * \nFROM \n(\n SELECT * FROM test_table\n ORDER BY updated DESC\n)\nWHERE \n ROWNUM = 1\n"
},
{
"answer_id": 285509,
"author": "WW.",
"author_id": 14663,
"author_profile": "https://Stackoverflow.com/users/14663",
"pm_score": -1,
"selected": false,
"text": "select test_value\nfrom\n(\n select test_value \n from test_table\n where foreign_key=10\n order by updated desc\n)\nwhere rownum = 1\n"
},
{
"answer_id": 285519,
"author": "FallenAvatar",
"author_id": 36965,
"author_profile": "https://Stackoverflow.com/users/36965",
"pm_score": -1,
"selected": false,
"text": "SELECT TOP 1 ID\nFROM test_table\nWHERE FOREIGN_KEY = 10\nORDER BY UPDATED DESC\n"
},
{
"answer_id": 285577,
"author": "Justin Cave",
"author_id": 10397,
"author_profile": "https://Stackoverflow.com/users/10397",
"pm_score": 5,
"selected": true,
"text": "SQL> select * from test_table;\n\n ID TEST_VALUE UPDATED FOREIGN_KEY\n---------- ---------- --------- -----------\n 1 10 12-NOV-08 10\n 2 20 11-NOV-08 10\n\nSQL> ed\nWrote file afiedt.buf\n\n 1* select * from test_table\nSQL> ed\nWrote file afiedt.buf\n\n 1 select max( test_value ) keep (dense_rank last order by updated)\n 2 from test_table\n 3* where foreign_key = 10\nSQL> /\n\nMAX(TEST_VALUE)KEEP(DENSE_RANKLASTORDERBYUPDATED)\n-------------------------------------------------\n 10\n SQL> ed\nWrote file afiedt.buf\n\n 1 select max( id ) keep (dense_rank last order by updated) id,\n 2 max( test_value ) keep (dense_rank last order by updated) test_value\n,\n 3 max( updated) keep (dense_rank last order by updated) updated\n 4 from test_table\n 5* where foreign_key = 10\nSQL> /\n\n ID TEST_VALUE UPDATED\n---------- ---------- ---------\n 1 10 12-NOV-08\n"
},
{
"answer_id": 285858,
"author": "EvilTeach",
"author_id": 7734,
"author_profile": "https://Stackoverflow.com/users/7734",
"pm_score": 0,
"selected": false,
"text": "WITH \nten AS\n(\n SELECT *\n FROM TEST_TABLE\n WHERE FOREIGH_KEY = 10\n)\nSELECT TEST_VALUE \nFROM ten\nWHERE UPDATED = \n(\n SELECT MAX(DATE)\n FROM ten\n)\n"
},
{
"answer_id": 28374340,
"author": "aaaantoine",
"author_id": 3466101,
"author_profile": "https://Stackoverflow.com/users/3466101",
"pm_score": 1,
"selected": false,
"text": "WITH test_table_ranked AS (\n SELECT\n test_table.*,\n ROW_NUMBER() OVER (\n PARTITION BY foreign_key ORDER BY updated DESC\n ) AS most_recent\n FROM\n test_table\n)\nSELECT *\nFROM test_table_ranked\nWHERE most_recent = 1\n-- AND foreign_key = 10\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] |
285,482
|
<p>We've got an app with some legacy printer "setup" code that we are still using <code><a href="http://msdn.microsoft.com/en-us/library/ms646940(VS.85).aspx" rel="nofollow noreferrer">PrintDlg</a></code> for. We use a custom template to allow the user to select which printer to use for various types of printing tasks (such as reports or drawings) along with orientation and paper size/source.</p>
<p>It works on XP and 32-bit Vista, but on Vista x64 it gets a <code>CDERR_MEMLOCKFAILURE</code> via <code>CommDlgExtendedError()</code>. I've tried running it with just the bare-bones input in the <code>PRINTDLG</code> structure, but if the parameters include <code>PD_PRINTSETUP</code> or <code>PD_RETURNDEFAULT</code>, I get that error.</p>
<p>Since the printer selection / page setup has been split into <code><a href="http://msdn.microsoft.com/en-us/library/ms646937(VS.85).aspx" rel="nofollow noreferrer">PageSetupDlg</a></code> and <code><a href="http://msdn.microsoft.com/en-us/library/ms646942(VS.85).aspx" rel="nofollow noreferrer">PrintDlgEx</a></code>, there is no apparent easy transition without changing a fair amount of code and/or changing completely how we present printing and printer setup to the user.</p>
<p>Has anyone seen this problem on 64-bit Vista, and have you found any work-arounds?</p>
<p><b>Notes:</b><br>
Application runs as Administrator due to other constraints</p>
|
[
{
"answer_id": 453486,
"author": "AZDean",
"author_id": 12058,
"author_profile": "https://Stackoverflow.com/users/12058",
"pm_score": 0,
"selected": false,
"text": "using System;\nusing System.Collections.Generic;\nusing System.Drawing;\nusing System.Drawing.Printing;\nusing System.Printing;\nusing System.Runtime.InteropServices;\nusing System.Windows.Forms;\nusing Zemetrics.Diagnostics;\n\nnamespace Utils\n{\n/// <summary>\n/// The PrintDialog64 class replaces the standard PrintDialog with one that works in Vista x64\n/// </summary>\npublic partial class PrintDialog64 : Form\n{\n #region Private members \n [DllImport(\"winspool.drv\", EntryPoint=\"DocumentPropertiesW\")]\n private static extern int DocumentProperties(IntPtr hWnd,IntPtr hPrinter,[MarshalAs(UnmanagedType.LPWStr)] string pDeviceName,IntPtr pDevMode,IntPtr devModeIn,int fMode);\n\n [DllImport(\"winspool.drv\")] private static extern int OpenPrinter(string pPrinterName,out IntPtr hPrinter,IntPtr pDefault);\n [DllImport(\"winspool.drv\")] private static extern int ClosePrinter(IntPtr phPrinter);\n [DllImport(\"kernel32.dll\")] private static extern IntPtr GlobalLock(IntPtr hMem);\n [DllImport(\"kernel32.dll\")] private static extern int GlobalUnlock(IntPtr hMem);\n [DllImport(\"kernel32.dll\")] private static extern int GlobalFree(IntPtr hMem);\n\n private const int DM_PROMPT = 4;\n private const int DM_OUT_BUFFER = 2;\n private const int DM_IN_BUFFER = 8;\n\n private List<PrinterItem> printers;\n private string printerName;\n private string originalName;\n private IntPtr hDevMode = IntPtr.Zero;\n #endregion\n\n /// <summary>\n /// Gets or sets the printer that prints the document \n /// </summary>\n public PrinterSettings PrinterSettings { get; set; }\n\n /// <summary>\n /// Gets or sets a value indicating the PrintDocument used to obtain PrinterSettings. \n /// </summary>\n public PrintDocument Document { get; set; }\n\n /// <summary>\n /// Constructs a replacement for the standard PrintDialog with one that works in Vista x64\n /// </summary>\n public PrintDialog64()\n {\n InitializeComponent();\n }\n\n #region PrinterItem class\n /// <summary>\n /// The PrinterItem class holds a reference to a PrintQueue and allows us to sort a list based on printer name\n /// </summary>\n private class PrinterItem : IComparable<PrinterItem>\n {\n #region Private members\n private PrinterItem() {}\n #endregion\n\n /// <summary>\n /// Construct a PrinterItem by supplying a reference to the printer's PrintQueue class\n /// </summary>\n ///\n /// \\param[in] printer Reference to PrintQueue class for this printer\n public PrinterItem(PrintQueue printer)\n {\n Printer = printer;\n }\n\n /// <summary>\n /// Reference to PrintQueue class for this printer\n /// </summary>\n public PrintQueue Printer { get; set; }\n\n /// <summary>\n /// The string for this class is simply the FullName of the printer\n /// </summary>\n public override string ToString()\n {\n return Printer.FullName;\n }\n\n #region IComparable<PrinterItem> Members\n /// <summary>\n /// Implements IComparable interface to allow sorting of PrinterItem classes (based on printer name)\n /// </summary>\n ///\n /// \\param[in] other The other PrinterItem class that we are to compare this one to\n public int CompareTo(PrinterItem other)\n {\n return other.Printer.FullName.CompareTo(this.Printer.FullName);\n }\n #endregion\n }\n #endregion\n\n private List<PrinterItem> GetPrinters()\n {\n List<PrinterItem> printers = new List<PrinterItem>();\n\n EnumeratedPrintQueueTypes[] Queue_types = {EnumeratedPrintQueueTypes.Local,EnumeratedPrintQueueTypes.Connections};\n\n try {\n using (LocalPrintServer server = new LocalPrintServer())\n foreach (PrintQueue printer in server.GetPrintQueues(Queue_types))\n printers.Add(new PrinterItem(printer)); \n } catch {}\n\n printers.Sort();\n return printers; \n }\n\n private void PrintDialog64_Shown(object sender, EventArgs e)\n {\n originalName = Document.PrinterSettings.PrinterName;\n printers = GetPrinters();\n int index=0, i=0;\n\n foreach(PrinterItem printer in printers) {\n nameComboBox.Items.Add(printer.ToString());\n\n if (printer.ToString() == originalName) index = i;\n i++;\n }\n\n nameComboBox.SelectedIndex = index;\n }\n\n private void nameComboBox_Leave(object sender, EventArgs e)\n {\n string text = nameComboBox.Text;\n\n foreach(Object field in nameComboBox.Items)\n if (((string) field).ToLower().StartsWith(text.ToLower())) nameComboBox.SelectedItem = field;\n\n if (nameComboBox.SelectedIndex < 0)\n nameComboBox.SelectedIndex = 0;\n }\n\n private void nameComboBox_SelectedIndexChanged(object sender, EventArgs e)\n {\n PrintQueue printer = printers[nameComboBox.SelectedIndex].Printer;\n\n if (hDevMode!=IntPtr.Zero) GlobalFree(hDevMode);\n\n PrinterSettings.PrinterName = printerName = printer.FullName;\n hDevMode = PrinterSettings.GetHdevmode(Document.DefaultPageSettings); \n\n statusValue .Text = printer.QueueStatus.ToString()==\"None\" ? \"Ready\" : printer.QueueStatus.ToString();\n whereValue .Text = printer.Location==\"\" ? printer.QueuePort.Name : printer.Location;\n commentValue.Text = printer.Comment;\n }\n\n private void propertiesButton_Click(object sender, EventArgs e)\n {\n IntPtr handle;\n OpenPrinter(printerName, out handle, IntPtr.Zero);\n\n IntPtr pDevMode = GlobalLock( hDevMode );\n DocumentProperties(this.Handle, handle, printerName, pDevMode, pDevMode, DM_IN_BUFFER | DM_PROMPT | DM_OUT_BUFFER);\n GlobalUnlock( hDevMode );\n\n PrinterSettings.SetHdevmode( hDevMode );\n PrinterSettings.DefaultPageSettings.SetHdevmode( hDevMode );\n ClosePrinter(handle);\n }\n\n private void pageDefaultsButton_Click(object sender, EventArgs e)\n {\n PageSetupDialog setup = new PageSetupDialog(); \n setup.PageSettings = Document.DefaultPageSettings;\n\n if (setup.ShowDialog() == DialogResult.OK) {\n if (hDevMode!=IntPtr.Zero) GlobalFree(hDevMode);\n\n hDevMode = PrinterSettings.GetHdevmode( Document.DefaultPageSettings = setup.PageSettings );\n }\n }\n\n private void okButton_Click(object sender, EventArgs e)\n {\n if (hDevMode!=IntPtr.Zero) GlobalFree(hDevMode);\n }\n\n private void cancelButton_Click(object sender, EventArgs e)\n {\n if (hDevMode!=IntPtr.Zero) GlobalFree(hDevMode);\n\n PrinterSettings.PrinterName = originalName;\n }\n}\n}\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1441/"
] |
285,495
|
<p>I am binding an SPGridView to a SPList. As code samples suggest, I am using the following code to create a dataview based on the list. </p>
<pre><code>dim data as DataView = myList.Items.GetDataTable.DefaultView
grid.DataSource = data
etc...
</code></pre>
<p>What I am finding is that the column names in the resulting dataview do not always match the source fields defined in the SPList. For example I have columns named </p>
<ul>
<li>Description </li>
<li>ReportItem</li>
<li><p>ReportStatus</p>
<p>these show up in the resulting dataview with column names like </p></li>
<li>ReportType0</li>
<li>ReportStatus1</li>
</ul>
<p>This leads me to think that I have duplicate field names defined, but that does not seem to be the case.</p>
<p>Seems like I am missing something fundamental here?
Thanks.</p>
|
[
{
"answer_id": 285590,
"author": "Abs",
"author_id": 1245,
"author_profile": "https://Stackoverflow.com/users/1245",
"pm_score": 3,
"selected": true,
"text": "GetDataTable internalName staticName Title GetDataTable internalName"
},
{
"answer_id": 470181,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "DataTable table = list.GetItems(list.DefaultView).GetDataTable();\nforeach(DataColumn column in table.Columns)\n{\n column.ColumnName = list.Fields.GetFieldByInternalName(column.ColumnName).Title;\n}\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10552/"
] |
285,502
|
<p>This code works in Firefox, Internet Explorer, not in Safari/Chrome:</p>
<pre><code><head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui.js"></script>
<script>
function newDiv() {
var div = $('<div id="divNew" style="width: 50px; height: 50px; border: solid 1px; background: Red"></div>');
$('#divParent').append(div);
div.draggable(
{
containment: 'parent'
});
}
</script>
</head>
<body>
<a href="javascript:;" onclick="newDiv()">new div</a>
<div id="divParent" style="width: 500px; height: 500px; border: solid 1px;"></div>
</body>
</code></pre>
<p>In Safari/Chrome, the divNew can only be moved vertically. jQuery's this feature is currently incompatible? I am using 1.5.2 stable version.It can be found here <a href="http://jquery-ui.googlecode.com/files/jquery.ui-1.5.2.zip" rel="nofollow noreferrer">jQuery 1.5.2</a></p>
|
[
{
"answer_id": 474619,
"author": "jacobangel",
"author_id": 31318,
"author_profile": "https://Stackoverflow.com/users/31318",
"pm_score": 2,
"selected": false,
"text": " <script>\n function newDiv() {\n var divs = \n $(unescape('%3Cdiv class=\"divNew\" style=\"\"%3E %3C/div%3E'));\n divs.draggable(\n {\n containment: $('#a')\n });\n $('#divParent').append(divs);\n }\n </script>\n</head>\n<body>\n <style>\n .divNew {width: 50px; height: 50px;border: solid 1px; background: Red;}\n #divParent {width: 500px; height: 500px; border: solid 1px;};\n </style>\n <a href=\"javascript:;\" onclick=\"newDiv()\">new div</a>\n <div id=\"a\">\n <div id=\"divParent\" style=\"\"> <!--<div class=\"divNew\"></div>-->\n </div> \n </div>\n</body>\n"
},
{
"answer_id": 4332107,
"author": "Anes",
"author_id": 401973,
"author_profile": "https://Stackoverflow.com/users/401973",
"pm_score": 1,
"selected": false,
"text": "if(!($browser.safari && navigator.appVersion.indexOf('Mac')!= -1)) {\n $('div.urid').draggable({\n helper: 'clone',\n opacity: 0.4\n });\n}\n"
},
{
"answer_id": 5282093,
"author": "anjalis",
"author_id": 656501,
"author_profile": "https://Stackoverflow.com/users/656501",
"pm_score": 4,
"selected": false,
"text": "position: absolute !important"
},
{
"answer_id": 10066296,
"author": "nathanlampe",
"author_id": 1133695,
"author_profile": "https://Stackoverflow.com/users/1133695",
"pm_score": 2,
"selected": false,
"text": "position: absolute !important;\n position: absolute !important position: relative;"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37122/"
] |
285,521
|
<p>I am making a post from a .NET console app to a .NET web service. I know that the timeout on the server side is 20 min, but if my client takes more than 100 seconds to post my data to that service then I get a timeout exception. How would I tell my client to wait the available 20 min to timeout?</p>
|
[
{
"answer_id": 285536,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 3,
"selected": false,
"text": "myServiceInstance.Timeout = 1200000\n"
},
{
"answer_id": 285547,
"author": "Vin",
"author_id": 1747,
"author_profile": "https://Stackoverflow.com/users/1747",
"pm_score": 0,
"selected": false,
"text": "ServiceInstance.Timeout"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13593/"
] |
285,522
|
<p>Let's say I have an html form. Each input/select/textarea will have a corresponding <code><label></code> with the <code>for</code> attribute set to the id of it's companion. In this case, I know that each input will only have a single label.</p>
<p>Given an input element in javascript — via an onkeyup event, for example — what's the best way to find it's associated label?</p>
|
[
{
"answer_id": 285560,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 4,
"selected": false,
"text": "var labels = document.getElementsByTagName(\"LABEL\"),\n lookup = {},\n i, label;\n\nfor (i = 0; i < labels.length; i++) {\n label = labels[i];\n if (document.getElementById(label.htmlFor)) {\n lookup[label.htmlFor] = label;\n }\n}\n var myLabel = lookup[myInput.id];\n"
},
{
"answer_id": 285565,
"author": "TonyB",
"author_id": 3543,
"author_profile": "https://Stackoverflow.com/users/3543",
"pm_score": 7,
"selected": false,
"text": "$('label[for=\"foo\"]').hide ();\n function findLableForControl(el) {\n var idVal = el.id;\n labels = document.getElementsByTagName('label');\n for( var i = 0; i < labels.length; i++ ) {\n if (labels[i].htmlFor == idVal)\n return labels[i];\n }\n}\n"
},
{
"answer_id": 285575,
"author": "AndreasKnudsen",
"author_id": 36465,
"author_profile": "https://Stackoverflow.com/users/36465",
"pm_score": 3,
"selected": false,
"text": "var nameOfLabel = someInput.attr('id');\nvar label = $(\"label[for='\" + nameOfLabel + \"']\");\n"
},
{
"answer_id": 285608,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 8,
"selected": true,
"text": "var labels = document.getElementsByTagName('LABEL');\nfor (var i = 0; i < labels.length; i++) {\n if (labels[i].htmlFor != '') {\n var elem = document.getElementById(labels[i].htmlFor);\n if (elem)\n elem.label = labels[i]; \n }\n}\n document.getElementById('MyFormElem').label.innerHTML = 'Look ma this works!';\n"
},
{
"answer_id": 5641041,
"author": "Mike McKay",
"author_id": 266111,
"author_profile": "https://Stackoverflow.com/users/266111",
"pm_score": 0,
"selected": false,
"text": "$(\"label[for=\"+inputElement.id+\"]\")\n"
},
{
"answer_id": 7121904,
"author": "ObjectType",
"author_id": 83964,
"author_profile": "https://Stackoverflow.com/users/83964",
"pm_score": 0,
"selected": false,
"text": "var labels = $(\"label\");\nfor (var i = 0; i < labels.length; i++) {\n var fieldId = labels[i].htmlFor;\n if (fieldId != \"\") {\n var elem = $(\"#\" + fieldId);\n if (elem.length != 0) {\n elem.data(\"label\", $(labels[i])); \n }\n }\n}\n $(\"#myFormElemId\").data(\"label\").css(\"border\",\"3px solid red\");\n"
},
{
"answer_id": 7304493,
"author": "haifacarina",
"author_id": 782125,
"author_profile": "https://Stackoverflow.com/users/782125",
"pm_score": 2,
"selected": false,
"text": "$(\"label[for='inputId']\").text()\n"
},
{
"answer_id": 8913025,
"author": "Gijs",
"author_id": 713326,
"author_profile": "https://Stackoverflow.com/users/713326",
"pm_score": 5,
"selected": false,
"text": "<label>Put your stuff here: <input value=\"Stuff\"></label>\n $.fn.getLabels = function() {\n return this.map(function() {\n var labels = $(this).parents('label');\n if (this.id) {\n labels.add('label[for=\"' + this.id + '\"]');\n }\n return labels.get();\n });\n};\n $('#myfancyinput').getLabels();\n aria-labelledby"
},
{
"answer_id": 13047684,
"author": "OzrenTkalcecKrznaric",
"author_id": 1632534,
"author_profile": "https://Stackoverflow.com/users/1632534",
"pm_score": 2,
"selected": false,
"text": "jQuery.fn.getLabels = function () {\n return this.map(function () {\n var parentLabels = $(this).parents('label').get();\n var associatedLabels = this.id ? associatedLabels = $(\"label[for='\" + this.id + \"']\").get() : [];\n return parentLabels.concat(associatedLabels);\n });\n};\n"
},
{
"answer_id": 15061155,
"author": "alex",
"author_id": 31671,
"author_profile": "https://Stackoverflow.com/users/31671",
"pm_score": 6,
"selected": false,
"text": "labels labels var getLabelsForInputElement = function(element) {\n var labels = [];\n var id = element.id;\n\n if (element.labels) {\n return element.labels;\n }\n\n id && Array.prototype.push\n .apply(labels, document.querySelector(\"label[for='\" + id + \"']\"));\n\n while (element = element.parentNode) {\n if (element.tagName.toLowerCase() == \"label\") {\n labels.push(element);\n } \n }\n\n return labels;\n};\n\n// ES6\nvar getLabelsForInputElement = (element) => {\n let labels;\n let id = element.id;\n\n if (element.labels) {\n return element.labels;\n }\n\n if (id) {\n labels = Array.from(document.querySelector(`label[for='${id}']`)));\n }\n\n while (element = element.parentNode) {\n if (element.tagName.toLowerCase() == \"label\") {\n labels.push(element);\n } \n }\n\n return labels;\n};\n var getLabelsForInputElement = function(element) {\n var labels = $();\n var id = element.id;\n\n if (element.labels) {\n return element.labels;\n }\n\n id && (labels = $(\"label[for='\" + id + \"']\")));\n\n labels = labels.add($(element).parents(\"label\"));\n\n return labels;\n};\n"
},
{
"answer_id": 20225078,
"author": "Martie Henry",
"author_id": 3037784,
"author_profile": "https://Stackoverflow.com/users/3037784",
"pm_score": 1,
"selected": false,
"text": "<label for=\"firstName\" id=\"firstNameLabel\">FirstName:</label>\n\n<input type=\"text\" id=\"firstName\" name=\"firstName\" class=\"input_Field\" \n pattern=\"^[a-zA-Z\\s\\-]{2,25}$\" maxlength=\"25\"\n title=\"Alphabetic, Space, Dash Only, 2-25 Characters Long\" \n autocomplete=\"on\" required\n/>\n if (myvariableforpagelang == 'es') {\n // set field label to spanish\n document.getElementById(\"firstNameLabel\").innerHTML = \"Primer Nombre:\";\n // set field tooltip (title to spanish\n document.getElementById(\"firstName\").title = \"Alfabética, espacio, guión Sólo, 2-25 caracteres de longitud\";\n}\n"
},
{
"answer_id": 20632804,
"author": "kuroi neko",
"author_id": 2960823,
"author_profile": "https://Stackoverflow.com/users/2960823",
"pm_score": 1,
"selected": false,
"text": "var labels = form.getElementsByTagName ('label');\nvar input_label = {};\nfor (var i = 0 ; i != labels.length ; i++)\n{\n var label = labels[i];\n var input = label.htmlFor\n ? document.getElementById(label.htmlFor)\n : label.getElementsByTagName('input')[0];\n input_label[input.outerHTML] = \n (label.innerText || label.textContent); // innerText for IE8-\n}\n"
},
{
"answer_id": 23790722,
"author": "Peter Nosko",
"author_id": 3361389,
"author_profile": "https://Stackoverflow.com/users/3361389",
"pm_score": 0,
"selected": false,
"text": "<label><input type=\"checkbox\" class=\"c123\" id=\"cb1\" name=\"item1\">item1</label>\n\n<input type=\"checkbox\" class=\"c123\" id=\"cb2\" name=\"item2\">item2</input>\n\n<input type=\"checkbox\" class=\"c123\" id=\"cb3\" name=\"item3\"><label for=\"cb3\">item3</label>\n $(\".c123\").click(function() {\n $cb = $(this);\n $lb = $(this).parent();\n alert( $cb.attr('id') + ' = ' + $lb.text() );\n});\n"
},
{
"answer_id": 27160272,
"author": "itsazzad",
"author_id": 540144,
"author_profile": "https://Stackoverflow.com/users/540144",
"pm_score": 0,
"selected": false,
"text": "$(\"input\").each(function () {\n if ($.trim($(this).prev('label').text()) != \"\") {\n console.log(\"\\nprev>children:\");\n console.log($.trim($(this).prev('label').text()));\n } else {\n if ($.trim($(this).parent('label').text()) != \"\") {\n console.log(\"\\nparent>children:\");\n console.log($.trim($(this).parent('label').text()));\n } else {\n if ($.trim($(this).parent().prev('label').text()) != \"\") {\n console.log(\"\\nparent>prev>children:\");\n console.log($.trim($(this).parent().prev('label').text()));\n } else {\n console.log(\"NOTFOUND! So set your own condition now\");\n }\n }\n }\n});\n"
},
{
"answer_id": 31941735,
"author": "Brendan",
"author_id": 945370,
"author_profile": "https://Stackoverflow.com/users/945370",
"pm_score": 2,
"selected": false,
"text": "for var form = document.querySelector('.sample-form');\nvar formFields = form.querySelectorAll('.form-field');\n\n[].forEach.call(formFields, function (formField) {\n var inputId = formField.id;\n var label = form.querySelector('label[for=' + inputId + ']');\n console.log(label.textContent);\n});\n for querySelectorAll querySelector"
},
{
"answer_id": 41756902,
"author": "Gordon Rouse",
"author_id": 2383941,
"author_profile": "https://Stackoverflow.com/users/2383941",
"pm_score": 0,
"selected": false,
"text": "<style>\n\n//for input element with class 'YYY'\ninput.YYY + label {}\n\n</style>\n $('#XXX + label');\n $('input[type=checkbox]').each( function(){\n $(this).find('+ label');\n});\n"
},
{
"answer_id": 47276699,
"author": "davidnagli",
"author_id": 4404040,
"author_profile": "https://Stackoverflow.com/users/4404040",
"pm_score": 4,
"selected": false,
"text": "input.labels\n input.labels"
},
{
"answer_id": 50145262,
"author": "StateOfTheArtJonas",
"author_id": 8571642,
"author_profile": "https://Stackoverflow.com/users/8571642",
"pm_score": 2,
"selected": false,
"text": "const getLabels = ({ labels, id }) => labels || document.querySelectorAll(`label[for=${id}]`)\n const getFirstLabel = ({ labels, id }) => labels && labels[0] || document.querySelector(`label[for=${id}]`)\n"
},
{
"answer_id": 51334543,
"author": "Dan Bray",
"author_id": 2452680,
"author_profile": "https://Stackoverflow.com/users/2452680",
"pm_score": 1,
"selected": false,
"text": "label label input function getLabelForInput(id)\n{\n var el = document.getElementById(id);\n if (!el)\n return null;\n var elPrev = el.previousElementSibling;\n var elNext = el.nextElementSibling;\n while (elPrev || elNext)\n {\n if (elPrev)\n {\n if (elPrev.htmlFor === id)\n return elPrev;\n elPrev = elPrev.previousElementSibling;\n }\n if (elNext)\n {\n if (elNext.htmlFor === id)\n return elNext;\n elNext = elNext.nextElementSibling;\n }\n }\n return null;\n}\n el = document.getElementById(id).previousElementSibling;\n label"
},
{
"answer_id": 68764425,
"author": "Rodolfo Bojo Pellegrino",
"author_id": 16652712,
"author_profile": "https://Stackoverflow.com/users/16652712",
"pm_score": 2,
"selected": false,
"text": "<label> <input> <label> <input> for= <label> id= function myFunction() {\n document.getElementById(\"p1\").innerHTML = \"The first label associated with input: <b>\" + document.getElementById(\"input4\").labels[0].id + \"</b>\";\n\n} <form>\n <label id=\"theLabel\" for=\"input4\">my id is \"theLabel\"</label>\n <input name=\"name1\" id=\"input4\" value=\"my id is input4\">\n <br>\n</form>\n\n<p>Click the \"click me\" button to see the label properties</p>\n\n<button onclick=\"myFunction()\">click me</button>\n\n\n<p id=\"p1\"></p> <label> <input> <label> for= function myFunction2() {\n\nvar x = document.getElementById(\"input7\").labels;\nlet text = \"\";\nfor (let i = 0; i < x.length; i++) {\n text += x[i].id + \"<br>\";\n}\ndocument.getElementById(\"p7\").innerHTML = text;\n} <b>Three labels for one input</b><br>\n<br>\n<form>\n <label id=\"theLabel2\" for=\"input7\">my id is \"theLabel2</label><br>\n <label id=\"theLabel3\" for=\"input7\">my id is \"theLabel3</label><br>\n <label id=\"theLabel4\" for=\"input7\">my id is \"theLabel4</label><br>\n <input name=\"name1\" id=\"input7\" value=\"my id is input7\">\n <br>\n</form>\n\n<p>Click the \"click me\" button to see the label properties</p>\n<button onclick=\"myFunction2()\">click me2</button>\n\n<p id=\"p7\"></p>"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3043/"
] |
285,523
|
<p>Is there a way to determine if the loop is iterating for the last time. My code looks something like this:</p>
<pre><code>int[] array = {1, 2, 3...};
StringBuilder builder = new StringBuilder();
for(int i : array)
{
builder.append("" + i);
if(!lastiteration)
builder.append(",");
}
</code></pre>
<p>Now the thing is I don't want to append the comma in the last iteration. Now is there a way to determine if it is the last iteration or am I stuck with the for loop or using an external counter to keep track.</p>
|
[
{
"answer_id": 285530,
"author": "Dinah",
"author_id": 356,
"author_profile": "https://Stackoverflow.com/users/356",
"pm_score": 5,
"selected": false,
"text": "StringBuilder deleteCharAt(int index) length() - 1"
},
{
"answer_id": 285534,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 2,
"selected": false,
"text": "int[] array = {1, 2, 3...};\nStringBuilder\n\nbuilder = new StringBuilder();\n\nfor(int i : array)\n{\n builder.append(i + \",\");\n}\n\nif(builder.charAt((builder.length() - 1) == ','))\n builder.deleteCharAt(builder.length() - 1);\n StringUtils.join()"
},
{
"answer_id": 285537,
"author": "Gareth Davis",
"author_id": 31480,
"author_profile": "https://Stackoverflow.com/users/31480",
"pm_score": 3,
"selected": false,
"text": "for(int i = 0 ; i < array.length ; i ++ ){\n builder.append(array[i]);\n if( i != array.length - 1 ){\n builder.append(',');\n }\n}\n"
},
{
"answer_id": 285543,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 3,
"selected": false,
"text": "builder.append( \"\" + array[0] );\nfor( int i = 1; i != array.length; i += 1 ) {\n builder.append( \", \" + array[i] );\n}\n"
},
{
"answer_id": 285544,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 8,
"selected": false,
"text": "\"\" + i int[] array = {1, 2, 3...};\nStringBuilder builder = new StringBuilder();\n\nfor (int i : array) {\n if (builder.length() != 0) {\n builder.append(\",\");\n }\n builder.append(i);\n}\n Iterable"
},
{
"answer_id": 285548,
"author": "FallenAvatar",
"author_id": 36965,
"author_profile": "https://Stackoverflow.com/users/36965",
"pm_score": 2,
"selected": false,
"text": "int[] array = {1, 2, 3...};\nStringBuilder builder = new StringBuilder();\nbool firstiteration=true;\n\nfor(int i : array)\n{\n if(!firstiteration)\n builder.append(\",\");\n\n builder.append(\"\" + i);\n firstiteration=false;\n}\n"
},
{
"answer_id": 285552,
"author": "Paul Brinkley",
"author_id": 18160,
"author_profile": "https://Stackoverflow.com/users/18160",
"pm_score": 0,
"selected": false,
"text": "first first first"
},
{
"answer_id": 285571,
"author": "Omar Kooheji",
"author_id": 20400,
"author_profile": "https://Stackoverflow.com/users/20400",
"pm_score": 5,
"selected": false,
"text": " StringBuffer buffer = new StringBuffer();\n Iterator iter = s.iterator();\n while (iter.hasNext()) {\n buffer.append(iter.next());\n if (iter.hasNext()) {\n buffer.append(delimiter);\n }\n }\n"
},
{
"answer_id": 285592,
"author": "bruno conde",
"author_id": 31136,
"author_profile": "https://Stackoverflow.com/users/31136",
"pm_score": 4,
"selected": false,
"text": " int[] array = {1, 2, 3};\n StringBuilder builder = new StringBuilder();\n\n if (array.length != 0) {\n builder.append(array[0]);\n for (int i = 1; i < array.length; i++ )\n {\n builder.append(\",\");\n builder.append(array[i]);\n }\n }\n"
},
{
"answer_id": 285628,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 7,
"selected": false,
"text": "String delim = \"\";\nfor (int i : ints) {\n sb.append(delim).append(i);\n delim = \",\";\n}\n"
},
{
"answer_id": 289669,
"author": "akuhn",
"author_id": 24468,
"author_profile": "https://Stackoverflow.com/users/24468",
"pm_score": 2,
"selected": false,
"text": "Separator s = new Separator(\", \");\nfor(int i : array)\n{\n builder.append(s).append(i);\n}\n Separator toString()"
},
{
"answer_id": 669201,
"author": "13ren",
"author_id": 50979,
"author_profile": "https://Stackoverflow.com/users/50979",
"pm_score": 2,
"selected": false,
"text": "StringBuffer buffer = new StringBuffer();\nIterator iter = s.iterator();\nfor (;;) {\n buffer.append(iter.next());\n if (! iter.hasNext())\n break;\n buffer.append(delimiter);\n}\n"
},
{
"answer_id": 669221,
"author": "Peter Lawrey",
"author_id": 57695,
"author_profile": "https://Stackoverflow.com/users/57695",
"pm_score": 1,
"selected": false,
"text": "StringBuilder builder = new StringBuilder();\nfor(int i : array)\n builder.append(',').append(i);\nString text = builder.toString();\nif (text.startsWith(\",\")) text=text.substring(1);\n"
},
{
"answer_id": 669233,
"author": "Phil H",
"author_id": 36537,
"author_profile": "https://Stackoverflow.com/users/36537",
"pm_score": 4,
"selected": false,
"text": "StringUtils.join(strArr, ',');\n"
},
{
"answer_id": 669806,
"author": "Julien Chastang",
"author_id": 32174,
"author_profile": "https://Stackoverflow.com/users/32174",
"pm_score": 1,
"selected": false,
"text": " int[] array = {1, 2, 3};\n StringBuilder builder = new StringBuilder();\n for (int i = 0 ; i < array.length; i++)\n builder.append(i == 0 ? \"\" : \",\").append(array[i]); \n"
},
{
"answer_id": 6106805,
"author": "fastcodejava",
"author_id": 184730,
"author_profile": "https://Stackoverflow.com/users/184730",
"pm_score": 0,
"selected": false,
"text": "String del = null;\nfor(int i : array)\n{\n if (del != null)\n builder.append(del);\n else\n del = \",\";\n builder.append(i);\n}\n"
},
{
"answer_id": 25083058,
"author": "Buffalo",
"author_id": 688843,
"author_profile": "https://Stackoverflow.com/users/688843",
"pm_score": 1,
"selected": false,
"text": "elapsed time with checks at every iteration: 12055(ms)\nelapsed time with deletion at the end: 11977(ms)\n import java.util.ArrayList;\nimport java.util.List;\n\n\npublic class TestCommas {\n\n public static String GetUrlsIn(int aProjectID, List<String> aUrls, boolean aPreferChecks)\n {\n\n if (aPreferChecks) {\n\n StringBuffer sql = new StringBuffer(\"select * from mytable_\" + aProjectID + \" WHERE hash IN \");\n\n StringBuffer inHashes = new StringBuffer(\"(\");\n StringBuffer inURLs = new StringBuffer(\"(\");\n\n if (aUrls.size() > 0)\n {\n\n for (String url : aUrls)\n {\n\n if (inHashes.length() > 0) {\n inHashes.append(\",\");\n inURLs.append(\",\");\n }\n\n inHashes.append(url.hashCode());\n\n inURLs.append(\"\\\"\").append(url.replace(\"\\\"\", \"\\\\\\\"\")).append(\"\\\"\");//.append(\",\");\n\n }\n\n }\n\n inHashes.append(\")\");\n inURLs.append(\")\");\n\n return sql.append(inHashes).append(\" AND url IN \").append(inURLs).toString();\n }\n\n else {\n\n StringBuffer sql = new StringBuffer(\"select * from mytable\" + aProjectID + \" WHERE hash IN \");\n\n StringBuffer inHashes = new StringBuffer(\"(\");\n StringBuffer inURLs = new StringBuffer(\"(\");\n\n if (aUrls.size() > 0)\n {\n\n for (String url : aUrls)\n {\n inHashes.append(url.hashCode()).append(\",\"); \n\n inURLs.append(\"\\\"\").append(url.replace(\"\\\"\", \"\\\\\\\"\")).append(\"\\\"\").append(\",\");\n }\n\n }\n\n inHashes.deleteCharAt(inHashes.length()-1);\n inURLs.deleteCharAt(inURLs.length()-1);\n\n inHashes.append(\")\");\n inURLs.append(\")\");\n\n return sql.append(inHashes).append(\" AND url IN \").append(inURLs).toString();\n }\n\n }\n\n public static void main(String[] args) { \n List<String> urls = new ArrayList<String>();\n\n for (int i = 0; i < 10000; i++) {\n urls.add(\"http://www.google.com/\" + System.currentTimeMillis());\n urls.add(\"http://www.yahoo.com/\" + System.currentTimeMillis());\n urls.add(\"http://www.bing.com/\" + System.currentTimeMillis());\n }\n\n\n long startTime = System.currentTimeMillis();\n for (int i = 0; i < 300; i++) {\n GetUrlsIn(5, urls, true);\n }\n long endTime = System.currentTimeMillis();\n System.out.println(\"elapsed time with checks at every iteration: \" + (endTime-startTime) + \"(ms)\");\n\n startTime = System.currentTimeMillis();\n for (int i = 0; i < 300; i++) {\n GetUrlsIn(5, urls, false);\n }\n endTime = System.currentTimeMillis();\n System.out.println(\"elapsed time with deletion at the end: \" + (endTime-startTime) + \"(ms)\");\n }\n}\n"
},
{
"answer_id": 40539794,
"author": "b1tw153",
"author_id": 2562562,
"author_profile": "https://Stackoverflow.com/users/2562562",
"pm_score": 3,
"selected": false,
"text": "String joined = array.stream().map(Object::toString).collect(Collectors.joining(\", \"));\n"
},
{
"answer_id": 44557769,
"author": "AnthonyJClink",
"author_id": 1092670,
"author_profile": "https://Stackoverflow.com/users/1092670",
"pm_score": 0,
"selected": false,
"text": "int nums[] = getNumbersArray();\nStringBuilder builder = new StringBuilder();\n\n// non enhanced version\nfor(int i = 0; i < nums.length; i++){\n builder.append(nums[i]);\n if(i < nums.length - 1){\n builder.append(\",\");\n } \n}\n\n//using iterator\nIterator<int> numIter = Arrays.asList(nums).iterator();\n\nwhile(numIter.hasNext()){\n int num = numIter.next();\n builder.append(num);\n if(numIter.hasNext()){\n builder.append(\",\");\n }\n}\n"
},
{
"answer_id": 69911951,
"author": "Hari Krishna",
"author_id": 3302424,
"author_profile": "https://Stackoverflow.com/users/3302424",
"pm_score": 0,
"selected": false,
"text": "int[] array = { 1, 2, 3 };\nStringJoiner stringJoiner = new StringJoiner(\",\");\n\nfor (int i : array) {\n stringJoiner.add(String.valueOf(i));\n}\n\nSystem.out.println(stringJoiner);\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36858/"
] |
285,524
|
<p>With the following code:</p>
<pre><code>Dim x As System.Xml.Linq.XElement = _
<div>
<%= message.ToString() %>
</div>
Dim m = x.ToString()
</code></pre>
<p>...if message is HTML, then the < and > characters get converted to <code>&lt;</code> and <code>&rt;</code>. </p>
<p>How can I force it to skip this encoding?</p>
|
[
{
"answer_id": 805559,
"author": "CoderDennis",
"author_id": 69527,
"author_profile": "https://Stackoverflow.com/users/69527",
"pm_score": 4,
"selected": true,
"text": "message message XElement .ToString Dim x As System.Xml.Linq.XElement = _\n <div>\n <%= message %>\n </div>\nDim m = x.ToString()\n message StringBuilder Dim x As System.Xml.Linq.XElement = _\n <div>\n <%= XElement.Parse(message.ToString()) %>\n </div>\nDim m = x.ToString()\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/337/"
] |
285,551
|
<p>I have a data acquisition program written in C++ (Visual Studio 6.0). Some clients would like to control the software from their own custom software or LabView. I would like to come up with a simple API with a dll I can distribute to them and would like some tips on how to get started. This is going to be VERY basic, maybe 4 or 5 commands. My DAQ program will still be running in its own window on the same machine, I would just like to set it up to be controlled from another program.</p>
|
[
{
"answer_id": 286745,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 2,
"selected": false,
"text": "stdcall"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6320/"
] |
285,553
|
<p>I need to be able to store a date (year/month/day) with no time component. It's an abstract concept of a date, such as a birthday - I need to represent a date in the year and not a particular instant in time.</p>
<p>I am using Java to parse the date from some input text, and need to store in a MySQL database. No matter what timezone the database, application, or any client is in, they should all see the same year/month/day.</p>
<p>My application will run on a machine with a different system timezone from the database server, and I don't have control over either. Does anyone have an elegant solution for ensuring I store the date correctly?</p>
<p>I can think of these solutions, neither of which seems very nice:</p>
<ul>
<li>Query my MySQL connection for its timezone and parse the input date in that timezone</li>
<li>Process the date entirely as a string yyyy-MM-dd</li>
</ul>
|
[
{
"answer_id": 285656,
"author": "Ben Noland",
"author_id": 32899,
"author_profile": "https://Stackoverflow.com/users/32899",
"pm_score": 2,
"selected": false,
"text": "public static Date truncateDate(Date date)\n {\n GregorianCalendar cal = getGregorianCalendar();\n cal.set(Calendar.ZONE_OFFSET, 0); // UTC\n cal.set(Calendar.DST_OFFSET, 0); // We don't want DST to get in the way.\n\n cal.setTime(date);\n cal.set(Calendar.MILLISECOND, 0);\n cal.set(Calendar.SECOND, 0);\n cal.set(Calendar.MINUTE, 0);\n cal.set(Calendar.HOUR, 0);\n cal.set(Calendar.AM_PM, Calendar.AM);\n\n return cal.getTime();\n }\n"
},
{
"answer_id": 285683,
"author": "Vinnie",
"author_id": 2890,
"author_profile": "https://Stackoverflow.com/users/2890",
"pm_score": 0,
"selected": false,
"text": "DATE INSERT INTO time_table(dt) VALUES('2008-12-31')\n"
},
{
"answer_id": 424568,
"author": "Michael Borgwardt",
"author_id": 16883,
"author_profile": "https://Stackoverflow.com/users/16883",
"pm_score": 0,
"selected": false,
"text": "java.sql.Date java.util.Date"
},
{
"answer_id": 67505173,
"author": "Arvind Kumar Avinash",
"author_id": 10819573,
"author_profile": "https://Stackoverflow.com/users/10819573",
"pm_score": 3,
"selected": false,
"text": "java.util java.util.Date January 1, 1970, 00:00:00 GMT java.util.Date toString LocalDate LocalDate DATE java.time LocalDate columnfoo DATE LocalDate localDate = LocalDate.now();\nPreparedStatement st = conn.prepareStatement(\"INSERT INTO mytable (columnfoo) VALUES (?)\");\nst.setObject(1, localDate);\nst.executeUpdate();\nst.close();\n LocalDate columnfoo Statement st = conn.createStatement();\nResultSet rs = st.executeQuery(\"SELECT * FROM mytable WHERE <some condition>\");\nwhile (rs.next()) {\n // Assuming the column index of columnfoo is 1\n LocalDate localDate = rs.getObject(1, LocalDate.class));\n System.out.println(localDate);\n}\nrs.close();\nst.close();\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37134/"
] |
285,572
|
<p>I've previously encountered the suggestion to call System.Threading.Thread.Sleep(0); in tights loops in C# to prevent CPU hogging and used it to good effect.</p>
<p>I have a PowerShell script that has a tight loop and I'm wondering whether I should be calling [Thread]::Sleep(0) or Start-Sleep 0 or whether the PS engine will yield for me occasionally.</p>
|
[
{
"answer_id": 288453,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 4,
"selected": true,
"text": "[Thread]::CurrentThread.ThreadPriority = System.Threading.ThreadPriority.Lowest\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20819/"
] |
285,573
|
<p>I have googled quite a bit and I cannot find the answer. So how many characters can be stored in a Windows Installer property value. If you give an answer can you provide the source of the answer?</p>
|
[
{
"answer_id": 286037,
"author": "saschabeaumont",
"author_id": 592,
"author_profile": "https://Stackoverflow.com/users/592",
"pm_score": 2,
"selected": false,
"text": "Property Property Value Value Text"
},
{
"answer_id": 286072,
"author": "Brody",
"author_id": 17131,
"author_profile": "https://Stackoverflow.com/users/17131",
"pm_score": 2,
"selected": false,
"text": "Property Value ISComments\ns72 L0 S255\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2768/"
] |
285,579
|
<p>I'm fairly new to c# so that's why I'm asking this here.</p>
<p>I am consuming a web service that returns a long string of XML values. Because this is a string all the attributes have escaped double quotes</p>
<pre><code>string xmlSample = "<root><item att1=\"value\" att2=\"value2\" /></root>"
</code></pre>
<p>Here is my problem. I want to do a simple string.replace. If I was working in PHP I'd just run strip_slashes().</p>
<p>However, I'm in C# and I can't for the life of me figure it out. I can't write out my expression to replace the double quotes (") because it terminates the string. If I escape it then it has incorrect results. What am I doing wrong?</p>
<pre><code> string search = "\\\"";
string replace = "\"";
Regex rgx = new Regex(search);
string strip = rgx.Replace(xmlSample, replace);
//Actual Result <root><item att1=value att2=value2 /></root>
//Desired Result <root><item att1="value" att2="value2" /></root>
</code></pre>
<blockquote>
<p>MizardX: To include a quote in a raw string you need to double it. </p>
</blockquote>
<p>That's important information, trying that approach now...No luck there either
There is something going on here with the double quotes. The concepts you all are suggesting are solid, BUT the issue here is dealing with the double quotes and it looks like I'll need to do some additional research to solve this problem. If anyone comes up with something please post an answer.</p>
<pre><code>string newC = xmlSample.Replace("\\\"", "\"");
//Result <root><item att=\"value\" att2=\"value2\" /></root>
string newC = xmlSample.Replace("\"", "'");
//Result newC "<root><item att='value' att2='value2' /></root>"
</code></pre>
|
[
{
"answer_id": 285603,
"author": "Markus Jarderot",
"author_id": 22364,
"author_profile": "https://Stackoverflow.com/users/22364",
"pm_score": 2,
"selected": false,
"text": "\\ \\ \" Regex rgx = new Regex(\"\\\\\\\\\\\"\");\nstring strip = rgx.Replace(xmlSample, \"\\\"\");\n @ Regex rgx = new Regex(@\"\\\"\"\") string strip = rgx.Replace(xmlSample, @\"\"\"\");"
},
{
"answer_id": 285624,
"author": "Timothy Khouri",
"author_id": 11917,
"author_profile": "https://Stackoverflow.com/users/11917",
"pm_score": 2,
"selected": false,
"text": "string xmlSample = \"blah blah blah\";\n\nxmlSample = xmlSample.Replace(\"\\\\\\\", \"\\\"\");\n"
},
{
"answer_id": 285961,
"author": "balexandre",
"author_id": 28004,
"author_profile": "https://Stackoverflow.com/users/28004",
"pm_score": 1,
"selected": false,
"text": "string xmlSample = \"<root><item att1=\\\"value\\\" att2=\\\"value2\\\" /></root>\";\n System.Xml.XmlDocument xml = new System.Xml.XmlDocument();\nxml.LoadXml(xmlSample);\n\nSystem.Xml.XmlElement _root = xml.DocumentElement;\n\nforeach (System.Xml.XmlNode _node in _root)\n{\n Literal1.Text = \"<hr/>\" + _node.Name + \"<br/>\";\n for (int iAtt = 0; iAtt < _node.Attributes.Count; iAtt++)\n Literal1.Text += _node.Attributes[iAtt].Name + \" = \" + _node.Attributes[iAtt].Value + \"<br/>\";\n}\n item\natt1 = value\natt2 = value2\n"
},
{
"answer_id": 286056,
"author": "ala",
"author_id": 37198,
"author_profile": "https://Stackoverflow.com/users/37198",
"pm_score": 6,
"selected": true,
"text": "string xmlSample = \"<root><item att1=\\\"value\\\" att2=\\\"value2\\\" /></root>\"\n <root><item att1=\"value\" att2=\"value2\" /></root>\n string xmlSample = @\"<root><item att1=\\\"\"value\\\"\" att2=\\\"\"value2\\\"\" /></root>\";\n <root><item att1=\\\"value\\\" att2=\\\"value2\\\" /></root>\n string test = xmlSample.Replace(@\"\\\", string.Empty);\n <root><item att1=\"value\" att2=\"value2\" /></root>\n \\"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30408/"
] |
285,584
|
<p>I am currently stuck on an ASP.NET error when trying to access a .aspx page through localhost. This is the error:</p>
<p><strong>OCIEnvCreate failed with return code -1 but error message text was not available.</strong></p>
<p><strong>Description</strong>: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.</p>
<p><strong>Exception Details</strong>: System.Exception: OCIEnvCreate failed with return code -1 but error message text was not available. </p>
<p><strong>Stack Trace:</strong></p>
<pre><code>[Exception: OCIEnvCreate failed with return code -1 but error message text was not available.]
System.Data.OracleClient.OciHandle..ctor(OciHandle parentHandle, HTYPE handleType, MODE ocimode, HANDLEFLAG handleflags) +363
System.Data.OracleClient.OciEnvironmentHandle..ctor(MODE environmentMode, Boolean unicode) +23
System.Data.OracleClient.OracleInternalConnection.OpenOnLocalTransaction(String userName, String password, String serverName, Boolean integratedSecurity, Boolean unicode, Boolean omitOracleConnectionName) +122
System.Data.OracleClient.OracleInternalConnection..ctor(OracleConnectionString connectionOptions) +135
System.Data.OracleClient.OracleConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) +36
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +68
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +519
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +104
System.Data.OracleClient.OracleConnection.Open() +37
Wilson.ORMapper.Internals.Connection..ctor(String connectString, CustomProvider customProvider) +287
[ORMapperException: ObjectSpace: Connection String is Invalid - OCIEnvCreate failed with return code -1 but error message text was not available.]
Wilson.ORMapper.Internals.Connection..ctor(String connectString, CustomProvider customProvider) +357
Wilson.ORMapper.Internals.Context.Init(XmlDocument xmlMappings, String connectString, CustomProvider customProvider, Int32 sessionMinutes, Int32 cleanupMinutes) +92
Wilson.ORMapper.Internals.Context..ctor(Stream mappingStream, String connectString, CustomProvider customProvider, Int32 sessionMinutes, Int32 cleanupMinutes) +171
Wilson.ORMapper.ObjectSpace..ctor(Stream mappingStream, String connectString, Provider providerType, Int32 sessionMinutes, Int32 cleanupMinutes) +66
zedi.DataManager.GetDefaultInstance() in C:\projects\FINE Application Interface\Production\On-site Backlog\Source\Code\DataAccess\ORClasses\Data\DataManager.cs:155
zedi.DataManager.get_ObjectSpaceGlobal() in C:\projects\FINE Application Interface\Production\On-site Backlog\Source\Code\DataAccess\ORClasses\Data\DataManager.cs:105
zedi.DataManager.get_ObjectSpace() in C:\projects\FINE Application Interface\Production\On-site Backlog\Source\Code\DataAccess\ORClasses\Data\DataManager.cs:129
zedi.DataObjects.CompanyBase.RetrieveQuery(ObjectQuery query) in C:\projects\FINE Application Interface\Production\On-site Backlog\Source\Code\DataAccess\ORClasses\DataObjects\Base\CompanyBase.cs:279
zedi.DataObjects.CompanyBase.RetrieveAll(String sortClause) in C:\projects\FINE Application Interface\Production\On-site Backlog\Source\Code\DataAccess\ORClasses\DataObjects\Base\CompanyBase.cs:78
maint_inetpub.siteTemplates.updateDeviceTemplate.Page_Load(Object sender, EventArgs e) in c:\projects\FINE Application Interface\Production\On-site Backlog\Source\Code\Websites\maint-inetpub\siteTemplates\updateDeviceTemplate.aspx.cs:47
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
</code></pre>
<p>I notice it says the I have an invalid connection string but I have tested it and it works. I currently have Oracle 10g Express installed and before that I had Oracle 8i Client. It was working before I installed 10g Express. </p>
|
[
{
"answer_id": 36290730,
"author": "AnisNoorAli",
"author_id": 5977038,
"author_profile": "https://Stackoverflow.com/users/5977038",
"pm_score": 0,
"selected": false,
"text": "\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.5 System.Data.OracleClient.dll Windows\\Microsoft.NET\\assembly\\GAC_32\\System.Data.OracleClient\\v4.0_4.0.0.0__b77a5c561934e089"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37140/"
] |
285,586
|
<p>I have a script that constantly segfaults - the problem that I can't solve as segfault is in python libxml bindings - didn't write those. Ok, so in Linux I used to run an inf.loop so that when script dies - it restarts, like so:</p>
<pre><code>#!/bin/bash
while [ 1 ]
do
nice -n 19 python server.py
sleep 1
done
</code></pre>
<p>Well, I can't seem to find /bin/bash in FreeBSD so that doesn't work. </p>
<p>Any ideas? Consider that cron is not an option - allowed downtime is a few seconds.</p>
|
[
{
"answer_id": 285609,
"author": "David Thornley",
"author_id": 14148,
"author_profile": "https://Stackoverflow.com/users/14148",
"pm_score": 1,
"selected": false,
"text": "type bash type bash type sh"
},
{
"answer_id": 285610,
"author": "Evan Teran",
"author_id": 13430,
"author_profile": "https://Stackoverflow.com/users/13430",
"pm_score": 3,
"selected": true,
"text": "cd /usr/ports/*/bash\nmake install\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37141/"
] |
285,591
|
<p>Is it possible to use the __unused attribute macro on Objective-C object method parameters? I've tried placing it in various positions around the parameter declaration but it either causes a compilation error or seems to be ignored (i.e., the compiler still generates unused parameter warnings when compiling with -Wall -Wextra).</p>
<p>Has anyone been able to do use this? Is it just unsupported with Objective-C? For reference, I'm currently using Apple's build of GCC 4.0.1.</p>
|
[
{
"answer_id": 285702,
"author": "Louis Gerbarg",
"author_id": 30506,
"author_profile": "https://Stackoverflow.com/users/30506",
"pm_score": 2,
"selected": false,
"text": "- (NSString *) test:(__unused NSString *)test {\n return nil;\n}\n Phoenix-VI:CouchPusher louis$ cc -c Pusher.m -Wall -Werror\nPhoenix-VI:CouchPusher louis$ cc -c Pusher.m -Wall -Werror -Wunused-parameter\ncc1obj: warnings being treated as errors\nPusher.m:40: warning: unused parameter ‘test’\nPhoenix-VI:CouchPusher louis$ \n"
},
{
"answer_id": 285750,
"author": "Jason Coco",
"author_id": 34218,
"author_profile": "https://Stackoverflow.com/users/34218",
"pm_score": 5,
"selected": true,
"text": "-(void)someMethod:(id) __unused someParam;\n"
},
{
"answer_id": 285751,
"author": "Lily Ballard",
"author_id": 582,
"author_profile": "https://Stackoverflow.com/users/582",
"pm_score": 2,
"selected": false,
"text": "- (NSString *)test:(NSString *)test {\n#pragma unused (test);\n return nil;\n}\n"
},
{
"answer_id": 285785,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 2,
"selected": false,
"text": "#define UNUSED(x) (void)x\nvoid SomeFunction(int param1, int param2)\n{\n UNUSED(param2);\n // do stuff with param1\n} UNUSED(param2)"
},
{
"answer_id": 1863688,
"author": "alecf",
"author_id": 204357,
"author_profile": "https://Stackoverflow.com/users/204357",
"pm_score": 1,
"selected": false,
"text": "+ (NSString*) runQuery:(id)query name:(NSString*)name options:(NSDictionary*)options\n{\n#pragma unused(name)\n ...\n\n}\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34218/"
] |
285,614
|
<p>Every night I need to trim back a table to only contain the latest 20,000 records. I could use a subquery:</p>
<pre><code>delete from table WHERE id NOT IN (select TOP 20000 ID from table ORDER BY date_added DESC)
</code></pre>
<p>But that seems inefficient, especially if we later decide to keep 50,000 records. I'm using SQL 2005, and thought I could use ROW_NUMBER() OVER somehow to do it? Order them and delete all that have a ROW_NUMBER greater than 20,000? But I couldn't get it to work. Is the subquery my best bet or is there a better way?</p>
|
[
{
"answer_id": 285851,
"author": "Borzio",
"author_id": 36215,
"author_profile": "https://Stackoverflow.com/users/36215",
"pm_score": 2,
"selected": false,
"text": "select top 20000 * into #myTempTable from MyTable ORDER BY DateAdded DESC\n truncate table MyTable \n insert into MyTable select * from #myTempTable\n drop table #myTempTable\n"
},
{
"answer_id": 285914,
"author": "Haoest",
"author_id": 10088,
"author_profile": "https://Stackoverflow.com/users/10088",
"pm_score": 2,
"selected": false,
"text": "DECLARE @limit INT\nSELECT @limit = min(id) FROM\n (SELECT TOP 20000 id FROM your_table ORDER BY id DESC)x\nDELETE FROM your_table where id < @limit\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10876/"
] |
285,617
|
<p>I'd like to call svn up from an asp.net page so people can hit the page to update a repository. (BTW: I'm using Beanstalk.com svn hosting which doesn't allow post-commit hooks, which is why I am doing it this way). </p>
<p>See what I've got below. The process starts (it shows up in Processes in Task Manager) and exits after several seconds with no output message (at least none is outputted to the page). The repository does not get updated. But it does do something with the repository because the next time I try to manually update it from the command line it says the repo is locked. I have to run svn cleanup to get it to update. </p>
<p>Ideas?</p>
<pre><code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
startInfo = New System.Diagnostics.ProcessStartInfo("svn")
startInfo.RedirectStandardOutput = True
startInfo.UseShellExecute = False
startInfo.Arguments = "up " & Request.QueryString("path")
pStart.StartInfo = startInfo
pStart.Start()
pStart.WaitForExit()
Response.Write(pStart.StandardOutput.ReadToEnd())
End Sub
</code></pre>
|
[
{
"answer_id": 286989,
"author": "Bert Huijben",
"author_id": 2094,
"author_profile": "https://Stackoverflow.com/users/2094",
"pm_score": 0,
"selected": false,
"text": "using(SvnClient client = new SvnClient())\n{\n client.Update(Request[\"path\"]);\n}\n"
},
{
"answer_id": 49434391,
"author": "wojouk",
"author_id": 9536082,
"author_profile": "https://Stackoverflow.com/users/9536082",
"pm_score": 0,
"selected": false,
"text": " private static int lineCount = 0;\n private static StringBuilder outputBuffer = new StringBuilder();\n private void SvnOutputHandler(object sendingProcess,\n DataReceivedEventArgs e)\n {\n Process p = sendingProcess as Process;\n\n // Save the output lines here\n // Prepend line numbers to each line of the output.\n if (!String.IsNullOrEmpty(e.Data))\n {\n lineCount++;\n outputBuffer.Append(\"\\n[\" + lineCount + \"]: \" + e.Data);\n }\n }\n\n private void RunSVNCommand()\n {\n ProcessStartInfo psi = new ProcessStartInfo(\"cmd.exe\",\n string.Format(\"/c svn.exe --config-dir=%APPDATA%\\\\Subversion --username=yrname --password=yrpassword --trust-server-cert --non-interactive update d:\\\\inetpub\\\\wwwroot\\\\yourpath\"));\n\n psi.UseShellExecute = false;\n psi.CreateNoWindow = true;\n\n // Redirect the standard output of the sort command. \n // This stream is read asynchronously using an event handler.\n psi.RedirectStandardOutput = true;\n psi.RedirectStandardError = true;\n\n Process p = new Process();\n\n // Set our event handler to asynchronously read the sort output.\n p.OutputDataReceived += SvnOutputHandler;\n p.ErrorDataReceived += SvnOutputHandler;\n p.StartInfo = psi;\n\n p.Start();\n\n p.BeginOutputReadLine();\n p.BeginErrorReadLine();\n\n p.WaitForExit();\n }\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,618
|
<p>Another angle:
how do I browse all the XUL for a given chrome path, e.g.</p>
<p><a href="http://kb.mozillazine.org/Dev_:_Firefox_Chrome_URLs" rel="nofollow noreferrer">http://kb.mozillazine.org/Dev_:_Firefox_Chrome_URLs</a> has a listing but seems to be out of date.</p>
|
[
{
"answer_id": 476769,
"author": "Jason S",
"author_id": 44330,
"author_profile": "https://Stackoverflow.com/users/44330",
"pm_score": 1,
"selected": false,
"text": "chrome:// {where you installed Firefox}/chrome/browser.jar\n {your profile directory}/extensions/{extension id}/chrome/content/...\n {your profile directory} c:\\Documents and Settings\\{your username}\\Application Data\\Mozilla\\Firefox\\Profiles\\{your profile name, usually ends in .default}\n"
},
{
"answer_id": 498352,
"author": "ephemient",
"author_id": 20713,
"author_profile": "https://Stackoverflow.com/users/20713",
"pm_score": 2,
"selected": false,
"text": "chrome://global/content/netError.xhtml?e=nssBadCert&u= netError.xhtml"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285618",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34594/"
] |
285,619
|
<p>I have an input String say <code>Please go to http://stackoverflow.com</code>. The url part of the String is detected and an anchor <code><a href=""></a></code> is automatically added by many browser/IDE/applications. So it becomes <code>Please go to <a href='http://stackoverflow.com'>http://stackoverflow.com</a></code>.</p>
<p>I need to do the same using Java.</p>
|
[
{
"answer_id": 285667,
"author": "Jason Coco",
"author_id": 34218,
"author_profile": "https://Stackoverflow.com/users/34218",
"pm_score": 3,
"selected": false,
"text": "String originalString = \"Please go to http://www.stackoverflow.com\";\nString newString = originalString.replaceAll(\"http://.+?(com|net|org)/{0,1}\", \"<a href=\\\"$0\\\">$0</a>\");\n"
},
{
"answer_id": 285690,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 0,
"selected": false,
"text": "String msg = \"Please go to http://stackoverflow.com\";\nString withURL = msg.replaceAll(\"(?:https?|ftps?)://[\\\\w/%.-]+\", \"<a href='$0'>$0</a>\");\nSystem.out.println(withURL);\n"
},
{
"answer_id": 285808,
"author": "ykaganovich",
"author_id": 10026,
"author_profile": "https://Stackoverflow.com/users/10026",
"pm_score": 0,
"selected": false,
"text": "String.replaceAll"
},
{
"answer_id": 285865,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 4,
"selected": false,
"text": "\\(?\\bhttp://[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]\n if (s.StartsWith(\"(\") && s.EndsWith(\")\"))\n{\n return s.Substring(1, s.Length - 2);\n}\n"
},
{
"answer_id": 285880,
"author": "OscarRyz",
"author_id": 20654,
"author_profile": "https://Stackoverflow.com/users/20654",
"pm_score": 6,
"selected": false,
"text": "import java.net.URL;\nimport java.net.MalformedURLException;\n\n// Replaces URLs with html hrefs codes\npublic class URLInString {\n public static void main(String[] args) {\n String s = args[0];\n // separate input by spaces ( URLs don't have spaces )\n String [] parts = s.split(\"\\\\s+\");\n\n // Attempt to convert each item into an URL. \n for( String item : parts ) try {\n URL url = new URL(item);\n // If possible then replace with anchor...\n System.out.print(\"<a href=\\\"\" + url + \"\\\">\"+ url + \"</a> \" ); \n } catch (MalformedURLException e) {\n // If there was an URL that was not it!...\n System.out.print( item + \" \" );\n }\n\n System.out.println();\n }\n}\n \"Please go to http://stackoverflow.com and then mailto:oscarreyes@wordpress.com to download a file from ftp://user:pass@someserver/someFile.txt\"\n Please go to <a href=\"http://stackoverflow.com\">http://stackoverflow.com</a> and then <a href=\"mailto:oscarreyes@wordpress.com\">mailto:oscarreyes@wordpress.com</a> to download a file from <a href=\"ftp://user:pass@someserver/someFile.txt\">ftp://user:pass@someserver/someFile.txt</a>\n url.getProtocol();\n"
},
{
"answer_id": 7122165,
"author": "Sérgio Nunes",
"author_id": 452172,
"author_profile": "https://Stackoverflow.com/users/452172",
"pm_score": 0,
"selected": false,
"text": "msg.replaceAll(\"(?:https?|ftps?)://[\\w/%.-][/\\??\\w=?\\w?/%.-]?[/\\?&\\w=?\\w?/%.-]*\", \"$0\");"
},
{
"answer_id": 9602832,
"author": "Jacob Zwiers",
"author_id": 228838,
"author_profile": "https://Stackoverflow.com/users/228838",
"pm_score": 2,
"selected": false,
"text": "// NOTES: 1) \\w includes 0-9, a-z, A-Z, _\n// 2) The leading '-' is the '-' character. It must go first in character class expression\nprivate static final String VALID_CHARS = \"-\\\\w+&@#/%=~()|\";\nprivate static final String VALID_NON_TERMINAL = \"?!:,.;\";\n\n// Notes on the expression:\n// 1) Any number of leading '(' (left parenthesis) accepted. Will be dealt with. \n// 2) s? ==> the s is optional so either [http, https] accepted as scheme\n// 3) All valid chars accepted and then one or more\n// 4) Case insensitive so that the scheme can be hTtPs (for example) if desired\nprivate static final Pattern URI_FINDER_PATTERN = Pattern.compile(\"\\\\(*https?://[\"+ VALID_CHARS + VALID_NON_TERMINAL + \"]*[\" +VALID_CHARS + \"]\", Pattern.CASE_INSENSITIVE );\n\n/**\n * <p>\n * Finds all \"URL\"s in the given _rawText, wraps them in \n * HTML link tags and returns the result (with the rest of the text\n * html encoded).\n * </p>\n * <p>\n * We employ the procedure described at:\n * http://www.codinghorror.com/blog/2008/10/the-problem-with-urls.html\n * which is a <b>must-read</b>.\n * </p>\n * Basically, we allow any number of left parenthesis (which will get stripped away)\n * followed by http:// or https://. Then any number of permitted URL characters\n * (based on http://www.ietf.org/rfc/rfc1738.txt) followed by a single character\n * of that set (basically, those minus typical punctuation). We remove all sets of \n * matching left & right parentheses which surround the URL.\n *</p>\n * <p>\n * This method *must* be called from a tag/component which will NOT\n * end up escaping the output. For example:\n * <PRE>\n * <h:outputText ... escape=\"false\" value=\"#{core:hyperlinkText(textThatMayHaveURLs, '_blank')}\"/>\n * </pre>\n * </p>\n * <p>\n * Reason: we are adding <code><a href=\"...\"></code> tags to the output *and*\n * encoding the rest of the string. So, encoding the outupt will result in\n * double-encoding data which was already encoded - and encoding the <code>a href</code>\n * (which will render it useless).\n * </p>\n * <p>\n * \n * @param _rawText - if <code>null</code>, returns <code>\"\"</code> (empty string).\n * @param _target - if not <code>null</code> or <code>\"\"</code>, adds a target attributed to the generated link, using _target as the attribute value.\n */\npublic static final String hyperlinkText( final String _rawText, final String _target ) {\n\n String returnValue = null;\n\n if ( !StringUtils.isBlank( _rawText ) ) {\n\n final Matcher matcher = URI_FINDER_PATTERN.matcher( _rawText );\n\n if ( matcher.find() ) {\n\n final int originalLength = _rawText.length();\n\n final String targetText = ( StringUtils.isBlank( _target ) ) ? \"\" : \" target=\\\"\" + _target.trim() + \"\\\"\";\n final int targetLength = targetText.length();\n\n // Counted 15 characters aside from the target + 2 of the URL (max if the whole string is URL)\n // Rough guess, but should keep us from expanding the Builder too many times.\n final StringBuilder returnBuffer = new StringBuilder( originalLength * 2 + targetLength + 15 );\n\n int currentStart;\n int currentEnd;\n int lastEnd = 0;\n\n String currentURL;\n\n do {\n currentStart = matcher.start();\n currentEnd = matcher.end();\n currentURL = matcher.group();\n\n // Adjust for URLs wrapped in ()'s ... move start/end markers\n // and substring the _rawText for new URL value.\n while ( currentURL.startsWith( \"(\" ) && currentURL.endsWith( \")\" ) ) {\n currentStart = currentStart + 1;\n currentEnd = currentEnd - 1;\n\n currentURL = _rawText.substring( currentStart, currentEnd );\n }\n\n while ( currentURL.startsWith( \"(\" ) ) {\n currentStart = currentStart + 1;\n\n currentURL = _rawText.substring( currentStart, currentEnd );\n }\n\n // Text since last match\n returnBuffer.append( HtmlUtil.encode( _rawText.substring( lastEnd, currentStart ) ) );\n\n // Wrap matched URL\n returnBuffer.append( \"<a href=\\\"\" + currentURL + \"\\\"\" + targetText + \">\" + currentURL + \"</a>\" );\n\n lastEnd = currentEnd;\n\n } while ( matcher.find() );\n\n if ( lastEnd < originalLength ) {\n returnBuffer.append( HtmlUtil.encode( _rawText.substring( lastEnd ) ) );\n }\n\n returnValue = returnBuffer.toString();\n }\n } \n\n if ( returnValue == null ) {\n returnValue = HtmlUtil.encode( _rawText );\n }\n\n return returnValue;\n\n}\n"
},
{
"answer_id": 11395769,
"author": "Tixa",
"author_id": 1499545,
"author_profile": "https://Stackoverflow.com/users/1499545",
"pm_score": -1,
"selected": false,
"text": "if (yourtextview.getText().toString().contains(\"www\") || yourtextview.getText().toString().contains(\"http://\"){ your code here if contains URL;}\n"
},
{
"answer_id": 12330748,
"author": "Adam Gent",
"author_id": 318174,
"author_profile": "https://Stackoverflow.com/users/318174",
"pm_score": 0,
"selected": false,
"text": "public static Iterator<ExtractedURI> extractURIs(\n final Reader reader,\n final Iterable<ToURIStrategy> strategies,\n String ... schemes);\n public static List<ToURIStrategy> DEFAULT_STRATEGY_CHAIN = ImmutableList.of(\n new RemoveSurroundsWithToURIStrategy(\"'\"),\n new RemoveSurroundsWithToURIStrategy(\"\\\"\"),\n new RemoveSurroundsWithToURIStrategy(\"(\", \")\"),\n new RemoveEndsWithToURIStrategy(\".\"),\n DEFAULT_STRATEGY,\n REMOVE_LAST_STRATEGY);\n"
},
{
"answer_id": 30829767,
"author": "robinst",
"author_id": 305973,
"author_profile": "https://Stackoverflow.com/users/305973",
"pm_score": 0,
"selected": false,
"text": "http://example.com. http://example.com, (http://example.com) (... (see http://example.com)) https://en.wikipedia.org/wiki/Link_(The_Legend_of_Zelda) http://üñîçøðé.com/"
},
{
"answer_id": 43037736,
"author": "Beeing Jk",
"author_id": 4665578,
"author_profile": "https://Stackoverflow.com/users/4665578",
"pm_score": -1,
"selected": false,
"text": "<TextView\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:autoLink=\"web\"\n android:linksClickable=\"true\"/>\n android:autoLink=\"all\""
},
{
"answer_id": 71198955,
"author": "Bayram Binbir",
"author_id": 11102299,
"author_profile": "https://Stackoverflow.com/users/11102299",
"pm_score": 0,
"selected": false,
"text": " public static List<String> extractURL(String text) {\n List<String> list = new ArrayList<>();\n Pattern pattern = Pattern\n .compile(\n \"(http://|https://){1}[\\\\w\\\\.\\\\-/:\\\\#\\\\?\\\\=\\\\&\\\\;\\\\%\\\\~\\\\+]+\",\n Pattern.CASE_INSENSITIVE);\n Matcher matcher = pattern.matcher(text);\n while (matcher.find()) {\n list.add(matcher.group());\n }\n return list;\n}\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37144/"
] |
285,649
|
<p>I have a web application that is using a data store that has it's own built in paging. The PagedResult class tells me the number of total pages. What I would like to do it (after binding my ASP.NET GridView) do this:</p>
<pre><code>MyGridView.PageCount = thePageCount;
</code></pre>
<p>And then have the GridView magically build the pagination links as it normally would if it was doing things itself.</p>
<p>The problem is that "PageCount" is a read-only property... so, how can I do this simply?</p>
|
[
{
"answer_id": 1725048,
"author": "Randi",
"author_id": 209916,
"author_profile": "https://Stackoverflow.com/users/209916",
"pm_score": 0,
"selected": false,
"text": " Dim myCount as Integer = 1 'this sets the page count to 1 \n While (oreader.Read())\n myCount += 1 'increments once for everytime a item is counted\n 'this sets an array for the items to go into\n idFname = oreader.GetOrdinal(\"workCenter\")\n 'this retrieves the values at those indices\n fName = oreader.GetValue(idFname)\n BulletedList1.Items.Add(fName)\n End While\n\n Catch ex As Exception\n BulletedList1.Items.Add(\"No Workcenters Found\")\n Finally\n oreader.Close()\n oconn.Close()\n End Try\nEnd If\nMe.insertItemForm.PagerSettings.PageButtonCount = myCount 'sets the page count to number of items in gridview or formview etc.\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11917/"
] |
285,658
|
<p>Is there a way in FreeBSD to (being root) run a command as unprivileged user, like nobody? Kind of like reverse of sudo. Oh and considering that 'nobody' has /usr/sbin/nologin as shell - so <b>su</b> is not an option.</p>
|
[
{
"answer_id": 285693,
"author": "DrStalker",
"author_id": 17007,
"author_profile": "https://Stackoverflow.com/users/17007",
"pm_score": 6,
"selected": true,
"text": "sudo -u nobody <command>\n"
},
{
"answer_id": 3234272,
"author": "Brad Ackerman",
"author_id": 113222,
"author_profile": "https://Stackoverflow.com/users/113222",
"pm_score": 6,
"selected": false,
"text": "su nologin -m su -m cthulhu -c '/usr/bin/scorpion-stare'\n cthulhu"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37141/"
] |
285,660
|
<p>In Vim I can <code>:set wrapscan</code> so that when I do an incremental search, the cursor jumps to the first match whether the first match is above or below the cursor.</p>
<p>In Emacs, if I start a search via <code>C-s</code>, the search fails saying <em>Failing I-search</em> if the first match is above the cursor. If I hit <code>C-s</code> again it then wraps the search, saying <em>Wrapped I-search</em>. How do I wrap and jump the cursor by default as in Vim, without having to <code>C-s</code> a second time?</p>
|
[
{
"answer_id": 287067,
"author": "link0ff",
"author_id": 23952,
"author_profile": "https://Stackoverflow.com/users/23952",
"pm_score": 5,
"selected": true,
"text": "(defadvice isearch-repeat (after isearch-no-fail activate)\n (unless isearch-success\n (ad-disable-advice 'isearch-repeat 'after 'isearch-no-fail)\n (ad-activate 'isearch-repeat)\n (isearch-repeat (if isearch-forward 'forward))\n (ad-enable-advice 'isearch-repeat 'after 'isearch-no-fail)\n (ad-activate 'isearch-repeat)))\n"
},
{
"answer_id": 36707038,
"author": "Chris Martin",
"author_id": 402884,
"author_profile": "https://Stackoverflow.com/users/402884",
"pm_score": 3,
"selected": false,
"text": ";; Prevents issue where you have to press backspace twice when\n;; trying to remove the first character that fails a search\n(define-key isearch-mode-map [remap isearch-delete-char] 'isearch-del-char)\n\n(defadvice isearch-search (after isearch-no-fail activate)\n (unless isearch-success\n (ad-disable-advice 'isearch-search 'after 'isearch-no-fail)\n (ad-activate 'isearch-search)\n (isearch-repeat (if isearch-forward 'forward))\n (ad-enable-advice 'isearch-search 'after 'isearch-no-fail)\n (ad-activate 'isearch-search)))\n"
},
{
"answer_id": 72900696,
"author": "cabo",
"author_id": 1163318,
"author_profile": "https://Stackoverflow.com/users/1163318",
"pm_score": 1,
"selected": false,
"text": "isearch-wrap-pause no"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23070/"
] |
285,662
|
<pre><code>some_var = foo()
another_var = bar()
</code></pre>
<p>or</p>
<pre><code>some_var = foo()
another_var = bar()
</code></pre>
<p>Including changing the whitespace as lines are added or removed to keep them lined up. Does this really look good? Is it worth the mucking up of the diff?</p>
|
[
{
"answer_id": 285678,
"author": "Patrick Szalapski",
"author_id": 7453,
"author_profile": "https://Stackoverflow.com/users/7453",
"pm_score": 1,
"selected": false,
"text": "some_var[ 1] = \"foo\";\nsome_var[100] = \"bar\";\n @some_var varchar(25) = NULL\n@another_var varchar(1000) = ''\n@one_more int = 0\n"
},
{
"answer_id": 285681,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 3,
"selected": false,
"text": "some_var = foo()\nanother_var = bar()\n another_another_var some_var = foo()\nanother_var = bar()\nanother_another_var = baz()\n some_var = foo()\nanother_var = bar()\nanother_another_var = baz()\n"
},
{
"answer_id": 285749,
"author": "Diastrophism",
"author_id": 18093,
"author_profile": "https://Stackoverflow.com/users/18093",
"pm_score": 1,
"selected": false,
"text": "...\nsome_important_number = 348273;\ninitial_message_prefix = \"foo\";\nanother_important_number = 348711;\nmax_bucket_sz = 456;\n...\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19687/"
] |
285,666
|
<p>I need to know how to return a default row if no rows exist in a table. What would be the best way to do this? I'm only returning a single column from this particular table to get its value. </p>
<p>Edit: This would be SQL Server. </p>
|
[
{
"answer_id": 285699,
"author": "Jason Anderson",
"author_id": 1530166,
"author_profile": "https://Stackoverflow.com/users/1530166",
"pm_score": 1,
"selected": false,
"text": "select '' as columnA, '' as columnB, '' as columnC from #tempTable\n"
},
{
"answer_id": 285701,
"author": "WW.",
"author_id": 14663,
"author_profile": "https://Stackoverflow.com/users/14663",
"pm_score": 7,
"selected": true,
"text": "SELECT val\nFROM myTable\nUNION ALL\nSELECT 'DEFAULT'\nFROM dual\nWHERE NOT EXISTS (SELECT * FROM myTable)\n SELECT NVL(MIN(val), 'DEFAULT')\nFROM myTable\n SELECT ISNULL(MIN(val), 'DEFAULT')\nFROM myTable\n MIN() NULL"
},
{
"answer_id": 285722,
"author": "John Baughman",
"author_id": 26923,
"author_profile": "https://Stackoverflow.com/users/26923",
"pm_score": 2,
"selected": false,
"text": "select rate \nfrom d_payment_index\nwhere fy = 2007\n and payment_year = 2008\n and program_id = 18\nunion\nselect 0 as rate \nfrom d_payment_index \nwhere not exists( select rate \n from d_payment_index\n where fy = 2007\n and payment_year = 2008\n and program_id = 18 )\n"
},
{
"answer_id": 285823,
"author": "John Lemp",
"author_id": 12915,
"author_profile": "https://Stackoverflow.com/users/12915",
"pm_score": 3,
"selected": false,
"text": "Declare @rate int\n\nselect \n @rate = rate \nfrom \n d_payment_index\nwhere \n fy = 2007\n and payment_year = 2008\n and program_id = 18\n\nIF @@rowcount = 0\n Set @rate = 0\n\nSelect @rate 'rate'\n"
},
{
"answer_id": 285871,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 2,
"selected": false,
"text": "CREATE TABLE [stackoverflow-285666] (k int, val varchar(255))\n\nINSERT INTO [stackoverflow-285666]\nVALUES (1, '1-1')\nINSERT INTO [stackoverflow-285666]\nVALUES (1, '1-2')\nINSERT INTO [stackoverflow-285666]\nVALUES (1, '1-3')\nINSERT INTO [stackoverflow-285666]\nVALUES (2, '2-1')\nINSERT INTO [stackoverflow-285666]\nVALUES (2, '2-2')\n\nDECLARE @k AS int\nSET @k = 0\n\nWHILE @k < 3\n BEGIN\n SELECT @k AS k\n ,COALESCE(ActualValue, DefaultValue) AS [Value]\n FROM (\n SELECT 'DefaultValue' AS DefaultValue\n ) AS Defaults\n LEFT JOIN (\n SELECT val AS ActualValue\n FROM [stackoverflow-285666]\n WHERE k = @k\n ) AS [Values]\n ON 1 = 1\n\n SET @k = @k + 1\n END\n\nDROP TABLE [stackoverflow-285666]\n k Value\n----------- ------------\n0 DefaultValue\n\nk Value\n----------- ------------\n1 1-1\n1 1-2\n1 1-3\n\nk Value\n----------- ------------\n2 2-1\n2 2-2\n"
},
{
"answer_id": 288185,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 4,
"selected": false,
"text": "select NVL( MIN(rate), 0 ) AS rate \nfrom d_payment_index\nwhere fy = 2007\n and payment_year = 2008\n and program_id = 18\n"
},
{
"answer_id": 534178,
"author": "beach",
"author_id": 53892,
"author_profile": "https://Stackoverflow.com/users/53892",
"pm_score": 3,
"selected": false,
"text": "SELECT DEF.Rate, ACTUAL.Rate, COALESCE(ACTUAL.Rate, DEF.Rate) AS UseThisRate\nFROM \n (SELECT 0) DEF (Rate) -- This is your default rate\nLEFT JOIN (\n select rate \n from d_payment_index\n --WHERE 1=2 -- Uncomment this line to simulate a missing value\n\n --...HERE IF YOUR ACTUAL WHERE CLAUSE. Removed for testing purposes...\n --where fy = 2007\n -- and payment_year = 2008\n -- and program_id = 18\n) ACTUAL (Rate) ON 1=1\n Rate Rate UseThisRate\n----------- ----------- -----------\n0 1 1\n Rate Rate UseThisRate\n----------- ----------- -----------\n0 NULL 0\n CREATE TABLE d_payment_index (rate int NOT NULL)\nINSERT INTO d_payment_index VALUES (1)\n"
},
{
"answer_id": 37454970,
"author": "Y-Mi Wong",
"author_id": 6384946,
"author_profile": "https://Stackoverflow.com/users/6384946",
"pm_score": 0,
"selected": false,
"text": " ---=== The table & its data\n CREATE TABLE dbo.Rates (\n PkId int,\n name varchar(10),\n rate decimal(10,2)\n )\n INSERT INTO dbo.Rates(PkId, name, rate) VALUES (1, 'Schedule 1', 0.1)\n INSERT INTO dbo.Rates(PkId, name, rate) VALUES (2, 'Schedule 2', 0.2)\n ---=== The solution \nCREATE PROCEDURE dbo.GetRate \n @PkId int\nAS\nBEGIN\n DECLARE @tempTable TABLE (\n PkId int, \n name varchar(10), \n rate decimal(10,2)\n )\n\n --- [1] Insert default values into @tempTable. PkId=0 is dummy value \n INSERT INTO @tempTable(PkId, name, rate) VALUES (0, 'DEFAULT', 0.00)\n\n --- [2] Update the single row in @tempTable with the actual value.\n --- This only happens if a match is found\n UPDATE @tempTable\n SET t.PkId=x.PkId, t.name=x.name, t.rate = x.rate\n FROM @tempTable t INNER JOIN dbo.Rates x\n ON t.PkId = 0\n WHERE x.PkId = @PkId\n\n SELECT * FROM @tempTable\nEND\n EXEC dbo.GetRate @PkId=1 --- returns values for PkId=1\nEXEC dbo.GetRate @PkId=12314 --- returns default values\n"
},
{
"answer_id": 51160249,
"author": "Eike",
"author_id": 388845,
"author_profile": "https://Stackoverflow.com/users/388845",
"pm_score": 3,
"selected": false,
"text": "WITH products AS (\n SELECT prod_name,\n price\n FROM Products_Table\n WHERE prod_name LIKE '%foo%'\n ),\n defaults AS (\n SELECT '-' AS prod_name,\n 0 AS price\n )\n\nSELECT * FROM products\nUNION ALL\nSELECT * FROM defaults\n WHERE NOT EXISTS ( SELECT * FROM products );\n"
},
{
"answer_id": 62469335,
"author": "Deepak Vaishnav",
"author_id": 6854712,
"author_profile": "https://Stackoverflow.com/users/6854712",
"pm_score": 2,
"selected": false,
"text": "SELECT * FROM review WHERE id = 1555\nUNION ALL\nSELECT * FROM review WHERE NOT EXISTS ( SELECT * FROM review where id = 1555 ) AND id = 1\n"
},
{
"answer_id": 63174302,
"author": "Serge Bugera",
"author_id": 3289809,
"author_profile": "https://Stackoverflow.com/users/3289809",
"pm_score": 2,
"selected": false,
"text": "config config_code CONFIG_CODE PARAM1 PARAM2\n--------------- -------- --------\ndefault_config def 000\nconfig1 abc 123\nconfig2 def 456\n config1 SELECT *\n FROM (SELECT *\n FROM config\n WHERE config_code = 'config1'\n OR config_code = 'default_config'\n ORDER BY CASE config_code WHEN 'default_config' THEN 999 ELSE 1 END)\n WHERE rownum = 1;\n CONFIG_CODE PARAM1 PARAM2\n--------------- -------- --------\nconfig1 abc 123\n config3 SELECT *\n FROM (SELECT *\n FROM config\n WHERE config_code = 'config3'\n OR config_code = 'default_config'\n ORDER BY CASE config_code WHEN 'default_config' THEN 999 ELSE 1 END)\n WHERE rownum = 1;\n CONFIG_CODE PARAM1 PARAM2\n--------------- -------- --------\ndefault_config def 000\n config"
},
{
"answer_id": 68619854,
"author": "Shanmukhi Goli",
"author_id": 9479518,
"author_profile": "https://Stackoverflow.com/users/9479518",
"pm_score": 0,
"selected": false,
"text": "\n SELECT IF (\n (SELECT COUNT(*) FROM tbs.replication_status) > 0, \n (SELECT rs.last_replication_end_date FROM tbs.replication_status AS rs \n WHERE rs.last_replication_start_date IS NOT NULL \n AND rs.last_replication_end_date IS NOT NULL \n AND rs.table = '%s' ORDER BY id DESC LIMIT 1), \n (SELECT CAST(UNIX_TIMESTAMP (CURRENT_TIMESTAMP(6)) AS UNSIGNED))\n ) AS ts;\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26923/"
] |
285,674
|
<p>In firefox, the error messages display as should. Just to the right of the element being validated. In IE. No matter what I do with the sizing of the labels/elements/errors, the error is always posted below the element, causing every other element to be pushed down.</p>
<pre><code><p>
<label for="handle"><strong>User Name</strong></label>
<INPUT NAME="handle" id="handle" VALUE="#attributes.getUser.handle#">
</p>
<p>
<label for="password"><strong>Password</strong></label>
<INPUT TYPE="TEXT" id="password" NAME="password"
MAXLENGTH=50 VALUE="#attributes.getUser.password#">
</p>
<p>
<label for="confirmPassword"><strong>Confirm Password</strong></label>
<INPUT TYPE="TEXT" id="confirmPassword" NAME="confirmPassword"
MAXLENGTH=50 VALUE="#attributes.getUser.password#">
</p>
</code></pre>
<p>If anyone else has had this issue, i'd be very grateful for any help.</p>
|
[
{
"answer_id": 285699,
"author": "Jason Anderson",
"author_id": 1530166,
"author_profile": "https://Stackoverflow.com/users/1530166",
"pm_score": 1,
"selected": false,
"text": "select '' as columnA, '' as columnB, '' as columnC from #tempTable\n"
},
{
"answer_id": 285701,
"author": "WW.",
"author_id": 14663,
"author_profile": "https://Stackoverflow.com/users/14663",
"pm_score": 7,
"selected": true,
"text": "SELECT val\nFROM myTable\nUNION ALL\nSELECT 'DEFAULT'\nFROM dual\nWHERE NOT EXISTS (SELECT * FROM myTable)\n SELECT NVL(MIN(val), 'DEFAULT')\nFROM myTable\n SELECT ISNULL(MIN(val), 'DEFAULT')\nFROM myTable\n MIN() NULL"
},
{
"answer_id": 285722,
"author": "John Baughman",
"author_id": 26923,
"author_profile": "https://Stackoverflow.com/users/26923",
"pm_score": 2,
"selected": false,
"text": "select rate \nfrom d_payment_index\nwhere fy = 2007\n and payment_year = 2008\n and program_id = 18\nunion\nselect 0 as rate \nfrom d_payment_index \nwhere not exists( select rate \n from d_payment_index\n where fy = 2007\n and payment_year = 2008\n and program_id = 18 )\n"
},
{
"answer_id": 285823,
"author": "John Lemp",
"author_id": 12915,
"author_profile": "https://Stackoverflow.com/users/12915",
"pm_score": 3,
"selected": false,
"text": "Declare @rate int\n\nselect \n @rate = rate \nfrom \n d_payment_index\nwhere \n fy = 2007\n and payment_year = 2008\n and program_id = 18\n\nIF @@rowcount = 0\n Set @rate = 0\n\nSelect @rate 'rate'\n"
},
{
"answer_id": 285871,
"author": "Cade Roux",
"author_id": 18255,
"author_profile": "https://Stackoverflow.com/users/18255",
"pm_score": 2,
"selected": false,
"text": "CREATE TABLE [stackoverflow-285666] (k int, val varchar(255))\n\nINSERT INTO [stackoverflow-285666]\nVALUES (1, '1-1')\nINSERT INTO [stackoverflow-285666]\nVALUES (1, '1-2')\nINSERT INTO [stackoverflow-285666]\nVALUES (1, '1-3')\nINSERT INTO [stackoverflow-285666]\nVALUES (2, '2-1')\nINSERT INTO [stackoverflow-285666]\nVALUES (2, '2-2')\n\nDECLARE @k AS int\nSET @k = 0\n\nWHILE @k < 3\n BEGIN\n SELECT @k AS k\n ,COALESCE(ActualValue, DefaultValue) AS [Value]\n FROM (\n SELECT 'DefaultValue' AS DefaultValue\n ) AS Defaults\n LEFT JOIN (\n SELECT val AS ActualValue\n FROM [stackoverflow-285666]\n WHERE k = @k\n ) AS [Values]\n ON 1 = 1\n\n SET @k = @k + 1\n END\n\nDROP TABLE [stackoverflow-285666]\n k Value\n----------- ------------\n0 DefaultValue\n\nk Value\n----------- ------------\n1 1-1\n1 1-2\n1 1-3\n\nk Value\n----------- ------------\n2 2-1\n2 2-2\n"
},
{
"answer_id": 288185,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 4,
"selected": false,
"text": "select NVL( MIN(rate), 0 ) AS rate \nfrom d_payment_index\nwhere fy = 2007\n and payment_year = 2008\n and program_id = 18\n"
},
{
"answer_id": 534178,
"author": "beach",
"author_id": 53892,
"author_profile": "https://Stackoverflow.com/users/53892",
"pm_score": 3,
"selected": false,
"text": "SELECT DEF.Rate, ACTUAL.Rate, COALESCE(ACTUAL.Rate, DEF.Rate) AS UseThisRate\nFROM \n (SELECT 0) DEF (Rate) -- This is your default rate\nLEFT JOIN (\n select rate \n from d_payment_index\n --WHERE 1=2 -- Uncomment this line to simulate a missing value\n\n --...HERE IF YOUR ACTUAL WHERE CLAUSE. Removed for testing purposes...\n --where fy = 2007\n -- and payment_year = 2008\n -- and program_id = 18\n) ACTUAL (Rate) ON 1=1\n Rate Rate UseThisRate\n----------- ----------- -----------\n0 1 1\n Rate Rate UseThisRate\n----------- ----------- -----------\n0 NULL 0\n CREATE TABLE d_payment_index (rate int NOT NULL)\nINSERT INTO d_payment_index VALUES (1)\n"
},
{
"answer_id": 37454970,
"author": "Y-Mi Wong",
"author_id": 6384946,
"author_profile": "https://Stackoverflow.com/users/6384946",
"pm_score": 0,
"selected": false,
"text": " ---=== The table & its data\n CREATE TABLE dbo.Rates (\n PkId int,\n name varchar(10),\n rate decimal(10,2)\n )\n INSERT INTO dbo.Rates(PkId, name, rate) VALUES (1, 'Schedule 1', 0.1)\n INSERT INTO dbo.Rates(PkId, name, rate) VALUES (2, 'Schedule 2', 0.2)\n ---=== The solution \nCREATE PROCEDURE dbo.GetRate \n @PkId int\nAS\nBEGIN\n DECLARE @tempTable TABLE (\n PkId int, \n name varchar(10), \n rate decimal(10,2)\n )\n\n --- [1] Insert default values into @tempTable. PkId=0 is dummy value \n INSERT INTO @tempTable(PkId, name, rate) VALUES (0, 'DEFAULT', 0.00)\n\n --- [2] Update the single row in @tempTable with the actual value.\n --- This only happens if a match is found\n UPDATE @tempTable\n SET t.PkId=x.PkId, t.name=x.name, t.rate = x.rate\n FROM @tempTable t INNER JOIN dbo.Rates x\n ON t.PkId = 0\n WHERE x.PkId = @PkId\n\n SELECT * FROM @tempTable\nEND\n EXEC dbo.GetRate @PkId=1 --- returns values for PkId=1\nEXEC dbo.GetRate @PkId=12314 --- returns default values\n"
},
{
"answer_id": 51160249,
"author": "Eike",
"author_id": 388845,
"author_profile": "https://Stackoverflow.com/users/388845",
"pm_score": 3,
"selected": false,
"text": "WITH products AS (\n SELECT prod_name,\n price\n FROM Products_Table\n WHERE prod_name LIKE '%foo%'\n ),\n defaults AS (\n SELECT '-' AS prod_name,\n 0 AS price\n )\n\nSELECT * FROM products\nUNION ALL\nSELECT * FROM defaults\n WHERE NOT EXISTS ( SELECT * FROM products );\n"
},
{
"answer_id": 62469335,
"author": "Deepak Vaishnav",
"author_id": 6854712,
"author_profile": "https://Stackoverflow.com/users/6854712",
"pm_score": 2,
"selected": false,
"text": "SELECT * FROM review WHERE id = 1555\nUNION ALL\nSELECT * FROM review WHERE NOT EXISTS ( SELECT * FROM review where id = 1555 ) AND id = 1\n"
},
{
"answer_id": 63174302,
"author": "Serge Bugera",
"author_id": 3289809,
"author_profile": "https://Stackoverflow.com/users/3289809",
"pm_score": 2,
"selected": false,
"text": "config config_code CONFIG_CODE PARAM1 PARAM2\n--------------- -------- --------\ndefault_config def 000\nconfig1 abc 123\nconfig2 def 456\n config1 SELECT *\n FROM (SELECT *\n FROM config\n WHERE config_code = 'config1'\n OR config_code = 'default_config'\n ORDER BY CASE config_code WHEN 'default_config' THEN 999 ELSE 1 END)\n WHERE rownum = 1;\n CONFIG_CODE PARAM1 PARAM2\n--------------- -------- --------\nconfig1 abc 123\n config3 SELECT *\n FROM (SELECT *\n FROM config\n WHERE config_code = 'config3'\n OR config_code = 'default_config'\n ORDER BY CASE config_code WHEN 'default_config' THEN 999 ELSE 1 END)\n WHERE rownum = 1;\n CONFIG_CODE PARAM1 PARAM2\n--------------- -------- --------\ndefault_config def 000\n config"
},
{
"answer_id": 68619854,
"author": "Shanmukhi Goli",
"author_id": 9479518,
"author_profile": "https://Stackoverflow.com/users/9479518",
"pm_score": 0,
"selected": false,
"text": "\n SELECT IF (\n (SELECT COUNT(*) FROM tbs.replication_status) > 0, \n (SELECT rs.last_replication_end_date FROM tbs.replication_status AS rs \n WHERE rs.last_replication_start_date IS NOT NULL \n AND rs.last_replication_end_date IS NOT NULL \n AND rs.table = '%s' ORDER BY id DESC LIMIT 1), \n (SELECT CAST(UNIX_TIMESTAMP (CURRENT_TIMESTAMP(6)) AS UNSIGNED))\n ) AS ts;\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26121/"
] |
285,680
|
<p>I understand that BigDecimal is recommended best practice for representing monetary values in Java. What do you use? Is there a better library that you prefer to use instead?</p>
|
[
{
"answer_id": 285707,
"author": "ninesided",
"author_id": 1030,
"author_profile": "https://Stackoverflow.com/users/1030",
"pm_score": 7,
"selected": true,
"text": "BigDecimal Cash Money BigDecimal BigDecimal.ROUND_HALF_EVEN BigDecimal"
},
{
"answer_id": 285709,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 2,
"selected": false,
"text": "BigDecimal Double Float"
},
{
"answer_id": 1137523,
"author": "Per Arneng",
"author_id": 85148,
"author_profile": "https://Stackoverflow.com/users/85148",
"pm_score": 0,
"selected": false,
"text": " assertEquals(Money.create(\"100.0 USD\").add(\"10 GBP\"),Money.create(\"116 USD\"));\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32595/"
] |
285,685
|
<p>Here is a nice underhand lob pitch to you guys.</p>
<p>So basically I've got my content table with unique primary key IDs and I've got my tag table with unique primary key IDs. </p>
<p>I've got a table that has an identity column as a primary key but the two other columes are the contentID and tagID. What do I need to do to the table to make sure that I only have the same contentID and tagID combo only once.</p>
|
[
{
"answer_id": 285697,
"author": "John Lemp",
"author_id": 12915,
"author_profile": "https://Stackoverflow.com/users/12915",
"pm_score": 2,
"selected": false,
"text": "ALTER TABLE ContentTag ADD CONSTRAINT\n IX_ContentID_TagID_Unique UNIQUE NONCLUSTERED ( contentID, tagID ) \nGO\n"
},
{
"answer_id": 285734,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 2,
"selected": true,
"text": "contentID tagID id UNIQUE contentID tagID"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37154/"
] |
285,687
|
<p>I would like to edit XHTML files using Emacs' <a href="http://www.emacswiki.org/emacs/NxmlMode" rel="nofollow noreferrer">nxml-mode</a> which can use <a href="http://infohost.nmt.edu/tcc/help/pubs/rnc/" rel="nofollow noreferrer">rnc</a> schemas for on the fly validation. This is all built in to newer Emacs versions.</p>
<p>However, my XHTML files contain elements from another schema. So <foo:foo> tags are valid, but only within the <xhtml:head> of the document.</p>
<p>Currently, nxml complains because the XHTML schema it is using does not describe the foo tag. How do I create a new schema which describes the foo tag in relation to the existing XHTML schema, and how do I apply that schema automatically using <a href="http://www.dpawson.co.uk/relaxng/nxml/schemaloc.html" rel="nofollow noreferrer">schema locating rules</a> in the schemas.xml file?</p>
<p>ie: I would like to validate a document using two schemas simultaneously: the built-in XHTML rules, and some custom rules which add certain namespaced tags.</p>
|
[
{
"answer_id": 285697,
"author": "John Lemp",
"author_id": 12915,
"author_profile": "https://Stackoverflow.com/users/12915",
"pm_score": 2,
"selected": false,
"text": "ALTER TABLE ContentTag ADD CONSTRAINT\n IX_ContentID_TagID_Unique UNIQUE NONCLUSTERED ( contentID, tagID ) \nGO\n"
},
{
"answer_id": 285734,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 2,
"selected": true,
"text": "contentID tagID id UNIQUE contentID tagID"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,700
|
<p>i'm looking for a way to programatically convert word documents in docx format to doc format without using ole automation. i already have a windows service that does this but it means installing office on a server and it is a little unreliable and not supported. i am aware of the aspose.words product, and i will try it out, but has anyone any recommendations for how to do this as simply, reliably, and cheaply as possible?</p>
|
[
{
"answer_id": 320854,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 4,
"selected": false,
"text": "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Shared Tools\\Text Converters\\Import\\Word12 \n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3142/"
] |
285,710
|
<p>Some of the platforms that I develop on, don't have profiling tools. I am looking for suggestions/techniques that you have personally used to help you identify hotspots, without the use of a profiler.</p>
<p>The target language is C++.</p>
<p>I am interested in what you have personally used.</p>
|
[
{
"answer_id": 285926,
"author": "Andreas Magnusson",
"author_id": 5811,
"author_profile": "https://Stackoverflow.com/users/5811",
"pm_score": 4,
"selected": true,
"text": "#ifdef PROFILING\n# define PROFILE_CALL(x) do{ \\\n const DWORD t1 = timeGetTime(); \\\n x; \\\n const DWORD t2 = timeGetTime(); \\\n std::cout << \"Call to '\" << #x << \"' took \" << (t2 - t1) << \" ms.\\n\"; \\\n }while(false)\n#else\n# define PROFILE_CALL(x) x\n#endif\n PROFILE_CALL(renderSlow(world));\nint r = 0;\nPROFILE_CALL(r = readPacketSize());\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7734/"
] |
285,712
|
<p>I have a file (called "number.txt") which I want to read to an array in Java. How exactly do I go ahead and do this? It is a straight-forward "1-dimensional" file, containing 100 numbers.</p>
<p>The problem is that I get an exception every time. Apparently it can't find it (I am sure its spelled correctly). When looking through code examples, it doesn't specify the file's entire file path, only the name of the file itself. How would I go about doing that if its necessary?</p>
<p>Also, when reading the file, will the array automatically contain all the lines of the file, or will I have to make a loop which which copies every line to corresponding subscript i?</p>
<p>I've heard of BufferedReader class, what it's purpose, and how does it corelate to reading input?</p>
|
[
{
"answer_id": 285745,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 6,
"selected": false,
"text": "package com.acme;\n\nimport java.io.BufferedReader;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class FileArrayProvider {\n\n public String[] readLines(String filename) throws IOException {\n FileReader fileReader = new FileReader(filename);\n BufferedReader bufferedReader = new BufferedReader(fileReader);\n List<String> lines = new ArrayList<String>();\n String line = null;\n while ((line = bufferedReader.readLine()) != null) {\n lines.add(line);\n }\n bufferedReader.close();\n return lines.toArray(new String[lines.size()]);\n }\n}\n package com.acme;\n\nimport java.io.IOException;\n\nimport org.junit.Test;\n\npublic class FileArrayProviderTest {\n\n @Test\n public void testFileArrayProvider() throws IOException {\n FileArrayProvider fap = new FileArrayProvider();\n String[] lines = fap\n .readLines(\"src/main/java/com/acme/FileArrayProvider.java\");\n for (String line : lines) {\n System.out.println(line);\n }\n }\n}\n"
},
{
"answer_id": 12592835,
"author": "Hélio Santos",
"author_id": 1698797,
"author_profile": "https://Stackoverflow.com/users/1698797",
"pm_score": 5,
"selected": false,
"text": "import java.io.File;\n\nimport java.nio.charset.Charset;\nimport java.nio.file.Files;\nimport java.nio.file.Path;\n\nimport java.util.List;\n\n// ...\n\nPath filePath = new File(\"fileName\").toPath();\nCharset charset = Charset.defaultCharset(); \nList<String> stringList = Files.readAllLines(filePath, charset);\nString[] stringArray = stringList.toArray(new String[]{});\n"
},
{
"answer_id": 69270638,
"author": "Stephen C",
"author_id": 139985,
"author_profile": "https://Stackoverflow.com/users/139985",
"pm_score": 0,
"selected": false,
"text": "String[] BufferedReader.lines() BufferedReader br ...\nString[] lines = br.lines().toArray(String[]::new);\n lines() String BufferedReader"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37161/"
] |
285,715
|
<h2>Background</h2>
<p>We are developing some in-house utilities using ASP.NET 2.0. One of which is extracting some information from databases and building an Excel workbook containing a number of spreadsheets with data based on queries into the database.</p>
<h2>Problem</h2>
<p>The proof-of-concept prototype (a simple ASP.NET page that queries a single item from the database and opens Excel to add data to a worksheet) is working well when run locally on the development machines, happily creating and displaying an Excel spreadsheet as requested. However, when run on our server, we get the following error upon trying to instantiate Excel .</p>
<p>Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).</p>
<h2>Solution?</h2>
<p>We are using the PIA for Excel 2003 and we have Excel 2003 and the PIA installed on the server. Can anyone explain why this isn't working or give us some tips on how we might track the problem down?</p>
<p>Thanks for any assistance you can provide.</p>
|
[
{
"answer_id": 285745,
"author": "toolkit",
"author_id": 3295,
"author_profile": "https://Stackoverflow.com/users/3295",
"pm_score": 6,
"selected": false,
"text": "package com.acme;\n\nimport java.io.BufferedReader;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class FileArrayProvider {\n\n public String[] readLines(String filename) throws IOException {\n FileReader fileReader = new FileReader(filename);\n BufferedReader bufferedReader = new BufferedReader(fileReader);\n List<String> lines = new ArrayList<String>();\n String line = null;\n while ((line = bufferedReader.readLine()) != null) {\n lines.add(line);\n }\n bufferedReader.close();\n return lines.toArray(new String[lines.size()]);\n }\n}\n package com.acme;\n\nimport java.io.IOException;\n\nimport org.junit.Test;\n\npublic class FileArrayProviderTest {\n\n @Test\n public void testFileArrayProvider() throws IOException {\n FileArrayProvider fap = new FileArrayProvider();\n String[] lines = fap\n .readLines(\"src/main/java/com/acme/FileArrayProvider.java\");\n for (String line : lines) {\n System.out.println(line);\n }\n }\n}\n"
},
{
"answer_id": 12592835,
"author": "Hélio Santos",
"author_id": 1698797,
"author_profile": "https://Stackoverflow.com/users/1698797",
"pm_score": 5,
"selected": false,
"text": "import java.io.File;\n\nimport java.nio.charset.Charset;\nimport java.nio.file.Files;\nimport java.nio.file.Path;\n\nimport java.util.List;\n\n// ...\n\nPath filePath = new File(\"fileName\").toPath();\nCharset charset = Charset.defaultCharset(); \nList<String> stringList = Files.readAllLines(filePath, charset);\nString[] stringArray = stringList.toArray(new String[]{});\n"
},
{
"answer_id": 69270638,
"author": "Stephen C",
"author_id": 139985,
"author_profile": "https://Stackoverflow.com/users/139985",
"pm_score": 0,
"selected": false,
"text": "String[] BufferedReader.lines() BufferedReader br ...\nString[] lines = br.lines().toArray(String[]::new);\n lines() String BufferedReader"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23234/"
] |
285,716
|
<p>I have written a program that gets input from a usb second keyboard (actually a barcode scanner). The problem is that if another window is active the data is input there rather than in my program. Could someone give me advice on what I'm doing wrong?</p>
<pre><code>#include <stdio.h>
#include <string.h>
int main(int argc, char * argv[]){
FILE * fp_in;
char * data;
fp_in = fopen("/dev/input/by-id/usb-04d9_1400-event-kbd","r");
if(fp_in == NULL){
fprintf(stderr,"Failed to open input by id\n");
}
fp_in = fopen("/dev/input/by-path/pci-0000:00:1d.1-usb-0:2:1.0-event-kbd","r");
if(fp_in == NULL){
fprintf(stderr,"Failed to open input by path\n");
return 1;
}
while(1){
fscanf(fp_in,data,"%s");
fprintf(stderr,"%s",data);
}
return 0;
}
</code></pre>
<p>thanks
<hr>
If I may be so bold as to rephrase the question on Confuzzled's behalf:</p>
<p>How can I write a program under Linux that attaches itself to an input device, in this case a barcode scanner, so that the input does not go to the program that has the keyboard focus?</p>
|
[
{
"answer_id": 21819422,
"author": "admiralswan",
"author_id": 3317403,
"author_profile": "https://Stackoverflow.com/users/3317403",
"pm_score": 2,
"selected": false,
"text": "xinput list HID Keyboard Device HID Keyboard Device id=13 [slave keyboard (3)] xinput float 13 SUBSYSTEM==\"input\", ATTRS{idVendor}==\"1d57\", ATTRS{idProduct}==\"001c\" MODE=\"0644\" dmesg"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37163/"
] |
285,717
|
<p>What's the best way to run scheduled tasks in a Rails environment? Script/runner? Rake? I would like to run the task every few minutes.</p>
|
[
{
"answer_id": 287107,
"author": "webmat",
"author_id": 6349,
"author_profile": "https://Stackoverflow.com/users/6349",
"pm_score": 4,
"selected": false,
"text": "# from ~\n/path/to/ruby /path/to/app/script/runner -e development \"MyClass.class_method\"\n/path/to/ruby /path/to/rake -f /path/to/app/Rakefile rake:task RAILS_ENV=development\n"
},
{
"answer_id": 290935,
"author": "Luke Francl",
"author_id": 17965,
"author_profile": "https://Stackoverflow.com/users/17965",
"pm_score": 3,
"selected": false,
"text": "0 6 * * * cd /var/www/apps/your_app/current; ./script/runner --environment production 'EmailSubscription.send_email_subscriptions' >> /var/www/apps/your_app/shared/log/send_email_subscriptions.log 2>&1"
},
{
"answer_id": 480255,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "crontab -l # command to print all cron tasks\ncrontab -e # command to edit/add cron tasks\n\n# Contents of crontab\n0 1 * * * cd /home/lenart/izziv. whiskas.si/current; /bin/sh cron_tasks >> log/cron_log 2>&1\n0 0 1 * * cd /home/lenart/izziv.whiskas.si/current; /usr/bin/env /usr/local/bin/ruby script/runner -e production lib/monthly_cron.rb >> log/cron_log 2>&1\n /usr/local/bin/rake db:backup RAILS_ENV=production; date; echo \"END OF OUTPUT ----\";\n #!/usr/local/bin/ruby\n# Expire challenge cache\nChallenge.force_expire_cache\nputs \"Expired cache for Challenges (Challenge.force_expire_cache) #{Time.now}\"\n whereis ruby # -> ruby: /usr/local/bin/ruby\nwhereis rake # -> rake: /usr/local/bin/rake\n"
},
{
"answer_id": 995643,
"author": "tardate",
"author_id": 6329,
"author_profile": "https://Stackoverflow.com/users/6329",
"pm_score": 8,
"selected": true,
"text": "task :cron => :environment do\n puts \"Pulling new requests...\"\n EdiListener.process_new_messages\n puts \"done.\"\nend\n"
},
{
"answer_id": 6377867,
"author": "Jim Garvin",
"author_id": 66145,
"author_profile": "https://Stackoverflow.com/users/66145",
"pm_score": 8,
"selected": false,
"text": "every 3.hours do\n runner \"MyModel.some_process\" \n rake \"my:rake:task\" \n command \"/usr/bin/my_great_command\"\nend\n\nevery 1.day, :at => '4:30 am' do \n runner \"MyModel.task_to_run_at_four_thirty_in_the_morning\"\nend\n"
},
{
"answer_id": 18159262,
"author": "Pankhuri",
"author_id": 2669893,
"author_profile": "https://Stackoverflow.com/users/2669893",
"pm_score": 5,
"selected": false,
"text": " require 'rufus-scheduler'\n\n scheduler = Rufus::Scheduler.new\n\n scheduler.in '10d' do\n # do something in 10 days\n end\n\n scheduler.at '2030/12/12 23:30:00' do\n # do something at a given point in time\n end\n\n scheduler.every '3h' do\n # do something every 3 hours\n end\n\n scheduler.cron '5 0 * * *' do\n # do something every day, five minutes after midnight\n # (see \"man 5 crontab\" in your terminal)\n end\n"
},
{
"answer_id": 24544045,
"author": "nnattawat",
"author_id": 3749163,
"author_profile": "https://Stackoverflow.com/users/3749163",
"pm_score": 2,
"selected": false,
"text": "clockworkd"
},
{
"answer_id": 25512430,
"author": "Israel Barba",
"author_id": 1904975,
"author_profile": "https://Stackoverflow.com/users/1904975",
"pm_score": 2,
"selected": false,
"text": "resque resque-schedular"
},
{
"answer_id": 33107035,
"author": "Alexander Paramonov",
"author_id": 598386,
"author_profile": "https://Stackoverflow.com/users/598386",
"pm_score": 4,
"selected": false,
"text": "class MyWorker\n include Sidekiq::Worker\n include Sidetiq::Schedulable\n\n recurrence { hourly.minute_of_hour(15, 45) }\n\n def perform\n # do stuff ...\n end\nend\n"
},
{
"answer_id": 33540967,
"author": "Vipul Lawande",
"author_id": 4486025,
"author_profile": "https://Stackoverflow.com/users/4486025",
"pm_score": 2,
"selected": false,
"text": "require 'clockwork'\n\nmodule Clockwork\n every(10.seconds, 'frequent.job')\nend\n"
},
{
"answer_id": 46341534,
"author": "Ami",
"author_id": 5681693,
"author_profile": "https://Stackoverflow.com/users/5681693",
"pm_score": 1,
"selected": false,
"text": "::CRON FORMAT::\n Examples Of crontab Entries\n15 6 2 1 * /home/melissa/backup.sh\nRun the shell script /home/melissa/backup.sh on January 2 at 6:15 A.M.\n\n15 06 02 Jan * /home/melissa/backup.sh\nSame as the above entry. Zeroes can be added at the beginning of a number for legibility, without changing their value.\n\n0 9-18 * * * /home/carl/hourly-archive.sh\nRun /home/carl/hourly-archive.sh every hour, on the hour, from 9 A.M. through 6 P.M., every day.\n\n0 9,18 * * Mon /home/wendy/script.sh\nRun /home/wendy/script.sh every Monday, at 9 A.M. and 6 P.M.\n\n30 22 * * Mon,Tue,Wed,Thu,Fri /usr/local/bin/backup\nRun /usr/local/bin/backup at 10:30 P.M., every weekday. \n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13195/"
] |
285,718
|
<p>I'm using MediaTemple's (dv) hosting service. How do I determine what mail-server is installed? Should I use the shell? If so, what command would be used?</p>
|
[
{
"answer_id": 285739,
"author": "Adam Pierce",
"author_id": 5324,
"author_profile": "https://Stackoverflow.com/users/5324",
"pm_score": 4,
"selected": false,
"text": "telnet <hostname> 25\n 220 example.com ESMTP Exim 4.69 Thu, 13 Nov 2008 10:06:01 +1100\n dig -t MX example.com\n"
},
{
"answer_id": 285918,
"author": "Federico A. Ramponi",
"author_id": 18770,
"author_profile": "https://Stackoverflow.com/users/18770",
"pm_score": 3,
"selected": false,
"text": "$ nmap -p 25 -A -T polite <hostname>\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
285,723
|
<p>I'm a .NET developer, and worked with VB6 before that. I've become very familiar with those environments, and working in the context of garbage collected languages. However, I now wish to bolster my skillset with native C++ and find myself a bit overwhelmed. Ironically, it's not what I'd imagine is the usual stumbling blocks for beginners as I feel that I've got the grasp of pointers and memory management fairly well. The thing that's a bit confusing for me is more along the lines of:</p>
<ul>
<li>Referencing/using other libraries</li>
<li>Exposing <em>my</em> libraries for others to use</li>
<li>String handling</li>
<li>Data type conversions</li>
<li>Good project structure</li>
<li>Data structures to use (ie. in C#, I use <code>List<T></code> a lot, what do I use in C++ that works simiarly?)</li>
</ul>
<p>It almost feels like depending on the IDE you use, the guidelines are different, so I was really looking for something that's perhaps a bit more universal. Or at worst, focused on using Microsoft's compiler/IDE. Also, just to be clear, I'm not looking for anything about general programming practices (Design Patterns, Code Complete, etc.) as I feel I'm pretty well versed in those topics.</p>
|
[
{
"answer_id": 285819,
"author": "jalf",
"author_id": 33213,
"author_profile": "https://Stackoverflow.com/users/33213",
"pm_score": 9,
"selected": true,
"text": "List<T> std::vector<T> void foo() {\n\n // declare a vector *without* using new. We want it allocated on the stack, not\n // the heap. The vector can allocate data on the heap if and when it feels like\n // it internally. We just don't need to see it in our user code\n std::vector<int> v;\n v.push_back(4);\n v.push_back(42); // Add a few numbers to it\n\n // And that is all. When we leave the scope of this function, the destructors \n // of all local variables, in this case our vector, are called - regardless of\n // *how* we leave the function. Even if an exception is thrown, v still goes \n // out of scope, so its destructor is called, and it cleans up nicely. That's \n // also why C++ doesn't have a finally clause for exception handling, but only \n // try/catch. Anything that would otherwise go in the finally clause can be put\n // in the destructor of a local object.\n} \n std::string std::string s = \"hello world\";\n int i = (int)42.0f; \n // The most common cast, when the types are known at compile-time. That is, if \n// inheritance isn't involved, this is generally the one to use\nstatic_cast<U>(T); \n\n// The equivalent for polymorphic types. Does the same as above, but performs a \n// runtime typecheck to ensure that the cast is actually valid\ndynamic_cast<U>(T); \n\n// Is mainly used for converting pointer types. Basically, it says \"don't perform\n// an actual conversion of the data (like from 42.0f to 42), but simply take the\n// same bit pattern and reinterpret it as if it had been something else). It is\n// usually not portable, and in fact, guarantees less than I just said.\nreinterpret_cast<U>(T); \n\n// For adding or removing const-ness. You can't call a non-const member function\n// of a const object, but with a const-cast you can remove the const-ness from \n// the object. Generally a bad idea, but can be necessary.\nconst_cast<U>(T);\n int add1(int i) { return i+1; } // The function we wish to apply\n\nvoid foo() {\n std::vector<int> v;\n v.push_back(1);\n v.push_back(2);\n v.push_back(3);\n v.push_back(4);\n v.push_back(5); // Add the numbers 1-5 to the vector\n\n std::list<int> l;\n\n // Transform is an algorithm which applies some transformation to every element\n // in an iterator range, and stores the output to a separate iterator\n std::transform ( \n v.begin(),\n v.end(), // Get an iterator range spanning the entire vector\n // Create a special iterator which, when you move it forward, adds a new \n // element to the container it points to. The output will be assigned to this\n std::back_inserter(l) \n add1); // And finally, the function we wish to apply to each element\n}\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5416/"
] |
285,730
|
<p>I'm attempting to bind a <code>DependancyProperty</code> in one of my usercontrols to the <code>Width</code> property of a <code>Column</code> in a <code>Grid</code>. </p>
<p>I have code similar to this:</p>
<pre><code><Grid x:Name="MyGridName">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="TitleSection" Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>...</Grid.RowDefinitions>
<GridSplitter x:Name="MyGridSplitter" Grid.Row="0" Grid.Column="0" ... />
</Grid>
</code></pre>
<p>In a separate Usercontrol I have the following<code>DependancyProperty</code> defined.</p>
<pre><code>public static readonly DependencyProperty TitleWidthProperty = DependencyProperty.Register("TitleWidth", typeof(int), typeof(MyUserControl));
public int TitleWidth
{
get { return (int)base.GetValue(TitleWidthProperty); }
set { base.SetValue(TitleWidthProperty, value); }
}
</code></pre>
<p>I am creating instances of the Usercontrol in code, hence I have a binding statement similar to this :</p>
<pre><code>MyUserControl Cntrl = new MyUserControl(/* Construction Params */);
BindingOperations.SetBinding(Cntrl , MyUserControl.AnotherProperty, new Binding { ElementName = "objZoomSlider", Path = new PropertyPath("Value"), Mode = BindingMode.OneWay });
BindingOperations.SetBinding(Cntrl , MyUserControl.TitleWidthProperty, new Binding { ElementName = "TitleSection", Path = new PropertyPath("ActualWidth"), Mode = BindingMode.OneWay });
/* Other operations on Cntrl */
</code></pre>
<p>The first binding defined works fantastically, although that is binding to an actual UIElement (in this case a Slider), but the Binding to "TitleSection" (which is the ColumnDefinition defined in the Grid) fails. Putting a breakpoint in the code and doing a watch on "TitleSection" returns the expected object. </p>
<p>I am beginning to suspect that a x:Name'd ColumnDefinition can't be bound to. <strong>Can anyone suggest how I might be able to bind to the changing width of the first column in my grid?</strong></p>
<p><strong>EDIT #1 - To answer comments</strong></p>
<p>The databinding 'fails' in the sense that with a breakpoint set on the setter for the <code>TitleWidth</code> property, and using the GridSplitter control to resize the first column, the breakpoint is never hit. Additionally, code I would expect to be fired when the DependancyProperty <code>TitleWidth</code> changes does not get executed.</p>
<p>The usercontrol is being created and added to a Stackpanel within the Grid in the <code>Window_Loaded</code> function. I would expect that the Grid has been rendered by the time the Usercontrols are being constructed. Certainly the x:Name'd Element <code>TitleSection</code> is watchable and has a value of <code>100</code> when they are being constructed / before the binding is happening.</p>
<p><strong>EDIT #2 - Possibly something to do with this?</strong></p>
<p>I've been having a sniff round the MSDN pages for the Grid ColumnDefinition documentation and have come across <a href="http://msdn.microsoft.com/en-us/library/system.windows.gridlength.aspx" rel="nofollow noreferrer">GridLength()</a> but I can't get my head around how I can use this in a binding expression. I cannot use the associated GridLengthConverter as a converter in the binding code as it does not derive from IValueConverter. </p>
<p>I am leaning towards somehow binding to the ActualWidth property of one of the cells in the Grid object. It doesn't seem as clean as binding to the column definition, but at the moment I cannot get that to work.</p>
|
[
{
"answer_id": 286695,
"author": "Ian Oakes",
"author_id": 21606,
"author_profile": "https://Stackoverflow.com/users/21606",
"pm_score": 2,
"selected": false,
"text": "<ColumnDefinition \n x:Name=\"TitleSection\" \n Width=\"{Binding \n Path=TitleWidth, \n RelativeSource={RelativeSource AncestorType=MyUserControl}}\" \n />\n BindingOperations.SetBinding(TitleSection, ColumnDefinition.WidthProperty,\n new Binding()\n {\n RelativeSource= new RelativeSource(RelativeSourceMode.FindAncestor, typeof(MyUserControl),1),\n Path = new PropertyPath(\"TitleWidth\"),\n });\n"
},
{
"answer_id": 286737,
"author": "Ash",
"author_id": 31128,
"author_profile": "https://Stackoverflow.com/users/31128",
"pm_score": 5,
"selected": true,
"text": "<Label> ActualWidth ActualWidth PropertyChanged"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31128/"
] |
285,731
|
<p>I have two C DLLs that I need to access in the same executable. I have header files and .LIB files for both libraries. Unfortunately a subset of the functions that I need to access have the exact same names. The best solution I have been able to come up with so far is to use LoadLibrary to load one of the DLLs and explicitly call its methods using GetProcAddress. Is there a way for me to implicitly load both libraries and somehow give the compiler a hint that in one case I want to call OpenApi in DLL A and in the other case I want to call OpenApi in DLL B?</p>
<p>I'm developing my executable in C++ using Visual Studio 2008 and the corresponding C runtime library (msvcr90.dll).</p>
<p>[Edit]</p>
<p>Commenter Ilya asks below what I don't like about the GetProcAddress solution. I don't like it for two reasons:</p>
<ol>
<li>It makes the code more complex. One line of code to call a function is replaced with three lines of code, one to define the function signature, one to call GetProcAddress, and one to actually call the function. </li>
<li>It's more prone to run-time errors. If I misspell the function name or mess up the signature I don't see the error until run-time. Say I decide to integrate a new version of the dll and one of the method names has changed, it will compile just fine and won't have a problem until the actual call to GetProcAddress, which could possibly even be missed in a test pass.</li>
</ol>
|
[
{
"answer_id": 285758,
"author": "Michael Burr",
"author_id": 12711,
"author_profile": "https://Stackoverflow.com/users/12711",
"pm_score": 3,
"selected": true,
"text": "LoadLibrary()/GetProcAddress()"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37155/"
] |
285,733
|
<p>I've tried the following, but I was unsuccessful:</p>
<pre><code>ALTER TABLE person ALTER COLUMN dob POSITION 37;
</code></pre>
|
[
{
"answer_id": 285740,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 8,
"selected": true,
"text": "attnum pg_attribute VIEW"
},
{
"answer_id": 27886259,
"author": "marcopolo",
"author_id": 4442083,
"author_profile": "https://Stackoverflow.com/users/4442083",
"pm_score": 3,
"selected": false,
"text": "INSERT INSERT INTO new ( c2, c3, c1 ) SELECT * from old;\n c2 c3 c1 c1 c2 c3 INSERT DROP ALTER TABLE new RENAME TO old;"
},
{
"answer_id": 34411880,
"author": "Ville",
"author_id": 134536,
"author_profile": "https://Stackoverflow.com/users/134536",
"pm_score": 5,
"selected": false,
"text": "pg_dump -s databasename > databasename_schema.sql"
},
{
"answer_id": 39781155,
"author": "Allwin",
"author_id": 2000649,
"author_profile": "https://Stackoverflow.com/users/2000649",
"pm_score": 7,
"selected": false,
"text": " alter table tablename rename to oldtable;\n create table tablename (column defs go here); ### with all the constraints\n insert into tablename (col1, col2, col3) select col1, col2, col3 from oldtable;\n"
},
{
"answer_id": 57519646,
"author": "Orlov Const",
"author_id": 9506423,
"author_profile": "https://Stackoverflow.com/users/9506423",
"pm_score": 1,
"selected": false,
"text": "CREATE VIEW bp.geo_location_vague_vw AS\n SELECT \n a.id, -- I change order of id column here. \n a.in_date,\n etc\n FROM bp.geo_location_vague a\n SELECT * into bp.geo_location_vague_cp2 FROM bp.geo_location_vague_vw\n CREATE SEQUENCE bp.tbl_tbl_id_seq;\nALTER TABLE bp.geo_location_vague_cp2 ALTER COLUMN id SET DEFAULT nextval('tbl_tbl_id_seq');\nALTER SEQUENCE bp.tbl_tbl_id_seq OWNED BY bp.geo_location_vague_cp2.id;\nSELECT setval('tbl_tbl_id_seq', COALESCE(max(id), 0)) FROM bp.geo_location_vague_cp2;\n"
},
{
"answer_id": 61924470,
"author": "GammaGames",
"author_id": 3903479,
"author_profile": "https://Stackoverflow.com/users/3903479",
"pm_score": 2,
"selected": false,
"text": "pg_dump pg_dump ./reorder.py -n schema -d database table \\\n first_col second_col ... penultimate_col ultimate_col --migrate\n pg_dump"
},
{
"answer_id": 74453351,
"author": "Ondrej Valenta",
"author_id": 5556714,
"author_profile": "https://Stackoverflow.com/users/5556714",
"pm_score": 0,
"selected": false,
"text": "select *\nfrom information_schema.columns\nwhere table_name = 'table1';\n\nupdate pg_catalog.pg_attribute\nset attnum = 10 where attname = 'column_on_9_position_to_move_to_7';\n\nupdate pg_catalog.pg_attribute\nset attnum = 9 where attname = 'column_on_7_position_to_move_to_9';\n\nupdate pg_catalog.pg_attribute\nset attnum = 7 where attname = 'column_on_9_position_to_move_to_7';\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10040/"
] |
285,754
|
<p>So, let's say I want to write a class that operates on different kinds of numbers, but I don't a priori know what kind of numbers (i.e. ints, doubles, etc.) I will be operating on.</p>
<p>I would like to use generics to create a general class for this scenario. Something like:</p>
<pre><code> Adder<Double> adder = new Adder<Double>();
adder.add(10.0d, 10.0d); // = 20.0d
</code></pre>
<p>But, I cannot instantiate the generic type I pass in to my Adder class! So -- what to do?</p>
|
[
{
"answer_id": 285773,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 4,
"selected": true,
"text": "Double double add(double, double) float add(float, fload) BigDecimal add(BigDecimal, BigDecimal)"
},
{
"answer_id": 285812,
"author": "Paul Brinkley",
"author_id": 18160,
"author_profile": "https://Stackoverflow.com/users/18160",
"pm_score": 2,
"selected": false,
"text": "public class Foob<T extends Number> {\n\n public T doSomething(T t1, T t2) {\n return null;\n }\n}\n"
},
{
"answer_id": 285919,
"author": "Laplie Anderson",
"author_id": 14204,
"author_profile": "https://Stackoverflow.com/users/14204",
"pm_score": 0,
"selected": false,
"text": "interface Adder<T> {\n T add(T arg1, arg3);\n}\n class DoubleAdder implements Adder<Double> {\n Double add(Double arg1, Double arg2) {\n return arg1.add(arg2);\n }\n}\n if (arg1 instanceof Double) {\n Adder<Double> adder = new DoubleAdder();\n}\n"
},
{
"answer_id": 1261665,
"author": "Graphics Noob",
"author_id": 127669,
"author_profile": "https://Stackoverflow.com/users/127669",
"pm_score": 0,
"selected": false,
"text": "Number someNumberFunction(Number n1, Number n2) \n{\n double\n d1 = n1.doubleValue(),\n d2 = n2.doubleValue();\n\n /* perform computations on d1 & d2 */\n}\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10675/"
] |
285,760
|
<p>I need to spawn a child process that is a console application, and capture its output.</p>
<p>I wrote up the following code for a method:</p>
<pre><code>string retMessage = String.Empty;
ProcessStartInfo startInfo = new ProcessStartInfo();
Process p = new Process();
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
startInfo.Arguments = command;
startInfo.FileName = exec;
p.StartInfo = startInfo;
p.Start();
p.OutputDataReceived += new DataReceivedEventHandler
(
delegate(object sender, DataReceivedEventArgs e)
{
using (StreamReader output = p.StandardOutput)
{
retMessage = output.ReadToEnd();
}
}
);
p.WaitForExit();
return retMessage;
</code></pre>
<p>However, this does not return anything. I don't believe the <code>OutputDataReceived</code> event is being called back, or the <code>WaitForExit()</code> command may be blocking the thread so it will never callback.</p>
<p>Any advice?</p>
<p><strong>EDIT:</strong> Looks like I was trying too hard with the callback. Doing:</p>
<pre><code>return p.StandardOutput.ReadToEnd();
</code></pre>
<p>Appears to work fine.</p>
|
[
{
"answer_id": 285841,
"author": "Judah Gabriel Himango",
"author_id": 536,
"author_profile": "https://Stackoverflow.com/users/536",
"pm_score": 8,
"selected": false,
"text": "process.StartInfo.UseShellExecute = false;\nprocess.StartInfo.RedirectStandardOutput = true;\nprocess.OutputDataReceived += (sender, args) => Console.WriteLine(\"received output: {0}\", args.Data);\nprocess.Start();\nprocess.BeginOutputReadLine();\n"
},
{
"answer_id": 285929,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 4,
"selected": false,
"text": "p.OutputDataReceived += ...\np.Start(); \n"
},
{
"answer_id": 9730455,
"author": "Umar Farooq Khawaja",
"author_id": 151742,
"author_profile": "https://Stackoverflow.com/users/151742",
"pm_score": 5,
"selected": false,
"text": "StringBuilder outputBuilder;\nProcessStartInfo processStartInfo;\nProcess process;\n\noutputBuilder = new StringBuilder();\n\nprocessStartInfo = new ProcessStartInfo();\nprocessStartInfo.CreateNoWindow = true;\nprocessStartInfo.RedirectStandardOutput = true;\nprocessStartInfo.RedirectStandardInput = true;\nprocessStartInfo.UseShellExecute = false;\nprocessStartInfo.Arguments = \"<insert command line arguments here>\";\nprocessStartInfo.FileName = \"<insert tool path here>\";\n\nprocess = new Process();\nprocess.StartInfo = processStartInfo;\n// enable raising events because Process does not raise events by default\nprocess.EnableRaisingEvents = true;\n// attach the event handler for OutputDataReceived before starting the process\nprocess.OutputDataReceived += new DataReceivedEventHandler\n(\n delegate(object sender, DataReceivedEventArgs e)\n {\n // append the new data to the data already read-in\n outputBuilder.Append(e.Data);\n }\n);\n// start the process\n// then begin asynchronously reading the output\n// then wait for the process to exit\n// then cancel asynchronously reading the output\nprocess.Start();\nprocess.BeginOutputReadLine();\nprocess.WaitForExit();\nprocess.CancelOutputRead();\n\n// use the output\nstring output = outputBuilder.ToString();\n"
},
{
"answer_id": 14932218,
"author": "Beatles1692",
"author_id": 111469,
"author_profile": "https://Stackoverflow.com/users/111469",
"pm_score": -1,
"selected": false,
"text": "public static string ShellExecute(this string path, string command, TextWriter writer, params string[] arguments)\n {\n using (var process = Process.Start(new ProcessStartInfo { WorkingDirectory = path, FileName = command, Arguments = string.Join(\" \", arguments), UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true }))\n {\n using (process.StandardOutput)\n {\n writer.WriteLine(process.StandardOutput.ReadToEnd());\n }\n using (process.StandardError)\n {\n writer.WriteLine(process.StandardError.ReadToEnd());\n }\n }\n\n return path;\n }\n @\"E:\\Temp\\MyWorkingDirectory\".ShellExecute(@\"C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\Bin\\svcutil.exe\", Console.Out);\n"
},
{
"answer_id": 18529868,
"author": "Sam",
"author_id": 238753,
"author_profile": "https://Stackoverflow.com/users/238753",
"pm_score": 5,
"selected": false,
"text": "var processStartInfo = new ProcessStartInfo\n{\n FileName = @\"C:\\SomeProgram\",\n Arguments = \"Arguments\",\n RedirectStandardOutput = true,\n UseShellExecute = false\n};\nvar process = Process.Start(processStartInfo);\nvar output = process.StandardOutput.ReadToEnd();\nprocess.WaitForExit();\n"
},
{
"answer_id": 21482452,
"author": "jws",
"author_id": 2183035,
"author_profile": "https://Stackoverflow.com/users/2183035",
"pm_score": 2,
"selected": false,
"text": "process.CancelOutputRead() process.WaitForExit(...);\n...\nwhile (process.StandardOutput.EndOfStream == false)\n{\n Thread.Sleep(100);\n}\n if (process.WaitForExit(timeout))\n{\n process.WaitForExit();\n}\n"
},
{
"answer_id": 31702940,
"author": "Robb Sadler",
"author_id": 540061,
"author_profile": "https://Stackoverflow.com/users/540061",
"pm_score": 5,
"selected": false,
"text": "Process process = new Process();\nStringBuilder outputStringBuilder = new StringBuilder();\n\ntry\n{\nprocess.StartInfo.FileName = exeFileName;\nprocess.StartInfo.WorkingDirectory = args.ExeDirectory;\nprocess.StartInfo.Arguments = args;\nprocess.StartInfo.RedirectStandardError = true;\nprocess.StartInfo.RedirectStandardOutput = true;\nprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;\nprocess.StartInfo.CreateNoWindow = true;\nprocess.StartInfo.UseShellExecute = false;\nprocess.EnableRaisingEvents = false;\nprocess.OutputDataReceived += (sender, eventArgs) => outputStringBuilder.AppendLine(eventArgs.Data);\nprocess.ErrorDataReceived += (sender, eventArgs) => outputStringBuilder.AppendLine(eventArgs.Data);\nprocess.Start();\nprocess.BeginOutputReadLine();\nprocess.BeginErrorReadLine();\nvar processExited = process.WaitForExit(PROCESS_TIMEOUT);\n\nif (processExited == false) // we timed out...\n{\n process.Kill();\n throw new Exception(\"ERROR: Process took too long to finish\");\n}\nelse if (process.ExitCode != 0)\n{\n var output = outputStringBuilder.ToString();\n var prefixMessage = \"\";\n\n throw new Exception(\"Process exited with non-zero exit code of: \" + process.ExitCode + Environment.NewLine + \n \"Output from process: \" + outputStringBuilder.ToString());\n}\n}\nfinally\n{ \nprocess.Close();\n}\n"
},
{
"answer_id": 33610114,
"author": "Craig",
"author_id": 2645643,
"author_profile": "https://Stackoverflow.com/users/2645643",
"pm_score": 2,
"selected": false,
"text": "BeginOutputReadLine(); var process = new Process();\n process.StartInfo.FileName = \"ping\";\n process.StartInfo.Arguments = \"google.com -t\";\n process.StartInfo.RedirectStandardOutput = true;\n process.StartInfo.UseShellExecute = false;\n process.OutputDataReceived += (sender, a) => Console.WriteLine(a.Data);\n process.Start();\n process.BeginOutputReadLine();\n process.WaitForExit();\n"
}
] |
2008/11/12
|
[
"https://Stackoverflow.com/questions/285760",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.