instruction
stringlengths 21
27.8k
| chosen
stringlengths 18
28.2k
| rejected
stringlengths 18
33.6k
| __index_level_0__
int64 0
50k
|
|---|---|---|---|
<p>HI,</p>
<p>I m doing the folling stuff in the jsp code I need to do it using Struts or using JSTL tag can any body have relevant idea please share..</p>
<p>The following is my JSP code</p>
<pre><code><%
Object category = request.getAttribute("categoryDetails");
Hashtable<String, Hashtable<String, Integer>> cat = (Hashtable<String, Hashtable<String, Integer>>) category;
//out.print(cat.entrySet());
Set<String> functions = cat.keySet();
for(String fun : functions){
out.print("-----------");
out.print(fun);
out.print("-----------");
Hashtable<String, Integer> obj = cat.get(fun);
Vector<String> subFunction = new Vector<String>(obj.keySet());
Collections.sort(subFunction);
for(String str : subFunction){
out.print("#"+str+"-"+obj.get(str));
}
}
%>
</code></pre>
<p>Thanks in advance.</p>
|
<p>According to <a href="http://net-snmp.sourceforge.net/wiki/index.php/Writing_your_own_MIBs" rel="nofollow noreferrer">this</a> net-snmp howto, there is a tool called <a href="http://www.ibr.cs.tu-bs.de/projects/libsmi/smilint.html" rel="nofollow noreferrer">smilint</a> from the <a href="http://www.ibr.cs.tu-bs.de/projects/libsmi/" rel="nofollow noreferrer">smilib</a> package that they recommend. Sounds more directed than using snmptranslate.</p>
<p>See also <a href="http://www.ops.ietf.org/mib-review-tools.html" rel="nofollow noreferrer">this</a> ietf page for descriptions on usage.</p>
|
<p>I've been using <a href="http://www.mibexplorer.com/download/download.html" rel="nofollow">MIB Explorer Lite</a> which has a syntax checker whenever you load a MIB. There's a free trial which I think lasts about 30 days.</p>
| 49,409
|
<p>I am running some queries to track down a problem with our backup logs and would like to display datetime fields in 24-hour military time. Is there a simple way to do this? I've tried googling and could find nothing.</p>
|
<pre><code>select to_char(sysdate,'DD/MM/YYYY HH24:MI:SS') from dual;
</code></pre>
<p>Give the time in 24 hour format.</p>
<p>More options are described <a href="http://www.oradev.com/oracle_date_format.jsp" rel="noreferrer">here</a>.</p>
|
<p>It's not oracle that determines the display of the date, it's the tool you're using to run queries. What are you using to display results? Then we can point you to the correct settings hopefully.</p>
| 12,848
|
<p>I have a source base that, depending on defined flags at build time, creates two different apps. I can build both of these apps using a Makefile by specifying two different targets, one that compiles with a flag and one that compiles without, and having an aggregate target that builds both.</p>
<p>How do I do the equivalent thing from Visual C# Express on Windows?</p>
|
<p>Create one solution with two project files in the same folder. Set two different configurations in your solution, one of them building one of the projects, the other one building the other project.</p>
<p>Alternatively, you can have one project which always builds to intermediate binary and then have a postbuild step that copies it to the final binary depending on the flag.</p>
|
<p>Release vs Debug? You can create your own custom configurations as well. But building a completely different app based on the configuration seems like a bad idea.</p>
<p>Normal visual studio can have multiple projects in one solution, and I think there's a way to shoe-horn this into Express edition (perhaps by opening a solution created elsewhere).</p>
<p>Really,though, you may have to settle for keeping two instances of Visual Studio open at at a time. You can always set one of them to build right into the /bin/Release/ folder of the other project if you want.</p>
| 24,745
|
<p>I´m currently working on a custom delta printer running Marlin 1.0.2 firmware. To control it I´m using the Repetier Host software with the onboard Cura software to slice my objects. The printing works fine but it takes the nozzle nearly 5 minutes to move from the homing position at 250 mm to the starting position of the print near z=0. </p>
<p>I already tried to increase the travel speed but nothing changed. Can you guys please tell me how to increase the speed of my nozzle to move down to my starting point of the print?</p>
|
<p>I had the same problem, and I solved it by changing the <em>Z-Axis Feed Rate</em> to a much higher value (1000 mm/min.) in Repetier Host via <em>Config -> Printer Settings -> Printer</em>.</p>
|
<p>Try changing the travel speed in you r slicer, if that doesn't work , try changing out the motors for newer ones.</p>
| 588
|
<p>How do you reference a bitmap on the stage in flash using actionscript 3?</p>
<p>I have a bitmap on the stage in flash and at the end of the movie I would like to swap it out for the next in the sequence before the movie loops. in my library i have 3 images, exported for actionscript, with the class name img1/img2/img3. here is how my layers in flash are set out.</p>
<pre><code>layer 5 : mask2:MovieClip
layer 4 : img2:Bitmap
layer 3 : mask1:MovieClip
layer 2 : img1:Bitmap
layer 1 : background:Bitmap
</code></pre>
<p>at the end of the movie I would like to swap img1 with img2, so the movie loops seamlessly, then ideally swap img2 (on layer 4) with img3 and so on until I get to the end of my images.</p>
<p>but I can not find out how to reference the images that have already been put on the stage (in design time), any one have any idea of how to do this?</p>
<p>The end movie will hopefully load images dynamically from the web server (I have the code for this bit) and display them as well as img1/img2/img3.</p>
<p>Any help would be appreciated.</p>
<p><strong>EDIT:</strong></p>
<p>@<a href="https://stackoverflow.com/questions/43354/how-do-you-reference-a-bitmap-on-the-stage-in-actionscript#43735">81bronco</a> , I tried this but the instance name is greyed out for graphics, it will only allow me to do it with movieclips and buttons. I half got it to work by turning them into moveclips, and clearing the images in the moveclip out before adding a new one (using something simpler to what <a href="https://stackoverflow.com/questions/43354/how-do-you-reference-a-bitmap-on-the-stage-in-actionscript#44347">vanhornRF</a> suggested), but for some odd reason when the mask kicks in the images I cleared out come back for the mask animation.</p>
|
<p>To reference something on the stage, you need to give the stage instance a name - not give the symbol in the library a class name.</p>
<p>Click on the item on the stage and look at the properties panel. There should be a text entry box just above the entry boxes for the item's dimensions. Enter a name there.</p>
<p>Elsewhere in your code, you can then refer to that item on stage by it's instance name.</p>
|
<p>I would probably do something like this in your document class</p>
<pre><code>for(var i:int=0; i<numChildren; i++){
trace(getChildAt(i),"This is the child at position "+i);
}
</code></pre>
<p>I do this because I still code in the flash IDE and its debugger is so very painful to get working most of the time it's easier to just trace variables out, so you can either use that for loop to print the object names of the items currently on your stage, or use a debugger program to find the objects as well.</p>
<p>Now that you have the children and at what index they actually are at within the stage, you can reference them by calling getChildAt(int), you can removeChildAt(int), you can addChildAt(displayObject, int) and swapChildrenAt(int, int). The int in these arguments would represent the index position that was returned by your trace statement and the displayObject would obviously just represent anything you wanted to add to the stage or parent DisplayObject.</p>
<p>Using those 4 commands you should be able to freely re-arrange any movieclips you have on stage so that they will appear to transition seamlessly.</p>
<p>@81bronco One should definitely name your assets on stage if you want to uniquely reference them specifically to avoid any confusion if there ends up being a lot of items on stage</p>
| 6,497
|
<p>While I'm developing my MS Access application, I open it with shift click. When an Error occurs, that is not trapped (by ON ERROR ...), a message box pops up informing me about the error. This is a good thing.</p>
<p>When a user open my application, he does't shift click, and an appropriate Start Form opens. However, now untrapped Errors don't show up, the application behaves as if the user clicked the Stop Button on the message box. I don't want this behaviour.</p>
<p>Is there an option / property / variable that provides the same behaviour in the production code (preferably even when the application id converted to an mde) as in development, i.e. show a message box for every untrapped error? Or is it neccessary to trap errors in every single event routine and pop up a message box by program?</p>
|
<p>It turns out, this is a side effect of setting the AllowSpecialKeys property to False. This can be done programmatically, but I did it in the menu under Tools > StartUp.</p>
<p>Since this property allows the user to open the code editor, it kind of makes sense, but the relationship of the phenomen described to this option was puzzling for me.</p>
<p>Does this mean, that if I want to hide my code, I need to write all those error handlers? Or is there one central place (like a main method in Java) where I can invoke an error handler. Alternatively, could I allow specical keys and just protect the code with a keyword?</p>
|
<p>You can create your own error handler and add it to all procs, subs and functions. You have this very nice <a href="http://www.mztools.com" rel="nofollow noreferrer">MZ Tools</a> VBA add-on that allows you many thing such as adding line numbers to your code, "preprogramming" your error label, etc. </p>
<p>If you are smart enough, you'll be able to use this add-on to generate a standard "error management" code displaying things such as err.number, err.description, and the undocument erl value, which is the number of the line where the error occured (you must first have your lines numbered before being able to get this value).</p>
<p>EDIT: I just opened <a href="https://stackoverflow.com/questions/357822/ms-access-and-error-management">this question</a> on a similar subject.</p>
| 46,372
|
<p>I've drawn an ellipse in the XZ plane, and set my perspective slightly up on the Y-axis and back on the Z, looking at the center of ellipse from a 45-degree angle, using gluPerspective() to set my viewing frustrum.</p>
<p><a href="http://www.flickr.com/photos/rampion/2863703051/" rel="nofollow noreferrer" title="ellipse by rampion, on Flickr"><img src="https://farm4.static.flickr.com/3153/2863703051_a768ed86a9_m.jpg" width="240" height="187" alt="ellipse" /></a></p>
<p>Unrotated, the major axis of the ellipse spans the width of my viewport. When I rotate 90-degrees about my line-of-sight, the major axis of the ellipse now spans the height of my viewport, thus deforming the ellipse (in this case, making it appear less eccentric).</p>
<p><a href="http://www.flickr.com/photos/rampion/2863703073/" rel="nofollow noreferrer" title="rotated ellipse by rampion, on Flickr"><img src="https://farm4.static.flickr.com/3187/2863703073_24c6549d4b_m.jpg" width="240" height="187" alt="rotated ellipse" /></a></p>
<p>What do I need to do to prevent this deformation (or at least account for it), so rotation about the line-of-sight preserves the perceived major axis of the ellipse (in this case, causing it to go beyond the viewport)?</p>
|
<p>It looks like you're using 1.0 as the aspect when you call gluPerspective(). You should use width/height. For example, if your viewport is 640x480, you would use 1.33333 as the aspect argument.</p>
|
<p>It looks like the aspect parameter on your gluPerspective call need tweaking. See <a href="http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/glu/perspective.html" rel="nofollow noreferrer">The Man Page</a>. If your window were physically square, the aspect ratio would be 1 and your problem would go away. However, your window is rectangular, so the viewing frustum needs to be non-square.</p>
<p>Set the aspect ratio to window_width / window_height, and your ellipse should look correct. Note that you'll need to update this whenever the window resizes; if you're using GLUT set a <a href="http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/glutReshapeFunc.3.html" rel="nofollow noreferrer">glutReshapeFunc</a> and recalculate the projection matrix in there.</p>
| 10,471
|
<p>So I assume I'm not the only one. I'm wondering if there are others out there who have compiled a personal code library. Something that you take from job to job that has examples of best practices, things you are proud of, or just common methods you see yourself using over and over. </p>
<p>I just recently started my C# library. It already has quite a few small items. Common Regex validations, interfaces for exception handling, some type conversion overloads, enum wrappers, sql injection detection methods, and some common user controls with AJAX toolkit examples.</p>
<p>I'm wondering what kind of things do you have in yours?</p>
|
<p>Because I primarily do web development, I've abstracted out some common features that I end up doing frequently on sites for clients. </p>
<ul>
<li><p><strong>Ajax Emailer</strong>. Nearly every site I work on has some type of contact form. I wrote a utility that allows me to drop some HTML on a page, having JavaScript field validation, and a PHP library that requires me to change a few parameters to work with each client's mail server. The only thing I have to write is CSS each time I include it on to a page.</p></li>
<li><p><strong>Stylesheet skeleton generator</strong>. I wrote a small JavaScript utility that walks the DOM for whatever page it has been included on and then stubs out a valid CSS skeleton so that I can immediately start writing styles without having to do the repetitive task for every site I work on.</p></li>
<li><p><strong>JavaScript Query String Parser.</strong> Occasionally I need to parse the query string but it doesn't warrant any major modifications to the server (such as installing PHP), so I wrote a generic JavaScript utility that I can easily configure for each site.</p></li>
</ul>
<p>I've got other odds and end utilities, as well, but they are kind of hacked together for personal use. I'd be embarrassed to let anyone see the source.</p>
<h2>Update</h2>
<p>Several people have asked for my stylesheet skeleton generator in the comments so I'm providing a link to the project <a href="http://www.tommcfarlin.com/pages_projects/get-styleshell/" rel="nofollow noreferrer">here</a>. It's more or less based on the way that I structure my XHTML and format my CSS, but hopefully you'll find it useful.</p>
|
<p>I have several utility MATLAB functions that I have taken with me as I move from job to job, particularly ones that enforce W3C standards on the plots I make to ensure that text and background colors have a good <a href="http://www.w3.org/TR/2005/WD-WCAG20-20051123/appendixA.html" rel="nofollow noreferrer">luminosity ratio</a>. I also have a function that uses ActiveX to insert a MATLAB figure into PowerPoint.</p>
| 23,341
|
<p>I want to serialize a Dictionary that has a custom <code>IEqualityComparer</code>.</p>
<p>I've tried using <code>DataContractSerializer</code> but I can't get the <code>Comparer</code> to be serialized.</p>
<p>I can't use <code>BinaryFormatter</code> because of <a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=303278&wa=wsignin1.0" rel="nofollow noreferrer">this</a>.</p>
<p>I can always do something like:</p>
<pre><code>var myDictionary = new MyDictionary(deserializedDictionary, myComparer);
</code></pre>
<p>But that means I'd need twice the memory the dictionary uses.</p>
|
<p>pop-cmd.py:</p>
<pre><code>#!/usr/bin/env python
import os, shlex, sys
from subprocess import call
filename = sys.argv[1]
lines = open(filename).readlines()
if lines:
command = lines[0].rstrip()
open(filename, "w").writelines(lines[1:])
if command:
sys.exit(call(shlex.split(command) + sys.argv[2:]))
</code></pre>
<p>Example:</p>
<pre><code>proc_A | proc_B | python pop-cmd.py cmdstack.lst | proc_D
</code></pre>
|
<p>You can't write to the beginning of a file, so cutting out line 1 would be a lot of work (rewrite the rest of the file (which isn't actually that much work for the programmer (it's what every other answer post has written for you :) ) ) ).</p>
<p>I'd recommend keeping the whole thing in memory and using a classic stack rather than a file.</p>
| 47,839
|
<p>In Cygwin a space in a path has to be escaped with a backslash
Not true in Windows, put the whole path in a quote</p>
<p>Is there a way to convert to this automatically in Ruby?</p>
<p>Otherwise, how in Ruby do I detect if I am running with Windows or Cygwin?</p>
|
<p><a href="http://rant.rubyforge.org/" rel="nofollow noreferrer">http://rant.rubyforge.org/</a></p>
<pre><code>sys.escape("foo bar")
# gives on Windows: '"foo bar"'
# other systems: 'foo\ bar'
</code></pre>
|
<p>I found how to detect the platform at least - the RUBY_PLATFORM constant defines that.</p>
| 29,913
|
<p>What is the best way to disable the warnings generated via <code>_CRT_SECURE_NO_DEPRECATE</code> that allows them to be reinstated with ease and will work across Visual Studio versions?</p>
|
<p>If you don't want to pollute your source code (after all this warning presents only with Microsoft compiler), add <code>_CRT_SECURE_NO_WARNINGS</code> symbol to your project settings via "Project"->"Properties"->"Configuration properties"->"C/C++"->"Preprocessor"->"Preprocessor definitions".</p>
<p>Also you can define it just before you include a header file which generates this warning.
You should add something like this</p>
<pre><code>#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
</code></pre>
<p>And just a small remark, make sure you understand what this warning stands for, and maybe, if you don't intend to use other compilers than MSVC, consider using safer version of functions i.e. strcpy_s instead of strcpy.</p>
|
<p>Another late answer... Here's how Microsoft uses it in their <code>wchar.h</code>. Notice they also disable <a href="http://msdn.microsoft.com/en-us/library/ms182089%28v=vs.100%29.aspx" rel="nofollow">Warning C6386</a>:</p>
<pre><code>__inline _CRT_INSECURE_DEPRECATE_MEMORY(wmemcpy_s) wchar_t * __CRTDECL
wmemcpy(_Out_opt_cap_(_N) wchar_t *_S1, _In_opt_count_(_N) const wchar_t *_S2, _In_ size_t _N)
{
#pragma warning( push )
#pragma warning( disable : 4996 6386 )
return (wchar_t *)memcpy(_S1, _S2, _N*sizeof(wchar_t));
#pragma warning( pop )
}
</code></pre>
| 14,541
|
<p>Are there any third party enterprisey data grid controls out there, alla JIDE Data Grid? Is there a website like torry.net that lists third party java controls? Google doesn't turn up much for and I thought there would be a lot of both considering how popular java seems to be.</p>
<p>TIA</p>
|
<p>Most Java frameworks offer that kind of component or widget. You can look into SWT (from eclipse), they is very good stuff in there: <a href="http://www.eclipse.org/swt/" rel="nofollow noreferrer">http://www.eclipse.org/swt/</a>. You could also look into Jambi (Qt in Java) from <a href="http://trolltech.com/products/appdev/programming-language-support" rel="nofollow noreferrer">http://trolltech.com/products/appdev/programming-language-support</a>. Now, if your into web apps, there are infinite options.</p>
|
<p>I usually look on component sales sites like
<a href="http://www.componentsource.com/features/grids/java-components/index.html" rel="nofollow noreferrer">http://www.componentsource.com/features/grids/java-components/index.html</a></p>
<p>Jonathan Wax
jwaxster@gmail.com</p>
| 29,588
|
<p>A long time ago I saw this trick in Ruby. Instead of doing (for example)</p>
<pre><code>if array1.empty? and array2.empty? and array3.empty?
</code></pre>
<p>You could call all of the objects at once and append the operation at the end, kind of like</p>
<pre><code>if %w(array1 array2 array3).each { |a| a.empty? }
</code></pre>
<p>But I think it was simpler than that... or, it could be that. I really don't know, but that's why I'm interested in finding out. Thanks.</p>
|
<p><code>if [array1, array2, array3].all? { |a| a.empty? }</code></p>
<p>I think that's what you're looking for</p>
|
<p>On a side note, Symbol#to_proc can have performance issues, so use it in cases when readability is worth it.</p>
| 49,401
|
<p>I've written a Custom User Control which returns some user specific data.
To load the Custom User Control I use the following line of code:</p>
<pre><code>UserControl myUC = (UserControl).Load("~/customUserControl.ascx");
</code></pre>
<p>But how can I access <code>string user</code> inside the User Control <code>myUC</code>? </p>
|
<p>Let's call your usercontrol "Bob"</p>
<p>If you Inherit from UserControl in Bob, then I guess it's safe to do this:</p>
<pre><code>Bob b = (Bob).Load("~/customUserControl.ascx");
</code></pre>
<p>For the user part, I can't really follow what you want to do, is the "user" in the class were you create the "Bob" usercontrol and you want to set a property in the "Bob" usercontrol or is it the other way around?</p>
<p>For the first one you should create a property in your usercontrol.</p>
<pre><code>class Bob : UserControl{
public string User { get; set;}
}
</code></pre>
<p>and then set it when after you create "Bob" instance.</p>
<pre><code>b.User = theuser;
</code></pre>
|
<p>You will need to cast the loaded control to the actual type and use its public property:</p>
<pre><code>MyUserControl myUCTyped = (MyUserControl)myUC;
myUCTyped.ThePublicProperty = "some value";
</code></pre>
| 43,645
|
<p>I have a project and it needs to access a large amount of proprietary data in ASP.NET. This was done on the Linux/PHP by loading the data in shared memory. I was wondering if trying to use Memory Mapped Files would be the way to go, or if there is a better way with better .NET support. I was thinking of using the Data Cache but not sure of all the pitfalls of size of data being saved in the Cache.</p>
|
<p>I know this is a bit late, but the .NET 4.0 framework now supports memory-mapped files out of the box:</p>
<p><a href="http://blogs.msdn.com/salvapatuel/archive/2009/06/08/working-with-memory-mapped-files-in-net-4.aspx" rel="noreferrer">http://blogs.msdn.com/salvapatuel/archive/2009/06/08/working-with-memory-mapped-files-in-net-4.aspx</a></p>
|
<p>You might want to just throw it in the Cache[] object. You can set a cache expiration based on the real file. Then whenever you modify the actual file the contents will be null for the object in the cache and you can reload it. This may not be appropriate if you're dealing with a large number of bytes.</p>
<pre><code>byte[] fileBytes = Cache["fileBytes"];
if (null == fileBytes) {
// reload the file and add it to the cache.
string fileLocation = Server.MapPath("path/to/file.txt");
// Just a same of some bytes.
fileBytes = new byte[10];
Cache.Insert(fileLocation, fileBytes, new System.Web.Caching.CacheDependency(fileLocation));
}
</code></pre>
<p>I guess I don't have a specific answer about the performance characteristics of the cache and large amounts of data. <a href="http://www.alachisoft.com/ncache/asp-net-cache.html" rel="nofollow noreferrer">http://www.alachisoft.com/ncache/asp-net-cache.html</a> States that you get between 2 and 3 gigs of cache space that must be shared between your application and the cache.</p>
| 46,574
|
<p>I'm writing an ASP.NET application. I have a textbox on a webform, and I want to force whatever the user types to upper case. I'd like to do this on the front end. You should also note that there is a validation control on this textbox, so I want to make sure the solution doesn't interfere with the ASP.NET validation.</p>
<p><strong>Clarification:</strong>
It appears that the CSS text transform makes the user input appear in uppercase. However, under the hood, it's still lower case as the validation control fails. You see, my validation control checks to see if a valid state code is entered, however the regular expression I'm using only works with uppercase characters.</p>
|
<p>Why not use a combination of the CSS and backend? Use:</p>
<pre><code>style='text-transform:uppercase'
</code></pre>
<p>on the TextBox, and in your codebehind use:</p>
<pre><code>Textbox.Value.ToUpper();
</code></pre>
<p>You can also easily change your regex on the validator to use lowercase and uppercase letters. That's probably the easier solution than forcing uppercase on them.</p>
|
<p>Minimum 8 characters at least 1 Alphabet and 1 Number
<asp:TextBox ID="txtPolicy1" runat="server"></asp:TextBox><br />
<asp:RegularExpressionValidator ID="Regex1" runat="server" ControlToValidate="txtPolicy1"
ValidationExpression="^(?=.<em>[A-Za-z])(?=.</em>\d)[A-Za-z\d]{8,}$" ErrorMessage="Password must contain: Minimum 8 characters atleast 1 Alphabet and 1 Number" ForeColor="Red" /></p>
<p>Valid Password Examples: pass1234 OR PaSs1234 OR PASS1234</p>
<p>Minimum 8 characters at least 1 Alphabet, 1 Number and 1 Special Character
<asp:TextBox ID="txtPolicy2" runat="server"></asp:TextBox><br />
<asp:RegularExpressionValidator ID="Regex2" runat="server" ControlToValidate="txtPolicy2"
ValidationExpression="^(?=.<em>[A-Za-z])(?=.</em>\d)(?=.<em>[$@$!%</em>#?&])[A-Za-z\d$@$!%*#?&]{8,}$"
ErrorMessage="Minimum 8 characters atleast 1 Alphabet, 1 Number and 1 Special Character" ForeColor="Red" /></p>
<p>Valid Password Examples: pass@123 OR PaSS#123 OR PASS@123</p>
<p>Minimum 8 characters at least 1 Uppercase Alphabet, 1 Lowercase Alphabet and 1 Number
<asp:TextBox ID="txtPolicy3" runat="server"></asp:TextBox><br />
<asp:RegularExpressionValidator ID="Regex3" runat="server" ControlToValidate="txtPolicy3"
ValidationExpression="^(?=.<em>[a-z])(?=.</em>[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$"
ErrorMessage="Password must contain: Minimum 8 characters atleast 1 UpperCase Alphabet, 1 LowerCase Alphabet and 1 Number" ForeColor="Red" /></p>
<p>Valid Password Examples: PaSs1234 OR pASS1234</p>
<p>Minimum 8 characters at least 1 Uppercase Alphabet, 1 Lowercase Alphabet, 1 Number and 1 Special Character</p>
<p><asp:TextBox ID="txtPolicy4" runat="server"></asp:TextBox><br />
<asp:RegularExpressionValidator ID="Regex4" runat="server" ControlToValidate="txtPolicy4"
ValidationExpression="^(?=.<em>[a-z])(?=.</em>[A-Z])(?=.<em>\d)(?=.</em>[$@$!%<em>?&])[A-Za-z\d$@$!%</em>?&]{8,}"
ErrorMessage="Password must contain: Minimum 8 characters atleast 1 UpperCase Alphabet, 1 LowerCase Alphabet, 1 Number and 1 Special Character" ForeColor="Red" /></p>
<p>Valid Password Examples: PaSs@123 OR pAss@123</p>
<p>Minimum 8 and Maximum 10 characters at least 1 Uppercase Alphabet, 1 Lowercase Alphabet, 1 Number and 1 Special Character</p>
<p><asp:TextBox ID="txtPolicy5" runat="server"></asp:TextBox><br />
<asp:RegularExpressionValidator ID="Regex5" runat="server" ControlToValidate="txtPolicy5"
ValidationExpression="^(?=.<em>[a-z])(?=.</em>[A-Z])(?=.<em>\d)(?=.</em>[$@$!%<em>?&])[A-Za-z\d$@$!%</em>?&]{8,10}"
ErrorMessage="Password must contain: Minimum 8 and Maximum 10 characters atleast 1 UpperCase Alphabet, 1 LowerCase Alphabet, 1 Number and 1 Special Character"
ForeColor="Red" /></p>
<p>Valid Password Examples: PaSs@123</p>
| 24,743
|
<p>Does anyone know how to programmaticly find out where the java classloader actually loads the class from? </p>
<p>I often work on large projects where the classpath gets very long and manual searching is not really an option. I recently had a <a href="https://stackoverflow.com/questions/226280/eclipse-class-version-bug" title="problem">problem</a> where the classloader was loading an incorrect version of a class because it was on the classpath in two different places.</p>
<p>So how can I get the classloader to tell me where on disk the actual class file is coming from?</p>
<p><strong><em>Edit:</em></strong> What about if the classloader actually fails to load the class due to a version mismatch (or something else), is there anyway we could find out what file its trying to read before it reads it?</p>
|
<p>Here's an example:</p>
<pre><code>package foo;
public class Test
{
public static void main(String[] args)
{
ClassLoader loader = Test.class.getClassLoader();
System.out.println(loader.getResource("foo/Test.class"));
}
}
</code></pre>
<p>This printed out:</p>
<pre><code>file:/C:/Users/Jon/Test/foo/Test.class
</code></pre>
|
<p>Assuming that you're working with a class named <code>MyClass</code>, the following should work:</p>
<pre><code>MyClass.class.getClassLoader();
</code></pre>
<p>Whether or not you can get the on-disk location of the .class file is dependent on the classloader itself. For example, if you're using something like BCEL, a certain class may not even have an on-disk representation.</p>
| 28,153
|
<p>Have you managed to get Aptana Studio debugging to work? I tried following this, but I don't see <code>Windows -> Preferences -> Aptana -> Editors -> PHP -> PHP Interpreters</code> in my menu (I have <code>PHP plugin</code> installed) and any attempt to set up the servers menu gives me "socket error" when I try to debug. <code>Xdebug</code> is installed, confirmed through <code>php info</code>.</p>
|
<p>I've been using ZendDebugger with Eclipse (on OS X) for a while now and it works great!</p>
<p>Here's the recipe that's worked well for me.</p>
<ol>
<li>install Eclipse PDT via "All in one" package at: <a href="http://www.zend.com/en/community/pdt" rel="nofollow noreferrer">http://www.zend.com/en/community/pdt</a></li>
<li>install ZendDebugger.so (<a href="http://www.zend.com/en/community/pdt" rel="nofollow noreferrer">http://www.zend.com/en/community/pdt</a>)</li>
<li>configure your php.ini w/ the ZendDebugger extenssion (info below)</li>
</ol>
<p>Configuring ZendDebugger:</p>
<ol>
<li>edit php.ini</li>
<li><p>add the following:</p>
<p>[Zend]<br>
zend_extension=/full/path/to/ZendDebugger.so<br>
zend_debugger.allow_hosts=127.0.0.1<br>
zend_debugger.expose_remotely=always<br>
zend_debugger.connector_port=10013 </p></li>
</ol>
<p>Now run "php -m" in the command line to output all the installed modules. If you see the following then its installed just fine</p>
<pre><code>[Zend Modules]
Zend Debugger
</code></pre>
<p>Now restart Apache so that it reloads PHP w/ the ZendDebugger. Create a dummy page with in it and examine the output to make sure the PHP apache module picked up ZendDebugger as well. If it's setup right you will see something like the following text somewhere in phpinfo()'s output. </p>
<blockquote>
<p>with Zend Debugger v5.2.14, Copyright (c) 1999-2008, by Zend Technologies</p>
</blockquote>
<p>OK - but you wanted Aptana Studio... at this point I install the Aptana Studio Plugin into the PDT build of Eclipse. The instructions for that are at: <a href="http://www.aptana.com/docs/index.php/Plugging_Aptana_into_an_existing_Eclipse_configuration" rel="nofollow noreferrer">http://www.aptana.com/docs/index.php/Plugging_Aptana_into_an_existing_Eclipse_configuration</a></p>
<p>That setup has served me well for a while - hopefully it helps you too</p>
<p>-Arin</p>
|
<p>I realize that this is a old thread but I was having the same problem with Aptana Studio 3 and FireFox. If anyone is having this problem make sure that FireFox has FireBug <strong>V1.8.X</strong> installed, any other version might give you the same problem...</p>
<p>Hope this helps</p>
| 15,551
|
<p>How exactly can I create a new directory using Emacs? What commands do I use? (If possible, please provide an example)</p>
|
<ul>
<li><p>to create the directory <code>dir/to/create</code>, type:</p>
<pre><code>M-x make-directory RET dir/to/create RET
</code></pre></li>
<li><p>to create directories <code>dir/parent1/node</code> and <code>dir/parent2/node</code>, type:</p>
<pre><code>M-! mkdir -p dir/parent{1,2}/node RET
</code></pre>
<p>It assumes that Emacs's inferior shell is <code>bash</code>/<code>zsh</code> or other compatible shell.</p></li>
<li><p>or in a <code>Dired</code> mode </p>
<pre><code>+
</code></pre>
<p>It doesn't create nonexistent parent directories.</p>
<p>Example:</p>
<pre><code>C-x d *.py RET ; shows python source files in the CWD in `Dired` mode
+ test RET ; create `test` directory in the CWD
</code></pre>
<p><code>CWD</code> stands for Current Working Directory.</p></li>
<li><p>or just create a new file with non-existing parent directories using <code>C-x C-f</code> and type:</p>
<pre><code>M-x make-directory RET RET
</code></pre></li>
</ul>
<p>Emacs asks to create the parent directories automatically while saving a new file in recent Emacs versions. For older version, see <a href="https://stackoverflow.com/q/6830671/4279">How to make Emacs create intermediate dirs - when saving a file?</a></p>
|
<p>I came across this question while searching for how to automatically create directories in Emacs. The best answer I found was in <a href="https://stackoverflow.com/questions/6830671/how-to-make-emacs-create-intermediate-dirs-when-saving-a-file">another thread</a> from a few years later. The answer from <a href="https://stackoverflow.com/users/513266/victor-deryagin">Victor Deryagin</a> was exactly what I was looking for. Adding that code to your .emacs will make Emacs prompt you to create the directory when you go to save the file.</p>
| 18,809
|
<p>I have a Virtual Machine in Virtual PC 2007.</p>
<p>To start it from the desktop, I have the following command in a batch file:</p>
<pre><code>"c:\program files\Microsoft Virtual PC\Virtual PC.exe" -pc "MY-PC" -launch
</code></pre>
<p>But that leaves a dos prompt on the host machine until the virtual machine shuts down, and I exit out of the Virtual PC console. That's annoying.</p>
<p>So I changed my command to use the START command, instead:</p>
<pre><code>start "c:\program files\Microsoft Virtual PC\Virtual PC.exe" -pc MY-PC -launch
</code></pre>
<p>But it chokes on the parameters passed into Virtual PC.</p>
<p><code>START /?</code> indicates that parameters do indeed go in that location. Has anyone used START to launch a program with multiple command-line arguments?</p>
|
<p>START has a peculiarity involving double quotes around the first parameter. If the first parameter has double quotes it uses that as the optional TITLE for the new window. </p>
<p>I believe what you want is:</p>
<pre><code>start "" "c:\program files\Microsoft Virtual PC\Virtual PC.exe" -pc MY-PC -launch
</code></pre>
<p>In other words, give it an empty title before the name of the program to fake it out.</p>
|
<p>have you tried:</p>
<pre><code>start "c:\program files\Microsoft Virtual PC\Virtual PC.exe" "-pc MY-PC -launch"
</code></pre>
<p>?</p>
| 18,613
|
<p>What Python libraries do folks use for querying Amazon product data? (Amazon Associates Web Service - used to be called E-Commerce API, or something along those lines).</p>
<p>Based on my research, <a href="http://pyaws.sourceforge.net/" rel="noreferrer">PyAWS</a> seems okay, but still pretty raw (and hasn't been updated in a while). Wondering if there's an obvious canonical library that I'm just missing.</p>
|
<p>I'm using <a href="https://github.com/aurorasoftware/bottlenose">Bottlenose</a>, Dan Loewenherz's "super awesome Python wrapper for the Amazon Product Advertising API". It doesn't parse the XML, so I'm using <a href="http://codespeak.net/lxml/objectify.html">lxml.objectify</a>:</p>
<pre><code>ACCESS_KEY_ID = "..."
SECRET_KEY = "..."
ASSOC_TAG = "..."
import bottlenose
amazon = bottlenose.Amazon(ACCESS_KEY_ID, SECRET_KEY, ASSOC_TAG)
response=amazon.ItemLookup(ItemId="B0018AFK38", ResponseGroup="OfferSummary")
from lxml import objectify
root = objectify.fromstring(response)
root.Items.Item.OfferSummary.LowestNewPrice.FormattedPrice
</code></pre>
|
<p>pyaws is the best in my opinion. The most available version is 0.2.0, but there is also a version 0.3.0 that is somewhat harder to find. The best maintained version of it that I have found though, which is based on 0.3.0, is on <a href="http://bitbucket.org/johnpaulett/pyaws/overview/" rel="nofollow noreferrer">bitbucket</a>.</p>
| 7,130
|
<p>The following method does not work because the inner block declares a variable of the same name as one in the outer block. Apparently variables belong to the method or class in which they are declared, not to the block in which they are declared, so I therefore can't write a short little temporary block for debugging that happens to push a variable in the outer scope off into shadow just for a moment:</p>
<pre><code>void methodName() {
int i = 7;
for (int j = 0; j < 10; j++) {
int i = j * 2;
}
}
</code></pre>
<p>Almost every block-scoped language I've ever used supported this, including trivial little languages that I wrote interpreters and compilers for in school. Perl can do this, as can Scheme, and even C. Even PL/SQL supports this!</p>
<p>What's the rationale for this design decision for Java?</p>
<p>Edit: as somebody pointed out, Java does have block-scoping. What's the name for the concept I'm asking about? I wish I could remember more from those language-design classes. :)</p>
|
<p>I believe the rationale is that most of the time, that isn't intentional, it is a programming or logic flaw.</p>
<p>in an example as trivial as yours, its obvious, but in a large block of code, accidentally redeclaring a variable may not be obvious.</p>
<p>ETA: it might also be related to exception handling in java. i thought part of this question was discussed in a question related to why variables declared in a try section were not available in the catch/finally scopes.</p>
|
<p>another reason: if this kind of variable declaration were allowed, people would want (need?) a way to access outer block variables. may be something like "outer" keyword would be added:</p>
<pre><code>void methodName() {
int i = 7;
for (int j = 0; j < 10; j++) {
int i = outer.i * 2;
if(i > 10) {
int i = outer.outer.i * 2 + outer.i;
}
}
}
</code></pre>
| 17,047
|
<p>Is there a <code>string.Empty</code> in JavaScript, or is it just a case of checking for <code>""</code>?</p>
|
<h3>Empty string, undefined, null, ...</h3>
<p>To check for a <a href="https://developer.mozilla.org/en-US/docs/Glossary/Truthy" rel="noreferrer">truthy value</a>:</p>
<pre><code>if (strValue) {
// strValue was non-empty string, true, 42, Infinity, [], ...
}
</code></pre>
<p>To check for a <a href="https://developer.mozilla.org/en-US/docs/Glossary/Falsy" rel="noreferrer">falsy value</a>:</p>
<pre><code>if (!strValue) {
// strValue was empty string, false, 0, null, undefined, ...
}
</code></pre>
<hr />
<h3>Empty string (only!)</h3>
<p>To check for exactly an empty string, compare for strict equality against <code>""</code> using the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality" rel="noreferrer"><code>===</code> operator</a>:</p>
<pre><code>if (strValue === "") {
// strValue was empty string
}
</code></pre>
<p>To check for not an empty string strictly, use the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_inequality" rel="noreferrer"><code>!==</code> operator</a>:</p>
<pre><code>if (strValue !== "") {
// strValue was not an empty string
}
</code></pre>
|
<pre><code>var x =" ";
var patt = /^\s*$/g;
isBlank = patt.test(x);
alert(isBlank); // Is it blank or not??
x = x.replace(/\s*/g, ""); // Another way of replacing blanks with ""
if (x===""){
alert("ya it is blank")
}
</code></pre>
| 18,612
|
<p>I want ajax application to process a simple form with textinput and submit button only , and without validation , i want to add this with a php script .
I ask this because i don't know how to program with ajax or javascript .</p>
|
<p>Honestly, you're not going to get anywhere without learning javascript. You should really look into learn it, it's not that complex of a language either. Ajax isn't actually a language, it's a function, a feature so to speak. Once you get the hang of using it, it's not difficult either, and frameworks like JQuery and MooTools will make it a lot easier.</p>
<p>www.w3schools.com is a good place to learn javascript, don't worry if you're constantly looking things up while learning it, even the best of us have to do so. And never be afraid of asking questions, that's how you learn.</p>
<p>If you know php, javascript would be relatively simple to pick up. One thing to keep in mind when using AJAX is that you remove the users ability to hit the back button or bookmark a page, because the use isn't taken to a new page.</p>
|
<p>You can use the <a href="http://exscale.se/archives/2008/01/20/ajax-submit-form-jquery-plugin/" rel="nofollow noreferrer">ajaxSubmit</a> plugin for jQuery.</p>
<p>After you include jquery and the plugin in the html you just add</p>
<pre><code>$(document).ready(function () {
$('form').ajaxSubmit('#result');
});
</code></pre>
<p>Where "result" is the id of the div where you want the results to go.</p>
| 35,614
|
<p>Currently, I am splitting all my tests by package (projects). So if I have 12 projects, I will create 1 more project for Unit Test with 12 classes that will test all my package. </p>
<p>Do you do the same way or do you have 1 testing class by class? How do you organize all your test?</p>
|
<p>Like Pokus my tests are in the same assembly as the classes to test so I can test internals and privates. </p>
<p>In C# you have Debug and Release builds, I add another called UnitTest with a compiler directive UNITTEST. I can then add the directive(#if UNITTEST) at the top of the test class, so that when I compile Debug or Release the tests are not compiled in, but when I compile UnitTest they are. </p>
<p>I add a folder called Tests that contain my test classes. Class1.cs has a test class Tests\Class1UnitTest.cs.</p>
<p>Maybe better ways, but this works for me.</p>
|
<p>We do one-to-one test assemblies (C#). For each assembly in a solution, we have a corresponding test project. Each project has a test for each class in the corresponding project.</p>
<p>For example:</p>
<p>Company.Product.Feature<br />
ClassnameAlpha<br />
ClassnameBeta<br />
ClassnameDelta<br /></p>
<p>Company.Product.Feature.UnitTests<br />
ClassnameAlphaTests<br />
ClassnameBetaTests<br />
ClassnameDeltaTests<br /></p>
<p>I take what xando does a bit further. Instead of using the default Debug/Release configurations, I have a configuration for each of the branches that we use for build configurations in Team Foundation Server. So, I have Development, Integration, and Production. Without getting into mind-numbingly boring specifics, the unit tests are built for the Development and Integration configurations. They are included in the Production branch, but not compiled with the build. The reason that they are included is for when we have to branch off of Production (a hotfix, for example) the unit tests can be ran, modified, and reverse-integrated with the modified code.</p>
<p>We currently only have a small subset of the team using this right now, as we are in the process of migrating from a legacy product and version control system, but so far it works well. The unit testing aspect of it works especially well, so far.</p>
| 38,741
|
<p>I'm required to write documentation for my current project that lists all .c files and for each one lists every .h file which is directly or indirectly included by that file.</p>
<p>This is a large project, and although we have Makefiles which theoretically have this information, those Makefiles are sometimes incorrect (we inherited this project from another company). We've often had to do a <code>make clean ; make</code> for our changes to actually be reflected in the recompilation, so I don't want to rely on these Makefiles.</p>
<p>So is there a tool which lets us give it the name of a .c file and an include path and have it tell us all of the .h files which are directly or indirectly included by the .c file? We don't have anything weird like</p>
<pre><code>#define my_include "some_file.h"
#include my_include
</code></pre>
<p>so the tool doesn't need to be perfect. Anything that searched .c and .h files in an include path for regular includes would be good enough.</p>
|
<p>What I do in my Makefile is</p>
<pre><code>SRCS=$(wildcard *.c)
depend: $(SRCS)
gcc -M $(CFLAGS) $(SRCS) >depend
include depend
</code></pre>
<p>This means that if any of the source files are updated, the depend rule will run, and use gcc -M to update the file called depend. This is then included in the makefile to provide the dependency rules for all the source files.</p>
<p>Make will check that a file is up to date before including it, so this depend rule will run if necessary whenever you run make without you needing to do a "make depend".</p>
<p>This will run any time any file has changed. I've never found this a problem, but if you had a huge number of files in the directory you might find it took too long, in which case you could try having one dependency file per source file, like this:</p>
<pre><code>SRCS=$(wildcard *.c)
DEPS=$(SRCS:.c=.dep)
%.dep : %.c
gcc -M $(CFLAGS) $< >$@
include $(DEPS)
</code></pre>
<p>Note that you can use -MM instead of -M to not include system headers.</p>
|
<p>In MSVC (2005 and 2008 at least, possibly other versions as well but not VC6) you can get the compiler to tell you all the files that were included during compilation. The output is quite verbose, but complete and fairly easy to parse with human eyes.</p>
<p>In Project Settings, go to the C/C++>Advanced tab, and toggle "Show Includes," then rebuild your project from the ground up.</p>
| 25,086
|
<p>The background should be transparent, but the text should not.</p>
|
<p>By making an "Enso style" application you mean the Enso launcher?</p>
<p>Here is a screenshot of it:
<a href="http://enscreenshots.softonic.com/s2en/68000/68880/3_ensolauncher03.jpg" rel="nofollow noreferrer">alt text http://enscreenshots.softonic.com/s2en/68000/68880/3_ensolauncher03.jpg</a></p>
<p>I would suggest at looking at the open-source C# <a href="http://www.codeplex.com/cropper" rel="nofollow noreferrer">Cropper</a> application. He does a similar looking GUI with transparent background. You can open up his project and see how he implements it.</p>
<p><a href="http://img352.imageshack.us/img352/726/cropperuijt3.png" rel="nofollow noreferrer">alt text http://img352.imageshack.us/img352/726/cropperuijt3.png</a></p>
|
<p>You can set the background color, and transparency key properties to the same color and that will make the background transparent. The rest of the control items will stay non-transparent, as long as they are different colors.</p>
| 13,636
|
<p>PHP 4.4 and PHP 5.2.3 under Apache 2.2.4 on ubuntu.</p>
<p>I am running Moodle 1.5.3 and have recently had a problem when updating a course. The $_POST variable is empty but only if a lot of text was entered into the textarea on the form. If only a short text is entered it works fine.</p>
<p>I have increased the post_max_size from 8M to 200M and increased the memory_limit to 256M but this has not helped.
I have doubled the LimitRequestFieldSize and LimitRequestLine to 16380 and set LimitRequestBody to 0 with no improvement.</p>
<p>I have googled for an answer but have been unable to find one.</p>
<p>HTTP Headers on firefox shows the content size of 3816 with the correct data, so its just not getting to $_POST.</p>
<p>The system was running fine until a few weeks ago. The only change was to /etc/hosts to correct a HELO issue with the exim4 email server.</p>
<p>I can replicate the issue on a development machine that has exim4 not running so I think it is just coincidence.</p>
<p>Thanks for your assistance.</p>
|
<p>I don't know enough to really provide a useful answer so the following is more a well-educated guess (at least I hope so).</p>
<p>First, you should debug the entire request, either by access_log or for example through <a href="http://www.getfirebug.com/" rel="nofollow noreferrer">firebug</a>. (Good to have Firebug anyway.) To me your problem <em>sounds</em> like a redirect happens in between. I give you an example:</p>
<p>Assume this is your structure:</p>
<pre><code>/form.php
/directory/index.php
</code></pre>
<p>This is your form:</p>
<pre><code><form action="/directory" method="post">
...
</form>
</code></pre>
<p>Problem in this case is, that even though <code>/directory</code> is a valid url, Apache will redirect you one more time to <code>/directory/</code>, thus you are loosing your payload (what is supposed to be in <code>$_POST</code>).</p>
|
<p>It sounds like an Apache or Apache/PHP integration problem. If $_POST is empty it would hint that the http server is not giving the POST information to PHP. If I were you I'd investigate the Apache configuration.</p>
| 28,381
|
<p>I have a VS2005 solution which contains a variety of projects (C++ DLLs, C++ static libraries, C# assemblies, C++ windows executables) that are combined in various ways to produce several executables. For some reason, every time I open the solution, VS2005 wants to check out one of the projects for editing. The project is not modified in any way, it's just checked out. If I configure VS2005 to prompt before checking out, I can cancel the auto-checkout during load with no ill effect that I can see. It may or may not be relevant, but the project it keeps checking out is cppunit version 1.12.0 (the static lib version). How can I stop this annoying behavior?</p>
<p>Other potentially relevant (or not) details:</p>
<ul>
<li>Source control is Team Foundation Server (not Visual SourceSafe)</li>
<li>no .suo or .ncb files are checked in</li>
<li>the .vcproj and .vspscc files are being checked out</li>
<li>When I close the solution or shut down Visual Studio, I'm asked whether I want to save changes to the project. Answering yes results in no changes to the file (Kdiff3 compares my local file to the server version and reports"files are binary equal")</li>
<li>Attempting to check in the "modified" files results in a Visual Studio message saying "No Changes to Check In. All of the changes were either unmodified files or locks. The changes have been undone by the server"</li>
</ul>
|
<p>As Charles and Graeme have hinted at, Visual Studio constantly make changes to user option files and such on the backed even if you don't make changes to the project directly.</p>
<p>I'm not sure what information is being stored but I do know that it happens. Common remedies is to not include the *.suo files. I also don't stored anything in the bin or obj folders in sauce control as this can have a similar effect as your talking about (if you build). (Checks out the project upon a build. Thought this does take an action to happen). </p>
<p>Overall it is unavoidable. It is just how VS2005, 2008 work.</p>
<p>Does this answer your question?</p>
<p>Regards,
Frank</p>
|
<p>Have you put a .suo or .ncb file into source control perhaps?</p>
| 12,754
|
<p>If I have a Django form such as:</p>
<pre><code>class ContactForm(forms.Form):
subject = forms.CharField(max_length=100)
message = forms.CharField()
sender = forms.EmailField()
</code></pre>
<p>And I call the as_table() method of an instance of this form, Django will render the fields as the same order as specified above.</p>
<p>My question is how does Django know the order that class variables where defined? </p>
<p>(Also how do I override this order, for example when I want to add a field from the classe's <strong>init</strong> method?)</p>
|
<p><strong>[NOTE: this answer is now pretty completely outdated - please see the discussion below it, and more recent answers].</strong></p>
<p>If <code>f</code> is a form, its fields are <code>f.fields</code>, which is a <code>django.utils.datastructures.SortedDict</code> (it presents the items in the order they are added). After form construction f.fields has a keyOrder attribute, which is a list containing the field names in the order they should be presented. You can set this to the correct ordering (though you need to exercise care to ensure you don't omit items or add extras).</p>
<p>Here's an example I just created in my current project:</p>
<pre><code>class PrivEdit(ModelForm):
def __init__(self, *args, **kw):
super(ModelForm, self).__init__(*args, **kw)
self.fields.keyOrder = [
'super_user',
'all_districts',
'multi_district',
'all_schools',
'manage_users',
'direct_login',
'student_detail',
'license']
class Meta:
model = Privilege
</code></pre>
|
<p>It has to do with the meta class that is used in defining the form class. I think it keeps an internal list of the fields and if you insert into the middle of the list it might work. It has been a while since I looked at that code.</p>
| 45,664
|
<p>Rather than rewriting the entire contents of an xml file when a single element is updated, is there a better alternative to updating the file?</p>
|
<p>I would recommend using VTD-XML <a href="http://vtd-xml.sourceforge.net/" rel="noreferrer">http://vtd-xml.sourceforge.net/</a></p>
<p>From their FAQ ( <a href="http://vtd-xml.sourceforge.net/faq.html" rel="noreferrer">http://vtd-xml.sourceforge.net/faq.html</a> ):</p>
<blockquote>
<p>Why should I use VTD-XML for large XML files?</p>
<p>For numerous reasons summarized below:</p>
<ul>
<li>Performance: The performance of VTD-XML is far better than SAX</li>
<li>Ease to use: Random access combined with XPath makes application easy to write</li>
<li>Better maintainability: App code is shorter and simpler to understand.</li>
<li>Incremental update: Occasional, small changes become very efficient.</li>
<li>Indexing: Pre-parsed form of XML will further boost processing performance.</li>
<li>Other features: Cut, paste, split and assemble XML documents is only possible with VTD-XML.</li>
</ul>
<p>In order to take advantage of VTD-XML, we recommended that developers split their ultra large XML documents into smaller, more manageable chucks (<2GB). </p>
</blockquote>
|
<p><strong>Process Large XML Files with XQuery Works with Gigabyte Size XML Files</strong>
<a href="http://www.xquery.com" rel="nofollow noreferrer">http://www.xquery.com</a></p>
<p>XQuery is a query language that was designed as a native XML query language. Because most types of data can be represented as XML, XQuery can also be used to query other types of data. For example, XQuery can be used to query relational data using an XML view of a relational database. This is important because many Internet applications need to integrate information from multiple sources, including data found in web messages, relational data, and various XML sources. XQuery was specifically designed for this kind of data integration.</p>
<p>For example, suppose your company is a financial institution that needs to produce reports of stock holdings for each client. A client requests a report with a Simple Object Access Protocol (SOAP) message, which is represented in XML. In most businesses, the stock holdings data is stored in multiple relational databases, such as Oracle, Microsoft SQL Server, or DB2. XQuery can query both the SOAP message and the relational databases, creating a report in XML.</p>
<p>XQuery is based on the structure of XML and leverages that structure to make it possible to perform queries on any type of data that can be represented as XML, including relational data. In addition, XQuery API for Java (XQJ) lets your queries run in any environment that supports the J2EE platform.</p>
| 8,783
|
<p>I've been raised to believe that if multiple threads can access a variable, then all reads from and writes to that variable must be protected by synchronization code, such as a "lock" statement, because the processor might switch to another thread halfway through a write.</p>
<p>However, I was looking through System.Web.Security.Membership using Reflector and found code like this:</p>
<pre><code>public static class Membership
{
private static bool s_Initialized = false;
private static object s_lock = new object();
private static MembershipProvider s_Provider;
public static MembershipProvider Provider
{
get
{
Initialize();
return s_Provider;
}
}
private static void Initialize()
{
if (s_Initialized)
return;
lock(s_lock)
{
if (s_Initialized)
return;
// Perform initialization...
s_Initialized = true;
}
}
}
</code></pre>
<p>Why is the s_Initialized field read outside of the lock? Couldn't another thread be trying to write to it at the same time? <strong>Are reads and writes of variables atomic?</strong> </p>
|
<p>For the definitive answer go to the spec. :)</p>
<p>Partition I, Section 12.6.6 of the CLI spec states: "A conforming CLI shall guarantee that read and write access to properly aligned memory locations no larger than the native word size is atomic when all the write accesses to a location are the same size."</p>
<p>So that confirms that s_Initialized will never be unstable, and that read and writes to primitve types smaller than 32 bits are atomic.</p>
<p>In particular, <code>double</code> and <code>long</code> (<code>Int64</code> and <code>UInt64</code>) are <strong>not</strong> guaranteed to be atomic on a 32-bit platform. You can use the methods on the <code>Interlocked</code> class to protect these.</p>
<p>Additionally, while reads and writes are atomic, there is a race condition with addition, subtraction, and incrementing and decrementing primitive types, since they must be read, operated on, and rewritten. The interlocked class allows you to protect these using the <code>CompareExchange</code> and <code>Increment</code> methods.</p>
<p>Interlocking creates a memory barrier to prevent the processor from reordering reads and writes. The lock creates the only required barrier in this example.</p>
|
<p>Ack, nevermind... as pointed out, this is indeed incorrect. It doesn't prevent a second thread from entering the "initialize" code section. Bah.</p>
<blockquote>
<p>You could also decorate s_Initialized with the volatile keyword and forego the use of lock entirely.</p>
</blockquote>
| 3,104
|
<p>No extracted data output to data2.txt? What goes wrong to the code?</p>
<p><strong>MyFile.txt</strong></p>
<pre><code>ex1,fx2,xx1
mm1,nn2,gg3
EX1,hh2,ff7
</code></pre>
<p>This is my desired output in data2.txt:</p>
<pre><code>ex1,fx2,xx1
EX1,hh2,ff7
</code></pre>
<p><br></p>
<pre><code>#! /DATA/PLUG/pvelasco/Softwares/PERLINUX/bin/perl -w
my $infile ='My1.txt';
my $outfile ='data2.txt';
open IN, '<', $infile or die "Cant open $infile:$!";
open OUT, '>', $outfile or die "Cant open $outfile:$!";
while (<IN>) {
if (m/EX$HF|ex$HF/) {
print OUT $_, "\n";
print $_;
}
}
close IN;
close OUT;
</code></pre>
|
<p>This regex makes no sense:</p>
<pre><code>m/EX$HF|ex$HF/
</code></pre>
<p>Is $HF supposed to be a variable? What are you trying to match? </p>
<p>Also, the second line in <em>every</em> Perl script you write should be:</p>
<pre><code>use strict;
</code></pre>
<p>It will make Perl catch such mistakes and tell you about them, rather than silently ignoring them.</p>
|
<p>When I run your code, but name the input file <code>My1.txt</code> instead of <code>MyFile.txt</code> I get the desired output - except with empty lines, which you can remove by removing the <code>, "\n"</code> from the print statement.</p>
| 25,952
|
<p>In SQL you can use </p>
<p>SELECT * FROM INFORMATION_SCHEMA.TABLES </p>
<p>etc to get information about the database structure. I need to know how to achieve the same thing for an Access database.</p>
|
<p>The equivalent operation can be accomplished using </p>
<p>OleDbConnection.GetOleDbSchemaTable() method.</p>
<p>see <a href="http://support.microsoft.com/kb/309488" rel="noreferrer">http://support.microsoft.com/kb/309488</a> for more information</p>
|
<p>In OLEDB it can be accessed as DBSCHEMA_TABLES. Following C++ code demonstrates the retrieval of the tables information from an OLEDB provider:</p>
<pre><code>#include <atldb.h>
...
// Standard way of obtaining table node info.
CAccessorRowset<CDynamicAccessor, CBulkRowset> pRS;
pRS.SetRows(100);
CSchemaTables<CSession>* pBogus;
hr = session.CreateSchemaRowset(NULL, 0, NULL, IID_IRowset, 0, NULL, (IUnknown**)&pRS.m_spRowset, pBogus);
if (FAILED(hr))
goto lblError;
hr = pRS.Bind();
if (FAILED(hr))
goto lblError;
hr = pRS.MoveFirst();
if (FAILED(hr))
goto lblError;
while (S_OK == hr)
{
wstring sTableSchema(pRS.GetWCharValue(L"TABLE_SCHEMA"));
wstring sTableName(pRS.GetWCharValue(L"TABLE_NAME"));
wstring sTableType(pRS.GetWCharValue(L"TABLE_TYPE"));
...
hr = pRS.MoveNext();
}
pRS.Close();
</code></pre>
| 14,359
|
<p>They both seem to be sending data to the server inside the body, so what makes them different?</p>
|
<p><strong>HTTP PUT:</strong></p>
<p>PUT puts a file or resource at a specific URI, and exactly at that URI. If there's already a file or resource at that URI, PUT replaces that file or resource. If there is no file or resource there, PUT creates one. PUT is <a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-idempotent-methods" rel="noreferrer">idempotent</a>, but paradoxically PUT responses are not cacheable.</p>
<p><a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-put" rel="noreferrer">HTTP 1.1 RFC location for PUT</a></p>
<p><strong>HTTP POST:</strong></p>
<p>POST sends data to a specific URI and expects the resource at that URI to handle the request. The web server at this point can determine what to do with the data in the context of the specified resource. The POST method is not <a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-idempotent-methods" rel="noreferrer">idempotent</a>, however POST responses <em>are</em> cacheable so long as the server sets the appropriate Cache-Control and Expires headers.</p>
<p>The official HTTP RFC specifies POST to be:</p>
<ul>
<li>Annotation of existing resources;</li>
<li>Posting a message to a bulletin board, newsgroup, mailing list,
or similar group of articles;</li>
<li>Providing a block of data, such as the result of submitting a
form, to a data-handling process;</li>
<li>Extending a database through an append operation.</li>
</ul>
<p><a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-post" rel="noreferrer">HTTP 1.1 RFC location for POST</a></p>
<p><strong>Difference between POST and PUT:</strong></p>
<p>The RFC itself explains the core difference:</p>
<blockquote>
<p>The fundamental difference between the
POST and PUT requests is reflected in
the different meaning of the
Request-URI. The URI in a POST request
identifies the resource that will
handle the enclosed entity. That
resource might be a data-accepting
process, a gateway to some other
protocol, or a separate entity that
accepts annotations. In contrast, the
URI in a PUT request identifies the
entity enclosed with the request --
the user agent knows what URI is
intended and the server MUST NOT
attempt to apply the request to some
other resource. If the server desires
that the request be applied to a
different URI, it MUST send a 301 (Moved Permanently) response; the user agent MAY then make
its own decision regarding whether or not to redirect the request.</p>
</blockquote>
<p>Additionally, and a bit more concisely, <a href="https://www.rfc-editor.org/rfc/rfc7231#section-4.3.4" rel="noreferrer">RFC 7231 Section 4.3.4 PUT</a> states (emphasis added),</p>
<blockquote>
<p><strong>4.3.4. PUT</strong></p>
<p>The PUT method requests that the state of the target resource be
<code>created</code> or <code>replaced</code> with the state defined by the representation
enclosed in the request message payload.</p>
</blockquote>
<p><strong>Using the right method, unrelated aside:</strong></p>
<p>One benefit of <a href="http://en.wikipedia.org/wiki/Resource_oriented_architecture" rel="noreferrer">REST ROA</a> vs SOAP is that when using HTTP REST ROA, it encourages the proper usage of the HTTP verbs/methods. So for example you would only use PUT when you want to create a resource at that exact location. And you would never use GET to create or modify a resource.</p>
|
<p>Both PUT and POST are Rest Methods .</p>
<p>PUT - If we make the same request twice using PUT using same parameters both times, the second request will not have any effect. This is why PUT is generally used for the Update scenario,calling Update more than once with the same parameters doesn't do anything more than the initial call hence PUT is idempotent. </p>
<p>POST is not idempotent , for instance Create will create two separate entries into the target hence it is not idempotent so CREATE is used widely in POST.</p>
<p>Making the same call using POST with same parameters each time will cause two different things to happen, hence why POST is commonly used for the Create scenario </p>
| 13,287
|
<p>A client of mine has asked me to integrate a 3rd party API into their Rails app. The only problem is that the API uses SOAP. Ruby has basically dropped SOAP in favor of REST. They provide a Java adapter that apparently works with the Java-Ruby bridge, but we'd like to keep it all in Ruby, if possible. I looked into soap4r, but it seems to have a slightly bad reputation.</p>
<p>So what's the best way to integrate SOAP calls into a Rails app?</p>
|
<p>I built <a href="http://savonrb.com" rel="noreferrer">Savon</a> to make interacting with SOAP webservices via Ruby as easy as possible.<br>
I'd recommend you check it out.</p>
|
<p>I was having the same issue, switched to Savon and then just tested it on an open WSDL (I used <a href="http://www.webservicex.net/geoipservice.asmx?WSDL" rel="nofollow">http://www.webservicex.net/geoipservice.asmx?WSDL</a>) and so far so good!</p>
<p><a href="https://github.com/savonrb/savon" rel="nofollow">https://github.com/savonrb/savon</a></p>
| 6,150
|
<p>I re-read my question and realized I made a confusing one, so I am rewording a LOT.</p>
<p>So the software I use is Craftware. When it comes to the first layer I have it set to .25mm, with the following layers being whatever I specify otherwise. And because of this there shouldn't be a difference with the first layer even though I choose different layer heights based on the project. But for some reason it is not the case. </p>
<p>When printing .2mm layer height everything works great. The print adheres amazing, the nozzle is at a really good height. Everything simply works. </p>
<p>When printing .1mm the first layer does not stick. A lot less plastic is coming out the nozzle. And it is a disaster. Have tried increasing the amount of flow a bit, but didn't help (I might need to raise it a lot more)</p>
<p>So I don't understand what is going wrong. The first layer is supposed to be set at .25mm no matter what the layer height is otherwise. What do I need to do or look at? </p>
|
<p>You likely need to re-calibrate the Z-height of your nozzle. The reason that a lot less plastic is coming out of the nozzle at 0.1mm is that the actual gap is likely smaller than 0.1mm. This makes the print bed act essentially like a partial "lid" on the nozzle which occludes the outflow of molten plastic. </p>
<p>Simplify3D has information on their website regarding the issue which can be found here: <a href="https://www.simplify3d.com/support/print-quality-troubleshooting/#not-extruding-at-start-of-print" rel="nofollow noreferrer">https://www.simplify3d.com/support/print-quality-troubleshooting/#not-extruding-at-start-of-print</a>. Hope this helps!</p>
|
<p>You have asked several questions here. </p>
<p>"why is first layer set to 0.25" -- check the gcode file, opening it in a text editor, to see what layer values are specified. </p>
<p>"looks like under-extrude" -- please show a picture. If it's purely that the print failing to adhere, you may need to adjust the Z-zero point slightly. Or perhaps When you printed at 0.2mm, for whatever reason the transverse stress on the base layer is less than when printing at 0.1 mm (e.g., linear speed adjustments needed).<br>
Is the second layer somehow not adhering to the first layer? It is possible that the linear speed setting for the first layer is too high and that should be adjusted. Or perhaps the z-height for the second layer is inconsistent with a 0.1mm layer setting, so check the gcode there too. </p>
<p>In general, adherence problems can be dealt with by adding a raft or brim. See if that suffices.</p>
| 852
|
<p>My goal here is to create a very simple template language. At the moment, I'm working on replacing a variable with a value, like this:</p>
<p>This input:</p>
<blockquote>
The Web
</blockquote>
<p>Should produce this output:</p>
<blockquote>
<p>The Web This Is A Test Variable</p>
</blockquote>
<p>I've got it working. But looking at my code, I'm running multiple identical regexes on the same strings -- that just offends my sense of efficiency. There's got to be a better, more Pythonic way. (It's the two "while" loops that really offend.)</p>
<p>This does pass the unit tests, so if this is silly premature optimization, tell me -- I'm willing to let this go. There may be dozens of these variable definitions and uses in a document, but not hundreds. But I suspect there's obvious (to other people) ways of improving this, and I'm curious what the StackOverflow crowd will come up with.</p>
<pre><code>def stripMatchedQuotes(item):
MatchedSingleQuotes = re.compile(r"'(.*)'", re.LOCALE)
MatchedDoubleQuotes = re.compile(r'"(.*)"', re.LOCALE)
item = MatchedSingleQuotes.sub(r'\1', item, 1)
item = MatchedDoubleQuotes.sub(r'\1', item, 1)
return item
def processVariables(item):
VariableDefinition = re.compile(r'<%(.*?)=(.*?)%>', re.LOCALE)
VariableUse = re.compile(r'<%(.*?)%>', re.LOCALE)
Variables={}
while VariableDefinition.search(item):
VarName, VarDef = VariableDefinition.search(item).groups()
VarName = stripMatchedQuotes(VarName).upper().strip()
VarDef = stripMatchedQuotes(VarDef.strip())
Variables[VarName] = VarDef
item = VariableDefinition.sub('', item, 1)
while VariableUse.search(item):
VarName = stripMatchedQuotes(VariableUse.search(item).group(1).upper()).strip()
item = VariableUse.sub(Variables[VarName], item, 1)
return item
</code></pre>
|
<p>The first thing that may improve things is to move the re.compile outside the function. The compilation is cached, but there is a speed hit in checking this to see if its compiled.</p>
<p>Another possibility is to use a single regex as below:</p>
<pre><code>MatchedQuotes = re.compile(r"(['\"])(.*)\1", re.LOCALE)
item = MatchedQuotes.sub(r'\2', item, 1)
</code></pre>
<p>Finally, you can combine this into the regex in processVariables. Taking <a href="https://stackoverflow.com/questions/146607/im-using-python-regexes-in-a-criminally-inefficient-manner#146683">Torsten Marek's</a> suggestion to use a function for re.sub, this improves and simplifies things dramatically.</p>
<pre><code>VariableDefinition = re.compile(r'<%(["\']?)(.*?)\1=(["\']?)(.*?)\3%>', re.LOCALE)
VarRepl = re.compile(r'<%(["\']?)(.*?)\1%>', re.LOCALE)
def processVariables(item):
vars = {}
def findVars(m):
vars[m.group(2).upper()] = m.group(4)
return ""
item = VariableDefinition.sub(findVars, item)
return VarRepl.sub(lambda m: vars[m.group(2).upper()], item)
print processVariables('<%"TITLE"="This Is A Test Variable"%>The Web <%"TITLE"%>')
</code></pre>
<p>Here are my timings for 100000 runs:</p>
<pre><code>Original : 13.637
Global regexes : 12.771
Single regex : 9.095
Final version : 1.846
</code></pre>
<p>[Edit] Add missing non-greedy specifier</p>
<p>[Edit2] Added .upper() calls so case insensitive like original version</p>
|
<p>Why not use XML and XSLT instead of creating your own template language? What you want to do is pretty easy in XSLT.</p>
| 17,653
|
<p>I am wondering if it is possible to use LINQ to pivot data from the following layout:</p>
<pre><code>CustID | OrderDate | Qty
1 | 1/1/2008 | 100
2 | 1/2/2008 | 200
1 | 2/2/2008 | 350
2 | 2/28/2008 | 221
1 | 3/12/2008 | 250
2 | 3/15/2008 | 2150
</code></pre>
<p>into something like this:</p>
<pre><code>CustID | Jan- 2008 | Feb- 2008 | Mar - 2008 |
1 | 100 | 350 | 250
2 | 200 | 221 | 2150
</code></pre>
|
<p>Something like this?</p>
<pre><code>List<CustData> myList = GetCustData();
var query = myList
.GroupBy(c => c.CustId)
.Select(g => new {
CustId = g.Key,
Jan = g.Where(c => c.OrderDate.Month == 1).Sum(c => c.Qty),
Feb = g.Where(c => c.OrderDate.Month == 2).Sum(c => c.Qty),
March = g.Where(c => c.OrderDate.Month == 3).Sum(c => c.Qty)
});
</code></pre>
<p><code>GroupBy</code> in Linq does not work the same as SQL. In SQL, you get the key and aggregates (row/column shape). In Linq, you get the key and any elements as children of the key (hierarchical shape). To pivot, you must project the hierarchy back into a row/column form of your choosing.</p>
|
<p>Group your data on month, and then project it into a new datatable with columns for each month. The new table would be your pivot table.</p>
| 20,206
|
<p>On a cross platform c/c++ project (Win32, Linux, OSX), I need to use the *printf functions to print some variables of type size_t. In some environments size_t's are 8 bytes and on others they are 4. On glibc I have %zd, and on Win32 I can use <a href="http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx" rel="noreferrer">%Id</a>. Is there an elegant way to handle this?</p>
|
<p>The <code>PRIuPTR</code> macro (from <inttypes.h>) defines a decimal format for <code>uintptr_t</code>, which should always be large enough that you can cast a <code>size_t</code> to it without truncating, e.g.</p>
<pre><code>fprintf(stream, "Your size_t var has value %" PRIuPTR ".", (uintptr_t) your_var);
</code></pre>
|
<p><code>size_t</code> is an <em>unsigned</em> type of at least 16 bits. Widths of 32 and 64 are often seen.</p>
<pre><code>printf("%zu\n", some_size_t_object); // Standard since C99
</code></pre>
<p>Above is the best way going forward, yet if code needs to also port to pre-C99 platforms, covert the value to some wide type. <code>unsigned long</code> is reasonable candidate yet may be lacking.</p>
<pre><code>// OK, yet insufficient with large sizes > ULONG_MAX
printf("%lu\n", (unsigned long) some_size_t_object);
</code></pre>
<p>or with conditional code</p>
<pre><code>#ifdef ULLONG_MAX
printf("%llu\n", (unsigned long long) some_size_t_object);
#else
printf("%lu\n", (unsigned long) some_size_t_object);
#endif
</code></pre>
<p>Lastly consider <code>double</code>. It is a bit inefficient yet should handle all ancient and new platforms until about the years 2030-2040 considering <a href="https://softwareengineering.stackexchange.com/q/38213/94903">Moore's law</a> when <code>double</code> may lack a precise result.</p>
<pre><code>printf("%.0f\n", (double) some_size_t_object);
</code></pre>
| 21,048
|
<p>I want to do something like this:</p>
<pre><code>List<Animal> animals = new ArrayList<Animal>();
for( Class c: list_of_all_classes_available_to_my_app() )
if (c is Animal)
animals.add( new c() );
</code></pre>
<p>So, I want to look at all of the classes in my application's universe, and when I find one that descends from Animal, I want to create a new object of that type and add it to the list. This allows me to add functionality without having to update a list of things. I can avoid the following:</p>
<pre><code>List<Animal> animals = new ArrayList<Animal>();
animals.add( new Dog() );
animals.add( new Cat() );
animals.add( new Donkey() );
...
</code></pre>
<p>With the above approach, I can simply create a new class that extends Animal and it'll get picked up automatically.</p>
<p>UPDATE: 10/16/2008 9:00 a.m. Pacific Standard Time:</p>
<p>This question has generated a lot of great responses -- thank you. <s>From the responses and my research, I've found that what I really want to do is just not possible under Java. There are approaches, such as ddimitrov's ServiceLoader mechanism that can work -- but they are very heavy for what I want, and I believe I simply move the problem from Java code to an external configuration file.</s> <strong>Update 5/10/19</strong> (11 years later!) There are now several libraries that can help with this according to @IvanNik's <a href="https://stackoverflow.com/a/9240969/9648">answer</a> <a href="https://github.com/ronmamo/reflections" rel="noreferrer">org.reflections</a> looks good. Also <a href="https://github.com/classgraph/classgraph" rel="noreferrer">ClassGraph</a> from @Luke Hutchison's <a href="https://stackoverflow.com/a/51625104/9648">answer</a> looks interesting. There are several more possibilities in the answers as well.</p>
<p>Another way to state what I want: a static function in my Animal class finds and instantiates all classes that inherit from Animal -- without any further configuration/coding. If I have to configure, I might as well just instantiate them in the Animal class anyway. I understand that because a Java program is just a loose federation of .class files that that's just the way it is.</p>
<p>Interestingly, it seems this is <a href="http://my.safaribooksonline.com/0596003390/csharpckbk-CHP-12-SECT-8" rel="noreferrer">fairly trivial</a> in C#.</p>
|
<p>I use <a href="https://github.com/ronmamo/reflections" rel="noreferrer">org.reflections</a>:</p>
<pre><code>Reflections reflections = new Reflections("com.mycompany");
Set<Class<? extends MyInterface>> classes = reflections.getSubTypesOf(MyInterface.class);
</code></pre>
<p>Another example:</p>
<pre><code>public static void main(String[] args) throws IllegalAccessException, InstantiationException {
Reflections reflections = new Reflections("java.util");
Set<Class<? extends List>> classes = reflections.getSubTypesOf(java.util.List.class);
for (Class<? extends List> aClass : classes) {
System.out.println(aClass.getName());
if(aClass == ArrayList.class) {
List list = aClass.newInstance();
list.add("test");
System.out.println(list.getClass().getName() + ": " + list.size());
}
}
}
</code></pre>
|
<p>This is a tough problem and you will need to find out this information using static analysis, its not available easily at runtime.
Basically get the classpath of your app and scan through the available classes and read the bytecode information of a class which class it inherits from. Note that a class Dog may not directly inherit from Animal but might inherit from Pet which is turn inherits from Animal,so you will need to keep track of that hierarchy.</p>
| 25,186
|
<p>I have the following project solution:</p>
<ul>
<li><p>There is a ASP.NET MVC Web
Application where I have a SQL
database (mdf file) in the App_Data directory.</p></li>
<li><p>There is a class library where I
have some migrations from
<a href="http://code.google.com/p/migratordotnet/" rel="nofollow noreferrer">migratordotnet</a>. In my build file I
have to specify where the SQL
database is so it can run the
migrations.</p></li>
</ul>
<p>For the moment on the migration project I'm using a <strong><em>hardcoded path</em></strong> to access the SQL database in the connection string. It looks sort of like this:</p>
<pre><code>connectionString="Data Source=.\SQLExpress; Integrated Security=true; AttachDbFilename=C:\MySolution\MyMVCProject\App_Data\MyDatabase.mdf"
</code></pre>
<p>This is not how I want to do. I also cannot use relative paths (such as <code>..\MyMVCPProject\AppData\MyDatabase.mdf</code> because the SQL classes used in migratordotnet won't be able to translate it right) But I want to use some kind of a substitute path to it, sort of what you'll find with <code>|DataDirectory|</code> in the <code>Web.Config</code> in the web project like this:</p>
<pre><code>connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyDatabase.mdf;Integrated Security=True;User Instance=True"
</code></pre>
<p>How do I do achieve this? I can't use that connection string in the migration project. Because the <code>|DataDirectory|</code> will go to .NET Framework installation path and look for the database file there.</p>
|
<p>One icon for user account, another icon is for group account. </p>
|
<p>Connect permission has been revoked and Connect permission has been denied are both correct. The only way I've found to cause the red arrow is for the user to NOT have connect access to the database. </p>
<p>Source SQL Server QOTD - 2 July 2014 (Andy Warren)</p>
| 49,868
|
<p>I'm trying to convert an Excel document into a table in SQL 2005. I found the link below and am wondering if it looks like a solution. If so, what would the @excel_full_file_name syntax be and where would the path be relative to? </p>
<p><a href="http://www.siccolo.com/Articles/SQLScripts/how-to-create-sql-to-convert-Excel_to_table.html" rel="nofollow noreferrer">http://www.siccolo.com/Articles/SQLScripts/how-to-create-sql-to-convert-Excel_to_table.html</a></p>
|
<p>You can use the BULK INSERT T-SQL command if you just want a pure sql solution. You have to save the file as csv/text first.</p>
<pre><code>BULK
INSERT YourDestinationTable
FROM 'D:\YourFile.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO
</code></pre>
<p>Alternatively, you can try OPENROWEST - again , a pure T-SQL solution.</p>
<pre><code>SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;DATABASE=D:\YourExcelFile.xls', 'Select * from YourExcelFile')
</code></pre>
<p>It really depends on how much control and flexibility you want, the SSIS route will have benefits over these methods.</p>
|
<p><a href="http://cheeso.members.winisp.net/srcview.aspx?dir=MSOffice&file=CopyData-SqlToExcel-TwoOledbConnections.cs" rel="nofollow noreferrer">This example</a> copies data from SQL to Excel.
But it is just a matter of swapping the OleDb providers to get it to work in the opposite direction. </p>
| 43,987
|
<p>I am asked to work on a piece of code which relies heavily on pthreads. So many calls are made to this library that I know nothing of. I have learnt the basics of pthread and have tried out a few examples like creating joining etc. but dont know the depths of it. </p>
<p>I have learnt much of it using <a href="http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html" rel="nofollow noreferrer">http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html</a></p>
<p>The above tutorial doesn't inlcude an indepth coverage of the pthread library that a beginner should need. Could u guys recommend a website or an eBook for me to have a look and learn most of the advanced stuff like signal handling, mutexes, concurrency etc.</p>
<p>TIA,
the_Saint</p>
|
<p><a href="https://hpc-tutorials.llnl.gov/posix/" rel="nofollow noreferrer">https://hpc-tutorials.llnl.gov/posix/</a></p>
<p><a href="http://en.wikipedia.org/wiki/POSIX_Threads" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/POSIX_Threads</a></p>
<p>[EDIT] First link was broken, now is fixed.</p>
|
<p>As Ankit S states above, Advanced Programming in the Unix Environment is a good source. Also, volume 2 of Unix Network Programming (also by Stevens) has a big section on posix semaphores and similar topics.</p>
| 29,482
|
<p>I'm using VS2008 Team Suite, ASP.NET MVC Beta, with TestDriven.Net installed. When I created my project from the template, it created a "Tests" project as well and put some controller tests for the AccountController in a folder inside this project. I've added other controllers and associated tests. Howerver, when I right-click on a method in a controller and use the "Create Unit Tests" dialog it fails to create the unit test stub in my existing test class in the project. It creates a new test class file with the same name at the root of the test project, but doesn't insert the test stub. If I move the controller tests up one level from the controllers folder in the test project it works fine.</p>
<p>Does anyone else see this behavior or is it something related to my particular set up? I wouldn't have noticed, but the project segregated the tests in a separate folder, which I thought was a good idea. Now that I'm trying to use it, I either have to create new tests by hand or undo the segregation. If it's just me, any ideas on where to adjust the behavior to fix it?</p>
<p>I have <code>Visual C# test project</code> selected as default in options, with <code>Unit Test</code> as the only file included.</p>
|
<p>It isn't going to very fast if you have a lot of <strong>a</strong> or <strong>b</strong> nodes but this validates against what you've described.</p>
<pre><code><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="test">
<xs:complexType>
<xs:sequence>
<xs:choice maxOccurs="unbounded">
<xs:element name="a"/>
<xs:element name="b"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</code></pre>
|
<p>If you paste the sample XML, we can help you better. However, <a href="https://stackoverflow.com/questions/288236/xsd-code-generator">Microsoft has an XSD code generator</a> that generates an XSD based on an XML file that you pass in as an argument.</p>
| 46,171
|
<p>My WinForms app uses a number of <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx" rel="noreferrer">BackgroundWorker</a> objects to retrieve information from a database. I'm using BackgroundWorker because it allows the UI to remain unblocked during long-running database queries and it simplifies the threading model for me.</p>
<p>I'm getting occasional DatabaseExceptions in some of these background threads, and I have witnessed at least one of these exceptions in a worker thread while debugging. I'm fairly confident these exceptions are timeouts which I suppose its reasonable to expect from time to time.</p>
<p>My question is about what happens when an unhandled exception occurs in one of these background worker threads.</p>
<p>I don't think I can catch an exception in another thread, but can I expect my WorkerCompleted method to be executed? Is there any property or method of the BackgroundWorker I can interrogate for exceptions?</p>
|
<p>If the operation raises an exception that your code does not handle, the <code>BackgroundWorker</code> catches the exception and passes it into the <code>RunWorkerCompleted</code> event handler, where it is exposed as the Error property of <code>System.ComponentModel.RunWorkerCompletedEventArgs</code>. If you are running under the Visual Studio debugger, the debugger will break at the point in the DoWork event handler where the unhandled exception was raised.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.dowork.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.dowork.aspx</a></p>
|
<p>As it was already noted:</p>
<blockquote>
<p>If the operation raises an exception
that your code does not handle, the
BackgroundWorker catches the exception
and passes it into the
RunWorkerCompleted event handler,
where it is exposed as the Error
property of
System.ComponentModel.RunWorkerCompletedEventArgs.</p>
</blockquote>
<p>This is important whenever you're interacting with the original thread. For example if you want the result of your exception to be written in some kind of a label on your form, that's when you mustn't catch the exception in the DoWork of the BackgroundWorker, but instead handle the e.Error from RunWorkerCompletedEventArgs.</p>
<p>If you analyze the BackgroundWorker code with reflector you can see its all handled pretty straightforward:
Your DoWork gets executed in a try-catch block, and the exception is just passed to RunWorkerCompleted.
Which is the reason why I disagree with the 'preferred' method of always catching all your exceptions in the DoWork event.</p>
<p>In short, to answer the original question:</p>
<p><strong>Yes</strong> - you can count on your RunWorkerCompleted to always be fired.</p>
<p>Use <strong>e.Error</strong> from RunWorkerCompleted to check for exceptions in the other thread.</p>
| 32,288
|
<p>I'm a C programmer trying to understand C++. Many tutorials demonstrate object instantiation using a snippet such as:</p>
<pre><code>Dog* sparky = new Dog();
</code></pre>
<p>which implies that later on you'll do:</p>
<pre><code>delete sparky;
</code></pre>
<p>which makes sense. Now, in the case when dynamic memory allocation is unnecessary, is there any reason to use the above instead of</p>
<pre><code>Dog sparky;
</code></pre>
<p>and let the destructor be called once sparky goes out of scope?</p>
<p>Thanks!</p>
|
<p>On the contrary, you should always prefer stack allocations, to the extent that as a rule of thumb, you should never have new/delete in your user code.</p>
<p>As you say, when the variable is declared on the stack, its destructor is automatically called when it goes out of scope, which is your main tool for tracking resource lifetime and avoiding leaks.</p>
<p>So in general, every time you need to allocate a resource, whether it's memory (by calling new), file handles, sockets or anything else, wrap it in a class where the constructor acquires the resource, and the destructor releases it. Then you can create an object of that type on the stack, and you're guaranteed that your resource gets freed when it goes out of scope. That way you don't have to track your new/delete pairs everywhere to ensure you avoid memory leaks.</p>
<p>The most common name for this idiom is <a href="http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization" rel="noreferrer">RAII</a></p>
<p>Also look into smart pointer classes which are used to wrap the resulting pointers on the rare cases when you do have to allocate something with new outside a dedicated RAII object. You instead pass the pointer to a smart pointer, which then tracks its lifetime, for example by reference counting, and calls the destructor when the last reference goes out of scope. The standard library has <code>std::unique_ptr</code> for simple scope-based management, and <code>std::shared_ptr</code> which does reference counting to implement shared ownership.</p>
<blockquote>
<p>Many tutorials demonstrate object
instantiation using a snippet such as ...</p>
</blockquote>
<p>So what you've discovered is that most tutorials suck. ;)
Most tutorials teach you lousy C++ practices, including calling new/delete to create variables when it's not necessary, and giving you a hard time tracking lifetime of your allocations.</p>
|
<p>I had the same problem in Visual Studio. You have to use:</p>
<p>yourClass->classMethod();</p>
<p>rather than:</p>
<p>yourClass.classMethod();</p>
| 43,220
|
<p>I have the following legacy code:</p>
<pre><code>public class MyLegacyClass
{
private static final String jndiName = "java:comp/env/jdbc/LegacyDataSource"
public static SomeLegacyClass doSomeLegacyStuff(SomeOtherLegacyClass legacyObj)
{
// do stuff using jndiName
}
}
</code></pre>
<p>This class is working in a J2EE-Container.</p>
<p>Now I would like to test the class outside of the container.</p>
<p>What is the best strategy?
Refactoring is basically allowed.</p>
<p>Accessing the LegacyDataSource is allowed (the test does not have to be a "pure" unit-test).</p>
<p>EDIT: Introducing additional runtime-frameworks is not allowed.</p>
|
<p>Just to make @Robin's suggestion of a strategy pattern more concrete: (Notice that the public API of your original question remains unchanged.)</p>
<pre><code>public class MyLegacyClass {
private static Strategy strategy = new JNDIStrategy();
public static SomeLegacyClass doSomeLegacyStuff(SomeOtherLegacyClass legacyObj) {
// legacy logic
SomeLegacyClass result = strategy.doSomeStuff(legacyObj);
// more legacy logic
return result;
}
static void setStrategy(Strategy strategy){
MyLegacyClass.strategy = strategy;
}
}
interface Strategy{
public SomeLegacyClass doSomeStuff(SomeOtherLegacyClass legacyObj);
}
class JNDIStrategy implements Strategy {
private static final String jndiName = "java:comp/env/jdbc/LegacyDataSource";
public SomeLegacyClass doSomeStuff(SomeOtherLegacyClass legacyObj) {
// do stuff using jndiName
}
}
</code></pre>
<p>...and JUnit test. I'm not a big fan of having to do this setup/teardown maintenance, but that's an unfortunate side effect of having an API based on static methods (or Singletons for that matter). What I <em>do</em> like about this test is it does not use JNDI - that's good because (a) it'll run fast, and (b) the unit test should only be testing the business logic in doSomeLegacyStuff() method anyway, not testing the actual data source. (By the way, this assumes the test class is in the same package as MyLegacyClass.)</p>
<pre><code>public class MyLegacyClassTest extends TestCase {
private MockStrategy mockStrategy = new MockStrategy();
protected void setUp() throws Exception {
MyLegacyClass.setStrategy(mockStrategy);
}
protected void tearDown() throws Exception {
// TODO, reset original strategy on MyLegacyClass...
}
public void testDoSomeLegacyStuff() {
MyLegacyClass.doSomeLegacyStuff(..);
assertTrue(..);
}
static class MockStrategy implements Strategy{
public SomeLegacyClass doSomeStuff(SomeOtherLegacyClass legacyObj) {
// mock behavior however you want, record state however
// you'd like for test asserts. Good frameworks like Mockito exist
// to help create mocks
}
}
}
</code></pre>
|
<p>I think that the best solution here is bind that JNDI to a local </p>
<p>The legacy Code is using the jndiName like that:</p>
<pre><code>DataSource datasource = (DataSource)initialContext.lookup(DATASOURCE_CONTEXT);
</code></pre>
<p>So, The solution here is bind a local (or whatever you have for you test data) into a JNDI like that:</p>
<pre><code> BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(System.getProperty("driverClassName"));
dataSource.setUser("username");
dataSource.setPassword("password");
dataSource.setServerName("localhost");
dataSource.setPort(3306);
dataSource.setDatabaseName("databasename");
</code></pre>
<p>And then the binding:</p>
<pre><code>Context context = new InitialContext();
context.bind("java:comp/env/jdbc/LegacyDataSource",datasource);
</code></pre>
<p>Or something similar, hope that helps you.</p>
<p>Good luck!</p>
| 31,115
|
<p>I am working on a cocoa software and in order to keep the GUI responsive during a massive data import (Core Data) I need to run the import outside the main thread.</p>
<p>Is it safe to access those objects even if I created them in the main thread without using locks <strong>if</strong> I don't explicitly access those objects while the thread is running.</p>
|
<p>With Core Data, you should have a separate managed object context to use for your import thread, connected to the same coordinator and persistent store. You cannot simply throw objects created in a context used by the main thread into another thread and expect them to work. Furthermore, you cannot do your own locking for this; you must at minimum lock the managed object context the objects are in, as appropriate. But if those objects are bound to by your views a controls, there are no "hooks" that you can add that locking of the context to.</p>
<p>There's no free lunch.</p>
<p>Ben Trumbull explains some of the reasons why you need to use a separate context, and why "just reading" isn't as simple or as safe as you might think, in <a href="http://lists.apple.com/archives/webobjects-dev/2004/Dec/msg00255.html" rel="nofollow noreferrer" title="Re: locking problem">this great post from late 2004 on the webobjects-dev list</a>. (The whole thread is great.) He's discussing the Enterprise Objects Framework and WebObjects, but his advice is fully applicable to Core Data as well. Just replace "EC" with "NSManagedObjectContext" and "EOF" with "Core Data" in the meat of his message.</p>
<p>The solution to the problem of sharing data between threads in Core Data, like the Enterprise Objects Framework before it, is "don't." If you've thought about it further and you really, honestly do have to share data between threads, then the solution is to keep independent object graphs in thread-isolated contexts, and use the information in the save notification from one context to tell the other context what to re-fetch. <a href="http://developer.apple.com/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObjectContext_Class/Reference/Reference.html#//apple_ref/occ/instm/NSManagedObjectContext/refreshObject:mergeChanges:" rel="nofollow noreferrer" title="-[NSManagedObjectContext refreshObject:mergeChanges:]"><code>-[NSManagedObjectContext refreshObject:mergeChanges:]</code></a> is specifically designed to support this use.</p>
|
<p>The whole point of using locks is to ensure that two threads don't try to access the same resource. If you can guarantee that through some other mechanism, go for it.</p>
| 9,274
|
<p>I'm embedding MSBuild directly into a more complex build tool. The relevant code looks roughly like this:</p>
<pre><code>// assume 'using Microsoft.Build.BuildEngine;'
Engine e = Engine();
BuildPropertyGroup props = new BuildPropertyGroup();
props.SetProperty( "Configuration", Config.BuildConfig );
e.BuildProjectFile( projectFile, new string[] { "Build" }, props )
</code></pre>
<p>My question is how to cancel this build once it's started, without doing something drastic like terminating the thread. Also, if the project being built is a C++ project, the build will involve at least one sub-process, so canceling the thread isn't even going to really cancel the build.</p>
<p>I don't see any cancel method on the Engine class - does someone know of a way?</p>
|
<p>This question has come up a few times on the MSDN boards, and unfortunately I haven't seen any other way, apart from terminating the thread. Sadly, in this case, terminating the thread isn't really drastic with it being the only real option.</p>
<p>On a random side note, I am not sure to what extent you are using MSBuild with what you are doing currently. Just wanted to recommend taking a look at the <a href="http://www.codeplex.com/MSBuildExtensionPack" rel="nofollow noreferrer">MSBuild Extension Pack</a> on Codeplex if you work with MSBuild on a regular basis.</p>
|
<p>I had done something similar by running msbuild from command. This starts a process which you could terminate.</p>
<p>From my experience, it is far easier and flexible to manipulate the project files using xml tools and then execute msbuild than it is to programmatically configure your projects the way you have described. It is also more manageable.</p>
| 40,188
|
<p>I have a table (volunteers_2009) that has all the volunteers stored within, then I have a table (venues) that list all the different venues a volunteer could work (volunteers are assigned to one venue each, and that is stored within volunteers_2009.venue_id, which equals venues.id)</p>
<p>The venues table also has a column for emails, each email is for the chairman of each venue.</p>
<p>What I want to do is be able to automatically send each chairman an email with a CSV file of the volunteers table (volunteers_2009), and during that process, I want it to match up volunteers_2009.venue_id with venues.id and send the CSV with only the volunteers assigned to that chairman's venue, so the chairman only receives a CSV of the volunteers that were assigned to their venue.</p>
<p>I would run thru the venues table, start at the beginning, match the venues.id to volunteers_2009.venue_id, then run the CSV export function to pull all the data WHERE venue_id = #, then attach it into the email and the recipient would be venues.chair_email.</p>
<p>I already have a export CSV function, I could just pass it the venue_id to pull the appropriate volunteers, and I have a working email function as well, so I can pass it the attachment and recipient.</p>
<p>Here is a sketch of the theory of the function of functions that would get this done:
<img src="https://i.stack.imgur.com/Kn8fm.jpg" alt="alt text"></p>
<p>If you see a better way on how to go about this (if you can follow along with my poor hand writing), then please let me know, thanks.</p>
|
<p>google.com, update.microsoft.com, and other services which handle astonishingly high aggregate bandwidth do much of their magic via DNS.</p>
<p>BGP Anycast routing is used to announce the IP address of their DNS servers from multiple points around the world. Each DNS server is configured to resolve google.com to IP addresses within a data center which is geographically close. So this is the first level of load balancing, based geographically.</p>
<p>Next, though a DNS query for google.com will return only a small number of IP addresses, the DNS server rapidly cycles through a large range of addresses in its responses. Each client requesting google.com will get a particular answer and will be allowed to cache that answer for a while, but the next client will get a different IP address. So this is the second level of load balancing.</p>
<p>Third, they use traditional server load balancers to map sessions to a single IP address to multiple backend servers. So this is a third level of load balancing.</p>
|
<p>This is normal internet traffic handling. Google literally has entire data centers all over the planet that respond to www.google.com</p>
| 25,897
|
<p>Is there any way to trap an error and exit gracefully from Perl? I am working on a script which might fail due to a SIG event from the OS or other applications running on my server. I wish to trap this event, display the error and exit after closing all files and other attributes I have open during the execution of the script.</p>
|
<p>Use the %SIG hash to install signal handlers. Example:</p>
<p>$SIG{INT} = 'SigIntHandler';</p>
<p>Where SigIntHandler is a sub that you write to be called when an interrupt is caught.</p>
|
<p>See <a href="http://www.perl.com/doc/manual/html/lib/sigtrap.html" rel="nofollow noreferrer">perldoc sigtrap</a>.</p>
| 34,953
|
<p>I'm planning to write an operating system and I don't know very much about operating systems. Are there any good resources or books to read in order for me to learn? What are your recommendations?</p>
|
<p>We used Andrew Tannenbaum's <a href="https://rads.stackoverflow.com/amzn/click/com/0136006639" rel="nofollow noreferrer" rel="nofollow noreferrer">Modern Operating Systems</a> at the university I attended. I highly recommend it for it's clear explanations of the tradeoffs inherent in many of the design decisions that you'll run up against. This book is a little bit more "fair and balanced" than the Minix book.</p>
<p><a href="https://i.stack.imgur.com/Ku7PB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ku7PB.jpg" alt="alt text"></a>
</p>
<p>I also recommend this book because, despite his <a href="http://oreilly.com/catalog/opensources/book/appa.html" rel="nofollow noreferrer">net-famous flame war with Linus Torvalds</a>, few of his biases come through in the book. Also, he's a pretty decent writer, and the book is actually entertaining.</p>
|
<p>Apart from books, there are many sites that learn OS Development<br>
<a href="http://www.brokenthorn.com/Resources/OSDevIndex.html" rel="nofollow">BrokenThorn Entertainment</a> is on of this website that learn OS dev from base </p>
| 31,692
|
<p>In our app, we currently live with the legacy of a decision to store all engineering data in our database in SI.</p>
<p>I worry that we may run the risk of not having sufficient precision and accuracy in our database or in .NET numeric types. I am also worried that we may see artifacts of floating-point maths (although that is probably a question all to itself). </p>
<p>For example, the source data may have been a pressure quantity expressed (and read in from some 3rd party service) in Psi (pounds per square inch). The engineers will have chosen this unit of measure because (for the quantity being expressed) this will tend to give easily-digested, human-readable numbers without requiring scientific notation.</p>
<p>When we 'standardise' the number, i.e. when we convert this quantity for our own persistence, we might convert it to Pa (Pascals) which will require either multiplying or dividing the number by some other potentially large number.</p>
<p>We often end up storing very large or very small numbers, and worse - we might do further calculations on these numbers.</p>
<p>At present we use ORACLE float and System.Double.</p>
<p>What do people think of this?</p>
<p><strong>UPDATE</strong></p>
<p>Further research has unearthed <a href="http://blogs.msdn.com/andrewkennedy/archive/2008/08/20/units-of-measure-in-f-part-one-introducing-units.aspx" rel="nofollow noreferrer">Units of Measure support</a> in the forthcoming F# language (in CTP as I write).</p>
<p>It seems we'll be able to have F# understand user input such as:</p>
<pre><code>9.81<n/s^2> // an acceleration
</code></pre>
<p>We'll also be able to create our own derived units and unit systems.</p>
<p><a href="https://i.stack.imgur.com/xMfVf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xMfVf.png" alt="creating a derived unit for Newtons in F#"></a><br>
<sub>(source: <a href="http://blogs.msdn.com/blogfiles/andrewkennedy/WindowsLiveWriter/UnitsofMeasureinFPartOneIntroducingUnits_A131/image_thumb_11.png" rel="nofollow noreferrer">msdn.com</a>)</sub> </p>
|
<p>Keep <em>significant figures</em> in mind -- the accuracy of the measurement. If the PSI is known to only whole pounds, then after conversion to Pa there are 15 decimals, there is still only one significant figure.</p>
<p>Precision is different from accuracy, and performing floating point operations on engineering units need to take this into account during the operations - don't store more precision than the accuracy of the measurement, don't use more precision in a calculation than is known.</p>
<hr>
<p>Edit:</p>
<p>You might also consider using <code>NUMERIC(p,s)</code> where the precision (number of digits) and scale (number of digits to the right of the decimal) can be explicitly specified.</p>
<p>If that is not an option, consider persisting the accuracy for a particular measurement so that it may be reported and/or used in calculations.</p>
|
<p>Well, it depends on how exact you want to be. Remember than when talking about engineering, it isn't enough to just store the number 3.20, because 3.2 isn't the same as 3.20 when it comes to engineering. 3.20 implies higher accuracy than 3.2, which could be <em>3.15 <= x < 3.25</em>.</p>
| 44,706
|
<p>I remember hearing <a href="http://en.wikipedia.org/wiki/Joel_Spolsky" rel="noreferrer">Joel Spolsky</a> mention in <a href="https://stackoverflow.fogbugz.com/default.asp?W4" rel="noreferrer">podcast 014</a> that he'd barely ever used a foreign key (if I remember correctly). However, to me they seem pretty vital to avoid duplication and subsequent data integrity problems throughout your database.</p>
<p>Do people have some solid reasons as to why (to avoid a discussion in lines with Stack Overflow principles)?</p>
<p><strong>Edit:</strong> <a href="https://stackoverflow.fogbugz.com/default.asp?W13086" rel="noreferrer"><em>"I've yet to have a reason to create a foreign key, so this might be my first reason to actually set up one."</em></a></p>
|
<p>Reasons to use Foreign Keys:</p>
<ul>
<li>you won't get Orphaned Rows</li>
<li>you can get nice "on delete cascade" behavior, automatically cleaning up tables</li>
<li>knowing about the relationships between tables in the database helps the Optimizer plan your queries for most efficient execution, since it is able to get better estimates on join cardinality. </li>
<li>FKs give a pretty big hint on what statistics are most important to collect on the database, which in turn leads to better performance</li>
<li>they enable all kinds of auto-generated support -- ORMs can generate themselves, visualization tools will be able to create nice schema layouts for you, etc.</li>
<li>someone new to the project will get into the flow of things faster since otherwise implicit relationships are explicitly documented</li>
</ul>
<p>Reasons not to use Foreign Keys:</p>
<ul>
<li>you are making the DB work extra on every <a href="https://en.wikipedia.org/wiki/Create,_read,_update_and_delete" rel="noreferrer">CRUD</a> operation because it has to check FK consistency. This can be a big cost if you have a lot of churn </li>
<li>by enforcing relationships, FKs specify an order in which you have to add/delete things, which can lead to refusal by the DB to do what you want. (Granted, in such cases, what you are trying to do is create an Orphaned Row, and that's not usually a good thing). This is especially painful when you are doing large batch updates, and you load up one table before another, with the second table creating consistent state (but should you be doing that sort of thing if there is a possibility that the second load fails and your database is now inconsistent?).</li>
<li>sometimes you know beforehand your data is going to be dirty, you accept that, and you want the DB to accept it</li>
<li>you are just being lazy :-)</li>
</ul>
<p>I think (I am not certain!) that most established databases provide a way to specify a foreign key that is not enforced, and is simply a bit of metadata. Since non-enforcement wipes out every reason not to use FKs, you should probably go that route if any of the reasons in the second section apply.</p>
|
<p>I always thought it was lazy not to use them. I was taught it should always be done. But then, I didnt listen to Joel's discussion. He may have had a good reason, I don't know.</p>
| 10,884
|
<p>I've just done a test with bitfields, and the results are surprising me. </p>
<pre><code>class test1 {
public:
bool test_a:1;
bool test_b:1;
bool test_c:1;
bool test_d:1;
bool test_e:1;
bool test_f:1;
bool test_g:1;
bool test_h:1;
};
class test2 {
public:
int test_a:1;
int test_b:1;
int test_c:1;
int test_d:1;
int test_e:1;
int test_f:1;
int test_g:1;
int test_h:1;
};
class test3 {
public:
int test_a:1;
bool test_b:1;
int test_c:1;
bool test_d:1;
int test_e:1;
bool test_f:1;
int test_g:1;
bool test_h:1;
};
</code></pre>
<p>The results were:-</p>
<pre><code>sizeof(test1) = 1 // This is what I'd expect. 8 bits in a byte
sizeof(test2) = 4 // Reasonable. Maybe padded out to the size of an int.
sizeof(test3) = 16 // What???
</code></pre>
<p>Is this what you'd expect, or a compiler bug? (Codegear C++ Builder 2007, btw...)</p>
|
<p>your compiler has arranged all of the members of test3 on integer size boundaries. Once a block has been used for a given type (integer bit-field, or boolean bit-field), the compiler does not allocate any further bit fields of a different type until the next boundary.</p>
<p>I doubt it is a bug. It probably has something to do with the underlying architecture of your system.</p>
<p><b>edit:</b></p>
<p>c++ compilers will allocate bit-fields in memory as follows: several consecutive bit-field members <i>of the same type</i> will be allocated sequentially. As soon as a new type needs to be allocated, it will be aligned with the beginning of the next logical memory block. The next logical block will depend on your processor. Some processors can align to 8-bit boundaries, while others can only align to 16-bit boundaries.</p>
<p>In your test3, each member is of a different type than the one before it, so the memory allocation will be 8 * (the minimum logical block size on your system). In your case, the minimum block size is two bytes (16-bit), so the size of test3 is 8*2 = 16.</p>
<p>On a system that can allocate 8-bit blocks, I would expect the size to be 8.</p>
|
<p>From "Samuel P. Harbison, Guy L. Steele] C A Reference":</p>
<p><strong>The problem:</strong></p>
<p>"Compilers are free to impose constraints on the maximum size of a bit field, and specify certain addressing boundaries that bit field cannot cross."</p>
<p><strong>Manipulations which can be done within standard:</strong></p>
<p>"An unnamed bit field may also be included in a structure to provide padding."</p>
<p>"Specify a length of 0 for unnamed bit field has a special meaning - it indicates that no more bit fields should be packed into the area in which the previous bit field...Area here means some impl. defined storage unit"</p>
<blockquote>
<p>Is this what you'd expect, or a compiler bug?</p>
</blockquote>
<p>So within C89, C89 with amendment I, C99 - it is not a bug. About C++ I don't know, but I think that the behavior is similar.</p>
| 39,721
|
<p>I'm using the following syntax to loop through a list collection:</p>
<pre><code>For Each PropertyActor As JCPropertyActor In MyProperty.PropertyActors
i = IndexOf(PropertyActor)
Next
</code></pre>
<p>How do I get the index of the current object within the loop? I'm using IndexOf(PropertyActor) but this seems inefficient as it searches the collection when I already have the object available!</p>
|
<p>An index doesn't have any meaning to an IEnumerable, which is what the foreach construct uses. That's important because <code>foreach</code> may not enumerate in index order, if your particular collection type implements IEnumerable in an odd way. If you have an object that can be accessed by index <em>and</em> you care about the index during an iteration, then you're better off just using a traditional for loop:</p>
<pre><code>for (int i=0;i<MyProperty.PropertyActors.Length;i++)
{
//...
}
</code></pre>
|
<p>Add an index variable that you increase yourself for each iteration?</p>
| 25,237
|
<p>While I'm googling/reading for this answer I thought I would also ask here. </p>
<p>I have a class that is a wrapper for a SDK. The class accepts an ILoader object and uses the ILoader object to create an ISBAObject which is cast into an ISmallBusinessInstance object. I am simply trying to mock this behavior using Moq.</p>
<pre><code> [TestMethod]
public void Test_Customer_GetByID()
{
var mock = new Mock<ILoader>();
var sbainst = new Mock<ISbaObjects>();
mock.Expect(x => x.GetSbaObjects("")).Returns(sbainst);
}
</code></pre>
<p>The compiler error reads: Error 1 The best overloaded method match for 'Moq.Language.IReturns.Returns(Microsoft.BusinessSolutions.SmallBusinessAccounting.Loader.ISbaObjects)' has some invalid arguments</p>
<p>What is going on here? I expected the Mock of ISbaObjects to be able to be returned without a problem.</p>
|
<p>You need to use sbainst.Object, as sbinst isn't an instance of ISbaObjects - it's just the mock part.</p>
|
<p>Updated, correct code</p>
<pre><code>[TestMethod]
public void Test_Customer_GetByID()
{
var mock = new Mock<ILoader>();
var sbainst = new Mock<ISbaObjects>();
mock.Expect(x => x.GetSbaObjects("")).Returns(sbainst.Object);
}
</code></pre>
| 19,871
|
<p>I cannot figure out a way to disable a container AND its children in Swing. Is Swing really missing this basic feature?</p>
<p>If I do setEnabled(false) on a container, its children are still enabled.</p>
<p>My GUI structure is pretty complex, and doing a traversion of all elements below the container is not an option. Neither is a GlassPane on top of the container (the container is not the entire window).</p>
|
<p>To add to <a href="https://stackoverflow.com/questions/305527#305551">mmyers's answer</a>, disabling children is not an easy task (see this <a href="http://forums.java.net/jive/thread.jspa?threadID=13758" rel="nofollow noreferrer">thread</a>)</p>
<blockquote>
<p>The problem is near-to unsolvable in the general case. That's why it is not part of core Swing.</p>
<p>Technically, the disable-and-store-old-state followed by a enable-and-restore-to-old-state might look attractive. It even might be a nice-to-have in special cases. But there are (at least, probably a bunch more) two issues with that.</p>
<p><strong>Compound components</strong></p>
<p>The recursion must stop on a "compound component" (or "single entity"). Then the component is responsible for keeping dependent's state. There's no general way to detect such a component - examples are JComboBox, JXDatePicker (which as related <a href="https://swingx.dev.java.net/issues/show_bug.cgi?id=275" rel="nofollow noreferrer">issue</a>)</p>
<p>To make things even more complicated, dependents don't need to be under the hierarchy of the "compound component", f.i. JXTable takes care of the ColumnControl's (and header's) enabled state.</p>
<p>Trying to tackle both would require to have</p>
<p>a) a property on the compound: "don't touch my children" and<br>
b) a property on the uncontained dependents: "don't touch me"</p>
<p><strong>Binding to enabled</strong></p>
<p>enable-and-update-to-old might break application state if the enabled status is bound to a (presentation or other) model property and that property changed in-the-meantime - now the old-state is invalid.</p>
<p>Trying to tackle that would require to have</p>
<p>c) a "real" stored-old-enabled-due-to-view-concerns property<br>
d) bind the presentation model property to both the enabled and the stored-old-enabled</p>
<p>JXRadioGroup has a variant of that problem: On disabling - the group itself or the general controller - keeps track of the old-enabled of every button. Button's enabled is controlled by the Action - if there is an Action. So the enabled controller needs to restore to old-enabled or to action's enabled. During group's disabled (as-group) a problem looms if the Action's enabled was false on storing and changed to true.
Another if actions are added.</p>
<p>Now imagine the complexity of state transitions when overloading a)-- d)</p>
</blockquote>
|
<p>This is what I came up with.</p>
<pre><code>Component[] comps = myPanel.getComponents();
for (Component comp:comps){
comp.setEnabled(false);
}
</code></pre>
| 39,299
|
<p>My application correctly handles different kind of character sets, but only internally - when it comes to displaying text in standard WinForms labels und textboxes, it seems to have problems with chinese characters.</p>
<p>The problem seems to be the font used (Tahoma), because when I copy&paste the text, or view it in the debugger, it is displayed correctly. Also when I set MS Mincho as the font to be used, the characters on the screen look OK.</p>
<p>Of course, I don't want to use MS Mincho in the entire application. Do I have to switch the font depending on the characters displayed, or is there a better way I have missed?</p>
|
<p><a href="http://en.wikipedia.org/wiki/Uniscribe" rel="nofollow noreferrer">UniScribe</a>, which was introduced in Windows 2000, is supposed to handle this transparently, meaning that it will automatically use a different font (such as Mincho) for characters that aren't present in the font you've selected. This is why it looks correct in the debugger, even though the font used in the debugger doesn't contain Chinese characters. Perhaps you are doing something that disables UniScribe, or is problematic in some other way. Perhaps if you could paste some code it would be easier to identify the problem.</p>
|
<p>All fonts don't have data for all the glyphs that can be expressed in unicode. You´ll have to locate a suitable font which has the subset you want.</p>
<p>edit: Just to clarify, there <em>are</em> fonts which cover the full unicode range, but the one you´re using now isn´t one of them.</p>
| 12,916
|
<p>Googling has turned up little to nothing.</p>
<p>I need to develop some heavy stuff in m4 and I'd love to do it in my favorite environment with all the bells and whistles thereof.</p>
<p>There are packages for running m4 on just about every platform, such as <a href="http://gnuwin32.sourceforge.net/packages/m4.htm" rel="nofollow noreferrer">windows</a>. So I know at the very least I can create a default project and test from the CLI. But I'd rather not :)</p>
|
<p>I'm not aware of any specific editing support for m4. However, if you have some time to spare (!) and the BNF for m4, then you could use Xtext (<a href="http://wiki.eclipse.org/Xtext" rel="nofollow noreferrer">http://wiki.eclipse.org/Xtext</a>) to create a syntax-coloring and -completing editor, with an outline view.</p>
<p><strong>Updated</strong> an answer below suggests that m4 doesn't have a BNF, or is not BNeFfable, and certainly a short search of the literature shows no claims that an m4 BNF is available - and it appears, though not explicitly stated, that the m4 language is inexpressible in this way.</p>
<p>Obviously this negates my suggestion, so I must retract it, unless of course Xtext has been extended to deal with such languages. Consult the Xtext website linked above for FAQs and mailing list links.</p>
|
<p>If you are familiar with (and like) vim, you could try out <a href="http://eclim.org/" rel="nofollow noreferrer">Eclim</a> and then setup syntax highlighting for m4.</p>
| 40,626
|
<p>I've had a lot of trouble trying to come up with the best way to properly follow TDD principles while developing UI in JavaScript. What's the best way to go about this?</p>
<p>Is it best to separate the visual from the functional? Do you develop the visual elements first, and then write tests and then code for functionality?</p>
|
<p>I've done some TDD with Javascript in the past, and what I had to do was make the distinction between Unit and Integration tests. Selenium will test your overall site, with the output from the server, its post backs, ajax calls, all of that. But for unit testing, none of that is important.</p>
<p>What you want is just the UI you are going to be interacting with, and your script. The tool you'll use for this is basically <a href="https://github.com/pivotal/jsunit" rel="nofollow noreferrer">JsUnit</a>, which takes an HTML document, with some Javascript functions on the page and executes them in the context of the page. So what you'll be doing is including the Stubbed out HTML on the page with your functions. From there,you can test the interaction of your script with the UI components in the isolated unit of the mocked HTML, your script, and your tests.</p>
<p>That may be a bit confusing so lets see if we can do a little test. Lets to some TDD to assume that after a component is loaded, a list of elements is colored based on the content of the LI. </p>
<p><strong>tests.html</strong></p>
<pre><code><html>
<head>
<script src="jsunit.js"></script>
<script src="mootools.js"></script>
<script src="yourcontrol.js"></script>
</head>
<body>
<ul id="mockList">
<li>red</li>
<li>green</li>
</ul>
</body>
<script>
function testListColor() {
assertNotEqual( $$("#mockList li")[0].getStyle("background-color", "red") );
var colorInst = new ColorCtrl( "mockList" );
assertEqual( $$("#mockList li")[0].getStyle("background-color", "red") );
}
</script>
</html>
</code></pre>
<p>Obviously TDD is a multi-step process, so for our control, we'll need multiple examples. </p>
<p><strong>yourcontrol.js (step1)</strong></p>
<pre><code>function ColorCtrl( id ) {
/* Fail! */
}
</code></pre>
<p><strong>yourcontrol.js (step2)</strong></p>
<pre><code>function ColorCtrl( id ) {
$$("#mockList li").forEach(function(item, index) {
item.setStyle("backgrond-color", item.getText());
});
/* Success! */
}
</code></pre>
<p>You can probably see the pain point here, you have to keep your mock HTML here on the page in sync with the structure of what your server controls will be. But it does get you a nice system for TDD'ing with JavaScript.</p>
|
<p>This is the primary reason I switched to the Google Web Toolkit ... I develop and test in Java and have a reasonable expectation that the compiled JavaScript will function properly on a variety of browsers. Since TDD is primarily a unit testing function, most of the project can be developed and tested before compilation and deployment.</p>
<p>Integration and Functional test suites verify that the resulting code is functioning as expected after it's deployed to a test server.</p>
| 12,165
|
<p>What is the least expensive 3D printer available today? I am looking for something suitable for general use in a home office.</p>
|
<p><strong>Depends on your definition of "available" and your definition of "suitable for general use."</strong> </p>
<p>The cheapest 3D printers are mostly Kickstarter promises that take a year or more to ship, if they ever do. For example, the Peachy 3D printer Kickstarter just imploded and failed. There have been many other failed low-cost 3D printer crowdfunding campaigns. Another low cost Kickstarter printer, the 101Hero, is ongoing now (May 2016), but most competent observers I've talked to don't believe it will succeed at delivering working printers to all backers at that price point. If they do deliver, it will be painfully low-cost components and the printer will not perform well or last long. <strong>Stay away from crowdfunding campaigns for your first printer.</strong> At best, you get a beta product with lots of kinks to work out. At worst, you get nothing and lose your money. </p>
<p>For actual products you can purchase today, there's a wide spectrum of quality/cost tradeoffs.</p>
<ul>
<li>Under \$200 there's nothing credible. The Tiko (\$179) might deliver, but post-Kickstarter units are widely expected to cost more.</li>
<li>Around \$200-300 you get into low-quality Prusa i3 kits from China. These aren't a great value -- most people end up spending another few hundred dollars on upgrades to get them working reliably and with high quality.</li>
<li>Around \$300-400 you can get an <em>ok</em> 3D printer, often with "chipped" proprietary filament so the vendor can make high profits on locked-in consumables. ("Razors and blades" model.) For example, the XYZPrinting Da Vinci Jr is \$350 but locks you into high-cost chipped filament. The Wanhao Duplicator i3 is currently a community favorite for value-for-money at \$399. The Printrbot Play is much higher quality/reliability but much smaller at the same price. </li>
<li>If you get up around \$600, a big range of decent printers opens up. But this is no longer the "least expensive" option, so I won't get into it. </li>
</ul>
<p>If you want to tinker, the Duplicator i3 is a good choice. If you want a machine that just prints, the Play is a good choice. There are other printers and cheaper printers, but most of what you'll find below $400 is going to end up causing pain unless your goal is simply to tinker with printer troubleshooting and upgrades. </p>
|
<p>You can get an A8 3D printer on Gearbest at 149$, It's a version of an i3, with easy assemble and pre configured, and it have a suprising good quality.</p>
<p>I thinks is the best price/quality that you can find at the moment. It prints with a good quality by default and you can upgrade it if you need it without spending hundreds of dollars.</p>
<p><a href="http://www.gearbest.com/3d-printers-3d-printer-kits/pp_337314.html" rel="nofollow">http://www.gearbest.com/3d-printers-3d-printer-kits/pp_337314.html</a></p>
| 295
|
<p>I want to include a js file depending on the value of the current Locale. I have tried to access it from JSP as follows: </p>
<pre><code><%@ page import="java.util.Locale" %>
<% if( ((Locale) pageContext.getAttribute("org.apache.struts.action.LOCALE",PageContext.REQUEST_SCOPE)).getLanguage().equals("de")) { %>
<script src="../themes/administration/js/languages/i18nDE.js" type="text/javascript"> </script>
<% } else { %>
<script src="../themes/administration/js/languages/i18nEN.js" type="text/javascript"> </script>
<% } %>
</code></pre>
<p>However, I am getting a <code>java.lang.NullPointerException</code> because <code>pageContext.getAttribute("org.apache.struts.action.LOCALE",PageContext.REQUEST_SCOPE)</code> is <code>NULL</code>. </p>
<p>Does anyone knows how I can solve this?</p>
|
<p>At the moment I am using this :</p>
<pre><code><c:set var="localeCode" value="${pageContext.response.locale}" />
</code></pre>
<p>This can later be access by using <code>${localeCode}</code> </p>
<ol>
<li><strong>Scriplet mode</strong>, discouraged! See <a href="http://www.coderanch.com/how-to/java/WhyNotUseScriptlets" rel="nofollow noreferrer">Why not use Scriptlets</a> for reason not to use a scriptlet. </li>
</ol>
<p>The <code>localeCode</code> variable can be queried inside a <strong>scriptlet</strong> with:</p>
<pre><code><%
Object ob_localeCode = pageContext.getAttribute("localeCode");
if (ob_localeCode != null) {
String currentLanguageCode = (String) ob_localeCode;
}
//more code
%>
</code></pre>
<ol start="2">
<li><strong>Scripletless mode</strong> correct way to go. See <a href="https://stackoverflow.com/q/3177733/112106">How to avoid Java Code in JSP-Files?</a> Here on SO.</li>
</ol>
<p>I am using spring 2.5 config at the moment.</p>
<p>So following this, coming back to your original question you can implement something like:</p>
<pre><code><c:set var="localeCode" value="${pageContext.response.locale}" />
<c:choose>
<c:when test="$localecode == 'de' }">
<script src="../themes/administration/js/languages/i18nDE.js" type="text/javascript"> </script>
</c:when>
<c:otherwise>
<script src="../themes/administration/js/languages/i18nEN.js" type="text/javascript"> </script>
</c:otherwise>
</c:choose>
</code></pre>
<p>or if you really want to use some short code to impress your colleagues, you can do:</p>
<pre><code><c:set var="localeCode" value="${fn:toUpperCase(pageContext.response.locale)}" />
<c:set var="availLanguages" value="EN,DE" />
<c:if test="${!fn:contains(availLanguages,localeCode)}">
<c:set var="localeCode" value="EN" />
</c:if>
<script src="../themes/administration/js/languages/i18n{$localeCode}.js" type="text/javascript"> </script>
</code></pre>
|
<p>Ken G. pointed to the answer.</p>
<pre><code>pageContext.getAttribute("org.apache.struts.action.LOCALE",PageContext.SESSION_SCOPE)
</code></pre>
<p>should be used instead</p>
<pre><code>pageContext.getAttribute("org.apache.struts.action.LOCALE",PageContext.REQUEST_SCOPE)
</code></pre>
| 43,264
|
<p>How can I list the contents of a zipped folder in C#? For example how to know how many items are contained within a zipped folder, and what is their name?</p>
|
<p><a href="http://www.codeplex.com/DotNetZip" rel="noreferrer">DotNetZip</a> - Zip file manipulation in .NET languages</p>
<p>DotNetZip is a small, easy-to-use class library for manipulating .zip files. It can enable .NET applications written in VB.NET, C#, any .NET language, to easily create, read, and update zip files.</p>
<p>sample code to read a zip:</p>
<pre><code>using (var zip = ZipFile.Read(PathToZipFolder))
{
int totalEntries = zip.Entries.Count;
foreach (ZipEntry e in zip.Entries)
{
e.FileName ...
e.CompressedSize ...
e.LastModified...
}
}
</code></pre>
|
<p>The best way is to use the .NET built in J# zip functionality, as shown in MSDN: <a href="http://msdn.microsoft.com/en-us/magazine/cc164129.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/magazine/cc164129.aspx</a>. In this link there is a complete working example of an application reading and writing to zip files. For the concrete example of listing the contents of a zip file (in this case a Silverlight .xap application package), the code could look like this:</p>
<pre><code>
ZipFile package = new ZipFile(packagePath);
java.util.Enumeration entries = package.entries();
//We have to use Java enumerators because we
//use java.util.zip for reading the .zip files
while ( entries.hasMoreElements() )
{
ZipEntry entry = (ZipEntry) entries.nextElement();
if (!entry.isDirectory())
{
string name = entry.getName();
Console.WriteLine("File: " + name + ", size: " + entry.getSize() + ", compressed size: " + entry.getCompressedSize());
}
else
{
// Handle directories...
}
}
</code></pre>
<p>Aydsman had a right pointer, but there are <a href="http://https://silverlight.net/forums/p/11394/36407.aspx" rel="nofollow noreferrer">problems</a>. Specifically, you might find issues opening zip files, but is a valid solution if you intend to <em>only</em> create pacakges. ZipPackage implements the abstract Package class and allows manipulation of zip files. There is a sample of how to do it in MSDN: <a href="http://msdn.microsoft.com/en-us/library/ms771414.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms771414.aspx</a>. Roughly the code would look like this:</p>
<pre><code> string packageRelationshipType = @"http://schemas.microsoft.com/opc/2006/sample/document";
string resourceRelationshipType = @"http://schemas.microsoft.com/opc/2006/sample/required-resource";
// Open the Package.
// ('using' statement insures that 'package' is
// closed and disposed when it goes out of scope.)
foreach (string packagePath in downloadedFiles)
{
Logger.Warning("Analyzing " + packagePath);
using (Package package = Package.Open(packagePath, FileMode.Open, FileAccess.Read))
{
Logger.OutPut("package opened");
PackagePart documentPart = null;
PackagePart resourcePart = null;
// Get the Package Relationships and look for
// the Document part based on the RelationshipType
Uri uriDocumentTarget = null;
foreach (PackageRelationship relationship in
package.GetRelationshipsByType(packageRelationshipType))
{
// Resolve the Relationship Target Uri
// so the Document Part can be retrieved.
uriDocumentTarget = PackUriHelper.ResolvePartUri(
new Uri("/", UriKind.Relative), relationship.TargetUri);
// Open the Document Part, write the contents to a file.
documentPart = package.GetPart(uriDocumentTarget);
//ExtractPart(documentPart, targetDirectory);
string stringPart = documentPart.Uri.ToString().TrimStart('/');
Logger.OutPut(" Got: " + stringPart);
}
// Get the Document part's Relationships,
// and look for required resources.
Uri uriResourceTarget = null;
foreach (PackageRelationship relationship in
documentPart.GetRelationshipsByType(
resourceRelationshipType))
{
// Resolve the Relationship Target Uri
// so the Resource Part can be retrieved.
uriResourceTarget = PackUriHelper.ResolvePartUri(
documentPart.Uri, relationship.TargetUri);
// Open the Resource Part and write the contents to a file.
resourcePart = package.GetPart(uriResourceTarget);
//ExtractPart(resourcePart, targetDirectory);
string stringPart = resourcePart.Uri.ToString().TrimStart('/');
Logger.OutPut(" Got: " + stringPart);
}
}
}
</code></pre>
<p>The best way seems to use J#, as shown in MSDN: <a href="http://msdn.microsoft.com/en-us/magazine/cc164129.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/magazine/cc164129.aspx</a></p>
<p>There are pointers to more c# .zip libraries with different licenses, like SharpNetZip and DotNetZip in this article: <a href="https://stackoverflow.com/questions/265549/how-to-read-files-from-uncompressed-zip-in-c">how to read files from uncompressed zip in c#?</a>. They might be unsuitable because of the license requirements.</p>
| 39,626
|
<p>I am having a lot of trouble finding good information on how to call a standard SOAP/WSDL web service with Android. All I've been able to find are either very convoluted documents and references to "kSoap2" and then some bit about parsing it all manually with <a href="http://en.wikipedia.org/wiki/Simple_API_for_XML" rel="noreferrer">SAX</a>. OK, that's fine, but it's 2008, so I figured there should be some good library for calling standard web services.</p>
<p>The web service is just basically one created in <a href="http://en.wikipedia.org/wiki/NetBeans" rel="noreferrer">NetBeans</a>. I would like to have IDE support for generating the plumbing classes. I just need the easiest/most-elegant way to contact a <a href="http://en.wikipedia.org/wiki/Web_Services_Description_Language" rel="noreferrer">WSDL</a> based web service from an Android-based phone.</p>
|
<p>Android does not provide any sort of SOAP library. You can either write your own, or use something like <a href="http://ksoap2.sourceforge.net/" rel="noreferrer">kSOAP 2</a>. As you note, others have been able to compile and use kSOAP2 in their own projects, but I haven't had to.</p>
<p>Google has shown, to date, little interest in adding a SOAP library to Android. My suspicion for this is that they'd rather support the current trends in Web Services toward REST-based services, and using JSON as a data encapsulation format. Or, using XMPP for messaging. But that is just conjecture.</p>
<p>XML-based web services are a slightly non-trivial task on Android at this time. Not knowing NetBeans, I can't speak to the tools available there, but I agree that a better library should be available. It is possible that the XmlPullParser will save you from using SAX, but I don't know much about that.</p>
|
<p>Add Soap Libaray(<code>ksoap2-android-assembly-3.2.0-jar-with-dependencies.jar</code>):</p>
<p>public static String Fn_Confirm_CollectMoney_Approval(</p>
<pre><code> HashMap < String, String > str1,
HashMap < String, String > str2,
HashMap < String, String > str3) {
Object response = null;
String METHOD_NAME = "CollectMoney";
String NAMESPACE = "http://xxx/yyy/xxx";
String URL = "http://www.w3schools.com/webservices/tempconvert.asmx";
String SOAP_ACTION = "";
try {
SoapObject RequestParent = new SoapObject(NAMESPACE, METHOD_NAME);
SoapObject Request1 = new SoapObject(NAMESPACE, "req");
PropertyInfo pi = new PropertyInfo();
Set mapSet1 = (Set) str1.entrySet();
Iterator mapIterator1 = mapSet1.iterator();
while (mapIterator1.hasNext()) {
Map.Entry mapEntry = (Map.Entry) mapIterator1.next();
String keyValue = (String) mapEntry.getKey();
String value = (String) mapEntry.getValue();
pi = new PropertyInfo();
pi.setNamespace("java:com.xxx");
pi.setName(keyValue);
pi.setValue(value);
Request1.addProperty(pi);
}
mapSet1 = (Set) str3.entrySet();
mapIterator1 = mapSet1.iterator();
while (mapIterator1.hasNext()) {
Map.Entry mapEntry = (Map.Entry) mapIterator1.next();
// getKey Method of HashMap access a key of map
String keyValue = (String) mapEntry.getKey();
// getValue method returns corresponding key's value
String value = (String) mapEntry.getValue();
pi = new PropertyInfo();
pi.setNamespace("java:com.xxx");
pi.setName(keyValue);
pi.setValue(value);
Request1.addProperty(pi);
}
SoapObject HeaderRequest = new SoapObject(NAMESPACE, "XXX");
Set mapSet = (Set) str2.entrySet();
Iterator mapIterator = mapSet.iterator();
while (mapIterator.hasNext()) {
Map.Entry mapEntry = (Map.Entry) mapIterator.next();
// getKey Method of HashMap access a key of map
String keyValue = (String) mapEntry.getKey();
// getValue method returns corresponding key's value
String value = (String) mapEntry.getValue();
pi = new PropertyInfo();
pi.setNamespace("java:com.xxx");
pi.setName(keyValue);
pi.setValue(value);
HeaderRequest.addProperty(pi);
}
Request1.addSoapObject(HeaderRequest);
RequestParent.addSoapObject(Request1);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
SoapEnvelope.VER10);
soapEnvelope.dotNet = false;
soapEnvelope.setOutputSoapObject(RequestParent);
HttpTransportSE transport = new HttpTransportSE(URL, 120000);
transport.debug = true;
transport.call(SOAP_ACTION, soapEnvelope);
response = (Object) soapEnvelope.getResponse();
int cols = ((SoapObject) response).getPropertyCount();
Object objectResponse = (Object) ((SoapObject) response)
.getProperty("Resp");
SoapObject subObject_Resp = (SoapObject) objectResponse;
modelObject = new ResposeXmlModel();
String MsgId = subObject_Resp.getProperty("MsgId").toString();
modelObject.setMsgId(MsgId);
String OrgId = subObject_Resp.getProperty("OrgId").toString();
modelObject.setOrgId(OrgId);
String ResCode = subObject_Resp.getProperty("ResCode").toString();
modelObject.setResCode(ResCode);
String ResDesc = subObject_Resp.getProperty("ResDesc").toString();
modelObject.setResDesc(ResDesc);
String TimeStamp = subObject_Resp.getProperty("TimeStamp")
.toString();
modelObject.setTimestamp(ResDesc);
return response.toString();
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
</code></pre>
| 38,084
|
<p>I have a registry value which is stored as a binary value (REG_BINARY) holding information about a filepath. The value is read out into an byte array. But how can I transform it into a readable string?</p>
<p>I have read about system.text.encoding.ASCII.GetString(value) but this does not work. As far as I got to know the registry value is arbitrary binary data and not ASCII which is the reason for the method to produce useless data.</p>
<p>Does anybody know how I can convert the data? </p>
<p>Sample:
(A piece of the entry)</p>
<pre><code>01 00 00 00 94 00 00 00 14 00 00 00 63 00 3A 00 5C 00
70 00 72 00 6F 00 67 00 72 00 61 00 6D 00 6d 00 65 00
5C 00 67 00 65 00 6D 00 65 00 69 00 6E 00 73 00 61 00
6D 00 65 00 20 00 64 00 61 00 74 00 65 00 69 00 65 00
6E 00 5C
</code></pre>
<p>Due to the regedit this is supposed to be:</p>
<pre><code>............c.:.\.p.r.o.g.r.a.m.m.e.\.g.e.m.e.i.n.s.a.m.e. .d.a.t.e.i.e.n.\
</code></pre>
<p>The entry itself was created from Outlook. It's an entry for an disabled addin item (resiliency)</p>
|
<p>Well, it's not <em>arbitrary</em> binary data - it's text data in <em>some</em> kind of encoding. You need to find out what the encoding is.</p>
<p>I wouldn't be surprised if <code>Encoding.Unicode.GetString(value)</code> worked - but if that doesn't, please post a sample (in hex) and I'll see what I can do. What does the documentation of whatever's put the data in there say?</p>
<p>EDIT: It looks like Encoding.Unicode is your friend, but starting from byte 12. Use</p>
<pre><code>Encoding.Unicode.GetString(bytes, 12, bytes.Length-12)
</code></pre>
|
<p>Use</p>
<pre><code>Function Microsoft.Win32.RegistryKey.GetValue(name as String) as Object
</code></pre>
<p>Also look at <code>System.Text.Encoding</code> and <code>System.Text.Encoding.Unicode</code></p>
| 45,466
|
<p>I can easily set breakpoints in embedded JS functions, but I don't see any way of accessing external JS scripts via Firebug unless I happen to enter them during a debug session. Is there a way to do this without having to 'explore' my way into the script?</p>
<p>@Jason: This is a good point, but in my case I do not have easy access to the script. I am specifically talking about the client scripts which are invoked by the ASP.Net Validators that I would like to debug. I can access them during a debug session through entering the function calls, but I could not find a way to access them directly.</p>
|
<p>Place <code>debugger;</code> in your external script file on the line you want to break on.</p>
|
<p>After you place a break point in them, you can also call them by name in the firebug console, and see the output of (or step through) any intermediate functions. This can help when the main entry point calls many other helper functions, and you are really just concerned with how these helpers are working.</p>
<p>That being said, I don't knwo anything about ASP.Net validators, so its possible this doesn't apply.</p>
| 5,259
|
<p>I am looking for a way to generate 2D horizontal templates for manually carving an object. My thought was to produce an STL of the model, generate the G-code, and then transform that into slices. Appreciate any suggestions for where to start. I'm not afraid of getting my hands dirty with python, R, matlab, whatever.</p>
|
<h1>Carving decorative patterns?</h1>
<p>If your templates needs to be used like one does a stencil, that's doable... but paper-thin is not as you can't make that with an FDM printer.</p>
<p>But if you allow 0.2 or even better, 0.5 mm thickness, it is as simple as making a vector graphic, importing it into a suitable CAD package, then extruding it to the relevant thickness, and sending it into the printer.</p>
<p>If you really need it to be thinner, invest in a vinyl cutter, and use the same vector graphic to cut a foil template for one use. Upside: you could use the vinyl to <em>etch</em> the patterns in metal.</p>
<h1>Carving figurines?</h1>
<p>Yes, that's possible too, even easier! Make a 3D model of the finished object in a CAD or 3D modeling software. Either cut up the model right there and export each slice as STL for the printer, or export the whole model and use a secondary software such as MeshMixer to do plane cuts onto the model.</p>
<p>The slices should be at least 0.5 mm thick to allow handling.</p>
<p>It might <em>also</em> be a good idea to use the same model and cut it from a cube, which then is sliced up - that way you get a pattern to press against the outside of the model.</p>
|
<p>I would approach following way. I saw interesting example of using <em>Autodesk Fusion 360</em> to generate moves (G-Code) for carving in vertical slices. Fusion generated moves like for CNC tool in "parallel mode". You can see details in the video <a href="https://www.youtube.com/watch?v=CkRDLPbVNo4" rel="nofollow noreferrer">3D printer cutting styrofoam like CNC router</a> (software setup is presented at 11:00-14:30). Steps/settings important for manual work would be:</p>
<ul>
<li>selecting parallel strategy</li>
<li>steup length and width of tool - reflecting "depth/width of slice"</li>
<li>check the simulation</li>
<li>create NC program - creating the G-Code file</li>
</ul>
<p>I think that even if really working manually, the benefit of such approach would be that you focus on one layer/slice at time, and carve in one depth from the top of "material block" to the line defined be two points (the move in G-Code). The trouble could be actual number of such "G-Code lines": there will be probably too many of them, e.g. to measure each by hand and draw on the sufrface. But maybe this could be reduced with resolution (and quality). You could try to use any G-Code visualizer to project lines (of given single layer/slice) with beamer on the material sufrace.</p>
<p>The depth (real width of slice) could be controlled only manually, to avoid carving too deep.</p>
<p>The video uses parallel carving strategy to work in vertical slices. "Adaptive cleanring" strategy could be used to work horizontally.</p>
| 1,831
|
<p>I wrote a program out, which was all in one file, and the methods were forward declared in a header. The program initially worked perfectly when it was in one file. But when I separated the program, I kept getting random occurrences for the destructor of one of the classes which was declared in the header file. </p>
<p>I have a static variable in my header to count the number of objects of a particular class. Whenever I construct the object I increment this variable. Then in my destructor I subtract 1 from that variable, check if it's 0 (meaning it's the last object) and do something. The value seems to be off sometimes, I'm not sure why. I do have random calls in my application but I don't see why that would effect what I have described above, thanks. Any help or insight is appreciated!</p>
<p>[Update]: have a base class, which contains the destructor.. which is implemented in the header, then I have two derived classes, which in their constructor increment the static var.. so what can I do? </p>
<p>What I am trying to do is the following: In my header I have this:</p>
<pre><code>class A {
public:
virtual ~A() {
count --;
if (count == 0) { /* this is the last one, do something */ }
}
class B : public A {
public:
B();
}
</code></pre>
<p>Then in Class B I have</p>
<pre><code>B::B() {
count++;
}
</code></pre>
<p>Where can I define count so I don't get misleading counts? Thanks.</p>
|
<p>You must define the constructor in A (all of them) to increment the count.</p>
<p>Note unless you define them the compiler automatically generate the following four methods:</p>
<ul>
<li>Default Constructor (if no other constructor is defined)</li>
<li>Default Destructor</li>
<li>Copy Constructor</li>
<li>Assignment operator</li>
</ul>
<p>The following code overrides the compiler defaults so that you should get an accurate count.</p>
<pre><code> class A
{
static int count;
public:
A() // Default constructor.
{
++count;
}
A(A const& copy) // Copy constructor/
{ // Note If you do not define it the compiler
++count; // will automatically do it for you
}
virtual ~A()
{
--count;
if (count == 0)
{ // PLOP
}
}
// A& operator=(A const& copy)
// do not need to override this as object has
// already been created and accounted for.
};
</code></pre>
<p>////
In source file:</p>
<pre><code>int A::count = 0;
</code></pre>
|
<p>Can you elaborate what you mean by the "value seems to be off"? Do you get too many constructions? Not enough destructions? If you get too many constructions and not enough destructions, it would not have anything to do with the statics.</p>
<p>Also, what do you mean by a static variable? Do you mean a static member field or an actual static variable ?</p>
<p>If you declare just a static variable in the header (which I doubt that you do), then each C file that includes that header would have a separate instance of that variable (since static before a global variable means that it is limited to that object file).</p>
| 42,746
|
<p>The ones that stick out and make life usefull.</p>
|
<p>Here is one for a testClass with Nunit support.</p>
<pre><code>
Imports Nunit.FrameWork
Namespace $NAMESPACE$
'''
''' A TestClass
'''
'''
_
Public Class $CLASSNAME$
#Region " Setup and TearDown "
'''
''' Sets up the Tests
'''
'''
_
Public Sub Setup()
End Sub
'''
''' Tears down the test. Is executed after the Test is Completed
'''
'''
_
Public Sub TearDown()
End Sub
#End Region
#Region " Tests "
'''
''' A Test
'''
'''
_
Public Sub $Test_Name$()
End Sub
#End Region
End Class
End Namespace</code></pre>
|
<p>MSTest testclass. I like my testclass basic. Not like the one that is created by VS.</p>
<pre><code>Imports Microsoft.VisualStudio.TestTools.UnitTesting
<TestClass()> _
Public Class $ClassName$
$END$
End Class
</code></pre>
<p><code>$Classname</code> is "Current file name without extension" macro.</p>
| 4,714
|
<p>I'm trying to compile over 100 java classes from different packages from a clean
directory (no incremental compiles) using the following ant tasks:</p>
<pre><code><target name="-main-src-depend">
<depend srcdir="${src.dir}"
destdir="${bin.dir}"
cache="${cache.dir}"
closure="true"/>
</target>
<target name="compile" depends="-main-src-depend"
description="Compiles the project.">
<echo>Compiling</echo>
<javac target="${javac.target}"
source="${javac.source}"
debug="${javac.debug}"
srcdir="${src.dir}"
destdir="${bin.dir}">
<classpath>
<path refid="runtime.classpath"/>
<path refid="compile.classpath"/>
</classpath>
</javac>
</target>
</code></pre>
<p>However, the first time I run the compile task I always get a StackOverflowException. If I run the task again the compiler does an incremental build and everything works fine. This is undesirable since we are using <a href="http://cruisecontrol.sourceforge.net/" rel="noreferrer">CruiseControl</a> to do an automatic daily build and this is causing false build failures.</p>
<p>As a quick-and-dirty solution I have created 2 separate tasks, compiling portions of the project in each. I really don't think this solution will hold as more classes are added in the future, and I don't want to be adding new compile tasks every time we hit the "compile limit".</p>
|
<blockquote>
<p>It will be nice to know; what can
cause or causes a StackOverflowError
during compilation of Java code?</p>
</blockquote>
<p>It is probable that evaluating the long expression in your java file consumes lots of memory and because this is being done in conjunction with the compilation of other classes, the VM just runs out of stack space. Your generated class is perhaps pushing the legal limits for its contents. See chapter <a href="http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#88659" rel="nofollow noreferrer">4.10 Limitations of the Java Virtual Machine</a> in <a href="http://java.sun.com/docs/books/jvms/" rel="nofollow noreferrer">The Java Virtual Machine Specification, Second Edition</a>.</p>
<p><strong>Fix 1: refactor the class</strong></p>
<p>Since your class is being generated, this might not be an option. Still, it is worth looking at the options your class generation tool offers to see if it can produce something less troublesome.</p>
<p><strong>Fix 2: increase the stack size</strong></p>
<p>I think <a href="https://stackoverflow.com/questions/16935/ants-javac-tasks-throws-stackoverflowexception#16982">Kieron</a> has one solution when he mentions the -Xss argument. <a href="http://java.sun.com/javase/6/docs/technotes/tools/windows/javac.html" rel="nofollow noreferrer">javac</a> takes a number of non-standard arguments that will vary between versions and compiler vendors.</p>
<p>My compiler:</p>
<pre><code>$ javac -version
javac 1.6.0_05
</code></pre>
<p>To list all the options for it, I'd use these commands:</p>
<pre><code>javac -help
javac -X
javac -J-X
</code></pre>
<p>I <em>think</em> the stack limit for javac is 512Kb by default. You can increase the stack size for this compiler to 10Mb with this command:</p>
<pre><code>javac -J-Xss10M Foo.java
</code></pre>
<p>You might be able to pass this in an Ant file with a <em>compilerarg</em> element nested in your <em>javac</em> task.</p>
<pre><code><javac srcdir="gen" destdir="gen-bin" debug="on" fork="true">
<compilerarg value="-J-Xss10M" />
</javac>
</code></pre>
|
<p>That's quite odd, 100 classes really isn't that many. What is the compiler doing when the stack overflows? Is there a useful stack trace generated? What happens if you run <code>javac</code> directly on the command line instead of thorugh ant?</p>
<p>One possible workaround is to simply increase the size of the stack using the <code>-Xss</code> argument to the JVM; either to the JVM running <code>ant</code> or by setting <code>fork="true"</code> and a <code><compilerarg></code> on the <code><javac></code> task. Actually now that I think of it, does the problem go away just putting in the <code>fork="true"</code>?</p>
| 3,762
|
<p>I currently have a .net SOAP web service with a timeout on the request that I set using</p>
<pre><code>Server.ScriptTimeout = TIME_OUT;
</code></pre>
<p>I then have java client calling said web service. However when the timeout is reached I get this exception:</p>
<pre><code>Exception in thread "Thread-9" com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type: text/html; charset=utf-8 Supported ones are: [text/xml]
</code></pre>
<p>What is happening is that the web service returns an html error page with the http timeout code (503 I think?), which my Java code (generated using WSDLimport) doesn't expect.</p>
<p>Now I could catch the error UnsupportedMediaException on the client and attempt to translate it into something more meaningful, but I would prefer to send out a more specific timeout exception on the web service side. Is there anyway in a .net web service to send out a better exception when a timeout occurs, or any other way to handle this situation better?</p>
<p><strong>EDIT:</strong><br>
I am using the WSDLImport from the glassfish 2 distribution.</p>
|
<p>This is a <a href="https://jax-ws.dev.java.net/issues/show_bug.cgi?id=566" rel="nofollow noreferrer">known issue</a> with Sun's JAX-WS stack.</p>
<p>For reference, the HTTP 500 code actually means that the server had an Internal Server Error. I'm not sure why .NET sends that rather than HTTP 503 Service Unavailable.</p>
|
<p>You can make your webservice <a href="http://msdn.microsoft.com/en-us/library/aa480516.aspx" rel="nofollow noreferrer">asynchronous</a>. Then start a timer with your timeout in the BeginMyMethod, and throw custom exception in your EndMyMethod method. It will be wrapped in SOAP exception and sent to the client as such.</p>
| 44,333
|
<p>I have a fair number of Python scripts that contain reusable code that are used and referenced by other Python scripts. However, these scripts tend to be scattered across different directories and I find it to be somewhat tedious to have to include (most often multiple) calls to sys.path.append on my top-level scripts. I just want to provide the 'import' statements without the additional file references in the same script.</p>
<p>Currently, I have this:</p>
<pre><code>import sys
sys.path.append('..//shared1//reusable_foo')
import Foo
sys.path.append('..//shared2//reusable_bar')
import Bar
</code></pre>
<p>My preference would be the following:</p>
<pre><code>import Foo
import Bar
</code></pre>
<p>My background is primarily in the .NET platform so I am accustomed to having meta files such as *.csproj, *.vbproj, *.sln, etc. to manage and contain the actual file path references outside of the source files. This allows me to just provide 'using' directives (equivalent to Python's import) without exposing all of the references and allowing for reuse of the path references themselves across multiple scripts.</p>
<p>Does Python have equivalent support for this and, if not, what are some techniques and approaches?</p>
|
<p>The simple answer is to put your reusable code in your site-packages directory, which is in your sys.path.</p>
<p>You can also extend the search path by adding .pth files somewhere in your path.
See <a href="https://docs.python.org/2/install/#modifying-python-s-search-path" rel="nofollow noreferrer">https://docs.python.org/2/install/#modifying-python-s-search-path</a> for more details</p>
<p>Oh, and python 2.6/3.0 adds support for PEP370, <a href="http://docs.python.org/whatsnew/2.6.html#pep-370-per-user-site-packages-directory" rel="nofollow noreferrer">Per-user site-packages Directory</a></p>
|
<p>My solution was to package up one utility that would import the module:
my_util is in site packages</p>
<pre><code>import my_util
foo = myutil.import_script('..//shared1//reusable_foo')
if foo == None:
sys.exit(1)
def import_script(script_path, log_status = True):
"""
imports a module and returns the handle
"""
lpath = os.path.split(script_path)
if lpath[1] == '':
log('Error in script "%s" in import_script' % (script_path))
return None
#check if path is already in sys.path so we don't repeat
npath = None
if lpath[0] == '':
npath = '.'
else:
if lpath[0] not in sys.path:
npath = lpath[0]
if npath != None:
try:
sys.path.append(npath)
except:
if log_status == True:
log('Error adding path "%s" in import_script' % npath)
return None
try:
mod = __import__(lpath[1])
except:
error_trace,error_reason = FormatExceptionInfo()
if log_status == True:
log('Error importing "%s" module in import_script: %s' % (script_path, error_trace + error_reason))
sys.path.remove(npath)
return None
return mod
</code></pre>
| 36,626
|
<p>This is a nasty one for me... I'm a PHP guy working in Java on a JSP project. I know how to do what I'm attempting through too much code and a complete lack of finesse. </p>
<p>I'd prefer to do it right. Here is the situation:</p>
<p>I'm writing a small display to show customers what days they can water their lawns based on their watering group (ABCDE) and what time of year it is. Our seasons look like this:
Summer (5-1 to 8-31)
Spring (3-1 to 4-30)
Fall (9-1 to 10-31)
Winter (11-1 to 2-28) </p>
<p>An example might be:</p>
<p>If I'm in group A, here would be my allowed times:
Winter: Mondays only
Spring: Tues, Thurs, Sat
Summer: Any Day
Fall: Tues, Thurs, Sat</p>
<p>If I was writing this in PHP I would use arrays like this:</p>
<pre><code>//M=Monday,t=Tuesday,T=Thursday.... etc
$schedule["A"]["Winter"]='M';
$schedule["A"]["Spring"]='tTS';
$schedule["A"]["Summer"]='Any';
$schedule["A"]["Fall"]='tTS';
$schedule["B"]["Winter"]='t';
</code></pre>
<p>I COULD make the days arrays (array("Tuesday","Thursday","Saturday")) etc, but it is not necessary for what I'm really trying to accomplish.</p>
<p>I will also need to setup arrays to determine what season I'm in:</p>
<pre><code>$seasons["Summer"]["start"]=0501;
$seasons["Summer"]["end"]=0801;
</code></pre>
<p>Can anyone suggest a really cool way to do this? I will have today's date and the group letter. I will need to get out of my function a day (M) or a series of days (tTS), (Any).</p>
|
<p>You could do essentially the same code with Hashtables (or some other Map):</p>
<pre><code>Hashtable<String, Hashtable<String, String>> schedule
= new Hashtable<String, Hashtable<String, String>>();
schedule.put("A", new Hashtable<String, String>());
schedule.put("B", new Hashtable<String, String>());
schedule.put("C", new Hashtable<String, String>());
schedule.put("D", new Hashtable<String, String>());
schedule.put("E", new Hashtable<String, String>());
schedule.get("A").put("Winter", "M");
schedule.get("A").put("Spring", "tTS");
// Etc...
</code></pre>
<p>Not as elegant, but then again, Java isn't a dynamic language, and it doesn't have hashes on the language level.</p>
<p>Note: You might be able to do a better solution, this just popped in my head as I read your question.</p>
|
<p>There is no pretty solution. Java just doesn't do things like this well. Mike's solution is pretty much the way to do it if you want strings as the indices (keys). Another option if the hash-of-hashes setup is too ugly is to append the strings together (shamelessly stolen from Mike and modified):</p>
<pre><code>Hashtable<String, String> schedule = new Hashtable<String, String>();
schedule.put("A-Winter", "M");
schedule.put("A-Spring", "tTS");
</code></pre>
<p>and then lookup:</p>
<pre><code>String val = schedule.get(group + "-" + season);
</code></pre>
<p>If you're unhappy with the general ugliness (and I don't blame you), put it all behind a method call:</p>
<pre><code>String whenCanIWater(String group, Date date) { /* ugliness here */ }
</code></pre>
| 3,394
|
<p>Before anyone recommends that I do a google search on this, I have. I just need a bit more clarity around what codepages and encodings.</p>
<p>If I use UTF8 encoding, and use an italian code page and then a french code page, does this mean ill get different characters even though the bytes havent changed?</p>
|
<p>Joel has a nice summary of this:<br>
<a href="http://www.joelonsoftware.com/articles/Unicode.html" rel="nofollow noreferrer">http://www.joelonsoftware.com/articles/Unicode.html</a></p>
<p>And no. if I understand your question correctly it doesn't mean that.
When you're converting UTF-8 to a specific code page, it is possible that only some of the characters are going to be converted. What happens to the ones that don't get converted depends on how you call the conversion. A possible result is that the characters which could not be mapped to the code page would be converted to question mark characters.</p>
|
<p>UTF-8 includes all characters from your French and Italian code page, but the language specific code pages does not include all of each others characters.</p>
<p>So you can take input from each language and convert it to UTF-8 for storage, but you can not be certain that you will get the right characters if you take Italian input and show it as French.</p>
<p>Use UTF-8 all the way if you can.</p>
| 32,192
|
<p>There has been some talk of Website performance monitoring tools and services on stackoverflow, however, they seem fairly expensive for what they actually do. Are there any good opensource libraries for automating checking/monitoring the availability of a website?</p>
|
<p>If you just want to know if your server is serving out content or not, take a look at <a href="http://www.montastic.com/" rel="nofollow noreferrer">Montastic</a>. I use it, and am pleased. Plus its free!</p>
<p>It will ping your site periodically, and if it doesn't get a 200 status, it lets you know.</p>
|
<p>I have always used <a href="http://www.zabbix.com/" rel="nofollow noreferrer">Zabbix</a> especially for critical web sites. It uses MySql for the database and it has a PHP frontend. Of course it is open source and it is very flexible. It uses servers to stick data in the database and agents collect the data and send it to the servers. It is very scalable with this respect. I cannot recommend this software enough. I have all kinds of monitoring going on, not just web servers.</p>
| 7,839
|
<p>I'm maintaining <a href="http://perl-begin.org/" rel="nofollow noreferrer">the Perl Beginners' Site</a> and used a modified template from Open Source Web Designs. Now, the problem is that I still have an undesired artifact: a gray line on the left side of the main frame, to the left of the navigation menu. Here's <a href="http://www.shlomifish.org/Files/files/images/Computer/Screenshots/perl-begin-bad-artif.png" rel="nofollow noreferrer">an image</a> highlighting the undesired effect.</p>
<p>How can I fix the CSS to remedy this problem?</p>
|
<p>It's the <code>background-image</code> on the body showing through. Quick fix (edit style.css or add elsewhere):</p>
<pre><code>#page-container
{
background-color: white;
}
</code></pre>
|
<p>Thanks to all the people who answered. The problem was indeed the transparency of the #page-container and the background image of the body. I fixed them both in the stylesheet. </p>
| 10,021
|
<p>How to obtain Vista Edition programmatically, that is Home Basic, Home Premium, Business or Ultimate ?</p>
|
<p>MSDN gives extensive answer:</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms724429%28VS.85%29.aspx" rel="nofollow noreferrer">Getting the System Version</a></p>
|
<p>Brilliant! This is just what I need as well. Thanks aku.</p>
<p>edg: Environment.OSVersion contains a version string but this doesn't generally give enough information to differentiate editions (also applies to XP Home/XP Pro). Also, there's the risk that this string will be localised so matching on it woudn't necessarily work.</p>
| 8,007
|
<p>This fails with 'X.m is not a function'...</p>
<pre><code>var Y = function () {
this.m = function () {
alert('this is m');
};
};
var X = new function () { };
X.prototype = new Y();
X.m();
</code></pre>
<p>It would certainly work if I skipped the new keyword in the X definition and then instantiated X before calling m() on it. Why can't I do it this way?</p>
|
<p>No you cannot set the prototype and have that change effect previously existing instances. You can however, modify the prototype object to have the desired effect. But not the way you have attempted. This is because your instance X is an object, not a class. (This is because you used the "new" operator before the definition of your class.)</p>
<p>Simple test:</p>
<pre><code>var X = new function () { };
alert(X.prototype); // displays "undefined" because X is an
// object not a class
</code></pre>
<p>So when you set the "prototype" attribute on X you are not storing the template object in a class, you are merely creating a new attribute on object X with the name "prototype" so, if you did this:</p>
<pre><code>var Y = function () {
this.m = function () {
alert('this is m');
};
};
var X = new function () { };
X.prototype = new Y();
X.prototype.m(); // displays "this is m"
</code></pre>
<p>Then you get the output you expected previously.</p>
<p>Even though you created X as an instance of an anonymous class, you can still access that class through the "constructor" property. Once you have that reference, you can then modify the prototype object. Like this:</p>
<pre><code>X.constructor.prototype.m = new Y().m;
X.m(); // displays "this is m"
</code></pre>
<p>You should note however, that this will not work:</p>
<pre><code>X.constructor.prototype = new Y();
X.m(); // fails
</code></pre>
<p>Because changing the entire prototype object only effects instances created in the future.</p>
|
<p>You're trying to use .prototype on an <code>object</code> when you should be using it on a <code>function</code>.</p>
<p><code>alert(typeof Y); alert(typeof X);</code></p>
<p>You're actually creating a property on X called prototype, rather than using the "magic" protoype (try <code>X.prototype.m()</code> to see what I mean).</p>
| 40,351
|
<p>My application has several threads:
1) Main Thread
2) 2 Sub-Main Threads (each with Message Loop, as shown below), used by TFQM
3) n Worker Threads (simple loop, containing Sleep())</p>
<p>My problem is, when I close my application, the Worker Threads manage to exit properly, but 1 of the 2 Sub-Main Threads hangs (never exits) when I issue WM_QUIT to close them.</p>
<hr>
<pre><code>procedure ThreadProcFQM(P: Integer); stdcall;
var
Msg: TMsg;
_FQM: TFQM;
begin
_FQM := Ptr(P);
try
_FQM.fHandle := AllocateHwnd(_FQM.WndProc);
while GetMessage(Msg, 0, 0, 0) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
finally
DeallocateHWnd(_FQM.fHandle);
SetEvent(_FQM.hTerminated);
end;
end;
</code></pre>
<hr>
<pre><code>procedure TFQM.Stop;
begin
PostMessage(fHandle, WM_QUIT, 0, 0);
WaitForSingleObject(hTerminated, INFINITE);
if hThread <> INVALID_HANDLE_VALUE then
begin
CloseHandle(hThread);
hThread := INVALID_HANDLE_VALUE;
end;
end;
</code></pre>
|
<p>If I may point to few problems in your code ...</p>
<p>1) You're not checking output of AllocateHwnd. Yes, most probably it will never fail, but still ...</p>
<p>2) AllocateHwnd belogs OUT of try..finally! If it fails, DeallocateHwnd should not be called.</p>
<p>3) AllocateHwnd is not threadsafe. If you call it from multiple threads at the same time, you can run into poblems. <a href="http://17slon.com/blogs/gabr/2007/06/allocatehwnd-is-not-thread-safe.html" rel="noreferrer">Read more.</a></p>
<p>As Davy said, use MsgWaitForMultipleObjects instead of creating hidden message window. Then use PostThreadMessage to send messages to thread.</p>
<p>If I may put a plug for a totally free product here - use my <a href="http://otl.17slon.com/" rel="noreferrer">OmniThreadLibrary</a> instead. Much simpler than messing directly with Windows messaging.</p>
|
<p>I've had the same problem, and I found out I <strong>shouldn't</strong> create a hidden window just to recieve messages. Threads already have a message system. </p>
<p>I think that you're creating your windows handle and store it in fHandle, but GetMessage checks your thread's message loop. Therefore the message PostMessage(fHandle, WM_QUIT, 0, 0); is never recieved by the getmesssage.</p>
<p>You can post messages to your thread using PostThreadMessage, and in the thread you use GetMessage(CurrentMessage, 0, 0, 0). The only important difference is that you have to start the message loop from your thread by calling </p>
<pre><code>PeekMessage(CurrentMessage, 0, WM_USER, WM_USER, PM_NOREMOVE);
</code></pre>
<p>You should start with this, than do your setup and than start your loop.</p>
<p>The reason why you should start with the peek message is to make sure messages which are sent during the initialization of your threadprocedure are not lost.</p>
<p>The weird thing is, at the moment I can't find the reference where I learned this, but my guess is the newsgroup community.</p>
| 28,426
|
<p>Suppose I have a couple of spring beans: </p>
<pre><code><beans>
<bean name="A" ... />
<bean name="B" ... />
</beans>
</code></pre>
<p>"B" exposes a remote service that doesn't need "A". Assume that "A" takes a non-negligble time to load. What this means is that during a restart cycle, the application hangs the remote client, which can actually connect to the server but waits for a response until the spring container fully initializes. </p>
<p>What I'd like to be able to do is have the "B" remote service respond immediately, even if (based on the application state) it can only return NOT_READY or some such. The container, however, forces a wait until all of it's beans are initialized, even if you specify the beans as lazy-init and irrespective of load order. </p>
<p>I suspect that having "B" available immediately would mean that spring would have to make available a partially initialized container, which sounds bad. However, I'd appreciate any information anyone's got on the initialization order and whether you've found any reasonable workarounds. </p>
|
<p>Don't refer to bean "A" directly. Instead, refer to a bean which is a FACTORY for bean "A"; in this way, the Factory bean can be created without taking the initialization hit for instantiating "A". You'll need to refactor your classes which refer to an "A" to retrieve an "A" first, of course.</p>
<p>Or, you could create a bean "AA", which is a container for bean "A", which has an initialization state, and which exposes the interface of bean "A"; upon invocation, it sets its initialization state to not initialized, and begins initialization of bean "A" in some thread; calls to any interface methods of "A" on "AA" can then either block or return a not ready response, until the initialization of "A" within "AA" has completed.</p>
<p>This all kinda hinges on what your definition of "takes a non-negligible time to load" is. Why does it take a non-negligible amount of time to load? Is there some particularly tricky initialization that's going on within A? Or is A just so monstrously huge that it chokes the JVM?</p>
|
<p>I do not understand, why "A takes a non-negligble time to load", but maybe you could to a lazy initialize yourself by refactoring A. Do not use InitializingBean or handle an ApplicationEvent. Just initialize on the first Request to be handled. This will slow down the first request!</p>
<p>The other possibility is to move the initialization to a separated thread created by the bean handling an ApplicationEvent. The thread calls the initialization method of the bean an async way. Be carefull to handle Requests to the uninitialized bean!</p>
| 24,667
|
<p>I have the need to copy the entire contents of a directory on a FTP location onto a shared networked location. FTP Task has you specify the exact file name (not a directory) and File System Task does not allow accessing a FTP location.</p>
<p><strong>EDIT</strong>: I ended up writing a script task.</p>
|
<p>I've had some similar issues with the FTP task before. In my case, the file names changed based on the date and some other criteria. I ended up using a Script Task to perform the FTP operation.</p>
<p>It looks like this is what you ended up doing as well. I'd be curious if anyone else can come up with a better way to use the FTP task. It's nice to have...but VERY limited. </p>
|
<p>When I need to do this sort of thing I use a batch file to call FTP on the command line and use the mget command. Then I call the batch from the DTS/DTSX package.</p>
| 6,358
|
<p>What's the general consensus on supporting Windows 2000 for software distribution? Are people supporting Windows XP SP2+ for new software development or is this too restrictive still?</p>
|
<p>"OK" is a subjective judgement. You'll need to take a look at your client base and see what they're using.</p>
<p>Having said that, I dropped support for Win2K over a year ago with no negative impact.</p>
|
<p>A lot of computers at my company use Win2k, so we couldn't really drop support. It all depends on the client base.</p>
| 3,290
|
<p>An image set as the background of a DIV is displayed in IE, but not in Firefox.</p>
<p>CSS example:</p>
<pre><code>div.something {
background:transparent url(../images/table_column.jpg) repeat scroll 0 0;
}
</code></pre>
<p>(The issue is described in many places but haven't seen any conclusive explanation or fix.)</p>
|
<p>Sorry this got huge, but it covers two possibilities that consistently happen to me.</p>
<h2>Possibility 1</h2>
<p>You may find the path to the CSS file isn't correct. For example:</p>
<p>Say I have the following file structure:</p>
<pre><code>public/
css/
global.css
images/
background.jpg
something/
index.html
index.html
</code></pre>
<p>On <code>public/index.html</code> the following paths will include the CSS file:</p>
<pre><code>#1: <link href="./css/global.css"
#2: <link href="/css/global.css"
#3: <link href="css/global.css"
</code></pre>
<p>However on <code>public/something/index.html</code> number 1 and 3 will fail. If you are using a directory structure like this (or an MVC structure e.g.: <code>http://localhost/controller/action/params</code>) use the second href type.</p>
<p>Firebug's Net monitor tab will tell you if the CSS file can't be included.</p>
<p>On the subject of paths remember that images are relative to the path of the CSS file. So:</p>
<pre><code>url('./images/background.jpg') /* won't work */
url('../images/background.jpg') /* works: ../ == up one level */
</code></pre>
<p>Hover over the <code>url()</code> part of the background attribute in Firebug's CSS tab to check if the file's being loaded.</p>
<h2>Possibility 2</h2>
<p>It could be that the <code>div</code> has no content and thus has a 0 height. Make sure the div has at least a line of something in (e.g.: lorem ipsum delors secorum) or:</p>
<pre><code>div.something {
display: block; /* for verification */
min-height: 50px;
min-width: 50px;
}
</code></pre>
<p>Check Firebug's layout tab (of the HTML tab) to check the div has a height/width.</p>
|
<p>This worked for me:</p>
<p>1) Click on the background image table.<br/>
2) Right click on the status bar at the bottom of the page.<br/>
3) Click Inline styles.<br/>
4) Click the Background styles tab.<br/>
5) If you see 'Transparent' in the colour title, that is the problem.<br/>
6) Click the colour box and select a colour (white is a good choice.)<br/>
7) The colour title should now read white.<br/>
8) Click OK.<br/>
9) Save the page.<br/>
10) Upload the page and overwrite the existing file.<br/>
11) Refresh the page and your background picture will display.<br/></p>
<p>Note: Please ensure that you have uploaded your background picture jpeg. I forgot to upload the background jpeg once and spent ages trying to sort it before I realised my error.</p>
<p>Regards</p>
<p>Martin</p>
| 48,528
|
<p>I have a makefile template to compile a single DLL (for a plugin system).
The makefile of the user looks like this:</p>
<pre><code>EXTRA_SRCS=file1 file2
include makefile.in
</code></pre>
<p>In the <code>makefile.in</code> I have:</p>
<pre><code>plugin.dll: plugin.os $(patsubst %,%.os,$(EXTRA_SRCS))
</code></pre>
<p>Where <code>plugin.os</code> is the main C++ file to be compiled. Btw, the files ending is <code>.os</code> are the object files compiled for shared library (i.e. using the <code>-fpic</code> option with <code>gcc</code>)</p>
<p>Now, the problem is that the extra sources will probably (but not necessarily) be header files. Ideally I would like to add them as dependencies for the target <code>plugin.os</code> and the <code>file.cpp</code>, but only if they exist.</p>
<p>The method should work for both windows and linux, or at least be adaptable to each. However, I only use the GNU version of make.</p>
|
<p>Use the "wildcard" function:</p>
<pre><code>$(wildcard *.h)
</code></pre>
<p>EDIT: in order to match a specific list, do</p>
<pre><code>$(wildcard $(HEADER_FILES))
</code></pre>
<p>There is no need to use $(filter ...), the wildcard function automatically filters files which don't exist.</p>
|
<p>Does the simple</p>
<pre><code>$(filter $(wildcard *.h),$(HEADER_FILES))
</code></pre>
<p>do what you want?</p>
| 31,111
|
<p>I have a website that plays mp3s in a flash player. If a user clicks 'play' the flash player automatically downloads an mp3 and starts playing it. </p>
<p>Is there an easy way to track how many times a particular song clip (or any binary file) has been downloaded?</p>
<hr>
<blockquote>
<p>Is the play link a link to the actual
mp3 file or to some javascript code
that pops up a player?</p>
<p>If the latter, you can easily add your
own logging code in there to track the
number of hits to it.</p>
<p>If the former, you'll need something
that can track the web server log
itself and make that distinction. My
hosting plan comes with Webalizer,
which does this nicely.</p>
</blockquote>
<p>It's a javascript code so that answers that. </p>
<p>However, it would be nice to know how to track downloads using the other method (without switching hosts).</p>
|
<p>The funny thing is I wrote a php media gallery for all my musics 2 days ago. I had a similar problem. I'm using <a href="http://musicplayer.sourceforge.net/" rel="nofollow noreferrer">http://musicplayer.sourceforge.net/</a> for the player. And the playlist is built via php. All music requests go to a script called xfer.php?file=WHATEVER</p>
<pre><code>$filename = base64_url_decode($_REQUEST['file']);
header("Cache-Control: public");
header('Content-disposition: attachment; filename='.basename($filename));
header("Content-Transfer-Encoding: binary");
header('Content-Length: '. filesize($filename));
// Put either file counting code here, either a db or static files
//
readfile($filename); //and spit the user the file
function base64_url_decode($input) {
return base64_decode(strtr($input, '-_,', '+/='));
}
</code></pre>
<p>And when you call files use something like:</p>
<pre><code>function base64_url_encode($input) {
return strtr(base64_encode($input), '+/=', '-_,');
}
</code></pre>
<p><a href="http://us.php.net/manual/en/function.base64-encode.php" rel="nofollow noreferrer">http://us.php.net/manual/en/function.base64-encode.php</a></p>
<p>If you are using some JavaScript or a flash player (JW player for example) that requires the actual link of an mp3 file or whatever, you can append the text "&type=.mp3" so the final link becomes something like:
"www.example.com/xfer.php?file=34842ffjfjxfh&type=.mp3". That way it looks like it ends with an mp3 extension without affecting the file link.</p>
|
<p>Is there a database for your music library? If there is any server code that runs when downloading the mp3 then you can add extra code there to increment the play count. You could also have javascript make a second request to increment the play count, but this could lead to people/robots falsely incrementing counts.</p>
<p>I used to work for an internet-radio site and we used separate tables to track the time every song was played. Our streams were powered by a perl script running icecast, so we triggered a database request every time a new track started playing. Then to compute the play count we would run a query to count how many times a song's id was in the play log.</p>
| 2,261
|
<p>We are using Zabbix for services monitoring.</p>
<p>There are some essential monitoring configured.
I want to have timeline of version strings of my service along with this monitorings. That would give me opportunity to see that upgrading to this version altered overall error-count.</p>
<p>Is it possible? </p>
|
<p>Yes, it's possible.</p>
<p>You can pass arbitrary data from your Zabbix agent to the Zabbix server by using "UserParameter" fields in zabbix_server.conf, i.e. agent configuration file. </p>
<p>General syntax is:</p>
<blockquote>
<p>UserParameter=section[id], command</p>
</blockquote>
<p>For example, let's assume you want to monitor how many users are logged in. You would use:</p>
<blockquote>
<p>UserParameter=sys[num_users], who | wc -l</p>
</blockquote>
<p>(I assume you know how to configure the Zabbix server to receive this data, it's pretty straightforward - just create a new item, bind it to a template and connect a template to a server or server group).</p>
<p>If you want to monitor some file for a specific string, just use grep, sed, cut, tr and other standard Unix tools. If you need more complex things, just write a shell script.</p>
|
<p>Update to Igor's answer:</p>
<p>UserParameter is declared client-side in <code>zabbix_agentd.conf</code> or <code>zabbix_agent.conf</code> (depending on whether you're using the daemon or inetd version), not <code>zabbix_server.conf</code>.</p>
| 15,020
|
<p>I know that you can do this in SQL Server 2005, but I'm at a loss for 2000.</p>
|
<p>Not to my knowledge.</p>
<p>To get around this, I manage my stored procedures in a Visual Studio database project. Every stored procedure is in its own file and has a drop command at the top of the file. When I update the stored through Visual Studio, the database's created date is updated in the database because of the drop/create statement. I am able to use the created date in SQL Server 2000 as the last modified date in this manner.</p>
|
<p>From all the research I've done on this in the past, I unfortunately have to say no. SQL Server 2000 simply does not store this information, and I've never seen any solution for retrieving it.</p>
<p>There are a few alternative methods, but they all involve user intervention. Besides keeping stored procedure scripts in a source control system, I think the next best approach is to use comments inside the stored procedure. Not ideal, but it's better than nothing if you want to track what gets updated.</p>
| 19,818
|
<ul>
<li>I autoformat a GridView in ASP.NET.</li>
<li><p>It looks nice but the headers all run together like this:</p>
<p><strong>idfirstNamelastNameage</strong></p></li>
<li><p>I set CellPadding="5" but it does nothing.</p></li>
</ul>
<p>How can I set the cell padding of the headers and all cells?</p>
<p>A D D E N D U M :</p>
<p>Thanks Andrew, I fixed it with this. Works in Firefox and Explorer 7:</p>
<pre><code>.gridview2 tr td
{
padding: 5px;
border: 1px solid #ddd;
}
.gridview2 tr th
{
padding: 5px;
}
</code></pre>
|
<p>You should set a cssclass and use css to control it. The only property of a table you cant fully control cross browser with css is cellspacing.</p>
<pre><code>.myTableClass tr th {
padding: 5px;
}
</code></pre>
|
<p>Check the generated HTML and find the table it has created. Check the ID of the table. With the id, add following lines to your CSS. This worked for me when all else failed..</p>
<pre><code>#YourTableIdFoo th , #YourTableIdFoo td
{
padding-right: 1em;
}
</code></pre>
| 40,931
|
<p>In a static view, how can I view an old version of a file?</p>
<p>Given an empty file (called <code>empty</code> in this example) I can subvert <code>diff</code> to show me the old version:</p>
<pre>
% cleartool diff -ser empty File@@/main/28
</pre>
<p>This feels like a pretty ugly hack. Have I missed a more basic command? Is there a neater way to do this?</p>
<p>(I don't want to edit the config spec - that's pretty tedious, and I'm trying to look at a bunch of old versions.)</p>
<p><strong>Clarification</strong>: I want to send the version of the file to stdout, so I can use it with the rest of Unix (grep, sed, and so on.) If you found this question because you're looking for a way to save a version of an element to a file, see <a href="https://stackoverflow.com/questions/176858/in-clearcase-how-can-i-view-old-version-of-a-file-in-a-static-view-from-the-com/4962643#4962643">Brian's answer</a>.</p>
|
<blockquote>
<p>I'm trying to look at a bunch of old versions</p>
</blockquote>
<p>I am not sure if you are speaking about "a bunch of old versions" of <em>one file</em>, "a bunch of old versions" from <em>several</em> files.</p>
<p>To visualize several old versions of one file, the simplest mean is to display its version tree (<code>ct lsvtree -graph File</code>), and then select a version, right-click on it and '<code>Send To</code>' an editor which accepts multiple files (like Notepad++). In a few click you will have a view of those old versions.<br />
Note: you must have CC6.0 or 7.0.1 IFix01 (7.0.0 and 7.0.1 fail to 'sent to' a file with the following error message "<code>Access to unnamed file was denied</code>")</p>
<p>But to visualize several old versions of different files, I would recommend a dynamic view and editing the config spec of that view (and not the snapshot view you are currently working with), in order to quickly select all those old files (hopefully through a simple select rule like '<code>element * aLabel</code>')</p>
<hr />
<p>[From the comments:]</p>
<blockquote>
<p>what's the idiomatic way to "cat" an earlier revision of a file?</p>
</blockquote>
<p>The idiomatic way is through a <strong>dynamic</strong> view (that you configure with the exact same config spec than your existing snapshot view).</p>
<p>You can then browse (as in 'change directory to') the various <strong>extended paths</strong> of a file.</p>
<p>If you want to cat all versions of a branch of a file, you go in:</p>
<pre><code>cd /view/MyView/vobs/myVobs/myPath/myFile@@/main/[...]/maBranch
cat 1
cat 2
...
cat x
</code></pre>
<p>'<code>1</code>', '<code>2</code>', ... '<code>x</code>' being the version 1, 2, ... x of your file within that branch.</p>
<hr />
<p>For a <strong>snapshot view</strong>, the <strong>extended path is not accessible</strong>, so your "hack" is the way to go.</p>
<p>However, 2 remarks here:</p>
<ul>
<li>to quickly display all previous revisions of a snapshot file in a given branch, you can type:</li>
</ul>
<p>(one line version for copy-paste, Unix syntax:)</p>
<pre>
cleartool find addon.xml -ver 'brtype(aBranch) && !version(.../aBranch/LATEST) && ! version(.../aBranch/0)' -exec 'cleartool diff -ser empty "$CLEARCASE_XPN"'
</pre>
<p>(multi-line version for readability:)</p>
<pre>
cleartool find addon.xml -ver 'brtype(aBranch) &&
!version(.../aBranch/LATEST) &&
! version(.../aBranch/0)'
-exec 'cleartool diff -ser empty "$CLEARCASE_XPN"'
</pre>
<ul>
<li>you can quickly have an output a little nicer with</li>
</ul>
<p>(one line version for copy-paste, Unix syntax:)</p>
<pre>
cleartool find addon.xml -ver 'brtype(aBranch) && !version(.../aBranch/LATEST) && ! version(.../aBranch/0)' -exec 'cleartool diff -ser empty "$CLEARCASE_XPN"' | ccperl -nle '$a=$_; $b = $a; $b =~ s/^>+\s(?:file\s+\d+:\s+)?//g;print $b if $a =~/^>/'
</pre>
<p>(multi-line version for readability:)</p>
<pre>
cleartool find addon.xml -ver 'brtype(aBranch) &&
!version(.../aBranch/LATEST) &&
! version(.../aBranch/0)'
-exec 'cleartool diff -ser empty "$CLEARCASE_XPN"'
| ccperl -nle '$a=$_; $b = $a;
$b =~ s/^>+\s(?:file\s+\d+:\s+)?//g;
print $b if $a =~/^>/'
</pre>
<p>That way, the output is nicer.</p>
<hr />
<p>The <a href="http://publib.boulder.ibm.com/infocenter/cchelp/v7r0m1/index.jsp?topic=/com.ibm.rational.clearcase.cc_ref.doc/topics/ct_get.htm" rel="noreferrer">"<code>cleartool get</code>" command (man page)</a> <a href="https://stackoverflow.com/questions/176858/in-clearcase-how-can-i-view-old-version-of-a-file-in-a-static-view-from-the-com/4962643#4962643">mentioned below</a> by <a href="https://stackoverflow.com/users/612108/brian">Brian</a> don't do stdout:</p>
<blockquote>
<p>The get command copies only file elements into a view.</p>
<p>On a UNIX or Linux system, copy <code>/dev/hello_world/foo.c@@/main/2</code> into the current directory.</p>
</blockquote>
<pre><code>cmd-context get –to foo.c.temp /dev/hello_world/foo.c@@/main/2
</code></pre>
<blockquote>
<p>On a Windows system, copy <code>\dev\hello_world\foo.c@@\main\2</code> into the <code>C:\build</code> directory.</p>
</blockquote>
<pre><code>cmd-context get –to C:\build\foo.c.temp \dev\hello_world\foo.c@@\main\2
</code></pre>
<p>So maybe than, by piping the result to a <code>cat</code> (or <code>type</code> in windows), you can then do something with the output of said <code>cat</code> (<code>type</code>) command.</p>
<pre><code>cmd-context get –to C:\build\foo.c.temp \dev\hello_world\foo.c@@\main\2 | type C:\build\foo.c.temp
</code></pre>
|
<p>ct shell cat File@@version</p>
| 21,304
|
<p>I have a method which prints out the order of a set of images. I need to submit this to a new php page.</p>
<p>I have a form which currently prints out the order to the same page.</p>
<pre><code><form action="mainpage.php" method="post">
<div style="clear:both;padding-bottom:10px">
<input type="Button" style="width:100px" value="Show order" onclick="saveImageOrder()">
</div>
</code></pre>
<p><code>Saveimageorder()</code> shows the image and it saves the order in a variable called orderString</p>
<pre><code>function saveImageOrder()
{
var orderString = "";
var objects = document.getElementsByTagName('DIV');
for(var no=0;no<objects.length;no++)
{
if(objects[no].className=='imageBox' || objects[no].className=='imageBoxHighlighted')
{
if(orderString.length>0) orderString = orderString + ',';
orderString = orderString + objects[no].id;
}
}
document.getElementById('debug').innerHTML = 'This is the new order of the images(IDs) : <br>' + orderString;
}
</code></pre>
<p>How to do this?</p>
|
<p>You can submit the form with (note that this isn't tested):</p>
<pre><code>document.formname.submit();
</code></pre>
<p>If you need to change the action (the page to submit to) first:</p>
<pre><code>document.formname.action = 'some_other_url';
</code></pre>
<p>If you need to submit the form asynchronously you need to use a XMLHttpRequest or something similar.</p>
|
<p>with plain POST (no ajax) you need to store the result of your process (image order id retrieval) in an form field:</p>
<pre><code><input type="hidden" name="imagesorder" value=""/>
</code></pre>
<p>in your function, you can set the value to this field after the orderString is populated:</p>
<pre><code>document.getElementsByName('imagesorder')[0].value = orderString;
</code></pre>
<p>then submit the form, you can do this by replacing your </p>
<pre><code><input type="button" .../>
</code></pre>
<p>with</p>
<pre><code><input type="submit" .../>
</code></pre>
<p>on the server side you will then get the value in the post collection (I'm not php dev)</p>
<pre><code>$_POST['imagesorder']
</code></pre>
| 46,857
|
<p>I can think of plenty of good reasons to using it; however, what are the downsides to it?</p>
<p>(Apart from buying another server)</p>
<p>What are some advantages to using a daily build instead of it?</p>
|
<p>(It's worth noting that by "continuous integration" I mean <strong>automated</strong> integration with an <strong>automated</strong> build process and <strong>automatically</strong> runs tests and <strong>automatically</strong> detects failure of each piece.</p>
<p>It's also worth noting that "continuous integration" just means to a trunk or test server. It does not mean "push every change live".</p>
<p>There are plenty of ways to do continuous integration wrong.)</p>
<hr>
<p>I can't think of any reason not to do continuous integration testing. I guess I'm assuming that "continuous integration" includes testing. Just because it compiles doesn't mean it works.</p>
<p>If your build and/or tests take a long time then continuous integration can get expensive. In that case, run the tests obviously related to your change before the commit (coverage analysis tools, like <a href="http://search.cpan.org/perldoc?Devel::CoverX::Covered" rel="noreferrer">Devel::CoverX::Covered</a> can help discover what tests go with what code), do your integration testing after the commit using something like <a href="http://search.cpan.org/perldoc?SVN::Notify" rel="noreferrer">SVN::Notify</a>, and alert the developers if it fails. Archive the test results using something like <a href="http://sourceforge.net/projects/smolder" rel="noreferrer">Smolder</a>. That allows developers to work quickly without having to sit around watching test suites run, while still catching mistakes early.</p>
<p>That said, with a little work you can often you can speed up your build and test process. Many times slow tests are the result of each test having to do too much setup and teardown pointing at a system that's far too coupled requiring the whole system to be setup just to test a small piece.</p>
<p>Decoupling often helps, breaking out sub-systems into independent projects. The smaller scope makes for easier understanding and faster builds and tests. Each commit can do a full build and test without inconveniencing the programmer. Then all the sub-projects can be collected together to do integration testing.</p>
<p>One of the major advantages of running the test suite on every commit, even if it's after the commit, is you know just what broke the build. Rather than "something we did yesterday broke the build", or worse "four things we did yesterday broke the build in different ways and now we have to untangle it" it's "revision 1234 broke the build". You only have to examine that one revision to find the problem.</p>
<p>The advantage of doing a daily build is that at least you know there's a complete, clean build and test run happening every day. But you should be doing that anyway.</p>
|
<p>The only good reason not to do continuous integration comes when you've gotten your project working to the point where your integration tests hadn't identified any defect in a good long while and they're taking too much time to run every time you do a build. In other words: you've done enough continuous integration that you've proven to yourself that you no longer need it.</p>
| 26,388
|
<p>Looking for a better Windows XP command-line interface. The Visual Studio Command Prompt isn't near as nice as the Linux/OSX terminals. </p>
<p>Thoughts?</p>
<p><strong>edit:</strong></p>
<p>Answers: Console on Sourceforge, and the Windows Powershell. Thanks, I'll go dig them up and evaluate them.
The Cygwin package is too much overhead for what I want.</p>
<p><strong>edit2:</strong>
Looks like the Windows Powershell for now. Its copy&paste functionality isn't great, but MS supports it. </p>
|
<p>Take a look at Console2 <a href="http://sourceforge.net/projects/console/" rel="noreferrer">http://sourceforge.net/projects/console/</a></p>
<p>It's features:</p>
<p>"multiple tabs, text editor-like text selection, different background types, alpha and color-key transparency, configurable font, different window styles"</p>
|
<p>I see you put "powershell" as one of your tags. Maybe you could help direct our answers by explaining what you don't like about PowerShell as a replacement for cmd.exe?</p>
| 23,502
|
<p>I work on a complex application where different teams work on their own modules with a degree of overlap. A while back we got a Mediawiki instance set up, partly at my prompting. I have a hard job getting people to actually use it, let alone contribute.</p>
<p>I can see a lot of benefit in sharing information. It may at least reduce the times we reinvent the wheel.</p>
<p>The wiki is not very structured, but I'm not sure that is a problem as long as you can search for what you need.</p>
<p>Any hints?</p>
|
<p>Some tips:</p>
<p>Any time someone sends information by email that really should be in a wiki, make a page for that topic and add what they put in the email. Then reply "Thanks for that info, I've put it into the wiki here so that it's easier to find in the future." </p>
<p>Likewise, if you have information you need to share that should be in the wiki, put it there and just send an email with a link to it, rather than email people. </p>
<p>When you ask people for information, phrase it so that putting such documentation in the wiki should be considered the default or standard: "I searched in the wiki but I couldn't find it. Have you put that info up there yet?"</p>
<p>If you are the "wiki champion", make sure other people know how to use it, e.g. "Did I go through how to create a new page with you yet?"</p>
<p>Edit the sidebar to make sure it is relevant to your work.</p>
<p>Use "nav box" style templates on related pages for easier navigation.</p>
<p>Put something like {{Special:NewPages/5}} on the front page, or recent changes, so that people can see the activity.</p>
<p>Take a peek at Recent changes every few days or week, and if you notice someone adding information without being prodded, send them an email or drop by and give them a little compliment.</p>
|
<p>Find "sticky" items (sub-3 pg. docs / diagrams / etc) something that the team seems to be creating again and again & post it on the wiki. Make sure everyone has access to the wiki and knows its there - set up a notification mechanism if possible. With some luck, the next time they have to access, rather than dig it out of version control or their machines - they should hit the wiki.
If they still don't, try to see if the team has enough slack to actually use the wiki - Subtler issues may lie beneath their reluctance. </p>
| 3,668
|
<p>I want to put in a date and serial number that would be difficult to erase or change. Is it better to print in the number or engrave it in with a laser engraver.</p>
<p>Material will be anti-bacterial PLA.</p>
<p>It will be on free masks donated to schools, I want to make sure we can identify them when they show up at the market or in shops.</p>
|
<p>For this specific application, it may be better to think in terms of a <strong>Lot Number</strong> for each batch instead of individual serial numbers. This will still let you trace back an item for where it was originally allocated, and greatly simplify your processing.</p>
<p>Under this plan, you create the STL file for the basic part and before each printing batch open the base file in even a simple tool like MS 3D Builder or TinkerCAD to emboss your number and the date, re-slice, and print.</p>
<p>I actually recommend a <strong>deboss</strong> here, where the text is recessed into the piece instead of extended outward. In this way it will be more difficult to file away without damaging the part, and again, even the basic modelling tools can quickly customize an STL file in this way.</p>
<p>If you really need individual serial numbers, design the part with a basic recessed rectangular cutout and print these in bulk. Then print individual plates the exact size (very slightly smaller) than the cutout with the serial number and date debossed, and superglue the plates down.</p>
<p>Finally, be aware there's a limit to how small the text can be, based on the size of the nozzle and the capabilities of the printer, and you may find it difficult to print very small text.</p>
|
<p>Have you considered using a barcode rather than text. It would be easier to print clearly as there are no curves, and would be machine readable.</p>
| 2,058
|
<p>How do I group search results returned by Lucene by fields (similar to SQL Server's)?</p>
|
<p>Lucene 3.4 now supports faceted search. At indexing you specify something supplementary and at search time you search by query and by groups.</p>
<p>for next 3 docs, that you index with these groups</p>
<pre><code>doc1: monday, 1pm, 3min
doc2: monday, 1pm, 4min
doc3: monday, 2pm, 3min
</code></pre>
<p>you can search only for the first param: monday, and get value:3,
or you can drill down and search for monday/1pm and get value:2
or set depth of search 3 and get</p>
<pre><code>monday :3
monday/1pm :2
monday/1pm/3min :1
monday/1pm/4min :1
monday/2pm :1
monday/2pm/3min :1
</code></pre>
<p>here's the <a href="https://svn.apache.org/repos/asf/lucene/dev/tags/lucene_solr_3_5_0/lucene/contrib/facet/src/examples/org/apache/lucene/facet/example/simple/" rel="nofollow">source sample</a> : </p>
<p>But most of all read<a href="http://en.wikipedia.org/wiki/Faceted_search" rel="nofollow">faceted search</a></p>
|
<p>It's not clear whether you want a true SQL-like "GROUP BY" behavior, or merely an "ORDER BY" behavior. There's nothing like aggregation functions in Lucene, so "GROUP BY" would have to implemented in your application, on top of Lucene.</p>
<p>However, sorting by fields is fairly easy. Make sure the desired field is indexed, and create a <code>org.apache.lucene.search.Sort</code> object to be passed as part of the search criteria; most search methods have an overload that accepts a <code>Sort</code> instance.</p>
<p>If you were to implement your own "GROUP BY" logic, having the results "ORDERED BY" the correct fields is a helpful first step.</p>
| 44,587
|
<p>I am primarily a fluent .NET developer (as can be seen from the amount of posts and threads I make about .NET), but I thought it would be good to learn RoR.</p>
<p>In doing so, I have a few questions about the architecture of the language (Ruby) and the framework (RoR):</p>
<p>1) In .NET, every object is derived from System but inherits System.Object. So when I type System., I get a list of namespaces and then in those namespaces, classes and more namespaces.</p>
<p>Does Ruby not have this sort of hierarchy?</p>
<p>2) In some cases, I don't get the intellisense. For example, I wrote the class as outlined here (<a href="http://wiki.rubyonrails.org/rails/pages/HowToSendEmailsWithActionMailer" rel="nofollow noreferrer">http://wiki.rubyonrails.org/rails/pages/HowToSendEmailsWithActionMailer</a>) but in the line recipients user.email, nothing comes up when I type "user.".</p>
<p>Any idea why?</p>
<p>Thank</p>
|
<p>Dave Thomas (Pragmatic Programmers) has an excellent <a href="http://www.pragprog.com/screencasts/v-dtrubyom/the-ruby-object-model-and-metaprogramming" rel="nofollow noreferrer">screencast series</a> on the Ruby object model/metaprogramming. We watched this in a local Ruby user's group. The series isn't free, but it's not expensive either. You might want to check out the free preview to see if you think it is worth your time.</p>
<p>And to give you an answer. Yes, everything in Ruby derives from Object. You can find the docs on this at <a href="http://corelib.rubyonrails.org/" rel="nofollow noreferrer">http://corelib.rubyonrails.org/</a>. Look for the Object class.</p>
<p>I'm not sure why you aren't getting intellisense, partly because you haven't specified your IDE. It's possible that you can't because you've added the method dynamically and no intellisense is available.</p>
|
<ol>
<li>If we compare .NET to Rails then yes, there is this kind of hierarchy there. And in general, you can achieve this kind of hierarchy in any Ruby application via using modules.</li>
<li>I guess it's because of Ruby's dynamic nature. </li>
</ol>
| 49,070
|
<p>I have a problem with a memory leak in a .NET CF application. </p>
<p>Using <a href="http://blogs.msdn.com/stevenpr/archive/2006/04/17/577636.aspx" rel="nofollow noreferrer">RPM</a> I identified that dynamically creating controls are not garbage collected as expected. Running the same piece of code in .NET Window Forms behave differently and disposes the control as I expected.</p>
<p>See the output from RPM via PerfMon for the <strong><em>Process Heap</em></strong> counter: <br/>
<img src="https://i462.photobucket.com/albums/qq346/pfourie/ScreenShot191.jpg" alt="alt text"></p>
<p>GC Heap:<br/>
<img src="https://i462.photobucket.com/albums/qq346/pfourie/ScreenShot190a.jpg" alt="alt text"></p>
<p>My best guess is that the Weak Reference to the Panel is for some unknown reason not making the object eligible for GC, can it be?</p>
<p><strong>Please note:</strong> Even though <strong>Dispose()</strong> solves the problem for the sample, I can't easily incorporate it into the existing application as it is not as clear cut to determine when the object is no longer in use.</p>
<p>I have included a simplified version of the source to illustrate the problem:</p>
<pre><code>using System;
using System.Windows.Forms;
namespace CFMemTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// Calling this event handler multiple times causes the memory leak
private void Button1_Click(object sender, EventArgs e)
{
Panel uc = new Panel();
// Calling uc.Dispose() cleans up the object
}
}
}
</code></pre>
<p><strong>Update:</strong> <br/>
1. Calling GC.Collect() also doesn't result in the panels being cleaned up. <br/>
2. Using .NET CF 2.0 SP1 on a Windows CE 4.2 device.</p>
|
<p>Some additional information here that explains this behaviour.</p>
<p><a href="http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=4002811&SiteID=1&mode=1" rel="nofollow noreferrer">According to Ilya Tumanov</a>:</p>
<blockquote>
<p><strong>Everything UI related on NETCF is
intentionally removed from GC scope so
it is never collected</strong>. This behavior
is different from desktop and has been
changed in NETCF V3.5 (unless running
in compatibility mode).</p>
<p>It is so different because managed UI
classes on NETCF are completely
different from desktop. They are thin
wrappers over native implementation
which was needed to achieve acceptable
performance.</p>
<p>I’m not sure there’s such a resource.
But really, all you need to know is:
it’s never collected, must call
dispose. You actually should do that
on desktop as well but if you don’t
its way more forgiving. Not so on
NETCF.</p>
</blockquote>
|
<p>Are you sure you have a memory leak? The .NET Compact Framework garbage collector works slightly differently to the one in the full .NET framework. From <a href="http://blogs.msdn.com/stevenpr/archive/2004/07/26/197254.aspx" rel="nofollow noreferrer">Steven Pratschner's blog</a>:</p>
<blockquote>
<p>A collection is initiated when either:</p>
<ul>
<li><p>1MB of objects have been allocated,</p></li>
<li><p>An application is moved to the background,</p></li>
<li><p>A failure to allocate memory occurs</p></li>
<li><p>An application calls GC.Collect.</p></li>
</ul>
</blockquote>
| 24,505
|
<p>I was asked to manage and develop a project. The client does not really care if I hire people who would do it or I do it myself. Thus, I've decided to be more manager than developer. </p>
<p>Are there any (free / low cost) web projects that could help me to communicate with each "sub-developer" outta there on Internet?</p>
<p>What I expect is to have similar project as basecamp, however sub-developers wouldn't know about each other because I would be communicator between them. It's possible that basecamp includes this kind of service, but I am not going to pay to every possible similar service to know this.</p>
<p>If you have some real-life experience with this kind of problem I'm about to encounter, please, write it here. </p>
<p>Thank you</p>
|
<p>As many open source projects found, <a href="http://trac.edgewall.org/" rel="nofollow noreferrer">trac</a> is a good fit - lightweight project management with integrated <a href="http://svn.tigris.org/" rel="nofollow noreferrer">subversion</a> interface:</p>
<blockquote>
<p>Trac is an enhanced wiki and issue tracking system for software development projects. Trac uses a minimalistic approach to web-based software project management. Our mission is to help developers write great software while staying out of the way. Trac should impose as little as possible on a team's established development process and policies.</p>
<p>It provides an interface to Subversion, an integrated Wiki and convenient reporting facilities.</p>
<p>Trac allows wiki markup in issue descriptions and commit messages, creating links and seamless references between bugs, tasks, changesets, files and wiki pages. A timeline shows all current and past project events in order, making the acquisition of an overview of the project and tracking progress very easy. The roadmap shows the road ahead, listing the upcoming milestones.</p>
</blockquote>
<p>Both <a href="http://trac.edgewall.org/" rel="nofollow noreferrer">trac</a> and <a href="http://svn.tigris.org/" rel="nofollow noreferrer">subversion</a> can be used from anywhere on the Web, using one of the free or low cost providers (for some references, see <a href="http://trac.edgewall.org/wiki/TracUsers" rel="nofollow noreferrer">TracUsers</a>).</p>
|
<p>It is possible that you can do this with the free version of <a href="http://www.aceproject.com/" rel="nofollow noreferrer">AceProject</a>.</p>
| 47,861
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.