instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>I've had a little search and I was wondering if there is back compatibility for the .NET framework.</p>
<p>The real question is, if there's a program that uses .NET Framework 1.1, can I install 3.5 and be done, or do I have to install 1.1 and then if something uses 3.5 I have to install 3.5 as well?</p>
|
<p>Unfortunately you will have to install both versions. Older version of the framework are not automatically bundled with newer versions.</p>
|
<p>If you install something that requires 3.5, then you will have to install it. The way that .Net works though, you can have 1.1, 2.x and 3.5 all installed at the same time. Programs specify the version of the framework they need, and that version is loaded for them.</p>
| 9,744
|
<p>Below I present three options for simplifying my database access when only a single connection is involved (this is often the case for the web apps I work on).</p>
<p>The general idea is to make the DB connection transparent, such that it connects the first time my script executes a query, and then it remains connected until the script terminates.</p>
<p>I'd like to know which one you think is the best and why. I don't know the names of any design patterns that these might fit so sorry for not using them. And if there's any <em>better</em> way of doing this with PHP5, please share.</p>
<p>To give a brief introduction: there is a DB_Connection class containing a query method. This is a third-party class which is out of my control and whose interface I've simplified for the purpose of this example. In each option I've also provided an example model for an imaginary DB "items" table to give some context.</p>
<p>Option 3 is the one that provides me with the interface I like most, but I don't think it's practical unfortunately.</p>
<p>I've described the pros and cons (that I can see) of each in the comment blocks below.</p>
<p>At the moment I lean towards Option 1 since the burden is put on my DB wrapper class instead of on the models.</p>
<p>All comments appreciated!</p>
<p>Note: For some reason, the Stack Overflow preview is showing an encoded HTML entity instead of underscores. If the post comes through like that, please take this into account.</p>
<pre><code><?php
/**
* This is the 3rd-party DB interface I'm trying to wrap.
* I've simplified the interface to one method for this example.
*
* This class is used in each option below.
*/
class DB_Connection {
public function &query($sql) { }
}
/**
* OPTION 1
*
* Cons: Have to wrap every public DB_Connection method.
* Pros: The model code is simple.
*/
class DB {
private static $connection;
private static function &getConnection() {
if (!self::$connection) {
self::$connection = new DB_Connection();
}
return self::$connection;
}
public static function &query($sql) {
$dbh = self::getConnection();
return $dbh->query($sql);
}
}
class Item {
public static function &getList() {
return DB::query("SELECT * FROM items");
}
}
/**
* OPTION 2
*
* Pros: Don't have to wrap every DB_Connection function like in Option 1
* Cons: Every function in the model is responsible for checking the connection
*/
class DB {
protected static $connection = null;
public function connect() {
self::$connection = new DB_Connection();
}
}
class Item extends DB {
public static function &getList() {
if (!self::$connection) $this->connect();
return self::$connection->query("SELECT * FROM items");
}
}
/**
* OPTION 3
*
* Use magic methods
*
* Pros: Simple model code AND don't have to reimplement the DB_Connection interface
* Cons: __callStatic requires PHP 5.3.0 and its args can't be passed-by-reference.
*/
class DB {
private static $connection = null;
public static function &getConnection() {
if (!self::$connection) {
self::$connection = new DB_Connection();
}
return self::$connection;
}
public static function __callStatic($name, $args) {
if (in_array($name, get_class_methods('DB_Connection'))) {
return call_user_func_array(
array(self::getConnection(), $name), $args);
}
}
}
</code></pre>
|
<p>Doh! Someone else here at work figured this out. It was really simple and I should have been able to sort it, but hey, that's how it goes sometimes.</p>
<p>Here the fix:<br>
On the web server, copy the 'aspnet_client' folder from 'C:\Inetpub\wwwroot' to 'C:\Inetpub\wwwroot\your-website-name'. </p>
<p>That's all we did and it's now working. </p>
<p>Hope this saves someone from all the fuss I just went through.</p>
|
<p>I took over maintaining some code produced by another developer who had left and suffered this issue too. In my case the compiled report was looking for the images in the crystalreportview115 folder which existed in my local development path and therefore worked locally. The only folder on on the target server was the CrystalReportWebFormViewer4 (I assume from a previous server installation or site deployment). Simply adding the ...115 folder sorted the problem out for me. </p>
<p>The root cause for us would appear to be the version of Crystal installed on the developers machine. Not sure that helps anyone but thought I'd mention it!</p>
| 7,675
|
<p>Sometimes a labeled break or continue can make code a lot more readable. </p>
<pre><code>OUTERLOOP: for ( ;/*stuff*/; ) {
//...lots of code
if ( isEnough() ) break OUTERLOOP;
//...more code
}
</code></pre>
<p>I was wondering what the common convention for the labels was. All caps? first cap? </p>
|
<p>If you have to use them use capitals, this draws attention to them and singles them out from being mistakenly interpreted as "Class" names. Drawing attention to them has the additional benefit of catching someone's eye that will come along and refactor your code and remove them. ;)</p>
|
<p>The convetion/best practise would still be not to use them at all and to refactor the code so that is more readable using extract as method.</p>
| 3,629
|
<p>What is the best way to sanitize user input for a Python-based web application? Is there a single function to remove HTML characters and any other necessary characters combinations to prevent an <a href="http://en.wikipedia.org/wiki/Cross-site_scripting" rel="noreferrer">XSS</a> or SQL injection attack?</p>
|
<p>Here is a snippet that will remove all tags not on the white list, and all tag attributes not on the attribues whitelist (so you can't use <code>onclick</code>).</p>
<p>It is a modified version of <a href="http://www.djangosnippets.org/snippets/205/" rel="noreferrer">http://www.djangosnippets.org/snippets/205/</a>, with the regex on the attribute values to prevent people from using <code>href="javascript:..."</code>, and other cases described at <a href="http://ha.ckers.org/xss.html" rel="noreferrer">http://ha.ckers.org/xss.html</a>.<br>
(e.g. <code><a href="ja&#x09;vascript:alert('hi')"></code> or <code><a href="ja vascript:alert('hi')"></code>, etc.)</p>
<p>As you can see, it uses the (awesome) <a href="http://www.crummy.com/software/BeautifulSoup/" rel="noreferrer">BeautifulSoup</a> library.</p>
<pre><code>import re
from urlparse import urljoin
from BeautifulSoup import BeautifulSoup, Comment
def sanitizeHtml(value, base_url=None):
rjs = r'[\s]*(&#x.{1,7})?'.join(list('javascript:'))
rvb = r'[\s]*(&#x.{1,7})?'.join(list('vbscript:'))
re_scripts = re.compile('(%s)|(%s)' % (rjs, rvb), re.IGNORECASE)
validTags = 'p i strong b u a h1 h2 h3 pre br img'.split()
validAttrs = 'href src width height'.split()
urlAttrs = 'href src'.split() # Attributes which should have a URL
soup = BeautifulSoup(value)
for comment in soup.findAll(text=lambda text: isinstance(text, Comment)):
# Get rid of comments
comment.extract()
for tag in soup.findAll(True):
if tag.name not in validTags:
tag.hidden = True
attrs = tag.attrs
tag.attrs = []
for attr, val in attrs:
if attr in validAttrs:
val = re_scripts.sub('', val) # Remove scripts (vbs & js)
if attr in urlAttrs:
val = urljoin(base_url, val) # Calculate the absolute url
tag.attrs.append((attr, val))
return soup.renderContents().decode('utf8')
</code></pre>
<p>As the other posters have said, pretty much all Python db libraries take care of SQL injection, so this should pretty much cover you.</p>
|
<p>If you are using a framework like <a href="http://www.djangoproject.com/" rel="nofollow noreferrer">django</a>, the framework can easily do this for you using standard filters. In fact, I'm pretty sure django automatically does it unless you tell it not to.</p>
<p>Otherwise, I would recommend using some sort of regex validation before accepting inputs from forms. I don't think there's a silver bullet for your problem, but using the re module, you should be able to construct what you need.</p>
| 3,756
|
<p>In a machine with AIX without <code>PERL</code> I need to filter records that will be considered duplicated if they have the same id and if they were registered between a period of four hours. </p>
<p>I implemented this filter using <code>AWK</code> and work pretty well but I need a solution much faster: </p>
<pre>
# Generar lista de Duplicados
awk 'BEGIN {
FS=","
}
/OK/ {
old[$8] = f[$8];
f[$8] = mktime($4, $3, $2, $5, $6, $7);
x[$8]++;
}
/OK/ && x[$8]>1 && f[$8]-old[$8]
<p>Any suggestions? Are there ways to improve the environment (preloading the file or someting like that)? </p>
<p>The input file is already sorted.</p>
<p>With the corrections suggested by <a href="https://stackoverflow.com/questions/6475/faster-way-to-find-duplicates-conditioned-by-time#6869">jj33</a> I made a new version with better treatment of dates, still maintaining a low profile for incorporating more operations: </p>
awk 'BEGIN {
FS=",";
SECSPERMINUTE=60;
SECSPERHOUR=3600;
SECSPERDAY=86400;
split("0 31 59 90 120 151 181 212 243 273 304 334", DAYSTOMONTH, " ");
split("0 366 731 1096 1461 1827 2192 2557 2922 3288 3653 4018 4383 4749 5114 5479 5844 6210 6575 6940 7305", DAYSTOYEAR, " ");
}
/OK/ {
old[$8] = f[$8];
f[$8] = mktime($4, $3, $2, $5, $6, $7);
x[$8]++;
}
/OK/ && x[$8]>1 && f[$8]-old[$8] 2 ) && ( ((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0) ) ) {
d2m = d2m + 1;
}
d2y = DAYSTOYEAR[ y - 1999 ];
return ss + (mm*SECSPERMINUTE) + (hh*SECSPEROUR) + (d*SECSPERDAY) + (d2m*SECSPERDAY) + (d2y*SECSPERDAY);
}
'
</pre>
|
<p>This sounds like a job for an actual database. Even something like SQLite could probably help you reasonably well here. The big problem I see is your definition of "within 4 hours". That's a sliding window problem, which means you can't simply quantize all the data to 4 hour segments... you have to compute all "nearby" elements for every other element separately. Ugh.</p>
|
<p>If your data file contains all your records (i.e. it includes records that do not have dupicate ids within the file) you could pre-process it and produce a file that only contains records that have duplicate (ids).</p>
<p>If this is the case that would reduce the size of file you need to process with your AWK program.</p>
| 2,821
|
<p>What are in your opinion the best resources (books or web pages) describing algorithms or techniques to use for collision detection in a 2D environment?</p>
<p>I'm just eager to learn different techniques to make more sophisticated and efficient games.
</p>
|
<p>Collision detection is often a two phase process. Some sort of "broad phase" algorithm for determinining if two objects even have a chance of overlapping (to try to avoid n^2 compares) followed by a "narrow phase" collision detection algorithm, which is based on the geometry requirements of your application.</p>
<p><a href="http://en.wikipedia.org/wiki/Sweep_and_prune" rel="noreferrer">Sweep and Prune</a> is a well established efficient broad phase algorithm (with a handful of variants that may or may not suit your application) for objects undergoing relatively physical movement (things that move crazy fast or have vastly different sizes and bounding regions might make this unsuitable). The <a href="http://sourceforge.net/projects/bullet" rel="noreferrer">Bullet</a> library has a 3d implementation for reference.</p>
<p>Narrow phase collision can often be as simple as "CircleIntersectCircle." Again the Bullet libraries have good reference implementations. In 3d land when more precise detection is required for arbitrary objects, <a href="http://www.dtecta.com/" rel="noreferrer">GJK</a> is among the current cream of the crop - nothing in my knowledge would prevent it from being adapted to 2d (but it might end up slower than just brute forcing all your edges ;)</p>
<p>Finally, after you have collision detection, you are often in need of some sort of collision response. <a href="http://www.box2d.org/" rel="noreferrer">Box 2d</a> is a good starting point for a physical response solution.</p>
|
<p>If your objects are represented as points in 2D space you can use line intersection to determine if two objects have collided. You can use similar logic to check if an object is inside another object (and thus they have collided even any of their lines are not currently intersecting). The <a href="http://paulbourke.net/geometry/pointlineplane/" rel="nofollow noreferrer">math to do this</a> is quite simple, and should be covered by any textbook on basic geometry. Detecting if an object has passed completely through an object might be a bit more tricky though. </p>
| 5,106
|
<p>I got a little curious after reading <a href="http://it.slashdot.org/it/08/09/09/1558218.shtml" rel="noreferrer">this /. article</a> over hijacking HTTPS cookies. I tracked it down a bit, and a good resource I stumbled across lists a few ways to secure cookies <a href="http://casabasecurity.com/content/using-aspnet-session-handling-secure-sites-set-secure-flag" rel="noreferrer">here</a>. Must I use adsutil, or will setting requireSSL in the httpCookies section of web.config cover session cookies in addition to all others (<a href="http://msdn2.microsoft.com/en-us/library/ms228262.aspx" rel="noreferrer">covered here</a>)? Is there anything else I should be considering to harden sessions further?</p>
|
<p>Typically I have always done this using a 3rd party aggregator. The messages are compiled into SMIL, which is the description language for the MMS messages. These are then sent on to the aggregator who will then send them through the MMS gateway of the Network Operator. They are typically charged on a per message basis and the aggregators will buy the messages in a block from the operators.</p>
<p>If you are trying to send an MMS message without getting charged then I am not sure how to do this, or if it is possible.</p>
|
<p>You could use Twilio to accomplish this. You can <a href="https://www.twilio.com/docs/quickstart/csharp/sms/sending-via-rest" rel="nofollow">dive into the docs</a> for specific implementation details but using the <a href="https://www.twilio.com/docs/csharp/install" rel="nofollow">C# helper library</a> the code to send an MMS would look like this:</p>
<pre><code> // Send a new outgoing MMS by POSTing to the Messages resource */
client.SendMessage(
"YYY-YYY-YYYY", // From number, must be an SMS-enabled Twilio number
person.Key, // To number, if using Sandbox see note above
// message content
string.Format("Hey {0}, Monkey Party at 6PM. Bring Bananas!", person.Value),
// media url of the image
new string[] {"https://demo.twilio.com/owl.png" }
);
</code></pre>
<p>Disclaimer: I work for Twilio.</p>
| 7,770
|
<p>What is the best way to calculate Age using Flex?</p>
|
<p>I found an answer at <a href="http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=08_Dates_and_times_164_2.html" rel="nofollow noreferrer">the bottom of this page in comments section (which is now offline)</a>. </p>
<blockquote>
<p><strong>jpwrunyan said on Apr 30, 2007 at 10:10 PM :</strong></p>
<blockquote>
<p>By the way, here is how to calculate age in years (only) from DOB without needing to account for leap years:</p>
</blockquote>
</blockquote>
<p>With a slight correction by <a href="https://stackoverflow.com/users/210612/fine-wei-lin">Fine-Wei Lin</a>, the code reads</p>
<pre><code>private function getYearsOld(dob:Date):uint {
var now:Date = new Date();
var yearsOld:uint = Number(now.fullYear) - Number(dob.fullYear);
if (dob.month > now.month || (dob.month == now.month && dob.date > now.date))
{
yearsOld--;
}
return yearsOld;
}
</code></pre>
<blockquote>
<blockquote>
<p>This handles most situations where you need to calculate age. </p>
</blockquote>
</blockquote>
|
<p>You could also do it roughly the same as discussed <a href="https://stackoverflow.com/questions/9/how-do-i-calculate-someones-age-in-c" title="Jeff Atwodd's Question about calculating age in C#">here</a>: (translated to AS3)</p>
<pre><code>var age:int = (new Date()).fullYear - bDay.fullYear;
if ((new Date()) < (new Date((bDay.fullYear + age), bDay.month, bDay.date))) age--;
</code></pre>
| 6,314
|
<p>I run a high school 3D printer lab and we have several 5th generation MakerBot printers. On one of them I have considerable trouble with "thin" prints and filament slip warnings.</p>
<p>So far I've tried changing extruders and using different filament rolls with no luck. But, if I move the job and the extruder to a different printer it works.</p>
<p>I'd appreciate suggestions for how to sort this out. I would have expected the slipping problems to follow the extruder.</p>
|
<p>Oh interesting. By slips, I take it you mean that the raw filament slips, not the print slips.</p>
<p>This will happen for a few reasons. First the tooth gear that grabs the plastic is either:</p>
<ul>
<li>Worn out</li>
<li>Out of place</li>
<li>Not the correct distance from the guide wheel. </li>
</ul>
<p>This is all part of the mechanism that the Smart Extruder attaches TO. Not the Smart Extruder itself. You might be able to fix this yourself, worst case you will need a replacement assembly from MakerBot. <em>I would look into online auction sites for the part</em></p>
<p>Another option is to try thicker filament. Which you might be able to custom order. So instead of 1.5, maybe get 1.8. I am not sure where you can buy off sizes.</p>
<p>From there this machine might just be getting jammed. It happens to some machines. This again points to the base of the X axis assembly. </p>
<p>Last which I would say is not likely as you have tried multiple extruders, you might have the nozzle becoming clogged. I often pop open my extruders <em>voids warranty</em> and clean them out. Also micro hand drills are a good option here. </p>
|
<p>So I had this issue for months, was about to either give up and call my printer a paper weight, but I figured it out. And it doesn't cost anything.</p>
<p>I literally reprinted the same hose adapter 6 times (every time the filament slipped about 20 times and it was unusable). I changed 4 settings and since then I've printed the same print twice in a row without a single filament slip.</p>
<p>In "Device Settings" in Makerbot application:
Extruder Temp: 220 °C
Travel Speed (I think this is what is actually causing the slip): 115 mm/s</p>
<p>Then in the "Infill" section:
Infill Density: 30 %</p>
<p>Lastly in "Model Properties":
Shell Starting Point: 220 °C</p>
<p>Please let me know if this works for you as well. </p>
<p>(I should point out I just have the regular smart extruder, and I was planning on dumping the $350 for the top of the line model)</p>
| 460
|
<p>I am trying out the debugger built into <code>Zend studio</code>. It seems great! One thing though, when I start a page using the debugger does anyone know how I can set a request get argument within the page?</p>
<p>For example, I don't want to debug runtests.php</p>
<p>I want to debug <code>runtests.php?test=10</code></p>
<p>I assume its a simple configuration and I just can't find it.</p>
|
<p>Just start the debugger on another page, and then change the browser url to what you wanted.
It's not ideal but it should work.</p>
<p>I have high hopes for their next release.</p>
|
<p>I recommend getting the <a href="http://www.zend.com/en/products/studio/downloads" rel="nofollow noreferrer">Zend Studio Toolbar</a>. The extension allows you to control which pages are debugged from within the browser instead of from Zend Studio. The options for debugging let you debug the next page, the next form post or all pages. When you debug like this it runs the PHP just like it will from your server instead of from within Zend Studio. It's an essential tool when using Zend Studio. </p>
| 9,473
|
<p>I need to store contact information for users. I want to present this data on the page as an <a href="http://en.wikipedia.org/wiki/Hcard" rel="nofollow noreferrer">hCard</a> and downloadable as a <a href="http://en.wikipedia.org/wiki/VCard" rel="nofollow noreferrer">vCard</a>. I'd also like to be able to search the database by phone number, email, etc. </p>
<p>What do you think is the best way to store this data? Since users could have multiple addresses, etc complete normalization would be a mess. I'm thinking about using XML, but I'm not familiar with querying XML db fields. Would I still be able to search for users by contact info?</p>
<p>I'm using SQL Server 2005, if that matters.</p>
|
<p>Consider two tables for People and their addresses: </p>
<pre><code>People (pid, prefix, firstName, lastName, suffix, DOB, ... primaryAddressTag )
AddressBook (pid, tag, address1, address2, city, stateProv, postalCode, ... )
</code></pre>
<p>The Primary Key (that uniquely identifies each and every row) of People is <code>pid</code>. The PK of AddressBook is the composition of pid and tag <code>(pid, tag)</code>.</p>
<p>Some example data:</p>
<h2>People</h2>
<pre><code>1, Kirk
2, Spock
</code></pre>
<h2>AddressBook</h2>
<pre><code>1, home, '123 Main Street', Iowa
1, work, 'USS Enterprise NCC-1701'
2, other, 'Mt. Selaya, Vulcan'
</code></pre>
<p>In this example, Kirk has two addresses: one 'home' and one 'work'. One of those two can (and should) be noted as a foreign key (like a cross-reference) in <code>People</code> in the primaryAddressTag column.</p>
<p>Spock has a single address with the tag 'other'. Since that is Spock's only address, the value 'other' ought to go in the <code>primaryAddressTag</code> column for pid=2.</p>
<p>This schema has the nice effect of preventing the same person from duplicating any of their own addresses by accidentally reusing tags while at the same time allowing all other people use any address tags they like.</p>
<p>Further, with FK references in <code>primaryAddressTag</code>, the database system itself will enforce the validity of the primary address tag (via something we database geeks call referential integrity) so that your -- or any -- application need not worry about it.</p>
|
<p>If you assume each user has one or more addresses, a telephone number, etc., you could have a 'Users' table, an 'Addresses Table' (containing a primary key and then non-unique reference to Users), the same for phone numbers - allowing multiple rows with the same UserID foreign key, which would make querying 'all addresses for user X' quite simple.</p>
| 5,926
|
<p>I want to be able to make an HTTP call updating some select boxes after a date is selected. I would like to be in control of updating the textbox so I know when there has been a "true" change (in the event the same date was selected). Ideally, I would call a function to pop-up the calendar and be able to evaluate the date before populating the text box...so I can do my validation before making a server call. </p>
|
<p>JQuery's <a href="http://docs.jquery.com/UI/Datepicker" rel="noreferrer">datepicker</a> is an extremely flexible tool. With the ability to attach handlers prior to opening or after date selection, <a href="http://marcgrabanski.com/article/jquery-ui-datepicker-themes" rel="noreferrer">themes</a>, range selection and a variety of other incredibly useful options, I've found that it meets all my needs.</p>
<p>The fact that I sit next to one of its maintainers here at work is also fairly useful... </p>
|
<p>I don't like the MS ASP.NET ajax, but their datepicker is superb. Otherwise, jQuery datepicker.</p>
| 4,501
|
<p>How can I call a BizTalk Orchestration dynamically knowing the Orchestration name? </p>
<p>The call Orchestration shapes need to know the name and parameters of Orchestrations at design time. I've tried using 'call' XLang keyword but it also required Orchestration name as Design Time like in expression shape, we can write as </p>
<pre><code>call BizTalkApplication1.Orchestration1(param1,param2);
</code></pre>
<p>I'm looking for some way to specify calling orchestration name, coming from the incoming message or from SSO config store.</p>
<p>EDIT: I'musing BizTalk 2006 R1 (ESB Guidance is for R2 and I didn't get how it could solve my problem) </p>
|
<p>The way I've accomplished something similar in the past is by using direct binding ports in the orchestrations and letting the MsgBox do the dirty work for me. Basically, it goes something like this:</p>
<ol>
<li>Make the callable orchestrations use a direct-bound port attached to your activating receive shape.</li>
<li>Set up a filter expression on your activating receive shape with a custom context-based property and set it equal to a value that uniquely identifies the orchestration (such as the orchestration name or whatever)</li>
<li>In the calling orchestration, create the message you'll want to use to fire the new orchestration. In that message, set your custom context property to the value that matches the filter used in the specific orchestration you want to fire.</li>
<li>Send the message through a direct-bound send port so that it gets sent to the MsgBox directly and the Pub/Sub mechanisms in BizTalk will take care of the rest.</li>
</ol>
<p>One thing to watch out in step 4: To have this work correctly, you will need to create a new Correlation Set type that includes your custom context property, and then make sure that the direct-bound send port "follows" the correlation set on the send. Otherwise, the custom property will only be written (and not promoted) to the msg context and the routing will fail.</p>
<p>Hope this helps!</p>
|
<p>Look at ESB Guidance (www.codeplex.com/esb) This package provides the functionality you are looking for</p>
| 9,787
|
<p>I'm working on a DCOM application with the server and client on two machines, both of which are running WinXP with Service Pack 2. On both machines, I'm logged in with the same username and password.</p>
<p>When the client on one machine calls CoCreateInstanceEx, asking the other machine to start up the server application, it returns E_ACCESSDENIED.</p>
<p>I tried going into the server app's component properties in dcomcnfg and giving full permisions to everyone for everything, but that didn't help.</p>
<p>What do I need to do to allow this call to succeed?</p>
<p><strong>Update:</strong> When the server app is running on a Windows 2000 box, I do not get this error; CoCreateInstanceEx returns S_OK.</p>
|
<p>Right, so if your Authentication level is set to Default. What is the authentication level set to in the Default Settings? Just out of interest. (although the fact that it works to a 2000 box probably makes that redundant)</p>
<p>EDIT:</p>
<p>Also: I seem to remember doing a lot of rebooting when I used to play/work with DCOM so maybe a quick reboot of both machines when you're happy with the dcomcnfg settings wouldn't go amis either.</p>
|
<p>What is the flavor of your Windows 2000 box, btw? Professional, Server, Adv Server...</p>
<p>Also, is there a difference between domain membership between the two (one on a domain, the other not, different domains, etc...?)</p>
<p>One more thing - DCOM errors will appear in the System event log at times - especially for object creation - did you check there for clues?</p>
| 4,120
|
<p>I want to use the Web Browser control within an mono application, but when I do get the error "libgluezilla not found. To have webbrowser support, you need libgluezilla installed." Installing the Intrepid Deb causes any application that references the web browser control to crash on startup with : 'Thread (nil) may have been prematurely finalized'.</p>
|
<pre><code>apt-cache search libgluezilla
libmono-mozilla0.1-cil - Mono Mozilla library
</code></pre>
<p>From the package description: </p>
<pre><code>Description: Mono Mozilla library
Mono is a platform for running and developing applications based on the
ECMA/ISO Standards. Mono is an open source effort led by Novell.
Mono provides a complete CLR (Common Language Runtime) including compiler and
runtime, which can produce and execute CIL (Common Intermediate Language)
bytecode (aka assemblies), and a class library.
.
This package contains the implementation of the WebControl class based on the
Mozilla engine using libgluezilla.
Homepage: http://www.mono-project.com/
</code></pre>
<p>You'll probably need to uninstall anything that came in from intrepid without being properly backported.</p>
|
<p>here's a link to it on the ubuntu site:</p>
<p><a href="http://packages.ubuntu.com/intrepid/libgluezilla" rel="nofollow noreferrer">http://packages.ubuntu.com/intrepid/libgluezilla</a></p>
<p>there is a download section at the bottom for a deb package</p>
| 6,387
|
<p>I have a control that is modelled on a <strong>ComboBox</strong>. I want to render the control so that the control <strong>border</strong> looks like that of a standard <strong>Windows ComboBox</strong>. Specifically, I have followed the MSDN documentation and all the rendering of the control is correct except for rendering when the control is disabled.</p>
<p>Just to be clear, this is for a system with <strong>Visual Styles</strong> enabled. Also, all parts of the control render properly except the border around a disabled control, which does not match the disabled <strong>ComboBox border</strong> colour.</p>
<p>I am using the <strong>VisualStyleRenderer</strong> class. MSDN suggests using the <code>VisualStyleElement.TextBox</code> element for the <strong>TextBox</strong> part of the <strong>ComboBox</strong> control but a standard disabled <strong>TextBox</strong> and a standard disabled <strong>ComboBox</strong> draw slightly differently (one has a light grey border, the other a light blue border).</p>
<p>How can I get correct rendering of the control in a disabled state?</p>
|
<p>I'm not 100% sure if this is what you are looking for but you should check out the <strong>VisualStyleRenderer</strong> in the System.Windows.Forms.VisualStyles-namespace.</p>
<ol>
<li><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.visualstyles.visualstylerenderer.aspx" rel="noreferrer">VisualStyleRenderer class</a> (MSDN)</li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms171735.aspx" rel="noreferrer">How to: Render a Visual Style Element</a> (MSDN)</li>
<li><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.visualstyles.visualstyleelement.combobox.dropdownbutton.disabled.aspx" rel="noreferrer">VisualStyleElement.ComboBox.DropDownButton.Disabled</a> (MSDN)</li>
</ol>
<p>Since VisualStyleRenderer won't work if the user don't have visual styles enabled (he/she might be running 'classic mode' or an operative system prior to Windows XP) you should always have a fallback to the ControlPaint class.</p>
<pre><code>// Create the renderer.
if (VisualStyleInformation.IsSupportedByOS
&& VisualStyleInformation.IsEnabledByUser)
{
renderer = new VisualStyleRenderer(
VisualStyleElement.ComboBox.DropDownButton.Disabled);
}
</code></pre>
<p>and then do like this when drawing:</p>
<pre><code>if(renderer != null)
{
// Use visual style renderer.
}
else
{
// Use ControlPaint renderer.
}
</code></pre>
<p>Hope it helps!</p>
|
<p>Are any of the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.controlpaint_members.aspx" rel="nofollow noreferrer">ControlPaint</a> methods useful for this? That's what I usually use for custom-rendered controls.</p>
| 2,503
|
<p>I often encounter the following scenario where I need to offer many different types of permissions. I primarily use ASP.NET / VB.NET with SQL Server 2000.</p>
<p><strong>Scenario</strong></p>
<p>I want to offer a dynamic permission system that can work on different parameters. Let's say that I want to give either a department or just a specific person access to an application. And pretend that we have a number of applications that keeps growing.</p>
<p>In the past, I have chosen one of the following two ways that I know to do this.</p>
<ol>
<li><p>Use a single permission table with special columns that are used for
determining a how to apply the parameters. The special columns in
this example are <code>TypeID</code> and <code>TypeAuxID</code>. The SQL would look something
like this.</p>
<pre><code>SELECT COUNT(PermissionID)
FROM application_permissions
WHERE
(TypeID = 1 AND TypeAuxID = @UserID) OR
(TypeID = 2 AND TypeAuxID = @DepartmentID)
AND ApplicationID = 1
</code></pre>
</li>
<li><p>Use a mapping table for each type of permission, then joining them
all together.</p>
<pre><code>SELECT COUNT(perm.PermissionID)
FROM application_permissions perm
LEFT JOIN application_UserPermissions emp
ON perm.ApplicationID = emp.ApplicationID
LEFT JOIN application_DepartmentPermissions dept
ON perm.ApplicationID = dept.ApplicationID
WHERE q.SectionID=@SectionID
AND (emp.UserID=@UserID OR dept.DeptID=@DeptID OR
(emp.UserID IS NULL AND dept.DeptID IS NULL)) AND ApplicationID = 1
ORDER BY q.QID ASC
</code></pre>
</li>
</ol>
<p><strong>My Thoughts</strong></p>
<p>I hope that the examples make sense. I cobbled them together.</p>
<p>The first example requires less work, but neither of them feel like the best answer. Is there a better way to handle this?</p>
|
<p>I agree with John Downey.</p>
<p>Personally, I sometimes use a flagged enumeration of permissions. This way you can use AND, OR, NOT and XOR bitwise operations on the enumeration's items.</p>
<pre><code>"[Flags]
public enum Permission
{
VIEWUSERS = 1, // 2^0 // 0000 0001
EDITUSERS = 2, // 2^1 // 0000 0010
VIEWPRODUCTS = 4, // 2^2 // 0000 0100
EDITPRODUCTS = 8, // 2^3 // 0000 1000
VIEWCLIENTS = 16, // 2^4 // 0001 0000
EDITCLIENTS = 32, // 2^5 // 0010 0000
DELETECLIENTS = 64, // 2^6 // 0100 0000
}"
</code></pre>
<p>Then, you can combine several permissions using the AND bitwise operator. <br /><br />
For example, if a user can view & edit users, the binary result of the operation is 0000 0011 which converted to decimal is 3. <br />
You can then store the permission of one user into a single column of your Database (in our case it would be 3).<br /><br />
Inside your application, you just need another bitwise operation (OR) to verify if a user has a particular permission or not.</p>
|
<p>An approach I've used in various applications is to have a generic PermissionToken class which has a changeable Value property. Then you query the requested application, it tells you which PermissionTokens are needed in order to use it.</p>
<p>For example, the Shipping application might tell you it needs:</p>
<pre><code>new PermissionToken()
{
Target = PermissionTokenTarget.Application,
Action = PermissionTokenAction.View,
Value = "ShippingApp"
};
</code></pre>
<p>This can obviously be extended to Create, Edit, Delete etc and, because of the custom Value property, any application, module or widget can define its own required permissions. YMMV, but this has always been an efficient method for me which I have found to scale well.</p>
| 2,382
|
<p>I had to delete all the rows from a log table that contained about 5 million rows. My initial try was to issue the following command in query analyzer:</p>
<p>delete from client_log</p>
<p>which took a very long time.</p>
|
<p>Check out <a href="https://msdn.microsoft.com/en-us/library/ms177570.aspx" rel="noreferrer">truncate table</a> which is a lot faster.</p>
|
<pre><code>DELETE * FROM table_name;
</code></pre>
<p>Premature optimization may be dangerous. Optimizing may mean doing something weird, but if it works you may want to take advantage of it.</p>
<pre><code>SELECT DbVendor_SuperFastDeleteAllFunction(tablename, BOZO_BIT) FROM dummy;
</code></pre>
<p>For speed I think it depends on...</p>
<ul>
<li><p>The underlying database: Oracle, Microsoft, MySQL, PostgreSQL, others, custom...</p></li>
<li><p>The table, it's content, and related tables:</p></li>
</ul>
<p>There may be deletion rules. Is there an existing procedure to delete all content in the table? Can this be optimized for the specific underlying database engine? How much do we care about breaking things / related data? Performing a DELETE may be the 'safest' way assuming that other related tables do not depend on this table. Are there other tables and queries that are related / depend on the data within this table? If we don't care much about this table being around, using DROP might be a fast method, again depending on the underlying database.</p>
<pre><code>DROP TABLE table_name;
</code></pre>
<p>How many rows are being deleted? Is there other information that is quickly gleaned that will optimize the deletion? For example, can we tell if the table is already empty? Can we tell if there are hundreds, thousands, millions, billions of rows?</p>
| 8,960
|
<p>Is it possible to connect two pieces of 1.75 mm filament end to end, with no change in width? I am asking the question because I am interested in creating a multi-filament feeder to a single extruder, and I am curious about the process of changing filament while the 3-d printer extruder continues uninterrupted. My current best-guess at the optimal solution is to someone 'cut' one end of the filament and 'melt' it to the end of another filament.</p>
|
<p>You'd have to ensure that the joining portion of the two filaments do not "bloom" or increase in diameter, which would happen if unconstrained at the melting and joining time. Alignment is also critical, otherwise you have a varying diameter from one color to the next at the point of join.</p>
<p>There's an item on ebay which is precision drilled and has precision machined mating surfaces to ensure alignment of the filament. The filament is extended through the two components, heated (in the case of the video, with a match) and the two metal parts are pushed together. The joining of the metal parts also cuts away the excess bulge of the melted filament, ensuring correct diameter.</p>
<p>In the case of the above item, the joining devices have to be threaded with the filament prior to the joining process and then have to be threaded off the filament by pushing them the entire length of the filament.</p>
<p>This would be okay if one were joining short lengths only. Consider how much fun it isn't to have to slide these two pieces over an entire full spool of filament.</p>
<p>A split device which would enable one to un-latch or otherwise open a clamshell to release the filament would require much more challenging machining to achieve the necessary precision, which is probably why we don't see such a product.</p>
|
<p>I haven't tried this but it is something I have thought about. The simplest way to try this that I could think of was to try cutting the ends flat and then using a soldering iron or just the printers printing nozzle to melt the ends and then quickly press them together, then you could sand the filamelt to try and clean up the join. </p>
<p>I think what would work better than trying to get the width perfect would be to make sure your printer is doing infill when it hits the join so over or under extrusion wont matter as much or have the printer move to the side of the print and extrude in thin air while getting past the join. I have done this when swapping filaments during a print by pausing the printer, and changing the filament.</p>
| 316
|
<p>3D-printing newbie here. I have a Geeetech's Prusa i3 mk2 B.</p>
<p>I'm trying to print this: <a href="https://www.thingiverse.com/thing:1358311" rel="noreferrer">https://www.thingiverse.com/thing:1358311</a></p>
<p>That's a mold, with 2 external parts and a core. The exterior prints wonderful. But the core is too messy. Take a look at this: </p>
<p><a href="https://i.stack.imgur.com/HrrKz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HrrKz.png" alt="enter image description here"></a></p>
<p>What riddles me is that the side parts, and the pole's base, print fine; so this does not look like a bad calibrated printer, but something else entirely. My guess is this is some precise tuning I don't know yet. </p>
<p>I've been trying to print that little pole without success for over a week now. Tried all this:</p>
<ul>
<li>Changing the slicer program (I've used Ultimaker Cura and Slic3r prusa edition)</li>
<li>Tuning the e-steps for avoiding over-extrusion.</li>
<li>Tuning the z-steps, so the nozzle doesn't melt the last layer when printing a new one.</li>
<li>In the same sense, changed the nozzle heat.</li>
<li>Tried lots of different layering, speed, walls, bridging, and quirks configurations.</li>
</ul>
<p>So far, the best I got is a little pole not-too-deformed so I can make my part anyway, even when the pole is not well printed. But after seeing lots of videos and reading lots of tips online, I still don't understand how to tune my print for that simple little pole.</p>
<p>Other that tips, what I would really like to ask is if somebody has a name for that problem I'm facing, so it would be much more easy to search for my tuning options.</p>
<p>So... any clue how to fix this? </p>
|
<p>Basically, <strong>you print too hot (and fast) without enough cooling</strong>. The deformed small pin in your image is a perfect example of depositing new layers onto too hot (not cooled down enough) prior layers.</p>
<p>You can easily solve this by printing two identical parts spaced apart from each other. This allows the layers to cool before the next is deposited. </p>
<p>From <a href="https://ultimaker.com/en/resources/21932-mastering-cura" rel="noreferrer">mastering Ultimaker Cura</a>:</p>
<blockquote>
<p>When printing a series of small parts, print them all together. The
travel time between the parts is often enough time for the layers to
cool without changing your settings.</p>
</blockquote>
<p>If you do want this to print as a single piece, you need to:</p>
<ul>
<li><strong>tune down hotend temperature</strong> (use the minimum temperature that gives good print results, printing a <a href="/q/7345">temperature tower</a> will help to determine this), </li>
<li><strong>increase minimal layer time</strong> (may not always work as speed will not be lowered under the minimum printing speed) and</li>
<li><strong>increase part cooling fan percentage</strong> (or print a better fan duct that allows for more cooling air to reach the print; many fan ducts are too convergent, the pressure increase is then too big for the fan to effectively push air through it).</li>
</ul>
|
<p>I'm sorry for the long time I took to answer, but the ammount of NEW problems I faced since started this question was so big that wanted to write a list of them before answering my own question. I've finally also desisted from the list, as the problems tends towards infinity. </p>
<p>Simple version: printing more than a single item did the trick, as several people proposed here. But then the piece broke when tried to remove it from the hot bed, as somebody else also warned me here. By that time I tried a temp tower, had to recalibrate almost the whole printer, had to also relubricate it, had to learn some tricks about sticking and de-sticking pieces from the bed, tried several different glues, started to fine-tune my slicings, and so on and so on... man, 3D printing is laborious.</p>
<p>But I wanted to let this link here for all the fellow newbies out there reading this. </p>
<p><a href="https://all3dp.com/1/common-3d-printing-problems-troubleshooting-3d-printer-issues/" rel="nofollow noreferrer">https://all3dp.com/1/common-3d-printing-problems-troubleshooting-3d-printer-issues/</a></p>
<p>That was exactly the kind of document I was looking for online as a newcomer to this world, and I'm sure it will be useful for a lot of people.</p>
<p>Thanks everybody.</p>
| 1,258
|
<p>Is there any python module to convert PDF files into text? I tried <a href="http://code.activestate.com/recipes/511465/" rel="noreferrer">one piece of code</a> found in Activestate which uses pypdf but the text generated had no space between and was of no use. </p>
|
<p>Try <a href="http://www.unixuser.org/~euske/python/pdfminer/index.html" rel="noreferrer">PDFMiner</a>. It can extract text from PDF files as HTML, SGML or "Tagged PDF" format.</p>
<p>The Tagged PDF format seems to be the cleanest, and stripping out the XML tags leaves just the bare text.</p>
<p>A Python 3 version is available under:</p>
<ul>
<li><a href="https://github.com/pdfminer/pdfminer.six" rel="noreferrer">https://github.com/pdfminer/pdfminer.six</a></li>
</ul>
|
<p>Found that solution today. Works great for me. Even rendering PDF pages to PNG images.
<a href="http://www.swftools.org/gfx_tutorial.html" rel="nofollow">http://www.swftools.org/gfx_tutorial.html</a></p>
| 4,528
|
<p>Is there a way to enforce constraint checking in MSSQL only when inserting new rows? I.e. allow the constraints to be violated when removing/updating rows?</p>
<p>Update: I mean FK constraint.</p>
|
<p>You could create an INSERT TRIGGER that checks that the conditions are met. That way all updates will go straight through.</p>
<pre><code>CREATE TRIGGER employee_insupd
ON employee
FOR INSERT
AS
/* Get the range of level for this job type from the jobs table. */
DECLARE @min_lvl tinyint,
@max_lvl tinyint,
@emp_lvl tinyint,
@job_id smallint
SELECT @min_lvl = min_lvl,
@max_lvl = max_lvl,
@emp_lvl = i.job_lvl,
@job_id = i.job_id
FROM employee e INNER JOIN inserted i ON e.emp_id = i.emp_id
JOIN jobs j ON j.job_id = i.job_id
IF (@job_id = 1) and (@emp_lvl <> 10)
BEGIN
RAISERROR ('Job id 1 expects the default level of 10.', 16, 1)
ROLLBACK TRANSACTION
END
ELSE
IF NOT (@emp_lvl BETWEEN @min_lvl AND @max_lvl)
BEGIN
RAISERROR ('The level for job_id:%d should be between %d and %d.',
16, 1, @job_id, @min_lvl, @max_lvl)
ROLLBACK TRANSACTION
END
</code></pre>
|
<p>I think your best bet is to remove the explicit constraint and add a <a href="http://msdn.microsoft.com/en-us/library/ms180169.aspx" rel="nofollow noreferrer">cursor</a> for inserts, so you can perform your checking there and raise an error if the constraint is violated.</p>
| 5,988
|
<p>I uploaded a 3D object for <a href="https://lerdagiovanni.wixsite.com/kauda/stl-files" rel="nofollow noreferrer">this project</a> to Fusion 360 and printed it out straightforward:</p>
<p><a href="https://i.stack.imgur.com/BLeFU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BLeFU.png" alt="enter image description here" /></a></p>
<p>Yet its middle hole is too small for the stepper motor (<a href="https://www.omc-stepperonline.com/nema-17-stepper-motor/" rel="nofollow noreferrer">Nema 17 Stepper-M</a>) I am using so I wanted to increase its tolerance before reprinting it.</p>
<p>So, I followed the <a href="https://www.youtube.com/watch?v=SigAE7GG9vs&ab_channel=TylerBeckofTech%26Espresso" rel="nofollow noreferrer">tutorial by Tyler Beck of Tech</a> who lead me to drawings:</p>
<p><a href="https://i.stack.imgur.com/0Z3YX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0Z3YX.png" alt="enter image description here" /></a></p>
<p>I was wondering if doing a drawing (sketch in Fusion 360) was sufficient to expect the shaft of the step motor to go through?</p>
<p>Here are the gear and the shaft before I add the drawing constraints:</p>
<p><a href="https://i.stack.imgur.com/arA1s.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/arA1s.jpg" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/wpxT3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wpxT3.jpg" alt="enter image description here" /></a></p>
|
<p>Besides offsetting the <strong>clearances</strong> you want into models, you can and should also calibrate your printer to <strong>compensate for included holes</strong> - because often inner holes are solved to be smaller than actually designed out of necessity.</p>
<p>However, the option can <em>also</em> be used to fix problems that stem from the slicing and printing itself, and thus offers to fix some problems that are endemic to your setup or where you can't easily fix the model by setting an offset to create the wanted clearances in it.</p>
<p>In Ultimaker <strong>Cura</strong>, the option for this fix is called <code>Hole horizontal expansion</code> since <a href="https://community.ultimaker.com/topic/32187-ultimaker-cura-46-released/" rel="nofollow noreferrer">4.6 in April 2020</a>, which only affects internal perimeters as I know from testing.</p>
<p><strong>SuperSlicer</strong>, a PrusaSlicer branch offers <code>hole_XY_compensation</code>, though I can't quite pinpoint the time when it was added. I guesstimate sometime before <a href="https://github.com/supermerill/SuperSlicer/commit/151ea0a39f94d383fdf17802e4e52e787a7bae46" rel="nofollow noreferrer">October 2020</a>.</p>
<p><strong>PrusaSlicer</strong> offers <code>XY size compensation</code>, which does affect outer perimeters. A hole-only is requested almost since that option was available the first time. An attempt to implement a hole-only compensation again appears to be <a href="https://github.com/prusa3d/PrusaSlicer/issues/4561" rel="nofollow noreferrer">worked on since mid-2020.</a> It seems that in the beginning of March some implementation has been tested.</p>
<p>The first work for such a function <a href="https://manual.slic3r.org/troubleshooting/dimension-errors" rel="nofollow noreferrer">was tried by <strong>Slic3r</strong></a> before PrusaSlicer was started on, using an <a href="https://reprap.org/mediawiki/index.php?title=ArcCompensation&action=history" rel="nofollow noreferrer">Arc-compensation formula</a> in at latest 2009, but the function proved to be overcompensating. As Prusa-Slicer is a <em>fork</em> of Slic3r, some of this work might remain in the code.</p>
|
<p>This seems like a tolerance press fit problem and similar to what you will find if you try the same using normal machining operations on a lathe or milling machine.</p>
<p>I print 3 mm clearance fit holes on my Prusa MK3S, meant to fit on 3.00 mm (measured with a digital caliper) stainless steel shafts. The printed parts are from Fusion 360 models, with 3 mm holes by design, converted to STL and then sliced and printed with 0.2 mm layer height. The holes are very close to 3.0 mm and out by 0.05-0.1 mm.</p>
<p>The solution was to make adjustments in Fusion. I left the model with the hole size as 3 mm but then use the Offset Face command on the inside of the extruded hole to make it slightly larger with the required tolerance.</p>
<p><a href="https://i.stack.imgur.com/OaMCs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OaMCs.png" alt="enter image description here" /></a></p>
<p>In my case, an offset of 0.05 provided a nice press fit, and 0.1 offset allowed the shaft to closely fit in the hole but loose enough to rotate.</p>
<p>I suggest you create a simple model with a number of holes designed to be the same size and then use different Offset Face numbers to dial in what you need. That way you get to learn what to expect from your printer and its accuracy.</p>
| 1,890
|
<p>An MFC application that I'm trying to migrate uses <code>afxext.h</code>, which causes <code>_AFXDLL</code> to get set, which causes this error if I set <code>/MT</code>:</p>
<blockquote>
<p>Please use the /MD switch for _AFXDLL builds</p>
</blockquote>
<p>My research to date indicates that it is impossible to build an application for execution on Windows NT 4.0 using Visual Studio (C++, in this case) 2005.</p>
<p>Is this really true? Are there any workaround available?</p>
|
<p>No, there are many applications built with VS2005 that have to support Windows XP, 2000, NT, the whole stack. The issue is that (by default) VS2005 wants to use libraries/exports not present on NT.</p>
<p>See <a href="http://www.mombu.com/microsoft/windows-programmer-win32/t-vs2005-and-nt4-392831.html" rel="noreferrer">this thread</a> for some background.</p>
<p>Then start limiting your dependencies via preprocessor macros, and avoiding APIs which aren't supported on NT.</p>
|
<p>The idea is that the exe is needed to link to the static library.</p>
<p>Please try this
"Configuration Properties", "General", "Use of MFC" to "Use MFC in a Static Library"
"Configuration Properties", "General", "Use of ATL" to "Static Link to ATL"</p>
<p>"Configuration Properties", "C\C++", "Code Generation", "Runtime Library" to "Multi-Threaded (\MT)"</p>
<p>Test Platform
Build Machine: Visual Studio 2005 on Window XP SP2
Client Machine: Window XP SP2 (no VS2005 installed)</p>
| 2,303
|
<p>I have 16,000 jpg's from a webcan screeb grabber that I let run for a year pointing into the back year. I want to find a way to grab every 4th image so that I can then put them into another directory so I can later turn them into a movie. Is there a simple bash script or other way under linux that I can do this.</p>
<p>They are named like so......</p>
<p>frame-44558.jpg</p>
<p>frame-44559.jpg</p>
<p>frame-44560.jpg</p>
<p>frame-44561.jpg</p>
<p>Thanks from a newb needing help.</p>
<hr>
<p>Seems to have worked.
Couple of errors in my origonal post. There were actually 280,000 images and the naming was.
/home/baldy/Desktop/webcamimages/webcam_2007-05-29_163405.jpg
/home/baldy/Desktop/webcamimages/webcam_2007-05-29_163505.jpg
/home/baldy/Desktop/webcamimages/webcam_2007-05-29_163605.jpg</p>
<p>I ran.
cp $(ls | awk '{nr++; if (nr % 10 == 0) print $0}') ../newdirectory/</p>
<p>Which appears to have copied the images. 70-900 per day from the looks of it.</p>
<p>Now I'm running
mencoder mf://*.jpg -mf w=640:h=480:fps=30:type=jpg -ovc lavc -lavcopts vcodec=msmpeg4v2 -nosound -o ../output-msmpeg4v2.avi</p>
<p>I'll let you know how the movie works out.</p>
<p>UPDATE: Movie did not work.
Only has images from 2007 in it even though the directory has 2008 as well.
webcam_2008-02-17_101403.jpg webcam_2008-03-27_192205.jpg
webcam_2008-02-17_102403.jpg webcam_2008-03-27_193205.jpg
webcam_2008-02-17_103403.jpg webcam_2008-03-27_194205.jpg
webcam_2008-02-17_104403.jpg webcam_2008-03-27_195205.jpg</p>
<p>How can I modify my mencoder line so that it uses all the images?</p>
|
<p>One simple way is: </p>
<pre>
$ touch a b c d e f g h i j k l m n o p q r s t u v w x y z
$ mv $(ls | awk '{nr++; if (nr % 4 == 0) print $0}') destdir
</pre>
|
<p>Just iterate over a list of files:</p>
<pre><code>files=( frame-*.jpg )
i=0
while [[ $i -lt ${#files} ]] ; do
cur_file=${files[$i]}
mungle_frame $cur_file
i=$( expr $i + 4 )
done
</code></pre>
| 9,732
|
<p>My HTML is all marked up, ready to make it rain CSS. The problem is that I have to go back and find out what all my id and class names are so I can get started. What I need is a tool that parses my HTML and spits out a stylesheet with all the possible elements ready to be styled (maybe even with some defaults). Does such a tool exist?</p>
|
<p>I have a poor man's version of this I have used in the past... this requires jquery and firebug...</p>
<pre><code><script type="text/javascript">
$(document).ready(function() {
$('*[@id]').each(function() {
console.log('#' + this.id + ' {}');
});
$('*[@class]').each(function() {
$.each($(this).attr('class').split(" "), function() {
console.log('.' + this + ' {}');
});
});
});
</script>
</code></pre>
<p>it gives you something like this:</p>
<pre><code>#spinner {}
#log {}
#area {}
.cards {}
.dialog {}
.controller {}
</code></pre>
<p>if you want them in "natural" page order instead...</p>
<pre><code><script type="text/javascript">
$(document).ready(function() {
$('*').each(function() {
if($(this).is('[@id]')) {
console.log('#' + this.id + ' {}');
}
if($(this).is('[@class]')) {
$.each($(this).attr('class').split(" "), function() {
console.log('.' + this + ' {}');
});
}
});
});
</script>
</code></pre>
<p>I just load the page with that script in there, then cut and paste the results out of firebug... then obviously, remove the script :)</p>
<p>you'll need to remove the dups manually or just toss in some simple dup checking logic with a map or array or something.. one for IDs and one for classes.</p>
|
<p>I've made a generator which makes the html and css for you = <a href="https://www.andy-howard.com/css-skeleton-screen-generator/" rel="nofollow noreferrer">https://www.andy-howard.com/css-skeleton-screen-generator/</a></p>
<p>Not much else to say really, it utilises the :empty selector in css.</p>
| 3,761
|
<p>I've got a collection that implements an interface that extends both IList<T> and List. </p>
<pre><code>public Interface IMySpecialCollection : IList<MyObject>, IList { ... }
</code></pre>
<p>That means I have two versions of the indexer. </p>
<p>I wish the generic implementation to be used, so I implement that one normally:</p>
<pre><code>public MyObject this[int index] { .... }
</code></pre>
<p>I only need the IList version for serialization, so I implement it explicitly, to keep it hidden:</p>
<pre><code>object IList.this[int index] { ... }
</code></pre>
<p>However, in my unit tests, the following</p>
<pre><code>MyObject foo = target[0];
</code></pre>
<p>results in a compiler error</p>
<blockquote>
<p>The call is ambiguous between the
following methods or properties</p>
</blockquote>
<p>I'm a bit surprised at this; I believe I've done it before and it works fine. What am I missing here? How can I get IList<T> and IList to coexist within the same interface?</p>
<p><strong>Edit</strong> IList<T> does <em>not</em> implement IList, and I <strong>must</strong> implement IList for serialization. I'm not interested in workarounds, I want to know what I'm missing.</p>
<p><strong>Edit again</strong>: I've had to drop IList from the interface and move it on my class. I don't want to do this, as classes that implement the interface are eventually going to be serialized to Xaml, which requires collections to implement IDictionary or IList...</p>
|
<p>You can't do this with </p>
<p><code>public interface IMySpecialCollection : IList<MyObject>, IList { ... }</code></p>
<p>But you can do what you want with a class, you will need to make the implementations for one of the interfaces explicit. In my example I made IList explicit.</p>
<p><code>public class MySpecialCollection : IList<MyObject>, IList { ... }</code></p>
<p><code>IList<object> myspecialcollection = new MySpecialCollection();
IList list = (IList)myspecialcollection;</code></p>
<p>Have you considered having IMySpecialCollection implement ISerializable for serialization?
Supporting multiple collection types seems a bit wrong to me. You may also want to look at casting yout IList to IEnumerable for serialization since IList just wraps IEnumerable and ICollection. </p>
|
<p>List<T> implies IList, so it's a bad idea to use both in the same class.</p>
| 8,125
|
<p>Since generics were introduced, Class is parametrized, so that List.class produces Class<List>. This is clear.</p>
<p>What I am not able to figure out is how to get a instance of Class of type which is parametrized itself, i.e. Class<List<String>>. Like in this snippet:</p>
<pre><code>public class GenTest {
static <T> T instantiate(Class<T> clazz) throws Exception {
return clazz.newInstance();
}
public static void main(String[] args) throws Exception {
// Is there a way to avoid waring on the line below
// without using @SuppressWarnings("unchecked")?
// ArrayList.class is Class<ArrayList>, but I would like to
// pass in Class<ArrayList<String>>
ArrayList<String> l = GenTest.instantiate(ArrayList.class);
}
}
</code></pre>
<p>I run into variations of this problem quite often and I still don't know, if I just miss something, or if there is really no better way. Thanks for suggestions.</p>
|
<p>The Class class is a run-time representation of a type. Since parametrized types undergo type erasure at runtime, the class object for Class would be the same as for Class<List<Integer>> and Class<List<String>>.</p>
<p>The reason you cannot instantiate them using the .class notation is that this is a special syntax used for class literals. The <a href="http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.8.2" rel="noreferrer">Java Language Specification</a> specifically forbids this syntax when the type is parametrized, which is why List<String>.class is not allowed.</p>
|
<p>The only thing you can do is instantiate <code>List<String></code> <em>directly</em> and call its <code>getClass()</code>:</p>
<pre><code>instantiate(new List<String>() { ... }.getClass());
</code></pre>
<p>For types with multiple abstract methods like <code>List</code>, this is quite awkward. But unfortunately, calling subclass constructors (like <code>new ArrayList<String></code>) or factory methods (<code>Collections.<String>emptyList()</code>) don't work.</p>
| 9,711
|
<p>In the context of a personal project I would like to reproduce the appearance of a commercial product of which I send you a cropped image.</p>
<p>I would also like to point out that I do not have the object in question, but it would seem that it is made from a polymer. </p>
<p>The product is a case with an embedded electronical card, so heat dissipation is important.</p>
<p>I'm interested by what kind of plastic is really used here. I plan to have the part manufactured by a company, so I think the method used will be SLS</p>
<p>I therefore rely on your expertise in the field of 3D printing to try to identify the material used.</p>
<p><a href="https://i.stack.imgur.com/3WtzK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3WtzK.png" alt="enter image description here"></a></p>
<p>Thanks</p>
|
<p>Surface finish does not really map to the substrate material, Visually, what you have shown could be glass, ceramic, plastic, epoxy or metal.</p>
<p>The surface finish is a combination of the shaping process, any post processing, and any surface finishing. Most significantly, there are a wide variety of custom paints which are designed to mimic specific surface finishes. This means you could carve an object out of clay, then spray it to give the appearance of being sand-blasted steel (to give a specific example).</p>
<p>The underlying material is mostly irrelevant to the appearance. It will be driven by mechanical/thermal considerations (is this a mock-up, or does it need to have functional wall-thickness), and production volume/cost considerations (is it a one off, or are you making hundreds/millions)?</p>
|
<p>Is there anything else about this object, but its picture? Softening temperature, biodegradability, is it stiff of flexible, hard or soft, anything could help identifying its material.</p>
<p>Also, post-processing (sanding down or chemicals like acetone bath) greatly enhances the range of filaments that can be used.</p>
<p>Just from the picture, my first guess would be: it looks very much like what ceramic powder added filaments can yield with when you sand them down afterwards. Take a look at pictures of prints with LayBrick, CERAMO, etc.</p>
<p>On second thought, <strong>the answer is: Polyamide/Nylon</strong>. It must be either a polyamide case or polyamide coating of some other material. For home projects, MJF polyamide prints can easily be ordered online. Ordering polyamide coating of plastic parts can be trickier depending on your location, although definitely doable.</p>
<p>Going with Nylon at home prints may require a non-basic 3D printer and some expertise.</p>
| 1,172
|
<p>I work with embedded Linux systems that sometimes want to get their IP address from a DHCP server. The DHCP Client client we use (<a href="http://www.phystech.com/download/dhcpcd.html" rel="nofollow noreferrer" title="DHCPCD">dhcpcd</a>) has limited retry logic. If our device starts up without any DHCP server available and times out, dhcpcd will exit and the device will never get an IP address until it's rebooted with a DHCP server visible/connected. I can't be the only one that has this problem. The problem doesn't even seem to be specific to embedded systems (though it's worse there). How do you handle this? Is there a more robust client available? </p>
|
<p>The reference dhclient from the ISC should run forever in the default configuration, and it should acquire a lease later if it doesn't get one at startup.</p>
<p>I am using the out of the box dhcp client on FreeBSD, which is derived from OpenBSD's and based on the ISC's dhclient, and this is the out of the box behavior.</p>
<p>See <a href="http://www.isc.org/index.pl?/sw/dhcp/" rel="nofollow noreferrer">http://www.isc.org/index.pl?/sw/dhcp/</a></p>
|
<p>Add to <code>rc.local</code> a check to see if an IP has been obtained. If no setup an 'at' job in the near future to attempt again. Continue scheduling 'at' jobs until an IP is obtained. </p>
| 8,909
|
<p>Common 3D printers (read "cheap") may be used to print masks for PCBs (printed-circuit boards) which use PTH (through-hole) components.</p>
<p>But can they be used to print PCBs which use SMD components? I'd like to make boards at least for Arduino-like SMD chips.</p>
|
<p>In addition to the thermal issues Tormod raised, there is a conductivity issue. Present conductive filaments are much less conductive than copper. The power loss may be enough to affect functionality. Also, the lost power goes to heat, making the thermal problems worse.</p>
<p>For bulk materials, "volume resistivity" is measured in "Ohm-cm", which is the resistance of a 1 cm cube of the material, measured from one entire face to the opposite entire face (see <a href="https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity" rel="nofollow">https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity</a>).</p>
<p>Copper has a volume resistivity of about 1.68 <em>micro</em>Ohm-cm. </p>
<p>Proto-pasta conductive PLA filament claims 15 ohm-cm (<a href="http://www.proto-pasta.com/pages/conductive-pla" rel="nofollow">http://www.proto-pasta.com/pages/conductive-pla</a>). Functionalize F-Electic™ claims 0.75 ohm-cm (<a href="http://functionalize.com/about/functionalize-f-electric-highly-conductive-filament/" rel="nofollow">http://functionalize.com/about/functionalize-f-electric-highly-conductive-filament/</a>).</p>
<p>Printing itself significantly raises resistivity. Proto-pasta claims 30 ohm-cm along X and Y, 115 along Z. More intuitively, each cm of length of a 2.5mm wide printed trace, 0.4mm thick, should add several hundred ohms with the Proto-pasta, or several tens of ohms with the F-electric. That may be enough to matter. </p>
<p>It's probably worth mentioning that there's a specialized PCB printer (the "Voltera") that uses (pricey) conductive ink, and can also dispense solder paste: <a href="http://www.computerworld.com/article/2885188/3d-circuit-board-printer-a-smash-hit-on-kickstarter.html" rel="nofollow">http://www.computerworld.com/article/2885188/3d-circuit-board-printer-a-smash-hit-on-kickstarter.html</a></p>
|
<p>In theory, I imagine you can, but there are some practical considerations that might need some thought:</p>
<p>If you have a desktop printer with multiple extruders, you could probably print with both one <em>conductive</em> and one <em>structural</em> filament, and thereby build circuits in 3D.</p>
<p>One concern would be the low melting points of most 3D printed filaments, since one would have to limit the heat generated by the mounted components and connections so that the structure of the "board" would not be melted.</p>
<p>Mounting components to the board would also differ from a normal PCB, since you would have to connect the components with the conductive filament without melting the structure of the board. In other words, you probably would have to use conductive filament as "solder", and melt components into place. </p>
<p>Whether you could use typical tools used for mounting SMD components with conductive filament as solder is beyond my knowledge. </p>
| 153
|
<p>Is it possible to retrieve items from a Python dictionary in the order that they were inserted?</p>
|
<p>The standard Python <code>dict</code> does this by default if you're using CPython 3.6+ (or Python 3.7+ for any other implementation of Python).</p>
<p>On older versions of Python you can use <a href="https://docs.python.org/library/collections.html#ordereddict-objects" rel="noreferrer"><code>collections.OrderedDict</code></a>.</p>
|
<p>if you don't need the dict functionality, and only need to return tuples in the order you've inserted them, wouldn't a queue work better?</p>
| 8,589
|
<p>Imagine you want to animate some object on a WinForm. You setup a timer to update the state or model, and override the paint event of the Form. But from there, what's the best way to continually repaint the Form for the animation?</p>
<ul>
<li>Invalidate the Form as soon as you are done drawing?</li>
<li>Setup a second timer and invalidate the form on a regular interval?</li>
<li>Perhaps there is a common pattern for this thing?</li>
<li>Are there any useful .NET classes to help out?</li>
</ul>
<p>Each time I need to do this I discover a new method with a new drawback. What are the experiences and recommendations from the SO community?</p>
|
<p>I've created a library that might help with this. It's called Transitions, and can be found here: <a href="https://github.com/UweKeim/dot-net-transitions" rel="nofollow noreferrer">https://github.com/UweKeim/dot-net-transitions</a>. Available on nuget as the <a href="https://www.nuget.org/packages/dot-net-transitions/" rel="nofollow noreferrer">dot-net-transitions package</a></p>
<p>It uses timers running on a background thread to animate the objects. The library is open-source, so if it is any use to you, you can look at the code to see what it's doing.</p>
|
<p>What you're doing is the only solution I've ever used in WinForms (a timer with constant redrawings). There are a bunch of techniques that you can use to make the user's experience with it smoother (such as double-buffering).</p>
<p>You might want to give WPF a try. There are built-in facilities for doing animations in WPF, and they're much smoother (and require less code and no synchronization on your part) than a timer-based solution.</p>
<p>Note that you do not need to use WPF throughout your whole app for that solution; it's possible to pack this functionality into a WPF control and embed the control in a WinForms application (or an unmanaged app, for that matter):</p>
<p><a href="http://www.codeproject.com/KB/WPF/WPF_UserControls.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/WPF/WPF_UserControls.aspx</a></p>
| 3,247
|
<p>In Java, there is no such thing as an unsigned byte.</p>
<p>Working with some low level code, occasionally you need to work with bytes that have unsigned values greater than 128, which causes Java to interpret them as a negative number due to the MSB being used for sign.</p>
<p>What's a good way to work around this? (Saying don't use Java is not an option)</p>
|
<p>It is actually possible to get rid of the if statement and the addition if you do it like this.</p>
<pre><code>byte[] foobar = ..;
int value = (foobar[10] & 0xff);
</code></pre>
<p>This way Java doesn't interpret the byte as a negative number and flip the sign bit on the integer also.</p>
|
<p>I guess you could just use a short to store them. Not very efficient, but really the only option besides some herculean effort that I have seen.</p>
| 3,227
|
<p>Been going over my predecessor's code and see usage of the "request" scope frequently. What is the appropriate usage of this scope?</p>
|
<p>There are several scopes that are available to any portion of your code: Session, Client, Cookie, Application, and Request. Some are inadvisable to use in certain ways (i.e. using Request or Application scope inside your Custom Tags or CFC's; this is <a href="http://en.wikipedia.org/wiki/Coupling_%28computer_science%29" rel="noreferrer">coupling</a>, violates encapsulation principles, and is considered a bad practice), and some have special purposes: Cookie is persisted on the client machine as physical cookies, and Session scoped variables are user-specific and expire with the user's session on the website.</p>
<p>If a variable is extremely unlikely to change (constant for all intents and purposes) and can simply be initialized on application startup and never written again, generally you should put it into Application scope because this persists it between every user and every session. When properly implemented it is written once and read N times.</p>
<p>A proper implementation of Application variables in Application.cfm might look like this:</p>
<pre><code><cfif not structKeyExists(application, "dsn")>
<cflock scope="application" type="exclusive" timeout="30">
<cfif not structKeyExists(application, "dsn")>
<cfset application.dsn = "MyDSN" />
<cfset foo = "bar" />
<cfset x = 5 />
</cfif>
</cflock>
</cfif>
</code></pre>
<p>Note that the existence of the variable in the application scope is checked before and after the lock, so that if two users create a race condition at application startup, only one of them will end up setting the application variables.</p>
<p>The benefit of this approach is that it won't constantly refresh these stored variables on every request, wasting the user's time and the server's processing cycles. The trade-off is that it is a little verbose and complex.</p>
<p>This was greatly simplified with the addition of Application.cfc. Now, you can specify which variables are created on application startup and don't have to worry about locking and checking for existence and all of that fun stuff:</p>
<pre><code><cfcomponent>
<cfset this.name = "myApplicationName" />
<cffunction name="onApplicationStart" returnType="boolean" output="false">
<cfset application.dsn = "MyDSN" />
<cfset foo = "bar" />
<cfset x = 5 />
<cfreturn true />
</cffunction>
</cfcomponent>
</code></pre>
<p>For more information on Application.cfc including all of the various special functions available and every little detail about what and how to use it, <a href="http://www.raymondcamden.com/2007/11/09/Applicationcfc-Methods-and-Example-Uses" rel="noreferrer">I recommend this post on Raymond Camden's blog</a>.</p>
<p>To summarize, request scope is available everywhere in your code, but that doesn't necessarily make it "right" to use it everywhere. Chances are that your predecessor was using it to break encapsulation, and that can be cumbersome to refactor out. You may be best off leaving it as-is, but understanding which scope is the best tool for the job will definitely make your future code better.</p>
|
<p>Okay, I just wanted to comment on your code. Please forgive me if I seem crazy. But you already verified that the structKeyExists in the beginning. Since you know it's going to be true, it wouldn't make sense to run another check. So my version of it would be this... But thats just me.</p>
<hr>
<pre><code><cfif not structKeyExists(application, "dsn")>
<cflock scope="application" type="exclusive" timeout="30">
<cfset application.dsn = "MyDSN" />
<cfset foo = "bar" />
<cfset x = 5 />
</cflock>
</cfif>
</code></pre>
<hr>
<p>Alright. </p>
<p></p>
| 4,529
|
<p>Most wiki software I've presents lots of "features" on their pages. This is fine for desktop users, but is annoying when using an iPhone or other mobile device. <br /><br />I'd prefer pages that just had the content, along with maybe an Edit button and a Search button. The editors are also often too fancy for mobile users; a simple multi-line edit field would be better for mobile users than a bunch of formatting controls.</p>
<p>What is a good wiki package for mobile users?</p>
|
<p>There isn't really a right answer. This is what coding standards within the company are for. If you can keep it consistent across the whole company then it will be easy to read. I personally like</p>
<pre><code>if ( a == b) {
doSomething();
}
else {
doSomething();
}
</code></pre>
<p>but this is a holy war. </p>
|
<p>Our boss makes us put { } after a decision statement no matter what, even if it's a single statement. It's really annoying to add two extra lines. The only exception is ternary operators.</p>
<p>I guess it's a good thing I have my code monitor in portrait orientation at 1200x1600.</p>
| 3,229
|
<p>Since <a href="http://www.iboxprinters.com/" rel="nofollow noreferrer">iBox Nano</a> is the smallest public-production-available 3d Resin printer (and the cheapest so far), I assume it has a huge size limitation. So far I've only seen pictures of its outputs that are <a href="http://www.iboxprinters.com/ibox-nano-1/" rel="nofollow noreferrer">miniature things</a>. I've never tried it nor have I seen it in action in person so I'd like to be sure. </p>
<p><strong>For example</strong>, my 3D models are of the size of beads to figurines to a standard sized pencil cup holder.</p>
<p><strong>I want to know in inches or millimeters the dimension (width, length, height) of the biggest possible object the iBox Nano can print.</strong></p>
|
<p>On their <a href="http://www.iboxprinters.com/ibox-nano-1/" rel="nofollow noreferrer">website</a>, I found the following picture, which states a build area of 40 mm x 20 mm x 90 mm (1.57" x 0,79" x 3.54").</p>
<p><a href="https://i.stack.imgur.com/TYxa8.jpg" rel="nofollow noreferrer" title="iBox Nano 3D printer specifications"><img src="https://i.stack.imgur.com/TYxa8.jpg" alt="iBox Nano 3D printer specifications" title="iBox Nano 3D printer specifications"></a></p>
|
<p>From their website I found a <a href="http://www.iboxprinters.com/pages.php?pageid=17" rel="nofollow">comparison between 300 microns down to 50 microns print quality</a>. My answer would be somewhere around this range.</p>
| 318
|
<p>There are lots of PHP articles about the subject so is this a PHP only problem.
I am sending emails using System.Net.Mail after some regular expression checks of course.
Similar to <a href="http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx" rel="noreferrer">http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx</a></p>
|
<p>the PHP email injection attack works because of a weakness in the PHP Mail() function. As a .net developer you need not worry.</p>
|
<p>I've never heard of that issue in ASP.NET. However, you should trust user input about as much as you'd trust a hooker with your wallet.</p>
| 7,856
|
<p>I am developing a mid-size application with VB2008. To better test my application I am following a MVP/Supervising Controller approach.</p>
<p>My question is: What are your recommendations to separate responsibilites? So far I've come up with a winform with an instance of a controller and with an instance of my class. The controls are updated via DataBinding</p>
<p>The problem is that I'm just not sure where to write the responsibilites (let's say Validation, Report creation, Queries and so on) Inside my class? in a separate class?</p>
<p>Is there any small example of a clean Winform class design that you could point me?</p>
|
<p>I would suggest you spend time reading Jeremy Millers '<a href="http://codebetter.com/blogs/jeremy.miller/archive/2007/07/25/the-build-your-own-cab-series-table-of-contents.aspx" rel="nofollow noreferrer">Build your own CAB</a>' series of posts to get a feel for what you might like/need to implement as your application becomes more complex.</p>
|
<p>Martin Fowler is a good source of information on all things design patterns including MVC. Fowler discusses Passive View and separation of responsibilities is demonstrated also</p>
<p><a href="http://martinfowler.com/eaaDev/ModelViewPresenter.html" rel="nofollow noreferrer">http://martinfowler.com/eaaDev/ModelViewPresenter.html</a></p>
| 8,865
|
<p>For a while now, my AmazonBasics PETG filament has been working like a charm. Now, it is balling up on my nozzle. I've tried slowing it down, re-leveling the bed, etc. I don't want to go through the hassle of replacing my nozzle with a Micro-Swiss all metal 0.4 mm nozzle. I've tried the other extruder which I know works with PLA, but same results. I'm using a Flashforge Creator Pro(2016).</p>
|
<p>PETG does this. PETG is like glue when soft this is why when you level the bed you have to add an additional 0.1 mm distance for PETG. PETG should not be as close as PLA, but futher away. It will stick to the hotend so preferably change the hotend from brass to a nickle plated nozzle (e.g. Micro Swiss, PETG does not stick to that nozzle at all).</p>
|
<p>PETG does this. PETG is like glue when soft this is why when you level the bed you have to add an additional 0.1 mm distance for PETG. PETG should not be as close as PLA, but futher away. It will stick to the hotend so preferably change the hotend from brass to a nickle plated nozzle (e.g. Micro Swiss, PETG does not stick to that nozzle at all).</p>
| 1,226
|
<p>I want to escape a DOS filename so I can use it with sed. I have a DOS batch file something like this:</p>
<pre><code>set FILENAME=%~f1
sed 's/Some Pattern/%FILENAME%/' inputfile
</code></pre>
<p>(Note: <code>%~f1</code> - expands <code>%1</code> to a Fully qualified path name - <code>C:\utils\MyFile.txt</code>)</p>
<p>I found that the backslashes in <code>%FILENAME%</code> are just escaping the next letter.</p>
<p>How can I double them up so that they are escaped?</p>
<p>(I have cygwin installed so feel free to use any other *nix commands)</p>
<h1>Solution</h1>
<p>Combining Jeremy and Alexandru Nedelcu's suggestions, and using | for the delimiter in the sed command I have</p>
<pre><code>set FILENAME=%~f1
cygpath "s|Some Pattern|%FILENAME%|" >sedcmd.tmp
sed -f sedcmd.tmp inputfile
del /q sedcmd.tmp
</code></pre>
|
<p>This will work. It's messy because in BAT files you can't use set var=`cmd` like you can in unix.
The fact that echo doesn't understand quotes is also messy, and could lead to trouble if <code>Some Pattern</code> contains shell meta characters.</p>
<pre><code>set FILENAME=%~f1
echo s/Some Pattern/%FILENAME%/ | sed -e "s/\\/\\\\/g" >sedcmd.tmp
sed -f sedcmd.tmp inputfile
del /q sedcmd.tmp
</code></pre>
<p>[Edited]: I am suprised that it didn't work for you. I just tested it, and it worked on my machine. I am using sed from <a href="http://sourceforge.net/projects/unxutils" rel="nofollow noreferrer">http://sourceforge.net/projects/unxutils</a> and using cmd.exe to run those commands in a bat file.</p>
|
<p>@Alexandru & Jeremy, Thanks for your help. You both get upvotes</p>
<p>@Jeremy</p>
<p>Using your method I got the following error:</p>
<blockquote>
<p>sed: -e expression #1, char 8:
unterminated `s' command</p>
</blockquote>
<p>If you can edit your answer to make it work I'd accept it. (pasting my solution doesn't count)</p>
<p><strong>Update:</strong> Ok, I tried it with UnixUtils and it worked. (For reference, the UnixUtils I downloaded was dated March 1, 2007, and uses GNU sed version 3.02, my Cygwin install has GNU sed version 4.1.5)</p>
| 5,572
|
<p>I have a weird problem with my old 3D printer, it is a Prusa/Mendel type.
When I print a 20 mm cube, X and Y are correct, Z is resulting 16 to 17 mm.
I have checked the correctness of the movement on Z using the manual controls and there are no issues.</p>
<p>I played a bit with the layer thickness, I have a 0.4 mm nozzle, setting the layer height to 0.12 mm (normally is on 0.16 mm) but no changes in the result.
I am printing PLA on a cold bed at 180 °C without any other particular defect.</p>
<p>I would appreciate some direction on how to solve such problem.</p>
|
<p>You should check that the steps per mm for your Z-axis are set correctly. This depends on the pitch of the leadscrews/threaded rods driving the axis and parameters of your steppers (microstepping and raw steps/revolution). <a href="http://prusaprinters.org/calculator/" rel="nofollow noreferrer">This Calculator</a>.</p>
<p>Make sure that your layer height is a multiple of a full step of the Z-stepper. The Z-stepper may be disabled intermittently, and when re-enabled it may "snap" to the nearest full step position. If your layer height requires microstepping, you may notice it getting rounded down or up due to this.</p>
<p>For instance, if a full step were 0.08 mm, then 0.16 mm layers would require 2 full steps, printing fine. 0.12 mm layers would require 1 full step and a half microstep. Due to rounding, some layers might be reduced to 0.08 mm instead. This might account for the height discrepancy you're seeing (though 0.08 mm is quite a high, unrealistic amount for a full-step).</p>
|
<p>A suitable test part for this problem, to check if the bad scaling is linear or the result of missing steps (as was identified in this case) would be a ramp, or sequence of steps. You can check the linearity using a straight edge, and would be able to perform repeated tests to identify of there was a specific Z location where steps were more likely to be lost (for example due to some tightness in the motion system).</p>
| 391
|
<p>Google maps in some region can serve traffic information showing the blocked roads and so on. I was wondering if there is any code example demonstrating how can I serve traffice information for my own region. </p>
|
<p>"Google Maps Hacks" has a hack, <a href="http://safari.oreilly.com/0596101619/googlemapshks-CHP-4-SECT-3" rel="nofollow noreferrer">"Hack 30. Stay Out of Traffic Jams"</a>, on that.</p>
<p>You can also find out how to get U.S. traffic info from John Resig's <a href="http://ejohn.org/blog/traffic-conditions-data/" rel="nofollow noreferrer">"Traffic Conditions Data"</a> article.</p>
|
<p>Google is mum on what source they use for their traffic data. You might contact them directly to see if they want to implement something for you, but my guess is that they'd simply refer you to their provider if they really wanted your data.</p>
<p>Keep in mind that traffic data is available for more than just the metropolitan areas, but Google isn't using it for a variety of reasons - one of the big reasons is that the entire tile set for the traffic overlay in areas with traffic tiles has to be regenerated every 15 minutes or so. It just doesn't scale.</p>
<p>So even if you managed to get your data in their flow, it likely won't be rendered.</p>
<p>-Adam</p>
| 9,258
|
<p>In Ruby, what's the difference between <code>{}</code> and <code>[]</code>?</p>
<p><code>{}</code> seems to be used for both code blocks and hashes.</p>
<p>Are <code>[]</code> only for arrays?</p>
<p>The documention isn't very clear.</p>
|
<p>It depends on the context:</p>
<ol>
<li><p>When on their own, or assigning to a variable, <code>[]</code> creates arrays, and <code>{}</code> creates hashes. e.g.</p>
<pre><code>a = [1,2,3] # an array
b = {1 => 2} # a hash
</code></pre></li>
<li><p><code>[]</code> can be overridden as a custom method, and is generally used to fetch things from hashes (the standard library sets up <code>[]</code> as a method on hashes which is the same as <code>fetch</code>) <br>
There is also a convention that it is used as a class method in the same way you might use a <code>static Create</code> method in C# or Java. e.g.</p>
<pre><code>a = {1 => 2} # create a hash for example
puts a[1] # same as a.fetch(1), will print 2
Hash[1,2,3,4] # this is a custom class method which creates a new hash
</code></pre>
<p>See the Ruby <a href="http://www.ruby-doc.org/core-2.0/Hash.html#method-c-5B-5D" rel="noreferrer">Hash docs</a> for that last example.</p></li>
<li><p>This is probably the most tricky one -
<code>{}</code> is also syntax for blocks, but only when passed to a method OUTSIDE the arguments parens.</p>
<p>When you invoke methods without parens, Ruby looks at where you put the commas to figure out where the arguments end (where the parens would have been, had you typed them)</p>
<pre><code>1.upto(2) { puts 'hello' } # it's a block
1.upto 2 { puts 'hello' } # syntax error, ruby can't figure out where the function args end
1.upto 2, { puts 'hello' } # the comma means "argument", so ruby sees it as a hash - this won't work because puts 'hello' isn't a valid hash
</code></pre></li>
</ol>
|
<p>a few examples:</p>
<pre><code>[1, 2, 3].class
# => Array
[1, 2, 3][1]
# => 2
{ 1 => 2, 3 => 4 }.class
# => Hash
{ 1 => 2, 3 => 4 }[3]
# => 4
{ 1 + 2 }.class
# SyntaxError: compile error, odd number list for Hash
lambda { 1 + 2 }.class
# => Proc
lambda { 1 + 2 }.call
# => 3
</code></pre>
| 3,358
|
<p>I'm creating a small database application to teach myself the following concepts</p>
<ol>
<li>C# programming</li>
<li>.Net 3.5 framework</li>
<li>WPF</li>
<li>LINQ ORM</li>
</ol>
<p>I want to use Microsoft Access as the database but I can't seem to find any mention of whether its possible to use SQLMetal to generate the ORM code from a Microsoft Access database.</p>
<p>Does anyone know if this is possible?</p>
<p>If not, are there any small database or embedded databases I could use? I think SQL express would be overkill for me at this point.</p>
|
<p>For an embedded database, you can use <a href="http://www.microsoft.com/sql/editions/compact/default.mspx" rel="nofollow noreferrer">SQL Server Compact Edition</a>. Unlike SQL Server Express, it is <em>not</em> compatible with the LINQ to SQL designer, but it is fully compatible with the command-line SQLMetal. It has a few advantages over SQL Express, like to ability to use embedded or run from a file. Microsoft has a very handy chart outlining the <a href="http://www.microsoft.com/sql/editions/compact/sscecomparison.mspx" rel="nofollow noreferrer">differences between Express and Compact</a>.</p>
|
<p>Thanks for all the responses. I never expected to get an answer this quick. For my test application I think SQL Server Compact Edition would be the way to go. I'm basically creating a money managment app similar to Microsoft Money and although it is an exercise to learn skills, I would eventually want to use it to manage my finances (provided its not too crap!) </p>
<p>This why I thought a fully blown database would be overkill.</p>
| 4,984
|
<p>The Weblogic servers we are using have been configured to allow JNDI datasource names like "appds".</p>
<p>For development (localhost), we might be running Tomcat and when declared in the <context> section of server.xml, Tomcat will hang JNDI datasources on "java:comp/env/jdbc/*" in the JNDI tree.</p>
<p><strong>Problem:</strong> in Weblogic, the JNDI lookup is "appds" whilst in Tomcat, it seems that that I must provide the formal "java:comp/env/jdbc/appds". I'm afraid the Tomcat version is an implicit standard but unfortunately, I can't change Weblogic's config ... so that means we end up with two different spring config files (we're using spring 2.5) to facilitate the different environments.</p>
<p>Is there an elegant way to address this. Can I look JNDI names up directly in Tomcat? Can Spring take a name and look in both places? Google searches or suggestions would be great.</p>
|
<p><code>JndiLocatorSupport</code> has a property <code>resourceRef</code>. When setting this true, "java:comp/env/" prefix will be prepended automatically. So I believe it would be correct to differentiate this parameter when moving from Tomcat to Weblogic.</p>
|
<p>My application also had a similar problem and this is how I solved it:</p>
<p>1) <code>WEB-INF/classes/application.properties</code> contains the entry:</p>
<pre>
ds.jndi=java:comp/env/jdbc/tcds
</pre>
<p>2) On the WLS machine, I have an entry in the <code>/etc/sysenv</code> file:</p>
<pre>
ds.jndi=wlsds
</pre>
<p>3) I configured spring to lookup the JNDI vis the property <code>${ds.jndi}</code>, using a <code>PropertyPlaceholderConfigurer</code> bean with <code>classpath:application.properties</code> and <code>file:/etc/sysenv</code> as locations. I also set the <code>ignoreResourceNotFound</code> to <code>true</code> so that developers need not have <code>/etc/sysenv</code> on their machines.</p>
<p>4) I run an integration test using Cargo+Jetty and I could not properly set up a JNDI environment there. So I have a fallback <code>BasicDataSource</code> configured too using the <code>defaultObject</code> property of <code>JndiObjectFactoryBean</code>.</p>
| 6,992
|
<p>I know that IList is the interface and List is the concrete type but I still don't know when to use each one. What I'm doing now is if I don't need the Sort or FindAll methods I use the interface. Am I right? Is there a better way to decide when to use the interface or the concrete type?</p>
|
<p>There are two rules I follow:</p>
<ul>
<li>Accept the most basic type that will work</li>
<li>Return the richest type your user will need</li>
</ul>
<p>So when writing a function or method that takes a collection, write it not to take a List, but an IList<T>, an ICollection<T>, or IEnumerable<T>. The generic interfaces will still work even for heterogenous lists because System.Object can be a T too. Doing this will save you headache if you decide to use a Stack or some other data structure further down the road. If all you need to do in the function is foreach through it, IEnumerable<T> is really all you should be asking for.</p>
<p>On the other hand, when returning an object out of a function, you want to give the user the richest possible set of operations without them having to cast around. So in that case, if it's a List<T> internally, return a copy as a List<T>.</p>
|
<p>In situations I usually come across, I rarely use IList directly.</p>
<p>Usually I just use it as an argument to a method </p>
<pre><code>void ProcessArrayData(IList almostAnyTypeOfArray)
{
// Do some stuff with the IList array
}
</code></pre>
<p>This will allow me to do generic processing on almost any array in the .NET framework, unless it uses IEnumerable and not IList, which happens sometimes.</p>
<p>It really comes down to the kind of functionality you need. I'd suggest using the List class in most cases. IList is best for when you need to make a custom array that could have some very specific rules that you'd like to encapsulate within a collection so you don't repeat yourself, but still want .NET to recognize it as a list.</p>
| 3,786
|
<p>I am trying to solve a persistent IO problem when we try to read or write to a Windows 2003 Clustered Fileshare. It is happening regularly and seem to be triggered by traffic. We are writing via .NET's FileStream object.</p>
<p>Basically we are writing from a Windows 2003 Server running IIS to a Windows 2003 file share cluster. When writing to the file share, the IIS server often gets two errors. One is an Application Popup from Windows, the other is a warning from MRxSmb. Both say the same thing:</p>
<blockquote>
<p>[Delayed Write Failed] Windows was unable to save all the data for the file \Device\LanmanRedirector. The data has been lost. This error may be caused by a failure of your computer hardware or network connection. Please try to save this file elswhere.</p>
</blockquote>
<p>On reads, we are also getting errors, which are System.IO.IOException errors: "The specified network name is no longer available."</p>
<p>We have other servers writing more and larger files to this File Share Cluster without an issue. It's only coming from the one group of servers that the issue comes up. So it doesn't seem related to writing large files. We've applied all the hotfixes referenced in articles online dealing with this issue, and yet it continues.</p>
<p>Our network team ran Network Monitor and didn't see any packet loss, from what I understand, but as I wasn't present for that test I can't say that for certain.</p>
<p>Any ideas of where to check? I'm out of avenues to explore or tests to run. I'm guessing the issue is some kind of network problem, but as it's only happening when these servers connect to that File Share cluster, I'm not sure what kind of problem it might be.</p>
<p>This issue is awfully specific, and potentially hardware related, but any help you can give would be of assistance.</p>
<p>Eric Sipple</p>
|
<p>I've heard of <a href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;q138365" rel="nofollow noreferrer">AutoDisconnect</a> causing similar issues (even if the device isn't idle). You may want to try disabling that on the server.</p>
|
<p>I've seen other people reporting the "delayed write failed" error. One recommendation was to adjust the size of the cache, there's a utility from sysinternals (<a href="http://technet.microsoft.com/en-us/sysinternals/bb897561.aspx" rel="nofollow noreferrer">http://technet.microsoft.com/en-us/sysinternals/bb897561.aspx</a>) that will allow you to do that.</p>
| 5,045
|
<p>I build and export my model using ZBrush and as STL files.<br />
To fix the mesh for 3D print, I try to use 3D Builder which can automatically repair my parts.<br />
As it saves as a single file, if I import all parts at once,<br />
I import the files one by one, repair them, then save them as a new file.<br />
After all the parts were repaired, I import all parts to see the result<br />
but find some repaired parts' positions shifted.<br />
How should I handle these issues?</p>
<p><a href="https://i.stack.imgur.com/01xRd.png" rel="nofollow noreferrer" title="Rendering of 3D model with parts shifted from original position"><img src="https://i.stack.imgur.com/01xRd.png" alt="Rendering of 3D model with parts shifted from original position" title="Rendering of 3D model with parts shifted from original position" /></a></p>
|
<p>STL models as exported by software often include their origin in the origin of the design software. However, when using software to fix modeling errors, those origins are not always retained and thus when importing them into a different software their <em>center of mass</em> is taken as the new point of reference.</p>
<p>Slicers are notorious in that they ignore the included origin. Even <em>if</em> models contain an origin that would, when imported into 3D design environments result in the items lining up correctly, the slicing software will simply not care and take a <em>lowest point in the projected center of the object</em> as the coordinate for the item, as this is what is relevant for positioning in the software.</p>
<p>To mitigate that problem, it is best to export models that need to be <em>joined</em> after processing a boolean union on them.</p>
|
<p>It has moved it to the ground as close as it could. This is generally best for 3d printing seperate objects.</p>
<p>If you need them together you can reposition them, or combine them.</p>
<p>Alternatively change the 'Collision' and 'Intersect' settings until you get what you want.</p>
| 2,138
|
<p>Here we go again, the old argument still arises... </p>
<p>Would we better have a business key as a primary key, or would we rather have a surrogate id (i.e. an SQL Server identity) with a unique constraint on the business key field? </p>
<p>Please, provide examples or proof to support your theory.</p>
|
<p>Both. Have your cake and eat it.</p>
<p>Remember there is nothing special about a primary key, except that it is labelled as such. It is nothing more than a NOT NULL UNIQUE constraint, and a table can have more than one.</p>
<p>If you use a surrogate key, you still want a business key to ensure uniqueness according to the business rules.</p>
|
<p>In the case of point in time database it is best to have combination of surrogate and natural keys. e.g. you need to track a member information for a club. Some attributes of a member never change. e.g Date of Birth but name can change.
So create a Member table with a member_id surrogate key and have a column for DOB.
Create another table called person name and have columns for member_id, member_fname, member_lname, date_updated. In this table the natural key would be member_id + date_updated.</p>
| 8,863
|
<p>We used the "undocumented" xp_fileexist stored procedure for years in SQL Server 2000 and had no trouble with it. In 2005, it seems that they modified the behavior slightly to always return a 0 if the executing user account is not a sysadmin. It also seems to return a zero if the SQL Server service is running under the LocalSystem account and you are trying to check a file on the network. </p>
<p>I'd like to get away from xp_fileexist. Does anyone have a better way to check for the existence of a file at a network location from inside of a stored procedure?</p>
|
<p>Maybe a CLR stored procedure is what you are looking for. These are generally used when you need to interact with the system in some way.</p>
|
<p>I still believe that a CLR procedure might be the best bet. So, I'm accepting that answer. However, either I'm not that bright or it's extremely difficult to implement. Our SQL Server service is running under a local account because, according to Mircosoft, that's the only way to get an iSeries linked server working from a 64-bit SQL Server 2005 instance. When we change the SQL Server service to run with a domain account, the xp_fileexist command works fine for files located on the network.</p>
<p>I created this CLR stored procedure and built it with the permission level set to External and signed it:</p>
<pre><code>using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Security.Principal;
public partial class StoredProcedures
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static void FileExists(SqlString fileName, out SqlInt32 returnValue)
{
WindowsImpersonationContext originalContext = null;
try
{
WindowsIdentity callerIdentity = SqlContext.WindowsIdentity;
originalContext = callerIdentity.Impersonate();
if (System.IO.File.Exists(Convert.ToString(fileName)))
{
returnValue = 1;
}
else
{
returnValue = 0;
}
}
catch (Exception)
{
returnValue = -1;
}
finally
{
if (originalContext != null)
{
originalContext.Undo();
}
}
}
}
</code></pre>
<p>Then I ran these TSQL commands:</p>
<pre><code>USE master
GO
CREATE ASYMMETRIC KEY FileUtilitiesKey FROM EXECUTABLE FILE = 'J:\FileUtilities.dll'
CREATE LOGIN CLRLogin FROM ASYMMETRIC KEY FileUtilitiesKey
GRANT EXTERNAL ACCESS ASSEMBLY TO CLRLogin
ALTER DATABASE database SET TRUSTWORTHY ON;
</code></pre>
<p>Then I deployed CLR stored proc to my target database from Visual Studio and used this TSQL to execute from SSMS logged in with windows authentication:</p>
<pre><code>DECLARE @i INT
--EXEC FileExists '\\\\server\\share\\folder\\file.dat', @i OUT
EXEC FileExists 'j:\\file.dat', @i OUT
SELECT @i
</code></pre>
<p>Whether I try a local file or a network file, I always get a 0. I may try again later, but for now, I'm going to try to go down a different road. If anyone has some light to shed, it would be much appreciated.</p>
| 3,735
|
<p>I keep running across this loading image</p>
<p><a href="http://georgia.ubuntuforums.com/images/misc/lightbox_progress.gif" rel="nofollow noreferrer">http://georgia.ubuntuforums.com/images/misc/lightbox_progress.gif</a></p>
<p>which seems to have entered into existence in the last 18 months. All of a sudden it is in every application and is on every web site. Not wanting to be left out is there somewhere I can get this logo, perhaps with a transparent background? Also where did it come from? </p>
|
<p>You can get many different AJAX loading animations in any colour you want here: <a href="http://www.ajaxload.info/" rel="noreferrer">ajaxload.info</a></p>
|
<p>I think it's just a general extension to the normal clock-face style loading icon. The Firefox <a href="http://en.wikipedia.org/wiki/Throbber" rel="nofollow noreferrer">throbber</a> is the first example of that style that I remember coming across; the only real difference between that and the current trend of straight lines is that the constituent symbols have been stretched to give a crisper look, moving back to more of a many-handed clock emblem.</p>
| 7,679
|
<p>I am reading a binary file into a parsing program. I will need to iterate through the file and look for certain markers so I can split the file up and pass those parts into their respective object’s constructors.</p>
<p>Is there an advantage to holding the file as a stream, either MemoryStream or FileStream, or should it be converted into a byte[] array?</p>
<p>Keith</p>
|
<p>A <code>byte[]</code> or <code>MemoryStream</code> will both require bringing the entire file into memory. A <code>MemoryStream</code> is really a wrapper around an underlying byte array. The best approach is to have two <code>FileStream</code> (one for input and one for output). Read from the input stream looking for the pattern used to indicate the file should be separated while writing to the current output file.</p>
<p>You may want to consider wrapping the input and output files in a <code>BinaryReader</code> and <code>BinaryWriter</code> respectively if they add value to your scenario.</p>
|
<p>A MemoryStream is basically a byte array with a stream interface, e.g. sequential reading/writing and the concept of a current position.</p>
| 3,763
|
<p>In python, you can have a function return multiple values. Here's a contrived example:</p>
<pre><code>def divide(x, y):
quotient = x/y
remainder = x % y
return quotient, remainder
(q, r) = divide(22, 7)
</code></pre>
<p>This seems very useful, but it looks like it can also be abused ("Well..function X already computes what we need as an intermediate value. Let's have X return that value also").</p>
<p>When should you draw the line and define a different method? </p>
|
<p>Absolutely (for the example you provided).</p>
<h3>Tuples are first class citizens in Python</h3>
<p>There is a builtin function <a href="https://docs.python.org/3/library/functions.html#divmod" rel="noreferrer"><code>divmod()</code></a> that does exactly that.</p>
<pre><code>q, r = divmod(x, y) # ((x - x%y)/y, x%y) Invariant: div*y + mod == x
</code></pre>
<p>There are other examples: <code>zip</code>, <code>enumerate</code>, <code>dict.items</code>. </p>
<pre><code>for i, e in enumerate([1, 3, 3]):
print "index=%d, element=%s" % (i, e)
# reverse keys and values in a dictionary
d = dict((v, k) for k, v in adict.items()) # or
d = dict(zip(adict.values(), adict.keys()))
</code></pre>
<p>BTW, parentheses are not necessary most of the time.
Citation from <a href="https://docs.python.org/3/library/stdtypes.html?highlight=type%20seq#tuple" rel="noreferrer">Python Library Reference</a>: </p>
<blockquote>
<p>Tuples may be constructed in a number of ways:</p>
<ul>
<li>Using a pair of parentheses to denote the empty tuple: ()</li>
<li>Using a trailing comma for a singleton tuple: a, or (a,)</li>
<li>Separating items with commas: a, b, c or (a, b, c)</li>
<li>Using the tuple() built-in: tuple() or tuple(iterable)</li>
</ul>
</blockquote>
<h3>Functions should serve single purpose</h3>
<p>Therefore they should return a single object. In your case this object is a tuple. Consider tuple as an ad-hoc compound data structure. There are languages where almost every single function returns multiple values (list in Lisp).</p>
<p>Sometimes it is sufficient to return <code>(x, y)</code> instead of <code>Point(x, y)</code>.</p>
<h3>Named tuples</h3>
<p>With the introduction of named tuples in Python 2.6 it is preferable in many cases to return named tuples instead of plain tuples.</p>
<pre><code>>>> import collections
>>> Point = collections.namedtuple('Point', 'x y')
>>> x, y = Point(0, 1)
>>> p = Point(x, y)
>>> x, y, p
(0, 1, Point(x=0, y=1))
>>> p.x, p.y, p[0], p[1]
(0, 1, 0, 1)
>>> for i in p:
... print(i)
...
0
1
</code></pre>
|
<p>It's fine to return multiple values using a tuple for simple functions such as <code>divmod</code>. If it makes the code readable, it's Pythonic.</p>
<p>If the return value starts to become confusing, check whether the function is doing too much and split it if it is. If a big tuple is being used like an object, make it an object. Also, consider using <a href="http://code.activestate.com/recipes/500261/" rel="nofollow noreferrer">named tuples</a>, which will be part of the standard library in Python 2.6.</p>
| 8,682
|
<p>I know PHP scripts don't actually compile until they are run. However, say I want to create a small simple program and compile it to a binary without requiring the PHP binary. How could I do this?</p>
<p>I've seen a few IDE's out there that would do this, but either they are all for windows or the Linux versions don't actually build properly.<br>
What I would like is something like py2exe that does it in the script itself.</p>
|
<p>Check out <a href="https://github.com/pbiggar/phc" rel="nofollow noreferrer">phc: the PHP compiler</a></p>
<p>If you just want to run it like a script, you may not need to compile it per se, but just run it via the command line. <a href="http://www.php.net/features.commandline" rel="nofollow noreferrer">Read running PHP via the command line.</a></p>
|
<p>Have a look at Facebook's <a href="http://github.com/facebook/hiphop-php#readme" rel="nofollow noreferrer">Hiphop-PHP</a>. It's able to convert PHP code into C++ then compile it with g++. Apparently, they've even gotten it to successfully compile entire WordPress installations.</p>
| 7,065
|
<p>What is the best way to find something in a list? I know LINQ has some nice tricks, but let's also get suggestions for C# 2.0. Lets get the best refactorings for this common code pattern.</p>
<p>Currently I use code like this:</p>
<pre><code>// mObjList is a List<MyObject>
MyObject match = null;
foreach (MyObject mo in mObjList)
{
if (Criteria(mo))
{
match = mo;
break;
}
}
</code></pre>
<p>or</p>
<pre><code>// mObjList is a List<MyObject>
bool foundIt = false;
foreach (MyObject mo in mObjList)
{
if (Criteria(mo))
{
foundIt = true;
break;
}
}
</code></pre>
|
<blockquote>
<p>@ Konrad: So how do you use it? Let's say I want to match mo.ID to magicNumber.</p>
</blockquote>
<p>In C# 2.0 you'd write:</p>
<pre><code>result = mObjList.Find(delegate(int x) { return x.ID == magicNumber; });
</code></pre>
<p>3.0 knows lambdas:</p>
<pre><code>result = mObjList.Find(x => x.ID == magicNumber);
</code></pre>
|
<p>Put the code in a method and you save a temporary and a <code>break</code> (and you recycle code, as a bonus):</p>
<pre><code>T Find<T>(IEnumerable<T> items, Predicate<T> p) {
foreach (T item in items)
if (p(item))
return item;
return null;
}
</code></pre>
<p>… but of course this method already exists anyway for Lists, even in .NET 2.0.</p>
| 4,364
|
<p>Do you attach the images? </p>
<p>Use absolute urls? </p>
<p>How do you best avoid getting flagged as spam? </p>
|
<p>One of the biggest causes, that I have found, for email to be flagged as spam is DNS. Make sure the domain / MX records from which you are sending the email actually resolve correctly back from the server used for sending.</p>
<p>As for images, you could attach them, but the most common way is to host them and use absolute urls. Primarily this is a bandwidth issue - you have to figure you're going to get an open rate of 10 - 15%: if you have to attach all the assets to every email, 85% of the bandwidth you'll use will be wasted.</p>
|
<p>Campaign Monitor is a great resources for html email:
<a href="http://www.campaignmonitor.com/resources/#building" rel="nofollow noreferrer">http://www.campaignmonitor.com/resources/#building</a></p>
<p>Also <a href="http://www.email-standards.org/" rel="nofollow noreferrer">http://www.email-standards.org/</a>, but seems down right now.</p>
| 6,631
|
<p>How do I find out whether or not Caps Lock is activated, using VB.NET?</p>
<p>This is a follow-up to my <a href="https://stackoverflow.com/questions/58937/how-do-i-toggle-caps-lock-in-vbnet">earlier question</a>.</p>
|
<p><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.iskeylocked.aspx" rel="noreferrer">Control.IsKeyLocked(Keys) Method - MSDN</a></p>
<pre><code>Imports System
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Public Class CapsLockIndicator
Public Shared Sub Main()
if Control.IsKeyLocked(Keys.CapsLock) Then
MessageBox.Show("The Caps Lock key is ON.")
Else
MessageBox.Show("The Caps Lock key is OFF.")
End If
End Sub 'Main
End Class 'CapsLockIndicator
</code></pre>
<hr>
<p>C# version:</p>
<pre class="lang-cs prettyprint-override"><code>using System;
using System.Windows.Forms;
public class CapsLockIndicator
{
public static void Main()
{
if (Control.IsKeyLocked(Keys.CapsLock)) {
MessageBox.Show("The Caps Lock key is ON.");
}
else {
MessageBox.Show("The Caps Lock key is OFF.");
}
}
}
</code></pre>
|
<p>The solution posted by <a href="https://stackoverflow.com/a/58993/7444103">.rp</a> works, but conflicts with the <code>Me.KeyDown</code> event handler.<br>
I have a sub that calls a sign in function when enter is pressed (shown below).<br>
The <code>My.Computer.Keyboard.CapsLock</code> state works and does not conflict with <code>Me.Keydown</code>.</p>
<pre><code>Private Sub WindowLogin_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
If Keyboard.IsKeyDown(Key.Enter) Then
Call SignIn()
End If
End Sub
</code></pre>
| 8,343
|
<p>Looking to print a new part for a home appliance. There's going to need to be a new model created with the customizations made, but the model (after printing) will have to fit where the old part was. Is there any 3D modeling software that is better for this purpose? Will I just have to guess at proper proportions and hand-adjust the scaling of each dimension and angle through trial and error until a version fits?</p>
|
<p>Here's a brief outline I threw out in chat once. I'm marking this as a "community Wiki" answer so feel free to edit.</p>
<p>It is not a full Primer, so should date better than a Word6.0 manual.</p>
<hr />
<p>Start by reading the instructions that came with your printer. There's a high chance that some assembly is required, and if you get something wrong then things may nor work right later. Some brands come complete, some are better than others in this regard. Take your time.</p>
<p>For most people, they spend the first couple of weeks failing prints for multiple reasons. For me it was bed levelling and getting the first layer-adhesion, and filament tension.</p>
<p>So work on getting the bed levelled, work out how much gluestick or tape your filament needs to work, and what temperatures work in your environment.</p>
<p>I use 210 °C on the hotend for PLA+ and 60 °C bed temp, though others get away with 190 °C on the hotend and 50 °C on the bed. My printer is in a garage though.</p>
<p>Try and print a 20 mm cube or a benchy.</p>
<p>After that, explore <a href="http://thingiverse.com" rel="nofollow noreferrer">http://thingiverse.com</a> or <a href="http://thangs.com" rel="nofollow noreferrer">http://thangs.com</a> looking for pre-made stuff that you would benefit from. Start small.</p>
<p>The Grab Toy Infinite is a great starter - it's very forgiving about tolerances, and kids like it. Expect rough handling to break it.</p>
<p>When you're happy printing other people's things, identify some needs of your own. In fact, make up a document / draught email / notepad of ideas of things to print. I add stuff to mine all the time.</p>
<p>When you've got a need that no one else can fill, you can start designing your own item and do the whole</p>
<pre><code>idea --> ||: (re)design --> implement --> test --> curse :|| success!! loop.
</code></pre>
<p>Many people bang on about expensive fancy software, but you can make a perfectly adequate part using <a href="http://tinkercad.com/" rel="nofollow noreferrer">http://tinkercad.com/</a> as a grounding.</p>
<p>For example, I had too many spare hacksaw blades and none of the "holders" I could buy were perfect, nor even close. Here's my output:</p>
<p><a href="https://www.tinkercad.com/things/9yQMmxRv4Lz-spare-hacksaw-blade-holder" rel="nofollow noreferrer">https://www.tinkercad.com/things/9yQMmxRv4Lz-spare-hacksaw-blade-holder</a></p>
<p>Like many things in making, expect to fail and learn and do it again.</p>
<p>Sometimes it looks like we buy printers to print things for the printers for printing things for the printers...repeat.</p>
<p>Look for needs in your life and design something to fill them. It's most satisfying.</p>
<p>There's a huge gap between Functional prints, which do a job, and pretty prints which are just to look nice.</p>
<p>Functional things are great - you can therefore justify the cost of more printer upgrades. LOOK AT ALL THE MONEY WE SAVED!</p>
<p>But overall enjoy yourself and the time you spend making things.</p>
|
<p>Thera are plenty of such guides. But from necessity they deal with specifics, there are too many things to cover otherwise.</p>
<p>Multiple types of printers, multiple brands, multiple slicers, multiple ways of modelling etc,. With more all the time. Reading up on something that tells me how to model and slice in Freecad & Creality, when I'm using Blender & Cura is a waste of time.</p>
<p>Generic instructions that apply to everything are so vague as to be essentially useless. (Plenty of those online though)</p>
| 2,144
|
<p>I'm planning on creating a social networking + MP3 lecture downloading / browsing / commenting / discovery website using Ruby on Rails. Partially for fun and also as a means to learn some Ruby on Rails. I'm looking for a social networking framework that I can use as a basis for my site. I don't want to re-invent the wheel. </p>
<p>Searching the web I found three such frameworks. Which of these three would you recommend using and why?</p>
<p><a href="http://portal.insoshi.com/" rel="nofollow noreferrer">http://portal.insoshi.com/</a></p>
<p><a href="http://www.communityengine.org/" rel="nofollow noreferrer">http://www.communityengine.org/</a></p>
<p><a href="http://lovdbyless.com/" rel="nofollow noreferrer">http://lovdbyless.com/</a></p>
|
<p>It depends what your priorities are.</p>
<p>If you really want to learn RoR, <strong>do it all from scratch</strong>. Seriously. Roll your own. It's the best way to learn, far better than hacking through someone else's code. If you do that, sometimes you'll be learning Rails, but sometimes you'll just be learning that specific social network framework. And <strong>you won't know which is which...</strong></p>
<p>The type of site you're suggesting sounds perfect for a Rails project. If you get stuck, <strong>then</strong> go browse the repositories of these frameworks. Who cares if you're reinventing the wheel? It's your site, your vision, your rules.</p>
<p>If you just want a site up and running, then I would pick Insoshi or LovdbyLess simply because they're out of the box apps so you'll have to do less to do get running. I suggest trying to install them both, and introducing yourself in the Google Groups. That'll give you a good indication of wether you're going to get along.</p>
|
<p>One other positive to Community Engine is that it is using <a href="http://rails-engines.org/" rel="nofollow noreferrer">Engines</a> which is an advanced type of plugin that <a href="http://weblog.rubyonrails.org/2009/2/1/rails-2-3-0-rc1-templates-engines-rack-metal-much-more" rel="nofollow noreferrer">is becoming a part of rails in 2.3</a>. So what you learn from using Community Engine (and therefore Engines) will be useful going forward.</p>
| 7,073
|
<p>We have an application that has to be flexible in how it displays it's main form to the user - depending on the user, the form should be slightly different, maybe an extra button here or there, or some other nuance. In order to stop writing code to explicitly remove or add controls etc, I turned to visual inheritance to solve the problem - in what I thought was a neat, clean and logical OO style - turns out that half the time inherited forms have a hard time rendering themeselves in VS for no good reason etc - and I get the feeling that developers and to some extent Microsoft have shunned the practice of Visual Inheritance - can you confirm this, am I missing something here?</p>
<p>Regards.</p>
|
<p>I thought they had more or less sorted the desktop designer issues in 2005.
Have you tried the usual culprits?</p>
<ul>
<li>No abstract control types</li>
<li>No constructor arguments in any form</li>
<li>Initialisation moved to Form_Load as opposed to the Ctor</li>
<li>No controls in the same project as the usercontrol/form that they are put inside</li>
<li>Close all documents -> Clean -> Rebuild</li>
<li>Restart VS</li>
</ul>
<p>I seemed to think that as long as you did all of the above it worked..... mostly.</p>
|
<p>Read this: <a href="http://cs.rthand.com/blogs/blog_with_righthand/archive/2005/11/10/186.aspx" rel="nofollow noreferrer">http://cs.rthand.com/blogs/blog_with_righthand/archive/2005/11/10/186.aspx</a></p>
<p>AFAIK, there are still issues with Visual Inheritance and objects that rely on collections for the design elements, typically grid controls etc. I believe MS still have removed the possibility of changing f.ex. a GridView in an inherited form/usercontrol etc. But other controls like TextBox, Form, UserControl, Panel etc. should work as expected.</p>
<p>I've so far had no problem with VI using 3rd party grid controls myself, but you have to be careful, in particular, removing items from collections MUST be avoided.</p>
| 7,204
|
<p>We have <a href="https://3dprinting.stackexchange.com/questions/1117/alternative-3d-molding-techniques-at-home">a recent question</a> that brings up the question of "<em>Should we support general hobbyist questions?</em>"</p>
<p>Currently, there doesn't appear to be a viable site within the SE network. The question at hand seems to be a mix between 3D Printing and DIY. If we allow this question, it could allow people to ask questions like the following:</p>
<ul>
<li>CNC Mills</li>
<li>Routers</li>
<li>Lasers</li>
<li>etc.</li>
</ul>
|
<p><s>There is a <a href="https://3dprinting.meta.stackexchange.com/questions/138/what-is-our-scope">new question on Meta</a> that should help define what is okay on this site.
</s></p>
<p>However, your question is important to address here.</p>
<p>Ultimately, you shouldn't be afraid to go ahead and ask the question. If the question does not meet the conditions of the present site, the general public will be sure to let you know and (hopefully) help direct you in at least asking a more direct question.</p>
<p>If you post a question that is closed, it would acceptable to post a question here on Meta that specifically asks how to make your question fit within the scope of the site.</p>
<p>I would suggest providing as much information as you have and feel free to ask the more general questions about 3D printing. Most people in the community will ask specific questions to try and help you. Some may even be able to fill in the blanks of what you're asking and provide you with very helpful answers.</p>
|
<p>I think your situation fits for many new users on this site, and saying that "easy" or "semi-defined" questions are discouraged would probably turn you - and many others - away from the site.</p>
<p>Rather, I believe it is the community's job to help you find a proper scope for your question. As long as you follow it up, edit and improve your questions according to feedback (as we all should), I'm pretty sure even the "easiest" question will turn out good.</p>
<p>In other words: ask anyway and stay open to (or even better, request) feedback to help define your question better. </p>
| 28
|
<p>I need to find out time taken by a function in my application. Application is a MS VIsual Studio 2005 solution, all C code. </p>
<p>I used thw windows API GetLocalTime(SYSTEMTIME *) to get the current system time before and after the function call which I want to measure time of.
But this has shortcoming that it lowest resolution is only 1msec. Nothing below that. So I cannot get any time granularity in micro seconds. </p>
<p>I know that time() which gives the time elapsed since the epoch time, also has resolution of 1msec (No microseconds) </p>
<p>1.) Is there any other Windows API which gives time in microseconds which I can use to measure the time consumed by my function?</p>
<p>-AD</p>
|
<p>There are some other possibilities.</p>
<h2>QueryPerformanceCounter and QueryPerformanceFrequency</h2>
<p><a href="http://msdn.microsoft.com/en-us/library/ms644904.aspx" rel="noreferrer">QueryPerformanceCounter</a> will return a "performance counter" which is actually a CPU-managed 64-bit counter that increments from 0 starting with the computer power-on. The frequency of this counter is returned by the <a href="http://msdn.microsoft.com/en-us/library/ms644905.aspx" rel="noreferrer">QueryPerformanceFrequency</a>. To get the time reference in <strong>seconds</strong>, divide performance counter by performance frequency. In Delphi: </p>
<pre><code>function QueryPerfCounterAsUS: int64;
begin
if QueryPerformanceCounter(Result) and
QueryPerformanceFrequency(perfFreq)
then
Result := Round(Result / perfFreq * 1000000);
else
Result := 0;
end;
</code></pre>
<p>On multiprocessor platforms, QueryPerformanceCounter <strong>should</strong> return consistent results regardless of the CPU the thread is currently running on. There are occasional problems, though, usually caused by bugs in hardware chips or BIOSes. Usually, patches are provided by motherboard manufacturers. Two examples from the MSDN:</p>
<ul>
<li><a href="http://support.microsoft.com/kb/895980" rel="noreferrer">Programs that use the QueryPerformanceCounter function may perform poorly in Windows Server 2003 and in Windows XP</a></li>
<li><a href="http://support.microsoft.com/kb/274323" rel="noreferrer">Performance counter value may unexpectedly leap forward</a></li>
</ul>
<p>Another problem with QueryPerformanceCounter is that it is quite slow.</p>
<h2>RDTSC instruction</h2>
<p>If you can limit your code to one CPU (SetThreadAffinity), you can use <a href="http://en.wikipedia.org/wiki/RDTSC" rel="noreferrer">RDTSC</a> assembler instruction to query performance counter directly from the processor.</p>
<pre><code>function CPUGetTick: int64;
asm
dw 310Fh // rdtsc
end;
</code></pre>
<p>RDTSC result is incremented with same frequency as QueryPerformanceCounter. Divide it by QueryPerformanceFrequency to get time in seconds.</p>
<p>QueryPerformanceCounter is much slower thatn RDTSC because it must take into account multiple CPUs and CPUs with variable frequency. From <a href="http://blogs.msdn.com/oldnewthing/archive/2008/09/08/8931563.aspx" rel="noreferrer">Raymon Chen's blog</a>:</p>
<blockquote>
<p>(QueryPerformanceCounter) counts elapsed time. It has to, since its value is
governed by the QueryPerformanceFrequency function, which returns a number
specifying the number of units per second, and the frequency is spec'd as not
changing while the system is running. </p>
<p>For CPUs that can run at variable speed, this means that the HAL cannot
use an instruction like RDTSC, since that does not correlate with elapsed time. </p>
</blockquote>
<h2>timeGetTime</h2>
<p><a href="http://msdn.microsoft.com/en-us/library/ms713418.aspx" rel="noreferrer">TimeGetTime</a> belongs to the Win32 multimedia Win32 functions. It returns time in milliseconds with 1 ms resolution, at least on a modern hardware. It doesn't hurt if you run timeBeginPeriod(1) before you start measuring time and timeEndPeriod(1) when you're done.</p>
<h2>GetLocalTime and GetSystemTime</h2>
<p>Before Vista, both <a href="http://msdn.microsoft.com/en-us/library/ms713418.aspx" rel="noreferrer">GetLocalTime</a> and <a href="http://msdn.microsoft.com/en-us/library/ms724390.aspx" rel="noreferrer">GetSystemTime</a> return current time with millisecond precision, but they are not accurate to a millisecond. Their accuracy is typically in the range of 10 to 55 milliseconds. (<a href="http://blogs.msdn.com/oldnewthing/archive/2005/09/02/459952.aspx" rel="noreferrer">Precision is not the same as accuracy</a>)
On Vista, GetLocalTime and GetSystemTime both work with 1 ms resolution.</p>
|
<p>On Windows you can use the 'high performance counter API'. Check out: <a href="http://msdn.microsoft.com/en-us/library/ms644904(VS.85).aspx" rel="nofollow noreferrer">QueryPerformanceCounter</a> and <a href="http://msdn.microsoft.com/en-us/library/ms644905(VS.85).aspx" rel="nofollow noreferrer">QueryPerformanceCounterFrequency</a> for the details.</p>
| 7,231
|
<p>I'm using a winforms webbrowser control to display some content in a windows forms app. I'm using the DocumentText property to write the generated HTML. That part is working spectacularly. Now I want to use some images in the markup. (I also would prefer to use linked CSS and JavaScript, however, that can be worked around by just embedding it.)</p>
<p>I have been googling over the course of several days and can't seem to find an answer to the title question. </p>
<p>I tried using a relative reference: the app exe is in the bin\debug. The images live in the "Images" directory at the root of the project. I've set the images to be copied to the output directory on compile, so they end up in bin\debug\Images*. So I then use a reference like this "Images..." thinking it will be relative to the exe. However, when I look at the image properties in the embedded browser window, I see the image URL to be "about:blankImages/*". Everything seems to be relative to "about:blank" when HTML is written to the control. Lacking a location context, I can't figure out what to use for a relative file resource reference.</p>
<p>I poked around the properties of the control to see if there is a way to set something to fix this. I created a blank html page, and pointed the browser at it using the "Navigate()" method, using the full local path to the file. This worked fine with the browser reporting the local "file:///..." path to the blank page. Then I again wrote to the browser, this time using Document.Write(). Again, the browser now reports "about:blank" as the URL.</p>
<p>Short of writing the dynamic HTML results to a real file, is there no other way to reference a file resource?</p>
<p>I am going to try one last thing: constructing absolute file paths to the images and writing those to the HTML. My HTML is being generated using an XSL transform of a serialized object's XML so I'll need to play with some XSL parameters which will take a little extra time as I'm not that familiar with them.</p>
|
<p>Here's what we do, although I should mention that we use a custom web browser to remove such things as the ability to right-click and see the good old IE context menu:</p>
<pre><code>public class HtmlFormatter
{
/// <summary>
/// Indicator that this is a URI referencing the local
/// file path.
/// </summary>
public static readonly string FILE_URL_PREFIX =
"file://";
/// <summary>
/// The path separator for HTML paths.
/// </summary>
public const string PATH_SEPARATOR = "/";
}
// We need to add the proper paths to each image source
// designation that match where they are being placed on disk.
String html = HtmlFormatter.ReplaceImagePath(
myHtml,
HtmlFormatter.FILE_URL_PREFIX + ApplicationPath.FullAppPath +
HtmlFormatter.PATH_SEPARATOR);
</code></pre>
<p>Basically, you need to have an image path that has a file URI, e.g. </p>
<pre><code><img src="file://ApplicationPath/images/myImage.gif">
</code></pre>
|
<p>I ended up using something that's basically the same as what Ken suggested. However, instead of manually appending the file prefix, I used the UriBuilder class to build the complete URI with the "file" protocol.</p>
<p>This also solved a subsequent problem when we tested the app in a more realistic location, Program Files. The spaces was encoded, but the OS couldn't deal with the encoded characters when the file was referenced using a standard system path (i.e. "C:\Program%20Files..."). Using the true URI value (file:///C:/Program Files/...) worked.</p>
| 9,767
|
<p>Are there any conflicts with having any combination of Visual Studio 2003, 2005 and/or 2008 installed? I noticed a related question <a href="https://stackoverflow.com/questions/9693/visual-studio-2005-macros-stop-working-when-visual-studio-2008-is-installed">here</a> but wanted a more general answer.</p>
|
<p>6, 2000/2001 (I can't remember which is .net 1.0), 2003, 2005, 2008... of course within .NET you may have issues with getting the right solution with the right version. I haven't really seen any conflicts in particular.</p>
|
<p>I've got 2005 and 2008 installed concurrently.</p>
<p>2008 is a superset of 2005, so I have no reason whatsoever to have them both, I just haven't gotten around to un-installing it yet</p>
| 4,892
|
<p>any idea how if the following is possible in PHP as a single line ?:</p>
<pre><code><?php
$firstElement = functionThatReturnsAnArray()[0];
</code></pre>
<p>... It doesn't seem to 'take'. I need to do this as a 2-stepper:</p>
<pre><code><?php
$allElements = functionThatReturnsAnArray();
$firstElement = $allElements[0];
</code></pre>
<p>... just curious - other languages I play with allow things like this, and I'm lazy enoug to miss this in PHP ... any insight appreciated ...</p>
|
<p>Try:</p>
<pre><code><?php
$firstElement = reset(functionThatReturnsAnArray());
</code></pre>
<p>If you're just looking for the first element of the array.</p>
|
<p>As far as I know this is not possible, I have wanted to do this myself several times.</p>
| 9,427
|
<p>I have a model that's placed on the bed exactly like on this picture:</p>
<p><a href="https://i.stack.imgur.com/hDTcF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hDTcF.png" alt="sample model placement" /></a></p>
<p>I have constant quality degradation as the bed moves down to print in the upper left corner <strong>(1)</strong>.</p>
<p>Everything is fine on the X <strong>(2)-(3)</strong> side. It does not have any visible artifacts. All hell goes along the <strong>(1)-(3)</strong> curve:</p>
<p><a href="https://i.imgur.com/EvgyKFi.png" rel="nofollow noreferrer"><img src="https://i.imgur.com/EvgyKFi.png" alt="hell lines" /></a></p>
<p>Top left corner <strong>(1)</strong>:</p>
<p><a href="https://i.imgur.com/LKxVVx0.jpg" rel="nofollow noreferrer"><img src="https://i.imgur.com/LKxVVx0.jpg" alt="top left corner" /></a></p>
<p>On the way from <strong>(1)</strong> to <strong>(2)</strong> lines seem to disappear almost completely.</p>
<p>I used Cura slicer and these printing settings:</p>
<ul>
<li>stock ender firmware</li>
<li>0.2 mm layer height</li>
<li>supports</li>
<li>2 bottom & top layers</li>
<li>PETG 235 °C nozzle</li>
<li>80 °C bed</li>
<li>walls x2</li>
<li>10 % infill gyroid</li>
<li>ironing</li>
<li>seam smart hiding</li>
<li>50 mm/s print speed</li>
<li>500 / 50 mm/s^2 acceleration / jerks</li>
</ul>
<p>It looks like a mechanical issue, so I tried tightening/untightening bed bolts. It didn't help. They are a little bit tight, but not too much. The bed does not seem to be wobbling. Also, I tried the bed for wobbling in its top/bottom position. It looks fine along all the way.</p>
<p>What should I try next?</p>
<p>Extruder steps/mm are tweaked for this filament. Extruder produces exactly 97 mm of 100 mm of filament.</p>
<h3>UPD</h3>
<p>I decided to change my software/hardware settings step by step. This time I changed only my software settings to these:</p>
<ul>
<li>Speed: 30 mm/s</li>
<li>Acceleration: 3000 mm/s^2</li>
<li>Retract: 4 mm</li>
<li>Combing: Not in Skin (previous print had the same value)</li>
<li>Overhanging wall speed 100% (same as the previous print)</li>
</ul>
<p>Corners have become much sharper and there is a lot less of bulging on the arc.</p>
<p><a href="https://i.imgur.com/gFVt0SO.jpg" rel="nofollow noreferrer"><img src="https://i.imgur.com/gFVt0SO.jpg" alt="arc" /></a></p>
<p>However, by X-axis <strong>(2) - (3)</strong> I see more artifacts:</p>
<p><a href="https://i.imgur.com/uoC7gmX.jpg" rel="nofollow noreferrer"><img src="https://i.imgur.com/uoC7gmX.jpg" alt="x-axis bottom" /></a></p>
<p>Y-axis has become better:</p>
<p><a href="https://i.imgur.com/Ip88dJf.jpg" rel="nofollow noreferrer"><img src="https://i.imgur.com/Ip88dJf.jpg" alt="y-axis bottom" /></a></p>
<p>Currently, I don't have any visible or sensible bed / X play. I tuned rollers to have enough tension not to slip if rotate them separately. So, if I rotate the roller, it moves the whole bed or X carriage. I'll try increasing the tension a little bit and then I'll share the result.</p>
<h3>UPD2</h3>
<p>I've made belts a little bit tighter and decided to print a new model. The layer height is 0.3 mm. Also, I tried increasing temperature up to <strong>240 °C</strong> and changed the stock vent with a circular vent. The wall count is 50 to make the model solid. Coasting is off.</p>
<p><a href="https://i.imgur.com/M0eq3KO.jpg" rel="nofollow noreferrer"><img src="https://i.imgur.com/M0eq3KO.jpg" alt="x-axis" /></a></p>
<p><a href="https://i.imgur.com/CyTwQOG.jpg" rel="nofollow noreferrer"><img src="https://i.imgur.com/CyTwQOG.jpg" alt="x-axis curve" /></a></p>
<p>Now all artifacts are along the X-axis. There are many fewer of them at (1) than at (2). The model is a doorstep. On the build plate it's placed like this:</p>
<p><a href="https://i.imgur.com/kBHlGtN.png" rel="nofollow noreferrer"><img src="https://i.imgur.com/kBHlGtN.png" alt="doorstep build plate placement" /></a></p>
<p>Now I think the problem has nothing to do with X/Y play and these two factors can be eliminated. I'll revert belt tensions back to their previous values and decrease the printing temperature down to 225-230 °C.</p>
<p>PS. USBASP is still in customs, so I'm doing all this on the stock firmware.</p>
<h3>UPD3</h3>
<p>I have finally figured out what was wrong. It was insufficient Z-belt tension on both sides. A close look at a DSLR camera shot gave me a clue: there was almost always a straight segment followed by a visible additional step down between layers.</p>
<p>There are still some artifacts but everything looks relatively tolerable now.</p>
<p><a href="https://i.imgur.com/xgrauz5.jpg" rel="nofollow noreferrer"><img src="https://i.imgur.com/xgrauz5.jpg" alt="after z-axis has been fixed" /></a></p>
<p>Thanks to all of you guys!</p>
|
<p>I think this is resolved. After looking at every conceivable source of over-extrusion and coming up negative, <code>R.. GitHub STOP HELPING ICE</code> suggested that it might be a mechanical problem in Z axis movement, like in <a href="https://3dprinting.stackexchange.com/questions/8022/first-3-mm-prints-poorly-then-fine-after-that">this question</a>.</p>
<p>I checked by leveling the bed and zeroing the Z axis at 0.05 mm above the bed, using a feeler gauge. I gave it the instruction to move the Z axis up by 0.2 mm (to simulate a single layer), then checked it with a 0.25 mm feeler gauge. It did not fit. I raised it .01 mm at a time, and I was not able to insert the gauge until it hit 0.5 mm!</p>
<p>I printed a 20 mm test cube and measured the Z height:
<a href="https://i.stack.imgur.com/4Lvq2.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/4Lvq2.jpg" alt="Initial 20 mm test cube" /></a></p>
<p>At 19.58 mm, it was short. Only a little bit though, which is consistent with Z problems only occurring in the first few layers for some reason.</p>
<p>Based on the advice in the other question, I fiddled with the eccentric nuts on the left and right side of X axis gantry, adjusting them to be tight enough that turning the wheels moves the gantry up and down, but loose enough that I can still turn the wheels if I hold the gantry in place.</p>
<p>I checked again with the feeler gauge, and this time the 0.25 mm gauge fit just fine at 0.2 mm. Cool! I printed another test cube and measured:</p>
<p><a href="https://i.stack.imgur.com/Yq2zW.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Yq2zW.jpg" alt="Revised 20 mm test cube" /></a></p>
<p>OK, at 20.06 mm it's not perfect, but it's a lot better. I printed the hinges again:</p>
<p><a href="https://i.stack.imgur.com/Q4MYZ.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Q4MYZ.jpg" alt="Hinges" /></a></p>
<p>Again not perfect, but so much better. And the specific problem of uncontrollable expansion in the 2nd and 3rd layers is totally gone.</p>
|
<p>I had the same problem with my Ender-3 V2.</p>
<p>You need to check if the feeder bracket is square like explained in <a href="https://www.youtube.com/watch?v=xnzNd_FIMKY" rel="nofollow noreferrer">this YouTube</a></p>
<p>If that is not the problem maybe you need a custom bracket to change the spacing between the Z-motor and the frame like <a href="https://www.thingiverse.com/thing:2752080" rel="nofollow noreferrer">this</a>, <a href="https://www.thingiverse.com/thing:4699747" rel="nofollow noreferrer">this</a> or <a href="https://www.thingiverse.com/thing:4723087" rel="nofollow noreferrer">this</a></p>
<p>I have improved mine a lot using:</p>
<ul>
<li><a href="https://www.thingiverse.com/thing:2752080" rel="nofollow noreferrer">This Z-motor mount</a></li>
<li>Using <a href="https://www.amazon.com/s?k=Elmer%E2%80%99s+Disappearing+Purple+Glue+Stick" rel="nofollow noreferrer">glue stick</a> instead of squeezing the first layer</li>
<li><a href="https://www.youtube.com/watch?v=rDm9OziZ6dY" rel="nofollow noreferrer">Leveling the bed using a feeler gauge</a> instead of a piece of paper</li>
<li>Initial fan speed 100 %, all layers the same</li>
<li>Same flow rate, line width, line height on all layers</li>
<li>Build plate 40 °C, nozzle 205 °C</li>
<li>Seam Corner Preference: Hide or Expose Seam</li>
</ul>
| 1,695
|
<p>I apologize for asking such a generalized question, but it's something that can prove challenging for me. My team is about to embark on a large project that will hopefully drag together all of the random one-off codebases that have evolved through the years. Given that this project will cover standardizing logical entities across the company ("Customer", "Employee"), small tasks, large tasks that control the small tasks, and utility services, I'm struggling to figure out the best way to structure the namespaces and code structure.</p>
<p>Though I guess I'm not giving you enough specifics to go on, <strong>do you have any resources or advice on how to approach splitting your domains up logically</strong>? In case it helps, most of this functionality will be revealed via web services, and we're a <strong>Microsoft</strong> shop with all the latest gizmos and gadgets.</p>
<ul>
<li>I'm debating one massive solution with subprojects to make references easier, but will that make it too unwieldy? </li>
<li>Should I wrap up legacy application functionality, or leave that completely agnostic in the namespace (making an <code>OurCRMProduct.Customer</code> class versus a generic <code>Customer</code> class, for instance)? </li>
<li>Should each service/project have its own <code>BAL</code> and <code>DAL</code>, or should that be an entirely separate assembly that everything references? </li>
</ul>
<p>I don't have experience with organizing such far-reaching projects, only one-offs, so I'm looking for any guidance I can get.</p>
|
<p>There's a million ways to skin a cat. However, the simplest one is always the best. Which way is the simplest for you? Depends on your requirements. But there are some general rules of thumb I follow.</p>
<p>First, reduce the overall number of projects as much as possible. When you compile twenty times a day, that extra minute adds up. </p>
<p>If your app is designed for extensibility, consider splitting your assemblies along the lines of design vs. implementation. Place your interfaces and base classes in a public assembly. Create an assembly for your company's implementations of these classes. </p>
<p>For large applications, keep your UI logic and business logic separate. </p>
<p>SIMPLIFY your solution. If it looks too complex, it probably is. Combine, reduce.</p>
|
<p>Large solutions with lots of projects can be quite slow to compile, but are easier to manage together.</p>
<p>I often have Unit test assemblies in the same solution as the ones they're testing, as you tend to make changes to them together.</p>
| 3,329
|
<p>I plan to be storing all my config settings in my application's app.config section (using the <code>ConfigurationManager.AppSettings</code> class). As the user changes settings using the app's UI (clicking checkboxes, choosing radio buttons, etc.), I plan to be writing those changes out to the <code>AppSettings</code>. At the same time, while the program is running I plan to be accessing the <code>AppSettings</code> constantly from a process that will be constantly processing data. Changes to settings via the UI need to affect the data processing in real-time, which is why the process will be accessing the <code>AppSettings</code> constantly.</p>
<p>Is this a good idea with regard to performance? Using <code>AppSettings</code> is supposed to be "the right way" to store and access configuration settings when writing .Net apps, but I worry that this method wasn't intended for a constant load (at least in terms of settings being constantly read).</p>
<p>If anyone has experience with this, I would greatly appreciate the input.</p>
<p><strong>Update:</strong> I should probably clarify a few points.</p>
<p>This is not a web application, so connecting a database to the application might be overkill simply for storing configuration settings. This is a Windows Forms application.</p>
<p>According to the MSDN documention, the <code>ConfigurationManager</code> is for storing not just application level settings, but user settings as well. (Especially important if, for instance, the application is installed as a partial-trust application.)</p>
<p><strong>Update 2:</strong> I accepted lomaxx's answer because <code>Properties</code> does indeed look like a good solution, without having to add any additional layers to my application (such as a database). When using Properties, it already does all the caching that others suggested. This means any changes and subsequent reads are all done in memory, making it extremely fast. Properties only writes the changes to disk when you explicitly tell it to. This means I can make changes to the config settings on-the-fly at run time and then only do a final save out to disk when the program exits.</p>
<p>Just to verify it would actually be able to handle the load I need, I did some testing on my laptop and was able to do 750,000 reads and 7,500 writes per second using Properties. That is so far above and beyond what my application will <em>ever</em> even come close to needing that I feel quite safe in using Properties without impacting performance.</p>
|
<p>since you're using a winforms app, if it's in .net 2.0 there's actually a user settings system (called Properties) that is designed for this purpose. <a href="https://learn.microsoft.com/en-us/previous-versions/aa730869%28v=vs.80%29" rel="nofollow noreferrer">This article on MSDN</a> has a pretty good introduction into this</p>
<p>If you're still worried about performance then take a look at <a href="https://web.archive.org/web/20080918011815/http://www.microsoft.com:80/sql/editions/compact/default.mspx" rel="nofollow noreferrer">SQL Compact Edition</a> which is similar to SQLite but is the Microsoft offering which I've found plays very nicely with winforms and there's even the ability to <a href="https://web.archive.org/web/20181015183404/http://geekswithblogs.net:80/steveclements/archive/2007/11/13/linq-to-sql.compact.aspx" rel="nofollow noreferrer">make it work with Linq</a></p>
|
<p>Could I ask why you're not saving the user's settings in a database?</p>
<p>Generally, I save application settings that are changed very infrequently in the appSettings section (the default email address error logs are sent to, the number of minutes after which you are automatically logged out, etc.) The scope of this really is at the application, not at the user, and is generally used for deployment settings.</p>
| 2,615
|
<p>On 16 September 2020, Autodesk announced changes in the way that Fusion 360 can be used for non-commercial use with their Personal license. As a hobbyist, most of these changes will not affect me very much, since I do not use Fusion 360's advanced features. The most irksome will be only being allowed to have up to ten "documents" active at any one time, the rest having to be archived.</p>
<p>However, Autodesk are also restricting the number of file formats that you can export to. For example, the STEP file format will no longer be available with the Personal license. Will this mean that I will not be able to move my models to another CAD package, such as FreeCAD, once the changes come into effect (without first buying a commercial license)?</p>
<p><a href="https://knowledge.autodesk.com/support/fusion-360/learn-explore/caas/sfdcarticles/sfdcarticles/Fusion-360-Free-License-Changes.html" rel="nofollow noreferrer">Autodesk: Changes to Fusion 360 for personal use</a></p>
<p><strong>Edit: Good news. Autodesk have announced, on 25 September 2020, that the facility to export models to STEP files will be retained for the free-to-use, personal license.</strong></p>
|
<p>Most of my answer is based off of what Autodesk has said and <a href="https://www.youtube.com/watch?v=SlnEThQ4HR8" rel="nofollow noreferrer">this video</a> from Maker's Muse, which explains this topic in much more detail.</p>
<p>In summary, Autodesk is planning on restricting your ability to export any parametric file formats like .STEP or .IGES, leaving no useful CAD-specific files available for users with personal licenses.</p>
<p>I would recommend exporting everything you want to keep as .STEP right now just in case you do decide to switch programs later on, because you won't be able to switch after the changes go into effect.</p>
<p>I hope that helps.</p>
<p>EDIT: As Oscar has pointed out, .STEP exporting is now also part of the general consumer's license, and you can export to other CAD packages at any time. As far as I can tell, other parametric formats, notably .IGES, is still not available for consumers. This shouldn't pose too much of a problem.</p>
<p>I'm going to leave my original post intact for now.</p>
|
<h1>If you use the private license: there was supposed to be a cutoff date.</h1>
<p>As long as you use the "private" license, you will get some restrictions. Originally, including the lock off of <code>.step</code> and similar files as well as limiting you to 10 active projects. This means, that you will need to deactivate some to make room for new ones, but unless you have many interlocking parts, 10 can be quite a lot for a hobbyist.</p>
<p>They also lock off features that are pretty much only useful for small companies - and if you are in the shoes missing those features, you are on the wrong free license anyway.</p>
<p>In late (<a href="https://www.autodesk.com/products/fusion-360/blog/changes-to-fusion-360-for-personal-use/" rel="nofollow noreferrer">25<sup>th</sup></a>.) September 2020, the lock of <code>.step</code> was reversed, but other formats will still no longer be available.</p>
<h1>This does not apply to all free licenses</h1>
<p>Note that this does not apply to the free education license for teachers and students or the free business license for sub 100,000 \$ companies. You might want to consider swapping to either of these two plans if you qualify.</p>
<h1>Last words</h1>
<p>I agree with <a href="https://www.youtube.com/watch?v=t4CqWWQXaPE&t=0s" rel="nofollow noreferrer">Thomas Sanladerer:</a> Autodesk is under no obligation to offer a free version at all and even a somewhat restricted, locked into the Autodesk-world version is much better than nothing. I will keep using it, but I am also in the education space and thus not directly affected.</p>
| 1,745
|
<p>I have a bunch of <strong>.NET</strong> frameworks installed on my machine.<br>
I know that with the <strong>Java JDK</strong>, I can use the <strong>6.0</strong> version to target <strong>5.0</strong> and earlier. </p>
<p>Can I do something similar with the <strong>.NET</strong> framework - target <strong>1.0</strong> and <strong>2.0</strong> with the <strong>3.0</strong> framework?</p>
|
<p>Visual Studio 2008 was the first to support targeting older versions of .NET. Unfortunately, it supports only .NET 2 and up.</p>
<p>In other words, you'll need .NET framework SDK 1 or 1.1 to do this.</p>
|
<p>(<strong>Updated</strong>)</p>
<p>You need to compile with the 1.0 compilers. These are only available with the 1.0 release of the runtime/SDK.</p>
<p>The 2.0/3.5 compilers won't emit 1.0-compatible assemblies.</p>
<p>Visual Studio 2008 can generate 2.0 assemblies, but 1.0 was left off.</p>
| 5,128
|
<p>I've just finished reading Domain Driven Design and I'm enchanted with some of the ideas covered in it. Do you know any companies that implement ubiquitous language in their projects?</p>
|
<p>The <a href="http://tech.groups.yahoo.com/group/domaindrivendesign/" rel="nofollow noreferrer">Domain Driven Design Yahoo Group</a> may be a better place to find an answer to your question.</p>
|
<p>The company I work for uses Domain-Driven Design to its fullest and after a few very successful projects, we're sticking with the design philosophy.</p>
<p>The company is <a href="http://www.hintinnovation.com" rel="nofollow noreferrer">Hint Innovation</a>, we are a relatively new company so the website is not done yet, but it should be by January, you might want to check back then.</p>
<p>I don't know of any other company that uses the Domain-Driven Design approach for all of their projects.</p>
| 9,941
|
<p>I have a dl containing some input boxes that I "clone" with a bit of JavaScript like: </p>
<pre><code>var newBox = document.createElement('dl');
var sourceBox = document.getElementById(oldkey);
newBox.innerHTML = sourceBox.innerHTML;
newBox.id = newkey;
document.getElementById('boxes').appendChild(columnBox);
</code></pre>
<p>In IE, the form in sourceBox is duplicated in newBox, complete with user-supplied values. In Firefox, last value entered in the orginal sourceBox is not present in newBox. How do I make this "stick?"</p>
|
<p>You could try the <code>cloneNode</code> method. It might do a better job of copying the contents. It should also be faster in most cases</p>
<pre><code>var newBox;
var sourceBox = document.getElementById(oldkey);
if (sourceBox.cloneNode)
newBox = sourceBox.cloneNode(true);
else {
newBox = document.createElement(sourceBox.tagName);
newBox.innerHTML = sourceBox.innerHTML;
}
newBox.id = newkey;
document.getElementById('boxes').appendChild(newBox);
</code></pre>
|
<p>You could try the <code>cloneNode</code> method. It might do a better job of copying the contents. It should also be faster in most cases</p>
<pre><code>var newBox;
var sourceBox = document.getElementById(oldkey);
if (sourceBox.cloneNode)
newBox = sourceBox.cloneNode(true);
else {
newBox = document.createElement(sourceBox.tagName);
newBox.innerHTML = sourceBox.innerHTML;
}
newBox.id = newkey;
document.getElementById('boxes').appendChild(newBox);
</code></pre>
| 9,509
|
<p>I know I've seen this in the past, but I can't seem to find it now.</p>
<p>Basically I want to create a page that I can host on a <a href="http://www.codeplex.com/dasblog" rel="nofollow noreferrer">dasBlog</a> instance that contains the layout from my theme, but the content of the page I control.</p>
<p>Ideally the content is a user control or ASPX that I write. Anybody know how I can accomplish this?</p>
|
<p>The easist way to do this is to "hijack" the FormatPage functionality.</p>
<p>First add the following to your web.config in the newtelligence.DasBlog.UrlMapper section:</p>
<pre><code><add matchExpression="(?&lt;basedir&gt;.*?)/Static\.aspx\?=(?&lt;value&gt;.+)" mapTo="{basedir}/FormatPage.aspx?path=content/static/{value}.format.html" />
</code></pre>
<p>Now you can create a directory in your content directory called static. From there, you can create html files and the file name will map to the url like this:</p>
<p><a href="http://BASEURL/Static.aspx?=FILENAME" rel="nofollow noreferrer">http://BASEURL/Static.aspx?=FILENAME</a></p>
<p>will map to a file called:</p>
<p>/content/static/FILENAME.format.html</p>
<p>You can place anything in that file that you would normally place in itemTemplate.blogtemplate, except it obviously won't have any post data. But you can essentially use this to put other macros, and still have it use the hometemplate.blogtemplate to keep the rest of your theme wrapped around the page.</p>
|
<p>I did something similar setting up a handler to stream video files from the blog on my home server. I ended up ditching it because it killed my bandwidth whenever someone would view a video, but I did have it up and working for a while.</p>
<p>To get it to work I had to check dasBlog out from source control and open it in visual studio. I had VS2008 and it was built using VS2005, so it took some work to get everything to build. Once I could get the unaltered solution to build I added a new class library project to hold my code. This is to make sure my code stays separate across dasBlog updates.</p>
<p>I don't have access to the code here at work so I can't tell you exact names right now, but if you want your pages to be able to use the themes then they need to inherit from a class in the newtelligence.dasBlog.Web namespace, and I believe also implement an interface. A good place to look is in FormatPage and FormatControl.</p>
| 7,250
|
<p>I am trying to create a mechanism with moving parts, and would like to see how it works (whether it even works) before printing it.</p>
<p>For example, there's a servo with a bracket, and I would like to see how far can the bracket move before colliding with other objects.</p>
<p><a href="https://i.stack.imgur.com/mlheh.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/mlheh.gif" alt="enter image description here"></a></p>
<p>Unfortunately I cannot find any information on how to set pivot points and rotate objects around these points in FreeCAD. Is this even possible?</p>
|
<p>freeCad has a draft rotate function in <strong>DRAFT workbench</strong>:</p>
<ol>
<li>Select an object;</li>
<li>Press the Draft Rotate button, then;</li>
<li>Click to set the rotating point and rotate. </li>
</ol>
<p>You will get used to that after a few trails.</p>
<p>There is a <a href="https://www.freecadweb.org/wiki/Draft_Rotate" rel="nofollow noreferrer">step by step guide</a> on freeCad site.</p>
<p>There is also a <a href="https://youtu.be/5KDEf16MNc0" rel="nofollow noreferrer">short demo of the function here</a>.</p>
|
<p>I would also like to take a look at the A2plus Workbench (Freecad Addon). There you can define constraints which can help with this problem. As far as I know, parts cannot be moved with the mouse pointer, but angle parameters can be entered.</p>
<p><a href="https://freecadweb.org/wiki/A2plus_Workbench" rel="nofollow noreferrer">https://freecadweb.org/wiki/A2plus_Workbench</a></p>
| 1,059
|
<p>My C# project - we'll call it the SuperUI - used to make use of a class from an external assembly. Now it doesn't, but the compiler won't let me build the project without the assembly reference in place. Let me elaborate.</p>
<p>This project used to throw and catch a custom exception class - the <code>SuperException</code> - which was derived from the standard System.Exception and lived in a separate, precompiled assembly, <code>SuperAssembly.DLL</code>, which I referenced.</p>
<p>Eventually, I decided this was a pointless exercise and replaced all <code>SuperExceptions</code> with a System.SuitableStandardException in each case. I removed the reference to <code>SuperException.DLL</code>, but am now met with the following on trying to compile the project:</p>
<blockquote>
<p>The type 'SuperException' is defined in an assembly that is not referenced. You must add a reference to assembly 'SuperException, Version=1.1.0.0 (...)'</p>
</blockquote>
<p>The source file referenced by the error doesn't seem relevant; it's the project namespace that gets highlighted in the IDE.</p>
<p>Now, here's the thing:</p>
<ol>
<li>All uses of <code>SuperException</code> have been eliminated from the project's code.</li>
<li>Compared to another project that compiles fine without a reference to <code>SuperException.DLL</code>, I only reference one more assembly - and <code>that</code> references nothing that my project doesn't reference itself. While it's possible that any of these dependencies could throw <code>SuperExceptions</code>, I'm only catching the base Exception class and in any case... the other project builds fine!</li>
<li>I've done Visual Studio's "Clean Solution" and cleared everything out by hand, many times.</li>
</ol>
<p>It's not the end of the world to include this reference, I just don't see why it's necessary any more. Nrrrgg. Any pointers welcome!</p>
|
<p>It's likely a transitive reference, where some type method call returns an instance of SuperException boxed ("downcast") as e.g. Exception, but from inspecting the code in the transitively included code, i.e. code from your external method calls, the compiler knows that you need to be able to have information about that type at some point. </p>
<p>Resharper would tell you where it's the case that you need to add a reference, and you could use Lütz Roeder's aka RedGate's Reflector to scan compiled IL for a reference to this type in two ways: 1) use the search-facility, 2) open each public type you're using and for that one which requires the "ghost" assembly, it will ask you to specify its location.</p>
<p>This most often happends to me when I reference Castle.Windsor but not Castle.MicroKernel. :p</p>
|
<p><code>grep -R SuperException *</code> in the base of your project (get <code>grep</code> from somewhere first) just to be sure.</p>
| 3,060
|
<p>So if I have a method of parsing a text file and returning a <strong>list</strong> <em>of a</em> <strong>list</strong> <em>of</em> <strong>key value pairs</strong>, and want to create objects from the kvps returned (each list of kvps represents a different object), what would be the best method?</p>
<p>The first method that pops into mind is pretty simple, just keep a list of keywords:</p>
<pre><code>private const string NAME = "name";
private const string PREFIX = "prefix";
</code></pre>
<p>and check against the keys I get for the constants I want, defined above. This is a fairly core piece of the project I'm working on though, so I want to do it well; does anyone have any more robust suggestions (not saying there's anything inherently un-robust about the above method - I'm just asking around)?</p>
<h1>Edit:</h1>
<p>More details have been asked for. I'm working on a little game in my spare time, and I am building up the game world with configuration files. There are four - one defines all creatures, another defines all areas (and their locations in a map), another all objects, and a final one defines various configuration options and things that don't fit else where. With the first three configuration files, I will be creating objects based on the content of the files - it will be quite text-heavy, so there will be a lot of strings, things like names, plurals, prefixes - that sort of thing. The configuration values are all like so:</p>
<pre><code>-
key: value
key: value
-
key: value
key: value
-
</code></pre>
<p>Where the '-' line denotes a new section/object.</p>
|
<p>Take a deep look at the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx" rel="nofollow noreferrer">XmlSerializer</a>. Even if you are constrained to not use XML on-disk, you might want to copy some of its features. This could then look like this:</p>
<pre><code>public class DataObject {
[Column("name")]
public string Name { get; set; }
[Column("prefix")]
public string Prefix { get; set; }
}
</code></pre>
<p>Be careful though to include some kind of format version in your files, or you will be in hell's kitchen come the next format change.</p>
|
<p>@David:<br>
I already have the parser (and most of these will be hand written, so I decided against XML). But that looks like I really nice way of doing it; I'll have to check it out. Excellent point about versioning too. </p>
<p>@Argelbargel:<br>
That looks good too. :')</p>
| 7,238
|
<p>I have windows 2003 terminal servers, multi-core. I'm looking for a way to monitor individual CPU core usage on these servers. It is possible for an end-user to have a run-away process (e.g. Internet Explorer or Outlook). The core for that process may spike to near 100% leaving the other cores 'normal'. Thus, the overall CPU usage on the server is just the total of all the cores or if 7 of the cores on a 8 core server are idle and the 8th is running at 100% then 1/8 = 12.5% usage.</p>
<p>What utility can I use to monitor multiple servers ? If the CPU usage for a core is "high" what would I use to determine the offending process and then how could I automatically kill that process if it was on the 'approved kill process' list?</p>
<p>A product from <a href="http://www.packettrap.com/" rel="nofollow noreferrer">http://www.packettrap.com/</a> called PT360 would be perfect except they use SMNP to get data and SMNP appears to only give total CPU usage, it's not broken out by an individual core. Take a look at their Dashboard option with the CPU gauge 'gadget'. That's exactly what I need if only it worked at the core level.</p>
<p>Any ideas?</p>
|
<p>Individual CPU usage is available through the standard windows performance counters. You can monitor this in perfmon.</p>
<p>However, it won't give you the result you are looking for. Unless a thread/process has been explicitly bound to a single CPU then a run-away process will not spike one core to 100% while all the others idle. The run-away process will bounce around between all the processors. I don't know why windows schedules threads this way, presumably because there is no gain from forcing affinity and some loss due to having to handle interrupts on particular cores.</p>
<p>You can see this easily enough just in task manager. Watch the individual CPU graphs when you have a single compute bound process running.</p>
|
<p>perfmon from Microsoft can monitor each individual CPU. perfmon also works remote and you can monitor farious aspects of Windows.</p>
<p>I'm not sure if it helps to find run-away processes because the Windows scheduler dos not execute a process always on the same CPU -> on your 8 CPU machine you will see 12.5 % usage on all CPU's if one process runs away.</p>
| 7,051
|
<p>I've been looking into this, but:</p>
<ol>
<li>I'm not certain how to configure my multimeter; </li>
<li>I don't know how to keep the voltage going, and;</li>
<li>I don't know how to keep the multimeter connected to the VMOT?</li>
</ol>
<p>I'm told you're supposed to aim for about 1 A.</p>
|
<p>Generally speaking voltage on stepstick output should be around 1V. </p>
<p>To imagine more or less what the current and what the voltage is, you can think about it in the same way as about water.</p>
<p>The wire is more or less the same as the pipe.
The voltage can be imagined as (sort of) the height from which the water flows but the current can be imagined as an amount of water which flows. To simplify things we assume that all our pipes are closed into circuit and we have pump/battery and we have a motor which is a reverted pump ;) and finally we have our stepstick which is a tap in our model.</p>
<p>So no matter what the height (voltage) is we know that tap (stepstick) will pass some amount (current) of water. We can drive it turning tap or turning a potentiometer on the stepstick PCB.</p>
<p>So we got it. Principles (deadly simplified) are now clear. <a href="https://learn.sparkfun.com/tutorials/voltage-current-resistance-and-ohms-law/voltage" rel="nofollow noreferrer">See here for more details</a></p>
<p>Getting back to your question.
You have to know what is your stepstick reference voltage. To make sure about that you have to check out resistor(s) next to main black element on stepstick board. There should be R100 or R200 which are very common.</p>
<p>Now you should read data from motor label to know what is proper current for your motor and calculate</p>
<p>voltage = motor_current * 8 * resistance_of_resistor</p>
<p>So now you know what is proper voltage for your motor and stepstick.</p>
<p>You measure voltage between potentiometer and GND (see on the picture)</p>
<p><a href="https://i.stack.imgur.com/6LnbU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6LnbU.png" alt="enter image description here"></a></p>
<p>If you set and connect everything and start printouts you should check motor temperature. Use your finger. If you can touch motor and hold your finger not more than half a second then probably the voltage set on potentiometer is too high (motor can reach 80° Celsius and it's fine but more will shorten its life span) and you should reduce it a bit (reduce by 5/100 V). If you notice that motor growls or barks then your voltage is probably too low and you can increase it by 5/100V.</p>
<p>Too high current will also reduce longevity of stepstick so cool them out with fan.</p>
<p><b>Please be noticed.</b></p>
<p>Z-axis motors will usually be not too hot as they work less than X and Y but as they are both connected to one stepstick so they need more current - set higher voltage there.</p>
<p>Here is a <a href="http://reprap.org/wiki/Stepstick" rel="nofollow noreferrer">reprap.org site</a> to get basic knowledge about stepsticks.</p>
|
<p>I want to add some points and clarifications to the answer that @darthpixel already has given. Most information you need is in there, I want to give some more practical advice, since that is what I understand you're question is asking for. I'll start with some points on the more theoretical side, though:</p>
<ul>
<li>notice that the Vref is not a voltage that is passed on to your motor. The described pipe analogy is very good, but the Vref is outside of this analogy. The reference voltage Vref is only used to set the current limit. This seems confusing, but has electronic reasons. One can understand the major (side-)benefit easily: Voltages are very easy to measure externally, because you connect your voltmeter in parallel. If you wouldd want to measure the current, you would need to get your ammeter in series with the circuit.</li>
<li>The stepsticks work by supplying the needed current for movement of the motor (current, because it works by creating magnetic fields), the voltage the stepstick supplies is 'just' supplied as high as needed to feed the desired current through your motor (determined by its resistivity/impedance). This just as an add-on.</li>
</ul>
<p>Now to the practical side and the application of darthpixel's answer and the above:</p>
<p>You want to measure the reference voltage to limit the current that produces the torque, but also heats up the motor - let darthpixel's advice be your guide: if you can't touch it because it is too hot, then there is too much current, i.e. Vref is too high). To do so:</p>
<ol>
<li>Set your multimeter to volts, range can be autorange or something bigger than 2V.</li>
<li>Connect one lead of your multimeter to the ground of your Prusa i3 controller board's power input (I use the screw that fastens the ground input of the RAMPS). The other lead goes directly to the center of the trimpot on the Stepstick. I took the best of my paint skills to create an image showing the process: <a href="https://i.stack.imgur.com/6cCzl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6cCzl.jpg" alt="measure Vref scheme" /></a></li>
<li>Note the value you read (12V power has to be on)</li>
<li>Use an insulated screwdriver and turn the trimpot slightly.</li>
<li>Get a new reading by repeating the measurement process.</li>
<li>Repeat the whole process until you get the desired Vref.</li>
</ol>
<p>Warning: While I've had no problems turning the trimpot while everything was switched on (with my DRV8825 drivers), you should switch the power supply off when doing so.</p>
<p>The described process allows only for a stepwise and rather slow setting of the Vref, but this is the easiest way I've found. I have read of people that use a crocodile clamp to attach the multimeter to the screwdriver for a readout while turning.</p>
<p>If you don't have any idea whether you need more or less current on the motor at the moment, check your resistors on the board and calculate the Vref you should need (see darthpixel's answer for the formula). I would however just do what darthpixel already suggested: figure out the trimpot position by ears and touch: klicking motor: go to higher Vref. Can't touch the motor for more than some seconds: go to lower Vref. It might be a lengthy process, but in the end you'd need to do it anyway to get the best out of the printer!</p>
| 339
|
<p>From what I've been able to find out, online sources recommend around 205ºC for PLA and around 240ºC for ABS. But these are only guidelines, of course. Optimal printing temperature can be different depending on the printer, the filament, the model and other slicer settings.</p>
<p>For example, I've had success printing black PLA at 190ºC, but silver PLA of the same brand is giving me trouble. I'm having a hard time figuring out the general rules. So I would like to see a general guide for this, based on (at least) the following questions:</p>
<ol>
<li><p>Which known factors before a print can help determine the right extrusion temperature? Obvious example: ABS vs PLA</p></li>
<li><p>What can happen during or after a print when the temperature is too low?</p></li>
<li><p>What can happen during or after a print when the temperature is too high?</p></li>
</ol>
<p>An answer to the first question could take the form of a lookup table, or similar. The second and third could help someone adjust their temperature based on the symptoms of a failed print.</p>
<p><em>I understand that the failure or success of a print can depend on many more factors than extrusion temperature, but I didn't want to make this question too general. I may later ask the same question for other settings (e.g., print speed). However, do let me know if this question should be expanded or improved to make it more useful.</em></p>
|
<h1>Printing temperature basics</h1>
<p>Manufacturers generally specify a somewhat wide range of printing temperatures, and what temperature you should actually need can only be determined by trial and error:</p>
<ol>
<li><p>The thermistor in your hotend is not 100 % accurate and may have an offset of a few degrees compared to its actual temperature.</p>
</li>
<li><p>Your hotend has a small temperature gradient, the place where the plastic is melted may have a higher/lower temperature compared to the temperature of your thermistor.</p>
</li>
</ol>
<p>2 is further exacerbated by</p>
<ol start="3">
<li><p>As you print faster, you need more heat. The cold filament rapidly moving through your hotend will cool it down locally, meaning that the temperature will be cooler than what the thermistor measures. Faster prints equal bumps in the temperature up to 10 °C, and for a really slow print you might turn it down 10 °C from where you normally are.</p>
</li>
<li><p>This is a minor issue, but different colors of the same brand and material might work better at different temperatures. The pigments used can affect the melting point somewhat. Different brands also might have different temperatures.</p>
</li>
</ol>
<p>Some symptoms may give you a guide as to how to adjust your temperature:</p>
<h1>Printing too hot</h1>
<ul>
<li><p>Small/slow prints may not solidify quickly enough, leaving you with an ugly blob.</p>
</li>
<li><p>Stringing/bad bridging.</p>
</li>
<li><p>Plastic in the heatbreak may soften, leading to clogging.</p>
</li>
<li><p>You might burn/degrade the material (but for this you would really need to go outside of the temperature range).</p>
</li>
</ul>
<h1>Printing too cool</h1>
<ul>
<li><p>Too much force required to extrude, leading so skipping/grinding of the filament drive.</p>
</li>
<li><p>Layer delamination: the plastic needs to be hot enough to partially melt the layer below it and stick to it. Objects printed at a colder temperature tend to be weaker at the layer boundaries.</p>
</li>
</ul>
<p>Furthermore, hot prints can sometimes have a more glossy finish than colder prints.</p>
|
<ol>
<li><p>Some manufacturers give a recommended temperature which would be the best place to start at and adjust from there. Otherwise you could print calibration objects and find the best temp that way. Here is a <a href="http://www.thingiverse.com/thing:915435" rel="nofollow">temp tower</a> for that purpose. Mostly it is a trial and error process with all the different printers out there. What might work on one printer may not work on another.</p></li>
<li><p>The object may come apart if the temperature is too low as the plastic won't bond well between layers. You may also get a rough surface on the object and the filament may also jam in the hotend as well.</p></li>
<li><p>Normally temperatures that are too high, your bridging wont be as good and you will get a lot of stringing. <a href="https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwjO17385onNAhWIcj4KHQE1B6MQjRwIBw&url=https%3A%2F%2Fwww.matterhackers.com%2Farticles%2Fretraction-just-say-no-to-oozing&psig=AFQjCNEUalIAKOP31E4tTKhdvNbzxpbl5g&ust=1464972656607170" rel="nofollow">Stringing example</a>, more filament will ooze out before retracting if your temperature is too high. Your overhangs may also curl at the edges as well.</p></li>
</ol>
| 302
|
<p>I need to do a simple mail merge in OpenOffice using C++, VBScript, VB.Net or C# via OLE or native API. Are there any good examples available?</p>
|
<p>I haven't come up with a solution I'm really happy with but here are some notes:</p>
<ul>
<li><p>Q. What is the OO API for mail merge?</p>
<p>A. <a href="http://api.openoffice.org/docs/common/ref/com/sun/star/text/MailMerge.html" rel="noreferrer">http://api.openoffice.org/docs/common/ref/com/sun/star/text/MailMerge.html</a></p></li>
<li><p>Q. What support groups?</p>
<p>A. <a href="http://user.services.openoffice.org/en/forum/viewforum.php?f=20" rel="noreferrer">http://user.services.openoffice.org/en/forum/viewforum.php?f=20</a></p></li>
<li><p>Q. Sample code?</p>
<p>A. <a href="http://user.services.openoffice.org/en/forum/viewtopic.php?f=20&t=946&p=3778&hilit=mail+merge#p3778" rel="noreferrer">http://user.services.openoffice.org/en/forum/viewtopic.php?f=20&t=946&p=3778&hilit=mail+merge#p3778</a></p>
<p><a href="http://user.services.openoffice.org/en/forum/viewtopic.php?f=20&t=8088&p=38017&hilit=mail+merge#p38017" rel="noreferrer">http://user.services.openoffice.org/en/forum/viewtopic.php?f=20&t=8088&p=38017&hilit=mail+merge#p38017</a></p></li>
<li><p>Q. Any more examples?</p>
<p>A. file:///C:/Program%20Files/OpenOffice.org_2.4_SDK/examples/examples.html (comes with the SDK)</p>
<p><a href="http://www.oooforum.org/forum/viewtopic.phtml?p=94970" rel="noreferrer">http://www.oooforum.org/forum/viewtopic.phtml?p=94970</a></p></li>
<li><p>Q. How do I build the examples?</p>
<p>A. e.g., for WriterDemo (C:\Program Files\OpenOffice.org_2.4_SDK\examples\CLI\VB.NET\WriterDemo)</p>
<ol>
<li>Add references to everything in here: C:\Program Files\OpenOffice.org 2.4\program\assembly</li>
<li>That is cli_basetypes, cli_cppuhelper, cli_types, cli_ure</li>
</ol></li>
<li><p>Q. Does OO use the same separate data/document file for mail merge?</p>
<p>A. It allows for a range of data sources including csv files</p></li>
<li><p>Q. Does OO allow you to merge to all the different types (fax, email, new document printer)?</p>
<p>A. You can merge to a new document, print and email</p></li>
<li><p>Q. Can you add custom fields?</p>
<p>A. Yes</p></li>
<li><p>Q. How do you create a new document in VB.Net?</p>
<p>A.</p>
<pre><code> Dim xContext As XComponentContext
xContext = Bootstrap.bootstrap()
Dim xFactory As XMultiServiceFactory
xFactory = DirectCast(xContext.getServiceManager(), _
XMultiServiceFactory)
'Create the Desktop
Dim xDesktop As unoidl.com.sun.star.frame.XDesktop
xDesktop = DirectCast(xFactory.createInstance("com.sun.star.frame.Desktop"), _
unoidl.com.sun.star.frame.XDesktop)
'Open a new empty writer document
Dim xComponentLoader As unoidl.com.sun.star.frame.XComponentLoader
xComponentLoader = DirectCast(xDesktop, unoidl.com.sun.star.frame.XComponentLoader)
Dim arProps() As unoidl.com.sun.star.beans.PropertyValue = _
New unoidl.com.sun.star.beans.PropertyValue() {}
Dim xComponent As unoidl.com.sun.star.lang.XComponent
xComponent = xComponentLoader.loadComponentFromURL( _
"private:factory/swriter", "_blank", 0, arProps)
Dim xTextDocument As unoidl.com.sun.star.text.XTextDocument
xTextDocument = DirectCast(xComponent, unoidl.com.sun.star.text.XTextDocument)
</code></pre></li>
<li><p>Q. How do you save the document?</p>
<p>A.</p>
<pre><code> Dim storer As unoidl.com.sun.star.frame.XStorable = DirectCast(xTextDocument, unoidl.com.sun.star.frame.XStorable)
arProps = New unoidl.com.sun.star.beans.PropertyValue() {}
storer.storeToURL("file:///C:/Users/me/Desktop/OpenOffice Investigation/saved doc.odt", arProps)
</code></pre></li>
<li><p>Q. How do you Open the document?</p>
<p>A.</p>
<pre><code> Dim xComponent As unoidl.com.sun.star.lang.XComponent
xComponent = xComponentLoader.loadComponentFromURL( _
"file:///C:/Users/me/Desktop/OpenOffice Investigation/saved doc.odt", "_blank", 0, arProps)
</code></pre></li>
<li><p>Q. How do you initiate a mail merge in VB.Net?</p>
<p>A.</p>
<ol>
<li><p>Don't know. This functionality is in the API reference but is missing from the IDL. We may be slightly screwed. Assuming the API was working, it looks like running a merge is fairly simple.</p></li>
<li><p>In VBScript:</p>
<p>Set objServiceManager = WScript.CreateObject("com.sun.star.ServiceManager")</p>
<p>'Now set up a new MailMerge using the settings extracted from that doc
Set oMailMerge = objServiceManager.createInstance("com.sun.star.text.MailMerge")</p>
<p>oMailMerge.DocumentURL = "file:///C:/Users/me/Desktop/OpenOffice Investigation/mail merged.odt"
oMailMerge.DataSourceName = "adds"
oMailMerge.CommandType = 0 ' <a href="http://api.openoffice.org/docs/common/ref/com/sun/star/text/MailMerge.html#CommandType" rel="noreferrer">http://api.openoffice.org/docs/common/ref/com/sun/star/text/MailMerge.html#CommandType</a>
oMailMerge.Command = "adds"
oMailMerge.OutputType = 2 ' <a href="http://api.openoffice.org/docs/common/ref/com/sun/star/text/MailMerge.html#OutputType" rel="noreferrer">http://api.openoffice.org/docs/common/ref/com/sun/star/text/MailMerge.html#OutputType</a>
oMailMerge.execute(Array())</p></li>
<li><p>In VB.Net (Option Strict Off)</p>
<pre><code> Dim t_OOo As Type
t_OOo = Type.GetTypeFromProgID("com.sun.star.ServiceManager")
Dim objServiceManager As Object
objServiceManager = System.Activator.CreateInstance(t_OOo)
Dim oMailMerge As Object
oMailMerge = t_OOo.InvokeMember("createInstance", _
BindingFlags.InvokeMethod, Nothing, _
objServiceManager, New [Object]() {"com.sun.star.text.MailMerge"})
'Now set up a new MailMerge using the settings extracted from that doc
oMailMerge.DocumentURL = "file:///C:/Users/me/Desktop/OpenOffice Investigation/mail merged.odt"
oMailMerge.DataSourceName = "adds"
oMailMerge.CommandType = 0 ' http://api.openoffice.org/docs/common/ref/com/sun/star/text/MailMerge.html#CommandType
oMailMerge.Command = "adds"
oMailMerge.OutputType = 2 ' http://api.openoffice.org/docs/common/ref/com/sun/star/text/MailMerge.html#OutputType
oMailMerge.execute(New [Object]() {})
</code></pre></li>
<li><p>The same thing but with Option Strict On (doesn't work)</p>
<pre><code> Dim t_OOo As Type
t_OOo = Type.GetTypeFromProgID("com.sun.star.ServiceManager")
Dim objServiceManager As Object
objServiceManager = System.Activator.CreateInstance(t_OOo)
Dim oMailMerge As Object
oMailMerge = t_OOo.InvokeMember("createInstance", _
BindingFlags.InvokeMethod, Nothing, _
objServiceManager, New [Object]() {"com.sun.star.text.MailMerge"})
'Now set up a new MailMerge using the settings extracted from that doc
oMailMerge.GetType().InvokeMember("DocumentURL", BindingFlags.SetProperty, Nothing, oMailMerge, New [Object]() {"file:///C:/Users/me/Desktop/OpenOffice Investigation/mail merged.odt"})
oMailMerge.GetType().InvokeMember("DataSourceName", BindingFlags.SetProperty, Nothing, oMailMerge, New [Object]() {"adds"})
oMailMerge.GetType().InvokeMember("CommandType", BindingFlags.SetProperty, Nothing, oMailMerge, New [Object]() {0})
oMailMerge.GetType().InvokeMember("Command", BindingFlags.SetProperty, Nothing, oMailMerge, New [Object]() {"adds"})
oMailMerge.GetType().InvokeMember("OutputType", BindingFlags.SetProperty, Nothing, oMailMerge, New [Object]() {2})
oMailMerge.GetType().InvokeMember("Execute", BindingFlags.InvokeMethod Or BindingFlags.IgnoreReturn, Nothing, oMailMerge, New [Object]() {}) ' this line fails with a type mismatch error
</code></pre></li>
</ol></li>
</ul>
|
<p>You should take a look at <strong><a href="http://api.openoffice.org" rel="nofollow noreferrer">Apache OpenOffice API</a></strong>. A project for creating an API for Open Office. A few languages they said to support are: C++, Java, Python, CLI, StarBasic, JavaScript and OLE.</p>
<p><a href="http://codesnippets.services.openoffice.org/Writer/Writer.MailMerge.snip" rel="nofollow noreferrer">Java Example of a mailmerge in OpenOffice</a>.</p>
| 5,982
|
<p>Using C++ (and Qt), I need to process a big amount of 3D coordinates.</p>
<p>Specifically, when I receive a 3D coordinate (made of 3 doubles), I need to check in a list if this coordinate has already been processed.
If not, then I process it and add it to the list (or container).</p>
<p>The amount of coordinates can become very big, so I need to store the processed coordinates in a container which will ensure that checking if a 3D coordinate is already contained in the container is fast.</p>
<p>I was thinking of using a map of a map of a map, storing the x coordinate, then the y coordinate then the z coordinate, but this makes it quite tedious to use, so I'm actually hoping there is a much better way to do it that I cannot think of.</p>
|
<p>Probably the simplest way to speed up such processing is to store the already-processed points in <a href="http://en.wikipedia.org/wiki/Octree" rel="noreferrer">Octree</a>. Checking for duplication will become close to logarithmic.</p>
<p>Also, make sure you tolerate round-off errors by checking the distance between the points, not the equality of the coordinates.</p>
|
<p>Pick a constant to scale the coordinates by so that 1 unit describes an acceptably small box and yet the integer part of the largest component by magnitude will fit into a 32-bit integer; convert the X, Y and Z components of the result to integers and hash them together. Use that as a hash function for a map or hashtable (NOT as an array index, you need to deal with collisions).</p>
<p>You may also want to consider using a fudge factor when comparing the coordinates, since you may get floating point values which are only slightly different, and it is usually preferable to weld those together to avoid cracks when rendering.</p>
| 9,773
|
<p>While working in a Java app, I recently needed to assemble a comma-delimited list of values to pass to another web service without knowing how many elements there would be in advance. The best I could come up with off the top of my head was something like this:</p>
<pre><code>public String appendWithDelimiter( String original, String addition, String delimiter ) {
if ( original.equals( "" ) ) {
return addition;
} else {
return original + delimiter + addition;
}
}
String parameterString = "";
if ( condition ) parameterString = appendWithDelimiter( parameterString, "elementName", "," );
if ( anotherCondition ) parameterString = appendWithDelimiter( parameterString, "anotherElementName", "," );
</code></pre>
<p>I realize this isn't particularly efficient, since there are strings being created all over the place, but I was going for clarity more than optimization.</p>
<p>In Ruby, I can do something like this instead, which feels much more elegant:</p>
<pre><code>parameterArray = [];
parameterArray << "elementName" if condition;
parameterArray << "anotherElementName" if anotherCondition;
parameterString = parameterArray.join(",");
</code></pre>
<p>But since Java lacks a join command, I couldn't figure out anything equivalent.</p>
<p>So, what's the best way to do this in Java?</p>
|
<h3>Pre Java 8:</h3>
<p>Apache's commons lang is your friend here - it provides a join method very similar to the one you refer to in Ruby: </p>
<p><a href="http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#join(java.lang.Iterable,%20char)" rel="noreferrer"><code>StringUtils.join(java.lang.Iterable,char)</code></a></p>
<hr>
<h3>Java 8:</h3>
<p>Java 8 provides joining out of the box via <code>StringJoiner</code> and <code>String.join()</code>. The snippets below show how you can use them:</p>
<p><a href="https://docs.oracle.com/javase/8/docs/api/java/util/StringJoiner.html" rel="noreferrer"><code>StringJoiner</code></a></p>
<pre><code>StringJoiner joiner = new StringJoiner(",");
joiner.add("01").add("02").add("03");
String joinedString = joiner.toString(); // "01,02,03"
</code></pre>
<hr>
<p><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#join-java.lang.CharSequence-java.lang.CharSequence...-" rel="noreferrer"><code>String.join(CharSequence delimiter, CharSequence... elements))</code></a></p>
<pre><code>String joinedString = String.join(" - ", "04", "05", "06"); // "04 - 05 - 06"
</code></pre>
<hr>
<p><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#join-java.lang.CharSequence-java.lang.Iterable-" rel="noreferrer"><code>String.join(CharSequence delimiter, Iterable<? extends CharSequence> elements)</code></a></p>
<pre><code>List<String> strings = new LinkedList<>();
strings.add("Java");strings.add("is");
strings.add("cool");
String message = String.join(" ", strings);
//message returned is: "Java is cool"
</code></pre>
|
<pre><code>public static String join(String[] strings, char del)
{
StringBuffer sb = new StringBuffer();
int len = strings.length;
boolean appended = false;
for (int i = 0; i < len; i++)
{
if (appended)
{
sb.append(del);
}
sb.append(""+strings[i]);
appended = true;
}
return sb.toString();
}
</code></pre>
| 8,872
|
<p>I have a large codebase that targetted Flash 7, with a <em>lot</em> of AS2 classes. I'm hoping that I'll be able to use Flex for any new projects, but a lot of new stuff in our roadmap is additions to the old code.</p>
<p>The syntax for AS2 and AS3 is generally the same, so I'm starting to wonder how hard it would be to port the current codebase to Flex/AS3. I know all the UI-related stuff would be iffy (currently the UI is generated at runtime with a lot of createEmptyMovieClip() and attachMovie() stuff), but the UI and controller/model stuff is mostly separated.</p>
<p>Has anyone tried porting a large codebase of AS2 code to AS3? How difficult is it? What kinds of pitfalls did you run into? Any recommendations for approaches to doing this kind of project?</p>
|
<p>Some notable problems I saw when attempting to convert a large number of AS2 classes to AS3:</p>
<h3>Package naming</h3>
<pre><code>class your.package.YourClass
{
}
</code></pre>
<p>becomes</p>
<pre><code>package your.package
{
class YourClass
{
}
}
</code></pre>
<h3>Imports are required</h3>
<p>You must explicitly import any outside classes used -- referring to them by their fully qualified name is no longer enough.</p>
<h3>Interface methods can't be labelled 'public'</h3>
<p>This makes total sense, but AS2 will let you do it so if you have any they'll need to be removed.</p>
<h3>Explicit 'override' keyword</h3>
<p>Any functions that override a parent class function must be declared with the <em>override</em> keyword, much like C#. Along the same lines, if you have interfaces that extend other interfaces and redeclare functions, those overrides must be removed (again, as with <em>public,</em> this notation didn't make sense anyway but AS2 let you do it).</p>
<h3>All the Flash builtin stuff changed</h3>
<p>You alluded to this above, but it's now <em>flash.display.MovieClip</em> instead of just <em>MovieClip,</em> for example. There are a lot of specifics in this category, and I didn't get far enough to find them all, but there's going to be a lot of annoyance here.</p>
<h3>Conclusion</h3>
<p>I didn't get to work on this conversion to the point of success, but I was able in a matter of hours to write a quick C# tool that handled every aspect of this except the <em>override</em> keyword. Automating the imports can be tricky -- in my case the packages we use all start with a few root-level packages so they're easy to detect.</p>
|
<p>Migrating a bigger project like this from as2 will be more than a simple search and replace. The new syntax is fairly similar and simple to adapt (as lilserf mentioned) but if nothing else the fact that as3 is more strict and the new event model will mostly likely cause a lot of problems. You'll probably be better off by more or less rewriting almost everything from scratch, possibly using the old code as a guide.</p>
<p>Migrating from as2 -> as3 in terms of knowledge is fairly simple though. If you know object oriented as2, moving on to as3 won't be a problem at all.</p>
<p>You still don't have to use mxml for your UI unless you specifically want to. Mxml just provides a quick way to build the UI (etc) but if you want to do it yourself with actionscript there's nothing stopping you (this would also probably be easier if you already have that UI in as2 code). Flex (Builder) is just a quick way to do stuff you may not want to do yourself, such as building the UI and binding data but essentially it's just creating a part of the .swf for you -- there's no magic to it ;)</p>
| 6,818
|
<p>I am trying to print a <a href="https://www.thingiverse.com/thing:2755765" rel="nofollow noreferrer">12 hole Ocarina</a> I found on thingiverse. When printing I have to stop it around 25-30 layers because the edge of the shell is higher then the infill. </p>
<p><a href="https://i.stack.imgur.com/kMrn5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kMrn5.jpg" alt="Example 1"></a></p>
<p><a href="https://i.stack.imgur.com/PVHAO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PVHAO.jpg" alt="Example 2"></a></p>
<p><a href="https://www.codepile.net/pile/Z0Y3v986" rel="nofollow noreferrer">G-Code of first 30 layers</a></p>
<p>I tried changing the infill, wall size, speed and retraction settings to no avail. The settings of the example print were:</p>
<ul>
<li>100% infill</li>
<li>0.2mm layer height</li>
<li>40mm printing speed (average)</li>
<li>1mm shell thickness (results in 2 layers)</li>
<li>Automatic infill patern</li>
<li>Printed at 210C with 3mm PLA (<a href="https://www.conrad.nl/p/renkforce-pla300h1-filament-pla-kunststof-3-mm-grijs-1-kg-1093147" rel="nofollow noreferrer">like this one</a>)</li>
<li>Printed on a RF1000</li>
<li>Sliced with CuraEngine in Repetier-host V2.1.6.</li>
</ul>
<p>Does anyone know what might cause this and how I can prevent it from happening?</p>
<p>Any help is greatly appreciated! :)</p>
|
<p>Did you verify the Cura z-offset actually changed the corresponding G-Codes? </p>
<p>I had the opposite problem on my RF1000. To fix the problem I added the following 2 lines to my start G-Codes:</p>
<pre><code>M3001 ; Activate Z-Compensation
M206 Z-0.3 ; Set z offset 0.3mm closer to the nozzle
</code></pre>
<p>The first line was default in some example prints and is (as far as I know) only used by Renkforce printers. The second line moves the nozzle closer to the bed. In your case you'd have to move it further away and would need a positive Z value.</p>
|
<p>Did you verify the Cura z-offset actually changed the corresponding G-Codes? </p>
<p>I had the opposite problem on my RF1000. To fix the problem I added the following 2 lines to my start G-Codes:</p>
<pre><code>M3001 ; Activate Z-Compensation
M206 Z-0.3 ; Set z offset 0.3mm closer to the nozzle
</code></pre>
<p>The first line was default in some example prints and is (as far as I know) only used by Renkforce printers. The second line moves the nozzle closer to the bed. In your case you'd have to move it further away and would need a positive Z value.</p>
| 1,438
|
<p>I have got the following situation. On a machine there is a <strong>Fritz ISDN</strong> card. There is a process that is responsible for playing a certain wave file on this device's wave out (<strong>ISDN</strong> connection is made at startup and made persistent). The scenario is easy, whenever needed the process calls <code>waveOutWrite()</code> on the previously opened wave device (everything initialized without any problems of course) and a callback function waits for <code>MM_WOM_DONE</code> msg to know that the playback has been finished. </p>
<p>Since a few days however (nothing changed neither in the process nor the machine) the <code>MM_WOM_DONE</code> message has been coming immediately after calling <code>waveOutWrite()</code> even though the wave lasts a couple of seconds. Again no error is reported, it looks like the file was played but had zero length (which is not the case). I am also sure that <code>waveOutReset()</code> was not called by my process (it would also trigger sending the mentioned message). I have already used to have some strange problems in the past that where solved simply by reinstalling <strong>TAPI</strong> drivers. This time for some reason it is problematic for me to perform that once again and I am trying more analytical approach :). Any suggestions what might cause such a behavior? Maybe something on the other end of the <strong>ISDN</strong> line?</p>
|
<p>I don't have the time to Google too much for this, but I know that either Larry Osterman or Raymond Chen blogged about a similar situation.</p>
<p>I'll check back later when I have more time to see if this question is still open.</p>
|
<p>What is the return value when the sound does not play? If you get MMSYSERR_NOERROR that points to the driver incorrectly reporting to the OS that the buffer was processed.</p>
<p>Has the WAV file itself changed? This <a href="http://blogs.msdn.com/larryosterman/archive/2007/07/24/playsound-is-failing-on-vista-what-s-wrong.aspx" rel="nofollow noreferrer">blog entry</a> indicates that some pretty in-depth validation is done on the metadata.</p>
| 3,101
|
<p>How can I close a browser window without receiving the <em>Do you want to close this window</em> prompt?</p>
<p>The prompt occurs when I use the <code>window.close();</code> function.</p>
|
<p>My friend... there is a way but "hack" does not begin to describe it. You have to basically exploit a bug in IE 6 & 7. </p>
<p>Works every time!</p>
<p>Instead of calling <code>window.close()</code>, redirect to another page. </p>
<p>Opening Page:</p>
<pre><code>alert("No whammies!");
window.open("closer.htm", '_self');
</code></pre>
<p>Redirect to another page. This fools IE into letting you close the browser on this page. </p>
<p>Closing Page:</p>
<pre><code><script type="text/javascript">
window.close();
</script>
</code></pre>
<p>Awesome huh?!</p>
|
<p>The best solution I have found is:</p>
<pre><code>this.focus();
self.opener=this;
self.close();
</code></pre>
| 8,227
|
<p>I'm still fairly new to 3D printing; got my Ender 3 V2 for Christmas last year. Recently the tension arm in the stock extruder snapped, so I bought and installed an all-aluminum replacement. My first successful(ish) print since installing it lasted two to three hours before I noticed the filament wasn't feeding. It had softened and clogged the lead-in to the Bowden tube just past the tooth gear. I figure the problem comes from (and what probably broke the original plastic) heat buildup; the new aluminum frame was VERY hot to the touch. I also noticed that the extruder motor was rather hot as well.</p>
<p>So you all know where I am: all I've printed with is PLA at 195 °C. Since changing extruders, I was getting over extrusion and dropped it to 185 °C and increased the retraction from 5 mm to 6.5 mm. The new one doesn't have (easily) adjustable tension, but the tension felt as strong as I had it on my old one, so I left it alone. I currently print within an enclosure, one of Creality's foil-lined ones since my printer is located in the garage (this is more for dust, but for longer prints I felt it was good to have since at the time it was getting very cold at night in the garage).</p>
<p>I don't think it's heat creep, since that meant it went all the way up the Bowden tube. My first guess is the ambient heat inside the enclosure. I am currently trying a new print with the top and side openings folded up to allow airflow. But I welcome more experienced suggestions and input.</p>
<h3>Additional info</h3>
<p>I think I was getting away with the low temperature (185 °C) because my printing enclosure held heat so well. I'm attempting to print outside the enclosure today to start removing variables to my problem, if it under-extrudes, I'll bump the temperature up again.</p>
<p>Please note that I replaced <em>just the frame</em>.</p>
<p>I wouldn't know how to adjust the voltage [of the Z-stepper] if indeed the [pre-set factory calibration is incorrect and causing the stepper to heat up]. The new tension arm is a bit tighter than I had it set on my old, but I can't imagine it's making enough resistance to overwork the motor without seeing other issues first.</p>
<p>I didn't see any signs of Heat Creep when I pulled out the filament. The only softening I saw was in the direct drive; it had been pushed into a conical shape that plugged the port into the Bowden just past the gears. I'm still leaning towards an issue with the direct drive (is that what it's called? still learning the terms). the aluminum was too hot to touch and I had to wait 10 minutes before I could safely depress the tensioner and pull the filament out. That or the motor is overheating trying to pull Filament through.</p>
<p>The motor driving the filament is on the opposite side of the Teflon tube, mounted to the vertical frame - it is <em>not</em> on the nozzle side of the Teflon tube.</p>
|
<p>You could still get heat creep with a Bowden tube. It has different characteristics. Instead of jamming up in the direct drive, the filament can melt too far upwards into the heat break where it can refreeze and jam. The characteristic, if you can pull out the filament, is widened filament extending into the heat break.</p>
<p>See <a href="https://3dprinting.stackexchange.com/questions/15732/air-printing-jamming-midway-through-raft-creation/15738#15738">Air printing/jamming midway through raft creation</a></p>
<p>and</p>
<p><a href="https://3dprinting.stackexchange.com/questions/15629/understanding-all-the-ways-to-avoid-heat-creep">What are ways to avoid heat creep?</a></p>
<p>Adding fans to an enclosure improves the temperature control in the enclosure.</p>
|
<p><em>Answer created from octopus8's comments. If octopus8 wants to post their own answer, this wiki answer can be deleted.</em></p>
<hr />
<p>185 °C is quite ok for several PLAs I have when printing slow.</p>
<p>Honestly, I couldn't believe that the heat can go up the heatsink and Bowden tube to make extruder frame hot. So maybe your extruder's stepper motor is just getting hot heats up all metal elements (or a combination of both)? Did you replace only frame or also the stepper motor? Maybe the voltage is too high? I think voltages might be not calibrated well in factory, because my Z stepper in Ender 3 V2 also is getting really hot since I bought the printer (so far I added radiator, but I plan to regulate this voltage).</p>
<blockquote>
<p>The new tension arm is a bit tighter than I had it set on my old, but I can't imagine it's making enough resistance to overwork the motor without seeing other issues first.</p>
</blockquote>
<p>I agree with your judgement. Regarding the voltage: first I am not sure if my copy of v4.2.2 mainboard <a href="https://www.reddit.com/r/ender3/comments/ibqo8s/" rel="nofollow noreferrer">has TMC2208 stepper drivers, or some older HR4988</a>. I would need to determine that first, then find a valid formula for Vref. Actual voltage is tuned using potentiometer next to corner of stepper's small radiator. You can <a href="https://marlin.crc.id.au/faq/Ender%203%20V2/#vref" rel="nofollow noreferrer">see here an example of this process</a>. One problem is that Ender 3 V2 has the mainboard accessible from the bottom, so I would need something like garage pit to operate...</p>
<p>As you can see, it is important to not touch the screwdriver's metal bar, and anyhow include your body's capacity to this circuit, or you may break things. There are also ceramic screwdrivers - but I already bought two and still my best option is sculpted from 3mm filament. Plastic or ceramic tool will need you to measure voltage separately from turning potentiometer. So the idea of connecting voltmeter to small metal screwdriver is very handy, but you have to be careful to touch only plastic parts.</p>
| 1,887
|
<p>What should I do if I want to release a .net assembly but wish to keep its internals detailed in the manifest private (from a utility such as <a href="https://learn.microsoft.com/en-us/dotnet/framework/tools/ildasm-exe-il-disassembler" rel="nofollow noreferrer">ildasm.exe</a>) ?</p>
|
<p>I think what you're talking about is "obfuscation".
There are lots of articles about it on the net:</p>
<p><a href="http://en.wikipedia.org/wiki/Obfuscation" rel="noreferrer">http://en.wikipedia.org/wiki/Obfuscation</a></p>
<p>The "standard" tool for obfuscation on .NET is by Preemptive Solutions:</p>
<p><a href="http://www.preemptive.com/obfuscator.html" rel="noreferrer">http://www.preemptive.com/obfuscator.html</a></p>
<p>They have a community edition that ships with Visual Studio which you can use.</p>
<p>You mentioned ILDasm, have you looked at the .NET Reflector?</p>
<p><a href="http://aisto.com/roeder/dotnet/" rel="noreferrer">http://aisto.com/roeder/dotnet/</a></p>
<p>It gives you an even better idea as to what people can see if you release a manifest!</p>
|
<p>The CLR cannot directly load modules that contain no manifest. So you can't make an assembly completely private unless you also want to make it unloadable ;)</p>
<p>You can however, as Mark noted above, use obfuscation tools to hide the parts you would like to keep truly internal. </p>
<p>It's too bad the <strong><em>internal</em></strong> keyword doesn't exclude that metadata</p>
<p>EDIT: it looks like <a href="https://stackoverflow.com/questions/31637/remove-meta-data-from-net-applications">this question</a> is highly related</p>
| 4,937
|
<p>I have seen <a href="http://blogs.msdn.com/djpark/archive/2007/11/07/how-to-use-solutions-and-projects-between-visual-studio-2005-and-2008.aspx" rel="nofollow noreferrer">Solutions created in Visual Studio 2008 cannot be opened in Visual Studio 2005</a> and tried workaround 1. Yet to try the workaround 2. </p>
<p>But as that link was bit old and out of desperation asking here: Is there any convertor available?</p>
<hr>
<p>I dont have VS2008 yet and i wanted to open an opensource solution which was done in vs2008.</p>
<p>Guess i have to fiddle around or wait till the vs2008 is shipped.</p>
|
<p>I have a project that I work on in both VS 2005 and VS 2008. The trick is just to have to different solution files, and to make sure they stay in sync. Remember that <strong>projects</strong> keep track of their <strong>files</strong>, so the main thing <strong>solutions</strong> do is keep track of which <strong>projects</strong> they contain; pretty easy to keep in sync.</p>
<p>So just create a new blank solution in VS 2005, and then add each of your projects to it, one by one. Be sure to name the solutions appropriately. (I call mine ProjectName.sln and ProjectNameVs2008.sln.)</p>
<p>Which is a long way of saying you should try workaround #2.</p>
|
<p>I'd say you should restore your 2005 version from source control, assuming you have source control and a 2005 copy of the file.</p>
<p>Otherwise, there are plenty of pages on the net that details the changes, but unfortunately no ready-made converter program that will do it for you.</p>
<p>Be aware that as soon as you open the file in 2008 again, it'll be upgraded once more.</p>
<p>Perhaps the solution (no pun intended) is to keep separate copy of the project and solution files for 2005 and 2008?</p>
<p>Why do you want to open it in 2005 anyway?</p>
| 4,542
|
<p>This error just started popping up all over our site.</p>
<p><strong><em>Permission denied to call method to Location.toString</em></strong></p>
<p>I'm seeing google posts that suggest that this is related to flash and our crossdomain.xml. What caused this to occur and how do you fix?</p>
|
<p>Are you using javascript to communicate between frames/iframes which point to different domains? This is not permitted by the JS "same origin/domain" security policy. Ie, if you have</p>
<pre><code><iframe name="foo" src="foo.com/script.js">
<iframe name="bar" src="bar.com/script.js">
</code></pre>
<p>And the script on bar.com tries to access <code>window["foo"].Location.toString</code>, you will get this (or similar) exceptions. Please also note that the same origin policy can also kick in if you have content from different subdomains. <a href="http://www.mozilla.org/projects/security/components/same-origin.html" rel="nofollow noreferrer">Here</a> you can find a short and to the point explanation of it with examples.</p>
|
<p>This <a href="http://willperone.net/Code/as3error.php" rel="nofollow noreferrer">post</a> suggests that there is one line that needs to be added to the crossdomain.xml file.</p>
<pre><code><allow-http-request-headers-from domain="*" headers="*"/>
</code></pre>
| 5,042
|
<p>I understand the principle of why a heater block is used. Helping to reduce temperature variation as the filament is extruded using the heat capacity of the block.</p>
<p>But I’m wondering why it takes the form it does? I imagine it is cuboid in shape just for convenience as it’s easy to machine?</p>
<p>From a surface area to volume ratio a cuboid appears to be one of the worst shapes to use.</p>
<p>Note:
I am currently doing a project which requires me to increase the tool clearance of the nozzle of a 3D printer. Hence why I am exploring alternative print head configurations and heater block design trying to minimise the profile of the print head as much as possible.</p>
|
<p>Changing the <strong>flow rate</strong> during a print can <strong>not</strong> be saved. There simply is no way. It is usually meant to be a fix with filament inconsistencies or to look for the right extrusion factor for a new filament batch.</p>
<h2>Slicer</h2>
<p>The only way to consistently increase the flow rate would be to alter the <code>flow rate</code> in your slicer to what you have found to work best for each machine, probably using separate profiles. This will up the rate for every subsequently sliced print. Note though that this 108 % increased extrusion is converted extrusion factors that are simply numerical and 1.08 times the normal in the g-code. These numerical values will be taken as 100 % by the printer - and since it requires extra work to slice the gode for different profiles it is not the optimal solution.</p>
<p>As you elaborated though, this is not a doable thing, so let's look further.</p>
<h2>Source hunt & Workaround</h2>
<p>Since only one printer is showing underextrusion while the others do not, it is time to check the hard- and firmware:</p>
<ul>
<li>underextrusion can be caused by a defective extruder assembly or a damaged or blocked nozzle.</li>
<li>if a machine has consistent underextrusion, its steps/mm in the firmware might be off. This could be altered and stored in the EEPROM. Since this could be a machine unique setting, here would be your point of attack to increase the extrusion of just one machine while using the identical G-code to all other machines.</li>
</ul>
<p>Note that the standard firmware of the Ender-3 in 2019 did not contain Thermal Runaway Protection (<a href="/q/8466/">What is Thermal Runaway Protection?</a>) and should be upgraded because of this anyway. You have to flash a bootloader too, so in the process of doing the upgradeability and safety-upgrade to all the machines, you could store the altered steps/mm to each machine individually so they get consistent output.</p>
|
<p>You should be able to add a global override to the flow percentage on Marlin firmware printers.</p>
<p>Add this line somewhere in your start code:</p>
<p><code>M221 S97 ; Flow Percentage hard set.</code></p>
<p>In Cura, edit the printer's machine settings. The <code>S</code> is the percentage. In my case, 97 % works for PLA+.</p>
<p>Here is a link you might find useful.
<a href="https://marlinfw.org/docs/gcode/M221.html" rel="nofollow noreferrer">Marlin Docs</a></p>
| 1,507
|
<p>The backstory: I'm installing a pigeon net in my home. Because of the shape of the opening I'm installing the net in and the material on the sides it's difficult to anchor the net using the normal means but I can print clips that will hold the net in place.</p>
<p>The clips will be outside and will be exposed to the weather and direct sunlight, the weather here is relatively hot (up to 30C) with a lot of sun most of the year and rain in the winter.</p>
<p>I only have PLA, ABS and PETG available, anything else will take too long to arrive.</p>
<p>I don't care about the parts changing color and mostly I don't care about them deforming a little bit - only about breaking.</p>
<p>If the parts have to be replaced after a year I'm ok with it, less then that will be annoying, longer will be better.</p>
<p>So, under those conditions, which of the 3 materials is more durable?</p>
|
<p>Ok, I tried all 3 materials.</p>
<p>PLA failed after less then one day, I believe it deformed from the constant pressure and fell out (I didn't find the part but I didn't really search for it, there's some tall grass below the window)</p>
<p>ABS lasted about a year, it fell strait down and I found the part, it looks ok if probably deformed by just a few mm so it doesn't pressure fit anymore.</p>
<p>PETG still going strong as I write this</p>
|
<p>What colour was your PLA? PLA will soften around 60C and a dark colour will easily get hotter than that in direct sun on a 30C day. Clear PLA seems to have much, much better temperature resistance, but any sort of PETG will kick it's butt in that regard.</p>
| 565
|
<p>OK, I am not sure if the title it completely accurate, open to suggestions!</p>
<p>I am in the process of creating an ASP.NET custom control, this is something that is still relatively new to me, so please bear with me.</p>
<p>I am thinking about the event model. Since we are not using Web Controls there are no events being fired from buttons, rather I am manually calling <strong>__doPostBack</strong> with the appropriate arguments. However this can obviously mean that there are a lot of postbacks occuring when say, selecting options (which render differently when selected).</p>
<p>In time, I will need to make this more Ajax-y and responsive, so I will need to change the event binding to call local Javascript.</p>
<p>So, I was thinking I should be able to toggle the "mode" of the control, it can either use postback and handlle itself, or you can specify the Javascript function names to call instead of the doPostBack.</p>
<ul>
<li>What are your thoughts on this?</li>
<li>Am I approaching the raising of the events from the control in the wrong way? (totally open to suggestions here!)</li>
<li>How would you approach a similar problem?
<hr></li>
</ul>
<h2>Edit - To Clarify</h2>
<ul>
<li>I am creating a custom rendered control (i.e. inherits from WebControl).</li>
<li>We are not using existnig Web Controls since we want complete control over the rendered output.</li>
<li>AFAIK the only way to get a server side event to occur from a custom rendered control is to call doPostBack from the rendered elements (please correct if wrong!).</li>
<li>ASP.NET MVC is not an option.</li>
</ul>
|
<p>You might like to try this <a href="http://www.vim.org/scripts/script.php?script_id=1491" rel="noreferrer">improved Javascript syntax highlighter</a> rather than the one that ships with VIMRUNTIME.</p>
|
<p>For a quick and dirty fix, sometimes I just scroll up and down and the highlighting readjusts. <kbd>Ctrl</kbd>+<kbd>L</kbd> for a screen redraw can also fix it.</p>
| 8,327
|
<p>There are many different printing technologies. While it might be clear to the asker that he's talking about his home 3D printing machine, that's not necessarily the case for those that try to answer the question.</p>
<p>I think it would help to specify the scope of questions with tags, to allow future visitors to identify what type of 3D printer it is about. Answers to a lot of questions related to general properties of the printing process like printing speed, resolution, additional manual work, support structures, etc. depend heavily on the technology that's being used.</p>
<p>This also prevents "Well, it depends..." type of answers that cover a lot of possibly unrelated things.</p>
|
<p>No, there will be many questions which are more general in nature, and have little to do with the actual process used to produce the part.</p>
<p>We should encourage tag use for process when appropriate, but I don't think making it mandatory will work in the long term.</p>
|
<p>No, there will be many questions which are more general in nature, and have little to do with the actual process used to produce the part.</p>
<p>We should encourage tag use for process when appropriate, but I don't think making it mandatory will work in the long term.</p>
| 1
|
<p>Is there a good ruby gem for a WYSIWYG editor that will easily work with a rails app?</p>
|
<p>Though it's certainly not a direct answer, in the past I've found I prefer to use RedCloth (or a Markdown parser if you don't enjoy Textile) and use a simple textarea with an AJAXy preview. Generally speaking, WYSIWYG editors have a long history of creating redundant tags and similar, leading to potentially broken pieces of HTML.</p>
|
<p>I'm really loving CKeditor gem. It's much, much more elegant than TinyMCE, especially if you deal with raw HTML. CKeditor displays on page--TinyMCE gives a popup. CKeditor allows access to things like all headings right out of the box, too. TinyMCE requires hacking.</p>
<p>RedCloth's inability to support ALL HTML was a dealbreaker for me. (Among other things, you can't support giving an image a description OR a caption!!!!) I didn't mind the markup so much as the complete lack of flexibility. Plus, it was like learning a new language--a lot of the markup was the opposite of intuitive (like image alignment), and I couldn't possibly imagine asking contributors to learn all that.</p>
<p>For comments, I will use something much lighter weight, though.</p>
| 4,420
|
<p>My main application for my 3D printer (Zortrax M200 Plus) is making 28 mm scale miniatures for role-playing games. Basically people and animals at 1:60 scale, which means that things like arms, legs, or weapons are only a few millimeters thick. If I use the automatically generated supports of the Z-Suite software, the supports end up being thicker than the model parts, and are impossible to remove.</p>
<p>I had a bit more luck creating support structures with Meshmixer, but am not totally happy with those. So I am looking for other software to edit .STL files to add supports automatically, preferably with an option to edit those support structures easily afterwards. Any ideas?</p>
<p>Note that Zortrax printers only work with proprietary Z-Suite software, so the software that adds the support also needs to be able to export the model with the supports into an STL file, not just gcode.</p>
|
<p>I see that you've already tried <a href="http://www.meshmixer.com/download.html" rel="nofollow noreferrer" title="Meshmixer - Free Download">Meshmixer</a> and didn't find it helpful, but I wanted to call out <a href="https://www.prusaprinters.org/how-to-create-custom-overhang-supports-in-meshmixer/" rel="nofollow noreferrer" title="How to Create Custom Overhang Supports in Meshmixer - Prusa Blog">an article and accompanying video</a> that I recently found which helped me understand Meshmixer's support generation feature a bit better. It isn't magic, but it is pretty flexible and you can customize them. Plus, you can export them either as a separate file (to be imported via Slic3r's Load Part for example), or as part of the primary object STL file (though you loose the ability to set different print settings for the supports). Much of my printer's time is also devoted to 28mm figurines and I've had varied success with them. There are some models whose detail is too fine and which require too much support to be worth it considering the cleanup - I have a bucket-of-shame that's full of them. I just ordered an upgrade for my printer to allow me to print with multiple filament and I'll be seeing if <a href="https://www.prusaprinters.org/printing-soluble-interface-supports-prusa-i3-mk2-multi-material/" rel="nofollow noreferrer" title="Printing Soluble Interface Supports with Prusa i3 MK2 Multi Material - Prusa Blog">soluble support material</a> is helpful for those small details. Barring that, I've found that some prints do better with Meshmixer's supports while others do better with simplify3d supports, while others still do better with slic3r supports. </p>
<p>Summarizing the <a href="https://www.prusaprinters.org/how-to-create-custom-overhang-supports-in-meshmixer/" rel="nofollow noreferrer" title="How to Create Custom Overhang Supports in Meshmixer - Prusa Blog">article</a> on custom Meshmixer supports:</p>
<blockquote>
<ol>
<li>Open your model in Meshmixer</li>
<li>From the top menu select View – Show Printer Bed</li>
<li>Select Edit – Transform and move the model to the middle of the print bed
<ul>
<li>This step is important because Meshmixer won’t generate any supports outside of the print area</li>
</ul></li>
<li>If you want to print the model on a different scale, scale the model now, again by using the Edit – Transform. It’s better to scale
the model now, because an additional change of scale later in slicer
would also affect the generated supports, resulting in either too thin
and weak supports or too thick and hard to remove supports.
<ul>
<li>Change the Scale X (Scale Y and Scale Z) to the desired value (1 = 100%, 1.5 = 150% etc.)</li>
</ul></li>
<li>Select Analysis – Overhangs
<ul>
<li>You can now adjust the Angle Thresh and see a live preview of areas of the model that should be supported</li>
</ul></li>
<li>Click on Generate Support to see a preview of the support structure
<ul>
<li>Every time you make changes to the support settings you’ll have to click on Remove Support and Generate Support to refresh the view</li>
</ul></li>
</ol>
</blockquote>
<p>(The <a href="https://www.youtube.com/watch?v=OXFKVmMwXCQ&feature=youtu.be" rel="nofollow noreferrer" title="How to create custom supports in Meshmixer - YouTube">video</a> in the article goes into greater detail on the settings available in step 6.)</p>
<blockquote>
<ol start="7">
<li>Adding and removing supports manually
<ul>
<li>You can create a new support by left-clicking and dragging from an overhang to the ground or from an existing support to the ground</li>
<li>Hold down the Shift key to ignore intersections of the support strut or any other warning and force Meshmixer to generate the new
support (use wisely)</li>
<li>You can also click on an existing support to generate a new strut going down to the build plate</li>
<li>CTRL + Left click on an existing support to remove it</li>
</ul></li>
<li>When you’re happy with the support structure you can export the model and the support structure together as STL by simply clicking
Done and clicking on the Export button in the left menu</li>
<li>Alternatively, you can select Convert to Solid to create a separate mesh from the support structure. This will let you set different
settings in Slic3r for the supports and for the model itself
<ol>
<li>After choosing Convert to Solid choose Edit – Separate shells</li>
<li>Export both the model and the supports as individual STL files</li>
<li>In Slic3r first load the STL with the model</li>
<li>Double-click on the model and choose Load part…, select the supports STL file</li>
<li>When the STL loads, you can overwrite some of the settings by clicking on the green plus icon</li>
</ol></li>
</ol>
</blockquote>
|
<p>I had good experience with the support interfaces from CURA. But reduce the thickness of the support interface to be just enough, that a smooth support interface top can be printed and set the top distance so that the model itself can be printed smooth and you can remove the interface easy enough. (I got good results with a thickness of 2-4 layers and a distance of 1-2 layers.
Important: the real filament thickness should be set in CURA very precisely, else it could lead to hard to remove interface or a not smooth bottom of the model. </p>
| 897
|
<p>In a Flex <code>AdvancedDatGrid</code>, we're doing a lot of grouping. Most of the columns are the same for the parents and for the children, so I'd like to show the first value of the group as the summary rather than the MAX, MIN or AVG</p>
<p>This code works on numerical but not textual values (without the commented line you get NaN's):</p>
<pre><code>private function firstValue(itr:IViewCursor,field:String, str:String=null):Object
{
//if(isNaN(itr.current[field])) return 0 //Theory: Only works on Numeric Values?
return itr.current[field]
}
</code></pre>
<p>The XML:</p>
<pre><code>(mx:GroupingField name="Offer")
(mx:summaries)
(mx:SummaryRow summaryPlacement="group")
(mx:fields)
(mx:SummaryField dataField="OfferDescription" label="OfferDescription" summaryFunction="firstValue"/)
(mx:SummaryField dataField="OfferID" label="OfferID" summaryFunction="firstValue"/)
(/mx:fields)
(/mx:SummaryRow)
(/mx:summaries)
(/mx:GroupingField)
</code></pre>
<p><code>OfferID</code>'s work Correctly, <code>OfferDescription</code>s don't.</p>
|
<p>It looks like the summaryFunction has to return a number. According to the <a href="https://bugs.adobe.com/jira/browse/FLEXDOCS-431" rel="nofollow noreferrer">Adobe bug tracker</a>, it is a bug in the documentation:</p>
<blockquote>
<p>Comment from Sameer Bhatt:</p>
<p>In the documentation it is mentioned that -
The built-in summary functions for SUM, MIN, MAX, AVG, and COUNT all return a Number containing the summary data.</p>
<p>So people can get an idea but I agree with you that we should clearly mention that the return type should be a Number.</p>
<p>We kept it as an Object so that it'll be easy in the future to add more things in it.</p>
</blockquote>
|
<p>It looks like the summaryFunction has to return a number. According to the <a href="https://bugs.adobe.com/jira/browse/FLEXDOCS-431" rel="nofollow noreferrer">Adobe bug tracker</a>, it is a bug in the documentation:</p>
<blockquote>
<p>Comment from Sameer Bhatt:</p>
<p>In the documentation it is mentioned that -
The built-in summary functions for SUM, MIN, MAX, AVG, and COUNT all return a Number containing the summary data.</p>
<p>So people can get an idea but I agree with you that we should clearly mention that the return type should be a Number.</p>
<p>We kept it as an Object so that it'll be easy in the future to add more things in it.</p>
</blockquote>
| 9,134
|
<p>I have a .tag file that requires a JavaScript library (as in a .js file).</p>
<p>Currently I am just remembering to import the .js file in every JSP that uses the tag but this is a bit cumbersome and prone to error.</p>
<p>Is there a way to do the importing of the .js inside the JSP tag?</p>
<p><em>(for caching reasons I would want the .js to be a script import)</em></p>
|
<p>There is no reason you cannot have a script tag in the body, even though it is preferable for it to be in the head. Just emit the script tag before you emit your tag's markup. The only thing to consider is that you do not want to include the script more than once if you use the jsp tag on the page more than once. The way to solve that is to remember that you have already included the script, by addng an attribute to the request object.</p>
|
<p>Short of just including the js in every page automatically, I do not think so. It really would not be something that tags are designed to to.</p>
<p>Without knowing what your tag is actually doing (presumably its its outputting something in the body section) then there is no way that it will be able to get at the head to put the declaration there.</p>
<p>One solution that might (in my head) work would be to have an include that copies verbatim what you have in the head after the place in the head to import tags right up to where you want to use the tag. This is really not something that you would want to do. You would have to have multiple 'header' files to import depending on the content and where you want to use the tag. Maintenance nightmare. Just a bad idea all round. Any solution I can think of would require more work than manually just adding in the declaration.</p>
<p>I think you are out of luck and stuck with manually putting it in.</p>
<p><em>edit: Just import it in every page. It will be cached and then this problem goes away.</em></p>
| 7,159
|
<p>I have an application that I would like to embed inside our companies CMS. The only way to do that (I am told), is to load it in an <code><iframe></code>.</p>
<p>Easy: just set <code>height</code> and <code>width</code> to <code>100%</code>! Except, it doesn't work.</p>
<p>I did find out about setting <code>frameborder</code> to <code>0</code>, so it at least <em>looks</em> like part of the site, but I'd prefer not to have an ugly scrollbar <em>inside</em> a page that allready has one.</p>
<p>Do you know of any tricks to do this?</p>
<p><strong>EDIT:</strong> I think I need to clarify my question somewhat:</p>
<ul>
<li>the company CMS displays the fluff and stuff for our whole website</li>
<li>most pages created through the CMS</li>
<li>my application isn't, but they will let me embedd it in an <code><iframe></code></li>
<li>I have no control over the <code>iframe</code>, so any solution must work from the referenced page (according to the <code>src</code> attribute of the <code>iframe</code> tag)</li>
<li>the CMS displays a footer, so setting the height to 1 million pixels is not a good idea</li>
</ul>
<p>Can I access the parent pages DOM from the referenced page? This might help, but I can see some people might not want this to be possible...</p>
<p>This technique seems to work (<a href="http://bytes.com/forum/thread91876.html" rel="noreferrer">gleaned</a> from several sources, but inspired by the <a href="http://brondsema.net/blog/index.php/2007/06/06/100_height_iframe" rel="noreferrer">link</a> from the accepted answer:</p>
<p>In parent document:</p>
<pre><code><iframe id="MyIFRAME" name="MyIFRAME"
src="http://localhost/child.html"
scrolling="auto" width="100%" frameborder="0">
no iframes supported...
</iframe>
</code></pre>
<p>In child:</p>
<pre><code><!-- ... -->
<body>
<script type="text/javascript">
function resizeIframe() {
var docHeight;
if (typeof document.height != 'undefined') {
docHeight = document.height;
}
else if (document.compatMode && document.compatMode != 'BackCompat') {
docHeight = document.documentElement.scrollHeight;
}
else if (document.body
&& typeof document.body.scrollHeight != 'undefined') {
docHeight = document.body.scrollHeight;
}
// magic number: suppress generation of scrollbars...
docHeight += 20;
parent.document.getElementById('MyIFRAME').style.height = docHeight + "px";
}
parent.document.getElementById('MyIFRAME').onload = resizeIframe;
parent.window.onresize = resizeIframe;
</script>
</body>
</code></pre>
<p><strong>BTW:</strong> This will only work if parent and child are in the same domain due to a restriction in JavaScript for security reasons...</p>
|
<p>You could either just use a scripting language to include the page into the parent page, other wise, you might want to try one of these javascript methods:</p>
<p><a href="http://brondsema.net/blog/index.php/2007/06/06/100_height_iframe" rel="nofollow noreferrer">http://brondsema.net/blog/index.php/2007/06/06/100_height_iframe</a>
<a href="http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_22840093.html" rel="nofollow noreferrer">http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_22840093.html</a></p>
|
<p>I might be missing something here, but adding <code>scrolling=no</code> as an attribute to the <code>iframe</code> tag normally gets rid of the scrollbars.</p>
| 8,291
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.