instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>In terms of performance and optimizations:</p>
<ul>
<li>When constructing a table in SQL Server, does it matter what order I put the columns in?</li>
<li>Does it matter if my primary key is the first column?</li>
<li>When constructing a multi-field index, does it matter if the columns are adjacent?</li>
<li>Using ALTER TABLE syntax, is it possible to specify in what position I want to add a column?
<ul>
<li>If not, how can I move a column to a difference position?</li>
</ul></li>
</ul>
|
<p>In SQL Server 2005, placement of nullable variable length columns has a space impact - placing nullable variable size columns at the end of the definition can result in less space consumption.</p>
<p>SQL Server 2008 adds the "SPARSE" column feature which negates this difference.</p>
<p>See <a href="https://web.archive.org/web/20210119185209/http://zine.net.pl/blogs/sqlgeek/archive/2008/06/06/en-column-order-does-it-matter.aspx" rel="nofollow noreferrer">here</a>.</p>
|
<p>For the first bullet:</p>
<p><strong>Yes</strong>, column order <em>does</em> matter, at least if you are using the deprecated BLOBs <code>image</code>, <code>text</code>, or <code>ntext</code>, and using SQL Server <= 2005.</p>
<p>In those cases, you should have those columns at the 'end' of the table, and there is a performance hit every time you retrieve one.</p>
<p>If you're retrieving the data from such a table using a DAL, this is the perfect place for the <a href="http://en.wikipedia.org/wiki/Lazy_loading" rel="nofollow noreferrer">Lazy Load</a> pattern.</p>
| 5,520
|
<p>I'm looking to the equivalent of Windows <a href="http://msdn.microsoft.com/fr-fr/library/yeby3zcb.aspx" rel="noreferrer"><code>_wfopen()</code></a> under Mac OS X. Any idea?</p>
<p>I need this in order to port a Windows library that uses <code>wchar*</code> for its File interface. As this is intended to be a cross-platform library, I am unable to rely on how the client application will get the file path and give it to the library.</p>
|
<p>POSIX API in Mac OS X are usable with UTF-8 strings. In order to convert a wchar_t string to UTF-8, it is possible to use the CoreFoundation framework from Mac OS X. </p>
<p>Here is a class that will wrap an UTF-8 generated string from a wchar_t string.</p>
<pre><code>class Utf8
{
public:
Utf8(const wchar_t* wsz): m_utf8(NULL)
{
// OS X uses 32-bit wchar
const int bytes = wcslen(wsz) * sizeof(wchar_t);
// comp_bLittleEndian is in the lib I use in order to detect PowerPC/Intel
CFStringEncoding encoding = comp_bLittleEndian ? kCFStringEncodingUTF32LE
: kCFStringEncodingUTF32BE;
CFStringRef str = CFStringCreateWithBytesNoCopy(NULL,
(const UInt8*)wsz, bytes,
encoding, false,
kCFAllocatorNull
);
const int bytesUtf8 = CFStringGetMaximumSizeOfFileSystemRepresentation(str);
m_utf8 = new char[bytesUtf8];
CFStringGetFileSystemRepresentation(str, m_utf8, bytesUtf8);
CFRelease(str);
}
~Utf8()
{
if( m_utf8 )
{
delete[] m_utf8;
}
}
public:
operator const char*() const { return m_utf8; }
private:
char* m_utf8;
};
</code></pre>
<p>Usage:</p>
<pre><code>const wchar_t wsz = L"Here is some Unicode content: éà€œæ";
const Utf8 utf8 = wsz;
FILE* file = fopen(utf8, "r");
</code></pre>
<p>This will work for reading or writing files.</p>
|
<p>If you're using Cocoa it's fairly easy with NSString. Just load the UTF16 data in using -initWithBytes:length:encoding: (or perhaps -initWithCString:encoding:) and then get a UTF8 version by calling UTF8String on the result. Then, just call fopen with your new UTF8 string as the param.</p>
<p>You can definitely call fopen with a UTF-8 string, regardless of language - can't help with C++ on OSX though - sorry.</p>
| 3,337
|
<p>I have some SQL Server DTS packages that import data from a FoxPro database. This was working fine until recently. Now the script that imports data from one of the FoxPro tables bombs out about 470,000 records into the import. I'm just pulling the data into a table with nullable varchar fields so I'm thinking it must be a weird/corrupt data problem.</p>
<p>What tools would you use to track down a problem like this?</p>
<p>FYI, this is the error I'm getting:</p>
<blockquote>
<p>Data for source column 1 ('field1') is not available. Your provider may require that all Blob columns be rightmost in the source result set.</p>
</blockquote>
<p>There should not be any blob columns in this table.</p>
<hr>
<p>Thanks for the suggestions. I don't know if it a corruption problem for sure. I just started downloading FoxPro from my MSDN Subscription, so I'll see if I can open the table. SSRS opens the table, it just chokes before running through all the records. I'm just trying to figure out which record it's having a problem with.</p>
|
<p><a href="http://www.cmstory.com/_cm/CMrepair.zip" rel="nofollow noreferrer">Cmrepair</a> is an excellent freeware utility to repair corrupted .DBF files.</p>
|
<p>@Lance:</p>
<p>if you have access to Visual FoxPro command line window, type:</p>
<pre><code>SET TABLEVALIDATE 11
USE "YourTable" EXCLUSIVE && If the table is damaged VFP must display an error here
PACK && To reindex the table and deleted "marked" records
PACK MEMO && If you have memo fields
</code></pre>
<p>After doing that, the structure of the table must ve valid, if you want to see fields with invalid data, you can try:</p>
<pre><code>SELECT * FROM YourTable WHERE EMPTY(YourField) && All records with YourField empty
SELECT * FROM YourTable WHERE LEN(YourMemoField) > 200 && All records with a long memo field, there can be corrupted data
</code></pre>
<p>etc. </p>
| 3,151
|
<p>Let's say you want to save a bunch of files somewhere, for instance in BLOBs. Let's say you want to dish these files out via a web page and have the client automatically open the correct application/viewer.</p>
<p>Assumption: The browser figures out which application/viewer to use by the mime-type (content-type?) header in the HTTP response.</p>
<p>Based on that assumption, in addition to the bytes of the file, you also want to save the MIME type.</p>
<p>How would you find the MIME type of a file? I'm currently on a Mac, but this should also work on Windows. </p>
<p>Does the browser add this information when posting the file to the web page?</p>
<p>Is there a neat python library for finding this information? A WebService or (even better) a downloadable database?</p>
|
<p>The python-magic method suggested by <a href="https://stackoverflow.com/a/2133843/5337834">toivotuo</a> is outdated. <a href="http://github.com/ahupp/python-magic" rel="noreferrer">Python-magic's</a> current trunk is at Github and based on the readme there, finding the MIME-type, is done like this.</p>
<pre><code># For MIME types
import magic
mime = magic.Magic(mime=True)
mime.from_file("testdata/test.pdf") # 'application/pdf'
</code></pre>
|
<p>I 've tried a lot of examples but with Django <a href="http://mutagen.readthedocs.io" rel="nofollow noreferrer">mutagen</a> plays nicely. </p>
<p>Example checking if files is <code>mp3</code> </p>
<pre><code>from mutagen.mp3 import MP3, HeaderNotFoundError
try:
audio = MP3(file)
except HeaderNotFoundError:
raise ValidationError('This file should be mp3')
</code></pre>
<p>The downside is that your ability to check file types is limited, but it's a great way if you want not only check for file type but also to access additional information.</p>
| 6,518
|
<p>In .Net you can read a string value into another data type using either <code><datatype>.parse</code> or <code>Convert.To<DataType></code>. </p>
<p>I'm not familiar with the fundamentals of parse versus convert so I am always at a loss when asked which one is better/faster/more appropriate. </p>
<p>So - which way is best in what type of circumstances?</p>
|
<p>The <code>Convert.ToXXX()</code> methods are for objects that might be of the correct or similar type, while <code>.Parse()</code> and <code>.TryParse()</code> are specifically for strings:</p>
<pre><code>//o is actually a boxed int
object o = 12345;
//unboxes it
int castVal = (int) 12345;
//o is a boxed enum
object o = MyEnum.ValueA;
//this will get the underlying int of ValueA
int convVal = Convert.ToInt32( o );
//now we have a string
string s = "12345";
//this will throw an exception if s can't be parsed
int parseVal = int.Parse( s );
//alternatively:
int tryVal;
if( int.TryParse( s, out tryVal ) ) {
//do something with tryVal
}
</code></pre>
<p>If you compile with optimisation flags TryParse is very quick - it's the best way to get a number from a string. However if you have an object that might be an int or might be a string Convert.ToInt32 is quicker.</p>
|
<p>There is also the DirectCast method which you should use only if you are sure what the type of the object is. It is faster, but doesn't do any proper checks. I use DirectCast when I'm extracting values from a loosely typed DataTable when I know the type for each column.</p>
| 3,906
|
<p>How stable is WPF not in terms of stability of a WPF program, but in terms of the 'stability' of the API itself. </p>
<p>Let me explain: </p>
<p>Microsoft is notorious for changing its whole methodology around with new technology. Like with the move from silverlight 1 to silverlight 2. With WPF, I know that MS changed a bunch of stuff with the release of the .NET service pack. I don't know how much they changed things around. So the bottom line is, in your opinion are they going to revamp the system again with the next release or do you think that it is stable enough now that they won't change the bulk of the system. I hate to have to unlearn stuff with every release. </p>
<p>I hope that the question wasn't too long winded.</p>
|
<p>MS do have a history of "fire and movement" with regards to introducing new technology into their development stack, but they also have a strong history of maintaining support for the older stuff, and backwards-compatibility. WPF seems to be getting stuff added to it with each new release of the framework but the things you learn aren't being superceded or invalidated.</p>
<p>The only breaking change I've seen in my own WPF applications with a new release of the framework was one recently in 3.5 SP1, and that was because we were unknowingly relying on a bug to get a certain behaviour from our code. We adjusted the XAML to be more correct and it started working fine.</p>
<p>So yeah, I think WPF is pretty "stable" as a client-side development technology.</p>
|
<p>WPF is pretty stable as far as changes go. Silverlight is still in flux. Though you may watch out since silverlight brought the concept of the state manager(instead of implementing triggers) which may get adopted in wpf... </p>
<p>If that happens there will be multiple ways to defining control templates and behavior...</p>
<p>and that will be a headache.</p>
| 5,142
|
<p>Can you use CMFCVisualManager with a dialog based application to change the applications appearance? If so how is it done?</p>
<p>The idea is to change the shape, colour etc. of controls such as push buttons using the MFC Feature Pack released with MSVC 2008.</p>
|
<p>No, can't be done, at least not if you're talking about the Feature Pack version. Version 10 of the BCGSoft libraries do have this functionality, see for example: <a href="http://www.bcgsoft.com/bcgcontrolbarpro-versions.htm" rel="nofollow noreferrer">http://www.bcgsoft.com/bcgcontrolbarpro-versions.htm</a> and <a href="http://www.bcgsoft.com/images/SkinnedBuiltInDlgs.jpg" rel="nofollow noreferrer">http://www.bcgsoft.com/images/SkinnedBuiltInDlgs.jpg</a>. The MFC feature pack is more or less the previous version of the BCGSoft libraries, MS bought a license from them.</p>
|
<p>You need to add the Common Controls manifest to your project resources. Here is the code for the manifest file:</p>
<pre><code><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="Program Name"
type="win32"
/>
<description>Description of Program</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
</code></pre>
| 9,820
|
<p>I'm developing some cross platform software targeting Mono under Visual Studio and would like to be able to build the installers for Windows and Linux (Ubuntu specifically) with a single button click. I figure I could do it by calling cygwin from a post-build event, but I was hoping for at best a Visual Studio plugin or at worst a more Windows-native way of doing it. It seems like the package format is fairly simple and this must be a common need.</p>
<p>edit: Re-asked question under other account due to duplicate login issue.</p>
|
<p>I am not aware of any plugin that does it natively, especially since Mono users seem to prefer <a href="http://www.monodevelop.com/Main_Page" rel="nofollow noreferrer">MonoDevelop</a>.</p>
<p>However, it should be possible to use Cygwin and a custom MSBuild Task or Batch file in order to achieve that by using the native .deb creation tools.</p>
|
<p>If you don't mind using Java tools it's possible to build Debian packages with <a href="https://github.com/tcurdt/jdeb" rel="nofollow">jdeb</a> in an Ant script. That's probably lighter than relying on Cygwin.</p>
| 2,526
|
<p>I'd like to write a script/batch that will bunch up my daily IIS logs and zip them up by month.</p>
<p>ex080801.log which is in the format of ex<em>yymmdd</em>.log</p>
<p>ex080801.log - ex080831.log gets zipped up and the log files deleted.</p>
<p>The reason we do this is because on a heavy site a log file for one day could be 500mb to 1gb so we zip them up which compresses them by 98% and dump the real log file. We use webtrend to analyze the log files and it is capable of reading into a zip file.</p>
<p>Does anyone have any ideas on how to script this or would be willing to share some code?</p>
|
<p>You'll need a command line tool to zip up the files. I recommend <a href="http://www.7-zip.org/download.html" rel="noreferrer">7-Zip</a> which is free and easy to use. The self-contained command line version (7za.exe) is the most portable choice.</p>
<p>Here's a two-line batch file that would zip the log files and delete them afterwards:</p>
<pre><code>7za.exe a -tzip ex%1-logs.zip %2\ex%1*.log
del %2\ex%1*.log
</code></pre>
<p>The first parameter is the 4 digit year-and-month, and the second parameter is the path to the directory containing your logs. For example: <code>ziplogs.bat 0808 c:\logs</code></p>
<p>It's possible to get more elaborate (i.e. searching the filenames to determine which months to archive). You might want to check out the Windows <a href="http://technet.microsoft.com/en-us/library/bb490907.aspx" rel="noreferrer">FINDSTR</a> command for searching input text with regular expressions.</p>
|
<p>Regex will do the trick... create a perl/python/php script to do the job for you..<br>
I'm pretty sure windows batch file can't do regex.</p>
| 4,914
|
<p>My users are having an intermittent error when using a Windows Forms application built in VB.NET 3.5. Apparently when they click on the form and the form re-paints, a red 'X' will be painted over the MenuStrip control and the app will crash with the following error. </p>
<p>Has anyone seen this before? Can someone point me in the right direction? </p>
<pre><code> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
at System.Windows.Forms.ToolStripItemCollection.get_Item(Int32 index)
at System.Windows.Forms.ToolStrip.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.MenuStrip.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
</code></pre>
|
<p>First rule of working with Visual Studio:</p>
<ul>
<li><strong>Install <a href="http://www.jetbrains.com/resharper/" rel="noreferrer">ReSharper</a></strong></li>
</ul>
|
<p>I have a tip regarding the "Track Active Item" option mentioned above, for when working with big projects. It's posted here:</p>
<p><a href="https://stackoverflow.com/questions/31163/forcing-the-solution-explorer-to-select-the-file-in-the-editor-in-visual-studio#46193">Forcing the Solution Explorer to select the file in the editor in visual studio 2005</a></p>
| 6,794
|
<p>I have a FlashForge CreatorX (MakerBot clone) that's been working fine for about 15 months. Int he past month, I started noticing "thin" layers in some of my ABS prints. I finally tracked the issue down to the extruder gear grinding the filament (after a while, enough filament had ground off that the gear teeth were filled with plastic). I cleaned the gear twice before giving up on ABS and switching to PLA. Everything seemed ok until the PLA started doing the same thing during an overnight print (thin layers on prints, audible skipping during filament feed). </p>
<p>Raising the temperature on the extruder seems to fix the problem, but I'm now extruding PLA at 242 °C, much higher than I used to need. I worry that continued printing at this temperature will increase wear on the thermistor and increase my chances of clogging PLA in the gear (an issue I've had twice before). </p>
<p>Are there any common issues that cause this issue of filament not feeding properly? I've tried cleaning out the extruder head with wire and there don't seem to be any clogs…</p>
|
<p>Usually there is no need to clean the hotend, as filament sticks well to itself rather than to the inside of the hotend. If there are remains - the simplest way to clean it up is to extrude 5-10 cm of new filament, which will gather all remainings clean the hotend.</p>
<p>The above concerns changing filament in the same group of plastic. So if you print PLA you can switch colors/manufacturers and so on without issues. The same goes for ABS.</p>
<p>There is also usually no problem when switching from PLA to ABS.</p>
<p>The worst scenario is to switch from ABS to PLA. This is because the extruding temperature of these two materials is different. Unfortunately ABS can have such a high melting temperature that the PLA will burn. So having a dirty hotend with ABS remainings, there is no way to extrude PLA to clean the hotend because the PLA temperature will not result in melting ABS. It can eventually lead to total plug of HE.</p>
<p>So what can you do when you are in such a situation (ABS -> PLA)?</p>
<p>You can clean the hotend first with ABS. Extrude some, wait until it is cold, ease the springs and pull or tear out the filament from the hotend.</p>
<p>If you are stuck you can use special drills to clean the nozzle.</p>
<p>But to totally omit the issue you can have two hotends :) One for ABS and one for PLA ;) But I think you can manage cleaning if you apply what I've written above.</p>
|
<p>Or you can use atomic nozle clianning!It woks fine for me :)
<a href="https://www.youtube.com/watch?v=04T8zdgyh3E" rel="nofollow">https://www.youtube.com/watch?v=04T8zdgyh3E</a></p>
| 293
|
<p>I've got two models: Message and Attachment. Each attachment is attached to a specific message, using a ForeignKey on the Attachment model. Both models have an auto_now DateTimeField called updated. I'm trying to make it so that when any attachment is saved, it also sets the updated field on the associated message to now. Here's my code:</p>
<pre><code>def save(self):
super(Attachment, self).save()
self.message.updated = self.updated
</code></pre>
<p>Will this work, and if you can explain it to me, why? If not, how would I accomplish this?</p>
|
<p>You would also need to then save the message. Then it that should work.</p>
|
<p>DateTime fields with auto_now are automatically updated upon calling <code>save()</code>, so you do not need to update them manually. Django will do this work for you.</p>
| 4,131
|
<p>I've read that it is possible to add a method to an existing object (i.e., not in the class definition) in Python. </p>
<p>I understand that it's not always good to do so. But how might one do this?</p>
|
<p>In Python, there is a difference between functions and bound methods.</p>
<pre><code>>>> def foo():
... print "foo"
...
>>> class A:
... def bar( self ):
... print "bar"
...
>>> a = A()
>>> foo
<function foo at 0x00A98D70>
>>> a.bar
<bound method A.bar of <__main__.A instance at 0x00A9BC88>>
>>>
</code></pre>
<p>Bound methods have been "bound" (how descriptive) to an instance, and that instance will be passed as the first argument whenever the method is called.</p>
<p>Callables that are attributes of a class (as opposed to an instance) are still unbound, though, so you can modify the class definition whenever you want:</p>
<pre><code>>>> def fooFighters( self ):
... print "fooFighters"
...
>>> A.fooFighters = fooFighters
>>> a2 = A()
>>> a2.fooFighters
<bound method A.fooFighters of <__main__.A instance at 0x00A9BEB8>>
>>> a2.fooFighters()
fooFighters
</code></pre>
<p>Previously defined instances are updated as well (as long as they haven't overridden the attribute themselves):</p>
<pre><code>>>> a.fooFighters()
fooFighters
</code></pre>
<p>The problem comes when you want to attach a method to a single instance:</p>
<pre><code>>>> def barFighters( self ):
... print "barFighters"
...
>>> a.barFighters = barFighters
>>> a.barFighters()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: barFighters() takes exactly 1 argument (0 given)
</code></pre>
<p>The function is not automatically bound when it's attached directly to an instance:</p>
<pre><code>>>> a.barFighters
<function barFighters at 0x00A98EF0>
</code></pre>
<p>To bind it, we can use the <a href="https://docs.python.org/3/library/types.html#types.MethodType" rel="noreferrer">MethodType function in the types module</a>:</p>
<pre><code>>>> import types
>>> a.barFighters = types.MethodType( barFighters, a )
>>> a.barFighters
<bound method ?.barFighters of <__main__.A instance at 0x00A9BC88>>
>>> a.barFighters()
barFighters
</code></pre>
<p>This time other instances of the class have not been affected:</p>
<pre><code>>>> a2.barFighters()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: A instance has no attribute 'barFighters'
</code></pre>
<p>More information can be found by reading about <a href="https://docs.python.org/3/howto/descriptor.html" rel="noreferrer">descriptors</a> and <a href="https://web.archive.org/web/20090124004817/http://www.onlamp.com/pub/a/python/2003/04/17/metaclasses.html" rel="noreferrer">metaclass</a> <a href="http://www.gnosis.cx/publish/programming/metaclass_2.html" rel="noreferrer">programming</a>.</p>
|
<p>Apart from what others said, I found that <code>__repr__</code> and <code>__str__</code> methods can't be monkeypatched on object level, because <code>repr()</code> and <code>str()</code> use class-methods, not locally-bounded object methods:</p>
<pre><code># Instance monkeypatch
[ins] In [55]: x.__str__ = show.__get__(x)
[ins] In [56]: x
Out[56]: <__main__.X at 0x7fc207180c10>
[ins] In [57]: str(x)
Out[57]: '<__main__.X object at 0x7fc207180c10>'
[ins] In [58]: x.__str__()
Nice object!
# Class monkeypatch
[ins] In [62]: X.__str__ = lambda _: "From class"
[ins] In [63]: str(x)
Out[63]: 'From class'
</code></pre>
| 2,339
|
<p>We have a custom-built Flash-based video player that I maintain, and it needs to support preroll ads and ideally both progressive video playback and streaming depending on a server switch.</p>
<p>I've been working with the flvPlayback component but am finding myself a little out of my depth. Are there any good tutorials or resources for understanding the difference between netstream and flvPlayback? Or is one part of the other? Have googled without success.</p>
<p>For the preroll ads we'll probably use DART In-Stream, which is part of the reason I feel I'm losing a grip on the best way to structure this thing.</p>
<p>Any help with best practices or links most appreciated - ta!</p>
<p>EDIT - Update: I wrote a player by hand and got it more or less working with everything it needed to do, but we did migrate to JW Player across all the web properties in the end, about six months later. It's very reliable and well-supported, it integrated with the DART system well, and the designers found it easy to skin.</p>
|
<p>I would definitely have a look at the JW Flash Media Player:</p>
<p><a href="http://www.jeroenwijering.com/?item=JW_FLV_Player" rel="nofollow noreferrer">http://www.jeroenwijering.com/?item=JW_FLV_Player</a></p>
<p>It's Open Source, and I found the Source quite clean and easy to understand, it also supports playlists. I don't know the DART In-Stream stuff, but maybe you could "creatively use" the playlist feature to achieve that?</p>
<p>Source Code is available here:</p>
<p><a href="http://code.jeroenwijering.com/trac/" rel="nofollow noreferrer">http://code.jeroenwijering.com/trac/</a></p>
|
<p>I don't really like the flvPlayback-component, it's hard to handle both implementation wise and somewhat tricky to skin nicely and it's also quite bloated. So I'd opt to use either the JW Flash Media Player as recommended by Michael above or rolling my own entirely. </p>
| 2,926
|
<p>What are the steps required to enable Hibernate's second-level cache, when using the Java Persistence API (annotated entities)? How do I check that it's working? I'm using JBoss 4.2.2.GA.</p>
<p>From the Hibernate documentation, it seems that I need to enable the cache and specify a cache provider in <em>persistence.xml</em>, like:</p>
<pre><code><property name="hibernate.cache.use_second_level_cache"
value="true" />
<property name="hibernate.cache.provider_class"
value="org.hibernate.cache.HashtableCacheProvider" />
</code></pre>
<p>What else is required? Do I need to add <em>@Cache</em> annotations to my JPA entities?</p>
<p>How can I tell if the cache is working? I have tried accessing cache statistics after running a Query, but <em>Statistics.getSecondLevelCacheStatistics</em> returns null, perhaps because I don't know what 'region' name to use.</p>
|
<p>I believe you need to add the cache annotations to tell hibernate how to use the second-level cache (read-only, read-write, etc). This was the case in my app (using spring / traditional hibernate and ehcache, so your mileage may vary). Once the caches were indicated, I started seeing messages that they were in use from hibernate.</p>
|
<p>Follow-up: in the end, after adding annotations, I have it working with EhCache, i.e.</p>
<pre><code><property name="hibernate.cache.provider_class"
value="net.sf.ehcache.hibernate.EhCacheProvider" />
</code></pre>
| 7,707
|
<p>I've been interested in 3D printing for the past month however, I have noticed that it's sort of a "reserved" topic. Meaning that everyone who talks about it, has already some basic knowledge about the topic. What are some good resources for someone who wants to start learning from zero? My main goal is to acquire enough knowledge in order to build my own 3D printer.</p>
|
<p>You can learn a lot just by reading the forums. I'll just list a few that are quite popular...</p>
<p><a href="http://forums.reprap.org/" rel="nofollow">Reprap Forums</a> - Has a ton of information on DIY printers including build logs and posts dealing with many issues.</p>
<p><a href="http://www.soliforum.com" rel="nofollow">Soliforum</a> - Large user base with lots of information. Not sure what it's standing is now that Solidoodle is gone but I'm sure the forum will stick around.</p>
<p><a href="http://forum.seemecnc.com/" rel="nofollow">SeeMeCNC</a> - Support forum for SeeMeCNC, has a lot of information for Delta printers and also other printers.</p>
<p>There aren't many books that I know of...Make magazine has done a few issues on 3D printing that you could try to obtain. I'm not sure what your idea of building a printer is, do you want to design your own or follow someone's instructions and put one together? Designing one would require some basic hardware and engineering knowledge.</p>
<p>All that said, the best learning experience would be buying a kit and learning as you go. You'll never read in a book what you will learn from having your own printer.</p>
|
<p>ADDITIVE MANUFACTURING TECHNOLOGIES
3D Printing, Rapid Prototyping, and
Direct Digital Manufacturing</p>
<p>Springer</p>
<p>I think its a perfect book. A lot of details to all technologies.
*Beware there is math and physics involved.</p>
<p><a href="https://i.stack.imgur.com/52f1O.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/52f1O.jpg" alt="enter image description here"></a></p>
| 271
|
<p>What is the best way to get and set the meta data for mp3, mp4, avi files etc. with .NET?</p>
|
<p>I use <a href="http://mediainfo.sourceforge.net/en" rel="noreferrer">MediaInfo</a> with my C# apps, gives you a lot of information about media files.</p>
|
<p>Looks like MediaInfo is read-only at this point, by the way: <a href="http://sourceforge.net/forum/message.php?msg_id=4241318&abmode=1" rel="nofollow noreferrer">http://sourceforge.net/forum/message.php?msg_id=4241318&abmode=1</a></p>
<p>Very cool project, though. It's fun finding out about all this cool stuff here on SO.</p>
| 3,056
|
<p>It seems that Silverlight/WPF are the long term future for user interface development with .NET. This is great because as I can see the advantage of reusing XAML skills on both the client and web development sides. But looking at WPF/XAML/Silverlight they seem very large technologies and so where is the best place to get start?</p>
<p>I would like to hear from anyone who has good knowledge of both and can recommend which is a better starting point and why.</p>
|
<p>Should you learn ASP.NET or Winforms first? ASP or MFC? HTML or VB? C# or VB? </p>
<p>Set aside the idea that there is a logical progression through what has become a highly complex interwoven set of technologies, and take a step back and ask yourself a series of questions:</p>
<ul>
<li>What are your goals; how do you want to balance profit against enjoyment</li>
<li>Are you short term oriented or in for the long haul</li>
<li>Are you the type of person who likes to get good at something and do it a lot or do you get bored once you fully understand it?</li>
</ul>
<p>The next and hardest step is to come to accept that any advice you are given is bound to be wrong; and the longer the time horizon the more likely it is to be incorrect. If the advice is for more than six to 12 months, the probability the advice is wildly incorrect approaches 1. </p>
<p>I can only tell you my story, quickly. In 2000 I was happy as a consultant working profitably in C++ on Windows applications, writing about ASP.NET and WinForms. then I saw C# and the world turned upside down. I never went back. </p>
<p>Two years ago I had the same kind of revelation, only an order of magnitude bigger, stronger and with more conviction about Silverlight. Yes, WPF is magnificent, and it may be that I'm all wet about this, but I believe in my gut that Silverlight changes everything. There was no doubt then and there is no doubt today that Silverlight is the most important development platform for Microsoft since .NET (certainly) and possibly since the switch to C++. </p>
<p>In a nutshell, here is why. I don't understand where its limitations are. With most platforms I do: you can do this, but you can't do that. WPF is a pretty good case in point, as was ASP.Net and WinForms and, well really everything until now.<br>
With Silverlight, I don't see the boundaries yet. Silverlight has already leaped off the desktop onto phones, and I don't see any reason for it to stop there. Yes, it is true, it is bound by the browser, but I see that less as a jail cell than as a tank in which Silverlight will be riding over lots of terrain (it must be very late, I should go to bed). </p>
<p>In any case, for now, learning Silverlight is a gas, there is a lot of material on the <a href="http://www.silverlight.net/" rel="noreferrer">Silverlight.net site</a>, and what is the very best thing about learning Silverlight is that if you don't see what you need you can holler at me and I'll make sure you get it pretty quickly.</p>
<p>Enjoy, good luck and the dirty little secret is you'll be fine whichever you choose. It's all just software.</p>
<p>-jesse</p>
<hr>
<p>Jesse Liberty
<a href="http://jesseliberty.com/" rel="noreferrer">"Silverlight Geek"</a></p>
|
<p>Some tips at <a href="https://stackoverflow.com/questions/60620/getting-started-with-silverlight-development">Getting started with Silverlight Development</a></p>
| 8,647
|
<p>Starting a new project and would like to use one of the MVC framworks. <a href="http://www.asp.net/mvc/" rel="nofollow noreferrer">ASP.NET MVC</a> is still in preview but <a href="http://springframework.net/" rel="nofollow noreferrer">Spring.net</a> is in production and has a history with Java. I'd like to know the general lowdown between the two.</p>
<p>Current questions..<br>
What are the major feature differences?<br>
What about deployment/hosting issues?<br>
Future support? Do you think Spring.net will fade once ASP.NET MVC is in production.<br>
Current Support? I saw the Jeff twitting about a breaking change in the next preview. </p>
<p>Thanks!</p>
|
<p>I am a little confused by the question. Spring.Net is a dependency injection framework that you can use in ASP.NET MVC. I kind of based my answer off what you are actually asking though. The difference between ASP.NET MVC and another MVC framework that runs in ASP.NET.</p>
<p>If you are worried about using ASP.NET MVC in production since it is not even in beta yet, then you may want to check out <a href="http://www.castleproject.org/MonoRail/" rel="nofollow noreferrer">MonoRail</a> as an alternate. There are some differences in features, but the two are pretty close in terminology and how MVC is implemented. To learn differences, <a href="https://stackoverflow.com/questions/24165/from-monorail-to-aspnet-mvc">here is a question</a> that was posted, that you might want to monitor. I think once ASP.NET hits release, that most Microsoft shops will switch to it. With ASP.NET MVC still being developed, you will run into breaking changes that you will have to change when you upgrade to the next release. That goes with the territory of living on the edge. You just need to read the release notes before jumping to the latest release.</p>
|
<p>I have an impression that Spring.NET never really took off, or at least not as much as <a href="http://www.castleproject.org/MonoRail/" rel="nofollow noreferrer">Castle Project Monorail</a>. </p>
<p>From what I understand, Spring.NET has also departed from Java Spring's implementation, so there will a steeper than expected learning curve if you are coming from Java. From <a href="http://springframework.net/overview.html" rel="nofollow noreferrer">Spring.NET's overview</a>:</p>
<blockquote>
<p>The design of Spring.NET is based on
the Java version of the Spring
Framework, which has shown real-world
benefits and is used in thousands of
enterprise applications world wide.
Spring .NET is not a quick port from
the Java version, but rather a
'spiritual port' based on following
proven architectural and design
patterns in that are not tied to a
particular platform.</p>
</blockquote>
<p>As for your other questions, the breadth of the topics make them a bit difficult to answer in one go, but I am hoping Phil Haack will see this question and respond. :)</p>
| 6,463
|
<p>I'm using Castle Windsor to do some dependency injection, specifically I've abstracted the DAL layer to interfaces that are now being loaded by DI.</p>
<p>Once the project is developed & deployed all the .bin files will be in the same location, but for while I'm developing in Visual Studio, the only ways I can see of getting the dependency injected project's .bin file into the startup project's bin folder is to either have a post-build event that copies it in, or to put in a manual reference to the DAL project to pull the file in.</p>
<p>I'm not totally thrilled with either solution, so I was wondering if there was a 'standard' way of solving this problem?</p>
|
<p>Could you set the build output path of the concrete DAL project to be the bin folder of the dependent project? </p>
|
<p>Mike: Didn't think of that, that could work, have to remember to turn off copy-local for any libraries / projects that are common between them</p>
| 5,156
|
<p>My company is going to be storing sensitive data for our customers, and will be encrypting data using one of the managed .NET encryption algorithm classes. Most of the work is done, but we haven't figured out how/where to store the key. I've done some light searching and reading, and it seems like a hardware solution might be the most secure. Does anyone have any recommendations on a key storage solution or method?</p>
<hr>
<p>Thanks for your replies, everyone.</p>
<p>spoulson, the issue is actually both the "scopes" that you mentioned. I suppose I should have been clearer.</p>
<p>The data itself, as well as the logic that encrypts it and decrypts it is abstracted away into an ASP.NET profile provider. This profile provider allows both encrypted profile properties as well as plain text ones. The encrypted property values are stored in exactly the same way the plain text ones are - with the obvious exception that they've been encrypted.</p>
<p>That said, the key will need to be able to be summoned for one of three reasons:</p>
<ol>
<li>The authorized web application, running on an authorized server, needs to encrypt data.</li>
<li>Same as #1, but for decrypting the data.</li>
<li>Authorized members of our business team need to view the encrypted data.</li>
</ol>
<p>The way I'm imagining it is that nobody would ever actually know the key - there would be a piece of software controlling the actual encrypting and decrypting of data. That said, the key still needs to come from <em>somewhere</em>.</p>
<p>Full disclosure - if you couldn't already tell, I've never done anything like this before, so if I'm completely off base in my perception of how this should work, by all means, let me know.</p>
|
<p>There only two real solutions for (the technical aspect of) this problem.
Assuming it's only the application itself that needs access the key...</p>
<ol>
<li><p>Hardware Security Module (HSM) - usually pretty expensive, and not simple to implement. Can be dedicated appliance (e.g. nCipher) or specific token (e.g. Alladin eToken). And then you still have to define how to handle that hardware...</p></li>
<li><p>DPAPI (Windows Data Protection API). There are classes for this in System.Security.Cryptography (ProtectedMemory, ProtectedStorage, etc). This hands off key management to the OS - and it handles it well. Used in "USER_MODE", DPAPI will lock decryption of the key to the single user that encrypted it.
(Without getting too detailed, the user's password is part of the encryption/decryption scheme - and no, changing the password does not foul it up.)</p></li>
</ol>
<p>ADDED: Best to use DPAPI for protecting your master key, and not encrypting your application's data directly. And don't forget to set strong ACLs on your encrypted key...</p>
|
<p><a href="http://www.microsoft.com/rms" rel="nofollow noreferrer">Microsoft Rights Management Server (RMS)</a> has a similar problem. It just solves it by encrypting its configuration with a master password. ...A password on a password, if you will.</p>
| 7,280
|
<p>I have about 150 000 rows of data written to a database everyday. These row represent outgoing articles for example. Now I need to <strong>show a graph using <a href="http://www.microsoft.com/technet/prodtechnol/sql/2005/2005ssrs.mspx" rel="nofollow noreferrer">SSRS</a> that show the average number of articles per day over time</strong>. <strong>I also need to have a information about the actual number of articles from yesterday</strong>.</p>
<p>The idea is to have a aggregated view on all our transactions and have something that can indicate that something is wrong (that we for example send out 20% less articles than the average).</p>
<p>My idea is to have yesterdays data moved into <a href="http://www.microsoft.com/sql/technologies/analysis/default.mspx" rel="nofollow noreferrer">SSAS</a> every night and there store the aggregated value of number of transactions and the actual number of transaction from yesterdays data. Using SSAS would hopefully speed up the reports.</p>
<p><strong>Do you think this is the right idea? Should I skip SSAS and have reports straight on the raw data? I know how use reporting services on raw data using standard SQL queries but how would this change when querying SSAS? I don't know <a href="http://www.microsoft.com/sql/technologies/analysis/default.mspx" rel="nofollow noreferrer">SSAS</a> - where do I start ..?</strong></p>
|
<p>The neat thing with SSAS is that you can get those indicators that you talk about quite easily either by creating calculated measures or by using KPIs.</p>
<p>I started with <a href="https://rads.stackoverflow.com/amzn/click/com/0072260904" rel="nofollow noreferrer" rel="nofollow noreferrer">Delivering Business Intelligence with Microsoft SQL Server 2005</a>. It had some good introduction, but unfortunately it's too verbose when it comes to the details. But if you want to understand SSAS, OLAP and reporting using this framework it's a good start.</p>
<p>Mosha Pasumansky has a <a href="http://sqlblog.com/blogs/mosha/default.aspx" rel="nofollow noreferrer">blog</a> on SSAS and <a href="http://en.wikipedia.org/wiki/Multidimensional_Expressions" rel="nofollow noreferrer">MDX</a> with great <a href="http://www.mosha.com/msolap/" rel="nofollow noreferrer">links</a>.</p>
<p>Other than that I would recommend Microsofts Online books.</p>
|
<p>SSAS is an <a href="http://en.wikipedia.org/wiki/Extract,_transform,_load" rel="nofollow noreferrer">ETL</a> tool. Basically you get data from somewhere (your outgoing articles), do something to it (aggregate), and put it somewhere else (your aggregates table, data warehouse, etc). Check the link for details. </p>
<p>You probably won't be keeping all of the rows in the DB indefinitely and if you want to be able to report on longer trends you need in any case do some kind of aggregating of historical data. So making the reports use this historical data store as their source makes sense. You can then use it to do all kinds of fancy reporting.</p>
<p>TL;DR: Define your aggregated history table with your future reporting needs in mind. Use the SSAS to populate the table and refresh it from the daily updates. Report from that table. Further reading: Star Schemas and data warehousing.</p>
| 4,938
|
<p>Why does the following code sometimes causes an Exception with the contents "CLIPBRD_E_CANT_OPEN":</p>
<pre><code>Clipboard.SetText(str);
</code></pre>
<p>This usually occurs the first time the Clipboard is used in the application and not after that.</p>
|
<p>Actually, I think this is the <a href="https://cloudblogs.microsoft.com/enterprisemobility/2006/11/20/why-does-my-shared-clipboard-not-work-part-2/" rel="noreferrer">fault of the Win32 API</a>.</p>
<p>To set data in the clipboard, you have to <a href="http://msdn.microsoft.com/en-us/library/ms649048(VS.85).aspx" rel="noreferrer">open it</a> first. Only one process can have the clipboard open at a time. So, when you check, if another process has the clipboard open <em>for any reason</em>, your attempt to open it will fail.</p>
<p>It just so happens that Terminal Services keeps track of the clipboard, and on older versions of Windows (pre-Vista), you have to open the clipboard to see what's inside... which ends up blocking you. The only solution is to wait until Terminal Services closes the clipboard and try again.</p>
<p>It's important to realize that this is not specific to Terminal Services, though: it can happen with anything. Working with the clipboard in Win32 is a giant race condition. But, since by design you're only supposed to muck around with the clipboard in response to user input, this usually doesn't present a problem.</p>
|
<p>The difference between Cliboard.SetText and Cliboard.SetDataObject in WPF is that the text is not copied to the clipboard, only the pointer. I checked the source code. If we call SetDataObject(data, true) Clipoard.Flush() will also be called. Thanks to this, text or data is available even after closing the application. I think Windows applications only call Flush() when they are shutting down. Thanks to this, it saves memory and at the same time gives access to data without an active application.</p>
<p>Copy to clipboard:</p>
<pre><code>IDataObject CopyStringToClipboard(string s)
{
var dataObject = new DataObject(s);
Clipboard.SetDataObject(dataObject, false);
return dataObject;
}
</code></pre>
<p>Code when app or window is closed:</p>
<pre><code>try
{
if ((clipboardData != null) && Clipboard.IsCurrent(clipboardData))
Clipboard.Flush();
}
catch (COMException ex) {}
</code></pre>
<p>clipboardData is a window class field or static variable.</p>
| 9,423
|
<p>I know this is still gray territory and it is asked so many times within the 3D printing and maker community but I'm curious about the limits of 3D models and were it touches on Free Use and infringement. I'm not trying to push the envelope, I just want to be clear on the matter.</p>
<p>Is it legal if a design is rendered in a CAD program of a copyrighted material for <strong>no</strong> purpose of using, distributing, creating, mixing, internalizing, re-licensing under GPL/CC, or any unauthorized use outlined by the owner of the original work? For instance, if someone is demonstrating the abilities of a particular CAD and makes a mock-up of Mickey Mouse just to show the limits of said CAD and the STL/OBJ isn't released or distributed and a letter of intent is given along with the demonstration regarding the original work (in this case, Mickey), is that infringement? In this example, no loss of revenue or sales will affect the original owner, no claims of ownership is implied or stated, and no physical model will be created.</p>
<p>While considering all of this, I figured that it wasn't very much different than if an artist sat down and drew a picture of Mickey Mouse. As long as the picture isn't sold, distributed, or released, in my mind, that is the same thing as a 3D render.</p>
<p>To further the details of the 3D model, the render would be made from scratch and not imported, copied, or reverse engineered from any other work. Bottom line, it will be a likeness that is created but it will be as close to the real thing as possible to demonstrate capabilities of a particular program (such as organic shapes, stitching, grouping, layering, or any other facet and characterization of 3D modeling).</p>
<p>I already understand that it is recommended to err on the side of caution and steer clear of things like this but it is more of a curiosity than a request for legal advice regarding a specific case.</p>
<p>Can this be covered under Fair Use?</p>
<p>Since there is nothing to be made from creating the render, it isn't released or distributed to others, isn't re-licensed, and no ownership is implied/credit to the original owner is given, is this Free Use or copyright infringement?</p>
|
<p>Whether or not you sell, distribute, release, license, profit from, claim ownership, etc... of something does not matter for copyright law. Copyright prohibits the very act of well, <em>copying</em>. Specifically, if a work is protected by copyright, you can't (among other things)</p>
<blockquote>
<ul>
<li><p>make adaptations and arrangements of the work</p>
</li>
<li><p>make reproductions in any manner or form</p>
</li>
</ul>
</blockquote>
<p>without permission (or a license) from the copyright holder. Just because you do something privately, don't distribute or profit from it, does not make you exempt from this rule.</p>
<p>In some cases though, a fair use exception may apply. In the United States, uses that may be (but not necessarily are) fair are limited to:</p>
<blockquote>
<p>criticism, comment, news reporting, teaching (including multiple copies for classroom use), scholarship, or research</p>
</blockquote>
<p>Note that in Europe, teaching is usually not considered fair use.</p>
<p>So no, it would not in general be permitted to make a 3D model of a copyrighted work, even if you don't plan to do any of the things you listed with it. An artist would not be allowed to draw the picture of Mickey Mouse as you describe either. However, in the United States, your use could be construed as fair use for educational purposes. However, considering that you could equally as well have used some non-copyrighted work to demonstrate the limits of CAD (there's nothing specific to Mickey Mouse that makes him more suitable than any other model) I would recommend against this. An important argument in fair use is usually that there is no other option but to use the copyrighted work (e.g. in a class discussing pop music you have no option but to use excerpts of copyrighted lyrics).</p>
|
<p>Well I think it's a good question, but like what was already stated this question is extremely broad. I am however curious as well. If I take what has already been said literally and apply it to a 3D model of a palm tree, for example. From what y'all are saying, everyone that has ever made a 3D model after the first person in history made one is now in violation of copyright infringement... Not sure how that makes sense but I am going by what was said in the answers. Because if something is copyrighted and you make something that is similar in nature then I take it all foliage made in a 3D modelling program must be in violation of copyright infringement.</p>
<p>Unless y'all are referring to unique cases where someone was to make a unique piece of art and then someone else was to come along and reproduce it?</p>
<p>Tom said above that these would be copyright violations:</p>
<blockquote>
<p>make adaptations and arrangements of the work</p>
<p>make reproductions in any manner or form</p>
</blockquote>
<p>Well, reproducing a palm tree someone else has made or a blade of grass would then technically be a copyright violation, since someone has claimed a copyright on it and sold it in landscape packages for example.</p>
| 547
|
<p>I'm trying to call a 3rd party vendor's C DLL from vb.net 2005 and am getting <code>P/Invoke</code> errors. I'm successfully calling other methods but have hit a bottle-neck on one of the more complex. The structures involved are horrendous and in an attempt to simplify the troubleshooting I'd like to create a C++ DLL to replicate the problem. </p>
<p>Can somebody provide the smallest code snippet for a C++ DLL that can be called from .Net? I'm getting a <code>Unable to find entry point named XXX in DLL</code> error in my C++ dll. It should be simple to resolve but I'm not a C++ programmer.</p>
<p>I'd like to use a .net declaration for the DLL of</p>
<pre><code>Declare Function Multiply Lib "C:\MyDll\Debug\MyDLL.DLL" Alias "Multiply" (ByVal ParOne As Integer, ByVal byvalParTwo As Integer) As Integer
</code></pre>
|
<p>Try using the <a href="http://msdn.microsoft.com/en-us/library/3y1sfaz2.aspx" rel="nofollow noreferrer">__decspec(dllexport)</a> magic pixie dust in your C++ function declaration. This declaration sets up several things that you need to successfully export a function from a DLL. You may also need to use WINAPI or something similar:</p>
<pre><code>__declspec(dllexport) WINAPI int Multiply(int p1, int p2)
{
return p1 * p2;
}
</code></pre>
<p>The WINAPI sets up the function calling convention such that it's suitable for calling from a language such as VB.NET.</p>
|
<p>You can try to look at the exported functions (through DumpBin or Dependency Walker) and see if the names are mangled.</p>
| 6,009
|
<p>Ruby has two different exceptions mechanisms: Throw/Catch and Raise/Rescue.</p>
<p>Why do we have two?</p>
<p>When should you use one and not the other? </p>
|
<p>I think <a href="http://hasno.info/ruby-gotchas-and-caveats" rel="noreferrer">http://hasno.info/ruby-gotchas-and-caveats</a> has a decent explanation of the difference:</p>
<blockquote>
<p>catch/throw are not the same as raise/rescue. catch/throw allows you to quickly exit blocks back to a point where a catch is defined for a specific symbol, raise rescue is the real exception handling stuff involving the Exception object.</p>
</blockquote>
|
<p><a href="https://coderwall.com/p/lhkkug/don-t-confuse-ruby-s-throw-statement-with-raise" rel="noreferrer">https://coderwall.com/p/lhkkug/don-t-confuse-ruby-s-throw-statement-with-raise</a> offers an excellent explanation that I doubt I can improve on. To summarize, nicking some code samples from the blog post as I go:</p>
<ol>
<li><p><code>raise</code>/<code>rescue</code> are the closest analogues to the <code>throw</code>/<code>catch</code> construct you're familiar with from other languages (or to Python's <code>raise</code>/<code>except</code>). If you've encountered an error condition and you would <code>throw</code> over it in another language, you should <code>raise</code> in Ruby.</p></li>
<li><p>Ruby's <code>throw</code>/<code>catch</code> lets you break execution and climb up the stack looking for a <code>catch</code> (like <code>raise</code>/<code>rescue</code> does), but isn't really meant for error conditions. It should be used rarely, and is there just for when the "walk up the stack until you find a corresponding <code>catch</code>" behaviour makes sense for an algorithm you're writing but it wouldn't make sense to think of the <code>throw</code> as corresponding to an error condition.</p>
<p><a href="https://stackoverflow.com/questions/3716801/what-is-catch-and-throw-used-for-in-ruby/">What is catch and throw used for in Ruby?</a> offers some suggestions on nice uses of the <code>throw</code>/<code>catch</code> construct.</p></li>
</ol>
<p>The concrete behavioural differences between them include:</p>
<ul>
<li><p><code>rescue Foo</code> will rescue instances of <code>Foo</code> including subclasses of <code>Foo</code>. <code>catch(foo)</code> will only catch <em>the same object, <code>Foo</code></em>. Not only can you not pass <code>catch</code> a class name to catch instances of it, but it won't even do equality comparisons. For instance</p>
<pre><code>catch("foo") do
throw "foo"
end
</code></pre>
<p>will give you an <code>UncaughtThrowError: uncaught throw "foo"</code> (or an <code>ArgumentError</code> in versions of Ruby prior to 2.2)</p></li>
<li><p>Multiple rescue clauses can be listed...</p>
<pre><code>begin
do_something_error_prone
rescue AParticularKindOfError
# Insert heroism here.
rescue
write_to_error_log
raise
end
</code></pre>
<p>while multiple <code>catch</code>es need to be nested...</p>
<pre><code>catch :foo do
catch :bar do
do_something_that_can_throw_foo_or_bar
end
end
</code></pre></li>
<li><p>A bare <code>rescue</code> is equivalent to <code>rescue StandardError</code> and is an idiomatic construct. A "bare <code>catch</code>", like <code>catch() {throw :foo}</code>, will never catch anything and shouldn't be used.</p></li>
</ul>
| 7,387
|
<p>Say I have a Student table, it's got an int ID. I have a fixed set of 10 multiple choice questions with 5 possible answers. I have a normalized answer table that has the question id, the Student.answer (1-5) and the Student.ID</p>
<p>I'm trying to write a single query that will return all scores over a certain pecentage. To this end I wrote a simple UDF that accepts the Student.answers and the correct answer, so it has 20 parameters.</p>
<p>I'm starting to wonder if it's better to denormalize the answer table, bring it into my applcation and let my application do the scoring.</p>
<p>Anyone ever tackle something like this and have insight? </p>
|
<p>If I understand your schema and question correctly, how about something like this:</p>
<pre><code>select student_name, score
from students
join (select student_answers.student_id, count(*) as score
from student_answers, answer_key
group by student_id
where student_answers.question_id = answer_key.question_id
and student_answers.answer = answer_key.answer)
as student_scores on students.student_id = student_scores.student_id
where score >= 7
order by score, student_name
</code></pre>
<p>That should select the students with a score of 7 or more, for example. Just adjust the where clause for your purposes.</p>
|
<p>The architecture you are talking about could become very cumbersome in the long run, and if you need to change the questions it means more changes to the UDF you are using.</p>
<p>I would think you could probably do your analysis in code without necessarily de-normalizing your database. De-normalization could also lend to inflexibility, or at least added expense to update, down the road.</p>
| 4,243
|
<p>I'm creating an application that will store a hierarchical collection of items in an XML file and I'm wondering about the industry standard for storing collections in XML. Which of the following two formats is preferred? (If there is another option I'm not seeing, please advise.)</p>
<p><strong>Option A</strong></p>
<pre><code><School>
<Student Name="Jack" />
<Student Name="Jill" />
<Class Name="English 101" />
<Class Name="Math 101" />
</School>
</code></pre>
<p><strong>Option B</strong></p>
<pre><code><School>
<Students>
<Student Name="Jack" />
<Student Name="Jill" />
</Students>
<Classes>
<Class Name="English 101" />
<Class Name="Math 101" />
</Classes>
</School>
</code></pre>
|
<p>I'm no XML expert, but I find Option B to be more human readable, and I think it's just as machine readable as Option A. I believe that XML is designed to be both human and machine readable, so I would go for Option B myself.</p>
<hr>
<p>I just realized something else after Ryan Farley's post. If the Students or Classes section becomes too big and must be moved to another XML file, it seems like it would be easier to copy the node and create a new XML file out of that node with Option B.</p>
|
<p><strong>Definitely - Option B.</strong> </p>
<p>I wouldn't mix students and classes in the XML just the same way that I wouldn't mix students and classes in the same table in a database. </p>
| 4,304
|
<p>Is there an IE6/PNG fix that is officially developed by the jQuery team?</p>
<p>If not which of the available plugins should I use?</p>
|
<p>I'm using <a href="http://jquery.andreaseberhard.de/pngFix/" rel="nofollow noreferrer">jquery.pngFix.js</a>. I don't know if it's officially sanctioned or not, I do know that it works. I chose it because it was the plugin included with FancyBox, no other reason. </p>
|
<p>Hey guys, just wanted to toss this one in. I was digging around for it again and it has one specific advantage over the rest: repeatable backgrounds, as well as background-position (the one thats flagged as the best answer here actually just scales the background image). </p>
<p><a href="http://www.dillerdesign.com/experiment/DD_belatedPNG/" rel="nofollow noreferrer">http://www.dillerdesign.com/experiment/DD_belatedPNG/</a></p>
<p>It's so great. Just drop it in and forget its there. Have yet to see it explode a set of CSS. </p>
| 8,572
|
<p>I've seen projects where the classes in the DB layer have just static functions in them and other projects where those classes need to be instantiated to get access to the member functions. </p>
<blockquote>
<p>Which is "better" and why?</p>
</blockquote>
|
<p>I like a single object to be correlated to a single record in the database, i.e. an object must be instantiated. This is your basic <a href="http://martinfowler.com/eaaCatalog/activeRecord.html" rel="nofollow noreferrer">ActiveRecord</a> pattern. In my experience, the one-object-to-one-row approach creates a much more fluid and literate presentation in code. Also, I like to treat objects as records and the class as the table. For example to change the name of a record I do:</p>
<pre><code>objPerson = new Person(id)
objPerson.name = "George"
objPerson.save()
</code></pre>
<p>while to get all people who live in Louisiana I might do</p>
<pre><code>aryPeople = Person::getPeopleFromState("LA")
</code></pre>
<p>There are plenty of criticisms of Active Record. You can especially run into problems where you are querying the database for each record or your classes are tightly coupled to your database, creating inflexibility in both. In that case you can move up a level and go with something like <a href="http://martinfowler.com/eaaCatalog/dataMapper.html" rel="nofollow noreferrer">DataMapper</a>. </p>
<p>Many of the modern frameworks and <a href="http://en.wikipedia.org/wiki/Object-relational_mapping" rel="nofollow noreferrer">ORM's</a> are aware of some of these drawbacks and provide solutions for them. Do a little research and you will start to see that this is a problem that has a number of solutions and it all depend on your needs. </p>
|
<p>It depends which model you subscribe to. ORM (Object Relational Model) or Interface Model. ORM is very popular right now because of frameworks like nhibernate, LINQ to SQL, Entity Framework, and many others. The ORM lets you customize some business constraints around your object model and pass it around with out actually knowing how it should be committed to the database. Everything related to inserting, updating, and deleting happens in the object and doesn't really have to worry the developer too much.</p>
<p>The Interface Model like the Enterprise Data Pattern made popular by Microsoft, requires you to know what state your object is in and how it should be handled. It also requires you to create the necessary SQL to perform the actions.</p>
<p>I would say go with ORM.</p>
| 3,702
|
<p>100 (or some even number 2N :-) ) prisoners are in a room A. They are numbered from 1 to 100.</p>
<p>One by one (from prisoner #1 to prisoner #100, in order), they will be let into a room B in which 100 boxes (numbered from 1 to 100) await them. Inside the (closed) boxes are numbers from 1 to 100 (the numbers inside the boxes are randomly permuted!).</p>
<p>Once inside room B, each prisoner gets to open 50 boxes (he chooses which one he opens). If he finds the number that was assigned to him in one of these 50 boxes, the prisoner gets to walk into a room C and all boxes are closed again before the next one walks into room B from room A. Otherwise, all prisoners (in rooms A, B and C) gets killed.</p>
<p>Before entering room B, the prisoners can agree on a strategy (algorithm). There is no way to communicate between rooms (and no message can be left in room B!).</p>
<p>Is there an algorithm that maximizes the probability that all prisoners survive? What probability does that algorithm achieve?</p>
<p>Notes:</p>
<ul>
<li><p>Doing things randomly (what you call 'no strategy') indeed gives a probability of 1/2 for each prisoner, but then the probability of all of them surviving is 1/2^100 (which is quite low). One can do much better!</p></li>
<li><p>The prisoners are not allowed to reorder the boxes!</p></li>
<li><p>All prisoners are killed the first time a prisoner fails to find his number. <em>And</em> no communication is possible.</p></li>
<li><p><b>Hint</b>: one can save more than 30 prisoners <em>on average</em>, which is much more that (50/100) * (50/99) * [...] * 1</p></li>
</ul>
|
<p>This puzzle is explained at <a href="https://web.archive.org/web/20090616153244/http://www.math.princeton.edu/~wwong/blog/blog200608191813.shtml" rel="nofollow noreferrer">http://www.math.princeton.edu/~wwong/blog/blog200608191813.shtml</a> and that person does a much better job of explaining the problem.</p>
<p>The "all prisoners are killed" statement is wrong.
The "you can save 30+ on average" is also wrong, the <a href="https://web.archive.org/web/20090616153244/http://www.math.princeton.edu/~wwong/blog/blog200608191813.shtml" rel="nofollow noreferrer">article</a> says that 30% of the time you can save 100% of the prisoners.</p>
|
<p>Maybe I'm not reading it right, but the question seems to be badly constructed or missing information.</p>
<blockquote>
<p>If he finds the number that was
assigned to him in one of these 50
boxes, the prisoner gets to walk into
a room C and all boxes are closed
again before the next one walks into
room B from room A. Otherwise, all
prisoners (in rooms A, B and C) gets
killed.</p>
</blockquote>
<p>Does the last sentence there mean that all prisoners are killed the first time a prisoner fails to find their number? If not, what happens to prisoners that don't find their number?</p>
<p>If no communication is possible, and whenever a prisoner enters room B it is always in an identical state then there is no possibility for a strategy.</p>
<p>The prisoners could could say before they leave room A which number box they are going to open. But without subsequent prisoners knowing whether they were successful or not (assuming failure for one isn't failure for all) when the next prisoner enters room B they still have the same odds of picking their number as the previous prisoner (always 1:100).</p>
<p>If failure for one is failure for all, then by knowing which box the previous prisoners opened, and by dint of the fact that they haven't all been killed, each successive prisoner could reduce the odds of picking the wrong box by one box. i.e. 1:100 for the first prisoner, 1:99 for the second, down to 1:1 for the last.</p>
| 5,456
|
<p>I want to generate a thumbnail preview of videos in Java. I'm mostly JMF and video manipulation alienated. </p>
<ul>
<li>Is there an easy way to do it?</li>
<li>What about codecs? Will I have to deal with it?</li>
<li>Any video type is suported? (including Quicktime)</li>
</ul>
|
<p>There seems to be a few examples out there that are far better than <a href="http://code.google.com/p/vitalopensource/source/browse/trunk/src/com/vtls/opensource/image/VideoImageSource.java" rel="noreferrer">what I was going to send you.</a></p>
<p>See <a href="http://krishnabhargav.blogspot.com/2008/02/processing-videos-in-java.html" rel="noreferrer">http://krishnabhargav.blogspot.com/2008/02/processing-videos-in-java.html</a>.</p>
<p>I'd agree with Stu, however. If you can find a way to get what you want using some command-line tools (and run them using <a href="http://commons.apache.org/exec/" rel="noreferrer">Commons-Exec</a>), you might have a better overall solution than depending on what is essentially the Sanskrit of Java extensions.</p>
|
<p>There is a relatively newer option called JThumbnailer that you find here: <a href="https://github.com/makbn/JThumbnail" rel="nofollow noreferrer">https://github.com/makbn/JThumbnail</a></p>
<blockquote>
<p>JThumbnail is a Java library for creating Thumbnails of common types
of file including .doc, .docx, .pdf , .mp4 and etc. full list</p>
</blockquote>
| 7,055
|
<p>Using <strong>NSURLRequest</strong>, I am trying to access a web site that has an expired certificate. When I send the request, my <strong>connection:didFailWithError</strong> delegate method is invoked with the following info:</p>
<pre><code>-1203, NSURLErrorDomain, bad server certificate
</code></pre>
<p>My searches have only turned up one solution: a hidden class method in NSURLRequest:</p>
<pre><code>[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:myHost];
</code></pre>
<p>However, I don't want to use private APIs in a production app for obvious reasons.</p>
<p>Any suggestions on what to do? Do I need to use CFNetwork APIs, and if so, two questions:</p>
<ul>
<li>Any sample code I can use to get started? I haven't found any online.</li>
<li>If I use CFNetwork for this, do I have to ditch NSURL entirely?</li>
</ul>
<hr>
<p>EDIT:</p>
<p>iPhone OS 3.0 introduced a supported method for doing this. More details here: <a href="https://stackoverflow.com/questions/933331/how-to-use-nsurlconnection-to-connect-with-ssl-for-an-untrusted-cert">How to use NSURLConnection to connect with SSL for an untrusted cert?</a></p>
|
<p>The supported way of doing this requires using CFNetwork. You have to do is attach a kCFStreamPropertySSLSettings to the stream that specifies kCFStreamSSLValidatesCertificateChain == kCFBooleanFalse. Below is some quick code that does it, minus checking for valid results add cleaning up. Once you have done this You can use CFReadStreamRead() to get the data.</p>
<pre><code>CFURLRef myURL = CFURLCreateWithString(kCFAllocatorDefault, CFSTR("http://www.apple.com"), NULL);
CFHTTPMessageRef myRequest = CFHTTPMessageCreateRequest(kCFAllocatorDefault, CFSTR("GET"), myURL, kCFHTTPVersion1_1);
CFReadStreamRef myStream = CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, myRequest);
CFMutableDictionaryRef myDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(myDict, kCFStreamSSLValidatesCertificateChain, kCFBooleanFalse);
CFReadStreamSetProperty(myStream, kCFStreamPropertySSLSettings, myDict);
CFReadStreamOpen(myStream);
</code></pre>
|
<p>Another option would be to use an alternate connection library.</p>
<p>I am a huge fan of AsyncSocket and it has support for self signed certs</p>
<p><a href="http://code.google.com/p/cocoaasyncsocket/" rel="nofollow noreferrer">http://code.google.com/p/cocoaasyncsocket/</a></p>
<p>Take a look, I think it is way more robust then the standard NSURLRequests.</p>
| 3,608
|
<p>I am developing a web app which requires a username and password to be stored in the web.Config, it also refers to some URLs which will be requested by the web app itself and never the client.</p>
<p>I know the .Net framework will not allow a web.config file to be served, however I still think its bad practice to leave this sort of information in plain text. </p>
<p>Everything I have read so far requires me to use a command line switch or to store values in the registry of the server. I have access to neither of these as the host is online and I have only FTP and Control Panel (helm) access.</p>
<p>Can anyone recommend any good, free encryption DLL's or methods which I can use? I'd rather not develop my own!</p>
<p>Thanks for the feedback so far guys but I am not able to issue commands and and not able to edit the registry. Its going to have to be an encryption util/helper but just wondering which one!</p>
|
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/zhhddkxy.aspx" rel="noreferrer">Encrypting and Decrypting Configuration Sections</a> (ASP.NET) on MSDN</li>
<li><a href="http://weblogs.asp.net/scottgu/archive/2006/01/09/434893.aspx" rel="noreferrer">Encrypting Web.Config Values in ASP.NET 2.0</a> on ScottGu's <a href="http://weblogs.asp.net/scottgu/default.aspx" rel="noreferrer">blog</a></li>
<li><a href="http://odetocode.com/Blogs/scott/archive/2006/01/08/2707.aspx" rel="noreferrer">Encrypting Custom Configuration Sections</a> on K. Scott Allen's <a href="http://odetocode.com/Blogs/scott/default.aspx" rel="noreferrer">blog</a></li>
</ul>
<p><strong>EDIT:</strong><br>
If you can't use asp utility, you can encrypt config file using <a href="http://msdn.microsoft.com/en-us/library/system.configuration.sectioninformation.protectsection.aspx" rel="noreferrer">SectionInformation.ProtectSection</a> method.</p>
<p>Sample on codeproject:</p>
<p><a href="https://secure.codeproject.com/KB/aspnet/webconfig.aspx" rel="noreferrer">Encryption of Connection Strings inside the Web.config in ASP.Net 2.0</a> </p>
|
<p>Use aspnet_setreg.exe <a href="http://support.microsoft.com/kb/329290" rel="nofollow noreferrer">http://support.microsoft.com/kb/329290</a></p>
| 7,781
|
<p>I have this <a href="https://www.tme.eu/en/details/mf50151vx-a99/dc12v-fans/sunon/mf50151vx-b00u-a99/" rel="noreferrer">fan model</a>, it is a SUNON model number <a href="https://www.tme.eu/en/Document/b30ea71fee61d11101012e50df6ac0ad/MF50151VX-A99-DTE.pdf" rel="noreferrer">MF50151VX-B00U-A99</a>
and it is a blower type. </p>
<p><a href="https://i.stack.imgur.com/rGueR.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/rGueR.jpg" alt="enter image description here"></a></p>
<p>When the head is moving in the X-axis it makes noise.<br>
I think this type of fans is not suitable for rapid movement and rapid changes in directions.</p>
<p>I think the noise is coming from the axial of the fan because I think there is a clearance in the axial for moving up and down.</p>
<p>When I put my finger on the fan body(the rotating part) the noise stop! </p>
<p><strong>My question, What type of fans suitable for rapid movement and rapid direction change? and if this is not the problem what is the problem in my situation?</strong></p>
<p>I have tried searching but I can really find a direct answer!</p>
|
<p>As discussed in the comments...</p>
<p>The problem with the fan seems to be its flimsy attachment to the printer head. The fact the fan chassis is not firmly kept in place allows for it to act as a soundboard, amplyfing whatever vibration nomally occurs in the motor.</p>
<p>You could probably get a fan that is more silent in the first place (<a href="https://noctua.at/en/products/fan" rel="noreferrer">noctua</a> is a known brand for silent fans, and it is used on the Original Prusa MK3 for example), but since there's nothing inherently wrong with your current fan, I would simply design a custom, more beefy mount for it. For added dampening effect you could also use small o-rings as washers for the screws.</p>
|
<p>In response to Answer from MAC above. The Sunon Maglev Fan is actually an exceptional fan that is superior in all aspects from static pressure, CFM, Decibels... far superior to that of a radial fan like a Noctua. </p>
<p><a href="http://www.sunon.com/index2/uFiles/file/03_products/08-catalog%20download/Sunon%20DC%20Brushless%20Fan%20&%20Blower_(240-A).pdf" rel="nofollow noreferrer">http://www.sunon.com/index2/uFiles/file/03_products/08-catalog%20download/Sunon%20DC%20Brushless%20Fan%20&%20Blower_(240-A).pdf</a></p>
<p>The noise probably comes from the way it’s been attached. </p>
| 843
|
<p>What is the difference between <strong><code>const</code></strong> and <strong><code>readonly</code></strong> in C#? </p>
<p>When would you use one over the other?</p>
|
<p>Apart from the apparent difference of</p>
<ul>
<li>having to declare the value at the time of a definition for a <code>const</code> VS <code>readonly</code> values can be computed dynamically but need to be assigned before the constructor exits. After that it is frozen.</li>
<li><code>const</code>'s are implicitly <code>static</code>. You use a <code>ClassName.ConstantName</code> notation to access them.</li>
</ul>
<p>There is a subtle difference. Consider a class defined in <code>AssemblyA</code>.</p>
<pre><code>public class Const_V_Readonly
{
public const int I_CONST_VALUE = 2;
public readonly int I_RO_VALUE;
public Const_V_Readonly()
{
I_RO_VALUE = 3;
}
}
</code></pre>
<p><code>AssemblyB</code> references <code>AssemblyA</code> and uses these values in code. When this is compiled:</p>
<ul>
<li>in the case of the <code>const</code> value, it is like a find-replace. The value 2 is 'baked into' the <code>AssemblyB</code>'s IL. This means that if tomorrow I update <code>I_CONST_VALUE</code> to 20, <em><code>AssemblyB</code> would still have 2 till I recompile it</em>.</li>
<li>in the case of the <code>readonly</code> value, it is like a <code>ref</code> to a memory location. The value is not baked into <code>AssemblyB</code>'s IL. This means that if the memory location is updated, <code>AssemblyB</code> gets the new value without recompilation. So if <code>I_RO_VALUE</code> is updated to 30, you only need to build <code>AssemblyA</code> and all clients do not need to be recompiled.</li>
</ul>
<p>So if you are confident that the value of the constant won't change, use a <code>const</code>.</p>
<pre><code>public const int CM_IN_A_METER = 100;
</code></pre>
<p>But if you have a constant that may change (e.g. w.r.t. precision) or when in doubt, use a <code>readonly</code>.</p>
<pre><code>public readonly float PI = 3.14;
</code></pre>
<p><em>Update: Aku needs to get a mention because he pointed this out first. Also I need to plug where I learned this: <a href="https://rads.stackoverflow.com/amzn/click/com/0321245660" rel="nofollow noreferrer" rel="nofollow noreferrer">Effective C# - Bill Wagner</a></em></p>
|
<p>One thing to add to what people have said above. If you have an assembly containing a readonly value (e.g. readonly MaxFooCount = 4; ), you can change the value that calling assemblies see by shipping a new version of that assembly with a different value (e.g. readonly MaxFooCount = 5;)</p>
<p>But with a const, it would be folded into the caller's code when the caller was compiled.</p>
<p>If you've reached this level of C# proficiency, you are ready for Bill Wagner's book, Effective C#: 50 Specific Ways to Improve Your C#
Which answers this question in detail, (and 49 other things).</p>
| 7,986
|
<p>How would you make the contents of Flex RIA applications accessible to Google, so that Google can index the content and shows links to the right items in your Flex RIA. Consider a online shop, created in Flex, where the offered items shall be indexed by Google. Then a link on Google should open the corresponding product in the RIA.</p>
|
<p>Currently the best technique for making an RIA indexable by search engines is called <a href="http://en.wikipedia.org/wiki/Progressive_enhancement" rel="nofollow noreferrer">progressive enhancement</a> (or graceful degradation, depending on which way you see it). Basically you create a simple HTML version of the application using the same data as the application loads. This version should be dynamically generated by some kind of backend server technology. This HTML version can be indexed by Google, but each page also contains a check that determines if the visitor is capable of viewing the rich version, and if so replaces the HTML content with the Flash, Flex or Silverlight application, preferably in such a way that the application starts in a state where it shows the same data as the current page. "Replaces" can mean that it just embeds the application on top of the HTML content, or that it redirects the user to a page that embeds it. The former solution is preferable, because the latter can be considered <a href="http://en.wikipedia.org/wiki/Cloaking" rel="nofollow noreferrer">cloaking</a>.</p>
<p>One way of keeping the HTML and RIA versions of a shop synchronized is to decide on a URL scheme and make sure that RIA uses some kind of deep linking technique. If a visitor arrives to a specific item via a search engine, say <code>/items/345</code> the corresponding pseudo-URL in the RIA should be the same, so that you can embed the RIA on top of the page and set that URL as a parameter to make the RIA display that same page as soon as it has loaded.</p>
<p>This summer, Google and Yahoo! announced that they would begin using a custom version of Flash Player to index Flash based applications by exploring them "in the same way that a person would". Now, two months later there is still no evidence that this is actually happening. <a href="http://blog.digitalbackcountry.com/?p=1617" rel="nofollow noreferrer">Ryan Stweart had to cancel his Flex SEO competition</a> because it became evident that no one could win. The problem seems to be that event though the technique may very well work (although I'm sceptical), the custom Flash Player needs some kind of network interface to be able to load any referenced resources, like XML data, other SWFs, etc., and <a href="http://blog.iconara.net/2008/07/27/why-google-isnt-indexing-dynamic-content-yet/" rel="nofollow noreferrer">this is currently not implemented by Google</a>. This means that for an application that loads all it's data dynamically, like say, all that I can think of, Googlebot will not actually see anything relevant. Yahoo! ignores SWF based content altogether.</p>
<p>Oh, and it just so happens that I talk about Flex and SEO on <a href="http://www.theflexshow.com/blog/index.cfm/2008/9/10/The-Flex-Show-Episode-54" rel="nofollow noreferrer">the latest episode of the Flex show</a> =)</p>
|
<p>There is a massive thread available here:</p>
<p><a href="http://tech.groups.yahoo.com/group/flexcoders/message/58926" rel="nofollow noreferrer">http://tech.groups.yahoo.com/group/flexcoders/message/58926</a></p>
<p>But essentially, google already indexes .SWF files (you can test this out yourself by restricting search results to just .SWF files). It can search any text content within the SWF file.</p>
<p>However, if the text information in your site comes from a database / web server. Then it won't be able to access this information easily.</p>
<p>One example of getting this to work is using an XML file as your index page, then using an XSLT transform to render it using Flex. "Ted On Flex" has good information about this.</p>
<p><a href="http://flex.org/consultants" rel="nofollow noreferrer">http://flex.org/consultants</a></p>
| 8,877
|
<p>I want to draw kossel delta corner in fusion 360 for 2040 aluminium extrusion like on picture below, but cant find a way to actualy start, I draw 3 side polygon and 20x40mm rectangle but cant go from there, so do you have any suggestion?</p>
<p><a href="https://i.stack.imgur.com/hxAR4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hxAR4.jpg" alt="enter image description here"></a></p>
|
<p>I attempted to create your drawing but discovered that an important set of parameters is missing. You have to have either the intersection point of the legs (73.34) from each side or the angle between the legs (73.34) and the base (106.41) to create construction lines. Once you have either of those items, you can construct the remainder of the design using offsets, radii, etc. </p>
<p>More accurately, one other missing item that would be required to complete this design is the placement of the holes at the top (12) relative to some other feature of the design.</p>
<p>Having taken on the challenge of your drawing, I've found that it is necessary to surrender. The angles or the intersection point are critical and without them, no solution comes to my alleged mind.</p>
<p>I have also discovered one additional datum missing. The distance of the bottom truss and the thickness of this truss would be required to provide a more certain solution.</p>
<p>One the flip side, I've found <a href="https://alfa-tech3d.com/en/metal-thread-rods/corner-set-of-aluminum-to-delta-rostock-kossel-3d-printer.html" rel="nofollow noreferrer">alpha-tech3d.com</a> which appears to include similar parts, rotated 180° with what appears to have all of the necessary data.
<a href="https://i.stack.imgur.com/peYBe.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/peYBe.jpg" alt="image of one part"></a></p>
<p><a href="https://i.stack.imgur.com/cjVpH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cjVpH.jpg" alt="image of another part"></a></p>
|
<p>I attempted to create your drawing but discovered that an important set of parameters is missing. You have to have either the intersection point of the legs (73.34) from each side or the angle between the legs (73.34) and the base (106.41) to create construction lines. Once you have either of those items, you can construct the remainder of the design using offsets, radii, etc. </p>
<p>More accurately, one other missing item that would be required to complete this design is the placement of the holes at the top (12) relative to some other feature of the design.</p>
<p>Having taken on the challenge of your drawing, I've found that it is necessary to surrender. The angles or the intersection point are critical and without them, no solution comes to my alleged mind.</p>
<p>I have also discovered one additional datum missing. The distance of the bottom truss and the thickness of this truss would be required to provide a more certain solution.</p>
<p>One the flip side, I've found <a href="https://alfa-tech3d.com/en/metal-thread-rods/corner-set-of-aluminum-to-delta-rostock-kossel-3d-printer.html" rel="nofollow noreferrer">alpha-tech3d.com</a> which appears to include similar parts, rotated 180° with what appears to have all of the necessary data.
<a href="https://i.stack.imgur.com/peYBe.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/peYBe.jpg" alt="image of one part"></a></p>
<p><a href="https://i.stack.imgur.com/cjVpH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cjVpH.jpg" alt="image of another part"></a></p>
| 702
|
<p><a href="http://resharper.blogspot.com/2008/03/varification-using-implicitly-typed.html" rel="noreferrer">Resharper</a> certainly thinks so, and out of the box it will nag you to convert</p>
<pre><code>Dooberry dooberry = new Dooberry();
</code></pre>
<p>to</p>
<pre><code>var dooberry = new Dooberry();
</code></pre>
<p>Is that really considered the best style?</p>
|
<p>It's of course a matter of style, but I agree with Dare: <a href="http://www.25hoursaday.com/weblog/2008/05/21/C30ImplicitTypeDeclarationsToVarOrNotToVar.aspx" rel="noreferrer">C# 3.0 Implicit Type Declarations: To var or not to var?</a>. I think using var instead of an explicit type makes your code less readable.In the following code:</p>
<pre><code>var result = GetUserID();
</code></pre>
<p>What is result? An int, a string, a GUID? Yes, it matters, and no, I shouldn't have to dig through the code to know. It's especially annoying in code samples.</p>
<p>Jeff wrote a post on this, saying <a href="http://blog.codinghorror.com/department-of-declaration-redundancy-department/" rel="noreferrer">he favors var</a>. But that guy's crazy!</p>
<p>I'm seeing a pattern for stackoverflow success: dig up old CodingHorror posts and (Jeopardy style) phrase them in terms of a question.</p>
|
<p>"Best style" is subjective and varies depending on context.</p>
<p>Sometimes it is way easier to use 'var' instead of typing out some hugely long class name, or if you're unsure of the return type of a given function. I find I use 'var' more when mucking about with Linq, or in for loop declarations.</p>
<p>Other times, using the full class name is more helpful as it documents the code better than 'var' does.</p>
<p>I feel that it's up to the developer to make the decision. There is no silver bullet. No "one true way".</p>
<p>Cheers!</p>
| 3,774
|
<p>Often, I find myself wanting to write a unit test for a portion of code that accesses HTTP resources as part of its normal function. Have you found any good ways to write these kinds of tests?</p>
|
<p>Extract the part that accesses the HTTP resources out of your main code. Create an interface for that new component, In your test, mock the interface and return data that you can control reliably.</p>
<p>You can test the HTTP access as an integration test.</p>
|
<p>This is typically a function I would mock out for the tests... I don't like my tests depending on anything external... even worse if it is an external resource I have no control over (such as a 3rd party website).</p>
<p>Databases is one of the few external resources I often won't mock... I use DBUnit instead.</p>
| 9,411
|
<p>I need to launch a server on the remote machine and retrieve the port number that the server process is lsitening on. When invoked, the server will listen on a random port and output the port number on stderr.</p>
<p>I want to automate the process of logging on to the remote machine, launching the process, and retrieving the port number. I wrote a Python script called "<code>invokejob.py</code>" that lives on the remote machine to act as a wrapper that invokes the job and then returns the port number, it looks like this:</p>
<pre><code>import re, subprocess
executable = ... # Name of executable
regex = ... # Regex to extract the port number from the output
p = subprocess.Popen(executable,
bufsize=1, # line buffered
stderr=subprocess.PIPE
)
s = p.stderr.readline()
port = re.match(regex).groups()[0]
print port
</code></pre>
<p>If I log in interactively, this script works:</p>
<pre><code>$ ssh remotehost.example.com
Last login: Thu Aug 28 17:31:18 2008 from localhost
$ ./invokejob.py
63409
$ exit
logout
Connection to remotehost.example.com closed.
</code></pre>
<p>(Note: successful logout, it did not hang).</p>
<p>However, if I try to invoke it from the command-line, it just hangs:</p>
<pre><code>$ ssh remotehost.example.com invokejob.py
</code></pre>
<p>Does anybody know why it hangs in the second case, and what I can do to avoid this? </p>
<p>Note that I need to retrieve the output of the program, so I can't just use the ssh "-f" flag or redirect standard output.</p>
|
<blockquote>
<pre><code>s = p.stderr.readline()
</code></pre>
</blockquote>
<p>I suspect it's the above line. When you invoke a command directly through ssh, you don't get your full pty (assuming Linux), and thus no stderr to read from.</p>
<p>When you log in interactively, stdin, stdout, and stderr are set up for you, and so your script works.</p>
|
<p>what if you do the following:</p>
<h2><code>ssh <remote host> '<your command> ;<your regexp using awk or something>'</code></h2>
<p>For example</p>
<h2><code>ssh <remote host> '<your program>; ps aux | awk \'/root/ {print $2}\''</code></h2>
<p>This will connect to , execute and then print each PSID for any user root or any process with root in its description.</p>
<p>I have used this method for running all kinds of commands on remote machines. The catch is to wrap the command(s) you wish to execute in single quotation marks (') and to separate each command with a semi-colon (;).</p>
| 5,354
|
<p>I am planing on printing something that will make contact with PCB boards. The print will be most likely to be in PLA. I don't want to fry the PCB board so I want to know if 3D printed PLA objects are conductive.</p>
<p>I googled and found out about special non-conductive PLA and conductive PLA. But what about the conductivity of normal PLA?</p>
|
<p>Normal PLA is non-conductive. You can take an <span class="math-container">$\Omega$</span>-meter to a test part if you're really concerned somehow you have some PLA that is conductive.</p>
<p>There is a caveat that your color may include metal flake or graphite of some kind. Depending on the density it may be conductive. But I've tested my silver on hand and it gave me infinite resistance.</p>
|
<p>It's non-conductive, but I would check to make sure with any colored filament. Black may have iron oxide or carbon black which may give it minor conductance. </p>
| 505
|
<p><a href="http://www.djangoproject.com/" rel="noreferrer">Django</a> view points to a function, which can be a problem if you want to change only a bit of functionality. Yes, I could have million keyword arguments and even more if statements in the function, but I was thinking more of an object oriented approach.</p>
<p>For example, I have a page that displays a user. This page is very similar to page that displays a group, but it's still not so similar to just use another data model. Group also has members etc...</p>
<p>One way would be to point views to class methods and then extend that class. Has anyone tried this approach or has any other idea? </p>
|
<p>I've created and used my own generic view classes, defining <strong><code>__call__</code></strong> so an instance of the class is callable. I really like it; while Django's generic views allow some customization through keyword arguments, OO generic views (if their behavior is split into a number of separate methods) can have much more fine-grained customization via subclassing, which lets me repeat myself a lot less. (I get tired of rewriting the same create/update view logic anytime I need to tweak something Django's generic views don't quite allow).</p>
<p>I've posted some code at <a href="http://www.djangosnippets.org/snippets/1009/" rel="noreferrer">djangosnippets.org</a>.</p>
<p>The only real downside I see is the proliferation of internal method calls, which may impact performance somewhat. I don't think this is much of a concern; it's rare that Python code execution would be your performance bottleneck in a web app.</p>
<p><strong>UPDATE</strong>: Django's own <a href="http://docs.djangoproject.com/en/dev/topics/class-based-views/" rel="noreferrer">generic views</a> are now class-based.</p>
<p><strong>UPDATE</strong>: FWIW, I've changed my opinion on class-based views since this answer was written. After having used them extensively on a couple of projects, I feel they tend to lead to code that is satisfyingly DRY to write, but very hard to read and maintain later, because functionality is spread across so many different places, and subclasses are so dependent on every implementation detail of the superclasses and mixins. I now feel that <a href="https://docs.djangoproject.com/en/dev/ref/template-response/" rel="noreferrer">TemplateResponse</a> and view decorators is a better answer for decomposing view code.</p>
|
<p>Sounds to me like you're trying to combine things that shouldn't be combined. If you need to do different processing in your view depending on if it's a User or Group object you're trying to look at then you should use two different view functions.</p>
<p>On the other hand there can be common idioms you'd want to extract out of your object_detail type views... perhaps you could use a decorator or just helper functions?</p>
<p>-Dan</p>
| 2,315
|
<p>Can someone shed some light in why FDM (Fuse Deposition Modelling) is not possible with metals?</p>
<p>Has anyone attempted any experiments with it?</p>
|
<p>Yes, it is possible and it's done all the time. It's more commonly known as welding.</p>
<p>We did TIG welding on our Hyrel printers back in 2017.</p>
<p><div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/azFY-IqDB_0?start=0"></iframe>
</div></div></p>
<p>Note: I work for Hyrel.</p>
|
<p>For many metals you would need to run the hotend around 1000 °C. Aluminum melts at a lower temperature but needs to be in an inert atmosphere, such as argon. Solder melts at the right temperature, but tends to stick to most metal nozzles. It would start dissolving a brass nozzle thus enlarging the nozzle opening. Lockheed has a titanium alloy printer that melts powder with a laser. I would assume they need an inert atmosphere since titanium reacts with nitrogen as well as oxygen.</p>
| 2,219
|
<p>How does Google Chrome command and control multiple cross platform processes and provide a shared window / rendering area?</p>
<p>Any insights?</p>
|
<p>The source code is online <a href="https://chromium.googlesource.com/chromium/chromium/+/trunk/chrome/" rel="nofollow noreferrer">here</a> ...</p>
|
<p>The source code is online <a href="https://chromium.googlesource.com/chromium/chromium/+/trunk/chrome/" rel="nofollow noreferrer">here</a> ...</p>
| 6,353
|
<p>How can I combine multiple PDFs into one PDF without a 3rd party component?</p>
|
<p>I don't think you can.
Opensource component PDFSharp has that functionality, and a nice <a href="http://www.pdfsharp.com/PDFsharp/index.php?option=com_content&task=view&id=24&Itemid=35" rel="noreferrer" title="source sample">source code sample on file combining</a></p>
|
<p>Although it has already been said, you can't manipulate PDFs with the built-in libraries of the .NET Framework. I can however recommend <a href="http://itextsharp.sourceforge.net/" rel="nofollow noreferrer">iTextSharp</a>, which is a .NET port of the Java iText. I have played around with it, and found it to be a very easy tool to use.</p>
| 9,966
|
<p>We have the requirement to take a form submission and save some data, then redirect the user to a page offsite, but in redirecting, we need to "submit" a form with POST, not GET.</p>
<p>I was hoping there was an easy way to accomplish this, but I'm starting to think there isn't. I think I must now create a simple other page, with just the form that I want, redirect to it, populate the form variables, then do a body.onload call to a script that merely calls document.forms[0].submit();</p>
<p>Can anyone tell me if there is an alternative? We might need to tweak this later in the project, and it might get sort of complicated, so if there was an easy we could do this all non-other page dependent that would be fantastic.</p>
<p>Anyway, thanks for any and all responses.</p>
|
<p>Doing this requires understanding how HTTP redirects work. When you use <code>Response.Redirect()</code>, you send a response (to the browser that made the request) with <a href="http://en.wikipedia.org/wiki/HTTP_302" rel="noreferrer">HTTP Status Code 302</a>, which tells the browser where to go next. By definition, the browser will make that via a <code>GET</code> request, even if the original request was a <code>POST</code>.</p>
<p>Another option is to use <a href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection" rel="noreferrer">HTTP Status Code 307</a>, which specifies that the browser should make the redirect request in the same way as the original request, but to prompt the user with a security warning. To do that, you would write something like this:</p>
<pre><code>public void PageLoad(object sender, EventArgs e)
{
// Process the post on your side
Response.Status = "307 Temporary Redirect";
Response.AddHeader("Location", "http://example.com/page/to/post.to");
}
</code></pre>
<p>Unfortunately, this won't always work. <a href="http://ilia.ws/archives/152-Cross-Domain-POST-Redirection.html" rel="noreferrer">Different browsers implement this differently</a>, since it is not a common status code.</p>
<blockquote>
<p>Alas, unlike the Opera and FireFox developers, the IE developers have never read the spec, and even the latest, most secure IE7 will redirect the POST request from domain A to domain B without any warnings or confirmation dialogs! Safari also acts in an interesting manner, while it does not raise a confirmation dialog and performs the redirect, it throws away the POST data, <strong>effectively changing 307 redirect into the more common 302.</strong></p>
</blockquote>
<p>So, as far as I know, the only way to implement something like this would be to use Javascript. There are two options I can think of off the top of my head:</p>
<ol>
<li>Create the form and have its <code>action</code> attribute point to the third-party server. Then, add a click event to the submit button that first executes an AJAX request to your server with the data, and then allows the form to be submitted to the third-party server.</li>
<li>Create the form to post to your server. When the form is submitted, show the user a page that has a form in it with all of the data you want to pass on, all in hidden inputs. Just show a message like "Redirecting...". Then, add a javascript event to the page that submits the form to the third-party server.</li>
</ol>
<p>Of the two, I would choose the second, for two reasons. First, it is more reliable than the first because Javascript is not required for it to work; for those who don't have it enabled, you can always make the submit button for the hidden form visible, and instruct them to press it if it takes more than 5 seconds. Second, you can decide what data gets transmitted to the third-party server; if you use just process the form as it goes by, you will be passing along all of the post data, which is not always what you want. Same for the 307 solution, assuming it worked for all of your users.</p>
<p>Hope this helps!</p>
|
<p>Typically, all you'll ever need is to carry some state between these two requests. There's actually a really funky way to do this which doesn't rely on JavaScript (think <noscript/>).</p>
<pre><code>Set-Cookie: name=value; Max-Age=120; Path=/redirect.html
</code></pre>
<p>With that cookie there, you can in the following request to /redirect.html retrieve the name=value info, you can store any kind of information in this name/value pair string, up to say 4K of data (typical cookie limit). Of course you should avoid this and store status codes and flag bits instead.</p>
<p>Upon receiving this request you in return respond with a delete request for that status code.</p>
<pre><code>Set-Cookie: name=value; Max-Age=0; Path=/redirect.html
</code></pre>
<p>My HTTP is a bit rusty I've been going trough RFC2109 and RFC2965 to figure how reliable this really is, preferably I would want the cookie to round trip exactly once but that doesn't seem to be possible, also, <em>third-party cookies might be a problem for you if you are relocating to another domain. This is still possible but not as painless as when you're doing stuff within your own domain.</em></p>
<p>The problem here is concurrency, if a power user is using multiple tabs and manages to interleave a couple of requests belonging to the same session (this is very unlikely, but not impossible) this may lead to inconsistencies in your application.</p>
<p>It's the <noscript/> way of doing HTTP round trips without meaningless URLs and JavaScript</p>
<p>I provide this code as a prof of concept: If this code is run in a context that you are not familiar with I think you can work out what part is what.</p>
<p>The idea is that you call Relocate with some state when you redirect, and the URL which you relocated calls GetState to get the data (if any).</p>
<pre><code>const string StateCookieName = "state";
static int StateCookieID;
protected void Relocate(string url, object state)
{
var key = "__" + StateCookieName + Interlocked
.Add(ref StateCookieID, 1).ToInvariantString();
var absoluteExpiration = DateTime.Now
.Add(new TimeSpan(120 * TimeSpan.TicksPerSecond));
Context.Cache.Insert(key, state, null, absoluteExpiration,
Cache.NoSlidingExpiration);
var path = Context.Response.ApplyAppPathModifier(url);
Context.Response.Cookies
.Add(new HttpCookie(StateCookieName, key)
{
Path = path,
Expires = absoluteExpiration
});
Context.Response.Redirect(path, false);
}
protected TData GetState<TData>()
where TData : class
{
var cookie = Context.Request.Cookies[StateCookieName];
if (cookie != null)
{
var key = cookie.Value;
if (key.IsNonEmpty())
{
var obj = Context.Cache.Remove(key);
Context.Response.Cookies
.Add(new HttpCookie(StateCookieName)
{
Path = cookie.Path,
Expires = new DateTime(1970, 1, 1)
});
return obj as TData;
}
}
return null;
}
</code></pre>
| 6,874
|
<p>Does anyone know of a way to declare a date constant that is compatible with international dates?</p>
<p>I've tried:</p>
<pre><code>' not international compatible
public const ADate as Date = #12/31/04#
' breaking change if you have an optional parameter that defaults to this value
' because it isnt constant.
public shared readonly ADate As New Date(12, 31, 04)
</code></pre>
|
<p>If you look at the IL generated by the statement</p>
<pre><code>public const ADate as Date = #12/31/04#
</code></pre>
<p>You'll see this:</p>
<pre><code>.field public static initonly valuetype [mscorlib]System.DateTime ADate
.custom instance void [mscorlib]System.Runtime.CompilerServices.DateTimeConstantAttribute::.ctor(int64) = ( 01 00 00 C0 2F CE E2 BC C6 08 00 00 )
</code></pre>
<p>Notice that the <a href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.datetimeconstantattribute.aspx" rel="noreferrer">DateTimeConstantAttribute</a> is being initialized with a constructor that takes an int64 tick count. Since this tick count is being determined at complile time, it seems unlikely that any localization is coming into play when this value is initialized at runtime. My guess is that the error is with some other date handling in your code, not the const initialization.</p>
|
<p>OK, I am unsure what you are trying to do here:</p>
<ul>
<li>The code you are posting is <strong>NOT</strong> .NET, are you trying to port?</li>
<li>DateTime's cannot be declared as constants.</li>
<li>DateTime's are a data type, so once init'ed, the format that they were init'ed from is irrelevant.</li>
<li>If you need a constant value, then just create a method to always return the same DateTime.</li>
</ul>
<p>For example:</p>
<pre><code>public static DateTime SadDayForAll()
{
return new DateTime(2001, 09, 11);
}
</code></pre>
<h3>Update</h3>
<p>Where the hell are you getting all that from?!</p>
<ul>
<li>There <strong>are</strong> differences between C# and VB.NET, and this highlights one of them.</li>
<li><strong>Date</strong> is not a <a href="http://www.ondotnet.com/pub/a/dotnet/2001/07/30/vb7.html" rel="nofollow noreferrer">.NET data type</a> - <strong>DateTime</strong> is.</li>
<li>It looks like you can create DateTime constants in VB.NET but there are limitations</li>
<li>The method was there to try and help you, since you cannot create a const from a <strong>variable</strong> (i.e. optional param). That doesn't even make sense.</li>
</ul>
| 8,174
|
<p>I'm on the lookout for tools to migrate from ClearCase to SVN. </p>
<p>Ideally would like to get all history information, or as much as can be acquired.</p>
<p>Incremental merges would be very beneficial but isn't required.</p>
|
<p><a href="http://www.polarion.org/index.php?page=download&project=svnimporter" rel="nofollow noreferrer">This</a> looks about the best. Polarion's business is SVN, so I guess they have a vested interest in <a href="http://www.polarion.org/index.php?page=features&project=svnimporter" rel="nofollow noreferrer">making as many people as possible use it</a>...</p>
<p>Oh, back up all your data before hand, do it on a test repository first, etc, etc.</p>
|
<p>The migration from clearcase is not an easy task. The polarion importer does a job to support you, however, the history and speed for large clearcase repositories is difficult to estimate.</p>
<p>The history will only import all files from main and will not take into account any directory versioning. The problem is that your files which will be placed into your tags have the latest name, if you renamed them. Also the importer will not migrate deleted files. </p>
<p>As the importer cannot use your config-specs, it will show only the changed files in branches, as clearcase uses lazy branching, which is fully different to svns branching mechanism.</p>
<p>Merge tracking is not supoorted by migration tool, as SVN supports it only from 1.5</p>
| 8,176
|
<p>I've just changed the motherboard on my Ender 3 Pro with a MKS GEN_L v1.0 and flashed the latest Marlin version on it.</p>
<p>I've calibrated my bed manually using the default XY and Z auto home commands on OctoPrint and a piece of paper.</p>
<p>I'm happy with the calibration, however whenever I launch a print the Z axis moves up from the calibrated position by about 4 mm and starts extruding.</p>
<p>I've checked my Z endstop status with <code>M119</code> and it's triggered at the right calibrated position.</p>
<p>How can I correct this?</p>
|
<p>I've actually found what the issue was. It turns out that my Z steps were way out of whack (i.e. 4000 steps/mm instead of 400). Apparently, that's the default value in GitHub for version 2.0 of Marlin. Not sure if that's a typo or a valid value, anyhow setting it to 400 fixed it.</p>
|
<p>If you are already sure that homing is performed correctly and in valid position, then there are few reasons why printer may start printing in unexpected position.</p>
<p>Do the following checks to narrow down the actual one:</p>
<ul>
<li><p><strong>steps/mm</strong>: use <a href="https://marlinfw.org/docs/gcode/M503.html" rel="nofollow noreferrer"><code>M503</code></a> (or <a href="https://marlinfw.org/docs/gcode/M092.html" rel="nofollow noreferrer"><code>M92</code></a> without parameters) to check if currently configured steps/mm match <a href="https://blog.prusaprinters.org/calculator_3416/#steppermotors" rel="nofollow noreferrer">your hardware setup</a> for each axis</p>
</li>
<li><p><strong>offsets:</strong> use <a href="https://marlinfw.org/docs/gcode/M503.html" rel="nofollow noreferrer"><code>M503</code></a> (or <a href="https://marlinfw.org/docs/gcode/M206.html" rel="nofollow noreferrer"><code>M206</code></a> without parameters) to check that there are no offsets configured</p>
</li>
<li><p><strong>backoff:</strong> look in <em>Configuration_adv.h</em> for following line:</p>
<pre><code>//#define HOMING_BACKOFF_POST_MM { 2, 2, 2 } // (mm) Backoff from endstops after homing
</code></pre>
<p>(Having the backoff set is nothing wrong, actually. But be sure to also check final positioning in the generated file.)</p>
</li>
<li><p><strong>slicer's Start G-code:</strong> review slicer configuration, if there is nothing suspicious injected to the print file, which could temporarily overrid printer setup - esepecially <a href="https://marlinfw.org/docs/gcode/M428.html" rel="nofollow noreferrer">M428</a>, <a href="https://marlinfw.org/docs/gcode/M206.html" rel="nofollow noreferrer">M206</a>, <a href="https://marlinfw.org/docs/gcode/G092.html" rel="nofollow noreferrer">G92</a> <em>(set position is normal for E in relative extrusion mode, but suspicious for X,Y,Z)</em></p>
</li>
<li><p><strong>generated file:</strong> review initial part of generated G-Code file, if there are any similar surprises, and if on initial layer section there is expected move to valid Z position before extrusion is made</p>
</li>
</ul>
| 1,851
|
<p>With the rise of multicore CPUs on the desktop, multithreading skills will become a valuable asset for programmers. Can you recommend some good resources (books, tutorials, websites, etc.) for a programmer who is looking to learn about threaded programming?</p>
|
<p>Take a look at Herb Sutter's "<a href="http://www.gotw.ca/publications/concurrency-ddj.htm" rel="noreferrer">The Free Lunch Is Over</a>" and then his series of articles on <a href="http://herbsutter.wordpress.com/2008/07/31/effective-concurrency-the-many-faces-of-deadlock/" rel="noreferrer">Effective Concurrency</a>.</p>
|
<p>If you work with C#, the book "C# 2008 and 2005 threaded programming", by Gaston C. Hillar - Packt Publishing - <a href="http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-programming/book" rel="nofollow noreferrer">http://www.packtpub.com/beginners-guide-for-C-sharp-2008-and-2005-threaded-programming/book</a> , will help you.
Highly recommended for C# programmers, because you can download the code with funny examples that exploit your multicore computer.
The book is a nice guide with a lot of code to practice. It tells stories while it explains the most difficult concepts.</p>
| 2,457
|
<p>As the printer ages, the constant motion of the print head wears out the conductors inside the cable. Creating all sorts of fun debugging scenarios.</p>
<p>Is there such a thing as a bundled cable, with all the necessary wires, for the stepper motor (in the case of direct drives), hot end, thermistor, etc... and when one of the conductors wear out just replace the whole bundle?</p>
|
<p>People have used parallel port cables (DB25) for a while. They are cheap enough and have enough pins for most uses.</p>
<p><a href="https://i.stack.imgur.com/6LaNG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6LaNG.jpg" alt="enter image description here" /></a></p>
<p>Obviously you will need to use multiple pins for the power hungry devices (heater, stepper motor). Parallel cables often use 28 AWG (0.08 mm^2) wires, which carry up to 1.5 A @ 30 °C temperature rise over ambient. It's quite a lot, so better stick to about 0.8 A/wire, which means one pin or better two are enough for each wire of the stepper motor. A 12 V/50 W heater draws 4.2 A and will likely need 5 pins per each wire, to be safe while a 24 V/50 W heater could work with two.</p>
<p>See some ratings <a href="https://www.powerstream.com/Wire_Size.htm" rel="nofollow noreferrer">here</a>.</p>
<p>You can also use Ethernet cables, they are even cheaper and more widely available, but each cable has only 8 of them. The advantage is that they are usually 23-24 AWG (0.21-0.26 mm^2), unless you look for slim or flat cables, 30-32 AWG, so the heater will need fewer wires. However, they are all twisted pairs therefore you may be forced to use more wires than you need: for example, you may have an accelerometer which uses four data wires: TX, RX, clock, enable. You cannot twist RX and TX to avoid interference, and also clock should not be twisted with either RX or TX. You may need to be creative (TX/GND, RX/VCC, clocl/enable), but in general it's uncommon.</p>
|
<p>Have you thought of using a ribbon cable? I have/ have had similar issues with a large print area CoreXY. I'm not sure if the ribbon cable can handle the motor current or heater current but pairing up wires may help. One other issue you may have is electrical interference if you have bed leveling that uses a servo command.</p>
<p>I'm going to try a ribbon cable on my next print head rewire.</p>
| 2,112
|
<p>I've been having trouble uploading the TH3DUF_R2 firmware to my CR-10. I've already successfully flashed the bootloader using my Arduino, but when I try to upload the bootloader I get this error:</p>
<p><code>avrdude: ser_open(): can't set com-state for "\\.\COM4"</code></p>
<p>Things I've tried:</p>
<ul>
<li>Changing the usb drivers</li>
<li>Changing the baud rate</li>
<li>Using a different computers without any other usb devices</li>
</ul>
<p>My printer is not functional right now with just a bootloader and no firmware, so I'm not really sure where to go from here.</p>
|
<p>You should not look at the relative dimensional differences, you should be looking at the absolute differences. Multiplying the undersized dimensions in percentage with the cylinder diameter gives you a value of 0.4 mm for each cylinder give or take a few hundreds. So, basically your printer works very consistent it is just suffering from a systematic offset.</p>
<p>Basically, the printing process needs to
adjust the X-Y dimensions to compensate for plastic flow effects. An option or setting in Ultimaker Cura to counteract this is called <code>Horizontal Expansion</code>. Slic3r and Simplify3d have similar settings. In Slic3r it is called <code>XY size compensation</code>. </p>
|
<p>This problem seems to have mostly gone away - at least any remaining error is within a margin explainable by my cheap/low-quality digital caliper. Since asking the question, I've made a lot of changes that could contribute, but the biggest factor was probably the loose X-axis timing belt and <a href="https://3dprinting.stackexchange.com/a/10137/11157">misaligned X-axis</a>.</p>
<p>Slicer options may also have been involved. For example, Cura's Ender 3 profile attempts to set limits on acceleration speeds, but does so in a way that requires the GUI to compute derived accelerations; if you're using the command line CuraEngine (which I am), all the derived settings are left at the very high defaults.</p>
| 1,267
|
<p>I'm trying to convert old QuickTime framework code to the 64-bit Cocoa-based QTKit on OS X, which means that I can't drop down to the straight C function calls at any time. Specifically, I'm trying to find a way to write QuickTime VR movies with QTKit, as they require some special metadata to set the display controller. How can I do this with QTKit?</p>
|
<p>If you <em>have</em> to delve down into the C APIs, you might tackle the limitation to 32-bit builds by moving the QuickTime specific code into a separate, 32-bit process. We do this on Windows and it works quite well ...</p>
|
<p>As far as I can tell from the QTKit Documentation there is not way to do this in straight QTKit cocoa calls. You'll need to <a href="http://www.cocoadev.com/index.pl?QTKitAddMetaData" rel="nofollow noreferrer">do this using the Quicktime-C APIs</a>, which of course aren't available to 64-bit applications.</p>
<p>I've run into issues like this numerous times when trying to convert a 32-bit app that uses Quicktime into a 64-bit app. Here's hoping that Quicktime X will have a more fully featured QTKit set of APIs.</p>
| 9,217
|
<p>This is not a question with a precise answer (strictly speaking the answer would be best captured by a poll, but that functionality is not available), but I am genuinely interested in the answer, so I will ask it anyway.</p>
<p>Over the course of your career, how much time have you spent on <a href="http://en.wikipedia.org/wiki/Greenfield_project" rel="nofollow noreferrer">greenfield</a> development compared with <a href="http://en.wikipedia.org/wiki/Brownfield_(software_development)" rel="nofollow noreferrer">brownfield</a>? </p>
<p>Over the last 10 years I would estimate that I have spent 20% on greenfield and 80% on brownfield. Is this typical?</p>
|
<p>I think it's typical for professionals who deal with customers to spend more time in brownfield development. The reason is that customers typically aren't willing to throw out their existing software to adopt the "latest and greatest" (green) software.</p>
<p>Developers in research or academics, however, may be more likely to do greenfield development. Start-ups as well.</p>
|
<p>Over the past decade or so, I've always worked on software that was used as the center of my company's business. (Both SaaS and a software product.) And while I've always come into the with an existing system (so brownfield), we've usually put out a ground-up redesign/rewrite (so greenfield.) So, to break to down:</p>
<ul>
<li>about 60/40 brown/green for the big projects, in number</li>
<li>about 20/80 brown/green for the big projects, in time spent on them</li>
<li>and nearly 0/100 brown green for little side projects</li>
</ul>
<p>So, that is seems to be the opposite of you. It is the nature of the companies I've sought out, and hence the projects. My software is our company's main product, and that means I work on the same code base for years, usually after having created it from scratch myself/ourselves. </p>
<p>And I like it that way.</p>
| 6,201
|
<p>Have any well-documented or open source projects targeted <code>iPhone</code>, <code>Blackberry</code>, and <code>Android</code> ? Are there other platforms which are better-suited to such an endeavor ?
Note that I am particularly asking about client-side software, not web apps, though any information about the difficulties of using web apps across multiple mobile platforms is also interesting.</p>
|
<p>The HTML5 standard has support for releasing stand-alone <em>HTML5</em> apps. Essentially a <em>HTML5</em> app is a bundle of <em>HTML5</em>, <em>JavaScript</em> and <em>CSS</em> files that will run stand-alone in the browser of the desktop or device. You can distribute them like any other program, including selling them on the <em>iStore</em> for the <strong>iPhone</strong>.</p>
<p>The support for this is patchy at the moment but is likely to improve tremendously in the next year or two.</p>
<p>Google for <em>HTML5</em> apps for information and resources. A good introduction to HTML5 is the online book <a href="http://fortuito.us/diveintohtml5/table-of-contents.html" rel="noreferrer">"Dive Into HTML5" by Mark Pilgrim</a>. This is a work in progress, but sufficiently complete to be useful.</p>
|
<p><em>S60 on Symbian OS</em> has alot of interesting projects happening relating to desktop/server languages to move applications mobile. Some interesting ones:-</p>
<p>Python: <a href="http://sourceforge.net/projects/pys60" rel="nofollow noreferrer">sourceforge</a> <BR>
Ruby: <a href="http://sourceforge.net/projects/pys60" rel="nofollow noreferrer">ruby-symbian</a>
<BR>
Mozilla: <a href="https://wiki.mozilla.org/Mobile/Symbian/NSPR" rel="nofollow noreferrer">mozilla</a>
<BR>
S60Webkit: <a href="http://opensource.nokia.com/projects/S60browser/" rel="nofollow noreferrer">S60browser</a>
<BR>
POSIX: <a href="http://www.forum.nokia.com/main/resources/technologies/openc_cpp/" rel="nofollow noreferrer">openc_cpp</a></p>
| 7,522
|
<p>What grease to use on linear rails to make them stick as little as possible? I've tried so far: </p>
<ul>
<li>WD40 (let’s not start a discussion about that please), </li>
<li>silicon spray and </li>
<li>some bearing grease called ‘motorex’, </li>
</ul>
<p>but with all of them the rails stick quite much and don’t slide as easily as I’d hope.</p>
<p>Can someone recommend some good grease for linear rails (specifically the hiwin type, 12-15mm)?</p>
|
<p><strong>Don't use grease</strong>, it is better to use a <strong>light oil</strong> to lubricate the rods. A light oil will help flush out any dust and filament debris, grease will trap it.</p>
<p>I've used both light machine oil (like used for sewing machines) and PTFE based spray (Teflon). Grease is thick and will collect and trap dust and particles more easily than light machine oil.</p>
<hr>
<p><em>Even high-end consumer printers use light machine oil, e.g. the Ultimaker 3 Extended I got came with a bottle of light machine oil for the linear guide rails. Their advice is to regularly add a drop of oil on each shaft once in a while (how frequent depends on how much your printer prints).</em></p>
|
<p>I have (what I thought was Silicon) spray that was given to me by the garage door installer to lube the rollers for my garage doors. I spray some on a paper towel and wipe the X, Y and Z bars with that. It is called Zep 70. </p>
<p><a href="https://www.zep.com/product/zepcorporate/zep-70" rel="nofollow noreferrer">https://www.zep.com/product/zepcorporate/zep-70</a></p>
<blockquote>
<p>Zep 70 is a soy-based penetrating lubricant that utilizes a renewable soy solvent. It provides excellent long-lasting lubrication, and superior water displacement properties. Zep 70 will penetrate quickly and clean dirt and grease. It will also protect against rust and corrosion. Zep 70 is packaged in a 24 oz. can with a net weight of 18 ounces.
Utilizing a soy-based solvent, a renewable source, helps to conserve nonrenewable resources such as petroleum.
Non-evaporative solvent extends life of the lubricant.
Quickly penetrates parts frozen from rust or corrosion.
Displaces moisture and condensation which can cause corrosion.
Treated surfaces are protected from rust.
Helps clean dirt and grease from metal surfaces.</p>
</blockquote>
<p>Reading the can contents, the Lubricant part seems to be TSRN-80100428-5003
The guides seem to slide on the bars with this stuff. Can't find a google hit on it.</p>
<p>I also made a polycarbonate enclosure around my printer to keep dust from settling on everything.</p>
| 1,347
|
<p>I have a script that checks responses from HTTP servers using the PEAR HTTP classes. However, I've recently found that the script fails on FTP servers (and probably anything that's not HTTP or HTTPS). I tried Google, but didn't see any scripts or code that returned the server status code from servers other than HTTP servers.</p>
<p>How can I find out the status of a newsgroup or FTP server using PHP?</p>
<p>EDIT: I should clarify that I am interested only in the ability to read from an FTP server and the directory that I specify. I need to know if the server is dead/gone, I'm not authorized to read, etc.</p>
<p>Please note that, although most of the time I'm language agnostic, the entire website is PHP-driven, so a PHP solution would be the best for easy of maintainability and extensibility in the future.</p>
|
<p>HTTP works slightly differently than FTP though unfortunately. Although both may look the same in your browser, HTTP works off the basis of URI (i.e. to access resource A, you have an identifier which tells you how to access that).</p>
<p>FTP is very old school server driven. Even anonymous FTP is a bit of a hack, since you still supply a username and password, it's just defined as "anonymous" and your email address.</p>
<p>Checking if an FTP server is up means checking</p>
<ol>
<li><p>That you can connect to the FTP server</p>
<p><code>if (!($ftpfd = ftp_connect($hostname))) { ... }</code></p></li>
<li><p>That you can login to the server:</p>
<p><code>if (!ftp_login($ftpfd, $username, $password)) { ... }</code></p></li>
<li><p>Then, if there are further underlying resources that you need to access to test whether a particular site is up, then use an appropiate operation on them. e.g. on a file, maybe use <code>ftp_mdtm()</code> to get the last modified time or on a directory, see if <code>ftp_nlist()</code> works.</p></li>
</ol>
|
<p>Wouldn't it be simpler to use the built-in PHP FTP* functionality than trying to roll your own? If the URI is coming from a source outside your control, you would need to check the protocal definition (http:// or ftp://, etc) in order to determine which functionality to use, but that is fairly trivial. If there is now protocal specified (there really should be!) then you could try to default to http.</p>
<ul>
<li>see <a href="http://uk.php.net/ftp" rel="nofollow noreferrer">here</a></li>
</ul>
| 3,021
|
<p>I'm using SQL Server 2000 to print out some values from a table using <code>PRINT</code>. With most non-string data, I can cast to nvarchar to be able to print it, but binary values attempt to convert using the bit representation of characters. For example:</p>
<pre><code>DECLARE @binvalue binary(4)
SET @binvalue = 0x12345678
PRINT CAST(@binvalue AS nvarchar)
</code></pre>
<p>Expected:</p>
<blockquote>
<p>0x12345678</p>
</blockquote>
<p>Instead, it prints two gibberish characters.</p>
<p>How can I print the value of binary data? Is there a built-in or do I need to roll my own?</p>
<p>Update: This isn't the only value on the line, so I can't just PRINT @binvalue. It's something more like PRINT N'other stuff' + ???? + N'more stuff'. Not sure if that makes a difference: I didn't try just PRINT @binvalue by itself.</p>
|
<p>If you were on Sql Server 2005 you could use this:</p>
<pre><code>print master.sys.fn_varbintohexstr(@binvalue)
</code></pre>
<p>I don't think that exists on 2000, though, so you might have to roll your own.</p>
|
<p>Really too much of tl;dr in the topic :( Will try to fix it following <a href="https://stackoverflow.com/a/12549880/10815638">this answer</a>.</p>
<pre><code>with
sq1 as (select '41424344' as v), -- this is 'ABCD'
-- Need binary size, otherwise it sets binary(30) in my case
sq2 as (select v, convert(binary(4), v, 2) as b from sq1),
sq3 as (select b, v, convert(varchar, b, 2) as v1 from sq2)
--
select b, v, v1 from sq3
where v = v1
;
</code></pre>
<p>The output is:</p>
<pre><code>b |v |v1 |
----|--------|--------|
ABCD|41424344|41424344|
</code></pre>
<p>Also see: <a href="https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-ver15" rel="nofollow noreferrer">documentation</a></p>
| 9,424
|
<p>I'm currently using the module <code>URI::URL</code> to generate a full URL from a relative URL; however, it isn't running as fast as I'd like it to be. Does anyone know another way to do this that may be faster?</p>
|
<p>The following code should work.</p>
<pre><code>$uri = URI->new_abs( $str, $base_uri )
</code></pre>
<p>You should also take a look at <a href="http://search.cpan.org/dist/URI/URI.pm" rel="nofollow noreferrer">the URI page on search.cpan.org</a>.</p>
|
<p>Perhaps I got the wrong end of the stick but wouldn't,</p>
<pre><code>$full_url = $base_url . $relative_url</code></pre>
<p>work? IIRC Perl text processing is pretty quick.</p>
<p><i>@lennysan</i> Ah sure yes of course. Sorry I can't help, my Perl is pretty rusty.</p>
| 4,649
|
<p>Here is the issue I am having: I have a large query that needs to compare datetimes in the where clause to see if two dates are on the same day. My current solution, which sucks, is to send the datetimes into a UDF to convert them to midnight of the same day, and then check those dates for equality. When it comes to the query plan, this is a disaster, as are almost all UDFs in joins or where clauses. This is one of the only places in my application that I haven't been able to root out the functions and give the query optimizer something it can actually use to locate the best index.</p>
<p>In this case, merging the function code back into the query seems impractical.</p>
<p>I think I am missing something simple here.</p>
<p>Here's the function for reference.</p>
<pre><code>if not exists (select * from dbo.sysobjects
where id = object_id(N'dbo.f_MakeDate') and
type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
exec('create function dbo.f_MakeDate() returns int as
begin declare @retval int return @retval end')
go
alter function dbo.f_MakeDate
(
@Day datetime,
@Hour int,
@Minute int
)
returns datetime
as
/*
Creates a datetime using the year-month-day portion of @Day, and the
@Hour and @Minute provided
*/
begin
declare @retval datetime
set @retval = cast(
cast(datepart(m, @Day) as varchar(2)) +
'/' +
cast(datepart(d, @Day) as varchar(2)) +
'/' +
cast(datepart(yyyy, @Day) as varchar(4)) +
' ' +
cast(@Hour as varchar(2)) +
':' +
cast(@Minute as varchar(2)) as datetime)
return @retval
end
go
</code></pre>
<p>To complicate matters, I am joining on time zone tables to check the date against the local time, which could be different for every row:</p>
<pre><code>where
dbo.f_MakeDate(dateadd(hh, tz.Offset +
case when ds.LocalTimeZone is not null
then 1 else 0 end, t.TheDateINeedToCheck), 0, 0) = @activityDateMidnight
</code></pre>
<p>[Edit]</p>
<p>I'm incorporating @Todd's suggestion:</p>
<pre><code>where datediff(day, dateadd(hh, tz.Offset +
case when ds.LocalTimeZone is not null
then 1 else 0 end, t.TheDateINeedToCheck), @ActivityDate) = 0
</code></pre>
<p>My misconception about how datediff works (the same day of year in consecutive years yields 366, not 0 as I expected) caused me to waste a lot of effort.</p>
<p>But the query plan didn't change. I think I need to go back to the drawing board with the whole thing.</p>
|
<p>This is much more concise:</p>
<pre><code>where
datediff(day, date1, date2) = 0
</code></pre>
|
<p>I would use the dayofyear function of datepart:</p>
<pre><code>
Select *
from mytable
where datepart(dy,date1) = datepart(dy,date2)
and
year(date1) = year(date2) --assuming you want the same year too
</code></pre>
<p>See the datepart reference <a href="http://www.tizag.com/sqlTutorial/sqldatepart.php" rel="nofollow noreferrer">here</a>.</p>
| 4,261
|
<p>I constantly hear how bad reflection is to use. While I generally avoid reflection and rarely find situations where it is impossible to solve my problem without it, I was wondering... </p>
<p>For those who have used reflection in applications, have you measured performance hits and, is it really so bad?</p>
|
<p>It is. But that depends on what you're trying to do. </p>
<p>I use reflection to dynamically load assemblies (plugins) and its performance "penalty" is not a problem, since the operation is something I do during startup of the application.</p>
<p>However, if you're reflecting inside a series of nested loops with reflection calls on each, I'd say you should revisit your code :)</p>
<p>For "a couple of time" operations, reflection is perfectly acceptable and you won't notice any delay or problem with it. It's a very powerful mechanism and it is even used by .NET, so I don't see why you shouldn't give it a try. </p>
|
<p>I think you will find that the answer is, it depends. It's not a big deal if you want to put it in your task-list application. It is a big deal if you want to put it in Facebook's persistence library.</p>
| 4,509
|
<p>I am looking for an open source project that uses EJB3 as backend and JSF as frontend. It should <em>not</em> be a tutorial but a real application that real people are using.</p>
<p>The application should be data-driven, i.e. the following aspects are fundamental and make 80% or more of the application.</p>
<ul>
<li>form-based (many input forms)</li>
<li>table views, master/detail, etc.</li>
<li>CRUD (create/read/update/delete)-Operations have been implemented</li>
<li>support for relations: 1:1, 1:n</li>
<li>JPA Entity Beans + EJB 3 Stateless Session Beans for Facade</li>
<li>no JBoss Seam</li>
</ul>
<p>Typical applications are CRM / ERP projects where people work a lot with lists, tables, and forms. But any other "administrative" application should be OK, too.</p>
<p>I know petstore, but that application isn't form-based. petstore is a end-user application. I am looking for backend-user applications.</p>
<p>Something like Microsofts AdventureWorks series, but with EJB3+JSF...
Something like SugarCRM, but with EJB3+JSF...</p>
<p>I've googled <em>a lot</em>... with no results :-(</p>
<ul>
<li>@Matthew: the samples provided with NetBeans are too simple.</li>
<li>@JB: It should be a real application. Not a "how to do EJB+JSF" application.</li>
<li>@50-50: voted down because of seam</li>
<li>@Kariem: I can't use seam, AppFuse hasn't EJB Session Beans</li>
</ul>
|
<p>Seam examples are quite good. They are stand-alone projects, that you may deploy out of the box. </p>
|
<p>I am not sure is it 100% what your looking for, <strong>but check out the built in example that comes packaged with NetBeans 6.1</strong>. It uses JSF/EJB3/ApacheDerby. I played around with it for like 20 minutes and thought it was pretty cool as a simple/starter JavaEE application to learn from.</p>
| 5,908
|
<p>I have a rather complex page that dynamically builds user controls inside of a repeater. This repeater must be bound during the Init page event before <code>ViewState</code> is initialized or the dynamically created user controls will not retain their state.</p>
<p>This creates an interesting Catch-22 because the object I bind the repeater to needs to be created on initial page load, and then persisted in memory until the user opts to leave or save.</p>
<p>Because I cannot use <code>ViewState</code> to store this object, yet have it available during Init, I have been forced to store it in Session.</p>
<p>This also has issues, because I have to explicitly null the session value during non postbacks in order to emulate how <code>ViewState</code> works.</p>
<p>There has to be a better way to state management in this scenario. Any ideas?</p>
<p><strong>Edit:</strong> Some good suggestions about using <code>LoadViewState</code>, but I'm still having issues with state not being restored when I do that.</p>
<p>Here is somewhat if the page structure</p>
<p>Page --> UserControl --> Repeater --> N amount of UserControls Dynamicly Created.</p>
<p>I put the overridden <code>LoadViewState</code> in the parent <code>UserControl</code>, as it is designed to be completely encapsulated and independent of the page it is on. I am wondering if that is where the problem is.</p>
|
<p>The LoadViewState method on the page is definitely the answer. Here's the general idea:</p>
<pre><code>protected override void LoadViewState( object savedState ) {
var savedStateArray = (object[])savedState;
// Get repeaterData from view state before the normal view state restoration occurs.
repeaterData = savedStateArray[ 0 ];
// Bind your repeater control to repeaterData here.
// Instruct ASP.NET to perform the normal restoration of view state.
// This will restore state to your dynamically created controls.
base.LoadViewState( savedStateArray[ 1 ] );
}
</code></pre>
<p>SaveViewState needs to create the savedState array that we are using above:</p>
<pre><code>protected override object SaveViewState() {
var stateToSave = new List<object> { repeaterData, base.SaveViewState() };
return stateToSave.ToArray();
}
</code></pre>
<p>Don't forget to also bind the repeater in Init or Load using code like this:</p>
<pre><code>if( !IsPostBack ) {
// Bind your repeater here.
}
</code></pre>
|
<p>1) there's probably a way to get it to work... you just have to make sure to add your controls to the tree at the right moment. Too soon and you don't get ViewState. Too late and you don't get ViewState.</p>
<p>2) If you can't figure it out, maybe you can turn off viewstate for the hole page and then rely only on querystring for state changes? Any link that was previously a postback would be a link to another URL (or a postback-redirect).</p>
<p>This can really reduce the weight of the page and make it easier to avoid issues with ViewState.</p>
| 6,699
|
<p>I'd like to store a properties file as XML. Is there a way to sort the keys when doing this so that the generated XML file will be in alphabetical order? </p>
<pre><code>String propFile = "/path/to/file";
Properties props = new Properties();
/*set some properties here*/
try {
FileOutputStream xmlStream = new FileOutputStream(propFile);
/*this comes out unsorted*/
props.storeToXML(xmlStream,"");
} catch (IOException e) {
e.printStackTrace();
}
</code></pre>
|
<p>Here's a quick and dirty way to do it:</p>
<pre><code>String propFile = "/path/to/file";
Properties props = new Properties();
/* Set some properties here */
Properties tmp = new Properties() {
@Override
public Set<Object> keySet() {
return Collections.unmodifiableSet(new TreeSet<Object>(super.keySet()));
}
};
tmp.putAll(props);
try {
FileOutputStream xmlStream = new FileOutputStream(propFile);
/* This comes out SORTED! */
tmp.storeToXML(xmlStream,"");
} catch (IOException e) {
e.printStackTrace();
}
</code></pre>
<p>Here are the caveats:</p>
<ul>
<li>The tmp Properties (an anonymous
subclass) doesn't fulfill the
contract of Properties.</li>
</ul>
<p>For example, if you got its <code>keySet</code> and tried to remove an element from it, an exception would be raised. So, don't allow instances of this subclass to escape! In the snippet above, you are never passing it to another object or returning it to a caller who has a legitimate expectation that it fulfills the contract of Properties, so it is safe.</p>
<ul>
<li>The implementation of
Properties.storeToXML could change,
causing it to ignore the keySet
method.</li>
</ul>
<p>For example, a future release, or OpenJDK, could use the <code>keys()</code> method of <code>Hashtable</code> instead of <code>keySet</code>. This is one of the reasons why classes should always document their "self-use" (Effective Java Item 15). However, in this case, the worst that would happen is that your output would revert to unsorted.</p>
<ul>
<li>Remember that the Properties storage
methods ignore any "default"
entries.</li>
</ul>
|
<p>Why do you want the XML file to be sorted in the first place? Presumably, there is another piece of code that reads the file and puts the data in another Properties object. Do you want to do this so you can manually find and edit entries in the XML file?</p>
| 7,792
|
<p>I have a web page that I have hooked up to a <a href="http://en.wikipedia.org/wiki/Stored_procedure" rel="nofollow noreferrer">stored procedure</a>. In this SQL data source, I have a parameter that I'm passing back to the stored procedure of type int. </p>
<p><a href="http://en.wikipedia.org/wiki/ASP.NET" rel="nofollow noreferrer">ASP.NET</a> seems to want to default to <em>int32</em>, but the number won't get higher than 6. Is it ok to override the ASP.NET default and put in 16 or will there be a conflict somewhere down the road?</p>
<p>specification: the database field has a length of 4 and precision of 10, if that makes a difference in the answer.</p>
|
<p>Would something like this work?</p>
<pre><code>from random import randint
mcworks = []
for n in xrange(NUM_ITERATIONS):
mctest = [randint(0, 100) for i in xrange(5)]
if sum(mctest[:3])/3 == mcavg[2]:
mcworks.append(mctest) # mcavg is real data
</code></pre>
<p>In the end, you are left with a list of valid <code>mctest</code> lists.</p>
<p>What I changed:</p>
<ul>
<li>Used a <a href="https://web.archive.org/web/20080928230016/http://docs.python.org:80/tut/node7.html#SECTION007140000000000000000" rel="nofollow noreferrer">list comprehension</a> to build the data instead of a for loop</li>
<li>Used <code>random.randint</code> to get random integers</li>
<li>Used <a href="http://docs.python.org/tut/node5.html" rel="nofollow noreferrer">slices</a> and <code>sum</code> to calculate the average of the first three items</li>
<li>(To answer your actual question :-) ) Put the results in a list <code>mcworks</code>, instead of creating a new variable for every iteration</li>
</ul>
|
<p>A neat way to do it is to use a list of lists in combination with Pandas. Then you are able to create a 3-day rolling average.
This makes it easy to search through the results by just adding the real ones as another column, and using the loc function for finding which ones that match.</p>
<pre><code>rand_vals = [randint(0, 100) for i in range(5))]
df = pd.DataFrame(data=rand_vals, columns=['generated data'])
df['3 day avg'] = df['generated data'].rolling(3).mean()
df['mcavg'] = mcavg # the list of real data
# Extract the resulting list of values
res = df.loc[df['3 day avg'] == df['mcavg']]['3 day avg'].values
</code></pre>
<p>This is also neat if you intend to use the same random values for different polls/persons, just add another column with their real values and perform the same search for them. </p>
| 8,429
|
<p>I am creating a small modal form that is used in Winforms application. It is basically a progress bar of sorts. But I would like the user to be able to click anywhere in the form and drag it to move it around on the desktop while it is still being displayed.</p>
<p>How can I implement this behavior?</p>
|
<p><a href="http://support.microsoft.com/kb/320687" rel="nofollow noreferrer" title="KB Article 320687">Microsoft KB Article 320687</a> has a detailed answer to this question.</p>
<p>Basically, you override the WndProc method to return HTCAPTION to the WM_NCHITTEST message when the point being tested is in the client area of the form -- which is, in effect, telling Windows to treat the click exactly the same as if it had occured on the caption of the form.</p>
<pre><code>private const int WM_NCHITTEST = 0x84;
private const int HTCLIENT = 0x1;
private const int HTCAPTION = 0x2;
protected override void WndProc(ref Message m)
{
switch(m.Msg)
{
case WM_NCHITTEST:
base.WndProc(ref m);
if ((int)m.Result == HTCLIENT)
m.Result = (IntPtr)HTCAPTION;
return;
}
base.WndProc(ref m);
}
</code></pre>
|
<p>VC++ 2010 Version (of FlySwat's):</p>
<pre><code>#include <Windows.h>
namespace DragWithoutTitleBar {
using namespace System;
using namespace System::Windows::Forms;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Data;
using namespace System::Drawing;
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void) { InitializeComponent(); }
protected:
~Form1() { if (components) { delete components; } }
private:
System::ComponentModel::Container ^components;
HWND hWnd;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->SuspendLayout();
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(640, 480);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::None;
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew EventHandler(this, &Form1::Form1_Load);
this->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::Form1_MouseDown);
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void Form1_Load(Object^ sender, EventArgs^ e) {
hWnd = static_cast<HWND>(Handle.ToPointer());
}
private: System::Void Form1_MouseDown(Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
if (e->Button == System::Windows::Forms::MouseButtons::Left) {
::ReleaseCapture();
::SendMessage(hWnd, /*WM_NCLBUTTONDOWN*/ 0xA1, /*HT_CAPTION*/ 0x2, 0);
}
}
};
}
</code></pre>
| 5,007
|
<p>Hello I have a Prusa I3 I am currently able to get press fit parts with my current settings. I am using Ramps 1.4 hardware and repetier software and cura as my slicer. I am printing with a .2 mm layer height right now but would like to get a better number such as .1 or .09. When I try to print with say .1mm layer height in the middle of the print the filament stops coming out of the nozzle. However I can still see the gear moving. I have check some sites that I have been using for troubleshooting but I haven't found anything that fixed the problem yet. How or what setting need to be changed in order to print with better resolution?</p>
|
<p>There are no settings that you should need to change. Rather, it seems like you are suffering from another issue that is not directly related to layer height.</p>
<p>It is possible that your hotend's heat sink is not being cooled enough, causing heat to migrate up and soften plastic in the heat sink, ultimately jamming it. Depending on your hotend's make, the heat sink should be cooled by a fan that is always on.</p>
<p>Normally, the plastic being fed into the hotend provides some cooling, but printing at a thinner layer height decreases this effect because less plastic is fed into the hotend per time unit.</p>
|
<p>I agree with Tom's answer, it seems that temperature slowly makes it's way up your heat sink and softens the plastic which causes the jam. </p>
<p>Even though you should first check your hardware to make sure that hotend cooling is installed correctly, <strong>to directly address your original question</strong> as to what setting needs to be changed, I would suggest lowering your printing temperature. When printing finer layers, the plastic moves slower in the hotend, spending more time in the heater block, possibly making your current temperature setting too high for this resolution.</p>
| 356
|
<p>I have a "showall" query string parameter in the url, the parameter is being added dynamically when "Show All/Show Pages" button is clicked. </p>
<p>I want the ability to toggle "showall" query string parameter value depending on user clicking the "Show All/Show Pages" button.</p>
<p>I'm doing some nested "if's" and <code>string.Replace()</code> on the url, is there a better way?</p>
<p>All manipulations are done on the server.</p>
<p><strong>p.s.</strong> Toran, good suggestion, however I HAVE TO USE URL PARAMETER due to some other issues.</p>
|
<p>Just to elaborate on Toran's answer:</p>
<p>Use:<br>
<code><asp:HiddenField ID="ShowAll" Value="False" runat="server" /></code></p>
<p>To toggle your state:</p>
<pre><code>protected void ToggleState(object sender, EventArgs e)
{
//parse string as boolean, invert, and convert back to string
ShowAll.Value = (!Boolean.Parse(ShowAll.Value)).ToString();
}
</code></pre>
|
<p>Another dirty alternative could be just to use a hidden input and set that on/off instead of manipulating the url.</p>
| 6,679
|
<p>I usually store my connectionstring in web.config or in the application settings of my Visual Studio project. The application I'm currently working on makes a lot of trips to the database which means it will look up the connectionstring every time. Should I be putting the connectionstring in the cache or should I be looking at storing the whole SqlConnection object in the cache to eliminate the need to open and close them all the time?</p>
<p><strong>Update</strong>: Seems like the consensus is to store the connection string in a configuration file and leave the caching in the trusting hand of ADO.NET</p>
|
<p>I wouldn't cache the connection object, that will defeat the built-in connection pooling -- ADO.NET will handle connections (assuming you instantiate and close them) efficiently by itself.</p>
<p>As far as the connection string itself, you shouldn't need to cache it if you load it from connection -- the connection manager object in the .NET 2.0 framework loads the config into memory when you first access it, so there are no repeat trips to the file system.</p>
|
<p>Keep it in a configuration file. Use a robust data access strategy provided by tools like NHibernate or Linq to Sql.</p>
| 6,235
|
<p>I don't remember whether I was dreaming or not but I seem to recall there being a function which allowed something like,</p>
<pre><code>foo in iter_attr(array of python objects, attribute name)</code></pre>
<p>I've looked over the docs but this kind of thing doesn't fall under any obvious listed headers</p>
|
<p>Using a list comprehension would build a temporary list, which could eat all your memory if the sequence being searched is large. Even if the sequence is not large, building the list means iterating over the whole of the sequence before <code>in</code> could start its search.</p>
<p>The temporary list can be avoiding by using a generator expression:</p>
<pre><code>foo = 12
foo in (obj.id for obj in bar)
</code></pre>
<p>Now, as long as <code>obj.id == 12</code> near the start of <code>bar</code>, the search will be fast, even if <code>bar</code> is infinitely long.</p>
<p>As @Matt suggested, it's a good idea to use <code>hasattr</code> if any of the objects in <code>bar</code> can be missing an <code>id</code> attribute:</p>
<pre><code>foo = 12
foo in (obj.id for obj in bar if hasattr(obj, 'id'))
</code></pre>
|
<p>I think:</p>
<pre><code>#!/bin/python
bar in dict(Foo)
</code></pre>
<p>Is what you are thinking of. When trying to see if a certain key exists within a dictionary in python (python's version of a hash table) there are two ways to check. First is the <strong><code>has_key()</code></strong> method attached to the dictionary and second is the example given above. It will return a boolean value.</p>
<p>That should answer your question.</p>
<p>And now a little off topic to tie this in to the <em>list comprehension</em> answer previously given (for a bit more clarity). <em>List Comprehensions</em> construct a list from a basic <em>for loop</em> with modifiers. As an example (to clarify slightly), a way to use the <code>in dict</code> language construct in a <em>list comprehension</em>:</p>
<p>Say you have a two dimensional dictionary <strong><code>foo</code></strong> and you only want the second dimension dictionaries which contain the key <strong><code>bar</code></strong>. A relatively straightforward way to do so would be to use a <em>list comprehension</em> with a conditional as follows:</p>
<pre><code>#!/bin/python
baz = dict([(key, value) for key, value in foo if bar in value])
</code></pre>
<p>Note the <strong><code>if bar in value</code></strong> at the end of the statement**, this is a modifying clause which tells the <em>list comprehension</em> to only keep those key-value pairs which meet the conditional.** In this case <strong><code>baz</code></strong> is a new dictionary which contains only the dictionaries from foo which contain bar (Hopefully I didn't miss anything in that code example... you may have to take a look at the list comprehension documentation found in <a href="http://docs.python.org/tut/node7.html#SECTION007140000000000000000" rel="nofollow noreferrer">docs.python.org tutorials</a> and at <a href="http://www.secnetix.de/olli/Python/list_comprehensions.hawk" rel="nofollow noreferrer">secnetix.de</a>, both sites are good references if you have questions in the future.).</p>
| 2,310
|
<p>Recently I started looking on pressure advance and how it works and I'm a bit confused about where it is usually implemented.</p>
<p>My Idea of 3D printer was that its firmware is fairly dumb and only replays GCode, not knowing anything about the object being printed, material used, or even the printer itself.</p>
<p>But with pressure advance this whole thing changes and now the firmware needs to know the linear advance factor which combines information about the filament and filament path used. In addition the E axis is no longer controlled directly by the GCode, but it's motion is almost independently determined by the firmware.</p>
<p>Why is this? Is there a reason that slicer (or a post-processor) can't compute all this and directly store the needed extruder axis movements in the GCode?
Does the printer have some additional information that the slicer is missing?</p>
|
<blockquote>
<p>In addition the E axis is no longer controlled directly by the GCode, but it's motion is almost independently determined by the firmware.</p>
</blockquote>
<p>This is the case even without linear advance. G-code does not directly control the movement of any of the axes. G-code only specifies the path the axes should travel, but not the acceleration and deceleration associated with following that path. If you are printing a cube, then the G-code might specify that the extruder has to extrude a square. It will specify that the 4 sides of the square should be printed, but it does not specify how the transition from one side to the next should be handled.</p>
<p>The printer cannot instantly transition from extruding one side of the square to extruding the next side, because the direction of the extruder cannot change instantaneously. It needs to smoothly decelerate and accelerate. This is handled by the firmware, which translates the straight line commands from G-code to smooth acceleration and deceleration of the extruder.</p>
<p>This is exactly where linear advance comes in. It is coupled to the acceleration and deceleration. There is no way to "implement" linear advance in G-code, because G-code does not even have any notion of acceleration and deceleration. The G-code (and slicer) has no idea how the firmware is handling the acceleration and deceleration, so therefore it is impossible for the slicer to know what linear advance is required to match.</p>
<p>Then you might ask: "why is acceleration and deceleration not implemented in G-code (rather than in firmware)?" This is simply a design choice. G-code is meant to be a very simple file format, and it simply allows you to specify straight line move commands. Representing smooth acceleration curves would either require breaking them down into many discrete, small steps, but this would greatly increase the file size. You could suggest a more complex G-code specification that would allow a more "compact" representation of acceleration and deceleration curves but then you're just shifting the computation back to the firmware (albeit with a more explicit specification in the G-code).</p>
|
<p>This is a really good question that sheds a lot of light on 3D printer software/firmware architecture, and Tom already said a lot of the things I wanted to say before getting a chance to write an answer. The basic problem is that, to do pressure advance accurately (and in a way that doesn't get it horribly wrong when inaccurate), you need to know the actual feedrate of the extruder at all times, and that's not available until applying the acceleration profile, which by convention happens in the printer firmware.</p>
<p>With that said, there were primitive and even somewhat advanced attempts to do pressure advance in the slicer. The first seems to have been "coasting", which, along with extra-priming after coast, is pretty much just "pressure advance, assuming a constant feedrate". It gets things horribly wrong if you mix different extruder feedrates (different print speeds or line widths, etc.) or if you have slow acceleration, but if your acceleration is so fast (relative to max speed) that it's approximately instantaneous, it might work okay.</p>
<p>Modern Cura also has Flow Rate Compensation, which is something like pressure advance. It's rate-sensitive, so in theory it can give accurate results with varying line width and print speed as long as acceleration is close enough to instantaneous. Since it appeared after Marlin added linear advance, I never bothered trying to play with it, so I can't speak to whether it actually works decently. There are still a lot of subtleties to when the advance is performed that it could get wrong, and I think you'd want to do some test cases just to read the gcode output and evaluate whether what it's doing is sufficiently close to reasonable.</p>
<p>If you wanted to do full pressure advance in the slicer, you'd need to let the slicer handle acceleration profile, breaking lines up into small segments each with nominal feedrate matching the rate they should end at, and sufficiently close to the rate they should start at, with the firmware acceleration limits set to accommodate the change. Then, knowing a very good approximation of the actual toolhead and thus extruder feedrate for each segment, you'd know the advance to apply, and could apply it as an additional subdivision at the end of the previous print move. And then in theory, it all works out. But this would make the gcode <strong>a lot</strong> larger/bulkier, and more demanding on the serial link speed and microcontroller's ability to keep up with parsing/planning. So it's almost surely a bad idea.</p>
<p>The Klipper firmware does this differently. It does the gcode parsing and planning (including pressure advance) in Python software (with some C for critical paths) running on a much more capable computer, and sends the precise generated stepper motor timings over the serial link to the microcontroller operating the printer hardware.</p>
| 1,796
|
<p>When exporting an STL from Fusion 360, one must select an STL refinement level to use for calculating the maximum triangle count. </p>
<p>For FDM printing (<em>0.05mm and above layer heights</em>), where is the point of diminishing returns on STL refinement level when printing PLA and PETG on an Ender 3 with a 0.4mm nozzle? All mechanical components on the printer are stock.</p>
<p><a href="https://i.stack.imgur.com/z9cgx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z9cgx.png" alt="Refinement quality"></a> </p>
|
<p>I don't know that this can be definitively answered for a specific printer and all arbitrary designs.</p>
<p>The refinement level basically determines how smooth a curved surface will turn out. The STL file format can only express an object in terms of triangular-shaped surfaces, so Fusion 360 will need to approximate a curved surface by breaking it up into triangles. Flat surfaces and straight edges can be represented perfectly, so they won't be affected. Low refinement will use a small number of relatively large triangles. On a part like your example, the cylindrical shaft will have noticeable facets. Higher refinement means a larger number of smaller triangles.</p>
<p>If you have "Preview Mesh" checked as shown, you will be able to see the triangle wireframe, and you can use your own judgment if it's "good enough".</p>
<p>Ultimately, higher refinement means longer processing times and larger file sizes. The final print time won't be affected much if any.</p>
<p>Personally, I always use high refinement. Even on my modest system, it only takes a few more seconds to prepare a multi-hour print, and maybe a few hundred kilobytes or a couple megabytes on my hard drive that I will barely notice. This is a small tradeoff to ensure the best possible STL definition.</p>
|
<p>If you print for example a thin wall cylinder vertically you cannot turn the refinement high enough to not see the flats on the surface. My triangle counts are 524 for Low, 828 for Medium, 2206 for High, and if you select custom and pull the surface deviation slider all the way to the left you get 6572 triangles. The Surface Deviation shows 0.004406 mm which you would think would be fine enough. (This is for a 12 inch diameter cylinder with a 4 inch height and a wall thickness of 2.4 mm. The numbers vary depending on dimensions.) However you can see this level of deviation in the surface of common FDM type 3D prints. For those who are Metric impaired this is a deviation of 0.00017 inches or about 2 ten thousandths. The situation I present is the best case for an FDM type 3D printer and for just about anything else this level of refinement would be overkill. This is partially some arbitrary limitation in Fusion 360 but it is more a characteristic of using STL files. For my purposes being able to specify a surface deviation two or three times more precise would probably eliminate the visible artifacts. Increasing the refinement to the maximum possible will slow Fusion 360 when it computes the STL file and it will slow the slicer down as well but other than this there is no downside to using maximum refinement.</p>
| 1,058
|
<p>I have to read data from some files and insert the data into different tables in a database. Is Unix shell script powerful enough to do the job?</p>
<p>Is it easy to do the job in shell script or should I go about doing this in Java?</p>
|
<p>If the data you are trying to import is in a reasonable format -- comma-delimited, for example -- and your database server has reasonable command line utilities, this should be no problem. MySQL has the "mysqlimport" command-line tool that will accept various arguments describing the format of the file:</p>
<pre class="lang-sh prettyprint-override"><code>mysqlimport \
--fields-terminated-by=, \
--ignore-lines=1 \
--fields-optionally-enclosed-by='"' < datafile.txt
</code></pre>
<p>Passing the data through perl/sed/awk one-liners can help with getting it in the proper format, and the shell script can easily handle prompting for filenames, handling arguments, etc.</p>
<p>Using the various command-line tools provided by Unix is the entire point of bash scripting. Perl, mysql, etc. are all part of that toolkit.</p>
|
<p>Shell scripting (Bash or similar) primary intention is not to deal with databases. Go for Java or even better, ride this opportunity to learn the basics of a scripting language like Python or Ruby.</p>
| 9,731
|
<p>I'm working on an email solution in SQL Server ONLY that will use Database Mail to send out HTML formatted emails. The catch is that the images in the HTML need to be embedded in the outgoing email. This wouldn't be a problem if I were using a .net app to generate & send the emails but, unfortunately, all I have is SQL Server.</p>
<p>Is it possible for SQL Server to embed images on its own?</p>
|
<p>Yes, what you need to do is include the images as attachments and then they can be referenced within the HTML.</p>
<p>Use the <code>@file_attachment</code> parameter of <code>sp_send_dbmail</code></p>
|
<p>You could try to encode the image as base64 and reference it directly in an img tag within the email ( <code><img src="data:image/png;base64[your encoded image here...]</code> ) but i think most email clients correlate this technique with spam. I think you're better off referencing hosted images or simply attaching it to the email.</p>
| 5,658
|
<p>Is there any type of software in which you can animate the way the .stl object will be printed? </p>
<p>I'm not talking about what the end result looks like. I'm talking about a tool which acts like it's printing the given object as an animation.</p>
<p>I know it somehow depends on your printer but is there anything I can use?</p>
|
<p>You may wish to consider <a href="https://craftunique.com/craftware" rel="nofollow">Craftware</a> for your purposes. It's a free program in beta form that does provide a tool-path animation for printing the layers. It is not so much specific to a printer as it is configurable for your own requirements. <a href="https://www.youtube.com/watch?v=dv_WxUm1JC8" rel="nofollow">The video</a> shows what I believe you are seeking at about the two minute point.</p>
<p>Simplify3D also provides such information, but is not a free program.</p>
|
<p>I'm using <a href="http://www.mattercontrol.com" rel="nofollow">MatterControl</a> and it has such visualization. User can see synchronized animation which shows how the object is actually printed and user is able to see each path of filament put onto the layer.</p>
<p>It's possible to control starting and ending position so it's possible to precisely visualize each milimiter of filament even between start and end point.</p>
<p>MatterControl also visualizes extrude flow so if user set extrude to 150% or 200% then application shows wider "line".</p>
<p>All of it can be seen in 2D (from top view) and in 3D (perspective view).
There is also possible to see overlay (by transparency) and print speed (visualized by color).</p>
<p>MatterControl also shows non-printing moves and retraction points and their hight.</p>
| 269
|
<p>I'm trying to run powershell commands through a web interface (ASP.NET/C#) in order to create mailboxes/etc on Exchange 2007. When I run the page using Visual Studio (Cassini), the page loads up correctly. However, when I run it on IIS (v5.1), I get the error "unknown user name or bad password". The biggest problem that I noticed was that Powershell was logged in as ASPNET instead of my Active Directory Account. How do I force my Powershell session to be authenticated with another Active Directory Account?</p>
<p>Basically, the script that I have so far looks something like this:</p>
<pre><code>RunspaceConfiguration rc = RunspaceConfiguration.Create();
PSSnapInException snapEx = null;
rc.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out snapEx);
Runspace runspace = RunspaceFactory.CreateRunspace(rc);
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
using (pipeline)
{
pipeline.Commands.AddScript("Get-Mailbox -identity 'user.name'");
pipeline.Commands.Add("Out-String");
Collection<PSObject> results = pipeline.Invoke();
if (pipeline.Error != null && pipeline.Error.Count > 0)
{
foreach (object item in pipeline.Error.ReadToEnd())
resultString += "Error: " + item.ToString() + "\n";
}
runspace.Close();
foreach (PSObject obj in results)
resultString += obj.ToString();
}
return resultString;
</code></pre>
|
<p>Here is a class that I use to impersonate a user.</p>
<pre><code>using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace orr.Tools
{
#region Using directives.
using System.Security.Principal;
using System.Runtime.InteropServices;
using System.ComponentModel;
#endregion
/// <summary>
/// Impersonation of a user. Allows to execute code under another
/// user context.
/// Please note that the account that instantiates the Impersonator class
/// needs to have the 'Act as part of operating system' privilege set.
/// </summary>
/// <remarks>
/// This class is based on the information in the Microsoft knowledge base
/// article http://support.microsoft.com/default.aspx?scid=kb;en-us;Q306158
///
/// Encapsulate an instance into a using-directive like e.g.:
///
/// ...
/// using ( new Impersonator( "myUsername", "myDomainname", "myPassword" ) )
/// {
/// ...
/// [code that executes under the new context]
/// ...
/// }
/// ...
///
/// Please contact the author Uwe Keim (mailto:uwe.keim@zeta-software.de)
/// for questions regarding this class.
/// </remarks>
public class Impersonator :
IDisposable
{
#region Public methods.
/// <summary>
/// Constructor. Starts the impersonation with the given credentials.
/// Please note that the account that instantiates the Impersonator class
/// needs to have the 'Act as part of operating system' privilege set.
/// </summary>
/// <param name="userName">The name of the user to act as.</param>
/// <param name="domainName">The domain name of the user to act as.</param>
/// <param name="password">The password of the user to act as.</param>
public Impersonator(
string userName,
string domainName,
string password)
{
ImpersonateValidUser(userName, domainName, password);
}
// ------------------------------------------------------------------
#endregion
#region IDisposable member.
public void Dispose()
{
UndoImpersonation();
}
// ------------------------------------------------------------------
#endregion
#region P/Invoke.
[DllImport("advapi32.dll", SetLastError = true)]
private static extern int LogonUser(
string lpszUserName,
string lpszDomain,
string lpszPassword,
int dwLogonType,
int dwLogonProvider,
ref IntPtr phToken);
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern int DuplicateToken(
IntPtr hToken,
int impersonationLevel,
ref IntPtr hNewToken);
[DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool RevertToSelf();
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern bool CloseHandle(
IntPtr handle);
private const int LOGON32_LOGON_INTERACTIVE = 2;
private const int LOGON32_PROVIDER_DEFAULT = 0;
// ------------------------------------------------------------------
#endregion
#region Private member.
// ------------------------------------------------------------------
/// <summary>
/// Does the actual impersonation.
/// </summary>
/// <param name="userName">The name of the user to act as.</param>
/// <param name="domainName">The domain name of the user to act as.</param>
/// <param name="password">The password of the user to act as.</param>
private void ImpersonateValidUser(
string userName,
string domain,
string password)
{
WindowsIdentity tempWindowsIdentity = null;
IntPtr token = IntPtr.Zero;
IntPtr tokenDuplicate = IntPtr.Zero;
try
{
if (RevertToSelf())
{
if (LogonUser(
userName,
domain,
password,
LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT,
ref token) != 0)
{
if (DuplicateToken(token, 2, ref tokenDuplicate) != 0)
{
tempWindowsIdentity = new WindowsIdentity(tokenDuplicate);
impersonationContext = tempWindowsIdentity.Impersonate();
}
else
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
}
else
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
}
else
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
}
finally
{
if (token != IntPtr.Zero)
{
CloseHandle(token);
}
if (tokenDuplicate != IntPtr.Zero)
{
CloseHandle(tokenDuplicate);
}
}
}
/// <summary>
/// Reverts the impersonation.
/// </summary>
private void UndoImpersonation()
{
if (impersonationContext != null)
{
impersonationContext.Undo();
}
}
private WindowsImpersonationContext impersonationContext = null;
// ------------------------------------------------------------------
#endregion
}
}
</code></pre>
|
<p>You might need a patch.</p>
<p>From: <a href="http://support.microsoft.com/kb/943937" rel="nofollow noreferrer">http://support.microsoft.com/kb/943937</a></p>
<blockquote>
<p><strong>An application cannot impersonate a
user and then run Windows PowerShell
commands in an Exchange Server 2007
environment</strong></p>
<p>To resolve this problem, install
Update Rollup 1 for Exchange Server
2007 Service Pack 1.</p>
</blockquote>
| 3,292
|
<p>When writing a T-SQL script that I plan on re-running, often times I use temporary tables to store temporary data. Since the temp table is created on the fly, I'd like to be able to drop that table only if it exists (before I create it).</p>
<p>I'll post the method that I use, but I'd like to see if there is a better way.</p>
|
<pre><code>IF Object_Id('TempDB..#TempTable') IS NOT NULL
BEGIN
DROP TABLE #TempTable
END
</code></pre>
|
<pre><code>SELECT name
FROM sysobjects
WHERE type = 'U' AND name = 'TempTable'
</code></pre>
| 2,476
|
<p>I have searched the internet and found various 3D printers with different advantages and materials which they can print - some even multi color. </p>
<p>However, I cannot seem to find a printer that can print multiple material with different properties; for instance, simultaneously printing PLA and metal. Is there currently such a printer available or in development? </p>
|
<p>Yes and no.</p>
<blockquote>
<p>for instance simultanious printing of plas plastic and lets say metal. Is such a printer available or in development ?</p>
</blockquote>
<p>Practically speaking, no. Metal printing requires significantly higher temperatures than plastic, and the two processes are so incompatible that there is currently no good solutions that would allow one printer to print both in the same print. Whether extruding filament, laser sintering, or curing resins, the materials involved have to be fairly similar in processing environment to print adjacent to each other without issue.</p>
<p>There are many printers that are intended to print multiple materials by changing the print head. You might, for instance, use a ceramic paste extruder, then change the head for the next print using plastic.</p>
<p>There have been efforts in the past, and some efforts are ongoing, to resolve this. For instance wood's metal, a low temperature alloy, can be poured at temperatures compatible with plastics, so it's possible to create a printer that prints plastic, leaving troughs or voids in the plastic, then the same printer during this print would pour molten woods metal into these areas, which then solidifies into an internal metal structure. These are intended for circuitry and electrical use, however significant problems still exist because the thermal expansion differences in these materials lead to stress and result in poor reliability.</p>
<p>So while some of these processes are being developed, this is still just in the experimental stage and there are significant problems to overcome before printers can print widely different materials in a single printing session.</p>
<p>Of course you can find plastics with such a wide range of characteristics that they can be seen as printing different materials. Plastics imbued with wood fibers, printing next to conductive plastics with graphite, printing next to flexible plastics, etc, etc are now possible, and depending on your requirements they may meet your needs.</p>
|
<p>For the most part, you can achieve this with a dual extruding printer. However, dual extrusion is best for either multi-color printing or printing with support material. For example, printing the part with PLA and all support material with water soluble PVA.</p>
<p>In practice, printing two completely different materials is not sound engineering practice as they have the potential to not make a well enough bond to each other. So, the case of pure metal and pure plastic, the two materials will not bond well because they will not both be in the same physical state together at any point in time.</p>
<p>However, your best option would be a printer like the <a href="https://markforged.com/" rel="nofollow">MarkForged</a> which uses a composite approach by combining a common binder (ABS, PLA, Nylon, etc.) and a strong material such as Carbon Fiber, Fiberglass, or Kevlar.</p>
| 182
|
<p>I have made a temperature ⨉ fan speed tower which needed 3x9-1 ChangeAtZ post processing scripts and it took me quite much time to configure them all (and check it twice). Is there a way to save this, so that I wouldn't need to make them all again if something went wrong and I needed to start over or if I wanted to do something similar again ?</p>
|
<p>The UK uses 230 V mains voltage. The 220 V designation is from the past, Europe is now using 230 V. You do not have to worry about the frequency.</p>
<p>You should place the switch to 220 V and plug the cord into the socket. The printer should start immediately booting (cycling) the printer firmware, the LCD should light up and the cold end cooling fan will spin (annoyingly).</p>
<p>If nothing happens, you need to check the Power Supply Unit (PSU) and all cables for proper connection (does the fan of the PSU spin if it has one, you should at least see a led light up). A multimeter is not expensive and generally very valuable to test if it outputs 12 V. That way you know the PSU is working or not, if it works the problem is at the main printer board.</p>
<p>As these PSU's are pretty cheap and faulty, you could well have received a broken one. </p>
<hr>
<p><strong><em>How to measure the voltage?</em></strong></p>
<p><em>If you look at the connection terminals you will find labels above them. Measuring position 6 and 8 might be the incorrect ones, this depends on your PSU. If you have exactly the same PSU as from the linked video, measuring between 6 and 8 would be correct:</em></p>
<p><a href="https://i.stack.imgur.com/Z39Wq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z39Wq.png" alt="enter image description here"></a></p>
<p><em>From the image above the connections from left to right (for other PSU units, the order may be different, I have units where the connection to the mains is on the right):</em></p>
<ul>
<li><em><code>L</code>, <code>N</code> and <code>ground</code> are used for connection to the mains,</em></li>
<li><em><code>COM</code> (stands for common or 0 V) or sometimes denoted as <code>-V</code> is the output ground (negative, connection for the black wires) and</em></li>
<li><em><code>+V</code> is positive, connection for the red wires.</em></li>
</ul>
<p><em>You need to measure the voltage difference over <code>COM</code> and <code>+V</code>, this should be the voltage of the power supply. Ideally you measure the voltage when the power supply is delivering a load (e.g. directly connected to a strip of LEDs or directly connected to the heated bed; some faulty PSU crash in under load, this can be seen by a lower voltage than the rated voltage).</em></p>
<p><em>If the PSU is correctly wired, your fuse is not broken, does not have a LED lighted and the voltage is zero the unit is defective.</em></p>
|
<p>@Oscar was correct, so long as the switch is set at 220 V, the printer will turn on. I am adding this answer to help anyone else who has a similar problem.</p>
<p>I strongly recommend that you buy a multimeter if you have any power supply issues, as this helped me to figure out what was wrong.</p>
<p>There were three issues that needed to be rectified before my printer would turn on. The first was that I had bought a fairly cheap EU to UK plug converter from my local supermarket. This was mistake number one, as the quality was low and there was no ground pin for the power supply (which is dangerous). I plugged the EU plug into my converter, and then the converter into the UK mains socket, and it would not turn on. By using my multimeter I was able to figure out that the converter was a piece of rubbish. With the plug still plugged into the converter, but the converter removed from the mains, I touched my multimeter cable, whilst in continuity mode, on one of the three pins on the UK side of the converter (the bit that goes into the wall), and the other cable onto one of the terminals that I had connected the power cable to the power supply with. I touched each terminal in sequence to see if it was electrically connected to the pin on the converter. I repeated this in sequence and identified that the live pin on the converter was not connected, and so no current could flow when plugged into mains. I immediately defenestrated the converter. Here is the replacement that I bought:</p>
<p><a href="https://www.amazon.co.uk/gp/product/B00QGYY5DC/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1" rel="nofollow noreferrer">EU to UK converter</a></p>
<p>The next issue was that the power supply cable was wired up incorrectly (or at least unintuitively). In continuity mode again, I touched one multimeter cable to one pin on the EU plug of my power supply, and the other to one of the terminals (which were connected to the wiring of my power cable.) I discovered that the live and neutral wires of the power cable were wired the wrong way round on the plug (in order for it to be used in a UK converter, not sure what the wiring convention is on mainland EU). In the UK, the right hole in the mains socket is live, the left is neutral, and the top one is ground. On the EU plug I had been provided with, the left pin was live and the right pin was neutral. If I were to plug this in to the new converter in the normal orientation (cable coming out the bottom side), the live and neutral would have been connected incorrectly (plug-live -> converter-neutral, plug-neutral -> converter-live). Hence, in order for the pins to be situated correctly in the converter, and subsequently in the mains socket, the EU plug had to be plugged into the converter upside down (plug-live -> converter-live, plug-neutral -> converter-neutral). </p>
<p><strong>Finally, the official instructions for the wiring of the Anet A6 are wrong.</strong> If you follow the youtube video that they provide, you will see that the positive terminal is closest to the bottom of the diagram (on the thermistor/endstop side of the board). <a href="https://youtu.be/mQzOHL_89nc?t=1530" rel="nofollow noreferrer">Mainboard wiring instructions</a>. THIS IS INCORRECT. Check your board, as the polarity will be printed onto the board. If you wire up the mainboard according to the instructions, your V+ wire will go to the negative terminal of the mainboard and, your positive terminal will go to the COM wire of the power supply. This is wrong, as the positive terminal should be connected to the V+ wire, and the negative to COM.</p>
<p>Hopefully this helps save someone some frustration and time!</p>
| 1,552
|
<p>I'm looking for an answer in MS VC++.</p>
<p>When debugging a large C++ application, which unfortunately has a very extensive usage of C++ exceptions. Sometimes I catch an exception a little later than I actually want.</p>
<p>Example in pseudo code:</p>
<pre><code>FunctionB()
{
...
throw e;
...
}
FunctionA()
{
...
FunctionB()
...
}
try
{
Function A()
}
catch(e)
{
(<--- breakpoint)
...
}
</code></pre>
<p>I can catch the exception with a breakpoint when debugging. But I can't trace back if the exception occurred in <code>FunctionA()</code> or <code>FunctionB()</code>, or some other function. (Assuming extensive exception use and a huge version of the above example).</p>
<p>One solution to my problem is to determine and save the call stack <strong>in the exception constructor</strong> (i.e. before it is caught). But this would require me to derive all exceptions from this base exception class. It would also require a lot of code, and perhaps slow down my program.</p>
<p>Is there an easier way that requires less work? Without having to change my large code base?</p>
<p>Are there better solutions to this problem in other languages?</p>
|
<p>If you are just interested in where the exception came from, you could just write a simple macro like</p>
<pre><code>#define throwException(message) \
{ \
std::ostringstream oss; \
oss << __FILE __ << " " << __LINE__ << " " \
<< __FUNC__ << " " << message; \
throw std::exception(oss.str().c_str()); \
}
</code></pre>
<p>which will add the file name, line number and function name to the exception text (if the compiler provides the respective macros).</p>
<p>Then throw exceptions using</p>
<pre><code>throwException("An unknown enum value has been passed!");
</code></pre>
|
<p>Other languages? Well, in Java you call e.printStackTrace(); It doesn't get much simpler than that.</p>
| 5,671
|
<p>Does anyone know an easy way to import a raw, XML RSS feed into C#? Am looking for an easy way to get the XML as a string so I can parse it with a Regex.</p>
<p>Thanks,
-Greg</p>
|
<p>If you're on .NET 3.5 you now got built-in support for syndication feeds (RSS and ATOM). Check out this <a href="http://msdn.microsoft.com/en-us/magazine/cc135976.aspx" rel="noreferrer">MSDN Magazine Article for a good introduction</a>.</p>
<p>If you really want to parse the string using regex (and parsing XML is not what regex was intended for), the easiest way to get the content is to use the WebClient class.It got a download string which is straight forward to use. Just give it the URL of your feed. Check this <a href="http://www.daveamenta.com/2008-05/c-webclient-usage/" rel="noreferrer">link for an example of how to use it</a>.</p>
|
<p>XmlDocument (located in System.Xml, you will need to add a reference to the dll if it isn't added for you) is what you would use for getting the xml into C#. At that point, just call the InnerXml property which gives the inner Xml in string format then parse with the Regex.</p>
| 9,348
|
<p>I'm not talking about how to indent here. I'm looking for suggestions about the best way of organizing the chunks of code in a source file.</p>
<p>Do you arrange methods alphabetically? In the order you wrote them? Thematically? In some kind of 'didactic' order?</p>
<p>What organizing principles do you follow? Why?</p>
|
<p>i normally order by the following</p>
<ol>
<li>constructors</li>
<li>destructors</li>
<li>getters</li>
<li>setters</li>
<li>any 'magic' methods </li>
<li>methods for changing the persisted state of reciever (save() etc)</li>
<li>behaviors</li>
<li>public helper methods</li>
<li>private/protected helper methods</li>
<li>anything else (although if there is anything else its normally a sign that some refactoring is necessary)</li>
</ol>
|
<p>I group them based on what there doing, and then in the order I wrote them (alphabetically would probs be better though)</p>
<p>eg in texture.cpp I have:</p>
<pre><code>//====(DE)CONSTRUCTOR====
...
//====LOAD FUNCTIONS====
...
//====SAVE FUNCTIONS====
...
//====RESOURCE MANGEMENT FUNCTIONS====
//(preventing multiple copies being loaded etc)
...
//====UTILL FUNCTIONS====
//getting texture details, etc
...
//====OVERLOADED OPERTORS====
....
</code></pre>
| 9,870
|
<p>When executing SubmitChanges to the DataContext after updating a couple properties with a LINQ to SQL connection (against SQL Server Compact Edition) I get a "Row not found or changed." ChangeConflictException.</p>
<pre><code>var ctx = new Data.MobileServerDataDataContext(Common.DatabasePath);
var deviceSessionRecord = ctx.Sessions.First(sess => sess.SessionRecId == args.DeviceSessionId);
deviceSessionRecord.IsActive = false;
deviceSessionRecord.Disconnected = DateTime.Now;
ctx.SubmitChanges();
</code></pre>
<p>The query generates the following SQL:</p>
<pre><code>UPDATE [Sessions]
SET [Is_Active] = @p0, [Disconnected] = @p1
WHERE 0 = 1
-- @p0: Input Boolean (Size = 0; Prec = 0; Scale = 0) [False]
-- @p1: Input DateTime (Size = 0; Prec = 0; Scale = 0) [9/4/2008 5:12:02 PM]
-- Context: SqlProvider(SqlCE) Model: AttributedMetaModel Build: 3.5.21022.8
</code></pre>
<p>The obvious problem is the <strong>WHERE 0=1</strong>, After the record was loaded, I've confirmed that all the properties in the "deviceSessionRecord" are correct to include the primary key. Also when catching the "ChangeConflictException" there is no additional information about why this failed. I've also confirmed that this exception get's thrown with exactly one record in the database (the record I'm attempting to update)</p>
<p>What's strange is that I have a very similar update statement in a different section of code and it generates the following SQL and does indeed update my SQL Server Compact Edition database.</p>
<pre><code>UPDATE [Sessions]
SET [Is_Active] = @p4, [Disconnected] = @p5
WHERE ([Session_RecId] = @p0) AND ([App_RecId] = @p1) AND ([Is_Active] = 1) AND ([Established] = @p2) AND ([Disconnected] IS NULL) AND ([Member_Id] IS NULL) AND ([Company_Id] IS NULL) AND ([Site] IS NULL) AND (NOT ([Is_Device] = 1)) AND ([Machine_Name] = @p3)
-- @p0: Input Guid (Size = 0; Prec = 0; Scale = 0) [0fbbee53-cf4c-4643-9045-e0a284ad131b]
-- @p1: Input Guid (Size = 0; Prec = 0; Scale = 0) [7a174954-dd18-406e-833d-8da650207d3d]
-- @p2: Input DateTime (Size = 0; Prec = 0; Scale = 0) [9/4/2008 5:20:50 PM]
-- @p3: Input String (Size = 0; Prec = 0; Scale = 0) [CWMOBILEDEV]
-- @p4: Input Boolean (Size = 0; Prec = 0; Scale = 0) [False]
-- @p5: Input DateTime (Size = 0; Prec = 0; Scale = 0) [9/4/2008 5:20:52 PM]
-- Context: SqlProvider(SqlCE) Model: AttributedMetaModel Build: 3.5.21022.8
</code></pre>
<p>I have confirmed that the proper primary fields values have been identified in both the Database Schema and the DBML that generates the LINQ classes.</p>
<p>I guess this is almost a two part question:</p>
<ol>
<li>Why is the exception being thrown?</li>
<li>After reviewing the second set of generated SQL, it seems like for detecting conflicts it would be nice to check all the fields, but I imagine this would be fairly inefficient. Is this the way this always works? Is there a setting to just check the primary key?</li>
</ol>
<p>I've been fighting with this for the past two hours so any help would be appreciated.</p>
|
<p>Thats nasty, but simple:</p>
<p>Check if the data types for all fields in the O/R-Designer match the data types in your SQL table.
<strong>Double check for nullable!</strong> A column should be either nullable in both the O/R-Designer and SQL, or not nullable in both.</p>
<p>For example, a NVARCHAR column "title" is marked as NULLable in your database, and contains the value NULL. Even though the column is marked as NOT NULLable in your O/R-Mapping, LINQ will load it successfully and set the column-String to null.</p>
<ul>
<li>Now you change something and call
SubmitChanges().</li>
<li>LINQ will generate a SQL query
containing "WHERE [title] IS NULL", to make sure the title has not been changed by someone else.</li>
<li>LINQ looks up the properties of
[title] in the mapping.</li>
<li>LINQ will find [title] NOT NULLable.</li>
<li>Since [title] is NOT NULLable, by
logic it never could be NULL!</li>
<li>So, optimizing the query, LINQ
replaces it with "where 0 = 1", the
SQL equivalent of "never".</li>
</ul>
<p>The same symptom will appear when the data types of a field does not match the data type in SQL, or if fields are missing, since LINQ will not be able to make sure the SQL data has not changed since reading the data.</p>
|
<p>I know this question has long since been answered but here I have spent the last few hours banging my head against a wall and I just wanted to share my solution which turned out not to be related to any of the items in this thread:</p>
<h2>Caching!</h2>
<p>The select() part of my data object was using caching. When it came to updating the object a Row Not Found Or Changed error was cropping up. </p>
<p>Several of the answers did mention using different DataContext's and in retrospect this is probably what was happening but it didn't instantly lead me to think caching so hopefully this will help somebody!</p>
| 6,685
|
<p>I am very new in the 3D printing scene.
After a lot of searching for my specific problem (and didn't find any answers, of course) I decided to reach out.</p>
<p>I bought a Creality Ender 3 Pro in November and after a few days of lovely prints
I decided to upgrade the printer with a glass bed and "Aluminum Dual Gear Pulley Dual Drive Extruder Kit".</p>
<p>The Problem, as you might expected already, is with the installation of the dual gear extruder. I have watched a dozen of YouTube videos, and all of them have something I don't – a screw in the stock gold gear on the extruder motor.</p>
<p>How can I install the Aluminum Dual Gear Pulley Dual Drive Extruder Kit if I take the gear out? Should I try remove it with force?
Please if someone has come across the same situation, that there isn’t a screw In the stock gear on the extruder motor and mange to take it out, please tell me.
I'm adding a picture so you understand what I mean.</p>
<p><img src="https://i.stack.imgur.com/7F5YQ.jpg" alt="" />
<img src="https://i.stack.imgur.com/MIBeb.jpg" alt="" /></p>
|
<p>This is an older Ender 3 Pro, they at one point came with these press-fit gears, these are not intended to be removed which is a poor design decision. I would recommend buying a new motor than going through the hassle of removing it.</p>
|
<p>Same problem here. I removed it by force using a pliers and a hammer, then drill a spot on the shaft using ikea drill. Everything works fine so far.</p>
| 1,811
|
<p>I bought new yellow PLA filament from XYZ (1.75 mm). </p>
<p>Over the past I have printed many objects with my da Vinci 1.0 (ABS only). I found that while the brim is being printing (using default configuration of XYZWare; the da Vinci machines give the user very little control over print parameters, if I remember correctly the temperatures are controlled by the chip in the filament cassette), filament stopped extruding from my extruder immediately. However, ABS can be printed properly. </p>
<p>Could anyone tell me how can I work around ?</p>
<p><a href="https://i.stack.imgur.com/TJPFb.jpg" rel="nofollow noreferrer" title="Part of brim that stopped printing"><img src="https://i.stack.imgur.com/TJPFb.jpg" alt="Part of brim that stopped printing" title="Part of brim that stopped printing"></a></p>
|
<p>The answer to this specific instance appeared in the comments:</p>
<blockquote>
<p>Also, <a href="https://3dprinting.stackexchange.com/a/6092/">a thorough cleaning of the nozzle/hotend</a> might also be a good idea to get rid of all the stuck ABS residue inside. – 0scar Mar 26 at 8:44</p>
<p>The problem solved !, my ABS is stuck in nozzle !!! – 3ORZ Apr 25 at 6:52</p>
</blockquote>
|
<p>That looks pretty bad for a number of reasons. If you've got an all-metal hotend, you can be pretty sure that your PLA issues are probably at least partially cooling-related. I'd recommend you try and find a better fan duct design for your hotend, if possible, and possibly upgrade to a better fan.</p>
<p>You can temporarily skirt around cooling issues with PLA in all-metal hotends by printing <em>more material</em>, which typically means one or all of the following:</p>
<ol>
<li>Faster print speeds (if your printer can move quickly enough and has good acceleration)</li>
<li>Thicker lines! Surprisingly useful. If you don't want to sacrifice print detail, then make the infill lines ridiculously thick, the inner wall lines fairly thick, and the single outer perimeter "normal" thickness.</li>
<li>Thicker layer height. Normally I printed at 0.2mm like everyone else, but with PLA in my all-metal hotend, I had to up it to 0.3 with fatter lines as well. </li>
</ol>
<p>If you can consistently keep the filament going through the hotend instead of lingering inside of it, you can basically "push" the melt zone back down into the heater block where it belongs, instead of it creeping upwards and resulting in a jam. </p>
<p>As a side note, the rippled surface of your brim there looks very similar to what used to happen to mine; the ripples are usually indicative of some form of over-extrusion on the first layer. I'd maybe look into checking your Z offset to make sure your print nozzle is far enough away from the bed, and maybe also check your flow rate is accurate for that particular filament. Check the filament diameter in a few places with a micrometer if you have access to one, and compare to your ABS prints to see if maybe you should adjust the flow rate down a few percent in your slicer.</p>
| 1,259
|
<p>Is it in best interests of the software development industry for one framework, browser or language to <strong>win the war</strong> and become the de facto standard? On one side it takes away the challenges of cross platform, but it opens it up for a single point of failure. Would it also result in a stagnation of innovation, or would it allow the industry to focus on more important things (whatever those might be).</p>
|
<p>Defacto standards are bad because they are usually controlled by a single party. What is best for the industry is for there to be a foundation of open standards on top of which everyone can compete. </p>
<p>The web is a perfect example. When IE won the browser war, it stagnated for <em>years</em>, and is only just now starting to improve because it's hemorrhaging marketshare. The Netscape years prior to that weren't much better. The CSS 2.1 standard was released ten years ago and still isn't supported well. As a consequence, web development is a Black Art of hacks and work-arounds to get websites to render consistently.</p>
<p>My job would be a hundred times easier if I could build a website according to web standards and be confident it would display correctly. Just think of all the cool things we could have been working on instead of fixing IE's rendering errors.</p>
|
<p>No. Competition is good. It may make a web developers job easier, but I think it's bad for the industry. I personally prefer having choices. </p>
<p>I believe Joel Spolsky's technique of creating his own language (Wasabi) to insulate his company from being platform specific is a good one. I also believe it is a good idea to use products that accomplish similar things that are more targeted at specific problems like JQuery.</p>
| 3,401
|
<p>I was wondering if anyone tried migrating between TS and SVN/CC.
What I mean by migrating is importing and exporting the repository between source control systems without losing the history.</p>
<p>How good are the tools to migrate to and from VSTS? </p>
<p>I am also interested in knowing any opinion regarding using Team System from users of SVN and continuous integration.</p>
<p>EDIT:
Assume I need the history, otherwise why use a SCM?</p>
|
<p>Try tfs2svn... worked great for a project with 1200 TFS changesets. It was a bit fussy to setup when svn authentication is enabled, but otherwise great.</p>
<p><a href="http://sourceforge.net/projects/tfs2svn/" rel="nofollow noreferrer">http://sourceforge.net/projects/tfs2svn/</a></p>
|
<p>In a <a href="http://www.dotnetrocks.com/default.aspx?showNum=373" rel="nofollow noreferrer">recent episode of DotNetRocks!</a> Brian Randell and Martin Woodward are of the opinion that in adopting a new Source Control / SCM system you're probably better off starting from a clean slate (begin with the most recent release and don't try to migrate history, and use the original system for read-only viewing of change history / blame).</p>
<p>Their discussion was focussed on Visual Source Safe rather than SVN and clearly the migration from/to SVN won't be nearly so problematic but I still think it's good advice. Ask yourself the question "how often do I <em>really</em> need the history?". Is it more work than justifies the benefit? Are you just making a rod for your own back? (...insert metaphor here...)</p>
<p><strong>Update:</strong> whoa! someone just gave <a href="https://stackoverflow.com/questions/71749/migrating-to-team-system-from-svn-cruise-controlnet-and-back#71859">exactly the same answer</a> at the same time as me - spooky!</p>
| 9,728
|
<p>I am trying to join together several audio files into one mp4/m4a file containing chapter metadata.</p>
<p>I am currently using QTKit to do this but unfortunately when QTKit exports to m4a format the metadata is all stripped out (this has been confirmed as a bug by Apple) see <a href="http://files.shinydevelopment.com/audiojoiner.zip" rel="nofollow noreferrer">sample code</a>. I think this rules QTKit out for this job, but would be happy to be proven wrong as it is a really neat API for it if it worked.</p>
<p>So, I am looking for a way to concatenate audio files (input format does not really matter as I can do conversion) into an m4a file with chapters metadata.</p>
<p>As an alternative to code, I am open to the idea of using an existing command line tool to accomplish this as long as it is redistributable as part of another application.</p>
<p>Any ideas?</p>
|
<p><a href="http://audiobookmaker.sourceforge.net/" rel="nofollow noreferrer">Audiobook Maker</a> does something like this, and I believe it uses ffmpeg under the hood. It's open source, so maybe its worth a look?</p>
|
<p>Depending on where the bug is, you could try going straight to the QuickTime C APIs to write the movie file. You might also try adding the chapters track using the C APIs. </p>
<p>Any word on when Apple will fix the bug? I am planning to create enhanced podcasts with QTKit, and need this to work. </p>
| 7,724
|
<p>I would like to make custom cake molds. </p>
<p>I've asked about this in a few stores that specialize in cooking equipment, they said this wasn't possible. </p>
<p>I wonder if 3D printing makes it possible. It would require a material that is food-safe, as per <a href="https://3dprinting.stackexchange.com/questions/147/which-are-the-food-safe-materials-and-how-do-i-recognize-them">Which are the food-safe materials and how do I recognize them?</a></p>
<p>However, there are two extra conditions:</p>
<ul>
<li>The material must be able to withstand the heat of an oven or microwave, and not mix with the dough.</li>
<li>It should not be too difficult to remove the cake from the mold after it is ready.</li>
</ul>
<p>The first condition is where this question is a little different from <a href="https://3dprinting.stackexchange.com/questions/181/can-you-use-pla-material-with-food-and-drinks">Can you use PLA material with food and drinks?</a> - that question is about cutlery and glasses, not about things that go into the oven or microwave.</p>
<p>Is there a material that can be used for this purpose?</p>
|
<p>For <a href="http://3dprintingfromscratch.com/common/types-of-3d-printers-or-3d-printing-technologies-overview/#fdm" rel="nofollow noreferrer">FDM</a> printing: </p>
<p>Both Cura and Makerbot Desktop (and perhaps others I'm not as familiar with) will give you a preview of both the length and weight of your print, including supports/rafts. Once the print is done you can weigh it on a kitchen scale.</p>
<p>PLA Filament currently runs about \$23/kg on Amazon, which works out to \$0.023/g. Multiplication can then give you a good estimate of materials costs for a print.</p>
<p>Only experience with your specific printer will give you an idea of how often you're going to hit a failed print, and how often you're going to need to replace parts. For wear and tear you could try using a depreciation model of 2-3 years, but that's only an estimate.</p>
|
<p>I recently faced the problem of calculating the cost of my printed 3D models. I wanted to know what their real value had to be counted in Excel. It was really inconvenient. Then I found a program for counting, it turned out really great, even takes into account the electricity. This is not an advertisement just throwing, maybe someone also encountered such a problem.
<a href="https://codecanyon.net/item/mcc-3d-model-cost-calculation-for-3d-printer/24033425" rel="nofollow noreferrer">https://codecanyon.net/item/mcc-3d-model-cost-calculation-for-3d-printer/24033425</a>
I was interested in the question who solved the given problem in what ways?</p>
| 130
|
<p>first time here.</p>
<p>I recently bought an Anycubic Mega S and I'm venturing in the 3D world. Lots to learn for sure. I have printed a few items so far and all went pretty well.</p>
<p>My question is about something that caught my attention while browsing on Thingiverse. I was looking for an organizer for a board game that I have and every option I found there shows the piece in a vertical position rather than horizontal which seems like the natural position of the piece.</p>
<p>I would like to know why most of this types of pieces are set to be printed in a vertical position rather than horizontal.</p>
<p>Here is the original piece <a href="https://www.thingiverse.com/thing:2949421" rel="nofollow noreferrer">Betrayal at Baldur's Gate Organizer</a> by <a href="https://www.thingiverse.com/playfutbol2/designs" rel="nofollow noreferrer">Jason Patch</a>. As you can see in the image below the piece is naturally horizontal but the actual files to print (blue ones) are all vertical.</p>
<p><a href="https://i.stack.imgur.com/Vik4M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vik4M.png" alt="enter image description here" /></a></p>
<p>PS.: I didn't really know which tags to use so I just added 3D, feel free to suggest any other I will happily edit it. :)</p>
|
<p>Thingieverse does respect the orientation an item was designed in, just like most slicers will. Designers will often choose any one of the three planes (XY, YZ, ZX) as their first by preference, then work out the other parts in relation to the first. This does often not take into account the actual print orientation it should be printed in.</p>
<p>In the case of this box, you'd have to turn all items around the Y-axis (the front-left to back-right one) by 90°, first to the <em>front</em>, then the <em>back</em> then to the <em>front</em> again, getting almost 0 overhangs.</p>
|
<p>When I design parts in CAD software I pick a starting plane and go from there. And that starting plane doesn't correspond to how the part is designed to be printed. That usually comes later.</p>
| 1,724
|
<p>In my application I have <code>TextBox</code> in a <code>FormView</code> bound to a <code>LinqDataSource</code> like so:</p>
<pre><code><asp:TextBox ID="MyTextBox" runat="server"
Text='<%# Bind("MyValue") %>' AutoPostBack="True"
ontextchanged="MyTextBox_TextChanged" />
protected void MyTextBox_TextChanged(object sender, EventArgs e)
{
MyFormView.UpdateItem(false);
}
</code></pre>
<p>This is inside an <code>UpdatePanel</code> so any change to the field is immediately persisted. Also, the value of <code>MyValue</code> is <code>decimal?</code>. This works fine unless I enter any string which cannot be converted to decimal into the field. In that case, the <code>UpdateItem</code> call throws: </p>
<blockquote>
<p><strong>LinqDataSourceValidationException</strong> -
Failed to set one or more properties on type MyType. asdf is not a valid value for Decimal.</p>
</blockquote>
<p>I understand the problem, ASP.NET does not know how to convert from 'asdf' to decimal?. What I would like it to do is convert all these invalid values to null. What is the best way to do this?</p>
|
<p>There was an interesting discussion of Technical Debt based on your definition of done on HanselMinutes a couple of weeks ago -- <a href="http://www.hanselminutes.com/default.aspx?showID=137" rel="nofollow noreferrer">What is Done</a>. The basics of the show were that if you re-define 'Done' to increase perceived velocity, then you will amass Technical Debt. The corollary of this is that if you do not have a proper definition of 'Done' then you most likely are acquiring a list of items that will need to be finished before release irrespective of the design methodology.</p>
|
<p>That's why it's always easier to write nice "acadamic papers" talking about how Agile development is good, what are the "best practices" and so on.</p>
<p>That's why you find a lot of "suited engineers" making up new software engineering techniques.</p>
<p>Process is important, keeping best practices is cool but over any other thing, common sense drive design process. Software is developed by people so YAGNI really should be: </p>
<p>I might not gonna needed but maybe I will because in my concrete bussiness/company/department this thing do happen or I will need it but I just haven't the time right no so quick and dirty hack to make the cash and keep my job, or I might need it and refactoring later will be a pain in the ass costing 10 times more than just doing it now from the scratch, and I have the time NOW.</p>
<p>So use your common sense, trust it or trust the common sense of the people working for you. Don't take every academic paper as proven fact, experience is the best teacher and your company should improve their way or making things with time and its own experience.</p>
<p><strong>Edit:</strong> Incidentally, TDD is the opposite of YAGNI you're building test before even knowing if you are gonna need them. Seriously, stop listening to academics!! There's no magical way to produce software.</p>
| 8,596
|
<p>A question that occasionally arises is what is the best way to determine the changelist that you last synced to in Perforce. This is often needed for things like injecting the changelist number into the revision info by the automatic build system.</p>
|
<p>I recommend the opposite for automatic build systems: you should first get the latest changelist from the server using:</p>
<pre><code>p4 changes -s submitted -m1
</code></pre>
<p>then sync to that change and record it in the revision info. The reason is as follows. Although <a href="https://portal.perforce.com/s/article/3458" rel="nofollow noreferrer">Perforce recommends the following</a> to determine the changelist to which the workspace is synced:</p>
<pre><code>p4 changes -m1 @clientname
</code></pre>
<p>they note a few gotchas:</p>
<ul>
<li>This only works if you have not submitted anything from the workspace in question.</li>
<li>It is also possible that a client workspace is not synced to any specific changelist.</li>
</ul>
<p>and there's an additional gotcha they don't mention:</p>
<ul>
<li>If the highest changelist to which the sync occured strictly deleted files from the workspace, the next-highest changelist will be reported (unless it, too, strictly deleted files).</li>
</ul>
<p>If you must sync first and record later, Perforce recommends running the following command to determine if you've been bit by the above gotchas; it should indicate nothing was synced or removed:</p>
<pre><code>p4 sync -n @changelist_number
</code></pre>
|
<p>I am not sure if you got the answer you needed but I had a similar problem. The goal was to write in our logger the specific version of the project. The problem was that while we are making our own makefile, the overall build system is controlled by our configuration management. This means that all the solutions which say "sync to something then do something" don't really work and I didn't want to manually change the version whenever we commit (a sure source for errors).
The solution (which is actually hinted in some of the answers above) is this:
in our makefile, I do p4 changes -m1 "./...#have"
The result for this is Change change_number on date by user@client 'msg'
I simply create the message into a string which is printed by the logger (the change number is the important element but the other is also useful to quickly decide if a certain version contains changes you know you made yourself without going to perforce to check).
Hope this helps.</p>
| 6,920
|
<p>I'm currently building a Java app that could end up being run on many different platforms, but primarily variants of Solaris, Linux and Windows.</p>
<p>Has anyone been able to successfully extract information such as the current disk space used, CPU utilisation and memory used in the underlying OS? What about just what the Java app itself is consuming?</p>
<p>Preferrably I'd like to get this information without using JNI.</p>
|
<p>You can get some limited memory information from the Runtime class. It really isn't exactly what you are looking for, but I thought I would provide it for the sake of completeness. Here is a small example. Edit: You can also get disk usage information from the java.io.File class. The disk space usage stuff requires Java 1.6 or higher.</p>
<pre><code>public class Main {
public static void main(String[] args) {
/* Total number of processors or cores available to the JVM */
System.out.println("Available processors (cores): " +
Runtime.getRuntime().availableProcessors());
/* Total amount of free memory available to the JVM */
System.out.println("Free memory (bytes): " +
Runtime.getRuntime().freeMemory());
/* This will return Long.MAX_VALUE if there is no preset limit */
long maxMemory = Runtime.getRuntime().maxMemory();
/* Maximum amount of memory the JVM will attempt to use */
System.out.println("Maximum memory (bytes): " +
(maxMemory == Long.MAX_VALUE ? "no limit" : maxMemory));
/* Total memory currently available to the JVM */
System.out.println("Total memory available to JVM (bytes): " +
Runtime.getRuntime().totalMemory());
/* Get a list of all filesystem roots on this system */
File[] roots = File.listRoots();
/* For each filesystem root, print some info */
for (File root : roots) {
System.out.println("File system root: " + root.getAbsolutePath());
System.out.println("Total space (bytes): " + root.getTotalSpace());
System.out.println("Free space (bytes): " + root.getFreeSpace());
System.out.println("Usable space (bytes): " + root.getUsableSpace());
}
}
}
</code></pre>
|
<p>Not exactly what you asked for, but I'd recommend checking out <a href="https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/ArchUtils.html" rel="nofollow noreferrer">ArchUtils</a> and <a href="https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/SystemUtils.html" rel="nofollow noreferrer">SystemUtils</a> from <code>commons-lang3</code>. These also contain some relevant helper facilities, <em>e.g.</em>:</p>
<pre><code>import static org.apache.commons.lang3.ArchUtils.*;
import static org.apache.commons.lang3.SystemUtils.*;
System.out.printf("OS architecture: %s\n", OS_ARCH); // OS architecture: amd64
System.out.printf("OS name: %s\n", OS_NAME); // OS name: Linux
System.out.printf("OS version: %s\n", OS_VERSION); // OS version: 5.18.16-200.fc36.x86_64
System.out.printf("Is Linux? - %b\n", IS_OS_LINUX); // Is Linux? - true
System.out.printf("Is Mac? - %b\n", IS_OS_MAC); // Is Mac? - false
System.out.printf("Is Windows? - %b\n", IS_OS_WINDOWS); // Is Windows? - false
System.out.printf("JVM name: %s\n", JAVA_VM_NAME); // JVM name: Java HotSpot(TM) 64-Bit Server VM
System.out.printf("JVM vendor: %s\n", JAVA_VM_VENDOR); // JVM vendor: Oracle Corporation
System.out.printf("JVM version: %s\n", JAVA_VM_VERSION); // JVM version: 11.0.12+8-LTS-237
System.out.printf("Username: %s\n", getUserName()); // Username: johndoe
System.out.printf("Hostname: %s\n", getHostName()); // Hostname: garage-pc
var processor = getProcessor();
System.out.printf("CPU arch: %s\n", processor.getArch()) // CPU arch: BIT_64
System.out.printf("CPU type: %s\n", processor.getType()); // CPU type: X86
</code></pre>
| 4,518
|
<p>Inspired by this CodingHorror article, "<a href="http://www.codinghorror.com/blog/archives/001167.html" rel="noreferrer">Protecting Your Cookies: HttpOnly</a>"</p>
<p>How do you set this property? Somewhere in the web config?</p>
|
<p>If you're using ASP.NET 2.0 or greater, you can turn it on in the Web.config file. In the <system.web> section, add the following line:</p>
<pre><code><httpCookies httpOnlyCookies="true"/>
</code></pre>
|
<p>Interestingly putting <code><httpCookies httpOnlyCookies="false"/></code> doesn't seem to disable <code>httpOnlyCookies</code> in ASP.NET 2.0. Check this article about <a href="http://nerd.steveferson.com/2007/09/14/act-sessionid-and-login-problems-with-asp-net-20/" rel="nofollow noreferrer">SessionID and Login Problems With ASP .NET 2.0</a>.</p>
<p>Looks like Microsoft took the decision to not allow you to disable it from the web.config. Check this <a href="http://forums.asp.net/p/976773/1240648.aspx" rel="nofollow noreferrer">post on forums.asp.net</a></p>
| 5,362
|
<p>If so how? </p>
<p>Did you roll your own with jQuery or use the Microsoft AJAX toolkit?</p>
<p>Did you create a webservice or call an action?</p>
<hr>
<p><strong>EDIT</strong> : Please note that this question was asked before Microsoft announced that they were going to bundle jQuery in with VS/ASP.NET MVC. I think there is less of a discussion around this topic now and the answer would now almost always be 'use jQuery'. IainMH 11th Feb 2009</p>
|
<p>jQuery, action, return JSON.</p>
<p><a href="http://devlicio.us/blogs/mike_nichols/archive/2008/05/25/jquery-cascade-cascading-values-from-forms.aspx" rel="nofollow noreferrer">http://devlicio.us/blogs/mike_nichols/archive/2008/05/25/jquery-cascade-cascading-values-from-forms.aspx</a></p>
|
<p><a href="http://blog.noma.li/2010/03/autopostback-and-cascading-drop-downs-in-asp-net-mvc-and-jquery/" rel="nofollow noreferrer">http://blog.noma.li/2010/03/autopostback-and-cascading-drop-downs-in-asp-net-mvc-and-jquery/</a></p>
| 6,086
|
<p>I'd like to know the standard way to benchmark a SQL Sever Query, preferably I'd like to know about the tools that come with SQL Server rather than 3rd Party tools.</p>
|
<p>set showplan_text on
will show you the execution plan (to see it graphically use <kbd>CTRL</kbd> + <kbd>K</kbd> (sql 2000) or <kbd>CTRL</kbd> + <kbd>M</kbd> (sql 2005 +)</p>
<p>set statistics IO on
will show you the reads</p>
<p>set statistics time on
will show you the elapsed time</p>
|
<p>+1 on the execution plan. From here you can see where all the time is being spent in your particular query. Eg. 85% of the time is spent table scanning a particular table, can you put an index on that table to improve it? etc etc.</p>
| 5,523
|
<p><img src="https://i.stack.imgur.com/xE1dA.gif" alt="enter image description here"></p>
<p>This is what is happening to my motor. Any suggestions would help.
1. I have tried adjusting the trimpot.
2. Rewire the connector to match the one on the motherboard.
3. Anything else I found on the internet.</p>
|
<p>If the one in your question is your <em>complete</em> code, a possibility is that your computer is just buffering the output for the serial port, withholding it in memory. Try to add</p>
<pre><code>ser.flush()
</code></pre>
<p>after your last line. This command will... well... <em>flush</em> anything into the buffer through the actual connection.</p>
|
<p>Sorry for the late answer, but with Repetrel v3 and later, we have the option for you to configure a secondary COM port, and relay G- or M-Code commands from your other source through the Repetrel software to the printer. Please contact us for assistance.</p>
<p>Note: I work for Hyrel 3D.</p>
| 802
|
<p>I'm looking for secure ways to pass data between a client running Flash and a server. The data in question will be generated BY the Flash app, which in this case is your score after finishing a game. I want to verify the data is untampered on the server. What are some good methods of getting this done?</p>
<p>One simple way is to perform some operations on the data such as a hash, and pass the hash back to the server along with the data. This is easily broken by someone with access to the client source code, however.</p>
<p><strong>Edit</strong>: I realize that nothing will be unhackable, but I want to make it as difficult as possible. @jcnnghm's solution of encryping data with a public key and optionally doing sanity-checks and/or recalculation with the game logs is the best option I think. SSL encryption is also a good idea as this makes it more difficult to decipher what's actually being sent back to the server.</p>
|
<p>Encrypt the data with a public key stored in the binary. This will raise the barrier of entry for an attack. In addition to that, sanity check the data as it arrives on the server. This could be as simple as calculating the maximum number of points that could realistically be earned per time unit of play, or transmitting game logs back to the server to make sure the scoring is correct.</p>
<p>Nothing is going to be totally hack proof, no matter what you do, but this will stop all but the most determined.</p>
<p><strong>Update:</strong> @mark: Flash supports SSL natively.</p>
|
<p>As long as people can get at the executable - which, unless you want to run the game on a locked kiosk, is always the case - there's no perfectly secure way of doing this.</p>
<p>The music and movie industries spent tens of millions on DRM that got cracked by home hobbyists in days/weeks. If they can't protect <em>their</em> stuff...</p>
| 6,855
|
<p>I'm not going to be too surprised if I get shot-down for asking a "non programming" question, but maybe somebody knows ...</p>
<p>I was zipping the contents of my subversion sandbox using WinXP's inbuilt "Send to Compressed (zipped) Folder" capability and was surprised to find that the .zip file created did not contain the .svn directories and their contents.</p>
<p>I had always assumed that all files were included and I can't locate which property/option/attribute controls inclusion or otherwise. Can anybody help?</p>
<p>Thanks, Tom</p>
<p>EDIT:</p>
<p>So, isnt there a smart way to handle the problem? The real problem (show hidden files set to true. .svn folders are not compressed because windows does not consider them as valid folders) is still un-answered.</p>
<p>Thanks...</p>
|
<p>Send to zipped Folder does not traverse into folders without names before dot (like ".svn"). If you had other folders that begin with dots, those would not be included either. Files without names are not excluded. Hidden attribute does not come into play.</p>
<p>Might be a bug, might be by design. Remember that Windows explorer does not allow creating folders beginning with dot, even though the underlying system can handle them.</p>
|
<p>A compressed folder doesn't mean that it will be a .ZIP file, only the contents of the folder are compressed and to you it will look like a normal folder</p>
| 5,002
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.