instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>I have a site running in a Windows shared hosting environment. In their control panel for the shared hosting account I have it set to use ASP.NET version 3.0 but it doesn't say 3.5 SP1 specifically.</p>
<p>How can I view the installed version running on the server where my website is hosted in an asp.net page?</p>
|
<p>Thanks!</p>
<p>I just dropped <%=Environment.Version%> on a page and got 2.0.50727.3053</p>
|
<p>The hint from Brian Boatright by putting the <code><%=Environment.Version%></code> on a page, and save it in DotNetVersion.aspx, upload it, at testing on the right URL, world great.</p>
<p>Sadly it was an too old version for me: 1.1.4322.2443</p>
| 5,814
|
<p>It's a bit difficult to implement a deep object copy function. What steps you take to ensure the original object and the cloned one share no reference? </p>
|
<p>A safe way is to serialize the object, then deserialize. This ensures everything is a brand new reference.</p>
<p><a href="http://javatechniques.com/blog/low-memory-deep-copy-technique-for-java-objects/" rel="noreferrer">Here's an article</a> about how to do this efficiently.</p>
<p>Caveats: It's possible for classes to override serialization such that new instances are <em>not</em> created, e.g. for singletons. Also this of course doesn't work if your classes aren't Serializable.</p>
|
<p>Here is an easy example on how to deep clone any object:
Implement serializable first</p>
<pre><code>public class CSVTable implements Serializable{
Table<Integer, Integer, String> table;
public CSVTable() {
this.table = HashBasedTable.create();
}
public CSVTable deepClone() {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(this);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
return (CSVTable) ois.readObject();
} catch (IOException e) {
return null;
} catch (ClassNotFoundException e) {
return null;
}
}
}
</code></pre>
<p>And then</p>
<pre><code>CSVTable table = new CSVTable();
CSVTable tempTable = table.deepClone();
</code></pre>
<p>is how you get the clone.</p>
| 8,952
|
<p>When I do:</p>
<pre><code>$ find /
</code></pre>
<p>It searches the entire system.<br>
How do I prevent that?</p>
<p>(This question comes from an "<a href="https://stackoverflow.com/questions/18836/why-doesnt-find-find-anything#26182">answer</a>" to another question.)</p>
|
<p>Consider:</p>
<pre><code>-maxdepth n
True if the depth of the current file into the tree is less than
or equal to n.
-mindepth n
True if the depth of the current file into the tree is greater
than or equal to n.
</code></pre>
|
<p>Use the <strong>-prune</strong> option.</p>
| 4,673
|
<p>I have a DataGrid, populated with objects in an ArrayCollection. After updating one of the objects' fields, I want the screen to update. The data source is not bindable, because I'm constructing it at runtime (and I don't understand how to make it bindable on the fly yet -- that's another question).</p>
<p>In this situation, if I call InvalidateDisplayList() on the grid nothing seems to happen. But if I call invalidateList(), the updates happen. (And it's very smooth too -- no flicker like I would expect from invalidating a window in WIN32.)</p>
<p>So the question: what is the difference between InvalidateList and InvalidateDisplayList? From the documentation it seems like either one should work.</p>
|
<p>invalidateList tells the component that the data has changed, and it needs to reload it and re-render it.</p>
<p>invalidateDisplayList tells the component that it needs to redraw itself (but not necessarily reload its data).</p>
|
<p>invalidateDisplayList() merely sets a flag so that updateDisplayList() can be called later during a screen update. invalidateList() is what you want. </p>
<p><a href="http://livedocs.adobe.com/flex/2/langref/mx/core/UIComponent.html#invalidateDisplayList()" rel="nofollow noreferrer">http://livedocs.adobe.com/flex/2/langref/mx/core/UIComponent.html#invalidateDisplayList()</a></p>
| 9,995
|
<p>I frequently work with multiple instances of Visual Studio, often working on different branches of the same solution.</p>
<p><a href="https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Strictly_32-bit_versions" rel="noreferrer">Visual C++ 6.0</a> used to display the full path of the current source file in its title bar, but Visual Studio 2005 doesn't appear to do this. This makes it slightly more awkward than it should be to work out which branch of the solution I'm currently looking at (the quickest way I know of is to hover over a tab so you get the source file's path as a tooltip).</p>
<p>Is there a way to get the full solution or file path into the title bar, or at least somewhere that's always visible, so I can quickly tell which branch is loaded into each instance?</p>
|
<p>There is not a native way to do it, but you can achieve it with a macro. The details are described here in full: <em><a href="https://www.helixoft.com/blog/how-to-show-full-file-path-or-anything-else-in-vs-2005-title-bar.html" rel="nofollow noreferrer">How To Show Full File Path (or Anything Else) in VS 2005 Title Bar</a></em></p>
<p>You just have to add a little Visual Basic macro to the EvironmentEvents macro section and restart Visual Studio.</p>
<p>Note: The path will not show up when you first load Visual Studio, but it will whenever you change which file you are viewing. There is probably a way to fix this, but it doesn't seem like a big deal.</p>
|
<p>File > Preferences > Settings >> Window:Title</p>
<p>I just changed ${activeEditorShort} => ${activeEditorLong}</p>
<p>within the setting:
${dirty}${activeEditorLong}${separator}${rootName}${separator}${appName}</p>
<p>Worked immediately when I clicked a file.</p>
<p>Great help right in the setting ...</p>
<p>Window: Title --
Controls the window title based on the active editor. Variables are substituted based on the context:</p>
<p>${activeEditorShort}: the file name (e.g. myFile.txt).</p>
<p>${activeEditorMedium}: the path of the file relative to the workspace folder (e.g. myFolder/myFileFolder/myFile.txt).</p>
<p>...</p>
<p>Visual Studio Code
Version: 1.56.2
Date: 2021-05-12</p>
<p>I found one reference saying this existed since 2017.</p>
| 5,038
|
<p>Sometimes IE6 will render the text of a <code><ul></code> list the same color as the background color. If you select it, they show back up, or if you scroll the page up and back down.</p>
<p>It is obviously a rendering bug, but I was wondering if anyone knows of a workaround to make it reliable?</p>
|
<p>try giving it hasLayout with</p>
<pre class="lang-css prettyprint-override"><code>zoom: 1
</code></pre>
|
<p>Have you tried explicitly setting a line-height? For some reason this seems to be the solution to a great many IE6 rendering bugs!</p>
<p>e.g.</p>
<pre class="lang-css prettyprint-override"><code>.mylist {
line-height: 1.6em;
}
</code></pre>
| 6,378
|
<p>If I'm running a signed Java applet. Can I load additional classes from remote sources, in the same domain or maybe even the same host, and run them?</p>
<p>I'd like to do this without changing pages or even stopping the current applet. Of course, the total size of all classes is too large to load them all at once.</p>
<p>Is there a way to do this? And is there a way to do this with signed applets and preserve their "confidence" status?</p>
|
<p>I think classes are lazy loaded in applets. being loaded on demand.</p>
<p>Anyway, if the classes are outside of a jar you can simply use the applet classloader and load them by name. Ex:</p>
<pre><code>ClassLoader loader = this.getClass().getClassLoader();
Class clazz = loader.loadClass("acme.AppletAddon");
</code></pre>
<p>If you want to load classes from a jar I think you will need to create a new instance of URLClassLoader with the url(s) of the jar(s).</p>
<pre><code>URL[] urls = new URL[]{new URL("http://localhost:8080/addon.jar")};
URLClassLoader loader = URLClassLoader.newInstance(urls,this.getClass().getClassLoader());
Class clazz = loader.loadClass("acme.AppletAddon");
</code></pre>
<p>By default, applets are forbidden to create new classloaders. But if you sign your applet and include permission to create new classloaders you can do it.</p>
|
<p>Sounds like it should be possible (but I've never done it). Have you already had a look at Remote Method Invocation (<a href="http://java.sun.com/javase/technologies/core/basic/rmi/index.jsp" rel="nofollow noreferrer">RMI</a>)?</p>
| 8,536
|
<p>For this directory structure:</p>
<pre><code>.
|-- README.txt
|-- firstlevel.rb
`-- lib
|-- models
| |-- foo
| | `-- fourthlevel.rb
| `-- thirdlevel.rb
`-- secondlevel.rb
3 directories, 5 files
</code></pre>
<p>The glob would match: </p>
<pre><code>firstlevel.rb
lib/secondlevel.rb
lib/models/thirdlevel.rb
lib/models/foo/fourthlevel.rb
</code></pre>
|
<p>Apologies if I've missed the real point of the question but, if I was using sh/bash/etc., then I would probably use <em>find</em> to do the job:</p>
<pre><code>find . -name '*.rb' -type f
</code></pre>
<p>Globs can get a bit nasty when used from within a script and <em>find</em> is much more flexible.</p>
|
<p>Looks like it can't be done from <code>bash</code></p>
<p>If you using <code>zsh</code> then</p>
<pre><code>ls **/*.rb
</code></pre>
<p>will produce the correct result. </p>
<p>Otherwise you can hijack the <code>ruby</code> interpreter (and probably those of other languages) </p>
<pre><code>ruby -e "puts Dir.glob('**/*.rb')"
</code></pre>
<p>Thanks to Chris and Gaius for your answers.</p>
| 6,625
|
<p>I talked to a few friends who say that Drupal is amazing, and it is a way better than Joomla. What are the major differences/advantages?</p>
|
<p>The general consensus is that programmers prefer Drupal whereas mere mortals prefer Joomla. Joomla is praised for having a simpler user interface. (I personally don't agree with that; I think Joomla's UI is pretty painful to use. But then again, I'm looking at it with a programmer's eye.) Drupal, on the other hand, is praised for its high level of extensibility, along with its large library of high-quality (more or less) plug-ins that add features ("modules" in Drupal lingo) and many of which are extensible themselves.</p>
<p>Start using Joomla today, and you'll probably end up with a decent but not quite perfect web site tonight. Start using Drupal today, and you'll be able to build exactly the web site you're wishing for - once you've put the time in.</p>
<p>If you're considering parlaying your skills into a paid job one day, you should definitely side with Drupal.</p>
|
<p>What I like about Drupal is the plugin model: you have your core of drupal, and you can customize it however you want it by creating your own seperate template directory and modules (the plugins).</p>
<p>For a complete technical overview you can also tick Drupal and Joomla in <a href="http://www.cmsmatrix.org/matrix/cms-matrix" rel="nofollow noreferrer"><a href="http://www.cmsmatrix.org/matrix/cms-matrix" rel="nofollow noreferrer">http://www.cmsmatrix.org/matrix/cms-matrix</a></a></p>
| 8,924
|
<p>I'm wondering if there's any way to write CSS specifically for Safari using only CSS. I know there has to be something out there, but I haven't found it yet.</p>
|
<p>I think the question is valid. I agree with the other responses, but it doesn't mean it's a terrible question. I've only ever had to use a Safari CSS hack once as a temporary solution and later got rid of it. I agree that you shouldn't have to target just Safari, but no harm in knowing how to do it.</p>
<p>FYI, this hack only targets Safari 3, and also targets Opera 9.</p>
<pre><code>@media screen and (-webkit-min-device-pixel-ratio:0) {
/* Safari 3.0 and Opera 9 rules here */
}
</code></pre>
|
<p>This really depends on what you are trying to do. Are you trying to do something special just in safari using some of the CSS3 features included or are you trying to make a site cross browser compliant?</p>
<p>If you are trying to make a site cross browser compliant I'd recommend writing the site to look good in safari/firefox/opera using correct CSS and then making changes for IE using conditional CSS includes in IE. This should (hopefully) give you compatibility for the future of browsers, which are getting better at following the CSS rules, and provide cross browser compatibility. <a href="http://creativebits.org/webdev/ie_conditional_css" rel="nofollow noreferrer">This is an example.</a></p>
<p>By using conditional stylesheets you can avoid hacks all together and target browsers.</p>
<p>If you are looking to do something special in safari check out <a href="http://trac.webkit.org/wiki/WebDevelopers" rel="nofollow noreferrer">this</a>.</p>
| 9,481
|
<p>I'm currently looking at the Python framework Django for future db-based web apps as well as for a port of some apps currently written in PHP. One of the nastier issues during my last years was keeping track of database schema changes and deploying these changes to productive systems. I haven't dared asking for being able to undo them too, but of course for testing and debugging that would be a great feature. From other questions here (such as <a href="https://stackoverflow.com/questions/1607/mechanisms-for-tracking-db-schema-changes">this one</a> or <a href="https://stackoverflow.com/questions/173/how-do-i-version-my-ms-sql-database-in-svn">this one</a>), I can see that I'm not alone and that this is not a trivial problem. Also, I found many inspirations in the answers there.</p>
<p>Now, as Django seems to be very powerful, does it have any tools to help with the above? Maybe it's even in their docs and I missed it?</p>
|
<p>There are at least two third party utilities to handle DB schema migrations, <a href="http://aeracode.org/projects/south/" rel="noreferrer">South</a> and <a href="http://code.google.com/p/django-evolution/" rel="noreferrer">Django Evolution</a>. I haven't tried either one, but I have heard some good things about South, though Evolution has been around a little longer. </p>
<p>Also, look at <a href="http://code.djangoproject.com/wiki/SchemaEvolution" rel="noreferrer">SchemaEvolution</a> on the Django wiki. It is just a wiki page about migrating the db.</p>
|
<p>And now there's also <a href="http://code.google.com/p/dmigrations/" rel="nofollow noreferrer">dmigrations</a>. From <a href="http://simonwillison.net/2008/Sep/3/dmigrations/" rel="nofollow noreferrer">announcement</a>:</p>
<blockquote>
<p>django-evolution attempts to address this problem the clever way, by detecting changes to models that are not yet reflected in the database schema and figuring out what needs to be done to bring the two back in sync. <strong>In contrast, dmigrations takes the stupid approach: it requires you to explicitly state the changes in a sequence of migrations, which will be applied in turn to bring a database up to the most recent state that reflects the underlying models.</strong></p>
<p>This means extra work for developers who create migrations, but it also makes the whole process completely transparent—for our projects, we decided to go with the simplest system that could possibly work.</p>
</blockquote>
<p>(My bold)</p>
| 4,035
|
<p>I need to add some simple image renders of STL files to a document. I currently open the STL files in Preview or one of the slicers and grab a screen shot.</p>
<p>Is there an easier or automatic way to generate PNG images from STL files on a Mac?</p>
|
<p>If you have <a href="http://www.openscad.org" rel="noreferrer">OpenSCAD</a> installed, this shell script will generate 100x100 pixel PNG images for each STL file in your current directory.</p>
<pre><code>for i in *.stl; do
T=__tmp__<span class="math-container">$i
b=`basename $</span>i`
echo import\(\"<span class="math-container">$i\"\)\; >$</span>T
/Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD -o <span class="math-container">$b.png --imgsize=100,100 $</span>T
rm $T
done
</code></pre>
<p>Credit to <a href="https://3dprinting.stackexchange.com/users/5740/0scar">0scar</a> for pointing out STL files can be imported into OpenSCAD.</p>
<p>Update: This code does the same, and generates an html file with annotated images of the files rendered. When I printed a batch of spare parts for my 3D printer I made a hardcopy and stuck it in the box so I could identify the parts later.</p>
<pre><code>n=-1
H=00-catalog.html
echo ><span class="math-container">$H '<table>'
echo >>$</span>H ' <tr>'
for i in <span class="math-container">$*; do
n=`expr $</span>n + 1`
if test $n = 4; then
n=0
echo >>$H ' </tr>'
echo >>$H ' <tr>'
fi
echo $i
T=__tmp__$i
B=`basename <span class="math-container">$i .stl`
echo import\(\"$</span>i\"\)\; ><span class="math-container">$T
/Applications/OpenSCAD.app//Contents/MacOS/OpenSCAD -o $</span>B.png --imgsize=200,200 <span class="math-container">$T
echo >>$</span>H
echo >><span class="math-container">$H ' <td>'$</span>i'<br><img src="'$B'.png"></td>'
rm <span class="math-container">$T
done
echo >>$</span>H ' </tr>'
echo >>$H '</table>'
</code></pre>
|
<p>You can use OpenSCAD, as stated in the accepted answer.
Here is a version of that script that works for Windows for anyone who needs it, as I did.</p>
<pre><code># Change height and width to the desired output image dimensions, in pixels.
# The path to openscad.exe may also have to be adjusted based on your installation.
height=1080
width=1080
for i in *.stl; do
T=__tmp__<span class="math-container">$i
b=`basename "$</span>i"`
echo import\(\"./<span class="math-container">$i\"\)\; > "$</span>T"
C:/'Program Files'/OpenSCAD/openscad.exe -o "<span class="math-container">$b".png --autocenter --viewall --imgsize=$</span>width,<span class="math-container">$height "$</span>T"
rm "$T"
done
</code></pre>
| 915
|
<p>I have a blogengine.net install that requires privatization.</p>
<p>I'm doing research work at the moment, but I have to keep my blog/journal private until certain conditions are met.</p>
<p>How can I privatize my blogEngine.net install so that readers must log in to read my posts?</p>
|
<p>I use this extension. Just save the file as RequireLogin.cs in your App_Code\Extensions folder and make sure the extension is activated.</p>
<pre><code>using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using BlogEngine.Core;
using BlogEngine.Core.Web.Controls;
using System.Collections.Generic;
/// <summary>
/// Summary description for PostSecurity
/// </summary>
[Extension("Checks to see if a user can see this blog post.",
"1.0", "<a href=\"http://www.lavablast.com\">LavaBlast.com</a>")]
public class RequireLogin
{
static protected ExtensionSettings settings = null;
public RequireLogin()
{
Post.Serving += new EventHandler<ServingEventArgs>(Post_Serving);
ExtensionSettings s = new ExtensionSettings("RequireLogin");
// describe specific rules for entering parameters
s.Help = "Checks to see if the user has any of those roles before displaying the post. ";
s.Help += "You can associate a role with a specific category. ";
s.Help += "All posts having this category will require that the user have the role. ";
s.Help += "A parameter with only a role without a category will enable to filter all posts to this role. ";
ExtensionManager.ImportSettings(s);
settings = ExtensionManager.GetSettings("PostSecurity");
}
protected void Post_Serving(object sender, ServingEventArgs e)
{
MembershipUser user = Membership.GetUser();
if(HttpContext.Current.Request.RawUrl.Contains("syndication.axd"))
{
return;
}
if (user == null)
{
HttpContext.Current.Response.Redirect("~/Login.aspx");
}
}
}
</code></pre>
|
<p>I would think it's possible to do this in the web config file by doing something like the following:</p>
<pre><code><system.web>
<authorization>
<allow roles="Admin" />
<deny users="*" />
</authorization>
</system.web>
</code></pre>
| 3,806
|
<p>I need to generate a random integer between 1 and n (where n is a positive whole number) to use for a unit test. I don't need something overly complicated to ensure true randomness - just an old-fashioned random number.</p>
<p>How would I do that?</p>
|
<p>To get a random integer value between 1 and N (inclusive) you can use the following.</p>
<pre><code>CInt(Math.Ceiling(Rnd() * n)) + 1
</code></pre>
|
<pre><code>Function xrand() As Long
Dim r1 As Long = Now.Day & Now.Month & Now.Year & Now.Hour & Now.Minute & Now.Second & Now.Millisecond
Dim RAND As Long = Math.Max(r1, r1 * 2)
Return RAND
End Function
</code></pre>
<p>[BBOYSE]
This its the best way, from scratch :P</p>
| 3,922
|
<p>My GPS logger occassionally leaves "unfinished" lines at the end of the log files. I think they're only at the end, but I want to check all lines just in case. </p>
<p>A sample complete sentence looks like:</p>
<pre><code>$GPRMC,005727.000,A,3751.9418,S,14502.2569,E,0.00,339.17,210808,,,A*76
</code></pre>
<p>The line should start with a <code>$</code> sign, and end with an <code>*</code> and a two character hex checksum. I don't care if the checksum is correct, just that it's present. It also needs to ignore "ADVER" sentences which don't have the checksum and are at the start of every file.</p>
<p>The following Python code might work: </p>
<pre><code>import re
from path import path
nmea = re.compile("^\$.+\*[0-9A-F]{2}$")
for log in path("gpslogs").files("*.log"):
for line in log.lines():
if not nmea.match(line) and not "ADVER" in line:
print "%s\n\t%s\n" % (log, line)
</code></pre>
<p>Is there a way to do that with <code>grep</code> or <code>awk</code> or something simple? I haven't really figured out how to get <code>grep</code> to do what I want.</p>
<p><strong>Update</strong>: Thanks @Motti and @Paul, I was able to get the following to do almost what I wanted, but had to use single quotes and remove the trailing <code>$</code> before it would work:</p>
<pre><code>grep -nvE '^\$.*\*[0-9A-F]{2}' *.log | grep -v ADVER | grep -v ADPMB
</code></pre>
<p>Two further questions arise, how can I make it ignore blank lines? And can I combine the last two <code>grep</code>s?</p>
|
<p>The minimum of testing shows that this should do it:</p>
<pre><code>grep -Ev "^\$.*\*[0-9A-Fa-f]{2}$" a.txt | grep -v ADVER
</code></pre>
<ul>
<li>-E use extended regexp</li>
<li>-v Show lines that do <strong>not</strong> match</li>
<li>^ starts with</li>
<li>.* anything</li>
<li>\* an asterisk </li>
<li>[0-9A-Fa-f] hexadecimal digit</li>
<li>{2} exactly two of the previous</li>
<li>$ end of line</li>
<li>| <code>grep -v ADVER</code> weed out the ADVER lines </li>
</ul>
<p>HTH, Motti.</p>
|
<p>@Motti: Combining the <code>grep</code>s isn't working, it's having no effect.</p>
<p>I understand that without the trailing <code>$</code> something else may folow the checksum & still match, but it didn't work at all with it so I had no choice...</p>
<p>GNU grep 2.5.3 and GNU bash 3.2.39(1) if that makes any difference.</p>
<p>And it looks like the log files are using DOS line-breaks (CR+LF). Does <code>grep</code> need a switch to handle that properly?</p>
| 5,735
|
<p>I'm new to MVC (and ASP.Net routing). I'm trying to map <code>*.aspx</code> to a controller called <code>PageController</code>. </p>
<pre><code>routes.MapRoute(
"Page",
"{name}.aspx",
new { controller = "Page", action = "Index", id = "" }
);
</code></pre>
<p>Wouldn't the code above map *.aspx to <code>PageController</code>? When I run this and type in any .aspx page I get the following error:</p>
<blockquote>
<p>The controller for path '/Page.aspx' could not be found or it does not implement the IController interface.
Parameter name: controllerType</p>
</blockquote>
<p>Is there something I'm not doing here?</p>
|
<blockquote>
<p>I just answered my own question. I had
the routes backwards (Default was
above page).</p>
</blockquote>
<p>Yeah, you have to put all custom routes above the Default route.</p>
<blockquote>
<p>So this brings up the next question...
how does the "Default" route match (I
assume they use regular expressions
here) the "Page" route?</p>
</blockquote>
<p>The Default route matches based on what we call Convention over Configuration. Scott Guthrie explains it well in his first blog post on ASP.NET MVC. I recommend that you read through it and also his other posts. Keep in mind that these were posted based on the first CTP and the framework has changed. You can also find web cast on ASP.NET MVC on the asp.net site by Scott Hanselman.</p>
<ul>
<li><a href="http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx" rel="noreferrer">http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx</a></li>
<li><a href="http://www.asp.net/MVC/" rel="noreferrer">http://www.asp.net/MVC/</a></li>
</ul>
|
<p>Not sure how your controller looks, the error seems to be pointing to the fact that it can't find the controller. Did you inherit off of Controller after creating the PageController class? Is the PageController located in the Controllers directory?</p>
<p>Here is my route in the Global.asax.cs</p>
<pre><code>routes.MapRoute(
"Page",
"{Page}.aspx",
new { controller = "Page", action = "Index", id = "" }
);
</code></pre>
<p>Here is my controller, which is located in the Controllers folder:</p>
<pre><code>using System.Web.Mvc;
namespace MvcApplication1.Controllers
{
public class PageController : Controller
{
public void Index()
{
Response.Write("Page.aspx content.");
}
}
}
</code></pre>
| 3,304
|
<p>Our library system just put a 3D printer in one of the branches. I have used SketchUp on the library computers for a number of years just to do artsy things. Suddenly, I have the opportunity to actually print something. (I'm really not sure why the libraries have SketchUp installed. But, I have enjoyed using it.)</p>
<p>There is a plug-in available for SketchUp so that it can export STL files. But, the security on the library computers will not allow me to put a file into the SketchUp plug-ins folder. And, the tech guy at the library doesn't think that the IT guys at the library will update all the copies of SketchUp at all the branches just so someone could do 3D printing.</p>
<p>After doing some searching on this website, I found out that I could export a COLLADA / dae file from SketchUp. I would then import that dae file into Blender (The portable version on my flash drive). I could then export it as an STL file.
The process appeared to work. I could see my test object in Blender. </p>
<p>I gave the STL file to the branch manager who tried to open it in the Makerbot software so that it could be sent to the printer. But, it gave him a message about the file not being recognized. </p>
<p>I am not familiar with all the details in the importing and exporting processes that are going on. Is there someone out there that can give me some help?</p>
<p>One problem is that, I am using the library computers. I cannot alter them. I can use what portable versions of software are out there, like Blender.</p>
|
<p>Here is what I suggest you try. If you have a file that you can view/edit in blender I would export it as both STL and OBJ formats. Then take those files and upload them to Netfabb (<a href="https://netfabb.azurewebsites.net/" rel="nofollow">https://netfabb.azurewebsites.net/</a>) and get a "repaired" file. Have the library try again with the repaired STL and OBJ files. If this doesn't work try to get the exact error message/dialog that the makerbot software is giving them as well as the version of the software that they are using.</p>
|
<p>Makerbot will accept obj files also.
Is there an error while importing the obj file?
Also you can see errors of your imported file in your makerbot
It will be marked in black.</p>
<p><a href="https://i.stack.imgur.com/pggIz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pggIz.png" alt="enter image description here"></a></p>
<p>Please make sure your object is a watertight mesh. As I have seen its easy to make a surface model in sketchup. A 3D Printer cannot print something in surface.
You can also try importing to netfabb to check if the part has errors in it. </p>
<p>If you want a better modeling software, I suggest you to check out OnShape.
Its a cloud based cad software. Its free as well. (10 private files, beyond that everything is public. 100$ per month i think)
www.onshape.com</p>
| 201
|
<p>If you were to write an GUI application that runs locally and calls a webservice, to be cross platform, can you do it with .Net, what tools would you recommend?</p>
<p>I was considering Java as it would be relatively easy to pick up due to its C# similarity and then I could use the JVM.</p>
|
<p>You should get familiar with the <a href="http://www.mono-project.com/Main_Page" rel="noreferrer">Mono project</a> and <a href="http://www.monodevelop.com/Main_Page" rel="noreferrer">MonoDevelop</a>; the express purpose of those projects is to allow building and running .NET code on a variety of platforms, including Windows, Linux, and Mac OSX.</p>
<p>Since the Mono is a re-implementation of .NET, it always lags a little behind Microsoft.NET, but they've got good coverage of .NET 2.0 and some .NET 3.x features. Note that Mono executes .NET binaries, so as long as your program features are supported by Mono, you can take an application EXE you complied on Windows and run it on Linux/Mono without recompiling.</p>
|
<p>Honestly I would evaluate your customer base and your existing skills. If you've got a 50/50 split, or even a 70/30 split of Windows to non-Windows, you'd likely be better off with Java or some other cross-platform toolkit. </p>
<p>Mono is a decent platform (See <a href="https://stackoverflow.com/questions/42627/best-practices-for-portable-c">this SO question asked about a week ago</a>), but if you are doing anything significant, I'd go with a toolkit designed for it.</p>
<p>BTW, if you want to see what a .NET GUI app looks like on Mono, here's a post I did whenever I got the NUnit GUI running on Mono:</p>
<p><a href="http://www.cornetdesign.com/2006/07/nunit-gui-running-green-on-monolinux.html" rel="nofollow noreferrer"><a href="http://www.cornetdesign.com/2006/07/nunit-gui-running-green-on-monolinux.html" rel="nofollow noreferrer">http://www.cornetdesign.com/2006/07/nunit-gui-running-green-on-monolinux.html</a></a></p>
| 7,988
|
<p>As the title says, is there a way to run the same Adobe AIR app more than once? I have a little widget I wrote that shows thumbnails from a couple of photo streams, and I'd like to fix it so I can look at more than one stream at a time. Thanks!</p>
|
<p>It seems that this is not possible. From the <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=app_launch_1.html" rel="nofollow noreferrer">documentation</a>:</p>
<blockquote>
<p>Only one instance of an AIR application is started. When an already running application is invoked again, AIR dispatches a new invoke event to the running instance.</p>
</blockquote>
<p>It also gives a possible workaround:</p>
<blockquote>
<p>It is the responsibility of an AIR to respond to an invoke event and take the appropriate action (such as opening a new document window).</p>
</blockquote>
<p>There is <a href="http://bugs.adobe.com/jira/browse/SDK-12915" rel="nofollow noreferrer">already a bug</a> related to this on the bugtracker, but it is marked closed with no explicit resolution given...</p>
|
<p>Last time I checked, an AIR app can only run a single instance. You could open multiple windows, but your app itself would have to support that. I hope they change this soon.</p>
| 6,121
|
<p>I'm sure many readers on SO have used <a href="https://www.lutzroeder.com/dotnet/" rel="nofollow noreferrer">Lutz Roeder</a>'s <a href="http://www.reflector.net/" rel="nofollow noreferrer">.NET reflector</a> to decompile their .NET code.
I was amazed just how accurately our source code could be recontructed from our compiled assemblies.</p>
<p>I'd be interested in hearing how many of you use obfuscation, and for what sort of products? </p>
<p>I'm sure that this is a much more important issue for, say, a .NET application that you offer for download over the internet as opposed to something that is built bespoke for a particular client. </p>
|
<p>I wouldn't worry about it too much. I'd rather focus on putting out an awesome product, getting a good user base, and treating your customers right than worry about the minimal percentage of users concerned with stealing your code or looking at the source.</p>
|
<p>Obsfucation is limited in it's effectiveness, it might keep the casual guy away. The most effective obsfucation is making only the smallest amount of code available to the user. If you can, make your app run depend heavily on a fat server.</p>
| 3,316
|
<p>Has anyone used the <a href="http://cmusphinx.sourceforge.net/html/cmusphinx.php" rel="nofollow noreferrer">Sphinx</a> speech recognition stack to build IVR applications? I am looking for open source alternatives to the expensive and somewhat limiting choices from MSFT and others. I have not been able to find a comprehensive package that ties open source speech/voip applications together.</p>
|
<p>You could try integrating Sphinx with <a href="http://www.asterisk.org/" rel="nofollow noreferrer">Asterisk</a>:</p>
<ul>
<li><a href="http://www.syednetworks.com/asterisk-integration-with-sphinx-voice-recognition-system" rel="nofollow noreferrer">http://www.syednetworks.com/asterisk-integration-with-sphinx-voice-recognition-system</a></li>
<li><a href="http://www.voip-info.org/wiki/view/Sphinx" rel="nofollow noreferrer">http://www.voip-info.org/wiki/view/Sphinx</a></li>
</ul>
|
<p>You could try integrating Sphinx with <a href="http://www.asterisk.org/" rel="nofollow noreferrer">Asterisk</a>:</p>
<ul>
<li><a href="http://www.syednetworks.com/asterisk-integration-with-sphinx-voice-recognition-system" rel="nofollow noreferrer">http://www.syednetworks.com/asterisk-integration-with-sphinx-voice-recognition-system</a></li>
<li><a href="http://www.voip-info.org/wiki/view/Sphinx" rel="nofollow noreferrer">http://www.voip-info.org/wiki/view/Sphinx</a></li>
</ul>
| 5,667
|
<p>I've printed mostly ABS in the past and encountered <a href="https://www.google.com/#q=3d+printing+layer+delamination">delamination</a> between layers many times. I've ensured the following conditions regularly:</p>
<ul>
<li>Build plate is level</li>
<li>Base of print isn't warped (using ABS slurry)</li>
<li>Prevent air draft. I've added acrylic panels to the sides of the machine and the machine is in a custom cupboard.</li>
<li>Nozzle temperature at about 225C</li>
<li>HBP temperature at about 112C (I live in NW USA, so the ambient temperature is typically fairly cool).</li>
<li>Using MakerBot filament</li>
</ul>
<p>What are some other variables to consider to help prevent delamination between layers?</p>
|
<p>Cool environmental conditions are the single biggest contributor to ABS delamination. Delamination or edge/corner cracking is caused by warping stresses when the first layer adhesion is stronger than the interlayer bonding. Or it happens when the heated build plate allows a strong non-warping foundation to be built until the print is too tall to be adequately warmed by the plate. In either case, the corners of the first layer can't lift, so the print cracks elsewhere to relieve the stress. </p>
<p>All ABS warping stress, in turn, is caused by the repeated thermal contraction of the fresh plastic layer at the top of the print. The FDM process sticks hot, expanded plastic onto cool, contracted plastic. When the new layer cools, it tries to contract, but it's stuck to a layer that is already fully cooled/contracted. This generates a large shear stress between the two layers. The accumulation of those shear stresses over many consecutive layers generates a large-scale bending force on the entire print. That's what causes both warping and delamination. </p>
<p><a href="https://i.stack.imgur.com/HZZam.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HZZam.png" alt="enter image description here"></a></p>
<p>The less the previous layer cools below the glass point of the plastic, the less thermal contraction it experiences before the next layer goes down, and therefore the less warping stress will accumulate as the <em>next</em> layer cools.</p>
<p>Environment temp is the biggest thing you can control:</p>
<ul>
<li>If your printer's environment is below 35C, you probably shouldn't even bother printing ABS. </li>
<li>A 50C environment is significantly better and will have minimal problems with warping and delamination. This is within the ambient temp ratings of most motors and electronics. Air-cooled extruders can typically extrude ABS reliably up to about 60C ambient, at which point they may be prone to clogging. And don't forget about plastic structural parts in your printer.</li>
<li>Industrial ABS printers with heated build chambers print ABS in a 75-85C environment, with lots of airflow. In terms of cooling regimes, ABS in an 80C chamber acts very similar to PLA in a room-temp environment. No warping, but lots of airflow required for good detail. </li>
</ul>
<p>Printing ABS at a higher nozzle temperature (say 240-250C) will also improve layer adhesion so delamination is less likely to occur. The same warping stresses will be there, but the layer bonding may be stronger than the internal stresses in the part so it survives printing.</p>
|
<p>wall size and filling are also parameters.
If wall size is too thin delamination is more visible</p>
| 273
|
<p>I've gone on quite a few sites (thingiverse, grabcad, etc) in search for a coiled tube, but I have yet to find anything suitable. There are a few coils ("springs") but no coiled tubes (i.e. the springs are hollow). Maybe my searching hasn't been good enough! But I was wondering if this is a limitation to 3D printing models? </p>
|
<p>I managed to do it in the end using AutoDesk 123D.</p>
<p><a href="https://i.stack.imgur.com/izeeR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/izeeR.png" alt="enter image description here"></a></p>
<p>Did it by making two coils of differing radius, then subtracting the smaller from the larger. I made each coil using the instructions found here:</p>
<p><div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/KfXV0mfy7XY?start=0"></iframe>
</div></div></p>
<p>So there we go...</p>
<p>Printed it out just now without supports - in the orientation shown - and it came out fine. Used a brim, though (don't want it rolling away!) </p>
|
<p>No, this is not a limitation. You should be able to create a coiled tube in almost every 3D design software package. However, how to do this depends on the specific 3D design software in use.</p>
<p>You'd generally do so by creating a cross-sectional profile (i.e. a hollow circle) and then sweeping it along a helical path. Another option is to first create a spring/coil, and then hollow it out (some CAD packages have a tool/command for this, usually called "shell").</p>
| 644
|
<p>(I'll begin by making it clear, I am not a .NET developer and am not tied to any other environment.)</p>
<p>Recently, I heard that the London Stock Exchange went down for an entire day. I've also heard that the software was written in .NET. Up to this point they would experience performance hits on busy days. People seem to be blaming .NET. </p>
<p>I don't want to debate the story, but it brought to mind the question of just how does .NET scale? How big is too big for .NET?</p>
|
<p>Honestly, I think it boils down to code optimization, apart from just the infrastructure.</p>
<p>In <a href="https://blog.stackoverflow.com/2008/08/podcast-19/">StackOverflow Podcast 19</a>, Jeff discussed about how they had to tweak SQL Server to handle the kinds of loads StackOverflow has; notice that it was not .NET that needed tweaking here.</p>
<p>One also has to note that <a href="http://weblogs.asp.net/scottgu/archive/2006/03/25/Handling-1.5-Billion-Page-Views-Per-Day-Using-ASP.NET-2.0.aspx" rel="nofollow noreferrer">MySpace.com, one of the most massive social networks out there, runs on ASP.NET</a>.</p>
<p>The MySpace use of ASP.NET alone is a testament to its scalability. It will boil down to how developers will write their applications in such a way that best leverages that capability.</p>
|
<p>It really bothers me when people say .NET is a platform of choice because 'its scalable', its no more or less scalable than any other platform: PHP, ColdFusion, JSP or native compiled apps with C++/Delphi etc... Scalability isn't a feature of the framework, it's a feature of the application design.</p>
<p>MySpace is certainly no advocate for scalability, instead look at the technology behind Google search, or the SETI@home project.</p>
<p>.NET is actually my least favorite platform to work with because its gone too far in trying to simplify software, so much so that there are things that I want to do that it can't, and so trying to overcome .NET limitations wastes time where it would have been easily and quickly achieved with C++ or PHP. .NET is to software development what duplo bricks are to mechanical engineering - no self respecting mechanical engineer would want to be constrained to using only inch wide square blocks.</p>
<p>If an application needs to be scalable you need to think about what data needs to be shared between servers, and what is the minimum data required for the application to run and serve its purpose. The need to scale an application can often be avoided by having super-efficient code in the first place (eg. not .NET or Java), but this generally requires a basic understanding of assembly at least and how your chosen language is translated to machine code.</p>
| 7,850
|
<p>Has anyone tried installing SQL Server 2008 Developer on a machine that already has 2005 Developer installed?</p>
<p>I am unsure if I should do this, and I need to keep 2005 on this machine for the foreseeable future in order to test our application easily. Since I sometimes need to take backup files of databases and make available for other people in the company I cannot just replace 2005 with 2008 as I suspect (but do not know) that the databases aren't 100% backwards compatible.</p>
<p>What kind of issues would arise? Do I need to install the new version with an instance name, will that work? Can I use a different port number to distinguish them?</p>
<p>I found this entry on technet: <a href="http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=3496209&SiteID=17" rel="noreferrer">http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=3496209&SiteID=17</a></p>
<p>It doesn't say more than just <em>yes you can do this</em> and I kinda suspected that this was doable anyway, but I need to know if there are anything I need to know before I start installing.</p>
<p>Anyone?</p>
|
<p>Yes this is possible. You will have to create a named instance not used by another version of SQL Server as per the previous answer and version 3.5 of .Net installed. Works great!!</p>
<p>Here the list of prerequisites:</p>
<ul>
<li>.NET Framework 3.5 SP1</li>
<li>Windows Installer 4.5</li>
<li>Windows PowerShell 1.0</li>
</ul>
|
<p>Unfortunately, it seems SQL Server 2008 Client Tools requires Visual Studio 2008 SP1, and I'm loath to install a beta of this on my main development machine.</p>
<p>I'll wait until SP1 is RTM before I move on.</p>
<p><strong>Edit</strong>: Yes, I do have Visual Studio 2008 on this machine, but I'd like to avoid beta installations of debugger applications. They tend to dig themselves too deep in for my taste.</p>
| 2,651
|
<p>What is the best approach to calculating the largest prime factor of a number?</p>
<p>I'm thinking the most efficient would be the following:</p>
<ol>
<li>Find lowest prime number that divides cleanly</li>
<li>Check if result of division is prime</li>
<li>If not, find next lowest</li>
<li>Go to 2.</li>
</ol>
<p>I'm basing this assumption on it being easier to calculate the small prime factors. Is this about right? What other approaches should I look into?</p>
<p>Edit: I've now realised that my approach is futile if there are more than 2 prime factors in play, since step 2 fails when the result is a product of two other primes, therefore a recursive algorithm is needed.</p>
<p>Edit again: And now I've realised that this does still work, because the last found prime number has to be the highest one, therefore any further testing of the non-prime result from step 2 would result in a smaller prime.</p>
|
<p>Actually there are several more efficient ways to find factors of big numbers (for smaller ones trial division works reasonably well). </p>
<p>One method which is very fast if the input number has two factors very close to its square root is known as <a href="http://en.wikipedia.org/wiki/Fermat's_factorization_method" rel="noreferrer">Fermat factorisation</a>. It makes use of the identity N = (a + b)(a - b) = a^2 - b^2 and is easy to understand and implement. Unfortunately it's not very fast in general.</p>
<p>The best known method for factoring numbers up to 100 digits long is the <a href="http://en.wikipedia.org/wiki/Quadratic_sieve" rel="noreferrer">Quadratic sieve</a>. As a bonus, part of the algorithm is easily done with parallel processing.</p>
<p>Yet another algorithm I've heard of is <a href="http://en.wikipedia.org/wiki/Pollard's_rho_algorithm" rel="noreferrer">Pollard's Rho algorithm</a>. It's not as efficient as the Quadratic Sieve in general but seems to be easier to implement.</p>
<hr>
<p>Once you've decided on how to split a number into two factors, here is the fastest algorithm I can think of to find the largest prime factor of a number:</p>
<p>Create a priority queue which initially stores the number itself. Each iteration, you remove the highest number from the queue, and attempt to split it into two factors (not allowing 1 to be one of those factors, of course). If this step fails, the number is prime and you have your answer! Otherwise you add the two factors into the queue and repeat.</p>
|
<p>I think it would be good to store somewhere all possible primes smaller then n and just iterate through them to find the biggest divisior. You can get primes from <a href="http://www.prime-numbers.org/" rel="nofollow noreferrer">prime-numbers.org</a>.</p>
<p>Of course I assume that your number isn't too big :)</p>
| 4,328
|
<p>What guidelines do you follow to improve the general quality of your code? Many people have rules about how to write C++ code that (supposedly) make it harder to make mistakes. I've seen people <em>insist</em> that every <code>if</code> statement is followed by a brace block (<code>{...}</code>).</p>
<p>I'm interested in what guidelines other people follow, and the reasons behind them. I'm also interested in guidelines that you think are rubbish, but are commonly held. Can anyone suggest a few?</p>
<p>To get the ball rolling, I'll mention a few to start with:</p>
<ul>
<li>Always use braces after every <code>if</code> / <code>else</code> statement (mentioned above). The rationale behind this is that it's not always easy to tell if a single statement is actually one statement, or a preprocessor macro that expands to more than one statement, so this code would break:</li>
</ul>
<pre>
// top of file:
#define statement doSomething(); doSomethingElse
// in implementation:
if (somecondition)
doSomething();
</pre>
<p>but if you use braces then it will work as expected.</p>
<ul>
<li>Use preprocessor macros for conditional compilation ONLY. preprocessor macros can cause all sorts of hell, since they don't allow C++ scoping rules. I've run aground many times due to preprocessor macros with common names in header files. If you're not careful you can cause all sorts of havoc!</li>
</ul>
<p>Now over to you.</p>
|
<p>A few of my personal favorites:</p>
<p>Strive to write code that is <a href="http://www.parashift.com/c++-faq-lite/const-correctness.html" rel="noreferrer">const correct</a>. You will enlist the compiler to help weed out easy to fix but sometimes painful bugs. Your code will also tell a story of what you had in mind at the time you wrote it -- valuable for newcomers or maintainers once you're gone.</p>
<p>Get out of the memory management business. Learn to use smart pointers: <code>std::auto_ptr</code>, <code>std::tr1::shared_ptr</code> (or <code>boost::shared_ptr</code>) and <code>boost::scoped_ptr</code>. Learn the differences between them and when to use one vs. another.</p>
<p>You're probably going to be using the Standard Template Library. Read the <a href="https://rads.stackoverflow.com/amzn/click/com/0201379260" rel="noreferrer" rel="nofollow noreferrer">Josuttis book</a>. Don't just stop after the first few chapters on containers thinking that you know the STL. Push through to the good stuff: algorithms and function objects.</p>
|
<p>make sure you indent properly</p>
| 8,565
|
<p>Occasionally, I find that while debugging an ASP.Net application (written in visual studio 2008, running on Vista 64-bit) the local ASP.Net development server (i.e. 'Cassini') stops responding.</p>
<p>A message often comes up telling me that "Data Execution Prevention (DEP)" has killed WebDev.WebServer.exe</p>
<p>The event logs simply tell me that "WebDev.WebServer.exe has stopped working"</p>
<p>I've heard that this 'problem' presents itself more often on Vista 64-bit because DEP is on by default. Hence, turning DEP off may 'solve' the problem.</p>
<p>But i'm wondering: </p>
<p><em>Is there a known bug/situation with Cassini that causes DEP to kill the process?</em></p>
<p><em>Alternatively, what is the practical danger of disabling Data Execution Prevention?</em></p>
|
<p>The only way to know for sure would be to dig through the Cassini source and see if there are any areas where it generates code on the heap and then executes it without clearing the NX flag.</p>
<p>However, instead of doing that, why not use IIS?</p>
<p>EDIT:</p>
<p>The danger of disabling DEP is that you open up security holes. DEP works by not allowing arbitrary generated code on the heap to be executed. This helps prevent malware programs from inserting code into the data segments of legit programs.</p>
|
<p>Thanks for the answers. I guess I developed such an aversion to IIS in the .net 1.x era that I've refused to consider re-using it -- until now.</p>
<p><em>aside: when choosing between two equally acceptable answers from ChanChan and Jonathan, I arbitrarily marked Jonathan's as 'accepted' because a) he got in first and b) his rep is currently lower.</em></p>
| 3,978
|
<p>We have a SharePoint WSS site and some of our users on on the Mac OSX platform. Are there any tips or tricks to get a similar experience to Windows with document shares and calendars on the Mac?</p>
<p>Edit: Browsing a SharePoint WSS site on a Mac, whether using Firefox or Safari, has a very similar look and feel as it does on Windows IE. The similar experience I am looking for has to do with integrating the calendars, document shares, etc. into the desktop.</p>
<p>For example, with IE you can go to a calendar and select "Actions -> Connect to Outlook" and it will make the calendar visible and manageable from within Outlook.</p>
<p>Is there any way to get the Mac to work similarly?</p>
|
<p>Unfortunately, the "full" Sharepoint Experience is limited to running Internet Explorer 6/7 and Office 2007.</p>
<p>On the Mac, I recommend using Firefox (Camino?) which seems to work a bit better than Safari.</p>
<p>Edit: When you say "Similar experience", what exactly are you missing? I don't have any Mac here, but I was under the impression that Office 2008 will have a working integration with Sharepoint as well.</p>
|
<p>ActiveX is used to enable the bridge between MOSS and Office, and as ActiveX is only on Windows, you will find that you cannot get the full experience if you do not use Windows as your OS.</p>
| 3,041
|
<p>I'm using <a href="http://www.helicontech.com/isapi_rewrite/" rel="nofollow noreferrer">Helicon's ISAPI Rewrite 3</a>, which basically enables .htaccess in IIS. I need to redirect a non-www URL to the www version, i.e. example.com should redirect to www.example.com. I used the following rule from the examples but it affects subdomains:</p>
<pre><code>RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
</code></pre>
<p>This works for most part, but is also redirect sub.example.com to www.sub.example.com. How can I rewrite the above rule so that subdomains do not get redirected?</p>
|
<p>Append the following RewriteCond:</p>
<pre><code>RewriteCond %{HTTP:Host} ^[^.]+\.[a-z]{2,5}$ [NC]
</code></pre>
<p>That way it'll only apply the rule to nondottedsomething.uptofiveletters as you can see, subdomain.domain.com will not match the condition and thus will not be rewritten.</p>
<p>You can change [a-z]{2,5} for a stricter tld matching regex, as well as placing all the constraints for allowed chars in domain names (as [^.]+ is more permissive than strictly necessary).</p>
<p>All in all I think in this case that wouldn't be necessary.</p>
<p>EDIT: sadie spotted a flaw on the regex, changed the first part of it from [^.] to [^.]+</p>
|
<p>Can't you adjust the RewriteCond to only operate on example.com?</p>
<pre><code>RewriteCond %{HTTP:Host} ^example\.com(.*) [NC]
</code></pre>
| 7,374
|
<p>A Sprint cellular modem plugs into a laptop - often the PCMCIA slot. To connect, the user opens a program called the Connection Manager. This program has a menu option to display the serial number and phone number of the modem that's currently inserted.</p>
<p>Does that imply that the serial/phone number of the modem could be available to other programs running on the system? (Note: let's assume this is Windows XP.)</p>
<p>Specifically, could a company's VPN software be configured to pass along information about which modem is being used to connect?</p>
<p>Finally, is there existing VPN software that already does this, or would it have to be custom-programmed?</p>
|
<p>You could send the mail asynchronous. That way the timeout should not interrupt your sending.</p>
<p>This article should help you get started with that: <a href="http://www.eggheadcafe.com/articles/20030720.asp" rel="nofollow noreferrer">Sending Emails Asynchronously in C#</a>.</p>
<p>There is another approach here: <a href="http://www.vikramlakhotia.com/Sending_Email_asynchronously_in_AspNet_20.aspx" rel="nofollow noreferrer">http://www.vikramlakhotia.com/Sending_Email_asynchronously_in_AspNet_20.aspx</a></p>
<p>And off course there are several commercial clients available, but the only one that i have tried and can recommend is <a href="http://www.aspnetemail.com/" rel="nofollow noreferrer">http://www.aspnetemail.com/</a></p>
|
<p>Definitely spawn it off on a background worker process so they go out asynchronously. </p>
<p>BTW, 5-10 seconds per e-mail seems way slow to me. On my server it takes just fractions of a second per e-mail. </p>
| 8,118
|
<p>I'm tearing my hair out with this one. If I start a block comment <code>/*</code> in VS.NET 2005+ then carriage return, Visual Studio insists that I have another asterisk <code>*</code>. I know there's an option to turn this off but I just can't find it. Anyone know how to turn this feature off?</p>
|
<p><strong>Update: this setting was changed in VS 2015 update 2. See <a href="https://stackoverflow.com/a/36319097/4294399">this answer</a>.</strong></p>
<p><a href="http://forums.msdn.microsoft.com/en-US/csharpide/thread/a41e3652-efe2-4f81-ad3e-94994974fcb2/" rel="nofollow noreferrer">This post</a> addresses your question. The gist of it is:</p>
<pre><code>Text Editor > C# > Advanced > Generate XML documentation comments for ///
</code></pre>
|
<p>Try this:</p>
<pre><code>#if false
whatever you want here
and here
#endif
</code></pre>
| 7,415
|
<p>I develop C++ applications in a Linux environment. The tools I use every day include Eclipse with the CDT plugin, gdb and valgrind.<br>
What tools do other people use? Is there anything out there for Linux that rivals the slickness of Microsoft Visual Studio?</p>
|
<p>I use a bunch of terminal windows. I have vim running on interesting source files, make and g++ output on another for compiler errors or a gdb session for runtime errors. If I need help finding definitions I run cscope and use vim's cscope support to jump around.</p>
<p>Eclipse CDT is my second choice. It's nice but huge, ungainly and slow compared to vim.</p>
<p>Using terminal windows and vim is very flexible because I do not need to carry 400 MB of Java around with me I can use SSH sessions from anywhere.</p>
<p>I use valgrind when I need to find a memory issue.</p>
<p>I use <code>strace</code> to watch what my software is doing on a system call level. This lets me clean up really stupid code that calls <code>time(0)</code> four times in a row or makes too many calls to <code>poll()</code> or non-blocking <code>read()</code> or things like calling <code>read()</code> on a socket to read 1 byte at a time. (That is <strong>super</strong> inefficient and lazy!)</p>
<p>I use <code>objdump -d</code> to inspect the machine code, especially for performance sensitive inner loops. That is how I find things like the slowness of the array index operator on strings compared to using iterators.</p>
<p>I use oprofile to try to find hot spots in optimized code, I find that it often works a little better than gprof, and it can do things like look for data and instruction cache misses. That can show you where to drop some helpful prefetch hints using GCC's <code>__builtin_prefetch</code>. I tried to use it to find hot mis-predicted branches as well, but couldn't get that to work for me.</p>
<p>Update: I've found that perf works way better than oprofile. At least on Linux. Learn to use perf and love it as I do.</p>
|
<p><a href="http://anjuta.sourceforge.net/" rel="nofollow noreferrer">Anjuta</a> is a nice idea that makes Linux C++ dev quite enjoyable as well.</p>
| 3,792
|
<p>I'm using Cura to slice my prints. I've noticed that when printing the bottom layer (and also the top layer, if it's flat), it first prints three walls, then fills in the middle by moving back and forth in straight lines.</p>
<p>I've noticed that for my parts, the walls look much nicer than the zig-zag pattern in the middle, and it also seems that the zig-zag part detaches from the bed quite easily, whereas the walls don't.</p>
<p>My parts would look much better, and possibly also stick better to the bed, if I set the number of walls to 100 or so, so that the parts would be entirely filled in with walls. But then the parts would be completely solid, which isn't what I want. So what I want to achieve is that the bottom layer (and if possible also the top layer) are printed as if the part was composed entirely of walls, but the other layers are printed with three walls as normal. Is this possible in Cura?</p>
|
<p>I found the answer myself just after posting - I'm posting it because it might be helpful to other Cura novices.</p>
<p>There is a setting for this, it's just that it's not shown by default. In print settings, you have to click on the three lines next to the search box, and select "Show All Settings". Then you can find a setting called "Top/Bottom Pattern". Setting this to "concentric" does what I described. </p>
<p>Actually this setting affects not just the top and bottom layers, but all layers that are part of the top and bottom shell. This seems like a good thing, but if you really want to affect <em>just</em> the bottom layer, there's a setting "Bottom Pattern Initial Layer" that does this. There is also a setting under "Experimental" called "Top Surface Skin Pattern" that I think does the same for just the top layer.</p>
<p>In addition to "Concentric" there is also a "Zig Zag" option that's quite similar to the default "Lines" mode.</p>
<p>You can also change the visibility of settings in the preferences menu, to make these settings show up by default.</p>
|
<p>The latest Cura that I have (4.2.1) includes "Ironing" in its options. When I enabled this, it prints the top layer twice. The first time with extrusion and the second time with just a little bit of extrusion (default is 10%) at 90 degrees to the first one. This effectively "irons out" the zig-zag pattern giving you a nice smooth top to your parts.
I was very impressed at how well this works (YMMV of course :-) ).</p>
| 1,490
|
<p>I need to decrement a Javascript date by 1 day, so that it rolls back across months/years correctly. That is, if I have a date of 'Today', I want to get the date for 'Yesterday'.</p>
<p>It always seems to take more code than necessary when I do this, so I'm wondering if there's any simpler way. </p>
<p>What's the simplest way of doing this?</p>
<p>[Edit: Just to avoid confusion in an answer below, this is a <strong>JavaScript</strong> question, not a Java one.]</p>
|
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var d = new Date();
d.setDate(d.getDate() - 1);
console.log(d);</code></pre>
</div>
</div>
</p>
|
<p><code>setDate(dayValue)</code></p>
<p><code>dayValue</code> is an integer from 1 to 31, representing the day of the month.</p>
<p>from <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Date/setDate" rel="nofollow noreferrer">https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Date/setDate</a></p>
<p>The behaviour solving your problem (and mine) seems to be out of specification range.</p>
<p>What seems to be needed are addDate(), addMonth(), addYear() ... functions.</p>
| 5,190
|
<p>In the vein of <em>programming questions</em>: suppose there's a collection of objects that can be compared to each other and sorted. What's the most efficient way to keep track of the smallest element in the collection as objects are added and the current smallest occasionally removed?</p>
|
<p>Using a min-heap is the best way.</p>
<p><a href="http://en.wikipedia.org/wiki/Heap_(data_structure)" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Heap_(data_structure)</a></p>
<p>It is tailor made for this application.</p>
|
<blockquote>
<p>If you need random insert and removal,
the best way is probably a sorted
array. Inserts and removals should be
O(log(n)).</p>
</blockquote>
<p>Yes, but you will need to re-sort on each insert and (maybe) each deletion, which, as you stated, is O(log(n)). </p>
<p>With the solution proposed by Harpreet:</p>
<ul>
<li>you have one O(n) pass in the beginning to find the smallest element</li>
<li>inserts are O(1) thereafter (only 1 comparison needed to the already-known smallest element)</li>
<li>deletes will be O(n) because you will need to re-find the smallest element (keep in mind Big O notation is worst case). You could also optimize by checking to see if the element to be deleted is the (known) smallest, and if not, just don't do any of the re-check to find the smallest element.</li>
</ul>
<p>So, it depends. One of these algorithms will be better for an insert-heavy use case with few deletes, but the other is overall more consistent. I think I would default to Harpreet's mechanism unless I knew that the smallest number would be removed often, because that exposes a weak point in that algorithm.</p>
| 5,414
|
<p>Could you use a 3D printer to make a 3D printer's parts? What is the most of a 3D printer that can be made this way? Could parts that break be replaced this way?</p>
|
<p>Yes, you can print most of the parts (electronics, linear guide rails, ball bearings and nuts and bolts, etc cannot be printed). Actually this was exactly the purpose of <a href="https://reprap.org/wiki/RepRap" rel="noreferrer">RepRap.org</a>:</p>
<blockquote>
<p>RepRap is humanity's first general-purpose self-replicating
manufacturing machine.</p>
</blockquote>
<p>and:</p>
<blockquote>
<p>Since many parts of RepRap are made from plastic and RepRap prints
those parts, RepRap self-replicates by making a kit of itself - a kit
that anyone can assemble given time and materials.</p>
</blockquote>
<p>There have been attempts in the past to even replicate the frames of printers (e.g. <a href="https://www.google.com/amp/s/www.digitaltrends.com/cool-tech/dollo-3d-printer-kickstarter/amp/" rel="noreferrer">Dollo 3D</a> or <a href="https://www.google.com/url?sa=t&source=web&rct=j&url=%23&ved=2ahUKEwiDrK3Ew8nfAhWBEVAKHcT8CKYQwqsBMAN6BAgLEAU&usg=AOvVaw0VTJzWxrN8ZFOD4xbU2nov" rel="noreferrer">Snappy</a>, but such designs are not very successful, printed frames are more flexible than metal frames.</p>
<hr>
<p><sub><em>I have built 2 custom printers myself using other printers to print parts and printed all printer parts for several others. It is possible to print <a href="https://www.thingiverse.com/thing:2476782" rel="noreferrer">your own linear bearings from POM</a>, I prefer these over the noisy metal bearings.</em>
</sub></p>
|
<p>You can print some of it but not all, as 3d printers can't print metal or silicon to make the boards and frame.</p>
| 1,154
|
<p>I have a custom installer action that updates the PATH environment, and creates an additional environment variable. Appending a directory to the existing path variable is working fine, but for some reason my attempts to create a new environment variable have been unsuccessful. The code I am using is:</p>
<pre><code> using (RegistryKey reg = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Control\Session Manager\Environment", true))
{
reg.SetValue("MYVAR", "SomeVal", RegistryValueKind.ExpandString);
}
</code></pre>
<p>Edit: The OS is 32-bit XP, and as far as I can tell it is failing silently.</p>
|
<p>Is there any reason that you have to do it through the registry?</p>
<p>If not, you can use Environment.SetEnvironmentVariable() since .NET 2.0. It allows you to set on a machine, process or user basis.</p>
|
<p>It turns out there was another problem that was preventing the code in my question from being called. However, I was using the Win32 assembly because the example code I was following was written before the Environment assembly became available. So Thanks Peter for pointing out the Environment API.</p>
| 6,210
|
<p>I am considering converting a project that I've inherited from .net 1.1 to .net 2.0. The main warning I'm concerned about is that it wants me to switch from <code>System.Web.Mail</code> to using <code>System.Net.Mail</code>.</p>
<p>I'm not ready to re-write all the components using the obsolete <code>System.Web.Mail</code>, so I'm curious to hear if any community members have had problems using it under .net 2.0?</p>
|
<p>System.Web.Mail is not a full .NET native implementation of the SMTP protocol. Instead, it uses the pre-existing COM functionality in CDONTS. System.Net.Mail, in contrast, is a fully managed implementation of an SMTP client.</p>
<p>I've had far fewer problems with System.Net.Mail as it avoids COM hell.</p>
|
<p>Yes, we had the same issue, and we decided not to upgrade either. We haven't seen any problems, so you're OK ignoring the warnings.</p>
| 9,017
|
<p>I sometimes need to modify OSS code or other peoples' code (usually C-based, but sometimes C++/Java) and find myself "grep"ing headers for types, function declarations etc. as I follow code flow and try to understand the system. Is there a good tool that exists to aid in code browsing. I'd love to be able to click on a type and be taken to the declaration or click on a function name and be taken to it's implementation. I'm on a linux box, so replies like "just use Visual Studio" won't necessarily work for me. Thanks!</p>
|
<p>You can't get anything better than <a href="http://www.sourceinsight.com" rel="noreferrer">SourceInsight</a>.</p>
|
<p>IntelliJ is pretty good as a source browser under Linux. It's got really good support for jumping between source and function declarations. Haven't tried it with C/C++ code, but it works well with Ruby and Java. </p>
| 9,376
|
<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>I'm not sure if many people know about this text-editor?</p>
<p>jEdit was kinda big in 2004, but now, Notepad++ seems to have taken the lead(on Windows)
Many of the plugins haven't been updated since 2003 and the overal layout and usage is confusing...</p>
<p>I'm sure jEdit has many nifty features, but I'll be damned if I can find out where to find them and how to use them. Reading that manual is a fulltime job on it's own.</p>
|
<p>I've been using jEdit for a few years now, mainly on windows, but also on Ubuntu.
I use it for: SQL, awk, batch files, html, xml, javascript...
Just about everything except .NET stuff (for which I use Visual Studio).<br />
I love it.</p>
<h2>summary</h2>
<p>I use jEdit because it has the right balance for me of <strong>ease of setting up</strong> vs. <strong>features</strong> and <strong>customisability</strong>. For me, no other editor strikes quite as good a balance.</p>
<h2>cons</h2>
<ul>
<li> It can be a bit hard to make it do the things you want. </li>
</ul>
<h2>pros</h2>
<ul>
<li> I love the <a href="http://plugins.jedit.org/list.php" rel="noreferrer"> plugins </a> </li>
<li> Being able to define my own syntax highlighting etc. is just what I want from a text editor. </li>
<li> The <a href="http://prdownloads.sourceforge.net/jedit/jedit4.3pre15manual-a4.pdf" rel="noreferrer">manual</a> is very good and quite readable. I strongly suggest reading it through to get an idea of what jEdit can do for you. (In fact, I suggest this for any software you use)
<li> It's cross-platform. I used it just on windows for a long time, but now I also use Ubuntu, and it works there: I can even copy the configuration files over from my windows machine, and everything works. Nice.
</ul>
<h2>other editors</h2>
<p>In the past I did take a look at <strong>Notepad++</strong>, but that was a while ago, and it didn't have a nice way to define your own syntax highlighting, which is important for me. I also paid for <strong>Textmate</strong> and <strong>UltraEdit</strong> at different times (both very good), but in the end, jEdit comes out on top for me.<br />
I also used <strong>Eclipse</strong> for a year or so. It's fantastic, and it'll do anything you want, <em>but</em> you have to be really into Eclipse to get the most out of it.</p>
|
<p>I had to use during my vocational education for XML and XSLT. It had a lot of bugs and didn't work always. I couldn't get to like it, but if I had to test some XSLT I'd give it another shot. I found Notepad++ and I am more than happy with it for what I need.</p>
<p>To your question: Did you take a look at <a href="http://plugins.jedit.org/list.php" rel="nofollow noreferrer">jEdit's plugin list</a>? There are some plugins released 2008 and the latest version was released on 8th August 2008.</p>
| 9,684
|
<p>I would love to start a small engraving business without having to purchase expensive hardware. </p>
<p>Using scrap parts at home, or parts from broken CD players, are there any ways to make a laser engraver at home? My cousin managed to make one of his own from scraps.</p>
|
<p>I have a printer and a diode laser head which will etch aluminum for under $4k, but you're going to have to manage potentially noxious fumes based on what material you're lasering. It's safe if used safely: the focal distance is 15-20mm from the lens, but all present should wear PPE.</p>
<p>Note: I work for Hyrel3D.</p>
|
<p>If you do not have knowledge about the electronics then consider buying a cheap etching machine instead.</p>
<h1>Build</h1>
<p>Take a look on <a href="https://hackaday.com/" rel="nofollow noreferrer">https://hackaday.com/</a> and search for laser engravers.</p>
<p>I have found following articles in few seconds:</p>
<ul>
<li><a href="https://hackaday.com/2013/05/06/dvd-laser-diode-used-to-build-a-laser-engraver/" rel="nofollow noreferrer">Hackaday.com: DVD LASER DIODE USED TO BUILD A LASER ENGRAVER</a></li>
<li><a href="https://hackaday.com/2016/03/14/laser-pcb-exposer-built-from-cd-rom-drives/" rel="nofollow noreferrer">Hackaday.com: LASER PCB EXPOSER BUILT FROM CD-ROM DRIVES</a></li>
<li><a href="https://hackaday.com/2017/10/31/homebuilt-laser-engraver-using-salvaged-parts/" rel="nofollow noreferrer">Hackaday.com: HOMEBUILT LASER ENGRAVER USING SALVAGED PARTS</a></li>
<li><a href="https://hackaday.com/2017/11/27/entry-level-3d-printer-becomes-budget-pcb-machine/" rel="nofollow noreferrer">Hackaday.com: ENTRY-LEVEL 3D PRINTER BECOMES BUDGET PCB MACHINE</a></li>
</ul>
<h1>Cheap laser engravers</h1>
<p>And this one is about 2018 list of laser cutters/engravers: <a href="https://all3dp.com/1/best-home-desktop-laser-cutter-engraver-aio-machine/%20It%20lists%20machines%20around%20100$" rel="nofollow noreferrer">15 Best Laser Cutters, Laser Engravers & AIO Machines of 2018</a>. It lists machines around 100$</p>
<ul>
<li>Meterk Laser Engraver ($125)</li>
<li>NEJE DK-8-KZ ($70)</li>
<li>QIILU Mini Laser Engraver ($130)</li>
<li>SuperCarver K2 ($160)</li>
</ul>
<h1>Safety</h1>
<p>Laser could damage your eyes (imagine laser reflection or if the machine falls from table when it's working). Take a look on <a href="https://en.wikipedia.org/wiki/Laser_safety" rel="nofollow noreferrer">wikipedia</a>.</p>
<p>The best option is to use <em>acrylic cover</em> in same color as your laser, so you can observe the etching process and the laser beam is always blocked. For example take a look on orange cover of <a href="https://formlabs.com/3d-printers/form-2/" rel="nofollow noreferrer">Formlabs Form 2</a> 3d printer (it uses laser for printing).</p>
<p>Another protection is to wear <em>laser protection glasses</em>. Again the glasses must have same color as your laser. </p>
<p>Using laser for cutting or engraving means to burn material away. You should have good ventilation in the room.</p>
<p>Buy a <em>smoke detector</em> if you use cheap electronics with higher power consumption.</p>
| 1,004
|
<p>How do I assign a method's output to a textbox value without code behind?</p>
<pre><code><%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Public TextFromString As String = "test text test text"
Public TextFromMethod As String = RepeatChar("S", 50) 'SubSonic.Sugar.Web.GenerateLoremIpsum(400, "w")
Public Function RepeatChar(ByVal Input As String, ByVal Count As Integer)
Return New String(Input, Count)
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Test Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%=TextFromString%>
<br />
<asp:TextBox ID="TextBox1" runat="server" Text="<%# TextFromString %>"></asp:TextBox>
<br />
<%=TextFromMethod%>
<br />
<asp:TextBox ID="TextBox2" runat="server" Text="<%# TextFromMethod %>"></asp:TextBox>
</div>
</form>
</body>
</html>
</code></pre>
<p>it was mostly so the designer guys could use it in the aspx page. Seems like a simple thing to push a variable value into a textbox to me.</p>
<p>It's also confusing to me why</p>
<pre><code><asp:Label runat="server" ID="label1"><%=TextFromString%></asp:Label>
</code></pre>
<p>and</p>
<pre><code><asp:TextBox ID="TextBox3" runat="server">Hello</asp:TextBox>
</code></pre>
<p>works but </p>
<pre><code><asp:TextBox ID="TextBox4" runat="server"><%=TextFromString%></asp:TextBox>
</code></pre>
<p>causes a compilation error.</p>
|
<p>There's a couple of different expression types in .ASPX files. There's:</p>
<pre><code><%= TextFromMethod %>
</code></pre>
<p>which simply reserves a literal control, and outputs the text at render time.</p>
<p>and then there's:</p>
<pre><code><%# TextFromMethod %>
</code></pre>
<p>which is a databinding expression, evaluated when the control is DataBound(). There's also expression builders, like:</p>
<pre><code><%$ ConnectionStrings:Database %>
</code></pre>
<p>but that's not really important here....</p>
<p>So, the <code><%= %></code> method won't work because it would try to insert a Literal into the .Text property...obviously, not what you want.</p>
<p>The <code><%# %></code> method doesn't work because the TextBox isn't DataBound, nor are any of it's parents. If your TextBox was in a Repeater or GridView, then this method would work.</p>
<p>So - what to do? Just call <code>TextBox.DataBind()</code> at some point. Or, if you have more than 1 control, just call <code>Page.DataBind()</code> in your <code>Page_Load</code>.</p>
<pre><code>Private Function Page_Load(sender as Object, e as EventArgs)
If Not IsPostback Then
Me.DataBind()
End If
End Function
</code></pre>
|
<p>Have you tried using an HTML control instead of the server control? Does it also cause a compilation error?</p>
<pre><code><input type="text" id="TextBox4" runat="server" value="<%=TextFromString%>" />
</code></pre>
| 5,665
|
<p>I am working with both <a href="http://activemq.apache.org/ajax.html" rel="nofollow noreferrer">amq.js</a> (ActiveMQ) and <a href="http://code.google.com/apis/maps/documentation/reference.html" rel="nofollow noreferrer">Google Maps</a>. I load my scripts in this order</p>
<pre><code><head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>AMQ & Maps Demo</title>
<!-- Stylesheet -->
<link rel="stylesheet" type="text/css" href="style.css"></link>
<!-- Google APIs -->
<script type="text/javascript" src="http://www.google.com/jsapi?key=abcdefg"></script>
<!-- Active MQ -->
<script type="text/javascript" src="amq/amq.js"></script>
<script type="text/javascript">amq.uri='amq';</script>
<!-- Application -->
<script type="text/javascript" src="application.js"></script>
</head>
</code></pre>
<p>However in my application.js it loads Maps fine but I get an error when trying to subscribe to a Topic with AMQ. AMQ depends on prototype which the error console in Firefox says object is not defined. I think I have a problem with using the amq object before the script is finished loading. <strong>Is there a way to make sure both scripts load before I use them in my application.js?</strong> </p>
<p>Google has this nice function call <code>google.setOnLoadCallback(initialize);</code> which works great. I'm not sure amq.js has something like this.</p>
|
<blockquote>
<p><strong>Is there a way to make sure both scripts load before I use them in my application.js?</strong></p>
</blockquote>
<p>JavaScript files should load sequentially <em>and block</em> so unless the scripts you are depending on are doing something unusual all you should need to do is load application.js after the other files.</p>
<p><a href="http://yuiblog.com/blog/2008/07/22/non-blocking-scripts/" rel="noreferrer">Non-blocking JavaScript Downloads</a> has some information about how scripts load (and discusses some techniques to subvert the blocking).</p>
|
<p>You can also use the built in SharePoint javascript method to control the execution of your scripts;</p>
<pre><code>_spBodyOnLoadFunctionNames.push("yourFunction");
</code></pre>
| 3,954
|
<p>I am re-factoring some code and am wondering about the use of a <code>lock</code> in the instance constructor.</p>
<pre><code>public class MyClass {
private static Int32 counter = 0;
private Int32 myCount;
public MyClass() {
lock(this) {
counter++;
myCount = counter;
}
}
}
</code></pre>
<p>Please confirm</p>
<ol>
<li>Instance constructors are thread-safe.</li>
<li>The lock statement prevents access to that code block, not to the static 'counter' member.</li>
</ol>
<p>If the intent of the original programmer were to have each instance know its 'count', how would I synchronize access to the 'counter' member to ensure that another thread isn't new'ing a <code>MyClass</code> and changing the count before this one sets its count?</p>
<p><em>FYI - This class is not a singleton. Instances must simply be aware of their number.</em></p>
|
<p>If you are only incrementing a number, there is a special class (Interlocked) for just that...</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.threading.interlocked.increment.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.threading.interlocked.increment.aspx</a></p>
<blockquote>
<p>Interlocked.Increment Method</p>
<p>Increments a specified variable and stores the result, as an atomic operation.</p>
</blockquote>
<pre><code>System.Threading.Interlocked.Increment(myField);
</code></pre>
<p>More information about threading best practices...</p>
<p><a href="http://msdn.microsoft.com/en-us/library/1c9txz50.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/1c9txz50.aspx</a></p>
|
<p>I think if you modify the <a href="http://en.wikipedia.org/wiki/Singleton_pattern#C.23" rel="nofollow noreferrer">Singleton Pattern</a> to include a count (obviously using the thread-safe method), you will be fine :)</p>
<h3>Edit</h3>
<p>Crap I accidentally deleted!</p>
<p>I am not sure if instance constructors <em>ARE</em> thread safe, I remember reading about this in a design patterns book, you need to ensure that locks are in place during the instantiation process, purely because of this..</p>
| 6,318
|
<p>I'm trying to print the following model:</p>
<p><a href="https://i.stack.imgur.com/b8cSN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b8cSN.jpg" alt="View 1" /></a></p>
<p><a href="https://i.stack.imgur.com/HGgi3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HGgi3.jpg" alt="View 2" /></a></p>
<p>I'm using <a href="https://www.simplify3d.com/" rel="nofollow noreferrer">Simplify3d</a> to print the model with the following settings on my <a href="https://www.qd3dprinter.com/" rel="nofollow noreferrer">Qidi X-pro</a>:</p>
<ul>
<li>Filament is ABS</li>
<li>Bed temp is 100 °C</li>
<li>Extruder temp is 230 °C</li>
<li>1 top layer</li>
<li>1 bottom layer</li>
<li>4 perimeter shells</li>
<li>The outside direction is 'outside in'.</li>
<li>Internal infill is triangular at 60 %.</li>
</ul>
<p>I've tried numerous tweaks to the settings, but, I can't seem to get a perfect perpendicular exterior wall as seen in the photos. The print more resembles a trapezoid. It appears like the walls are bowing inward. This also seems to throw off the dimensions. They aren't consistent. For example, the height of the part is 6 mm, but, in measuring with a caliper it shows 5.8 mm to 6.2 mm.</p>
<p>Can anyone tell me how I can get my external walls perpendicular?</p>
|
<p>You may be getting shrinking due to cooling on the non-top and non-bottom layers. Sixty percent infill is rather substantial. I'm printing 20 hour pieces in ABS at 100 °C / 250 °C using ten percent infill and getting nothing like what your image shows.</p>
<p>Can you do with a lower infill? More isn't always stronger. Four perimeter shells may be a factor but you'll probably see a difference with a smaller percentage infill.</p>
|
<p>If your object doesn't need to be flexible and can tolerate a more brittle material, PLA has better dimensional accuracy. Thus, it would be easier to get your desired shape.</p>
<p>Try two perimeter shells, but slow down the print speed of the perimeter.</p>
| 1,928
|
<p>I am using CCNET on a sample project with SVN as my source control. CCNET is configured to create a build on every check in. CCNET uses MSBuild to build the source code.</p>
<p>I would like to use the latest revision number to generate <code>AssemblyInfo.cs</code> while compiling.
How can I retrieve the latest revision from subversion and use the value in CCNET?</p>
<p>Edit: I'm not using NAnt - only MSBuild.</p>
|
<p>CruiseControl.Net 1.4.4 has now an <a href="http://confluence.public.thoughtworks.org/display/CCNET/Assembly+Version+Labeller" rel="noreferrer">Assembly Version Labeller</a>, which generates version numbers compatible with .Net assembly properties.</p>
<p>In my project I have it configured as:</p>
<pre><code><labeller type="assemblyVersionLabeller" incrementOnFailure="true" major="1" minor="2"/>
</code></pre>
<p>(Caveat: <code>assemblyVersionLabeller</code> won't start generating svn revision based labels until an actual commit-triggered build occurs.)</p>
<p>and then consume this from my MSBuild projects with <a href="http://msbuildtasks.tigris.org/" rel="noreferrer">MSBuildCommunityTasks.AssemblyInfo</a> :</p>
<pre><code><Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<Target Name="BeforeBuild">
<AssemblyInfo Condition="'$(CCNetLabel)' != ''" CodeLanguage="CS" OutputFile="Properties\AssemblyInfo.cs"
AssemblyTitle="MyTitle" AssemblyCompany="MyCompany" AssemblyProduct="MyProduct"
AssemblyCopyright="Copyright © 2009" ComVisible="false" Guid="some-random-guid"
AssemblyVersion="$(CCNetLabel)" AssemblyFileVersion="$(CCNetLabel)"/>
</Target>
</code></pre>
<p>For sake of completness, it's just as easy for projects using NAnt instead of MSBuild:</p>
<pre><code><target name="setversion" description="Sets the version number to CruiseControl.Net label.">
<script language="C#">
<references>
<include name="System.dll" />
</references>
<imports>
<import namespace="System.Text.RegularExpressions" />
</imports>
<code><![CDATA[
[TaskName("setversion-task")]
public class SetVersionTask : Task
{
protected override void ExecuteTask()
{
StreamReader reader = new StreamReader(Project.Properties["filename"]);
string contents = reader.ReadToEnd();
reader.Close();
string replacement = "[assembly: AssemblyVersion(\"" + Project.Properties["CCNetLabel"] + "\")]";
string newText = Regex.Replace(contents, @"\[assembly: AssemblyVersion\("".*""\)\]", replacement);
StreamWriter writer = new StreamWriter(Project.Properties["filename"], false);
writer.Write(newText);
writer.Close();
}
}
]]>
</code>
</script>
<foreach item="File" property="filename">
<in>
<items basedir="..">
<include name="**\AssemblyInfo.cs"></include>
</items>
</in>
<do>
<setversion-task />
</do>
</foreach>
</target>
</code></pre>
|
<p>Be careful. The structure used for build numbers is only a short so you have a ceiling on how high your revision can go.</p>
<p>In our case, we've already exceeded the limit.</p>
<p>If you attempt to put in the build number 99.99.99.599999, the file version property will actually come out as 99.99.99.10175.</p>
| 2,358
|
<p>Repetier-host has a setting to specify the "print area". That's roughly the size of the bed.</p>
<p>Note that the printer head can go out of those bounds, in my case my bed is very undersized compared to the printer frame, but this would also be an issue if you had clips or some obstacles in the bed.</p>
<p>Is there a similar setting in Cura where I can specify the "print area"/"bed size"/"margins" to be different from the printer width/depth?</p>
<p>Thanks.</p>
<p><strong>Repetier host settings:</strong></p>
<p><a href="https://i.stack.imgur.com/mAOAA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mAOAA.png" alt="Repetier-host" /></a></p>
|
<p>The print area settings would be in the Preferences > Printers. Select the particular printer on the left side pane, then click the "Machine Settings" button.</p>
<p><a href="https://i.stack.imgur.com/86dAH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/86dAH.jpg" alt="enter image description here" /></a></p>
<p>You will need to set a printing offset <a href="https://marlinfw.org/docs/gcode/M206.html" rel="nofollow noreferrer">(<code>M206</code>)</a> in Marlin: via <strong>Start G-code</strong> in Cura, or any other suitable way (LCD configuration, configuration files, etc.).</p>
|
<p>I am not sure this is the "official" solution for this, but I was able to define the "disallowed areas" in a custom printer definition.</p>
<p>I created a json file under C:\Program Files\Ultimaker Cura 4.8.0\resources\definitions for the printer, and added the machine_disallowed_areas section to "overrides".</p>
<pre><code> "machine_disallowed_areas": {
"default_value": [
[ [ -97.5, 90],[97.5,90] , [97.5,80] ,[-97.5,80] ] ,
[ [ -97.5, -57],[97.5,-57] , [97.5,-90] ,[-97.5,-90] ] ,
[ [ -97.5, -90], [-49.5, -90], [-49.5,90 ] ,[-97.5, 90] ],
[ [ 64.5, 90], [64.5, -90], [97.5, -90], [97.5,90 ] ]
]
}
</code></pre>
| 1,859
|
<p>We're looking for a Transformation library or engine which can read any input (EDIfact files, CSV, XML, stuff like that. So files (or webservices results) that contain data which must be transformed to a known business object structure.) This data should be transformed this to a existing business object using custom rules. XSLT is both to complex (to learn) and to simple (not enough features) </p>
<p>Can anybody recommend a C# library or engine? I have seen Altova MapForce but would like something I can send out to dozens of people who will build / design their own transformations without having to pay dozens of Altova licenses.</p>
|
<p>If you think that XSLT is too difficult for you, I think you can try LINQ to XML for parsing XML files. It is integrated in the .NET framework, and you can use C# (or, if you use VB.NET 9.0, better because of the XML literals) instead of learning another language. You can integrate it with the existing application without much effort and withouth the paradigm mismatch between the language and the file management that occurs with XSLT.</p>
<p><a href="http://www.google.it/url?sa=t&source=web&ct=res&cd=3&url=http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fbb387098.aspx&ei=6VrOSLmTN4qO8wThtpDsBQ&usg=AFQjCNEk8C3xS7mIRT5zr-2zfmDe9tYDqQ&sig2=uY2Nb-rBbWq9lstqUXyARQ" rel="nofollow noreferrer">Microsoft LINQ to XML</a></p>
<p>Sure, it's not a framework or library for parsing files, but neither XSLT is, so...</p>
|
<p><a href="http://www.microsoft.com/biztalk/en/us/default.aspx" rel="nofollow noreferrer">Microsoft BizTalk Server</a> does a very good job of this.</p>
| 8,742
|
<p>When it comes to web-design, I am horrible at producing anything remotely good looking. Thankfully there are a lot of free <a href="http://www.mantisatemplates.com/web-templates.php" rel="noreferrer">sources</a> for <a href="http://www.freecsstemplates.org/" rel="noreferrer">design</a> <a href="http://www.oswd.org/" rel="noreferrer">templates</a>. However, a problem with these designs is that they just cover a single page, and not many use cases. If you take a look at <a href="http://www.csszengarden.com/" rel="noreferrer">CSS Zen Gardens</a>, they have 1 single HTML file, and can radically style it differently by just changing the CSS file.</p>
<p>Now I am wondering if there is a standard HTML layout (tags and ids), that covers alot of use cases, and can be generically themed with different CSS files like Zen Garden. What I am imagining is a set of rules off how you write your html, and what boxes, lists, menus and styles you are supposed to use. A set of standard test pages covering the various uses can be created, and a new CSS file while have to support all the different pages in a nice view.</p>
<p>Is there any projects that covers anything similar to what I am describing?</p>
|
<p>Check out the <a href="http://developer.yahoo.com/yui/grids/" rel="nofollow noreferrer">Grids framework</a> from YUI. Particularly awesome is the <a href="http://developer.yahoo.com/yui/grids/builder/" rel="nofollow noreferrer">Grid Builder</a>. Also, they have a set of reset, base, and font CSS files that will give you a good baseline to build on.</p>
|
<p><a href="http://www.blueprintcss.org/" rel="nofollow noreferrer">BluePrintCSS</a> was, from what I know, the first CSS framework.
As YUI CSS Framework, It's help you to handle layout.</p>
<p>That kind of framework will help you to build multiple CSS for your site.</p>
<p>BluePrintCSS is a quite mature project so I encourage you to check it out.</p>
| 6,501
|
<p>Does anybody have links to site or pre built report running on the SQL Analysis Service provided by TFS2008?</p>
<p>Creating a meaningful Excel report or a new report sometime is a very boring and difficult taks, maybe finding a way to share reports could be a good idea?</p>
|
<p>Try this download: <a href="http://www.microsoft.com/downloads/details.aspx?familyid=a74486b2-f7db-4a85-97bd-46bf478bda60&displaylang=en" rel="nofollow noreferrer">Creating and Customizing TFS Reports</a>, it includes a few samples and some guidance. <a href="http://msdn.microsoft.com/en-us/library/cc487893.aspx" rel="nofollow noreferrer">More here</a>.</p>
<p>Also try the <a href="http://blogs.msdn.com/buckh/archive/2006/09/09/tfs-reporting.aspx" rel="nofollow noreferrer">TFS Reporting Samples.zip</a> linked from this site. </p>
<p>This site links to a large number of TFS reporting resources:
<a href="http://blogs.msdn.com/teams_wit_tools/archive/2007/03/26/tfs-report-developer-resources.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/teams_wit_tools/archive/2007/03/26/tfs-report-developer-resources.aspx</a> </p>
|
<p>If you are using SCRUM, this has Sprint reports and Product Burndown reports:</p>
<p><a href="http://www.scrumforteamsystem.com/en/default.aspx" rel="nofollow noreferrer">http://www.scrumforteamsystem.com/en/default.aspx</a></p>
| 9,873
|
<p>I am using <a href="http://msdn.microsoft.com/en-us/library/aa387410(VS.85).aspx" rel="nofollow noreferrer">Windows Media Format SDK</a> to capture the desktop in real time and save it in a WMV file (actually this is an oversimplification of my project, but this is the relevant part). For encoding, I am using the <a href="http://www.microsoft.com/windows/windowsmedia/forpros/codecs/video.aspx#WindowsMediaVideo9Screen" rel="nofollow noreferrer">Windows Media Video 9 Screen</a> codec because it is very efficient for screen captures and because it is available to practically everybody without the need to install anything, as the codec is included with Windows Media Player 9 runtime (included in Windows XP SP1).</p>
<p>I am making BITMAP screen shots using the GDI functions and feed those BITMAPs to the encoder. As you can guess, taking screen shots with GDI is slow, and I don't get the screen cursor, which I have to add manually to the BITMAPs. The BITMAPs I get initially are DDBs, and I need to convert those to DIBs for the encoder to understand (RGB input), and this takes more time. </p>
<p>Firing a profiler shows that about 50% of the time is spent in WMVCORE.DLL, the encoder. This is to be expected, of course as the encoding is CPU intensive.</p>
<p>The thing is, there is something called <a href="http://www.microsoft.com/windows/windowsmedia/forpros/encoder/default.mspx" rel="nofollow noreferrer">Windows Media Encoder</a> that comes with a SDK, and can do screen capture using the desired codec in a simpler, and more CPU friendly way.</p>
<p>The WME is based on WMF. It's a higher lever library and also has .NET bindings. I can't use it in my project because this brings unwanted dependencies that I have to avoid.</p>
<p>I am asking about the method WME uses for feeding sample data to the WMV encoder. The encoding takes place with WME exactly like it takes place with my application that uses WMF. WME is more efficient than my application because it has a much more efficient way of feeding video data to the encoder. It doesn't rely on slow GDI functions and DDB->DIB conversions. </p>
<p>How is it done?</p>
|
<p>The source to CamStudio, a GPL'd screencasting app that's been around for years (commercially and then open-srcd later) might be useful?</p>
<p><a href="http://sourceforge.net/project/showfiles.php?group_id=131922" rel="nofollow noreferrer">http://sourceforge.net/project/showfiles.php?group_id=131922</a></p>
<p>I'd suggest looking at the guts of VNC clients too, though they're probably very simplistic (I think just grabbing screenshots then jpg'ing the tiles that have changed since the last capture).</p>
<p>You might want to consider not using WMV9 as the encoder for on-the-fly encoding if it is too cpu-heavy? Maybe use an older, less efficient compressor (like MS RLE) as used by HyperCam and then compress to WMV afterwards? MS RLE has been a default install since at least Win2000 I believe:
<a href="http://wiki.multimedia.cx/index.php?title=Microsoft_RLE" rel="nofollow noreferrer">http://wiki.multimedia.cx/index.php?title=Microsoft_RLE</a></p>
<p>CamStudio's Lossless codec is GPL (same link as above), that offers pretty good compression (though you'd need to bundle the dll in your installer) and could be used on the fly, it works well with high compression on all modern systems.</p>
|
<p>It's been ages since I've done any Win32 coding, but AFAIK, WMF as a format is basically a list of GDI commands and their parameters which would explain why it is much more efficient to encode...</p>
<p>You'd probably need to hook into the top level GDI context (just as Remote Desktop does, I guess) and capture the GDI commands as they are called. I seem to remember there being some way of creating a WMF output GDI context which means you may be able to just delegate calls to it in some way. </p>
<p>I'm guessing here, but you may be able to find example code for the above in the TightVNC/QuickVNC for Windows projects as they would have to do something like that to capture changes on screen in an efficient way.</p>
| 8,900
|
<p>What's the simplest SQL statement that will return the duplicate values for a given column and the count of their occurrences in an Oracle database table?</p>
<p>For example: I have a <code>JOBS</code> table with the column <code>JOB_NUMBER</code>. How can I find out if I have any duplicate <code>JOB_NUMBER</code>s, and how many times they're duplicated?</p>
|
<p>Aggregate the column by COUNT, then use a HAVING clause to find values that appear greater than one time.</p>
<pre><code>SELECT column_name, COUNT(column_name)
FROM table_name
GROUP BY column_name
HAVING COUNT(column_name) > 1;
</code></pre>
|
<p>Also u can try something like this to list all duplicate values in a table say reqitem</p>
<pre><code>SELECT count(poid)
FROM poitem
WHERE poid = 50
AND rownum < any (SELECT count(*) FROM poitem WHERE poid = 50)
GROUP BY poid
MINUS
SELECT count(poid)
FROM poitem
WHERE poid in (50)
GROUP BY poid
HAVING count(poid) > 1;
</code></pre>
| 8,379
|
<p>I've bought a new type of filament (GreenTEC Pro Natural) for my Anycubic Mega i3 to print some food-safe cookie cutters. Now I have changed the print settings to an extruder temperature of 210 °C and a heated bed temperture of 60 °C and everything works well.</p>
<p>But when I look at the print, I see that too little filament is extruded at the beginning of an extrusion and at the end. So every time the nozzle is lifted to move without extruding, it takes too long for the filament to correctly start extruding again (see picture). </p>
<p><a href="https://i.stack.imgur.com/HUztR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HUztR.jpg" alt="enter image description here"></a></p>
<p>What can I do? Is there a setting to print slower at these points (I'm currently using Cura)? Maybe change retraction distance? Different extrusion temp? Before I used PLA from Anycubic and everything worked fine...</p>
|
<p>Check your retraction settings.. It's either too far or one of your priming/wipe settings is off, some slicers call it priming or extra restart distance. </p>
<p>Your linear advance "k" might be set wrong if you're using linear advance. </p>
<p>I see a bit of under-extrusion on the between walls and center, your overlap % might a little short. Or you're printing too fast for the filament to melt and deposit. </p>
|
<p>I think there's a retraction issue(had the same issue). You need to change retraction and check whether there are any improvements. Some times different filament types need slight filament setting calibration.</p>
| 1,525
|
<p>Given our successful private beta, soon after we go public it will be time for us to get our first crop of moderators, as explained in the <a href="http://blog.stackoverflow.com/2010/07/moderator-pro-tempore/">“Moderator Pro Tempore” blog post</a>:</p>
<blockquote>
<p>About a week into the public beta, we will seek out members who are deeply engaged in the community’s development; members who:</p>
<ul>
<li>Have a reasonably high reputation score to indicate active, consistent participation.</li>
<li>Show an interest in their meta’s community-building activities.</li>
<li>Lead by example, showing patience and respect for their fellow community members in everything they write.</li>
<li>Exhibit those intangible traits discussed in <a href="http://blog.stackoverflow.com/2009/05/a-theory-of-moderation/"><em>A Theory of Moderation</em></a>.</li>
</ul>
<p>Bonus points for:</p>
<ul>
<li>Members with participation in both meta and the parent site (i.e. interest in both community building and expertise in the field).</li>
<li>Area 51 participation, social network referrals, or blogging about the site.</li>
<li>Members who have already shown an interest or ability to promote their community.</li>
</ul>
<p>Candidates will be contacted and three of them will be selected to act as provisional Moderators until the community holds formal elections after the Beta period. Besides the normal abilities of a Moderator, they will:</p>
<ul>
<li>Have access to a special chat room where we will collectively work through the challenges of moderation and community self-policing.</li>
<li>Organize the process of selecting the site's attributes (domain names, design issues, the FAQ, etc.).</li>
<li>Rally community support and drive the mission of getting publicity for the site.</li>
</ul>
<p>Essentially, <strong>they will have the ear of the Stack Exchange team for anything we can do to help their sites succeed!</strong></p>
</blockquote>
<p>Although the moderators pro tempore will ultimately be selected by Stack Exchange, the purpose of this post is to seek out and propose candidates:</p>
<ul>
<li>Each nomination should be posted as an answer and it should include (at minimum) a link to the user's main and meta profile so we can check out their activity.</li>
<li>Self nominations are encouraged, step up if you feel you can help.</li>
<li>If you are nominated by someone else you should edit the answer and let us know if you accept or decline (explanation optional). If a nominee declines we will not delete the answer, as to not have someone else nominate them again.</li>
<li>If you are nominating someone else, please mark the post as Community Wiki before saving. Meta doesn't allow suggested edits, so your nominee may be blocked from accepting the nomination.</li>
<li>The nominations are not binding to Stack Exchange or the nominees. If you are being considered by Stack Exchange, you will get an official confirmation email at one point. </li>
<li>Before nominating someone or accept / decline a nomination, you should read <a href="http://blog.stackoverflow.com/2009/05/a-theory-of-moderation/"><em>A Theory of Moderation</em></a> thoroughly to find out what's generally expected from moderators.</li>
</ul>
<p>If you would like to learn more about the role, please drop into <a href="http://chat.stackexchange.com/rooms/34216/3d-printing">chat room</a> where you can ask about the role from other moderators (they appear with a blue name in the chat room). Another chatroom called <a href="http://chat.stackexchange.com/rooms/2691/the-assembly">The Assembly</a> was created specifically for users and moderators to discuss moderation activities, moderators from all over the network are there to answer your questions.</p>
<p>Once again, <strong>please don't hesitate to step up and self-nominate!</strong>. </p>
<p><sub>Thanks to <a href="https://chemistry.meta.stackexchange.com/users/30/fx">F'x</a> for the original version of this post <a href="https://chemistry.meta.stackexchange.com/q/113/17315">over on chemistry</a>.</sub></p>
|
<p>I would like to nominate myself, <a href="https://stackexchange.com/users/526476/matt-clark">Matt Clark</a>.</p>
<p><a href="http://stackexchange.com/users/526476/matt-clark"><img src="http://stackexchange.com/users/flair/526476.png" width="208" height="58" alt="profile for Matt Clark on Stack Exchange, a network of free, community-driven Q&A sites" title="profile for Matt Clark on Stack Exchange, a network of free, community-driven Q&A sites" /></a></p>
<p>While I might not have the wildest credentials or reputation, I have been around the StackExchange network for a while (11/2012) and generally know my way around the sites.</p>
<p>Mostly active on StackOverflow, I answer when I can, and try and do my part to clean up the review queue: ~5000 review tasks; I plan on giving this site as much attention as I can.</p>
<p>I started <a href="https://area51.stackexchange.com/proposals/82438/3d-printing">this 3D Printing proposal</a> just under a year ago on Area 51, and am either way, glad to see the day we made it to beta.</p>
|
<p>I would like to nominate myself for a moderator, I think I'd be up for the job.</p>
<p><a href="http://stackexchange.com/users/6668626/chase-cromwell">http://stackexchange.com/users/6668626/chase-cromwell</a></p>
<p>I'm probably not the best candidate and I'm not super active in meta or Stack Exchange, but I'm becoming more active.</p>
| 4
|
<p>I have the ISO week and year but how do I correctly convert that into two dates representing the start and end of that week?</p>
|
<p><code>ffmpeg</code> is a general purpose (de)muxer/transcoder. <code>MP4Box</code> is a (de)muxer/transcoder from <a href="http://gpac.wp.institut-telecom.fr/mp4box/" rel="nofollow noreferrer">GPAC</a>, a package dedicated to MP4 related software tech. Right now it seems wiser to use MP4Box because it writes the moov atom at the beginning of the file, which is important for streaming and ipod playing.</p>
<p>Use ffmpeg like this:</p>
<pre><code>ffmpeg -i input.aac -codec: copy output.m4a
</code></pre>
<p>Use MP4Box like this:</p>
<pre><code>MP4Box -add input.aac#audio output.m4a
</code></pre>
|
<p>Just use any mp4-Muxer like Yamb to create an <code>mp4</code>-file with only the <code>aac</code> audio track in it, then change the file extension to <code>m4a</code>.</p>
| 9,592
|
<p>I've got a div that uses overflow:auto to keep the contents inside the div as it is resized and dragged around the page. I'm using some ajax to retrieve lines of text from the server, then append them to the end of the div, so the content is growing downwards. Every time this happens, I'd like to use JS to scroll the div to the bottom so the most recently added content is visible, similar to the way a chat room or command line console would work.</p>
<p>So far I've been using this snippet to do it (I'm also using jQuery, hence the $() function):</p>
<pre><code>$("#thediv").scrollTop = $("#thediv").scrollHeight;
</code></pre>
<p>However it's been giving me inconsistent results. Sometimes it works, sometimes not, and it completely ceases to work if the user ever resizes the div or moves the scroll bar manually.</p>
<p>The target browser is Firefox 3, and it's being deployed in a controlled environment so it doesn't need to work in IE at all.</p>
<p>Any ideas guys? This one's got me stumped. Thanks!</p>
|
<p><code>scrollHeight</code> should be the total height of content. <code>scrollTop</code> specifies the pixel offset into that content to be displayed at the top of the element's client area.</p>
<p>So you really want (still using jQuery):</p>
<pre><code>$("#thediv").each( function()
{
// certain browsers have a bug such that scrollHeight is too small
// when content does not fill the client area of the element
var scrollHeight = Math.max(this.scrollHeight, this.clientHeight);
this.scrollTop = scrollHeight - this.clientHeight;
});
</code></pre>
<p>...which will set the scroll offset to the last <code>clientHeight</code> worth of content.</p>
|
<p>I had a div wrapping 3 divs that were floating left, and whose contents were being resized. It helps to turn funky-colored borders/background on for the div-wrapper when you try to resolve this. The problem was that the resized div-content was overflowing outside the div-wrapper (and bled to underneath the area of content below the wrapper). </p>
<p>Resolved by using @Shog9's answer above. As applied to my situation, this was the HTML layout:</p>
<pre><code><div id="div-wrapper">
<div class="left-div"></div>
<div id="div-content" class="middle-div">
Some short/sweet content that will be elongated by Jquery.
</div>
<div class="right-div"></div>
</div>
</code></pre>
<p>This was the my jQuery to resize the div-wrapper:</p>
<pre><code><script>
$("#div-content").text("a very long string of text that will overflow beyond the width/height of the div-content");
//now I need to resize the div...
var contentHeight = $('#div-content').prop('scrollHeight')
$("#div-wrapper").height(contentHeight);
</script>
</code></pre>
<p>To note, $('#div-content').prop('scrollHeight') produces the height that the wrapper needs to resize to. Also I am unaware of any other way to obtain the scrollHeight an actual jQuery function; Neither of $('#div-content').scrollTop() and $('#div-content').height would produce the real content-height values. Hope this helps someone out there!</p>
| 3,432
|
<p>I've recently switched from being an employee of a small consulting company to being an independent consultant and as time goes on I will need to upgrade Windows and Visual Studio. So what is the most affordable way to go about this for a small time developer?</p>
<p>My previous boss suggested I get a TechNet Plus subscription for OS licenses, I've done that and appears to be what I need, but open to other options for the future.</p>
<p>Visual Studio I'm having a hard time figuring out exactly what is the difference between Professional and Standard. Also I'd really like a digital version, but seems that expensive MSDN subscription is the only way?</p>
<p>Visual Studio 2008 Professional with MSDN Professional listed <a href="http://msdn.microsoft.com/en-us/subscriptions/aa718657.aspx" rel="nofollow noreferrer">here</a> appears to be semi-reasonably priced at $1,199. That would make the TechNet Plus subscription unneeded.</p>
|
<p>I recommend that if VS Express is not good enough, use Professional. Standard is missing some really useful features, like a Remote Debugger. Here is a detailed comparison:</p>
<p><a href="http://msdn.microsoft.com/en-us/vs2008/products/cc149003.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/vs2008/products/cc149003.aspx</a></p>
<p>I'd say cancel TechNet and get one of the bottom two MSDN Subscriptions, Visual Studio Professional with either MSDN Professional or with MSDN Premium.</p>
|
<p>I think that Visual Studio Professional with MSDN Subscription doesn't offer much value compared to just purchasing Visual Studio 2010 Pro. You get testing licenses for Windows Server and MSSQL, but that's it. And you can get by just fine without those 90% of the time.</p>
<p>But Visual Studio Premium with MSDN is a different story. You get access to most other server products (testing license only of course), and an Office Professional license. That's a much better value for a one-man shop in my opinion, if you can afford it.</p>
| 4,385
|
<p>For example, <a href="http://developer.apple.com/cocoa/pyobjc.html" rel="nofollow noreferrer">http://developer.apple.com/cocoa/pyobjc.html</a> is still for OS X 10.4 Tiger, not 10.5 Leopard.. And that's the official Apple documentation for it..</p>
<p>The official PyObjC page is equally bad, <a href="http://pyobjc.sourceforge.net/" rel="nofollow noreferrer">http://pyobjc.sourceforge.net/</a></p>
<p>It's so bad it's baffling.. I'm considering learning Ruby primarily because the RubyCocoa stuff is so much better documented, and there's lots of decent tutorials (<a href="http://www.rubycocoa.com/" rel="nofollow noreferrer">http://www.rubycocoa.com/</a> for example), and because of the Shoes GUI toolkit..</p>
<p>Even <a href="http://66.163.168.225/babelfish/translate_url_content?lp=ja_en&url=http%3A%2F%2Fblog.monospace.jp%2F2007%2F11%2F05%2Fxcode3_cocoa_python%2F&fr=avbbf-us&.intl=us" rel="nofollow noreferrer">this badly-auto-translated Japanese tutorial</a> is more useful than the rest of the documentation I could find..</p>
<p>All I want to do is create fairly simple Python applications with Cocoa GUI's..<br>
Can anyone shed light on the horrible documentation, or point me at some tutorials that don't just give you huge blocks of code and assume you know what <code>NSThread.detachNewThreadSelector_toTarget_withObject_("queryController", self, None)</code> does..?</p>
|
<p>I agree that that tutorial is flawed, throwing random, unexplained code right in front of your eyes. It introduces concepts such as the autorelease pool and user defaults without explaining why you would want them ("Autorelease pool for memory management" is hardly an explanation).</p>
<p>That said…</p>
<blockquote>
<p>basically all I want to do is write Cocoa applications without having to learn ObjC.</p>
</blockquote>
<p>I'm afraid that for the time being, you <em>will</em> need a basic grasp of ObjC in order to benefit from any language that uses Cocoa. PyObjC, RubyCocoa, Nu and others are niches at best, and all of them were developed by people intimately familiar with the ins and outs of ObjC <em>and</em> Cocoa.</p>
<p>For now, you will benefit the most if you realistically see those bridges as useful where scripting languages truly shine, rather than trying to build a whole application with them. While this <em>has</em> been done (with LimeChat, I'm using a RubyCocoa-written app right now), it is rare and likely will be for a while.</p>
|
<p>This answer isn't going to be very helpful but, as a developer I hate doing documentation. This being a opensource project, it's hard to find people to do documentation.</p>
| 3,524
|
<p>What is the best way to refactor the attached code to accommodate multiple email addresses?</p>
<p>The attached HTML/jQuery is complete and works for the first email address. I can setup the other two by copy/pasting and changing the code. But I would like to just refactor the existing code to handle multiple email address fields.</p>
<pre><code><html>
<head>
<script src="includes/jquery/jquery-1.2.6.min.js" type="text/javascript"></script>
<script language="javascript">
$(document).ready(function() {
var validateUsername = $('#Email_Address_Status_Icon_1');
$('#Email_Address_1').keyup(function() {
var t = this;
if (this.value != this.lastValue) {
if (this.timer) clearTimeout(this.timer);
validateUsername.removeClass('error').html('Validating Email');
this.timer = setTimeout(function() {
if (IsEmail(t.value)) {
validateUsername.html('Valid Email');
} else {
validateUsername.html('Not a valid Email');
};
}, 200);
this.lastValue = this.value;
}
});
});
function IsEmail(email) {
var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (regex.test(email)) return true;
else return false;
}
</script>
</head>
<body>
<div>
<label for="Email_Address_1">Friend #1</label></div>
<input type="text" ID="Email_Address_1">
<span id="Email_Address_Status_Icon_1"></span>
</div>
<div>
<label for="Email_Address_2">Friend #2</label></div>
<input type="text" id="Email_Address_2">
<span id="Email_Address_Status_Icon_2"></span>
</div>
<div>
<label for="Email_Address_3">Friend #3</label></div>
<input type="text" id="Email_Address_3">
<span id="Email_Address_Status_Icon_3"></span>
</div>
</form>
</body>
</html>
</code></pre>
|
<p>Instead of using IDs for your email fields, you can give them each a class:</p>
<pre><code><div>
<label for="Email_Address_1">Friend #1</label></div>
<input type="text" class="email">
<span></span>
</div>
<div>
<label for="Email_Address_2">Friend #2</label></div>
<input type="text" class="email">
<span></span>
</div>
<div>
<label for="Email_Address_3">Friend #3</label></div>
<input type="text" class="email">
<span></span>
</div>
</code></pre>
<p>Then, instead of selecting $("#Email_Address_Status_Icon_1"), you can select $("input.email"), which would give you a jQuery wrapped set of all input elements of class email.</p>
<p>Finally, instead of referring to the status icon explicitly with an id, you could simply say:</p>
<pre><code>$(this).next("span").removeClass('error').html('Validating Email');
</code></pre>
<p>'this' would be the email field, so 'this.next()' would give you its next sibling. We apply the "span" selector on top of that just to be sure we're getting what we intend to. $(this).next() would work the same way.</p>
<p>This way, you are referring to the status icon in a relative manner.</p>
<p>Hope this helps!</p>
|
<p>Thanks! Here is the completed refactor with your suggested changes.</p>
<pre><code><script language="javascript">
$(document).ready(function() {
$('#Email_Address_1').keyup(function(){Update_Email_Validate_Status(this)});
$('#Email_Address_2').keyup(function() { Update_Email_Validate_Status(this)});
$('#Email_Address_3').keyup(function() { Update_Email_Validate_Status(this)});
});
function Update_Email_Validate_Status(field) {
var t = field;
if (t.value != t.lastValue) {
if (t.timer) clearTimeout(t.timer);
$(t).next("span").removeClass('error').html('Validating Email');
t.timer = setTimeout(function() {
if (IsEmail(t.value)) {
$(t).next("span").removeClass('error').html('Valid Email');
} else {
$(t).next("span").removeClass('error').html('Not a valid Email');
};
}, 200);
t.lastValue = t.value;
}
}
function IsEmail(email) {
var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (regex.test(email)) return true;
else return false;
}
</script>
</code></pre>
| 9,456
|
<p>I am on the hunt for CAD packages which can perform some level of slicing as an inherent model feature, instead of either exporting to STL and then importing into the slicer (a la OnShape) or directly opening the slicer from within the software (a la Fusion 360). I would like this because I want to model directly for the print instead of having to go through an iterative process where certain tools cannot be used to their fullest extent.</p>
<p>For instance, it's very easy for me to print a model, measure it to quantify shrink, and then backport required changes into my CAD model. However, this is not ideal as it prevents me from analyzing the model before print. (For instance, using the CAD software to calculate mass, C.G., moment of inertia, or doing mechanical and thermal analysis on the printed shape, not the modeled solid.)</p>
<p>In a perfect world, I'd have the ability to run Cura as an operation on the model. The resulting CAD would then include the infill structures as well as any required modifications to the original part, e.g. a discrepancy between the desired height and the printed height or a wall width vs the nozzle width.</p>
<p>Is there anything out there which fits the bill? I know nothing is perfect, but anything right now would be a big step forward.</p>
|
<p>Blender has a CNC slicer plugin, it's not exactly what you're asking for but it can perform some of the tasks that you're asking for.</p>
<p><a href="https://sourceforge.net/projects/cnc-slicer-blender-plugin/" rel="nofollow noreferrer">CNC slicer for Blender</a></p>
|
<p>Microsoft 3d builder will do it. It's far from the best CAD or Printing software though. Works very well for what it is.</p>
| 2,172
|
<p>Now, before you say it: I <strong>did</strong> Google and my <code>hbm.xml</code> file <strong>is</strong> an Embedded Resource. </p>
<p>Here is the code I am calling:</p>
<pre><code>ISession session = GetCurrentSession();
var returnObject = session.Get<T>(Id);
</code></pre>
<p>Here is my mapping file for the class:</p>
<pre class="lang-xml prettyprint-override"><code><?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="HQData.Objects.SubCategory, HQData" table="SubCategory" lazy="true">
<id name="ID" column="ID" unsaved-value="0">
<generator class="identity" />
</id>
<property name="Name" column="Name" />
<property name="NumberOfBuckets" column="NumberOfBuckets" />
<property name="SearchCriteriaOne" column="SearchCriteriaOne" />
<bag name="_Businesses" cascade="all">
<key column="SubCategoryId"/>
<one-to-many
class="HQData.Objects.Business, HQData"/>
</bag>
<bag name="_Buckets" cascade="all">
<key column="SubCategoryId"/>
<one-to-many
class="HQData.Objects.Bucket, HQData"/>
</bag>
</class>
</hibernate-mapping>
</code></pre>
<p>Has anyone run to this issue before?</p>
<p>Here is the full error message:</p>
<blockquote>
<pre>MappingException: No persister for: HQData.Objects.SubCategory]NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String entityName, Boolean throwIfNotFound)
in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionFactoryImpl.cs:766 NHibernate.Impl.SessionFactoryImpl.GetEntityPersister(String entityName)
in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionFactoryImpl.cs:752 NHibernate.Event.Default.DefaultLoadEventListener.OnLoad(LoadEvent event, LoadType loadType)
in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Event\Default\DefaultLoadEventListener.cs:37 NHibernate.Impl.SessionImpl.FireLoad(LoadEvent event, LoadType loadType)
in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionImpl.cs:2054 NHibernate.Impl.SessionImpl.Get(String entityName, Object id)
in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionImpl.cs:1029 NHibernate.Impl.SessionImpl.Get(Type entityClass, Object id)
in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionImpl.cs:1020 NHibernate.Impl.SessionImpl.Get(Object id)
in c:\CSharp\NH2.0.0\nhibernate\src\NHibernate\Impl\SessionImpl.cs:985 HQData.DataAccessUtils.NHibernateObjectHelper.LoadDataObject(Int32 Id)
in C:\Development\HQChannelRepo\HQ Channel Application\HQChannel\HQData\DataAccessUtils\NHibernateObjectHelper.cs:42 HQWebsite.LocalSearch.get_subCategory()
in C:\Development\HQChannelRepo\HQ Channel Application\HQChannel\HQWebsite\LocalSearch.aspx.cs:17 HQWebsite.LocalSearch.Page_Load(Object sender, EventArgs e)
in C:\Development\HQChannelRepo\HQ Channel Application\HQChannel\HQWebsite\LocalSearch.aspx.cs:27 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436</pre>
</blockquote>
<p><strong>Update</strong>, here's what the solution for <em>my</em> scenario was: I had changed some code and I wasn't adding the Assembly to the config file during runtime. </p>
|
<p>Sounds like you forgot to add a mapping assembly to the session factory configuration..</p>
<p>If you're using app.config...</p>
<pre><code>.
.
<property name="show_sql">true</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<mapping assembly="Project.DomainModel"/> <!-- Here -->
</session-factory>
.
.
</code></pre>
|
<p>Had a similar problem when find an object by id...
All i did was to use the fully qualified name in the class name. That is
Before it was :</p>
<pre><code>find("Class",id)
</code></pre>
<p>Object so it became like this : </p>
<pre><code>find("assemblyName.Class",id)
</code></pre>
| 8,222
|
<p>Has anybody experience in building a custom style in Qt? What I have in my mind is a complete new style that affects all kind of widgets. I have seen some examples in the web for a custom combo box. But I have no idea how much time and code it takes to build a "complete" new custom style ... maybe someone can give me a hint.</p>
<p>We think of using Qt 4.3 (or even newer) ...</p>
|
<p>Check out the <a href="http://doc.qt.io/qt-4.8/stylesheet.html" rel="nofollow noreferrer">Stylesheets</a> facility in Qt 4. While it's still a hassle, it's way easier than doing a full-on custom style. You can just adjust one visual facet at a time and try it out.</p>
<p>It pays attention to inheritance. So if you style the font in QWidget, then every visual widget will also use that font. And so on.</p>
|
<p>If you don't need to radically change the widget style, you might want to try using widget style sheets:</p>
<pre><code> http://doc.qt.digia.com/4.4/stylesheet.html
</code></pre>
| 9,236
|
<p>Is there a way to run a regexp-string replace on the current line in the bash?</p>
<p>I find myself rather often in the situation, where I have typed a long commandline and then realize, that I would like to change a word somewhere in the line.</p>
<p>My current approach is to finish the line, press <kbd>Ctrl</kbd>+<kbd>A</kbd> (to get to the start of the line), insert a # (to comment out the line), press enter and then use the <code>^oldword^newword</code> syntax (<code>^oldword^newword</code> executes the previous command after substituting oldword by newword).</p>
<p>But there has to be a better (faster) way to achieve this. (The mouse is not possible, since I am in an ssh-sessions most of the time).</p>
<p>Probably there is some emacs-like key-command for this, that I don't know about.</p>
<p>Edit: I have tried using vi-mode. Something strange happened. Although I am a loving vim-user, I had serious trouble using my beloved bash. All those finger-movements, that have been burned into my subconscious suddenly stopped working. I quickly returned to emacs-mode and considered, giving emacs a try as my favorite editor (although I guess, the same thing might happen again).</p>
|
<p>G'day,</p>
<p>What about using vi mode instead? Just enter set -o vi</p>
<p>Then you can go to the word you want to change and just do a cw or cW depending on what's in the word?</p>
<p>Oops, forgot to add you enter a ESC k to o to the previous line in the command history.</p>
<p>What do you normally use for an editor?</p>
<p>cheers,
Rob</p>
<p>Edit: What I forgot to say in my original reply was that you need to think of the vi command line in bash using the commands you enter when you are in "ex" mode in vi, i.e. after you've entered the colon.</p>
<p>Worst thing is that you need to move around through your command history using the ancient vi commands of h (to the left) and l (to the right). You can use w (or W) to bounce across words though.</p>
<p>Once you get used to it though, you have all sorts of commands available, e.g. entering ESC / my_command will look back through you r history, most recent first, to find the first occurrance of the command line containing the text my_command. Once it has found that, you can then use n to find the next occurrance, etc. And N to reverse the direction of the search.</p>
<p>I'd go have a read of the man page for bash to see what's available under vi mode. Once you get over the fact that up-arrow and down-arrow are replaced by ESC k, and then j, you'll see that vi mode offers more than emacs mode for command line editing in bash.</p>
<p>IMHO natchurly! (-:</p>
<p>Emacs? Eighty megs and constantly swapping!</p>
<p>cheers,
Rob</p>
|
<p>G'day,</p>
<p>What about using vi mode instead? Just enter set -o vi</p>
<p>Then you can go to the word you want to change and just do a cw or cW depending on what's in the word?</p>
<p>Oops, forgot to add you enter a ESC k to o to the previous line in the command history.</p>
<p>What do you normally use for an editor?</p>
<p>cheers,
Rob</p>
<p>Edit: What I forgot to say in my original reply was that you need to think of the vi command line in bash using the commands you enter when you are in "ex" mode in vi, i.e. after you've entered the colon.</p>
<p>Worst thing is that you need to move around through your command history using the ancient vi commands of h (to the left) and l (to the right). You can use w (or W) to bounce across words though.</p>
<p>Once you get used to it though, you have all sorts of commands available, e.g. entering ESC / my_command will look back through you r history, most recent first, to find the first occurrance of the command line containing the text my_command. Once it has found that, you can then use n to find the next occurrance, etc. And N to reverse the direction of the search.</p>
<p>I'd go have a read of the man page for bash to see what's available under vi mode. Once you get over the fact that up-arrow and down-arrow are replaced by ESC k, and then j, you'll see that vi mode offers more than emacs mode for command line editing in bash.</p>
<p>IMHO natchurly! (-:</p>
<p>Emacs? Eighty megs and constantly swapping!</p>
<p>cheers,
Rob</p>
| 4,788
|
<p>Winform on CF is a bit heavy, initialising a lot of windows handles takes serious time and memory. Another issue is the lack of inbuilt double buffering and lack of control you have over the UI rendering means that during processor intensive operations the UI might leave the user staring at a half rendered screen. Nice!</p>
<p>To alleviate this issue I would seek a lightweight control framework, is there one kicking about already or would one have to homebrew?</p>
<p>By lightweight I mean a control library that enables one to fully control painting of controls and doesn't use many expensive windows handles. </p>
<p>NOTE: Please don't suggest that I am running too much on the UI thread. That is <strong>not</strong> the case.</p>
|
<p>I ran across this the other day, which might be helpful at least as a starting point: <a href="http://fluid.codeplex.com/" rel="nofollow noreferrer">Fuild - Windows Mobile .NET Touch Controls</a>. The look and feel is nice, but there is no design time support. I don't know too much about memory footprint, etc but everything is double buffered and the performance appears to be pretty good.</p>
|
<p>Actually, you can override the paint event.</p>
<p>And the idea is that you offload long-running operations to a separate thread. That's no different from any other event-driven framework, really. <em>Anything</em> that relies on a handling a Paint event is going to be susceptible to that.</p>
<p>Also, there's no system that lets you determine when the paint event is raised. That kind of event is generally raised by the window manager layer, which is outside of the application (or even the framework). You can handle the event yourself and just do no work some of the time, but I wouldn't recommend it.</p>
| 5,322
|
<p>I've been trying to come up with a way to create a 3 column web design where the center column has a constant width and is always centered. The columns to the left and right are variable. This is trivial in tables, but not correct semantically. </p>
<p>I haven't been able to get this working properly in all current browsers. Any tips on this?</p>
|
<p>Use <a href="http://matthewjamestaylor.com/blog/perfect-3-column.htm" rel="nofollow noreferrer">this technique</a>, and simply specify a fixed width for the centre column.</p>
|
<p>I think you'd need to start off with initial (fixed) widths for both sidebar columns and then, when the page loads, use javascript to get the window width and calculate the new width of the sidebars.</p>
<p>sidebar width = (window width - center column width) / 2</p>
<p>You could then reapply the javascript if the window is resized.</p>
| 9,875
|
<p>Bought a new printer. When this problem has happened anywhere from the third to the twentieth layer up. An excess of filament suddenly exits the nozzle, often pulling the print from the bed when the nozzle moves away. The only advice I've found so far is that the nozzle or hotend may have damage, but I didn't find any when removing them to examine them. I've tried a few different ranges of settings. Guidance would be appreciated.</p>
<p>I'm using a Creality Ender 3 with out-of-the-box equipment and slicing with the most recent Creality Print version. Settings are default (bed: 70 °C and hot end: 200 °C).</p>
<p><a href="https://i.stack.imgur.com/4yjEx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4yjEx.jpg" alt="an unfortunate excess of filament" /></a></p>
<p>Here's what I get if I set everything to default, switch filament spool, and use a .gcode file that was sent in-box from the manufacturer. There was not really ever anything printed, since the blob was stuck to the nozzle and was dragged around in three dimensions until I stopped the printer.</p>
<p><a href="https://i.stack.imgur.com/Ucg06.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ucg06.jpg" alt="an even more unfortunate excess of filament" /></a></p>
|
<p>For casings I use a combination of TPU and PETG or PLA. PETG shell gives it rigidity and TPU gives it a bit of impact protection. So corners and inside layers of TPU within a hard PETG or PLA shell (shell has no corners).</p>
<p>I haven't had a problem with either but obviously PLA won't withstand heat very well, so it depends on environment.</p>
<p>For a laptop case you'd maybe want to do it the other way around with the outside shell of TPU and inside layers of PETG for rigidity.</p>
|
<p>If you just cared about impact resistance of the housing itself, the clear choice would be TPU, which would be basically indestructible. However, the housing is there to protect what's inside - not only from impact, but from stresses (e.g. bending) that could break it. This means you need a material that both provides rigidity and avoids breaking easily itself.</p>
<p>If you were doing an old (90s or earlier) style laptop case that's a tank, I'd actually say yeah, go with TPU 95A or higher (98A or so if you could get it) and add some reinforcement ribs/stiffeners. This stuff can be quite rigid at 100% infill, and it will hold up fine to heat, abrasion, even most chemicals. But if this is a modern slim style case, a small amount of material needs to provide a lot of rigidity and that's not going to work.</p>
<p>PLA actually fares really well here in some ways - it's one of the most rigid printable materials, and very easy to get good bonding. If you check for example CNC Kitchen's strength tests, you'll find plain PLA usually coming out on top of most comparisons. However, PLA doesn't handle heat well, which might rule it out.</p>
<p>ASA, ABS, or PC is probably your best bet, but I don't have any experience with them so I'll leave the part about them as something for another answerer to write.</p>
| 2,140
|
<p>I am coding a client-server application using Eclipse's RCP.
We are having trouble testing the interaction between the two sides
as they both contain a lot of GUI and provide no command-line or other
remote API.</p>
<p>Got any ideas?</p>
|
<p>I have about 1.5 years worth of experience with the RCP framework, I really liked it. We simply JUnit for testing...</p>
<p>It's sort of cliche to say, but if it's not easy to test, maybe the design needs some refactoring?</p>
<p>Java and the RCP framework provide great facilities for keeping GUI code and logic code separate. We used the MVC pattern with the observer, observable constructs that are available in Java...</p>
<p>If you don't know about observer / observable construct that are in Java, I would HIGHLY recommend you take a look at this: <a href="http://www.javaworld.com/javaworld/jw-10-1996/jw-10-howto.html" rel="nofollow noreferrer">http://www.javaworld.com/javaworld/jw-10-1996/jw-10-howto.html</a>, you will use it all the time and your apps will be easier to test.</p>
|
<p>Separate your client-server communication into a pure logic module (or package). Test this separately - either have a test server, or use mock objects.</p>
<p>Then, have your UI actions invoke the communications layer. Also, have a look at the <a href="http://en.wikipedia.org/wiki/Command_pattern" rel="nofollow noreferrer">command design pattern</a>, using it may help you.</p>
| 5,157
|
<p>How do I multiply 10 to an <code>Integer</code> object and get back the <code>Integer</code> object?</p>
<p>I am looking for the neatest way of doing this.</p>
<p>I would probably do it this way:
Get int from <code>Integer</code> object, multiply it with the other int and create another Integer object with this int value.</p>
<p>Code will be something like ... </p>
<pre><code>integerObj = new Integer(integerObj.intValue() * 10);
</code></pre>
<p>But, I saw a code where the author is doing it this way: Get the <code>String</code> from the <code>Integer</code> object, concatenate "0" at the end and then get <code>Integer</code> object back by using <code>Integer.parseInt</code></p>
<p>The code is something like this:</p>
<pre><code>String s = integerObj + "0";
integerObj = Integer.parseInt(s);
</code></pre>
<p>Is there any merit in doing it either way?</p>
<p>And what would be the most efficient/neatest way in general and in this case?</p>
|
<p>With Java 5's <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/autoboxing.html" rel="nofollow noreferrer">autoboxing</a>, you can simply do:</p>
<pre><code>Integer a = new Integer(2); // or even just Integer a = 2;
a *= 10;
System.out.println(a);
</code></pre>
|
<p>toolkit's answer above is correct and the best way, but it doesn't give a full explanation of what is happening.
Assuming Java 5 or later:</p>
<pre><code>Integer a = new Integer(2); // or even just Integer a = 2;
a *= 10;
System.out.println(a); // will output 20
</code></pre>
<p>What you need to know is that this is the exact same as doing:</p>
<pre><code>Integer a = new Integer(2); // or even just Integer a = 2;
a = a.intValue() * 10;
System.out.println(a.intValue()); // will output 20
</code></pre>
<p>By performing the operation (in this case *=) on the object 'a', you are not changing the int value inside the 'a' object, but actually assigning a new object to 'a'.
This is because 'a' gets auto-unboxed in order to perform the multiplication, and then the result of the multiplication gets auto-boxed and assigned to 'a'.</p>
<p>Integer is an immutable object. (All wrapper classes are immutable.)</p>
<p>Take for example this piece of code:</p>
<pre><code>static void test() {
Integer i = new Integer(10);
System.out.println("StartingMemory: " + System.identityHashCode(i));
changeInteger(i);
System.out.println("Step1: " + i);
changeInteger(++i);
System.out.println("Step2: " + i.intValue());
System.out.println("MiddleMemory: " + System.identityHashCode(i));
}
static void changeInteger(Integer i) {
System.out.println("ChangeStartMemory: " + System.identityHashCode(i));
System.out.println("ChangeStartValue: " + i);
i++;
System.out.println("ChangeEnd: " + i);
System.out.println("ChangeEndMemory: " + System.identityHashCode(i));
}
</code></pre>
<p>The output will be:</p>
<pre><code>StartingMemory: 1373539035
ChangeStartMemory: 1373539035
ChangeStartValue: 10
ChangeEnd: 11
ChangeEndMemory: 190331520
Step1: 10
ChangeStartMemory: 190331520
ChangeStartValue: 11
ChangeEnd: 12
ChangeEndMemory: 1298706257
Step2: 11
MiddleMemory: 190331520
</code></pre>
<p>You can see the memory address for 'i' is changing (your memory addresses will be different).</p>
<p>Now lets do a little test with reflection, add this onto the end of the test() method:</p>
<pre><code>System.out.println("MiddleMemory: " + System.identityHashCode(i));
try {
final Field f = i.getClass().getDeclaredField("value");
f.setAccessible(true);
f.setInt(i, 15);
System.out.println("Step3: " + i.intValue());
System.out.println("EndingMemory: " + System.identityHashCode(i));
} catch (final Exception e) {
e.printStackTrace();
}
</code></pre>
<p>The additional output will be:</p>
<pre><code>MiddleMemory: 190331520
Step2: 15
MiddleMemory: 190331520
</code></pre>
<p>You can see that the memory address for 'i' did not change, even though we changed its value using reflection.<br>
(DO NOT USE REFLECTION THIS WAY IN REAL LIFE!!)</p>
| 6,799
|
<p>I'm currently writing a TYPO3 extension which is configured with a list of <code>tt_content</code> UID's.
These point to content elements of type "text" and i want to render them by my extension.</p>
<p>Because of TYPO3s special way of transforming the text you enter in the rich text editing when it enters the database, and again transforming it when it is rendered to the frontend, i can not just output the database contents of the <code>bodytext</code> field.</p>
<p>I want to render these texts as they would usually get rendered by TYPO3.
How do I do that? </p>
|
<p>I had the same problem a couple of months ago. Now I must say that I am no typo3 developer, so I don't know if this is the right solution.</p>
<p>But I used something like this:</p>
<p><code>$output .= $this->pi_RTEcssText( $contentFromDb );</code></p>
<p>in my extension and it works.</p>
|
<h2>PHP</h2>
<p>That works for me; it renders any content element with the given ID:</p>
<pre><code>function getCE($id)
{
$conf['tables'] = 'tt_content';
$conf['source'] = $id;
$conf['dontCheckPid'] = 1;
return $GLOBALS['TSFE']->cObj->cObjGetSingle('RECORDS', $conf);
}
</code></pre>
<p>See <a href="http://lists.typo3.org/pipermail/typo3-dev/2007-May/023467.html" rel="nofollow noreferrer">http://lists.typo3.org/pipermail/typo3-dev/2007-May/023467.html</a></p>
<p>This does work for non-cached plugins, too. You will get a string like <code><!--INT_SCRIPT.0f1c1787dc3f62e40f944b93a2ad6a81--></code>, but TYPO3 will replace that on the next INT rendering pass with the real content.</p>
<h2>Fluid</h2>
<p>If you're in a fluid template, the <a href="https://fluidtypo3.org/viewhelpers/vhs/master/Content/RenderViewHelper.html" rel="nofollow noreferrer">VHS <code>content.render</code> view helper</a> is useful:</p>
<pre><code><v:content.render contentUids="{0: textelementid}"/>
</code></pre>
<p>If your fluidcontent element has a grid itself, you can render the elements with flux' own <code>content.get</code> or <code>content.render</code> view helper:</p>
<pre><code><f:section name="Configuration>
... <flux:grid.column name="teaser"/> ...
</f:section>
<f:section name="Main>
<flux:content.render area="teaser"/>
<f:section>
</code></pre>
| 9,669
|
<p>Are there any statistics regarding how many units each manufacturer has sold, e.g. in 2019?</p>
<p><a href="https://3dprinterchat.com/top-selling-3d-printers/" rel="nofollow noreferrer">An article</a> from 2016 claims Monoprice to have led the market back then - but all of the printers in that article have become obsolete since then.
Some manufacturers also claim theirs to be "one of the most popular" - but that likely doesn't translate to sales, at least for the more overpriced ones.</p>
|
<p>Getting this data is not easy. Many companies that make 3D printers are either private companies that do not report results or are larger companies where 3D printers are one of many products they manufacture. Some companies study this information through mining public sources and surveying users for their opinions and experience. The result of some of these studies are available for a fee.</p>
<p>Occasionally, a trade publication will survey data sources and produce an article. In other cases, a trade pub will publish an article generously offered by a commercial contributor.</p>
<p>It is always difficult to know what is true when abstracting information from obscured, noisy, and biased information sources.</p>
<p>Your question itself includes a bias. You use a words that include a value judgement: "but that likely doesn't translate to sales, at least for the more overpriced ones."</p>
<p>The article you reference is not a deeply researched investigative piece. It is simply some product details for the five printers in 2016 which sold the most on Amazon.com. It doesn't include printers which were not sold on Amazon, so it leaves out any printers which use a different distribution channel. Also, the article include an link, probably which generate revenue back to the magazine, to each of the five printers sold through Amazon.</p>
<p>To summarize, it is very difficult to aggregate this kind of information. Those who try to do so like to be compensated. A list of the top five devices on Amazon is a biased list.</p>
|
<p>For sales figures of the smaller companies; it is very difficult because they don't publish (esp the Chinese brands). For the larger organizations there is </p>
<p>The Wholler's Report <a href="https://wohlersassociates.com/2019report.htm" rel="nofollow noreferrer">https://wohlersassociates.com/2019report.htm</a></p>
<p>An article on <a href="https://www.forbes.com/sites/tjmccue/2018/06/04/wohlers-report-2018-3d-printer-industry-rises-21-percent-to-over-7-billion/#af651352d1a4" rel="nofollow noreferrer">Forbes</a> gave a quote about the 2018 Wholers Report:</p>
<blockquote>
<p>The 2018 report has the estimated number of desktop systems sold at nearly double the 2015 data (reported in the 2016 report). In just over two years, an astonishing <strong>528,952</strong> desktop 3D printers (or systems) are believed to have been sold.</p>
</blockquote>
<p>For 24 Years (basically the start) they have been tracking the 3D printing industry, providing the most reliable source of market share and growth. It costs a bit to purchase and you can't share the contents with anyone else, but if you're really interested then; grab a copy.</p>
<p>Further, there are the statistics of 3DHubs.com. They used to be a distributed 3d printing service (I guess they still are). They keep track of the most popular printers of all types:</p>
<p><a href="https://www.3dhubs.com/get/trends/" rel="nofollow noreferrer">https://www.3dhubs.com/get/trends/</a></p>
| 1,557
|
<p>I'm trying to connect my PC to my Anet A8 through <a href="https://www.pronterface.com/" rel="nofollow noreferrer">Pronterface</a> on Ubuntu.</p>
<p>But when I'm clicking on the "connect" button in Pronterface, all I see is "<em>Connecting ...</em>".</p>
<p>What I did so far</p>
<ul>
<li>added my user to the <code>dialout</code> group</li>
<li>tried to run it as <code>root</code></li>
<li>tried different baudrates</li>
<li>switch to different USB cables</li>
<li>tried to install and run it on a different machine and different OS (Windows) with nearly the same result (additionally I see repeated lines with <code>M105</code>, but no response)</li>
</ul>
<p>The printer itself works - I want to connect to it, to "PID tune" it, because I added a different fan duct.</p>
<p><strong>How can I make sure the board isn't somewhat damaged, and its just my setup?</strong></p>
|
<p>I have this printer and used this board many times over USB.</p>
<p>The genuine Arduino boards use the FTDI FT232RL to convert USB signals to UART signals.</p>
<p>The problem with these Arduino based clone boards is that they do not use the FTDI chips as these are too expensive. These boards use a CH340G chip which is a Chinese clone which requires a specific driver to be installed before you can communicate with the board:</p>
<p><a href="https://i.stack.imgur.com/C5712.jpg" rel="nofollow noreferrer" title="CH304G chipset on Anet A8 board"><img src="https://i.stack.imgur.com/C5712.jpg" alt="CH304G chipset on Anet A8 board" title="CH304G chipset on Anet A8 board" /></a>
<em>Image shows a close-up of the CH340G chipset on the Anet A8 controller board.</em></p>
<p>When you bought the printer, the SD-card contained the driver that you need to install on your OS. I remember that this driver was for the Windows OS. However, you can download the driver for many platforms (Windows, Mac and Linux) directly from the <a href="http://www.wch.cn/download/CH341SER_EXE.html" rel="nofollow noreferrer">manufacturer</a>.</p>
|
<p>You may need to install a device driver for the USB interface chip that your printer uses. I'm guessing that the Anet A8 uses a clone of the FTDI FT232RL chip (which was and may still be common with cheap Chinese printers).</p>
<p>If this is the case, you will need to install the appropriate driver from this site: <a href="https://www.ftdichip.com/Drivers/VCP.htm" rel="nofollow noreferrer">FTDI Chip Virtual COM Port Drivers</a>.</p>
<p>Edit: I can confirm that Pronterface will not work with my Tronxy X1 (which uses an FT232RL clone) on the latest version of Ubuntu.</p>
| 1,749
|
<p>For debugging and testing I'm searching for a JavaScript shell with auto completion and if possible object introspection (like ipython). The online <a href="http://www.squarefree.com/shell/" rel="nofollow noreferrer">JavaScript Shell</a> is really nice, but I'm looking for something local, without the need for an browser.</p>
<p>So far I have tested the standalone JavaScript interpreter rhino, spidermonkey and google V8. But neither of them has completion. At least Rhino with jline and spidermonkey have some kind of command history via key up/down, but nothing more.</p>
<p>Any suggestions?</p>
<p>This question was asked again <a href="https://stackoverflow.com/questions/260787/javascript-shell">here</a>. It might contain an answer that you are looking for.</p>
|
<p>Rhino Shell since 1.7R2 has support for completion as well. You can find more information <a href="http://blog.norrisboyd.com/2009/03/rhino-17-r2-released.html" rel="noreferrer">here</a>.</p>
|
<p><a href="http://code.google.com/p/jslibs/" rel="nofollow">jslibs</a> (a standalone javascript runtime) could also be suitable for this purpose.</p>
| 6,250
|
<p>Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of data on a web-page with XSL over ASP.NET MVC?</p>
<p>The two alternatives are:</p>
<ol>
<li><p><strong>ASP.NET (MVC/WebForms) with XSL</strong><br/>
Getting the data from the database and transforming it to XML which is then displayed on the different pages with XSL-templates.</p></li>
<li><p><strong>ASP.NET MVC</strong><br />
Getting the data from the database as C# objects (or LinqToSql/EF-objects) and displaying it with inline-code on MVC-pages.</p></li>
</ol>
<p>The main benefit of XSL has been consistent display of data on many different pages, like WebControls. So, correct me if I'm wrong, ASP.NET MVC can be used the same way, but with strongly typed objects. Please help me see if there are any benefits to XSL.</p>
|
<p>I can see the main benefit of employing XSLT to transform your data and display it to the user would be the following:</p>
<ul>
<li>The data is already in an XML format</li>
<li>The data follows a well defined schema (this makes using tools like XMLSpy much easier).</li>
<li>The data needs to be transformed into a number of different output formats, e.g. PDF, WMP and HTML</li>
</ul>
<p>If this is to be the only output for your data, and it is not in XML format, then XSLT might not be the best solution.</p>
<p>Likewise if user interaction is required (such as editing of the data) then you will end up employing back-end code anyway to handle updates so might prove one technology too far...</p>
|
<p>If you only going to display data from DB XSL templates may be convenient solution, but if you gonna handle user interaction. Hm... I don't think it'll be maintainable at all.</p>
| 6,043
|
<p>We create new sites in IIS 6 (Windows Server 2003) using IIS Manager. When these sites are created in IIS 6, the ASP.NET version defaults to ASP.NET 1.1. We would like it to default to ASP.NET 2.0. The reason this is a problem for us is that when you take any site on the server and switch the ASP.NET version from ASP.NET 1.1 to ASP.NET 2.0, all web sites recycle.</p>
<p>Is there a setting in the IIS metabase that controls this or a way to create a site via script that sets the ASP.Net version correctly so that we can avoid the IIS reset when setting up each site?</p>
|
<p>As already mentioned by another, I reference this <a href="http://weblogs.asp.net/owscott/archive/2006/05/30/ASPNet_5F00_regiis.exe-tool_2C00_-setting-the-default-version-without-forcing-an-upgrade-on-all-sites.aspx" rel="noreferrer">post</a> whenever I need to change the .NET settings for a site.</p>
<p>As for your question, the following steps (summarized from the linked post) should achieve what you need:</p>
<ol>
<li><p>Run <code>aspnet_regiis -lk</code> from any .NET framework folder to list your current settings to help you determine which sites should remain using .NET 1.1. If you know there is a .NET 1.1 site, but it is not explicitly listed by this command, then it is inheriting from the root <code>W3SVC/</code>.</p></li>
<li><p>For all .NET 1.1 sites not explicitly listed by the previous command, you will need to force them to use .NET 1.1:</p>
<ol>
<li>Determine the Identifier ID of the site(s) which you want to force to use .NET 1.1. (Through the IIS 6 Manager, you can determine the Identifier of a site by clicking the "Web Sites" folder on the left side of the tool. On the right side, all your sites will be listed, and the Identifier column shows the ID.)</li>
<li>From the .NET 1.1 framework folder, run <code>aspnet_regiis -sn W3SVC/<Identifier ID>/ROOT/</code> where <code><Identifier ID></code> is the ID of the site which you want to force to use .NET 1.1. </li>
</ol></li>
<li>Finally, change the root <code>W3SVC/</code> to use .NET 2.0 so that all newly created sites will inherit from the root and default to use .NET 2.0. To change the root, from the .NET 2.0 framework folder, run <code>aspnet_regiis -sn W3SVC/</code>.</li>
</ol>
<p>You can run <code>aspnet_regiis -lk</code> again to verify your settings.</p>
|
<p>Simple answer: Open IIS Manager. In navigation pane, find the .NET2 web site and right click on it. Select "Properties". Then select "ASP.NET" tab. First dropdown on that screen gives you option to select a different version of .NET.</p>
<p>Please be aware -- when I did this, all of the web sites on the web server stopped running. Microsoft support told me that .NET1 and .NET2 should not be run from same general area (default web sites) of the web server. Solution is to create an application pool on the web server for either .NET1 or .NET2 sites and then use that to isolate all sites running the "other" version of .NET. Instruction for creating an application pool can be found under "help" in IIS Manager.</p>
<p>You can create just one application pool and put all sites with same .NET in the same pool <strong>or</strong> you can create an application pool for each application. Your choice.</p>
| 8,979
|
<p>So we've discussed logging in passing at my place of work and I was wondering if some of you guys here could give me some ideas of your approaches?</p>
<p>Typically our scenario is, no logging really at all, and mostly .NET apps, winforms/WPF clients talking through web services or direct to a db.</p>
<p>So, the real question is, where or what would you log? At the moment we have users reporting error messages - so I would assume log startups/shutdowns, exceptions...</p>
<p>Do you take it to calls to the web services or db? Page loads?</p>
<p>How do you get a good idea of what the user was trying to do at the time?</p>
<p>Is it better to go all the way and log everything across multiple attempts/days, or log only what you need to (given hdd is cheap).</p>
<p>I guess that's a few questions, but I wanted to get more of an idea of what the actual practice is out there in larger shops!</p>
|
<p>The key thing for logging is good planning. I would suggest that you look into the enterprise library exception and logging application block (<a href="http://msdn.microsoft.com/en-us/library/cc467894.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/cc467894.aspx</a>). There is a wee bit of a learning curve but it does work quite well. The approach I favour at the moment is to define 4 priority levels. 4=Unhandled exception (error in event log), 3=Handled exception (warning in event log), 2=Access an external resource such as a webservice, db or mainframe system (information in event log), 1=Verbose/anything else of interest (information in event log).</p>
<p>Using the application block it's then quite easy to tweak what level of priority you want to log. So in development you'd log everything but as you get a stable system in production, you'd probably only be interested in unhandled exceptions and possibly handled exceptions.</p>
<p><strong>Update</strong>: For clarity, I would suggest you have logging in both your winform/wpf app and your webservices. In a web scenario, I've had problems in the past where it can be difficult to tie an error on the client back through to the app servers. Mainly because any error through webservices gets wrapped up as a SOAP exception. I can't remember off the top of my head, but I think if you use a custom exception handler (that is part of the enterprise library) you can add data onto exceptions such as the handlinginstance id of the exception from the app server. This makes it easier to tie up exceptions on a client back to your app box by using LogParser (<a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en" rel="nofollow noreferrer">http://www.microsoft.com/downloads/details.aspx?FamilyID=890cd06b-abf8-4c25-91b2-f8d975cf8c07&displaylang=en</a>). </p>
<p><strong>Second Update</strong>: I also like to give each different event a seperate event id and to track that in a text file or spreadsheet under source control. Yes, its a pain but if you're lucky enough to have an IT team looking after your systems in production, I find they tend to expect different events to have different event ids.</p>
|
<p>Thanks guys, lot of good info, but Martin has given me a bit more detail on how to proceed. I'll give him the answer, as it seems like now we're off the front few pages answers will drop off.</p>
| 5,644
|
<p>Anet A8 printer, Github Marlin, Repetier Host, Cura slicer</p>
<p>Just setting up printer and printed 20mm calibration cube from Thingiverse. X,Y,Z & E not too far off but not quite right (centre hole was oval not round) X19.5mm, Y19.5mm & Z20mm.</p>
<p>Followed Youtube calibration help and updated firmware to Marlin. I ran several iterations of request travel, measure result and tweek stepper settings (M501,M92xxxx, M500) Live Die Repeat...</p>
<p>When I now print the calibration cube I get X25mm, Y20mm & Z19.5mm.</p>
<p>Could the issue be with the firmare being upgraded to Marlin? The cube was sliced by Cura and I have used the same file for all of the prints. When I stop the print and ask Repetier to move the steppers the distance is as they should be for a 100mm travel.</p>
|
<p>If you have a stock printer, your calibration values should be stock - i.e. 100 steps/mm for X/Y. Also, as an extra hint, X and Y steps should be identical since the mechanics are identical (unless you swapped out one of the motors or drive gears).</p>
<p>It sounds like you have Y correct, but something wrong with X. This could be the belt being damaged, or slipping (or having slipped during your initial cal, and not later). Try increasing/decreasing print speed, this might show up some dynamic problems with the movement.</p>
<p>If you print something bigger (like <a href="https://www.thingiverse.com/thing:2566871" rel="nofollow noreferrer">this</a>) you don't need to worry so much about measurement precision and under/over-extrusion (which adds to the error, but doesn't scale with size).</p>
<p>You don't make it clear if you've started by calibrating your extruder. This is the most important first step, and ensures that you extrude the right length of filament during the print. All this requires is that you mark out 10cm of filament and extrude it into free space.</p>
|
<p>There could be a number of issues causing this.</p>
<p>Since you just set it up here is a list of questions for you to go through:</p>
<ul>
<li>Are your belts tightened? (With an additional belt tightener)</li>
<li>Are your carriages are sliding smoothly?</li>
</ul>
<p>Both might cause some irregular movements explaining the results being off.</p>
<p>Having said that, I wouldn't worry too much if you're <0.5 mm off. This is still a cheap DIY printer (I have the same one, by the way).</p>
<p>This video actually goes into some details why you shouldn't worry so much about 100% accuracy and what you should actually care for when tuning your printer: <a href="https://m.youtube.com/watch?v=Mbn1ckR86Z8" rel="nofollow noreferrer">https://m.youtube.com/watch?v=Mbn1ckR86Z8</a></p>
<p>Also Not sure how you measured the cube but callipers are often also not that reliable.</p>
| 799
|
<p>So I'm interested in hearing different thoughts about what is the best way to go about unit testing XNA Game/Applications. Astute googlers can probably figure out why I'm asking, but I didn't want to bias the topic :-)</p>
|
<p>I would that this question is geared more toward the approach of <strong>unit testing in game development</strong>. I mean, XNA is a framework. Plug in <a href="http://www.nunit.org/index.php" rel="nofollow noreferrer">NUnit</a>, and begin writing test cases while you develop. </p>
<p><a href="https://stackoverflow.com/questions/14087/unit-testing-a-game#14136">Here</a> is a post on SO about unit testing a game. It'll give you a little insight into how you need to think while progressing.</p>
|
<p>I know this is an old post, but for other people wondering how to best go about testing their XNA Games, there is another option. The built-in testing in Visual Studio is definitely great, but is not well suited for games. Everytime a value is needed, you have to pause the game, and then either hover over the variable, go to quick watch, or add a watch. Then you can see the value of the variable at that frame. To see the value again during another frame, you must pause your game, again. This can be a big hassle. Therefore I have created a debugging terminal to run on top of your game. It allows you to see values of variables, invoke methods, and even watch a variable change in real-time all while you game is running! To find out more, visit: <a href="http://www.protohacks.net/xna_debug_terminal/" rel="nofollow noreferrer">http://www.protohacks.net/xna_debug_terminal/</a></p>
<p>The project is completely free and open source. If you like it, feel free to tell others using XNA Game Studio about it. Hopes this helps out!</p>
| 5,283
|
<p>My end goal is getting high quality dash footage from a 6 month road trip I'm going on. From my research, very few dash cams support 4k 30fps filming, and the ones that do overwrite their own footage really quick, so instead of that I'd like to use my iPhone. I have a wide angle lens for it, and I figure I can mount it to my windshield, behind the rear-view mirror.</p>
<p>But here's the problem: <strong>there are no windshield phone mounts that allow for the angle I need.</strong> They're all designed to point the phone screen at the driver, and the little ball joints that let you set the angle just don't work to point the camera straight ahead. I've tried like 5 different ones, and they all have this problem.</p>
<p>What I need is a solid thing that sticks to my windshield and holds my phone in the correct direction. Once stuck, it never needs to be adjusted. I think I could use 3M strips to stick something to the glass, so the only remaining part of the mystery is this: <strong>A piece of plastic the exact right shape to hold my phone and point it at a specific angle.</strong></p>
<p>My question is: <strong>Is this a good use case for 3D printing?</strong> And if so, how would a complete amateur get started on this?</p>
<p>A few more requirements that I'm not sure if 3D printing can meet:</p>
<ul>
<li>It would need to withstand heat, as it would be left in the car on hot days in the south.</li>
<li>It can't be too brittle, as speed bumps and dirt roads will knock it around a fair bit, and it has to support a large phone with an added lens.</li>
</ul>
|
<p>You'd <a href="https://3dprinting.stackexchange.com/questions/6119/can-you-put-pla-parts-in-your-car-in-the-sun">need to print in a heat resistant material</a> - ASA for example - and design the part for your needs, but this project is certainly feasible and doable with 3D printing. If that isn't enough for you, you could drill a hole to the internal cavity (it's best to have an infill pattern that does not split the internal cavity into several ones. Gyroid is one of these) and fill it with resin to make it even more sturdy.</p>
<p>With the right design, you could also go for SLA/DLP aks resin printing, but I am not well versed in the properties of printed resins but that they have some of the best inter-layer bonds.</p>
<p>If you don't want to get a 3D printer yourself, order the part printed, which usually comes cheaper than an entry-level printer with better quality for a one-off project as you won't have to learn the ins and outs of your printer and how to ensure the quality in the material you choose. Some print services also provide really exotic materials.</p>
|
<p>Why not try a GoPro camera? They now have 4K, image stabilized camera with all kinds of accessory mounts.</p>
<p><a href="https://shop.gopro.com/cameras/hero7-silver/CHDHC-601-master.html" rel="nofollow noreferrer">https://shop.gopro.com/cameras/hero7-silver/CHDHC-601-master.html</a></p>
| 1,398
|
<p>I'm hearing more and more about domain specific languages being thrown about and how they change the way you treat business logic, and I've seen <a href="http://ayende.com/blog/tags/domain-specific-languages" rel="noreferrer">Ayende's blog posts</a> and things, but I've never really gotten exactly why I would take my business logic away from the methods and situations I'm using in my provider.</p>
<p>If you've got some background using these things, any chance you could put it in real laymans terms:</p>
<ul>
<li>What exactly building DSLs means?</li>
<li>What languages are you using?</li>
<li>Where using a DSL makes sense?</li>
<li>What is the benefit of using DSLs?</li>
</ul>
|
<p>DSL's are good in situations where you need to give some aspect of the system's control over to someone else. I've used them in Rules Engines, where you create a simple language that is easier for less-technical folks to use to express themselves- particularly in workflows.</p>
<p>In other words, instead of making them learn java:</p>
<pre><code>DocumentDAO myDocumentDAO = ServiceLocator.getDocumentDAO();
for (int id : documentIDS) {
Document myDoc = MyDocumentDAO.loadDoc(id);
if (myDoc.getDocumentStatus().equals(DocumentStatus.UNREAD)) {
ReminderService.sendUnreadReminder(myDoc)
}
</code></pre>
<p>I can write a DSL that lets me say:</p>
<pre><code>for (document : documents) {
if (document is unread) {
document.sendReminder
}
</code></pre>
<p>There are other situations, but basically, anywhere you might want to use a macro language, script a workflow, or allow after-market customization- these are all candidates for DSL's.</p>
|
<p>DSL is basically creating your own small sublanguage to solve a specific domain problem. This is solved using method chaining. Languages where dots and parentheses are optional help make these expression seem more natural. It can also be similar to a builder pattern.
DSL aren't languages themselves, but rather a pattern that you apply to your API to make the calls be more self explanatory.</p>
<p>One example is Guice, <a href="http://docs.google.com/View?docid=dd2fhx4z_5df5hw8" rel="nofollow noreferrer">Guice Users Guide http://docs.google.com/View?docid=dd2fhx4z_5df5hw8</a> has some description further down of how interfaces are bound to implementations, and in what contexts.</p>
<p>Another common example is for query languages. For example:</p>
<pre><code>NewsDAO.writtenBy("someUser").before("someDate").updateStatus("Deleted")
</code></pre>
<p>In the implementation, imagine each method returning either a new Query object, or just this updating itself internally. At any point you can terminate the chain by using for example rows() to get all the rows, or updateSomeField as I have done above here. Both will return a result object.</p>
<p>I would recommend taking a look at the Guice example above as well, as each call there returns a new type with new options on them. A good IDE will allow you to complete, making it clear which options you have at each point. </p>
<p>Edit: seems many consider DSLs as new, simple, single purpose languages with their own parsers. I always associate DSL as using method chaining as a convention to express operations.</p>
| 6,312
|
<p>Maybe this is a silly question, but I've always assumed each number delineated by a period represented a single component of the software. If that's true, do they ever represent something different? I'd like to start assigning versions to the different builds of my software, but I'm not really sure how it should be structured. My software has five distinct components.</p>
|
<p>In version <em>1.9.0.1</em>:</p>
<ul>
<li><p><strong>1</strong>: Major revision (new UI, lots of new features, conceptual change, etc.)</p></li>
<li><p><strong>9</strong>: Minor revision (maybe a change to a search box, 1 feature added, collection of bug fixes)</p></li>
<li><p><strong>0</strong>: Bug fix release</p></li>
<li><p><strong>1</strong>: Build number (if used)—that's why you see the .NET framework using something like 2.0.4.2709</p></li>
</ul>
<p>You won't find a lot of apps going down to four levels, 3 is usually sufficient.</p>
|
<p>A combination of major, minor, patch, build, security patch, etc.</p>
<p>The first two are major & minor-- the rest will depend on the project, company and sometimes community. In OS's like FreeBSD, you will have 1.9.0.1_number to represent a security patch.</p>
| 9,142
|
<p>I'm early in development on a web application built in VS2008. I have both a desktop PC (where most of the work gets done) and a laptop (for occasional portability) on which I use AnkhSVN to keep the project code synced. What's the best way to keep my development database (SQL Server Express) synced up as well?</p>
<p>I have a VS database project in SVN containing create scripts which I re-generate when the schema changes. The original idea was to recreate the DB whenever something changed, but it's quickly becoming a pain. Also, I'd lose all the sample rows I entered to make sure data is being displayed properly.</p>
<p>I'm considering putting the .MDF and .LDF files under source control, but I doubt SQL Server Express will handle it gracefully if I do an SVN Update and the files get yanked out from under it, replaced with newer copies. Sticking a couple big binary files into source control doesn't seem like an elegant solution either, even if it is just a throwaway development database. Any suggestions?</p>
|
<p>There are obviously a number of ways to approach this, so I am going to list a number of links that should provide a better foundation to build on. These are the links that I've referenced in the past when trying to get others on the bandwagon.</p>
<ul>
<li><a href="https://web.archive.org/web/20210513230815/http://aspnet.4guysfromrolla.com/articles/071305-1.aspx" rel="nofollow noreferrer">Database Projects in Visual Studio .NET</a></li>
<li><a href="http://www.ssw.com.au/SSW/Standards/Rules/DataSchemaStandard.aspx" rel="nofollow noreferrer">Data Schema - How Changes are to be Implemented</a></li>
<li><a href="https://blog.codinghorror.com/is-your-database-under-version-control/" rel="nofollow noreferrer">Is Your Database Under Version Control?</a></li>
<li><a href="https://blog.codinghorror.com/get-your-database-under-version-control/" rel="nofollow noreferrer">Get Your Database Under Version Control</a></li>
<li>Also look for MSDN Webcast: Visual Studio 2005 Team Edition for Database Professionals (Part 4 of 4): Schema Source and Version Control</li>
</ul>
<p>However, with all of that said, if you don't think that you are committed enough to implement some type of version control (either manual or semi-automated), then I HIGHLY recommend you check out the following:</p>
<ul>
<li><a href="http://www.red-gate.com/products/SQL_Compare/index.htm" rel="nofollow noreferrer">Red Gate SQL Compare</a></li>
<li><a href="http://www.red-gate.com/products/SQL_Data_Compare/index.htm" rel="nofollow noreferrer">Red Gate SQL Data Compare</a></li>
</ul>
<p>Holy cow! Talk about making life easy! I had a project get away from me and had multiple people in making schema changes and had to keep multiple environments in sync. It was trivial to point the Red Gate products at two databases and see the differences and then sync them up.</p>
|
<p>We use a combo of, taking backups from higher environments down.<br>
As well as using ApexSql to handle initial setup of schema.<br>
Recently been using Subsonic migrations, as a coded, source controlled, run through CI way to get change scripts in, there is also "tarantino" project developed by headspring out of texas.</p>
<p>Most of these approaches especially the latter, are safe to use on top of most test data. I particularly like the automated last 2 because I can make a change, and next time someone gets latest, they just run the "updater" and they are ushered to latest.</p>
| 6,222
|
<p>In a project that I'm about to wrap up, I've written and implemented an object-relational mapping solution for PHP. Before the doubters and dreamers cry out "how on earth?", relax -- I haven't found a way to make late static binding work -- I'm just working around it in the best way that I possibly can.</p>
<p>Anyway, I'm not currently using prepared statements for querying, because I couldn't come up with a way to pass a variable number of arguments to the <code>bind_params()</code> or <code>bind_result()</code> methods. </p>
<p>Why do I need to support a variable number of arguments, you ask? Because the superclass of my models (think of my solution as a hacked-up PHP ActiveRecord wannabe) is where the querying is defined, and so the find() method, for example, doesn't know how many parameters it would need to bind.</p>
<p>Now, I've already thought of building an argument list and passing a string to eval(), but I don't like that solution very much -- I'd rather just implement my own security checks and pass on statements.</p>
<p>Does anyone have any suggestions (or success stories) about how to get this done? If you can help me solve this first problem, perhaps we can tackle binding the result set (something I suspect will be more difficult, or at least more resource-intensive if it involves an initial query to determine table structure).</p>
|
<p>In PHP you can pass a variable number of arguments to a function or method by using <a href="http://www.php.net/call_user_func_array" rel="noreferrer"><code>call_user_func_array</code></a>. An example for a method would be:</p>
<pre><code>call_user_func_array(array(&$stmt, 'bindparams'), $array_of_params);
</code></pre>
<p>The function will be called with each member in the array passed as its own argument.</p>
|
<p>I am not allowed to edit, but I believe in the code</p>
<pre><code>call_user_func_array(array(&$stmt, 'bindparams'), $array_of_params);
</code></pre>
<p>The reference in front of $stmt is not necessary. Since <code>$stmt</code> is the object and <code>bindparams</code> is the method in that object, the reference is not necessary. It should be:</p>
<pre><code>call_user_func_array(array($stmt, 'bindparams'), $array_of_params);
</code></pre>
<p>For more information, see the PHP manual on <a href="http://au2.php.net/manual/en/language.pseudo-types.php#language.types.callback" rel="nofollow noreferrer">Callback Functions</a>." </p>
| 3,374
|
<p>Now that I know <code>C++</code> I want to get into desktop application that have a UI instead of <code>Command Prompt</code> stuff, where should I start?, and what are some good <strong>online</strong> resources?</p>
|
<p><a href="http://www.wxwidgets.org/" rel="nofollow noreferrer">wxWidgets</a> is a cross platform GUI library for C++ (and other languages). The main site should have enough pointers to resources to get going.</p>
<p>You might also want to check out <a href="https://stackoverflow.com/questions/4347/where-is-a-good-place-to-start-programming-guis-for-windows">this</a> question/answer here on stack overflow if you are specifically thinking of Windows</p>
|
<p>On Linux and maybe Windows, you can use <a href="http://gtk.org" rel="nofollow noreferrer">Gtk+</a> with <a href="http://glade.gnome.org/" rel="nofollow noreferrer">Glade</a>. Gtk+ is the GUI toolkit. Glade is a GUI drag and drop GUI editor. If you came from Windows or Java and thought GUI programming is hard, this stuff is easy.</p>
| 7,071
|
<p>I'm trying to construct a find command to process a bunch of files in a directory using two different executables. Unfortunately, <code>-exec</code> on find doesn't allow to use pipe or even <code>\|</code> because the shell interprets that character first. </p>
<p>Here is specifically what I'm trying to do (which doesn't work because pipe ends the find command):</p>
<pre><code>find /path/to/jpgs -type f -exec jhead -v {} | grep 123 \; -print
</code></pre>
|
<p>Try this</p>
<pre><code>find /path/to/jpgs -type f -exec sh -c 'jhead -v {} | grep 123' \; -print
</code></pre>
<p>Alternatively you could try to embed your exec statement inside a sh script and then do:</p>
<pre><code>find -exec some_script {} \;
</code></pre>
|
<p>There is kind of another way you can do it but it is also pretty ghetto.</p>
<p>Using the shell option extquote you can do something similar to this in order to make find exec stuff and then pipe it to sh.</p>
<pre><code>root@ifrit findtest # find -type f -exec echo ls $"|" cat \;|sh
filename
</code></pre>
<p><br></p>
<pre><code>root@ifrit findtest # find -type f -exec echo ls $"|" cat $"|" xargs cat\;|sh
h
</code></pre>
<p>I just figured I'd add that because at least the way i visualized it, it was closer to the OP's original question of using pipes within exec.</p>
| 8,739
|
<p>A basic problem I run into quite often, but ever found a clean solution to, is one where you want to code behaviour for interaction between different objects of a common base class or interface. To make it a bit concrete, I'll throw in an example;</p>
<p><em>Bob has been coding on a strategy game which supports "cool geographical effects". These round up to simple constraints such as if troops are walking in water, they are slowed 25%. If they are walking on grass, they are slowed 5%, and if they are walking on pavement they are slowed by 0%.</em></p>
<p><em>Now, management told Bob that they needed new sorts of troops. There would be jeeps, boats and also hovercrafts. Also, they wanted jeeps to take damage if they went drove into water, and hovercrafts would ignore all three of the terrain types. Rumor has it also that they might add another terrain type with even more features than slowing units down and taking damage.</em></p>
<p>A very rough pseudo code example follows:</p>
<pre><code>public interface ITerrain
{
void AffectUnit(IUnit unit);
}
public class Water : ITerrain
{
public void AffectUnit(IUnit unit)
{
if (unit is HoverCraft)
{
// Don't affect it anyhow
}
if (unit is FootSoldier)
{
unit.SpeedMultiplier = 0.75f;
}
if (unit is Jeep)
{
unit.SpeedMultiplier = 0.70f;
unit.Health -= 5.0f;
}
if (unit is Boat)
{
// Don't affect it anyhow
}
/*
* List grows larger each day...
*/
}
}
public class Grass : ITerrain
{
public void AffectUnit(IUnit unit)
{
if (unit is HoverCraft)
{
// Don't affect it anyhow
}
if (unit is FootSoldier)
{
unit.SpeedMultiplier = 0.95f;
}
if (unit is Jeep)
{
unit.SpeedMultiplier = 0.85f;
}
if (unit is Boat)
{
unit.SpeedMultiplier = 0.0f;
unit.Health = 0.0f;
Boat boat = unit as Boat;
boat.DamagePropeller();
// Perhaps throw in an explosion aswell?
}
/*
* List grows larger each day...
*/
}
}
</code></pre>
<p>As you can see, things would have been better if Bob had a solid design document from the beginning. As the number of units and terrain types grow, so does code complexity. Not only does Bob have to worry about figuring out which members might need to be added to the unit interface, but he also has to repeat alot of code. It's very likely that new terrain types require additional information from what can be obtained from the basic IUnit interface. </p>
<p>Each time we add another unit into the game, each terrain must be updated to handle the new unit. Clearly, this makes for a lot of repetition, not to mention the ugly runtime check which determines the type of unit being dealt with. I've opted out calls to the specific subtypes in this example, but those kinds of calls are neccessary to make. <em>An example would be that when a boat hits land, its propeller should be damaged. Not all units have propellers.</em></p>
<p>I am unsure what this kind of problem is called, but it is a many-to-many dependence which I have a hard time decoupling. I don't fancy having 100's of overloads for each IUnit subclass on ITerrain as I would want to come clean with coupling.</p>
<p>Any light on this problem is highly sought after. Perhaps I'm thinking way out of orbit all together?</p>
|
<p>Terrain has-a Terrain Attribute </p>
<p>Terrain Attributes are multidimensional. </p>
<p>Units has-a Propulsion.</p>
<p>Propulsion is compatible able with Terrain Attributes.</p>
<p>Units move by a Terrain visit with Propulsion as an argument.
That gets delegated to the Propulsion.</p>
<p>Units <em>may</em> get affected by terrain as part of the visit.</p>
<p>Unit code knows nothing about propulsion.
Terrain types can change w/o changing anything except Terrain Attributes and Propulsion.
Propuslion's constructors protect existing units from new methods of travel.</p>
|
<p>Old idea:</p>
<blockquote>
<p>Make a class iTerrain and another
class iUnit which accepts an argument
which is the terrain type including a
method for affecting each unit type</p>
<p>example:</p>
<pre> <code> boat = new
iUnit("watercraft") field = new
iTerrain("grass")
field.effects(boat)</code></pre>
</blockquote>
<p>ok forget all that I have a better idea:</p>
<p>Make the effects of each terrain a property of each unit</p>
<p>Example:</p>
<pre><code>
public class hovercraft : unit {
#You make a base class for defaults and redefine as necessary
speed_multiplier.water = 1
}
public class boat : unit {
speed_multiplier.land = 0
}
</code></pre>
| 9,401
|
<p>I'm working with a large (270+ project) VS.Net solution. Yes, I know this is pushing the friendship with VS but it's inherited and blah blah. Anyway, to speed up the solution load and compile time I've removed all projects that I'm not currently working on... which in turn has removed those project references from the projects I want to retain. So now I'm going through a mind numbing process of adding binary references to the retained projects so that the referenced Types can be found.</p>
<p>Here's how I'm working at present;</p>
<ul>
<li>Attempt to compile, get thousands of
errors, 'type or namespace missing'</li>
<li>Copy the first line of the error
list to the clipboard</li>
<li>Using a perl script hooked up to a
hotkey (AHK) I extract the type name from
the error message and store it in the windows clipboard</li>
<li>I paste the type name into source
insight symbol browser and note the
assembly containing the Type</li>
<li>I go back to VS and add that
assembly as a binary reference to
the relevant project</li>
</ul>
<p>So now, after about 30 mins I'm thinking there's just got to be a quicker way...</p>
|
<p>These solutions come to my mind:</p>
<ul>
<li>You can try to use <a href="http://www.dependencywalker.com" rel="nofollow noreferrer">Dependency Walker</a> or similar program to analyze dependecies.</li>
<li>Parse MSBuild files (*.csproject) to get list of dependencies</li>
</ul>
<p><strong>EDIT:</strong><br>
Just found 2 cool tools <a href="http://www.codeplex.com/dependencyvisualizer" rel="nofollow noreferrer">Dependency Visualizer</a> & <a href="http://www.codeplex.com/DependencyFinder" rel="nofollow noreferrer">Dependency Finder</a> on codeplex I think they can help you greatly.</p>
<p><strong>EDIT:</strong><br>
@edg, I totally misread your question, since you lose references from csproj files you have to use static analysis tool like NDepend or try to analyze dependencies in run time.</p>
|
<p>One thing you can try is opening up the old .csproj file in notepad and replacing the ProjectReference tags with Reference tags. If you can write a parser, feel free to share. :)</p>
<p>Entry in .csproj file if it is a project reference</p>
<pre><code> <ItemGroup>
<ProjectReference Include="..\WindowsApplication2\WindowsApplication2.csproj">
<Project>{7CE93073-D1E3-49B0-949E-89C73F3EC282}</Project>
<Name>WindowsApplication2</Name>
</ProjectReference>
</ItemGroup>
</code></pre>
<p>Entry in .csproj file if it is an assembly reference</p>
<pre><code> <ItemGroup>
<Reference Include="WindowsApplication2, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<ExecutableExtension>.dll</ExecutableExtension>
<HintPath>..\WindowsApplication2\bin\Release\WindowsApplication2.dll</HintPath>
</Reference> </ItemGroup>
</code></pre>
| 7,753
|
<p>Is there a maintained package I can use to retrieve and set MP3 ID3 metadata using Python?</p>
|
<p>I used <a href="http://eyed3.nicfit.net/" rel="noreferrer">eyeD3</a> the other day with a lot of success. I found that it could add artwork to the ID3 tag which the other modules I looked at couldn't. You'll have to install using pip or download the tar and execute <code>python setup.py install</code> from the source folder. </p>
<p>Relevant examples from the website are below.</p>
<p>Reading the contents of an mp3 file containing either v1 or v2 tag info:</p>
<pre><code> import eyeD3
tag = eyeD3.Tag()
tag.link("/some/file.mp3")
print tag.getArtist()
print tag.getAlbum()
print tag.getTitle()
</code></pre>
<p>Read an mp3 file (track length, bitrate, etc.) and access it's tag:</p>
<pre><code>if eyeD3.isMp3File(f):
audioFile = eyeD3.Mp3AudioFile(f)
tag = audioFile.getTag()
</code></pre>
<p>Specific tag versions can be selected:</p>
<pre><code> tag.link("/some/file.mp3", eyeD3.ID3_V2)
tag.link("/some/file.mp3", eyeD3.ID3_V1)
tag.link("/some/file.mp3", eyeD3.ID3_ANY_VERSION) # The default.
</code></pre>
<p>Or you can iterate over the raw frames:</p>
<pre><code> tag = eyeD3.Tag()
tag.link("/some/file.mp3")
for frame in tag.frames:
print frame
</code></pre>
<p>Once a tag is linked to a file it can be modified and saved:</p>
<pre><code> tag.setArtist(u"Cro-Mags")
tag.setAlbum(u"Age of Quarrel")
tag.update()
</code></pre>
<p>If the tag linked in was v2 and you'd like to save it as v1:</p>
<pre><code> tag.update(eyeD3.ID3_V1_1)
</code></pre>
<p>Read in a tag and remove it from the file:</p>
<pre><code> tag.link("/some/file.mp3")
tag.remove()
tag.update()
</code></pre>
<p>Add a new tag:</p>
<pre><code> tag = eyeD3.Tag()
tag.link('/some/file.mp3') # no tag in this file, link returned False
tag.header.setVersion(eyeD3.ID3_V2_3)
tag.setArtist('Fugazi')
tag.update()
</code></pre>
|
<p>It can depend on exactly what you want to do in addition to reading the metadata. If it is just simply the bitrate / name etc. that you need, and nothing else, something lightweight is probably best.</p>
<p>If you're manipulating the mp3 past that PyMedia may be suitable.</p>
<p>There are quite a few, whatever you do get, make sure and test it out on plenty of sample media. There are a few different versions of ID3 tags in particular, so make sure it's not too out of date. </p>
<p>Personally I've used this small MP3Info class with luck. It is quite old though.</p>
<p><a href="http://www.omniscia.org/~vivake/python/MP3Info.py" rel="nofollow noreferrer">http://www.omniscia.org/~vivake/python/MP3Info.py</a></p>
| 3,040
|
<p>I have an if statement with two conditions (separated by an OR operator), one of the conditions covers +70% of situations and takes far less time to process/execute than the second condition, so in the interests of speed I only want the second condition to be processed if the first condition evaluates to false.</p>
<p>if I order the conditions so that the first condition (the quicker one) appears in the if statement first - on the occasions where this condition is met and evaluates true is the second condition even processed?</p>
<pre><code>if ( (condition1) | (condition2) ){
// do this
}
</code></pre>
<p>or would I need to nest two if statements to only check the second condition if the first evaluates to false?</p>
<pre><code>if (condition1){
// do this
}else if (condition2){
// do this
}
</code></pre>
<p>I am working in PHP, however, I assume that this may be language-agnostic.</p>
|
<p>For C, C++, C#, Java and other .NET languages boolean expressions are optimised so that as soon as enough is known nothing else is evaluated.</p>
<p>An old trick for doing obfuscated code was to use this to create if statements, such as:</p>
<pre><code>a || b();
</code></pre>
<p>if "a" is true, "b()" would never be evaluated, so we can rewrite it into:</p>
<pre><code>if(!a)
b();
</code></pre>
<p>and similarly:</p>
<pre><code>a && b();
</code></pre>
<p>would become</p>
<pre><code>if(a)
b();
</code></pre>
<p><strong>Please note</strong> that this is only valid for the || and && operator. The two operators | and & is bitwise or, and and, respectively, and are therefore not "optimised".</p>
<p>EDIT:
As mentioned by others, trying to optimise code using short circuit logic is very rarely well spent time.</p>
<p>First go for clarity, both because it is easier to read and understand. Also, if you try to be too clever a simple reordering of the terms could lead to wildly different behaviour without any apparent reason.</p>
<p>Second, go for optimisation, but only after timing and profiling. Way too many developer do premature optimisation without profiling. Most of the time it's completely useless.</p>
|
<p>Since this is tagged language agnostic I'll chime in. For Perl at least, the first option is sufficient, I'm not familiar with PHP. It evaluates left to right and drops out as soon as the condition is met.</p>
| 5,534
|
<p>When designing parts that should either fit with external objects or other printed parts, what measures can one take to ensure that the dimensions of the final print are accurate and fit the other object?</p>
<p>To my knowledge, you at least have two options to account for printer inaccuracy and shrinkage:</p>
<ul>
<li>Adjust the space around joints in your CAD model</li>
<li>Adjust dimensional offsets in your slicer software</li>
</ul>
<p>Are there any good workflows one can use to design and print 3D-models accurately without resorting to trial and error?</p>
|
<p>I think the best way to go about this would be to calibrate your printer and slicer as best you can. One of my pet peeves is when people upload STLs that have been adjusted to fit their printer/material. There are many suppliers of material that vary in quality as well as many materials and different printers that the tolerances shouldn't be built into the part because in the end it usually just makes it harder for others attempting to print the model.</p>
<p>If you aren't sharing models then all I can say is you are still better off to calibrate your printer and tune your slicer to your material. You'll have more luck with models from other people and have an easier time designing your own. </p>
<p>If you still have trouble then modifying the model is probably the last option. I don't know of any CAD programs that can work with problems 3D printers have so experience is going to be your only help. I know in Inventor you can go around and Thicken/Offset individual surfaces of the model to compensate or if you had a percentage for your shrinkage you could get creative with formulas in the sketches.</p>
|
<p>A few suggestions I haven't seen explicitly stated in the other answers.</p>
<h1>Export resolution</h1>
<p>When you export your STL files you can increase the resolution. If dimensional accuracy is extremely critical, you'll want to confirm that the STL conversion process hasn't altered the dimensions of curved surfaces outside your max min tolerances. I.e. open your STL file in you CAD program and then re-measure the resulting surfaces. STL conversion for holes makes the wholes slightly smaller, and external curved surfaces slightly larger.</p>
<h1>Material Swell</h1>
<p>I've noticed on my printer that parts are typically slightly larger when printed. I've managed to account for this in my CAD model by shrinking certain dimensions slightly in CAD prior to exporting them. My dimensions are typically off by about 0.1-0.2mm in XY, which if you're making something with close fits it's worth tweaking the file prior to printing.</p>
<h1>Warping</h1>
<p>If I've got a part that needs to be perfectly flat, I'll use a raft with an additional ring (or two) of helper discs surrounding the part. For the flattest side I'll also print this on the build plate. If you've got two or more, best judgement.</p>
<h1>Angled Flats</h1>
<p>If i have a part with flat surfaces that are at angles to the the build platform I'll slow my extruder way down, 10mm/s is my go to speed. Keeping the extruder moving slowly will help to ensure that your edges and walls will be relatively smooth and with the least amount of distortion.</p>
<h1>Calibration and setup</h1>
<p>Everyone has said it, I'll say it again. Check your printer prior to a critical print. Any sag in your belts will cause drooping, Print a test part to ensure that your temperature settings are good for your filament, and that your extraction distance will minimize stringing.</p>
<p>I do a few test prints with a new filament and again about half way through a roll to ensure everything is still working properly, and if needed I'll tweak things as needed.</p>
| 154
|
<p>How can I create an empty one-dimensional string array?</p>
|
<p>Dim strEmpty(-1) As String</p>
|
<p>try this
Dim Arraystr() as String ={}</p>
| 6,645
|
<p>Is there anything special for printing TPU material e.g extruder or temperature?</p>
<p>It's my first time printing TPU material, so if you have any photos, it would be great if you can share them.</p>
|
<p>Elastomers do much better on direct-drive heads (pulled to the head by the motor) than on Bowden designs (where the material is pushed to the head by a motor). This is because the flexible TPU or TPE can bend in the guide tube, causing lag during advance/retract changes, and sometimes even bind up during delivery.</p>
<p>Look for equipment which explicitly states that it is compatible with, and designed for, flexible filaments.</p>
|
<p>Flexible materials cause lot of issues if there is any space between extruder gear and PTFE tube. Since it is flexible it refuses to follow the path and starts bending around the opening. There are parts in Thingiverse that you can print to remove that distance. Additionally make sure that your extruder fan is working. After those two modifications, I was able to reliably print flexible filaments.</p>
| 691
|
<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 want to write a little "DBQuery" function in perl so I can have one-liners which send an SQL statement and receive back and an array of hashes, i.e. a recordset. However, I'm running into an issue with Perl syntax (and probably some odd pointer/reference issue) which is preventing me from packing out the information from the hash that I'm getting from the database. The sample code below demonstrates the issue.</p>
<p>I can get the data "Jim" out of a hash inside an array with this syntax:</p>
<pre><code>print $records[$index]{'firstName'}
</code></pre>
<p>returns "Jim"</p>
<p>but if I copy the hash record in the array to its own hash variable first, then I strangely can't access the data anymore in that hash:</p>
<pre><code>
%row = $records[$index];
$row{'firstName'};
</code></pre>
<p>returns "" (blank)</p>
<p>Here is the full sample code showing the problem. Any help is appreciated:</p>
<pre><code>
my @records = (
{'id' => 1, 'firstName' => 'Jim'},
{'id' => 2, 'firstName' => 'Joe'}
);
my @records2 = ();
$numberOfRecords = scalar(@records);
print "number of records: " . $numberOfRecords . "\n";
for(my $index=0; $index < $numberOfRecords; $index++) {
#works
print 'you can print the records like this: ' . $records[$index]{'firstName'} . "\n";
#does NOT work
%row = $records[$index];
print 'but not like this: ' . $row{'firstName'} . "\n";
}
</code></pre>
|
<p>The nested data structure contains a hash <em>reference</em>, not a hash.</p>
<pre><code># Will work (the -> dereferences the reference)
$row = $records[$index];
print "This will work: ", $row->{firstName}, "\n";
# This will also work, by promoting the hash reference into a hash
%row = %{ $records[$index] };
print "This will work: ", $row{firstName}, "\n";
</code></pre>
<p>If you're ever presented with a deep Perl data structure, you may profit from printing it using <a href="http://search.cpan.org/perldoc?Data::Dumper" rel="noreferrer">Data::Dumper</a> to print it into human-readable (and Perl-parsable) form.</p>
|
<p>Also note a good perl idiom to use is</p>
<pre>for my $rowHR ( @records ) {
my %row = %$rowHR;
#or whatever...
}</pre>
<p>to iterate through the list.</p>
| 7,417
|
<p>How to successfully pause 3D printing and turn off the printer and the next day, continue to print the model?</p>
|
<p>If you enable <code>M413</code> in Marlin firmware, the printer will write a resume printing file to SD card e.g. every layer.</p>
<p>From <a href="http://marlinfw.org/docs/gcode/M413.html" rel="nofollow noreferrer">M413 - Power-loss Recovery documentation</a> I quote:</p>
<blockquote>
<p>Enable or disable the Power-loss Recovery feature. When this feature is enabled, the state of the current print job (SD card only) will be saved to a file on the SD card. If the machine crashes or a power outage occurs, the firmware will present an option to Resume the interrupted print job. In Marlin 2.0 the <code>POWER_LOSS_RECOVERY</code> option must be enabled.</p>
<p>This feature operates without a power-loss detection circuit by writing to the recovery file periodically (e.g., once per layer), or if a <code>POWER_LOSS_PIN</code> is configured then it will write the recovery info only when a power-loss is detected. The latter option is preferred, since constant writing to the SD card can shorten its life, and the print will be resumed where it was interrupted rather than repeating the last layer. (Future implementations may allow use of the EEPROM or the on-board SD card.)</p>
</blockquote>
<p>This means if you cut the power you can resume the print layer, the only problem is that the part must remain attached to the plate, if it comes loose it is hard to resume printing. This feature is now commonly found on printers these days.</p>
<p>The regular pause and resume functionality of the printer will not work when the power is cut over night, i.e. no recovery file is written in such a case.</p>
|
<p>1) Cut the model up in several parts and print one each day. Remove each part every day and in the end, glue them all together.</p>
<p>2) Cut the model up in several parts and each day, add a G-code to the file to be printed so it lowers the heat-bed and thus starts to print on top of yesterdays print. This cannot be used when the printer is auto-calibrating as the printer-head would crash into the already printed part. It would probably be tricky.</p>
<p>3) Pause the printer in the evening, then resume next day (don't forget to lower temperatures and rise them again tomorrow).</p>
| 1,404
|
<p>I found a bug in the Contains statement in Linq (not sure if it is really in Linq or Linq to SQL) and want to know if anyone else has seen this and if there is a fix or workaround.</p>
<p>If the querysource you do the contains with has more than 10 items in it, it does not pass the items correctly to the SQL query. It is hard to explain what it does, an example will show it best.</p>
<p>If you look at the raw query, the parameters look like this:</p>
<pre><code>@P0 = 'aaa'
@P1 = 'bbb'
@P2 = 'ccc'
... [@P3 through @P9]
@P10 = '111'
@P11 = '222'
... [@p12 through @P19]
@P20 = 'sss'
... [@P21 through @P99]
@P100 = 'qqq'
</code></pre>
<p>when the values are passed into the final query (all parameters resolved) it has resolved the parameters as if these were the values passed:</p>
<pre><code>@P0 = 'aaa'
@P1 = 'bbb'
@P2 = 'ccc'
...
@P10 = 'bbb'0
@P11 = 'bbb'1
...
@P20 = 'ccc'0
...
@P100 = 'bbb'00
</code></pre>
<p>So it looks like the parameter resolving looks at the first digit only after the <code>@P</code> and resolves that, then adds on anything left at the end of the parameter name.</p>
<p>At least that is what the Sql Server Query Visualizer plugin to Visual Studio shows the query doing.</p>
<p>Really strange.</p>
<p>So if any one has advice please share. Thanks!</p>
<p><strong>Update:</strong><br>
I have rewritten the original linq statement to where I now use a join instead of the Contains, but would still like to know if there is a way around this issue.</p>
|
<p>The more I look at it, and after running more tests, I'm thinking the bug may be in the Sql Server Query Visualizer plugin for Visual Studio, not actually in Linq to SQL itself. So it is not nearly as bad a situation as I thought - the query will return the right results, but you can't trust what the Visualizer is showing. Not great, but better than what I thought was going on.</p>
|
<p>Try actually looking at the output from your datacontext before you pass judgement.</p>
<p>DataContext.Log() will give you the generated SQL.</p>
| 8,460
|
<p>I wanted some of those spiffy rounded corners for a web project that I'm currently working on.</p>
<p>I thought I'd try to accomplish it using javascript and not CSS in an effort to keep the requests for image files to a minimum (yes, I know that it's possible to combine all required rounded corner shapes into one image) and I also wanted to be able to change the background color pretty much on the fly.</p>
<p>I already utilize jQuery so I looked at the excellent <a href="http://plugins.jquery.com/project/corners" rel="nofollow noreferrer">rounded corners plugin</a> and it worked like a charm in every browser I tried. Being a developer however I noticed the opportunity to make it a bit more efficient. The script already includes code for detecting if the current browser supports webkit rounded corners (safari based browsers). If so it uses raw CSS instead of creating layers of divs.</p>
<p>I thought that it would be awesome if the same kind of check could be performed to see if the browser supports the Gecko-specific <code>-moz-border-radius-*</code> properties and if so utilize them.</p>
<p>The check for webkit support looks like this:</p>
<pre><code>var webkitAvailable = false;
try {
webkitAvailable = (document.defaultView.getComputedStyle(this[0], null)['-webkit-border-radius'] != undefined);
}
catch(err) {}
</code></pre>
<p>That, however, did not work for <code>-moz-border-radius</code> so I started checking for alternatives.</p>
<p>My fallback solution is of course to use browser detection but that's far from recommended practice ofcourse.</p>
<p>My best solution yet is as follows.</p>
<pre><code>var mozborderAvailable = false;
try {
var o = jQuery('<div>').css('-moz-border-radius', '1px');
mozborderAvailable = $(o).css('-moz-border-radius-topleft') == '1px';
o = null;
} catch(err) {}
</code></pre>
<p>It's based on the theory that Gecko "expands" the composite -moz-border-radius to the four sub-properties</p>
<ul>
<li><code>-moz-border-radius-topleft</code></li>
<li><code>-moz-border-radius-topright</code></li>
<li><code>-moz-border-radius-bottomleft</code></li>
<li><code>-moz-border-radius-bottomright</code></li>
</ul>
<p>Is there any javascript/CSS guru out there that have a better solution?</p>
<p>(The feature request for this page is at <a href="http://plugins.jquery.com/node/3619" rel="nofollow noreferrer">http://plugins.jquery.com/node/3619</a>)</p>
|
<p>How about this?</p>
<pre><code>var mozborderAvailable = false;
try {
if (typeof(document.body.style.MozBorderRadius) !== "undefined") {
mozborderAvailable = true;
}
} catch(err) {}
</code></pre>
<p>I tested it in Firefox 3 (true) and false in: Safari, IE7, and Opera.</p>
<p>(Edit: better undefined test)</p>
|
<p>Apply CSS unconditionally and check <code>element.style.MozBorderRadius</code> in the script?</p>
| 3,868
|
<p>How can you import a foxpro DBF file in SQL Server?</p>
|
<p>Use a linked server or use openrowset, example</p>
<pre><code>SELECT * into SomeTable
FROM OPENROWSET('MSDASQL', 'Driver=Microsoft Visual FoxPro Driver;
SourceDB=\\SomeServer\SomePath\;
SourceType=DBF',
'SELECT * FROM SomeDBF')
</code></pre>
|
<p>This tools allows you to import to and from SQL Server.</p>
<ul>
<li><a href="http://www.download3000.com/download_17933.html" rel="nofollow noreferrer">http://www.download3000.com/download_17933.html</a></li>
</ul>
| 7,615
|
<p>In the Windows applications I work on, we have a custom framework that sits directly above Win32 (don't ask). When we create a window, our normal practice is to put <code>this</code> in the window's user data area via <code>SetWindowLong(hwnd, GWL_USERDATA, this)</code>, which allows us to have an MFC-like callback or a tightly integrated <code>WndProc</code>, depending. The problem is that this will not work on 64-bit Windows, since LONG is only 32-bits wide. What's a better solution to this problem that works on both 32- and 64-bit systems?</p>
|
<p><a href="http://msdn.microsoft.com/en-us/library/ms644898%28VS.85%29.aspx" rel="noreferrer">SetWindowLongPtr</a> was created to replace <a href="http://msdn.microsoft.com/en-us/library/ms633591%28VS.85%29.aspx" rel="noreferrer">SetWindowLong</a> in these instances. It's LONG_PTR parameter allows you to store a pointer for 32-bit or 64-bit compilations.</p>
<pre><code>LONG_PTR SetWindowLongPtr(
HWND hWnd,
int nIndex,
LONG_PTR dwNewLong
);
</code></pre>
<p>Remember that the constants have changed too, so usage now looks like:</p>
<pre><code>SetWindowLongPtr(hWnd, GWLP_USERDATA, this);
</code></pre>
<p>Also don't forget that now to retrieve the pointer, you must use <a href="http://msdn.microsoft.com/en-us/library/ms633585%28VS.85%29.aspx" rel="noreferrer">GetWindowLongPtr</a>:</p>
<pre><code>LONG_PTR GetWindowLongPtr(
HWND hWnd,
int nIndex
);
</code></pre>
<p>And usage would look like (again, with changed constants):</p>
<pre><code>LONG_PTR lpUserData = GetWindowLongPtr(hWnd, GWLP_USERDATA);
MyObject* pMyObject = (MyObject*)lpUserData;
</code></pre>
|
<p>The other alternative is SetProp/RemoveProp (When you are subclassing a window that already uses GWLP_USERDATA)</p>
<p>Another good alternative is ATL style thunking of the WNDPROC, for more info on that, see</p>
<ul>
<li><a href="http://www.ragestorm.net/blogs/?cat=20" rel="noreferrer">http://www.ragestorm.net/blogs/?cat=20</a></li>
<li><a href="http://www.hackcraft.net/cpp/windowsThunk/" rel="noreferrer">http://www.hackcraft.net/cpp/windowsThunk/</a></li>
</ul>
| 4,307
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.