instruction
stringlengths 27
22.5k
| chosen
stringlengths 27
28.2k
| rejected
stringlengths 19
24.9k
| __index_level_0__
int64 0
10k
|
|---|---|---|---|
<p>I am using Cura 4.13.1 as a slicer for my Ender 3 v2 printer.</p>
<p>I want to print a model which I scaled to 400 %. To improve bed adhesion I wanted to add a default raft (Extra Margin = 15 mm). Unfortunately, Cura is not able to slice the model despite being still within the printer's build volume (400 % = 190x200x200 mm). I have to reduce the scaling to 365 % (= 171x183x180 mmm) to fit the slicing.</p>
<p>As a workaround for printing the 400 % size, I will try to use a small support structure for better bed adhesion but I would prefer a raft.</p>
<p><strong>Edit:</strong> Sorry for leaving out the info about the models form. I get the 220+raft limitation but my model is tapered downwards:
<a href="https://i.stack.imgur.com/9PC5q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9PC5q.png" alt="enter image description here" /></a></p>
<p>So the raft actually fits the printers/slicers default limit.
Does it really not matter and cura simply adds the raft size to models max X and Y values?</p>
|
<p>The raft still needs to fit on the bed, and it counts as a print, because, it is printed. You want the raft for better adhesion, so that means that you need more contact with the bed. If you’re not, your basically wasting filament. Its kinda logical actually.</p>
|
<h2>Adjusted model Dimensions</h2>
<p>The model has the size determined by the base area of the bounding box, in this case, <span class="math-container">$\pu{190 \times 200 mm }$</span>. The raft as told by OP adds 15mm on <strong>all</strong> sides of the model, and thus adds 30 mm in total on both the X and Y dimensions. This gets us a bounding box floor area of <span class="math-container">$\pu{220 \times 230 mm}$</span>.</p>
<p>The model's bounding box has a height of <span class="math-container">$\pu{200 mm}$</span>. Add to that the thickness of the raft. This is not mentioned, but in the worst case, this is about 3 mm, and so you get <span class="math-container">$\pu{203 mm}$</span> as the maximum. Our model's Bounding Box thus is <span class="math-container">$\pu{220\times 230\times 203 mm}$</span></p>
<p>The smaller scale model (<span class="math-container">$\pu{171 \times 183 \times 180 mm}$</span>) results in an adjusted area of <span class="math-container">$\pu{201 \times 213 \times 183 mm}$</span>.</p>
<h2>Printer dimensions</h2>
<p>The standard Creality Ender3 v2 is set up with a build volume of (<span class="math-container">$\pu{220\times 220\times 250 mm}$</span>) As your base area is 230 mm in one dimension, it just can't fit. The slightly scaled item is <em>just</em> under that dimension and thus fits.</p>
<h2>Solutions</h2>
<p>With a firmware update, the printer can be told to use all of the bed, and then Cura's printer settings can be adjusted accordingly.</p>
<p>Sometimes, but not in this case, rotating the model can result in a model that doesn't fit in normal orientation to fit: A line of 240 mm doesn't fit along the X or Y axis, but easily along the diagonal of the printer. In fact, it is enough to turn the model by about 23.3° and the line fits:</p>
<p><a href="https://i.stack.imgur.com/rP9Ab.png" rel="nofollow noreferrer" title="Graphic showing a 240 mm line at a 23.3-degree angle fitting inside a gray box"><img src="https://i.stack.imgur.com/rP9Ab.png" alt="Graphic showing a 240 mm line of 0.45 mm width first at horizontal orientation and then at a 23.3-degree angle fitting inside a gray box of 220 mm width" title="Graphic showing a 240 mm line at a 23.3-degree angle fitting inside a gray box" /></a></p>
| 2,223
|
<p>I am trying to create a couple of holders for my ultrasonic cleaners. They are supposed to be used for parts that don't fit in the holder that came with the cleaners. I was wondering what material is best to use for this.</p>
<p>My initial thoughts are:</p>
<ul>
<li>Material should hold up to the cleaning solution, I have a wide range of them from degreaser, deruster, and so on. I would say PETG or PLA should be a safe bet as it reacts with almost nothing</li>
<li>Material should not have issues with warm (not hot) water, I'd say something along the lines of 60-80 °C. This already eliminates PLA, but I think PETG should still be OK-ish (I am aiming more towards 60 °C than 80 °C).</li>
</ul>
<p>Is there something I am missing? Does anyone have any input? I am anyway just going to do a few tests, but I assume starting with PETG is a good start.</p>
|
<p>This is going to be hard. Even holding a vacuum is hard (I've tried it and not succeeded). I'm not sure what the mechanism of air molecules getting thru the print is - whether it's defects in inter-layer bonding, defects at seams, imperfect mating with the fitting, or even permeability of the plastic itself. It might not actually be existing flaws in the print, but rather the high pressure being a stronger force than the bonded layers can withstand, essentially ripping the layers apart from the weakest point until the pressure can discharge through the opening produced.</p>
<p>If using ABS, you might try an acetone bath followed by a long period of trying or use of vacuum chamber to quickly remove the solvent, if you can stand some possible part deformation. This would tend to fill any gaps. Coating with low-viscosity CA glue (Loctite 420 or equivalent) might be a better version of this approach, as the solvent will both attack the ABS and deliver fill material.</p>
<p>In principle PET (maybe also PETG, but PET is preferable anyway if you can get it) should be a suitable material for pressure vessels, as it's what's used for soda bottles at comparable pressure, but those are blown from a single piece, not fused together with seams.</p>
<p>At some point I will attempt this again, and will update my answer if I have any findings that contribute to your question.</p>
|
<h2>Not without postprocessing</h2>
<p>FDM is pretty much welding plastic to plastic. Many many layers. Each of them is a potential breaking point, a corner for stress to arise and break the print.</p>
<h2>Easy with a hollow body</h2>
<p>Printing a hollow item that can be filled with resin is comparatively easy. Once filled with a monolithic curing resin (epoxy), that will take the pressure much better and seal it fully.</p>
| 2,199
|
<p>I asked a question about Currying and closures were mentioned.
What is a closure? How does it relate to currying?</p>
|
<h2>Variable scope</h2>
<p>When you declare a local variable, that variable has a scope. Generally, local variables exist only within the block or function in which you declare them.</p>
<pre class="lang-js prettyprint-override"><code>function() {
var a = 1;
console.log(a); // works
}
console.log(a); // fails
</code></pre>
<p>If I try to access a local variable, most languages will look for it in the current scope, then up through the parent scopes until they reach the root scope.</p>
<pre class="lang-js prettyprint-override"><code>var a = 1;
function() {
console.log(a); // works
}
console.log(a); // works
</code></pre>
<p>When a block or function is done with, its local variables are no longer needed and are usually blown out of memory.</p>
<p>This is how we normally expect things to work.</p>
<h2>A closure is a persistent local variable scope</h2>
<p>A closure is a persistent scope which holds on to local variables even after the code execution has moved out of that block. Languages which support closure (such as JavaScript, Swift, and Ruby) will allow you to keep a reference to a scope (including its parent scopes), even after the block in which those variables were declared has finished executing, provided you keep a reference to that block or function somewhere.</p>
<p>The scope object and all its local variables are tied to the function and will persist as long as that function persists.</p>
<p>This gives us function portability. We can expect any variables that were in scope when the function was first defined to still be in scope when we later call the function, even if we call the function in a completely different context.</p>
<h2>For example</h2>
<p>Here's a really simple example in JavaScript that illustrates the point:</p>
<pre class="lang-js prettyprint-override"><code>outer = function() {
var a = 1;
var inner = function() {
console.log(a);
}
return inner; // this returns a function
}
var fnc = outer(); // execute outer to get inner
fnc();
</code></pre>
<p>Here I have defined a function within a function. The inner function gains access to all the outer function's local variables, including <code>a</code>. The variable <code>a</code> is in scope for the inner function.</p>
<p>Normally when a function exits, all its local variables are blown away. However, if we return the inner function and assign it to a variable <code>fnc</code> so that it persists after <code>outer</code> has exited, <strong>all of the variables that were in scope when <code>inner</code> was defined also persist</strong>. The variable <code>a</code> has been closed over -- it is within a closure.</p>
<p>Note that the variable <code>a</code> is totally private to <code>fnc</code>. This is a way of creating private variables in a functional programming language such as JavaScript.</p>
<p>As you might be able to guess, when I call <code>fnc()</code> it prints the value of <code>a</code>, which is "1".</p>
<p>In a language without closure, the variable <code>a</code> would have been garbage collected and thrown away when the function <code>outer</code> exited. Calling fnc would have thrown an error because <code>a</code> no longer exists.</p>
<p>In JavaScript, the variable <code>a</code> persists because the variable scope is created when the function is first declared and persists for as long as the function continues to exist.</p>
<p><code>a</code> belongs to the scope of <code>outer</code>. The scope of <code>inner</code> has a parent pointer to the scope of <code>outer</code>. <code>fnc</code> is a variable which points to <code>inner</code>. <code>a</code> persists as long as <code>fnc</code> persists. <code>a</code> is within the closure.</p>
<h2>Further reading (watching)</h2>
<p>I made a <a href="https://www.youtube.com/watch?v=2cRjcXwsG0I" rel="noreferrer">YouTube video</a> looking at this code with some practical examples of usage.</p>
|
<p>Here is another real life example, and using a scripting language popular in games - Lua. I needed to slightly change the way a library function worked to avoid a problem with stdin not being available.</p>
<pre><code>local old_dofile = dofile
function dofile( filename )
if filename == nil then
error( 'Can not use default of stdin.' )
end
old_dofile( filename )
end
</code></pre>
<p>The value of old_dofile disappears when this block of code finishes it's scope (because it's local), however the value has been enclosed in a closure, so the new redefined dofile function CAN access it, or rather a copy stored along with the function as an 'upvalue'.</p>
| 5,724
|
<p>I would like to be able to define and use a custom type in some of my PowerShell scripts. For example, let's pretend I had a need for an object that had the following structure:</p>
<pre><code>Contact
{
string First
string Last
string Phone
}
</code></pre>
<p>How would I go about creating this so that I could use it in function like the following:</p>
<pre><code>function PrintContact
{
param( [Contact]$contact )
"Customer Name is " + $contact.First + " " + $contact.Last
"Customer Phone is " + $contact.Phone
}
</code></pre>
<p>Is something like this possible, or even recommended in PowerShell?</p>
|
<h2>Prior to PowerShell 3</h2>
<p>PowerShell's Extensible Type System didn't originally let you create concrete types you can test against the way you did in your parameter. If you don't need that test, you're fine with any of the other methods mentioned above. </p>
<p>If you want an actual type that you can cast to or type-check with, as in your example script ... it <strong>cannot</strong> be done without writing it in C# or VB.net and compiling. In PowerShell 2, you can use the "Add-Type" command to do it quite simmple:</p>
<pre><code>add-type @"
public struct contact {
public string First;
public string Last;
public string Phone;
}
"@
</code></pre>
<p><strong><em>Historical Note</em></strong>: In PowerShell 1 it was even harder. You had to manually use CodeDom, there is a very old function <a href="http://poshcode.org/scripts/190" rel="noreferrer">new-struct</a> script on PoshCode.org which will help. Your example becomes:</p>
<pre><code>New-Struct Contact @{
First=[string];
Last=[string];
Phone=[string];
}
</code></pre>
<p>Using <code>Add-Type</code> or <code>New-Struct</code> will let you actually test the class in your <code>param([Contact]$contact)</code> and make new ones using <code>$contact = new-object Contact</code> and so on...</p>
<h1>In PowerShell 3</h1>
<p>If you don't need a "real" class that you can cast to, you don't have to use the Add-Member way that <a href="https://stackoverflow.com/a/59980/8718">Steven and others have demonstrated</a> above.</p>
<p>Since PowerShell 2 you could use the -Property parameter for New-Object:</p>
<pre><code>$Contact = New-Object PSObject -Property @{ First=""; Last=""; Phone="" }
</code></pre>
<p>And in PowerShell 3, we got the ability to use the <code>PSCustomObject</code> accelerator to add a TypeName:</p>
<pre><code>[PSCustomObject]@{
PSTypeName = "Contact"
First = $First
Last = $Last
Phone = $Phone
}
</code></pre>
<p>You're still only getting a single object, so you should make a <code>New-Contact</code> function to make sure that every object comes out the same, but you can now easily verify a parameter "is" one of those type by decorating a parameter with the <code>PSTypeName</code> attribute:</p>
<pre><code>function PrintContact
{
param( [PSTypeName("Contact")]$contact )
"Customer Name is " + $contact.First + " " + $contact.Last
"Customer Phone is " + $contact.Phone
}
</code></pre>
<h1>In PowerShell 5</h1>
<p>In PowerShell 5 everything changes, and we finally got <code>class</code> and <code>enum</code> as language keywords for defining types (there's no <code>struct</code> but that's ok):</p>
<pre><code>class Contact
{
# Optionally, add attributes to prevent invalid values
[ValidateNotNullOrEmpty()][string]$First
[ValidateNotNullOrEmpty()][string]$Last
[ValidateNotNullOrEmpty()][string]$Phone
# optionally, have a constructor to
# force properties to be set:
Contact($First, $Last, $Phone) {
$this.First = $First
$this.Last = $Last
$this.Phone = $Phone
}
}
</code></pre>
<p>We also got a new way to create objects without using <code>New-Object</code>: <code>[Contact]::new()</code> -- in fact, if you kept your class simple and don't define a constructor, you can create objects by casting a hashtable (although without a constructor, there would be no way to enforce that all properties must be set):</p>
<pre><code>class Contact
{
# Optionally, add attributes to prevent invalid values
[ValidateNotNullOrEmpty()][string]$First
[ValidateNotNullOrEmpty()][string]$Last
[ValidateNotNullOrEmpty()][string]$Phone
}
$C = [Contact]@{
First = "Joel"
Last = "Bennett"
}
</code></pre>
|
<p>Here's one more option, which uses a similar idea to the PSTypeName solution mentioned by <a href="https://stackoverflow.com/a/66693/361842">Jaykul</a> (and thus also requires PSv3 or above).</p>
<h1>Example</h1>
<ol>
<li>Create a <strong><em>TypeName</em>.Types.ps1xml</strong> file defining your type. E.g. <code>Person.Types.ps1xml</code>:</li>
</ol>
<pre class="lang-xml prettyprint-override"><code><?xml version="1.0" encoding="utf-8" ?>
<Types>
<Type>
<Name>StackOverflow.Example.Person</Name>
<Members>
<ScriptMethod>
<Name>Initialize</Name>
<Script>
Param (
[Parameter(Mandatory = $true)]
[string]$GivenName
,
[Parameter(Mandatory = $true)]
[string]$Surname
)
$this | Add-Member -MemberType 'NoteProperty' -Name 'GivenName' -Value $GivenName
$this | Add-Member -MemberType 'NoteProperty' -Name 'Surname' -Value $Surname
</Script>
</ScriptMethod>
<ScriptMethod>
<Name>SetGivenName</Name>
<Script>
Param (
[Parameter(Mandatory = $true)]
[string]$GivenName
)
$this | Add-Member -MemberType 'NoteProperty' -Name 'GivenName' -Value $GivenName -Force
</Script>
</ScriptMethod>
<ScriptProperty>
<Name>FullName</Name>
<GetScriptBlock>'{0} {1}' -f $this.GivenName, $this.Surname</GetScriptBlock>
</ScriptProperty>
<!-- include properties under here if we don't want them to be visible by default
<MemberSet>
<Name>PSStandardMembers</Name>
<Members>
</Members>
</MemberSet>
-->
</Members>
</Type>
</Types>
</code></pre>
<ol start="2">
<li>Import your type: <code>Update-TypeData -AppendPath .\Person.Types.ps1xml</code></li>
<li>Create an object of your custom type: <code>$p = [PSCustomType]@{PSTypeName='StackOverflow.Example.Person'}</code></li>
<li>Initialise your type using the script method you defined in the XML: <code>$p.Initialize('Anne', 'Droid')</code></li>
<li>Look at it; you'll see all properties defined: <code>$p | Format-Table -AutoSize</code></li>
<li>Type calling a mutator to update a property's value: <code>$p.SetGivenName('Dan')</code></li>
<li>Look at it again to see the updated value: <code>$p | Format-Table -AutoSize</code></li>
</ol>
<h1>Explanation</h1>
<ul>
<li>The PS1XML file allows you to define custom properties on types.</li>
<li>It is not restricted to .net types as the documentation implies; so you can put what you like in '/Types/Type/Name' any object created with a matching 'PSTypeName' will inherit the members defined for this type.</li>
<li>Members added through <code>PS1XML</code> or <code>Add-Member</code> are restricted to <code>NoteProperty</code>, <code>AliasProperty</code>, <code>ScriptProperty</code>, <code>CodeProperty</code>, <code>ScriptMethod</code>, and <code>CodeMethod</code> (or <code>PropertySet</code>/<code>MemberSet</code>; though those are subject to the same restrictions). All of these properties are read only.</li>
<li>By defining a <code>ScriptMethod</code> we can cheat the above restriction. E.g. We can define a method (e.g. <code>Initialize</code>) which creates new properties, setting their values for us; thus ensuring our object has all the properties we need for our other scripts to work.</li>
<li>We can use this same trick to allow the properties to be updatable (albeit via method rather than direct assignment), as shown in the example's <code>SetGivenName</code>.</li>
</ul>
<p>This approach isn't ideal for all scenarios; but is useful for adding class-like behaviors to custom types / can be used in conjunction with other methods mentioned in the other answers. E.g. in the real world I'd probably only define the <code>FullName</code> property in the PS1XML, then use a function to create the object with the required values, like so:</p>
<h1>More Info</h1>
<p>Take a look at the <a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_types.ps1xml?view=powershell-6" rel="nofollow noreferrer">documentation</a>, or the OOTB type file <code>Get-Content
$PSHome\types.ps1xml</code> for inspiration.</p>
<pre><code># have something like this defined in my script so we only try to import the definition once.
# the surrounding if statement may be useful if we're dot sourcing the script in an existing
# session / running in ISE / something like that
if (!(Get-TypeData 'StackOverflow.Example.Person')) {
Update-TypeData '.\Person.Types.ps1xml'
}
# have a function to create my objects with all required parameters
# creating them from the hash table means they're PROPERties; i.e. updatable without calling a
# setter method (note: recall I said above that in this scenario I'd remove their definition
# from the PS1XML)
function New-SOPerson {
[CmdletBinding()]
[OutputType('StackOverflow.Example.Person')]
Param (
[Parameter(Mandatory)]
[string]$GivenName
,
[Parameter(Mandatory)]
[string]$Surname
)
([PSCustomObject][Ordered]@{
PSTypeName = 'StackOverflow.Example.Person'
GivenName = $GivenName
Surname = $Surname
})
}
# then use my new function to generate the new object
$p = New-SOPerson -GivenName 'Simon' -Surname 'Borg'
# and thanks to the type magic... FullName exists :)
Write-Information "$($p.FullName) was created successfully!" -InformationAction Continue
</code></pre>
| 8,454
|
<p>I think it can be done by applying the transformation matrix of the scenegraph to z-normal (0, 0, 1), but it doesn't work. My code goes like this:</p>
<pre><code>Vector3f toScreenVector = new Vector3f(0, 0, 1);
Transform3D t3d = new Transform3D();
tg.getTransform(t3d); //tg is Transform Group of all objects in a scene
t3d.transform(toScreenVector);
</code></pre>
<p>Then I tried something like this too:</p>
<pre><code>Point3d eyePos = new Point3d();
Point3d mousePos = new Point3d();
canvas.getCenterEyeInImagePlate(eyePos);
canvas.getPixelLocationInImagePlate(new Point2d(Main.WIDTH/2, Main.HEIGHT/2), mousePos); //Main is the class for main window.
Transform3D motion = new Transform3D();
canvas.getImagePlateToVworld(motion);
motion.transform(eyePos);
motion.transform(mousePos);
Vector3d toScreenVector = new Vector3f(eyePos);
toScreenVector.sub(mousePos);
toScreenVector.normalize();
</code></pre>
<p>But still this doesn't work correctly. I think there must be an easy way to create such vector. Do you know what's wrong with my code or better way to do so?</p>
|
<p>If I get this right, you want a vector that is normal to the screen plane, but in world coordinates?</p>
<p>In that case you want to <code>INVERT</code> the transformation from <code>World -> Screen and do Screen -> World</code> of <code>(0,0,-1)</code> or <code>(0,0,1)</code> depending on which axis the screen points down.</p>
<p>Since the ModelView matrix is just a rotation matrix (ignoring the homogeneous transformation part), you can simply pull this out by taking the transpose of the rotational part, or simple reading in the bottom row - as this transposes onto the <code>Z</code> coordinate column under transposition.</p>
|
<p>Yes, you got my question right. Sorry that I was a little bit confused yesterday. Now I have corrected the code by following your suggestion and mixing two pieces of code in the question together:</p>
<pre><code>Vector3f toScreenVector = new Vector3f(0, 0, 1);
Transform3D t3d = new Transform3D();
canvas.getImagePlateToVworld(t3d);
t3d.transform(toScreenVector);
tg.getTransform(t3d); //tg is Transform Group of all objects in a scene
t3d.transform(toScreenVector);
</code></pre>
<p>Thank you.</p>
| 6,122
|
<p>I am trying to code a flowchart generator for a language using Ruby. </p>
<p>I wanted to know if there were any libraries that I could use to draw various shapes for the various flowchart elements and write out text to those shapes. </p>
<p>I would really prefer not having to write code for drawing basic shapes, if I can help it. </p>
<p>Can someone could point me to some reference documentation with examples of using that library?</p>
|
<p>Write up your flowchart as a directed or undirected graph in <a href="http://www.graphviz.org/About.php" rel="nofollow noreferrer">Graphviz</a>. Graphviz has a language, <a href="http://www.graphviz.org/Documentation.php" rel="nofollow noreferrer">dot</a> that makes it easy to generate graphs. Just generate the dot file, run it through Graphiviz, and you get your image.</p>
<pre><code>graph {
A -- B -- C;
B -- D;
C -- D [constraint=false];
}
</code></pre>
<p>renders as <br>
<a href="http://www.flickr.com/photos/rampion/3130993214/" rel="nofollow noreferrer" title="undirected by rampion, on Flickr"><img src="https://farm4.static.flickr.com/3126/3130993214_af71aa44f6.jpg" width="183" height="255" alt="undirected" /></a></p>
<pre><code>digraph {
A [label="start"];
B [label="eat"];
C [label="drink"];
D [label="be merry"];
A -> B -> C;
C -> D [constraint=false];
B -> D [ arrowhead=none, arrowtail=normal]; // reverse this edge
}
</code></pre>
<p>renders as<br>
<a href="http://www.flickr.com/photos/rampion/3130162313/" rel="nofollow noreferrer" title="directed by rampion, on Flickr"><img src="https://farm4.static.flickr.com/3085/3130162313_51e5b00dc9.jpg" width="212" height="255" alt="directed" /></a></p>
<p>You can control node shapes and much more in Graphviz. </p>
|
<p>I am totally sure, but check out cairo bindings for ruby. Pango for text. I am investigating then currently and came across this page.</p>
| 3,233
|
<p>Ok, so I got my extender working on a default.aspx page on my website and it looks good. I basically copied and pasted the code for it into a user control control.ascx page. When I do this I completely loose the functionality (just shows the target control label and no dropdown, even upon hover). Is there any reason why it doesn't work in a custom user control inside a masterpage setup?</p>
<p>Edit:
Didn't quite do the trick. Any other suggestions?
Its in a master page setup, using eo web tabs (I tried it inside the tabs and outside the tabs but on the same page as the tabs, to no avail), and its in a custom user control. Think there are dependency issues?</p>
|
<p>I don't know if this helps, but I had the same problem with the autocomplete extender and determined that the server-side function could not be in the user control, but needed to be on the page (or in a webservice, I guess). Once I moved the function, it worked fine.</p>
|
<p>Check the DocType. Here is what I have found useful</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
</code></pre>
<p>Place this in your user control (or the page that uses it) and all should be well. I had a similar problem with a collapsible extender and this worked for me.</p>
<p>Edit: Here is a <a href="https://stackoverflow.com/questions/26825/uncollapsible-collapsiblepanelextender">link</a> to my question for further details.</p>
| 8,186
|
<p>I want to buy my first FDM printer, to print household items and wearable gadgets too big for my LCD resin one. Due to financing & tax reasons, what I'll buy now is what I will have for at least a year.</p>
<p>I was thinking about <a href="https://www.prusa3d.com/product/original-prusa-i3-mk3s-kit-3/" rel="nofollow noreferrer">Prusa i3 MK3S+</a>, and <a href="https://www.prusa3d.com/product/original-prusa-i3-mmu2s-upgrade-kit-for-mk2-5s-mk3s-org/" rel="nofollow noreferrer">MMU2S</a> looks really interesting and useful, especially to print water soluble supports. However, after reading reviews I hardly can justify buying it.</p>
<p>I have some technical experience, can make some things and once even built a 3 axis stepper motor system from scratch, and it worked. I have a resin LCD printer and have printed working parts. I still have NEMA17 motors, 4 of them.</p>
<p>Assuming I'll get Prusa i3 MK3S+, what else would I need to print and assemble MMU2S? Is there an official Bill Of Materials? Blueprints? STL files?</p>
|
<p>I would go back to the brass nozzle and try again for comparison.</p>
<p>We had a batch of 10 cheap steel nozzles all of which caused problems.</p>
|
<p>I think the answer is printing temperature. This shiny PLA I'm using is Eryone Silk PLA. Although the working temperature is stated as 190-220 °C, my 205 °C was too much for it. A temperature of 190-195 °C produces good results though not as shiny anymore. It is three layers printed on the sample below with no problems.</p>
<p><a href="https://i.stack.imgur.com/tJP8x.jpg" rel="nofollow noreferrer" title="3D printed sample printed with 195 degrees Celsius and showing no printing errors"><img src="https://i.stack.imgur.com/tJP8x.jpg" alt="3D printed sample printed with 195 degrees Celsius and showing no printing errors" title="3D printed sample printed with 195 degrees Celsius and showing no printing errors" /></a></p>
| 2,222
|
<p>I'm using the following method to send mail from Python using SMTP. Is it the right method to use or are there gotchas I'm missing ?</p>
<pre><code>from smtplib import SMTP
import datetime
debuglevel = 0
smtp = SMTP()
smtp.set_debuglevel(debuglevel)
smtp.connect('YOUR.MAIL.SERVER', 26)
smtp.login('USERNAME@DOMAIN', 'PASSWORD')
from_addr = "John Doe <john@doe.net>"
to_addr = "foo@bar.com"
subj = "hello"
date = datetime.datetime.now().strftime( "%d/%m/%Y %H:%M" )
message_text = "Hello\nThis is a mail from your server\n\nBye\n"
msg = "From: %s\nTo: %s\nSubject: %s\nDate: %s\n\n%s"
% ( from_addr, to_addr, subj, date, message_text )
smtp.sendmail(from_addr, to_addr, msg)
smtp.quit()
</code></pre>
|
<p>The script I use is quite similar; I post it here as an example of how to use the email.* modules to generate MIME messages; so this script can be easily modified to attach pictures, etc.</p>
<p>I rely on my ISP to add the date time header.</p>
<p>My ISP requires me to use a secure smtp connection to send mail, I rely on the smtplib module (downloadable at <a href="http://www1.cs.columbia.edu/~db2501/ssmtplib.py" rel="noreferrer">http://www1.cs.columbia.edu/~db2501/ssmtplib.py</a>)</p>
<p>As in your script, the username and password, (given dummy values below), used to authenticate on the SMTP server, are in plain text in the source. This is a security weakness; but the best alternative depends on how careful you need (want?) to be about protecting these.</p>
<p>=======================================</p>
<pre><code>#! /usr/local/bin/python
SMTPserver = 'smtp.att.yahoo.com'
sender = 'me@my_email_domain.net'
destination = ['recipient@her_email_domain.com']
USERNAME = "USER_NAME_FOR_INTERNET_SERVICE_PROVIDER"
PASSWORD = "PASSWORD_INTERNET_SERVICE_PROVIDER"
# typical values for text_subtype are plain, html, xml
text_subtype = 'plain'
content="""\
Test message
"""
subject="Sent from Python"
import sys
import os
import re
from smtplib import SMTP_SSL as SMTP # this invokes the secure SMTP protocol (port 465, uses SSL)
# from smtplib import SMTP # use this for standard SMTP protocol (port 25, no encryption)
# old version
# from email.MIMEText import MIMEText
from email.mime.text import MIMEText
try:
msg = MIMEText(content, text_subtype)
msg['Subject']= subject
msg['From'] = sender # some SMTP servers will do this automatically, not all
conn = SMTP(SMTPserver)
conn.set_debuglevel(False)
conn.login(USERNAME, PASSWORD)
try:
conn.sendmail(sender, destination, msg.as_string())
finally:
conn.quit()
except:
sys.exit( "mail failed; %s" % "CUSTOM_ERROR" ) # give an error message
</code></pre>
|
<p>What about <a href="https://red-mail.readthedocs.io/" rel="nofollow noreferrer">Red Mail</a>?</p>
<p>Install it:</p>
<pre><code>pip install redmail
</code></pre>
<p>Then just:</p>
<pre><code>from redmail import EmailSender
# Configure the sender
email = EmailSender(
host="YOUR.MAIL.SERVER",
port=26,
username='me@example.com',
password='<PASSWORD>'
)
# Send an email:
email.send(
subject="An example email",
sender="me@example.com",
receivers=['you@example.com'],
text="Hello!",
html="<h1>Hello!</h1>"
)
</code></pre>
<p>It has quite a lot of features:</p>
<ul>
<li><a href="https://red-mail.readthedocs.io/en/latest/tutorials/attachments.html" rel="nofollow noreferrer">Email attachments from various sources</a></li>
<li><a href="https://red-mail.readthedocs.io/en/latest/tutorials/body_content.html" rel="nofollow noreferrer">Embedding images and plots to the HTML body</a></li>
<li><a href="https://red-mail.readthedocs.io/en/latest/tutorials/jinja_support.html" rel="nofollow noreferrer">Templating emails with Jinja</a></li>
<li><a href="https://red-mail.readthedocs.io/en/latest/tutorials/config.html" rel="nofollow noreferrer">Preconfigured Gmail and Outlook</a></li>
<li><a href="https://red-mail.readthedocs.io/en/latest/extensions/logging.html" rel="nofollow noreferrer">Logging handler</a></li>
<li><a href="https://red-mail.readthedocs.io/en/latest/extensions/flask.html" rel="nofollow noreferrer">Flask extension</a></li>
</ul>
<p>Links:</p>
<ul>
<li><a href="https://github.com/Miksus/red-mail" rel="nofollow noreferrer">Source code</a></li>
<li><a href="https://red-mail.readthedocs.io/" rel="nofollow noreferrer">Documentation</a></li>
<li><a href="https://pypi.org/project/redmail/" rel="nofollow noreferrer">Releases</a></li>
</ul>
| 9,006
|
<p>Should be available to non-U.S. companies, easy to setup, reliable, cheap, customizable, etc. What are your experiences?</p>
|
<p>You can't really answer this kind of question with a "I like 'insert provide name here'" type answer because like so many things it is a balance and the reasons for choosing a payment processing solution tend to be complex.</p>
<h2>Volume / Value</h2>
<p>The most important factor in choosing a secure payment clearance service (the people who will connect to the banking networks and clear the money for you - will refer to them as SPCS) is how many widgets will you be selling at what cost. The pricing models of all the SCPS providers is based around this equation. This dictates the economics of using the service, which is nearly always the most important factor.</p>
<p>For example, in the UK <a href="http://securetrading.net" rel="noreferrer">securetrading.net</a> have a large annual fee and high minimum transaction values (been a while since I've seen the exact numbers and they don't make it immediately obvious on the site, but this is for illustration only anyway) making it one of the most expensive solutions to use <em>if</em> you are selling high value low volume. Most smaller clients will fall into this model. High value is really anything over a couple of dollars. Low volume is typically anything less than tens of thousands of units per month. <em>However</em>, if you are running a donations service in the aftermath of an international environmental disaster (relatively low value <em>very</em> high volume) then they become one of the cheapest.</p>
<p>Factor in to this the setup costs (relatively high), and the cost to tie the service into the site (in SecureTrading's case it's very easy to do, but still a lot harder than adding a PayPal button) and you start to build up a true picture.</p>
<p>On the flip side, a service such as <a href="http://www.paypal.com" rel="noreferrer">PayPal</a> has very low setup costs (no fee to pay, and trivially easy to integrate), but relatively high transaction costs. It is great for high value / low volume transactions.</p>
<h2>The Bank</h2>
<p>There are two main categories of payment clearance service - Bureau and Bank Acquired.</p>
<p>In the UK at least <a href="http://www.netbanx.com" rel="noreferrer">NetBanx</a>, <a href="http://www.securetrading.net" rel="noreferrer">SecureTrading</a> and <a href="http://www.worldpay.com" rel="noreferrer">WorldPay</a> offer both bank acquired and bureau services. <a href="http://www.protx.com" rel="noreferrer">ProtX</a> and <a href="http://www.secpay.com" rel="noreferrer">SecPay</a> offer only bank acquired services. PayPal and its ilk operates slightly outside both definitions (see Protection below).</p>
<p>A Bank Acquired service plumbs into your normal banking merchant account and clears the funds straight into it. As well as charging you for this service, your bank will also take a slice, typically this is more than the SPCS provider will charge and so it actually is the <em>bank</em> that becomes the deciding factor.</p>
<p>Some banks will only work with their preferred provider. In the UK, most banks want you to have a separate Internet Merchant Account <em>even</em> if you already have a Merchant Account with them.</p>
<p>I always tell clients to shop around, as this will make a huge difference to how much their e-commerce venture can bring in. All banks are not created equal.</p>
<p>Bureau services effectively act as your bank at the same time as providing the clearance service. They were popular in a time when banks hadn't grasped the concept of the Internet and would prefer transactions be chiseled into stone tablets if they got their way. Often the choice between a bureau service and a bank acquired service is made for you based on circumstances.</p>
<h3>Trading History</h3>
<p>In many countries (including the UK), most banks won't give you a merchant account until you have been trading for a particular period of time (2 years in the UK). Your only option is then a bureau service.</p>
<h3>Cash flow</h3>
<p>Most bureau services will hold onto your cash as security against "charge backs".</p>
<p>If you sell me a Ferrari and I am horrified to learn that you've sold me a small metal toy rather than the 1.5 tonnes of Italian automotive passion I was expecting, I will complain to my credit card company who will refund me and then chase your merchant services provider for a refund. They will have to give them the refund and then chase you for the money.</p>
<p>It's therefore in their interests to hold on to your money for a period of 4-6 weeks to protect against this. If you sell services or goods with no capital outlay (software for instance), then you can afford this. If on the other hand, you really are having to pay your luxury car importer to provide you with stock, then cash flow becomes very important and you're going to need a bank acquired service where you can be paid immediately.</p>
<h2>Protection</h2>
<p>One major downside to PayPal and similar services is that it is not covered under the same regulations that govern credit cards.</p>
<p>Simply put, if you buy something on a credit card your card provider is liable for ensure you get what you paid for (broadly speaking, in most countries, does not constitute legal advice etc.) and if you have a problem with your purchase they will refund you very quickly and then will go and chase the person that you paid.</p>
<p>This is the kind of protection you hear about when Leo Laporte advertises American Express on his podcasts. It is a "Good Thing"TM. You don't have that protection with PayPal because when you use your credit card on PayPal, you are actually buying PayPal's service. So, even if you are mis-sold a product, the person you paid for the service (PayPal) <em>didn't</em> mis-sell, they provided the service you paid for. This breaks the chain.</p>
<p>PayPal don't have a legal obligation to protect you in the same way, and their record on refunding ripped off customers is less than spangly. I'm guessing they have "Caveat Emptor" writ large on the walls of their head office. :)</p>
<p>I'm not dissing PayPal, they are way ahead of the curve on many other security features, but just another factor to bear in mind.</p>
<h2>End to end integration</h2>
<p>Different services differ in their ease of integration. Oh boy do they differ. I'm sitting on some work right now to do an HSBC integration. I'd rather have a root canal. Some of the systems make big assumptions about the way you have to work with them, and are poorly designed or inflexible. Retro-fitting them to an active site can be very painful. Some of them are beautiful and easy to work with (and not necessarily less secure). The biggest difference is how you choose to integrate though.</p>
<p>Most services integrate by allowing you to redirect to a secure site where your customer fills in his / her details. They are finally redirected back to a page on your own site with the results of the transaction. This works well in most cases and is easiest to integrate.</p>
<p>When you buy something on Amazon, you don't get redirected to WorldPay, or PayPal however. If you want end-to-end integration, most services now will let the communication happen behind the scenes. Your own site has to have a decent secure server certificate of course, and the integration is necessarily more complex.</p>
<h2>Reputation</h2>
<p>It used to be that PayPal was used on dinky sites. You wouldn't catch Amazon using it. That perception has changed a lot, and in fact in some senses PayPal does security better than most. If your audience expects to see PayPal and you give them some other service then you may lose custom, or vice versa. These days many merchants offer a choice to customers.</p>
<h2>UK Providers</h2>
<ul>
<li><a href="http://www.worldpay.com" rel="noreferrer">WorldPay</a>. Well established. Bureau and bank acquired. Relatively high transaction costs and annual costs. Fairly easy to integrate. Owned ultimately by Royal Bank of Scotland.</li>
<li><a href="http://www.secpay.com" rel="noreferrer">SecPay</a>. Bank Acquired. Low per transaction cost and low annual cost and flexible payment models.</li>
<li><a href="http://www.protx.com" rel="noreferrer">ProtX</a>. Bank Acquired. Low per transaction cost and low annual cost, flexible payment models. Can be quite demanding to integrate.</li>
<li><a href="http://www.hsbc.com" rel="noreferrer">HSBC</a>. Bank Acquired. Low per transaction cost. High set up and annual costs. Very inflexible to integrate.</li>
<li><a href="http://www.securetrading.net" rel="noreferrer">SecureTrading</a>. Bureau and Bank Acquired. Low per transaction cost but high setup and annual costs. Was a doddle to integrate last time I used it (9 years ago!)</li>
<li><a href="http://www.netbanx.com" rel="noreferrer">NetBanx</a>. Bureau and Bank Acquired. Haven't used since 1996 so can't comment!</li>
</ul>
<p>And of course <a href="http://www.paypal.com" rel="noreferrer">PayPal</a>, <a href="http://checkout.google.com" rel="noreferrer">Google Checkout</a> and <a href="http://aws.amazon.com/fps/" rel="noreferrer">Amazon FPS</a> are well worth looking at and worth a whole answer on their own!</p>
<h2>Summary</h2>
<p>Told you it wasn't that simple! Usually, as developers, we're not in the position to choose for ourselves, and these decisions should be driven by the business needs of our employer / client.</p>
<p>Most e-commerce projects would start with PayPal or similar. When the business gets enough orders that they could save money by switching to another service, then they've got enough money to pay for the switch.</p>
<p><em>Disclaimer: I am UK based, and have performed many integrations with a whole slew of these services over the years, however the market changes all the time and things may have changed and your mileage may vary! I am not a lawyer or accountant, and if you take my advice it's not my fault :)</em></p>
|
<p>Try AlertPay, they have very competetive fees.</p>
| 2,470
|
<p>I talked to a friend of mine and he told me that it's possible to create an image in an image editor (gimp/photoshop) and then use it as a button . He said that's the way applications that have great GUIs do it. </p>
<p>He also said that there is a file describing which parts of the image make up the button.</p>
<p>Is this possible , or is he "crazy"? :)</p>
|
<p>This needs to be clarified with a language of choice, etc. In general, most languages (WinForms, Java AWT/SWT, etc) have an image or background image property that allows you to use images for buttons. There are even skinning frameworks that will let you use images for all controls in an easy-to-define manner.</p>
<p>If you are talking about HTML, there is a button input type that can allow an image to be used as a button for a form.</p>
<p>@Vhaerun<br/>
<a href="http://www.codeproject.com" rel="nofollow noreferrer">CodeProject</a> is a good place to find lots of skinning libraries. I used <a href="http://www.codeproject.com/KB/library/SkinCtrl.aspx" rel="nofollow noreferrer">this one</a> a long time ago. <a href="http://www.winamp.com" rel="nofollow noreferrer">Winamp</a> is a great example of a skinned application, where users can actually create their own templates to completely change the look of the application without changing code whatsoever. Actually, most media players have some sort of skinning available.</p>
|
<p>Imagemaps I guess.
No seperate file describes the map, it is all part of the html document.</p>
<p><a href="http://www.w3schools.com/TAGS/tag_map.asp" rel="nofollow noreferrer">http://www.w3schools.com/TAGS/tag_map.asp</a></p>
| 9,940
|
<p>I have a page using <code><ul></code> lists for navigation (Javascript changes the styling to display or not on mouseover).</p>
<p>This is working fine for me <em>except</em> in IE6 and IE7 when I have a Google Map on the page.</p>
<p>In this case the drop-down simply does not work. However, the page continues to work in FireFox 2.</p>
<p>I have done a little bit of research and discovered that this may be an example of the IE Select Box Bug, but I am not sure as the Google Map appears to be using a <code><div></code>, not an <code><iframe></code>.</p>
<p>Has anyone else encountered a problem similar to this, and if so do they have any recommendations on the best way to overcome this problem?</p>
|
<p>I don't know if this will fix your problem but you may want to try <a href="http://www.cssplay.co.uk/menus/pro_drop8.html" rel="nofollow noreferrer">this solution at ccsplay.co.uk</a> which fixes the problem of menus appearing underneath drop-down lists. I don't know if it will work for sure, but it's worth a shot.</p>
|
<p>I don't have an immediate answer for you, but the tools mentioned in <a href="https://stackoverflow.com/questions/17561/recommendations-for-browser-add-on-tools-to-help-with-development#17621">this answer</a> (particularly the IE DOM Inspector) may help.</p>
| 3,961
|
<p>I'm looking to write a programming language for fun, however most of the resource I have seen are for writing a context free language, however I wish to write a language that, like python, uses indentation, which to my understanding means it can't be context free.</p>
|
<p>A context-free grammar is, simply, one that doesn't require a symbol table in order to correctly parse the code. A context-sensitive grammar does.</p>
<p>The D programming language is an example of a context free grammar. C++ is a context sensitive one. (For example, is T*x declaring x to be pointer to T, or is it multiplying T by x ? We can only tell by looking up T in the symbol table to see if it is a type or a variable.)</p>
<p>Whitespace has nothing to do with it.</p>
<p>D uses a context free grammar in order to greatly simplify parsing it, and so that simple tools can parse it (such as syntax highlighting editors).</p>
|
<p>Just because a language uses significant indentation doesn't mean that it is inherently context-sensitive. As an example, Haskell makes use of significant indentation, and (to my knowledge) its grammar is context-free.</p>
<p>An example of source requiring a context-sensitive grammar could be this snippet from Ruby:</p>
<pre><code>my_essay = << END_STR
This is within the string
END_STR
<< self
def other_method
...
end
end
</code></pre>
<p>Another example would be Scala's XML mode:</p>
<pre><code>def doSomething() = {
val xml = <code>def val <tag/> class</code>
xml
}
</code></pre>
<p>As a general rule, context-sensitive languages are slightly harder to imagine in any precise sense and thus far less common. Even Ruby and Scala don't <em>really</em> count since their context sensitive features encompass only a minor sub-set of the language. If I were you, I would formulate my grammar as inspiration dictates and then worry about parsing methodologies at a later date. I think you'll find that whatever you come up with will be naturally context-free, or very close to it.</p>
<p>As a final note, if you <em>really</em> need context-sensitive parsing tools, you might try some of the less rigidly formal techniques. Parser combinators are used in Scala's parsing. They have some annoying limitations (no lexing), but they aren't a bad tool. LL(*) tools like ANTLR also seem to be more adept at expressing such "ad hoc" parsing escapes. Don't try to use Yacc or Bison with a context-sensitive grammar, they are far to strict to express such concepts easily.</p>
| 9,374
|
<p>I recently bought a Windows Mobile device and since I'm a developer I want to use it as a development platform. Yes, it's not supposed to be used like that but it's always with me and my laptop isn't. I know <a href="http://www.animaniak.com/cke/cke_main.asp" rel="nofollow noreferrer">cke</a> is a good editor for code but how can I run JavaScript/Ruby code without too much of a headache?</p>
<p>I probably could write a web application, send code to it and get the results back but maybe there's better solutions?</p>
|
<p>There is a possibility to run <a href="http://uema2.s8.xrea.com/ruby-mswince/" rel="nofollow noreferrer"><strong>Ruby on Windows Mobile</strong></a></p>
<p>Check this article for steps: <a href="http://andryshuzain.com/journal/ruby-on-windows-mobile-5" rel="nofollow noreferrer"><strong>Human vs Machine</strong></a> </p>
<p>Javascript is bit crippled on Windows Mobile.
Follow up the discussions here: <a href="http://blogs.msdn.com/iemobile/archive/2006/04/06/570375.aspx" rel="nofollow noreferrer"><strong>Windows Mobile IE Team Blog</strong></a>
Hopefully the next version if Pocket Internet Explorer supports better!</p>
|
<p>This is n old port of Ruby to WinCE, but from what I've read it doesn't work all that well - who knows, give it a try, YMMV</p>
<p><a href="http://uema2.s8.xrea.com/ruby-mswince/" rel="nofollow noreferrer">http://uema2.s8.xrea.com/ruby-mswince/</a></p>
<p>As for Javascript, WinMo devices have Pocket Internet Explorer - it isn't very good, but runs some Javascript. If you want something that is a bit closer to a desktop you could install Opera.</p>
| 8,539
|
<p>What method do you use when you want to get performance data about specific code paths?</p>
|
<p>This method has several limitations, but I still find it very useful. I'll list the limitations (I know of) up front and let whoever wants to use it do so at their own risk.</p>
<ol>
<li>The original version I posted over-reported time spent in recursive calls (as pointed out in the comments to the answer).</li>
<li>It's not thread safe, it wasn't thread safe before I added the code to ignore recursion and it's even less thread safe now.</li>
<li>Although it's very efficient if it's called many times (millions), it will have a measurable effect on the outcome so that scopes you measure will take longer than those you don't.</li>
</ol>
<hr>
<p>I use this class when the problem at hand doesn't justify profiling all my code or I get some data from a profiler that I want to verify. Basically it sums up the time you spent in a specific block and at the end of the program outputs it to the debug stream (viewable with <a href="http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx" rel="nofollow noreferrer">DbgView</a>), including how many times the code was executed (and the average time spent of course)).</p>
<pre><code>#pragma once
#include <tchar.h>
#include <windows.h>
#include <sstream>
#include <boost/noncopyable.hpp>
namespace scope_timer {
class time_collector : boost::noncopyable {
__int64 total;
LARGE_INTEGER start;
size_t times;
const TCHAR* name;
double cpu_frequency()
{ // cache the CPU frequency, which doesn't change.
static double ret = 0; // store as double so devision later on is floating point and not truncating
if (ret == 0) {
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
ret = static_cast<double>(freq.QuadPart);
}
return ret;
}
bool in_use;
public:
time_collector(const TCHAR* n)
: times(0)
, name(n)
, total(0)
, start(LARGE_INTEGER())
, in_use(false)
{
}
~time_collector()
{
std::basic_ostringstream<TCHAR> msg;
msg << _T("scope_timer> ") << name << _T(" called: ");
double seconds = total / cpu_frequency();
double average = seconds / times;
msg << times << _T(" times total time: ") << seconds << _T(" seconds ")
<< _T(" (avg ") << average <<_T(")\n");
OutputDebugString(msg.str().c_str());
}
void add_time(__int64 ticks)
{
total += ticks;
++times;
in_use = false;
}
bool aquire()
{
if (in_use)
return false;
in_use = true;
return true;
}
};
class one_time : boost::noncopyable {
LARGE_INTEGER start;
time_collector* collector;
public:
one_time(time_collector& tc)
{
if (tc.aquire()) {
collector = &tc;
QueryPerformanceCounter(&start);
}
else
collector = 0;
}
~one_time()
{
if (collector) {
LARGE_INTEGER end;
QueryPerformanceCounter(&end);
collector->add_time(end.QuadPart - start.QuadPart);
}
}
};
}
// Usage TIME_THIS_SCOPE(XX); where XX is a C variable name (can begin with a number)
#define TIME_THIS_SCOPE(name) \
static scope_timer::time_collector st_time_collector_##name(_T(#name)); \
scope_timer::one_time st_one_time_##name(st_time_collector_##name)
</code></pre>
|
<p>The article <em>Code profiler and optimizations</em> has lots of information about C++ code profiling and also has a free download link to a program/class that will show you a graphic presentation for different code paths/methods.</p>
| 8,645
|
<p>I have an iMac, and I want to be able to turn off the monitor when I go to sleep,. Alas, the iMac has no switch for this. I do not want to put the iMac into sleep mode, i want to write a "expose" like application or service, which when the mouse is put into the upper left hand corner of my screen, the display will sleep. Likewise, if i move the mouse away, it comes back.</p>
<p>Does anyone have experience with tracking mouse movements within the Windows and Display APIs I'd need to look up. I just need some direction to get started.</p>
<p>Cheers!
Chris</p>
<hr>
<p>I've been asked to clarrify. Sorry if i'm confusing anyone. I'm running Windows Vista 32 via Bootcamp. I like that Mac OSX has a "hot corners" feature via Expose. I have noticed that besides power managment which runs on a time metric, there is no way to sleep the display at will in Vista.</p>
<p>I would like to write my own tool for this. I might be a glutton for punishment, but i'm a coder, and it's a good excuse to learn something new.</p>
|
<p>In Leopard, you can just go to "System Preferences" and "Desktop & Screensaver". Click the Screensaver tab, click "Hot Corners", selected the corner you want to change, then chose "Sleep display". Does that not work?</p>
|
<p>Not really the answer you seem to be looking for, but cant you do this via the power save option and/or the screen saver - can it be set to nothing.</p>
| 9,534
|
<p>I have a wooden first generation Replicator with dual extruders and I'm trying to get an X, Y, Z position from the printer to the computer in real time. Is that even possible? </p>
<p>The firmware used by the replicator is version 5.5 I believe, and I've been doing tests with ReplicatorG but I'm not married to that software.</p>
<p>Please let me know if you need any extra info before being able to comment on this... </p>
|
<p>I had mistakenly left the setting "one at a time" in print sequence. This meaning the printhead needs a lot of room since it will go back and forth in z.</p>
<p>Cura allocates this extra space even if there's only one object.</p>
|
<p>That looks like you've got the "brim" set to a very wide value. I know you said it's not explained by skirts --which, as Greenonline pointed out, is not the same as a brim--, but you didn't post that setting. At the same time, make sure you don't have a 'raft' set up. </p>
<p>One other possibility is that your source file actually contains a very large first layer. Try looking at the STL file in Meshlab or Meshmixer to see what's actually there.</p>
| 613
|
<p>I have a large codebase without Javadoc, and I want to run a program to write a skeleton with the basic Javadoc information (e.g., for each method's parameter write @param...), so I just have to fill the gaps left.</p>
<p>Anyone know a good solution for this?</p>
<p><strong>Edit:</strong></p>
<p>JAutodoc is what I was looking for. It has Ant tasks, an Eclipse plugin, and uses Velocity for the template definition.</p>
|
<p>The <a href="http://jautodoc.sourceforge.net/" rel="noreferrer">JAutodoc</a> plugin for eclipse does exactly what you need, but with a package granularity : </p>
<p>right click on a package, select "Add javadoc for members..." and the skeleton will be added.</p>
<p>There are numerous interesting options : templates for javadoc, adding a TODO in the header of every file saying : "template javadoc, must be filled...", etc.</p>
|
<p>If you right-click in the source of a file in Eclipse, it has a Javadoc generation option under the source menu.</p>
| 4,941
|
<p>I have control over the HttpServer but not over the ApplicationServer or the Java Applications sitting there but I need to block direct access to certain pages on those applications. Precisely, I don't want users automating access to forms issuing direct GET/POST HTTP requests to the appropriate servlet. </p>
<p>So, I decided to block users based on the value of <code>HTTP_REFERER</code>. After all, if the user is navigating inside the site, it will have an appropriate <code>HTTP_REFERER</code>. Well, that was what I thought. </p>
<p>I implemented a rewrite rule in the .htaccess file that says: </p>
<pre><code>RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} !^http://mywebaddress(.cl)?/.* [NC]
RewriteRule (servlet1|servlet2)/.+\?.+ - [F]
</code></pre>
<p>I expected to forbid access to users that didn't navigate the site but issue direct GET requests to the "servlet1" or "servlet2" servlets using querystrings. But my expectations ended abruptly because the regular expression <code>(servlet1|servlet2)/.+\?.+</code> didn't worked at all. </p>
<p>I was really disappointed when I changed that expression to <code>(servlet1|servlet2)/.+</code> and it worked so well that my users were blocked no matter if they navigated the site or not. </p>
<p>So, my question is: How do I can accomplish this thing of not allowing "robots" with direct access to certain pages if I have no access/privileges/time to modify the application?</p>
|
<p>I'm not sure if I can solve this in one go, but we can go back and forth as necessary.</p>
<p>First, I want to repeat what I think you are saying and make sure I'm clear. You want to disallow requests to servlet1 and servlet2 is the request doesn't have the proper referer and it <strong>does</strong> have a query string? I'm not sure I understand (servlet1|servlet2)/.+\?.+ because it looks like you are requiring a file under servlet1 and 2. I think maybe you are combining PATH_INFO (before the "?") with a GET query string (after the "?"). It appears that the PATH_INFO part will work but the GET query test will not. I made a quick test on my server using script1.cgi and script2.cgi and the following rules worked to accomplish what you are asking for. They are obviously edited a little to match my environment:</p>
<pre><code>RewriteCond %{HTTP_REFERER} !^http://(www.)?example.(com|org) [NC]
RewriteCond %{QUERY_STRING} ^.+$
RewriteRule ^(script1|script2)\.cgi - [F]
</code></pre>
<p>The above caught all wrong-referer requests to script1.cgi and script2.cgi that tried to submit data using a query string. However, you can also submit data using a path_info and by posting data. I used this form to protect against any of the three methods being used with incorrect referer:</p>
<pre><code>RewriteCond %{HTTP_REFERER} !^http://(www.)?example.(com|org) [NC]
RewriteCond %{QUERY_STRING} ^.+$ [OR]
RewriteCond %{REQUEST_METHOD} ^POST$ [OR]
RewriteCond %{PATH_INFO} ^.+$
RewriteRule ^(script1|script2)\.cgi - [F]
</code></pre>
<p>Based on the example you were trying to get working, I think this is what you want:</p>
<pre><code>RewriteCond %{HTTP_REFERER} !^http://mywebaddress(.cl)?/.* [NC]
RewriteCond %{QUERY_STRING} ^.+$ [OR]
RewriteCond %{REQUEST_METHOD} ^POST$ [OR]
RewriteCond %{PATH_INFO} ^.+$
RewriteRule (servlet1|servlet2)\b - [F]
</code></pre>
<p>Hopefully this at least gets you closer to your goal. Please let us know how it works, I'm interested in your problem.</p>
<p>(BTW, I agree that referer blocking is poor security, but I also understand that relaity forces imperfect and partial solutions sometimes, which you seem to already acknowledge.)</p>
|
<p>I'm guessing you're trying to prevent screen scraping?</p>
<p>In my honest opinion it's a tough one to solve and trying to fix by checking the value of HTTP_REFERER is just a sticking plaster. Anyone going to the bother of automating submissions is going to be savvy enough to send the correct referer from their 'automaton'.</p>
<p>You could try rate limiting but without actually modifying the app to force some kind of is-this-a-human validation (a CAPTCHA) at some point then you're going to find this hard to prevent.</p>
| 2,560
|
<p>Our topics page has been sorely lacking for a few years now, and in need of an update, in order to reflect what the site has become, and to take into account what people has been asking for. Note that, the core concept is still the same - 3D Printing. However, the scope has been widened in a number of ways/directions. For example:</p>
<ul>
<li>to include technologies which aren't strictly 3D Printing, but where there is overlap</li>
<li>to cover 3D Printing related tools, such as scanning, and tools/software used</li>
<li>to cover 3D printing related areas, such as modelling, legal issues,</li>
<li>and so on.</li>
</ul>
<p>After the suggested expanded topics list had been sitting around for about a year now, on <a href="https://3dprinting.meta.stackexchange.com/questions/276/game-plan-what-is-on-topic">Game plan - What is on-topic?</a>, and changed/modified throughout the year to accomodate comments/feedback/requests, the proposed list has been moved on to the actual On-topics page, in the Help Center: <a href="https://3dprinting.stackexchange.com/help/on-topic">What topics can I ask about here?</a></p>
<p>Yes, it will still need a little tidying up, as it is basically a copy and paste and some additional formatting to make it fit, but at least it's there now - just rough around the edges.</p>
<p>Please, if you have any comments/suggestions/improvements/disagreements/anger, please post it as comments or answers below. Feedback, any feedback at all, will be more than welcomed.</p>
|
<p>I like the expanded definitions, but there is probably an issue with some of the things you'd put into "just rough around the edges" portion of what you state.</p>
<p>For instance, "Print Services" are mentioned as far as on-topic and what is allowed. <em>To what extent are Print Services</em> on-topic and allowed? In and of itself, as you've stated it, it could be anything from what to expect to giving them service recommendations (ie: <em>What's a good place to get xxxx done?</em> or <em>Who provides to best services in the Dallas, TX area?</em>) This isn't the only place where it could be done. If you don't want questions like this, throw a little more specification in there as far as what would be acceptable. </p>
|
<p>I like the expanded definitions, but there is probably an issue with some of the things you'd put into "just rough around the edges" portion of what you state.</p>
<p>For instance, "Print Services" are mentioned as far as on-topic and what is allowed. <em>To what extent are Print Services</em> on-topic and allowed? In and of itself, as you've stated it, it could be anything from what to expect to giving them service recommendations (ie: <em>What's a good place to get xxxx done?</em> or <em>Who provides to best services in the Dallas, TX area?</em>) This isn't the only place where it could be done. If you don't want questions like this, throw a little more specification in there as far as what would be acceptable. </p>
| 68
|
<p>I have a <a href="https://whambamsystems.com/flexible-build-system" rel="nofollow noreferrer">WhamBam build system</a> on order. A magnet attaches (glues down I think) to the Aluminium printing bed (or add a glass sheet? Separate question), then PEX material on flexible steel sheet gets slapped down for the print surface. </p>
<p><a href="https://i.stack.imgur.com/lplp5.jpg" rel="nofollow noreferrer" title="WhamBam build system"><img src="https://i.stack.imgur.com/lplp5.jpg" alt="WhamBam build system" title="WhamBam build system"></a></p>
<p>I have been printing PLA on a cold PEI sheet from Vertex, using 4 binder clips to hold it in place vs peeling the backing off and sticking it down. The print job wants to keep heating the bed to 60 °C, I turn it down, a couple minutes into a job it cranks it back to 60 °C and I turn it down again. A few times I missed the second turn on, and the PEI has been kinda warped now (or maybe it's just the plastic over the sticky backing), and has also peeled off some surface chunks in the middle, so we've been trying to print around the damaged section. The warping has now made the PEI unusable, so I'm hoping the WhamBam arrives soon.</p>
<p>We've been printing for a couple of weeks now (I printed a chess set, largest has 4 cm diameter and is 10 cm tall, some pieces on blue tape, some on the PEI) and are starting to venture into our own designs.</p>
<p>Intended project is box tops & bottoms that are ~90 mm x 65 mm x different heights with openings. We tried one on blue tape (a bottom with no openings) and ended up chiseling it off the bed with a steel putty knife (I don't recall if heat was on or not). We tried a top with openings on the PEI, missed that the heat had turned back on, but between the bed not quite level (forgot to re-check it) and the PEI being warped we killed it after the openings were printed around. It was not going to be usable, but we did print enough to be able to confirm the opening spacings (needs work still) so it was not a total loss. Came off the PEI easily (<2 mm thick when we stopped), we managed to miss the damaged parts mostly.</p>
<p>So the question: when the WhamBam arrives, is it better to print PLA at 60 °C, or do I keep playing the game of turning it down (and saving the waiting time of it heating up)?</p>
|
<p>I print PLA on a PEI bed at 60°C. I have also printed PLA on an aluminum bed at 60°C with Elmer's Glue Stick for bonding, which worked better for me than PLA. I recently switched to Aqua Net Hairspray on the aluminum bed at 60°C, which also worked well.</p>
<p>I have found no reason to avoid bed heating with PLA.</p>
<p>If the object is stuck too tightly on the PEI bed, you could try adding hairspray. It acts as a glue, but also as a release agent, and, being soluble in water, you can help release the object with a few water drops.</p>
|
<p>Received and installed the WhamBam system, and it works great! Have been letting it heat to 60C, which I'm pretty sure is not making it all the way thru the magnet, flex steel plate, and the PEX surface, but parts are adhering great and pop right off the PEX just by the act of picking up the plate, even a large box bottom (~68mm x 95mm) came off so easily I thought it had lost adhesion - my wife printed several items earlier and they came off the same way. I am impressed with the system!</p>
<p>We had lost a blade off the hot end fan (and turns out it was 3 blades), initial prints had failed to adhere on the PEX, the PLA didn't appear to be extruding properly, and the fan irregularity was very irritating. Internet searches indicated the plastic melting temp was not accurate enough. Replaced the fan and every print since has been great.</p>
<p>EDIT 6/14/2019 Here is a youtube clip of a freshly printed door knob (screen door latch) coming off a 60C bed, no problem!</p>
<p><div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/a7nms-t8peQ?start=0"></iframe>
</div></div></p>
<p>And a larger box, ~65 x 98mm, that popped right off.</p>
<p><div class="youtube-embed"><div>
<iframe width="640px" height="395px" src="https://www.youtube.com/embed/ku-fMtnlXhQ?start=0"></iframe>
</div></div></p>
| 1,340
|
<p>We have a project with over 500,000 lines of VB.NET that we need to convert to C#. Any recommendations, based on experience, for tools to use? We are using Visual Studio 2008 and we're targeting 3.5 .</p>
|
<p>I would concur with the comment. You have 500,000 lines of tried and true VB.NET code. Why on earth would you waste any time changing that? No one says that you can't write all new components in C#.</p>
<p>I would consider not worrying about a tool and instead ask yourself, truly, why you are doing this?</p>
|
<p>I've used <a href="http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx" rel="nofollow noreferrer">this site</a> for a while now for some of my smaller conversions. It has been quite reliable.</p>
<p>According to the site, their converter is based off an <a href="http://www.icsharpcode.net/OpenSource/SD/Features.aspx" rel="nofollow noreferrer">open source IDE</a> that has the converter built in, so you might try the "source site" as well.</p>
| 9,278
|
<p>In a typical handheld/portable embedded system device Battery life is a major concern in design of H/W, S/W and the features the device can support. From the Software programming perspective, one is aware of MIPS, Memory(Data and Program) optimized code.
I am aware of the H/W Deep sleep mode, Standby mode that are used to clock the hardware at lower Cycles or turn of the clock entirel to some unused circutis to save power, but i am looking for some ideas from that point of view:</p>
<p>Wherein my code is running and it needs to keep executing, given this how can I write the code "power" efficiently so as to consume minimum watts?</p>
<p>Are there any special programming constructs, data structures, control structures which i should look at to achieve minimum power consumption for a given functionality.</p>
<p>Are there any s/w high level design considerations which one should keep in mind at time of code structure design, or during low level design to make the code as power efficient(Least power consuming) as possible? </p>
|
<ul>
<li>Like <code>1800 INFORMATION</code> said, avoid polling; subscribe to events and wait for them to happen</li>
<li>Update window content only when necessary - let the system decide when to redraw it</li>
<li>When updating window content, ensure your code recreates as little of the invalid region as possible</li>
<li>With quick code the CPU goes back to deep sleep mode faster and there's a better chance that such code stays in L1 cache</li>
<li>Operate on small data at one time so data stays in caches as well</li>
<li>Ensure that your application doesn't do any unnecessary action when in background</li>
<li>Make your software not only power efficient, but also power aware - update graphics less often when on battery, disable animations, less hard drive thrashing</li>
</ul>
<p>And read some other <a href="https://software.intel.com/en-us/articles/partner-energy-efficient-software-guidelines" rel="nofollow noreferrer">guidelines</a>. ;)</p>
<p>Recently a series of posts called <a href="http://software.intel.com/en-us/search/site/field_tags/software-17970/field_tags/acpi-18789/language/en/type/blog?query=Optimizing%20Software%20Applications%20for%20Power" rel="nofollow noreferrer">"Optimizing Software Applications for Power"</a>, started appearing on Intel Software Blogs. May be of some use for x86 developers.</p>
|
<p>also something that is not trivial to do is reduce precision of the mathematical operations, go for the smallest dataset available and if available by your development environment pack data and aggregate operations. </p>
<p>knuth books could give you all the variant of specific algorithms you need to save memory or cpu, or going with reduced precision minimizing the rounding errors</p>
<p>also, spent some time checking for all the embedded device api - for example most symbian phones could do audio encoding via a specialized hardware</p>
| 8,719
|
<p>Many of the parameters for interacting with the Office Object model in VSTO require object parameters that are passed by reference, even when the notional type of the parameter is an int or string.</p>
<ol>
<li>I suppose that this mechanism is used so that code can modify the parameter, although I can't figure out why these need to be passed as generic object instead of as their more appropriate types. Can anyone enlighten me?</li>
<li><p>The mechanism I've been using (cribbed from help and MSDN resources) essentially creates a generic object that contains the appropriate data and then passes that to the method, for example:</p>
<p>object nextBookmarkName = "NextContent";
object nextBookmark = this.Bookmarks.get_Item( ref nextBookmarkName ).Range;</p>
<p>Microsoft.Office.Interop.Word.Range newRng = this.Range( ref nextBookmark, ref nextBookmark );</p></li>
</ol>
<p>This seems like a lot of extra code, but I can't see a better way to do it. I'm sure I'm missing something; what is it? Or is this really the best practice?</p>
|
<p>I agree with Joe. I even developed helper structs and classes like this one:</p>
<pre><code>internal struct Argument
{
internal static object False = false;
internal static object Missing = System.Type.Missing;
internal static object True = true;
}
</code></pre>
<p>And this one:</p>
<pre><code>/// <summary>
/// Defines the "special characters"
/// in Microsoft Word that VSTO 1.x
/// translates into C# strings.
/// </summary>
internal struct Characters
{
/// <summary>
/// Word Table end-of-cell marker.
/// </summary>
/// <remarks>
/// Word Table end-of-row markers are also
/// equal to this value.
/// </remarks>
internal static string CellBreak = "\r\a";
/// <summary>
/// Word line break (^l).
/// </summary>
internal static string LineBreak = "\v";
/// <summary>
/// Word Paragraph break (^p).
/// </summary>
internal static string ParagraphBreak = "\r";
}
</code></pre>
<p>And a few more...</p>
|
<p>I'd be interested in this too. I'm coding several apps that uses automation in Word and I even have things like</p>
<pre><code>object oFalse = false, oTrue = true, oOne = 1;
</code></pre>
<p>It's very nasty, but it's the only way I know so far. </p>
<p>The only thing I can think of is writing a wrapper class for the frequently used functions...</p>
| 9,894
|
<p>Does Stackoverflow create a new OpenID when a user registers with an email address (i.e. does not provide an existing OpenID)? How do you do that? Do you have code examples in C#? Java? Python?</p>
|
<p>You can find OpenID implementations <a href="http://wiki.openid.net/Libraries" rel="nofollow noreferrer">here</a>. If you just want more information, I would check out the <a href="http://openid.net/" rel="nofollow noreferrer">OpenID site</a>.</p>
|
<p>I think you are mis-understanding OpenID, the process of registering and OpenID is the responsibility of the user, you'll note that there is no place to signup here without an OpenID.</p>
| 6,386
|
<p>We have a whole bunch of DLLs that give us access to our database and other applications and services.</p>
<p>We've wrapped these DLLs with a thin WCF service layer which our clients then consume.</p>
<p>I'm a little unsure on how to write unit tests that only test the WCF service layer. Should I just write unit tests for the DLLs, and integration tests for the WCF services? I'd appreciate any wisdom... I know that if my unit tests actually go to the database they won't actually be true unit tests. I also understand that I don't really need to test the WCF service host in a unit test. </p>
<p>So, I'm confused about exactly what to test and how.</p>
|
<p>If you want to unit test your WCF service classes make sure you design them with loose coupling in mind so you can mock out each dependancy as you only want to test the logic inside the service class itself.</p>
<p>For example, in the below service I break out my data access repository using "Poor Man's Dependency Injection".</p>
<pre><code>Public Class ProductService
Implements IProductService
Private mRepository As IProductRepository
Public Sub New()
mRepository = New ProductRepository()
End Sub
Public Sub New(ByVal repository As IProductRepository)
mRepository = repository
End Sub
Public Function GetProducts() As System.Collections.Generic.List(Of Product) Implements IProductService.GetProducts
Return mRepository.GetProducts()
End Function
End Class
</code></pre>
<p>On the client you can mock the WCF service itself using the interface of the service contract.</p>
<pre><code><TestMethod()> _
Public Sub ShouldPopulateProductsListOnViewLoadWhenPostBackIsFalse()
mMockery = New MockRepository()
mView = DirectCast(mMockery.Stub(Of IProductView)(), IProductView)
mProductService = DirectCast(mMockery.DynamicMock(Of IProductService)(), IProductService)
mPresenter = New ProductPresenter(mView, mProductService)
Dim ProductList As New List(Of Product)()
ProductList.Add(New Product)
Using mMockery.Record()
SetupResult.For(mView.PageIsPostBack).Return(False).Repeat.Once()
Expect.Call(mProductService.GetProducts()).Return(ProductList).Repeat.Once()
End Using
Using mMockery.Playback()
mPresenter.OnViewLoad()
End Using
'Verify that we hit the service dependency during the method when postback is false
Assert.AreEqual(1, mView.Products.Count)
mMockery.VerifyAll()
End Sub
</code></pre>
|
<p>If you want to unit test your WCF service classes make sure you design them with loose coupling in mind so you can mock out each dependancy as you only want to test the logic inside the service class itself.</p>
<p>For example, in the below service I break out my data access repository using "Poor Man's Dependency Injection".</p>
<pre><code>Public Class ProductService
Implements IProductService
Private mRepository As IProductRepository
Public Sub New()
mRepository = New ProductRepository()
End Sub
Public Sub New(ByVal repository As IProductRepository)
mRepository = repository
End Sub
Public Function GetProducts() As System.Collections.Generic.List(Of Product) Implements IProductService.GetProducts
Return mRepository.GetProducts()
End Function
End Class
</code></pre>
<p>On the client you can mock the WCF service itself using the interface of the service contract.</p>
<pre><code><TestMethod()> _
Public Sub ShouldPopulateProductsListOnViewLoadWhenPostBackIsFalse()
mMockery = New MockRepository()
mView = DirectCast(mMockery.Stub(Of IProductView)(), IProductView)
mProductService = DirectCast(mMockery.DynamicMock(Of IProductService)(), IProductService)
mPresenter = New ProductPresenter(mView, mProductService)
Dim ProductList As New List(Of Product)()
ProductList.Add(New Product)
Using mMockery.Record()
SetupResult.For(mView.PageIsPostBack).Return(False).Repeat.Once()
Expect.Call(mProductService.GetProducts()).Return(ProductList).Repeat.Once()
End Using
Using mMockery.Playback()
mPresenter.OnViewLoad()
End Using
'Verify that we hit the service dependency during the method when postback is false
Assert.AreEqual(1, mView.Products.Count)
mMockery.VerifyAll()
End Sub
</code></pre>
| 5,803
|
<p>I am getting the following error in an MS Access ADP when trying to add a record on a form linked to a MS SQL Server 2000 table:</p>
<blockquote>
<p>Run-time error '31004':</p>
<p>The value of an (AutoNumber) field
cannot be retrived prior to being
saved.</p>
<p>Please save the record that contains
the (AutoNumber) field prior to
performing this action.
note: <em>retrieved</em> is actually spelled wrong in the error.</p>
</blockquote>
<p>Does anyone know what this means?</p>
<p>I've done a web search and was only able to find the answer at a certain site that only experts have access to.</p>
|
<p>First of all, if you are going to look at experts-exchange - do it in FireFox, you'll see the unblocked answers at the bottom of the page.</p>
<p>Second, do you have a subform on that form that's using the autonumber/key field on the master form? Do you require the data that's on that subform to be saved (i.e., having its own key) before the main form is saved. You could be into a deadlock of A and B requiring each other to be saved first.</p>
<p>Other than that, you must somehow be accessing that autonumber field whenyou are saving it. The best I can suggest is to step through the code line by line.</p>
|
<p>Are you trying to assign the value of an Identity field to a variable or something else before you have saved the record?</p>
<p>For whatever reason, your app is trying to read the value of the identity field before the record has been saved, which is what generates that identity field. In other words, no value exists for the Autonumber field until the row is saved.</p>
<p>I think we'd need to see more code or know more about the steps that lead up to this error to resolve it in more detail.</p>
| 8,452
|
<p>Recently Jeff has <a href="http://blog.codinghorror.com/deadlocked/" rel="noreferrer">posted</a> regarding his trouble with database deadlocks related to reading. <a href="https://en.m.wikipedia.org/wiki/Multiversion_concurrency_control" rel="noreferrer">Multiversion Concurrency Control (MVCC)</a> claims to solve this problem. What is it, and what databases support it?</p>
<p>updated: these support it (which others?)</p>
<ul>
<li>oracle</li>
<li>postgresql </li>
</ul>
|
<p>Oracle has had an excellent multi version control system in place since very long(at least since oracle 8.0)</p>
<p>Following should help.</p>
<ol>
<li>User A starts a transaction and is updating 1000 rows with some value At Time T1</li>
<li>User B reads the same 1000 rows at time T2.</li>
<li>User A updates row 543 with value Y (original value X)</li>
<li>User B reaches row 543 and finds that a transaction is in operation since Time T1.</li>
<li>The database returns the unmodified record from the Logs. The returned value is the value that was committed at the time less than or equal to T2.</li>
<li>If the record could not be retreived from the redo logs it means the database is not setup appropriately. There needs to be more space allocated to the logs.</li>
<li>This way the read consitency is achieved. The returned results are always the same with respect to the start time of transaction. So within a transaction the read consistency is achieved.</li>
</ol>
<p>I have tried to explain in the simplest terms possible...there is a lot to multiversioning in databases.</p>
|
<p>DB2 version 9.7 has a licensed version of postgress plus in it. This means that this feature (in the right mode) supports this feature. </p>
| 4,710
|
<p>I am having a problem with the speed of accessing an association property with a large number of records.</p>
<p>I have an XAF app with a parent class called <code>MyParent</code>.</p>
<p>There are 230 records in <code>MyParent</code>.</p>
<p><code>MyParent</code> has a child class called <code>MyChild</code>.</p>
<p>There are 49,000 records in <code>MyChild</code>.</p>
<p>I have an association defined between <code>MyParent</code> and <code>MyChild</code> in the standard way:</p>
<p>In <code>MyChild</code>:</p>
<pre><code>// MyChild (many) and MyParent (one)
[Association("MyChild-MyParent")]
public MyParent MyParent;
</code></pre>
<p>And in <code>MyParent</code>:</p>
<pre><code>[Association("MyChild-MyParent", typeof(MyChild))]
public XPCollection<MyCHild> MyCHildren
{
get { return GetCollection<MyCHild>("MyCHildren"); }
}
</code></pre>
<p>There's a specific <code>MyParent</code> record called <code>MyParent1</code>.</p>
<p>For <code>MyParent1</code>, there are 630 <code>MyChild</code> records.</p>
<p>I have a DetailView for a class called <code>MyUI</code>.</p>
<p>The user chooses an item in one drop-down in the <code>MyUI</code> DetailView, and my code has to fill another drop-down with <code>MyChild</code> objects.</p>
<p>The user chooses <code>MyParent1</code> in the first drop-down.</p>
<p>I created a property in <code>MyUI</code> to return the collection of <code>MyChild</code> objects for the selected value in the first drop-down.</p>
<p>Here is the code for the property:</p>
<pre><code>[NonPersistent]
public XPCollection<MyChild> DisplayedValues
{
get
{
Session theSession;
MyParent theParentValue;
XPCollection<MyCHild> theChildren;
theParentValue = this.DropDownOne;
// get the parent value
if theValue == null)
{
// if none
return null;
// return null
}
theChildren = theParentValue.MyChildren;
// get the child values for the parent
return theChildren;
// return it
}
</code></pre>
<p>I marked the <code>DisplayedValues</code> property as <code>NonPersistent</code> because it is only needed for the UI of the DetailVIew. I don't think that persisting it will speed up the creation of the collection the first time, and after it's used to fill the drop-down, I don't need it, so I don't want to spend time storing it.</p>
<p>The problem is that it takes 45 seconds to call <code>theParentValue = this.DropDownOne</code>.</p>
<p>Specs:</p>
<ul>
<li>Vista Business</li>
<li>8 GB of RAM</li>
<li>2.33 GHz E6550 processor</li>
<li>SQL Server Express 2005</li>
</ul>
<p>This is too long for users to wait for one of many drop-downs in the DetailView.</p>
<p>I took the time to sketch out the business case because I have two questions:</p>
<ol>
<li><p>How can I make the associated values load faster?</p></li>
<li><p>Is there another (simple) way to program the drop-downs and DetailView that runs much faster?</p></li>
</ol>
<p>Yes, you can say that 630 is too many items to display in a drop-down, but this code is taking so long I suspect that the speed is proportional to the 49,000 and not to the 630. 100 items in the drop-down would not be too many for my app.</p>
<p>I need quite a few of these drop-downs in my app, so it's not appropriate to force the user to enter more complicated filtering criteria for each one. The user needs to pick one value and see the related values.</p>
<p>I would understand if finding a large number of records was slow, but finding a few hundred shouldn't take that long.</p>
|
<p>Firstly you are right to be sceptical that this operation should take this long, XPO on read operations should add only between 30 - 70% overhead, and on this tiny amount of data we should be talking milli-seconds not seconds.</p>
<p>Some general perf tips are available in the DevExpress forums, and centre around object caching, lazy vs deep loads etc, but I think in your case the issue is something else, unfortunately its very hard to second guess whats going on from your question, only to say, its highly unlikely to be a problem with XPO much more likely to be something else, I would be inclined to look at your session creation (this also creates your object cache) and SQL connection code (the IDataStore stuff), Connections are often slow if hosts cannot not be resolved cleanly and if you are not pooling / re-using connections this problem can be exacerbated.</p>
|
<p>Thanks for the answer. I created a separate solution and was able to get good performance, as you suggest.</p>
<p>My SQL connection is OK and works with other features in the app.</p>
<p>Given that I'm using XAF and not doing anything extra/fancy, aren't my sessions managed by XAF?</p>
<p>The session I use is read from the DetailView.</p>
| 8,786
|
<p>This question is similar:</p>
<p><a href="https://3dprinting.stackexchange.com/questions/156/are-there-biocompatible-materials-available-to-the-general-public">Are there biocompatible materials available to the general public?</a></p>
<p>But appears to be for non-implantation use. This question is for materials intended to be implanted.</p>
<p>Are any typical 3D printed (extrusion based 3D printer) materials, such as ABS or PLA (or slightly more exotic ones, such as kevlar, fibreglass, or carbon fiber), safe for implantation in the human body? Or in medical terms, are they biocompatible (biofunctionality is not topical for this question)? If not, why not? If most of them are safe, then please explain which ones are NOT safe.</p>
<p>Highly relevant, and perhaps even more interesting is: Are there any peer reviewed medical papers that have investigated what materials are safe for implantation in the human body? A paper which answers this unambiguously would be the ideal answer to this question. Another concern is if the process of 3D printing itself adversely influences the properties of the material in the context of implantation applications.</p>
<p>I've tried to determine the answer to this question myself, but I cannot find any papers or studies which answer it. I can easily find that ABS plastic is "non-biodegradable", but I suppose the issue of adverse host responses is more crucial, e.g. causing inflammation or it being a bacterial growth substrate to promote infections seems like plausible concerns. I'm sure there might be other dangerous complications too, which I'm not aware of.</p>
<p>I found a paper dealing with corrosion issues for implantable metals: DOI: 10.1089/end.1997.11.383</p>
<p>I found a paper dealing with silicone-urethane being prone to breakdown: DOI: 10.1021/ma301965y</p>
<p>I found a paper describing the properties and history of ultra-high molecular weight polyethylene (UHMWPE), which appears to be commonly used as implants: DOI: 10.1109/EEIC.2005.1566331</p>
<p>By extension, a 3D printer using UHMWPE might be safe, barring any adverse chemical or mechanical issues as a result of the 3D printing process itself. However, it is not clear to me if any 3D printers can actually reliably print UHMWPE. Furthermore, it is unclear if UHMWPE is a sane choice, as it appears to be useful in applications where strength is required, such as for joints. What about other applications where load bearing properties are not required (e.g. a simple enclosure for implantable electronics)?</p>
<p>I'm aware that titanium appears to be frequently used for implants, and while titanium 3D printers do exist, they are beyond the scope of this question. The valid context is extrusion based 3D printers in the sub $10,000 range (arbitrarily chosen to make the question avoid being tagged as "too broad").</p>
|
<p>Perhaps more than biocompatible, which generally refers to a material that does not illicit a harmful inflammatory response inside the body, you should be looking at bioresorbable materials, which are materials that dissolve inside the body after a certain time period without needing mechanical removal. </p>
<p>As an example, FDA approved poly (lactic acid) is available in pellet form from Corbion (formerly PURAC biomaterials) and can be extruded into 1.75mm filament for use with any desktop 3D printer (<a href="https://www.sciencedirect.com/science/article/pii/S2214860416301385" rel="nofollow noreferrer">https://www.sciencedirect.com/science/article/pii/S2214860416301385</a>). Similarly, researchers have used poly (caprolactone) to 3D print scaffolds with using a stratasys FDM machine (<a href="https://onlinelibrary.wiley.com/doi/pdf/10.1002/1097-4636(200105)55:2%3C203::AID-JBM1007%3E3.0.CO;2-7" rel="nofollow noreferrer">https://onlinelibrary.wiley.com/doi/pdf/10.1002/1097-4636(200105)55:2%3C203::AID-JBM1007%3E3.0.CO;2-7</a>).</p>
|
<p>Yes. I have worked with people who have printed implants of PCL, loaded with antibiotics, for delivery at the infection site: <a href="https://www.google.com/search?q=pcl+medical+approval" rel="nofollow noreferrer">https://www.google.com/search?q=pcl+medical+approval</a></p>
<p>Also look at PPSU: <a href="https://www.google.com/search?q=ppsu+medical+approval" rel="nofollow noreferrer">https://www.google.com/search?q=ppsu+medical+approval</a></p>
<p>And PEEK: <a href="https://www.google.com/search?q=peek+medical+approval" rel="nofollow noreferrer">https://www.google.com/search?q=peek+medical+approval</a></p>
<p>These are currently used for appliances; I'm not aware of them being used for implants yet.</p>
| 842
|
<p>What are some important practices to follow when creating a .NET assembly that is going to be embedded to SQL Server 2005?</p>
<p>I am brand new to this, and I've found that there are significant method attributes like:</p>
<pre><code>[SqlFunction(FillRowMethodName = "FillRow", TableDefinition = "letter nchar(1)")]
</code></pre>
<p>I'm also looking for common pitfalls to avoid, etc.</p>
|
<p>Some that I remember:</p>
<ul>
<li>Keep its usage to a minimum, only use it when T-SQL proved too complex.</li>
<li>Avoid pointers/cursors at all costs because a for loop is so easily abusable in CLR context.</li>
<li>Only use the SQL-Server native data types unless totally necessary.</li>
</ul>
<p>Can't remember where I've found the information, but those are some that I do remember.</p>
<p>Basically, only use it when declarative T-SQL is too complex or is impossible to do (such as registry editing etc.).</p>
|
<p>I would strongly advise against putting .net assemblies in your database server, think n-tier applications. Persistence <- Business Logic <-Presentation Logic <- client
Keep your Logic in your Business Logic layer. </p>
<p>The only reason I can think of to put .net in your database would to add a new complex data type, I would strongly that this be a dumb class that only holds data and does no processing on it.</p>
<p>Just because you can does not mean you should.
Sorry for not directly answering your question.</p>
| 9,757
|
<p>I'm printing a object with a pretty sizable overhang. And the results, after support removal, are pretty ugly.</p>
<p>Here is the print before support removal.
<a href="https://i.stack.imgur.com/VOWiG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VOWiG.jpg" alt="3d print with support" /></a></p>
<p>And here is the final product, sigh.
<a href="https://i.stack.imgur.com/z19Oe.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z19Oe.jpg" alt="enter image description here" /></a></p>
<p>Finally here are my slic3r settings:</p>
<ul>
<li>Generate Support Material: [✔]</li>
<li>Overhang threshold: 60°</li>
<li>Max Layer Count for Supports: 0 layers</li>
<li>Enforce Support for the First: 0 layers</li>
<li>Raft layers: 0 layers</li>
</ul>
<p>Options for support material and raft</p>
<ul>
<li>Contact Z distance: 0.2 mm (detachable)</li>
<li>Pattern: pillars</li>
<li>Pattern spacing: 2.5 mm</li>
<li>Pattern angle: 0°</li>
<li>Interface Layers: 3 layers</li>
<li>Interface pattern spacing: 2 mm</li>
<li>Support on Build Plate Only: [✔]</li>
<li>Don't support bridges: [ ]</li>
</ul>
<p>The material I'm using is ABS, 230 °C temperature setting. Layers, Adaptive Slicing, Adaptive quality: 75 %, Match horizontal surfaces. Vertical shells, 3 perimeters minimum. Horizontal shells, solid layers: top: 3, bottom 3.</p>
<p>Is there a way to improve this?</p>
<p>Note: for anybody interested... these are small disposable spatulas used to place bondo mix onto a flat surface at the bottom of a restricted space, to fill small holes in wood. Its too tight in there to use a normal putty knife.</p>
<hr />
<p><strong>Some more print settings</strong></p>
<p>Included here are the speed settings from Slic3r:</p>
<p><a href="https://i.stack.imgur.com/5NXO1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5NXO1.png" alt="slic3r speed settings" /></a></p>
<hr />
<p><strong>G-code analysis</strong></p>
<p><a href="https://i.stack.imgur.com/pDYAz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pDYAz.png" alt="gcode analysis" /></a></p>
<p>I'm wondering why there is such a large gap between the gold colored E shaped interface to the blue spatula handle? And that makes me wonder, what support material and raft settings should I be using? Why is that gap so big? (And I have to go back into SolidWorks and check, but I'm nearly certain that handle is 2 mm wide. That gap to the support is really big.)</p>
|
<p>Judging from the print quality of support material (very "fat") and of top surfaces (which look with ripples and a lot of material), you have at least 3% overxtrusion, which will result also in stronger connection between support and print, and more difficult removal, lower quality parts.</p>
<p>I would reduce extrusion by 3%, to start, and see if it goes better. In your case you can tolerate underextrusion, since the part is likely not stressed significantly, so in doubt reduce it even more.</p>
<p>You can also print <a href="https://www.thingiverse.com/thing:3695183" rel="nofollow noreferrer">this test part</a> to check optimal extrusion.</p>
<p>Also, remember that extrusion is (almost always) dependent on speed: if you get perfect extrusion at 60 mm/s, infill at 80 mm/s will be slightly underextruded and outer perimeters (30 mm/s) will be overextruded. In general, set everything to the same speed.</p>
|
<p>I'm not terribly familiar with slic3r, but it looks like you have a setting (possibly a default one) to slow down on printing overhangs. This was a popular "feature" in slicing software (Cura has it I know) but it's <strong>exactly the opposite</strong> of what you should be doing. When slowing down to print an overhang, the pressure in the nozzle forces the material to keep coming out at the same rate it was coming out until it subsides, and you end up with a big hanging glob of ooze like in your photo.</p>
<p>If your printer firmware has linear-advance/pressure-advance functionality, this can mostly be eliminated. But if not (most stock firmware), you need to maintain full speed on overhangs, and might even need to turn up your acceleration limits so that you don't get a significant slowdown just by decelerating to go around the corner.</p>
| 1,678
|
<p>I am relatively new to JavaScript and am trying to understand how to use it correctly.</p>
<p>If I wrap JavaScript code in an anonymous function to avoid making variables <code>public</code> the functions within the JavaScript are not available from within the html that includes the JavaScript. </p>
<p>On initially loading the page the JavaScript loads and is executed but on subsequent reloads of the page the JavaScript code does not go through the execution process again. Specifically there is an ajax call using <code>httprequest</code> to get that from a PHP file and passes the returned data to a callback function that in <em>onsuccess</em> processes the data, if I could call the function that does the <code>httprequest</code> from within the html in a </p>
<pre><code><script type="text/javascript" ></script>
</code></pre>
<p>block on each page load I'd be all set - as it is I have to inject the entire JavaScript code into that block to get it to work on page load, hoping someone can educate me.</p>
|
<p>If you aren't using a javascript framework, I strongly suggest it. I use MooTools, but there are many others that are very solid (Prototype, YUI, jQuery, etc). These include methods for attaching functionality to the DomReady event. The problem with:</p>
<pre><code>window.onload = function(){...};
</code></pre>
<p>is that you can only ever have one function attached to that event (subsequent assignments will overwrite this one).</p>
<p>Frameworks provide more appropriate methods for doing this. For example, in MooTools:</p>
<pre><code>window.addEvent('domready', function(){...});
</code></pre>
<p>Finally, there are other ways to avoid polluting the global namespace. Just namespacing your own code (mySite.foo = function...) will help you avoid any potential conflicts.</p>
<p>One more thing. I'm not 100% sure from your comment that the problem you have is specific to the page load event. Are you saying that the code needs to be executed when the ajax returns as well? Please edit your question if this is the case.</p>
|
<p>It might be best not to wrap everything in an anonymous function and just hope that it is executed. You could name the function, and put its name in the body tag's onload handler. This should ensure that it's run each time the page is loaded.</p>
| 9,352
|
<p>I would like to have all developers on my team to use the same rules for formatting several types of code (ASPX, CSS, JavaScript, C#). Can I have visual studio look to a common place for these rules?</p>
<p>I would like to not rely on export/import settings as that brings many settings along. I (for example) don't care what font colors the developer uses when typing, I just want similar formatting. Can you import a subset of settings?</p>
|
<p><a href="http://stylecop.codeplex.com/" rel="nofollow noreferrer">StyleCop</a>, originally called <a href="http://code.msdn.microsoft.com/sourceanalysis" rel="nofollow noreferrer">"Source Analysis"</a> is the best choice for C#. The first version was rather inflexible, but after recognizing the value that it provides for the community, Microsoft has opened it up to extensions and customizations. It's a solid tool.</p>
<p>For Visual Studio settings, it's trivial to export a sub-set of your settings into a .settings file and require that other team members import and use these settings.</p>
<p>Like any standards, the tools are only as good as the team members, so it probably goes without saying that you will need team buy-in regardless of what tool you use for enforcement.</p>
|
<p><strong>Code Review.</strong></p>
| 6,082
|
<p>I would like to save the programs settings every time the user exits the program. So I need a way to call a function when the user quits the program. How do I do that?</p>
<p>I am using Java 1.5.</p>
|
<p>You can add a shutdown hook to your application by doing the following:</p>
<pre><code>Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
public void run() {
// what you want to do
}
}));
</code></pre>
<p>This is basically equivalent to having a try {} finally {} block around your entire program, and basically encompasses what's in the finally block.</p>
<p>Please note the <a href="https://stackoverflow.com/questions/63687/calling-function-when-program-exits-in-java#63886">caveats</a> though!</p>
|
<p>Are you creating a stand alone GUI app (i.e. Swing)?</p>
<p>If so, you should consider how you are providing options to your users how to exit the application.
Namely, if there is going to be a File menu, I would expect that there will be an "Exit" menu item.
Also, if the user closes the last window in the app, I would also expect it to exit the application.
In both cases, it should call code that handles saving the user's preferences.</p>
| 8,908
|
<p>Does anyone here know of good batch file code indenters or beautifiers?</p>
<p>Specifically for PHP, JS and SGML-languages.</p>
<p>Preferably with options as to style.</p>
|
<p>Try quoting the wildcard:</p>
<pre><code>$ find /usr -name \*.sh
</code></pre>
<p>or:</p>
<pre><code>$ find /usr -name '*.sh'
</code></pre>
<p>If you happen to have a file that matches <strong>*.sh</strong> in the current working directory, the wildcard will be expanded before find sees it. If you happen to have a file named tkConfig.sh in your working directory, the <strong>find</strong> command would expand to:</p>
<pre><code>$ find /usr -name tkConfig.sh
</code></pre>
<p>which would only find files named tkConfig.sh. If you had more than one file that matches <strong>*.sh</strong>, you'd get a syntax error from <strong>find</strong>:</p>
<pre><code>$ cd /usr/local/lib
$ find /usr -name *.sh
find: bad option tkConfig.sh
find: path-list predicate-list
</code></pre>
<p>Again, the reason is that the wildcard expands to both files:</p>
<pre><code>$ find /usr -name tclConfig.sh tkConfig.sh
</code></pre>
<p>Quoting the wildcard prevents it from being prematurely expanded.</p>
<p>Another possibility is that /usr or one of its subdirectories is a symlink. <strong>find</strong> doesn't normally follow links, so you might need the <strong>-follow</strong> option:</p>
<pre><code>$ find /usr -follow -name '*.sh'
</code></pre>
|
<p>For finding files on your disks, lean to use "locate" instead that is instantaneous
(looks into a daily built index)
you example would be:</p>
<pre><code>locate '/usr*.sh'
</code></pre>
| 3,937
|
<p>I'm looking for a general solution for upgrading database schema with ORM tools, like JPOX or Hibernate. How do you do it in your projects?</p>
<p>The first solution that comes to my mind is to create my own mechanism for upgrading databases, with SQL scripts doing all the work. But in this case I'll have to remember about creating new scripts every time the object mappings are updated. And I'll still have to deal with low-level SQL queries, instead of just defining mappings and allowing the ORM tools to do all the job...</p>
<p>So the question is how to do it properly. Maybe some tools allow for simplifying this task (for example, I heard that Rails have such mechanism built-in), if so please help me decide which ORM tool to choose for my next Java project.</p>
|
<p><a href="http://www.liquibase.org" rel="noreferrer">LiquiBase</a> is an interesting open source library for handling database refactorings (upgrades). I have not used it, but will definitely give it a try on my next project where I need to upgrade a db schema.</p>
|
<p>I think your best bet is to use an ORM-tool that includes database migration like <a href="http://subsonicproject.com/" rel="nofollow noreferrer">SubSonic</a>:</p>
<p><a href="http://subsonicproject.com/2-1-pakala/subsonic-using-migrations/" rel="nofollow noreferrer">http://subsonicproject.com/2-1-pakala/subsonic-using-migrations/</a></p>
| 8,964
|
<p>In our embedded system (using a PowerPC processor), we want to disable the processor cache. What steps do we need to take?</p>
<p>To clarify a bit, the application in question must have as constant a speed of execution as we can make it.
Variability in executing the same code path is not acceptable. This is the reason to turn off the cache.</p>
|
<p>I'm kind of late to the question, and also it's been a while since I did all the low-level processor init code on PPCs, but I seem to remember the cache & MMU being pretty tightly coupled (one had to be enabled to enable the other) and I <em>think</em> in the MMU page tables, you could define the cacheable attribute.</p>
<p>So my point is this: if there's a certain subset of code that must run in deterministic time, maybe you locate that code (via a linker command file) in a region of memory that is defined as non-cacheable in the page tables? That way all the code that can/should benefit from the cache does, and the (hopefully) subset of code that shouldn't, doesn't.</p>
<p>I'd handle it this way anyway, so that later, if you want to enable caching for part of the system, you just need to flip a few bits in the MMU page tables, instead of (re-)writing the init code to set up all the page tables & caching.</p>
|
<p>Perhaps you don't want to globally disable cache, you only want to disable it for a particular address range?</p>
<p>On some processors you can configure TLB (translation lookaside buffer) entries for address ranges such that each range could have caching enabled or disabled. This way you can disable caching for memory mapped I/O, and still leave caching on for the main block of RAM.</p>
<p>The only PowerPC I've done this on was a PowerPC 440EP (from IBM, then AMCC), so I don't know if all PowerPCs work the same way.</p>
| 9,899
|
<p>Has anyone actually shipped an Entity Framework project that does O/R mapping into conceptual classes that are quite different from the tables in the datastore?</p>
<p>I mean collapse junction (M:M) tables into other entities to form <strong>Conceptual</strong> classes that exist in the business domain but are organized as <strong>multiple tables</strong> in the datastore. All the examples that I see on the MSDN have little use of inheritance, collapsing junction tables into other entities, or collapsing lookup tables into entities.</p>
<p>I'd love to hear of or see examples of the below which support all the CRUD operations you would typically expect to do on a business object.:</p>
<ol>
<li><p>Vehicle table and a Color table. A Color can appear in many Vehicles (1:M). They form the conceptual class UsedCar which has the property Color. </p></li>
<li><p>Doctor, DoctorPatients, and Patients tables (form a many to many). Doctors have many Patients, Patients can have many Doctors (M:M). Map out the two conceptual classes Doctor (which has a Patients collection) and Patients (which has a Doctors collection).</p></li>
</ol>
<p><strong>Anyone seen/done this with CSDL AND SSDL in the Entity Framework? The CSDL is no good if it doesn't actaully map to anything!</strong></p>
|
<p>I attempted to use the Entity Framework on an existing project (~60 tables, 3 with inheritance) just to see what it was all about. My experience boiled down to:</p>
<p>The designer surface is kludgy. The mapping isn’t intuitive and someone must have thought that having several tool windows open at the same time is acceptable. It took a long time to manually create an object and map the right fields – then it was still odd talking to it from the code. While having something handling the database communication is essential, <em>I feel that handing the control over to EF was far more of a fight than doing it manually</em>.</p>
<p>Sometimes the designer just doesn’t load until you restart Visual Studio. I’m sure it’s just a bug but restarting VS is annoying.</p>
<p>All your work ends up in a single file, I’d hate to merge multiple developer editions.</p>
<p>The resultant SQL (watched via the Profiler) wasn’t very good. I didn’t really delve into looking why, but you’d be pressed to write something worse on a first attempt.</p>
|
<p>You mean like this?</p>
<pre><code><edmx:ConceptualModels>
<Schema xmlns="http://schemas.microsoft.com/ado/2006/04/edm" Namespace="Model1" Alias="Self">
<EntityContainer Name="Model1Container" >
<EntitySet Name="ColorSet" EntityType="Model1.Color" />
<EntitySet Name="DoctorSet" EntityType="Model1.Doctor" />
<EntitySet Name="PatientSet" EntityType="Model1.Patient" />
<EntitySet Name="UsedCarSet" EntityType="Model1.UsedCar" />
<AssociationSet Name="Vehicle_Color" Association="Model1.Vehicle_Color">
<End Role="Colors" EntitySet="ColorSet" />
<End Role="Vehicles" EntitySet="UsedCarSet" /></AssociationSet>
<AssociationSet Name="DoctorPatient" Association="Model1.DoctorPatient">
<End Role="Doctor" EntitySet="DoctorSet" />
<End Role="Patient" EntitySet="PatientSet" /></AssociationSet>
</EntityContainer>
<EntityType Name="Color">
<Key>
<PropertyRef Name="ColorID" /></Key>
<Property Name="ColorID" Type="Int32" Nullable="false" />
<NavigationProperty Name="Vehicles" Relationship="Model1.Vehicle_Color" FromRole="Colors" ToRole="Vehicles" /></EntityType>
<EntityType Name="Doctor">
<Key>
<PropertyRef Name="DoctorID" /></Key>
<Property Name="DoctorID" Type="Int32" Nullable="false" />
<NavigationProperty Name="Patients" Relationship="Model1.DoctorPatient" FromRole="Doctor" ToRole="Patient" /></EntityType>
<EntityType Name="Patient">
<Key>
<PropertyRef Name="PatientID" /></Key>
<Property Name="PatientID" Type="Int32" Nullable="false" />
<NavigationProperty Name="Doctors" Relationship="Model1.DoctorPatient" FromRole="Patient" ToRole="Doctor" />
</EntityType>
<EntityType Name="UsedCar">
<Key>
<PropertyRef Name="VehicleID" /></Key>
<Property Name="VehicleID" Type="Int32" Nullable="false" />
<NavigationProperty Name="Color" Relationship="Model1.Vehicle_Color" FromRole="Vehicles" ToRole="Colors" /></EntityType>
<Association Name="Vehicle_Color">
<End Type="Model1.Color" Role="Colors" Multiplicity="1" />
<End Type="Model1.UsedCar" Role="Vehicles" Multiplicity="*" /></Association>
<Association Name="DoctorPatient">
<End Type="Model1.Doctor" Role="Doctor" Multiplicity="*" />
<End Type="Model1.Patient" Role="Patient" Multiplicity="*" /></Association>
</Schema>
</edmx:ConceptualModels>
</code></pre>
| 8,207
|
<p>I have taken over the development of a web application that is targeted at the .net 1.0 framework and is written in C# and Visual Basic. </p>
<p>I decided that the first thing we need to do is refine the build process, I wrote build files for the C# projects, but am having tons of problems creating a build file for Visual Basic. </p>
<p>Admittedly, I do not personally know VB, but it seems like I have to hardcode all the imports and references in my build file to get anything to work...certainly not the best way to be doing things...</p>
<p>For any example: if I do not include the namespace System in the build file I will get several errors of common Unkown Types e.g: Guid</p>
<p>does NAnt typically require this for VB code or is does the VB code need a possible NAnt-freindly refactoring?</p>
<p>Does anybody have VB NAnt tips?</p>
|
<p>I have had a similar experience with NAnt and the vbc compiler for VB.NET projects that are developed with Visual Studio. My solution has been to avoid importing namespaces at the project level in Visual Studio (which occurs by default), and use explicit Imports statements at the class/file level. C# projects work this way by default (no project level namespace imports), and I like the extra information provided by explicit namespace directives when looking at a file.</p>
<p>Interesting that VB.NET and C# VS projects are so different in that respect.</p>
|
<p>I'm not sure, if you talk about VB or VB.Net.<br>
Either way, have a look at <a href="http://nantcontrib.sourceforge.net/release/latest/help/tasks/" rel="nofollow noreferrer">Nant Contrib</a>. Maybe they have a solution.</p>
| 3,476
|
<p>If I use restful_authentication in my ruby on rails app are passwords transfered between the broswer and the server in paintext? And if so how worried should I be about it?</p>
|
<p>Well, you need to be worried if you are not hosting it over HTTPS... because if it is straight HTTP, then yes it is being passed in plaintext.</p>
<p>I don't know Rails specifically, but I'm pretty sure it has nothing to do with whether you host it via HTTP or HTTPS.</p>
<p>Edit: I found <a href="http://blog.caboo.se/articles/2007/4/21/sample-rails-app-branch-with-ssl" rel="nofollow noreferrer">this link</a> which apparently provides an example Rails app over HTTPS.</p>
<p>Further Edit: Here is <a href="http://weeatbricks.com/2007/10/31/how-to-use-a-rails-app-with-https/" rel="nofollow noreferrer">another link</a> discussing HTTPS with Rails.</p>
|
<p>Authentication with plain text can be done with CHAP style protocols. Is that possible over HTTP?</p>
<p>I'm asking, because I think that it would need some state on the server to foil replay-attacks - state on the server is something to be eliminated with RESTful architectures, right?</p>
| 7,700
|
<p>Is there a good way to see what format an image is, without having to read the entire file into memory? </p>
<p>Obviously this would vary from format to format (I'm particularly interested in TIFF files) but what sort of procedure would be useful to determine what kind of image format a file is without having to read through the entire file?</p>
<p><strong>BONUS</strong>: What if the image is a Base64-encoded string? Any reliable way to infer it before decoding it?</p>
|
<p>Most image file formats have unique bytes at the start. The unix <code>file</code> command looks at the start of the file to see what type of data it contains. See the Wikipedia article on <a href="http://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files" rel="noreferrer">Magic numbers in files</a> and <a href="http://magicdb.org/" rel="noreferrer">magicdb.org</a>.</p>
|
<p>TIFFs will begin with either II or MM (Intel byte ordering or Motorolla).<br>
The TIFF 6 specification can be downloaded <a href="http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf" rel="nofollow noreferrer">here</a> and isn't too hard to follow</p>
| 7,604
|
<p>I'm trying to test a simple WebForms (asp.net) based UI, and follow the MVP pattern to allow my UI to be more testable. </p>
<p>As I follow the TDD methodology for backend algorithms, I find that there are some unit test refactorings that happen in the spirit of the DRY principle (Don't Repeat Yourself). As I try to apply this to the UI using Rhino Mocks to verify my interactions, I see many commonalities in the Controller tests when setting up the view or model expectations.</p>
<p>My question is: how far do you typically take this refactoring, if at all? I'm curious to see how other TDDer's test their MVC/MVP based UIs.</p>
|
<p>I would not refactor tests like standard code. Tests start to become more obscure as you refactor things into common base classes, helper methods, etc. Tests should be sufficiently clear on their own. </p>
<p>DRY is not a test concern.</p>
<p>That said, there are many plumbing things that are commonly done, and those should be abstracted away. </p>
|
<p>I use MVP, and on my tests I try to apply most of the refactoring I would in standard code. It normally doesn't work quite as well on the tests, due to the slight variations needed to test different scenarios, but within parts there can be commonality, and when possible I do consolidate. This does ease the needed changes later as the project evolves; just like in your standard code it is easier to change one place instead of 20.</p>
| 8,463
|
<p>I'm about to start a project that will record and edit audio files, and I'm looking for a good library (preferably Ruby, but will consider anything other than Java or .NET) for on-the-fly visualization of waveforms.</p>
<p>Does anybody know where I should start my search?</p>
|
<p>That's a lot of data to be streaming into a browser. Flash or Flex charts is probably the only solution that will be memory efficient. Javascript charting tends to break-down for large data sets. </p>
|
<p>The other option is generating the waveforms on the server-side with GD or RMagick. But good luck getting RubyGD to compile.</p>
| 6,247
|
<p>If I want to send mail not via SMTP, but rather via sendmail, is there a library for python that encapsulates this process?</p>
<p>Better yet, is there a good library that abstracts the whole 'sendmail -versus- smtp' choice?</p>
<p>I'll be running this script on a bunch of unix hosts, only some of which are listening on localhost:25; a few of these are part of embedded systems and can't be set up to accept SMTP.</p>
<p>As part of Good Practice, I'd really like to have the library take care of header injection vulnerabilities itself -- so just dumping a string to <code>popen('/usr/bin/sendmail', 'w')</code> is a little closer to the metal than I'd like.</p>
<p>If the answer is 'go write a library,' so be it ;-)</p>
|
<p>Header injection isn't a factor in how you send the mail, it's a factor in how you construct the mail. Check the <a href="https://docs.python.org/2/library/email.html" rel="noreferrer">email</a> package, construct the mail with that, serialise it, and send it to <code>/usr/sbin/sendmail</code> using the <a href="https://docs.python.org/2/library/subprocess.html" rel="noreferrer">subprocess</a> module:</p>
<pre><code>import sys
from email.mime.text import MIMEText
from subprocess import Popen, PIPE
msg = MIMEText("Here is the body of my message")
msg["From"] = "me@example.com"
msg["To"] = "you@example.com"
msg["Subject"] = "This is the subject."
p = Popen(["/usr/sbin/sendmail", "-t", "-oi"], stdin=PIPE)
# Both Python 2.X and 3.X
p.communicate(msg.as_bytes() if sys.version_info >= (3,0) else msg.as_string())
# Python 2.X
p.communicate(msg.as_string())
# Python 3.X
p.communicate(msg.as_bytes())
</code></pre>
|
<p>The easiest answer is the smtplib, you can find docs on it <a href="http://docs.python.org/lib/SMTP-example.html" rel="nofollow noreferrer">here</a>. </p>
<p>All you need to do is configure your local sendmail to accept connection from localhost, which it probably already does by default. Sure, you're still using SMTP for the transfer, but it's the local sendmail, which is basically the same as using the commandline tool. </p>
| 9,948
|
<p>With this code I can show an animated gif while the server script is running:</p>
<pre><code>function calculateTotals() {
$('#results').load('getResults.php', null, showStatusFinished);
showLoadStatus();
}
function showLoadStatus() {
$('#status').html('');
}
function showStatusFinished() {
$('#status').html('Finished.');
}
</code></pre>
<p>However, I would like to display a status of how far along the script is, e.g. "Processing line 342 of 20000..." and have it count up until it is finished.</p>
<p>How can I do that? I can make a server-script which constantly contains the updated information but where do I put the command to read this, say, every second?</p>
|
<p>After reading your comments to Andrew's answer.</p>
<p>You would read the status like this:</p>
<pre><code>function getStatus() {
$.getJSON("/status.php",{"session":0, "requestID":12345},
function(data) { //data is the returned JSON object from the server {name:"value"}
setStatus(data.status);
window.setTimeout("getStatus()",intervalInMS)
});
}
</code></pre>
<p>Using this method you can open several simultaneous XHR request on the server.</p>
<p>all your status.php as to output is :</p>
<pre><code>{"status":"We are done row 1040/45983459"}
</code></pre>
<p>You can however output as many information you want in the response and to process it accordingly (feeding a progress bar for example or performing an animation..)</p>
<p>For more information on $.getJSON see <a href="http://docs.jquery.com/Ajax/jQuery.getJSON" rel="nofollow noreferrer">http://docs.jquery.com/Ajax/jQuery.getJSON</a></p>
|
<p>Your server-side script should somehow keep its progress somewhere on server (file, field in database, memcached, etc.). </p>
<p>You should have AJAX function returning current progress. Poll this function once a second and render result accordingly. </p>
| 9,712
|
<p>I have an object that is mapped to a cookie as a serialized base-64 string. I only want to write out a new cookie if there are changes made to the object stored in the cookie on server-side.</p>
<p>What I want to do is get a hash code when the object is pulled from the cookie/initialized and compare the original hash code to the hash code that exists just before I send the cookie header off to the client to ensure I don't have to re-serialize/send the cookie unless changes were made.</p>
<p>I was going to override the .NET's <code>Object.GetHashCode()</code> method, but I wasn't sure that this is the best way to go about checking if an object is modified.</p>
<p>Are there any other ways I can check if an object is modified, or should I override the <code>GetHashCode()</code> method.</p>
<p><strong>Update</strong> I decided to accept @rmbarnes's answer as it had an interesting solution to the problem, and because I decided to use his advice at the end of his post and not check for modification. I'd still be interested to hear any other solutions anyone may have to my scenario however.</p>
|
<p>GetHashCode() should always be in sync with Equals(), and Equals() isn't necessarily guaranteed to check for <em>all</em> of the fields in your object (there's certain situations where you want that to not be the case).</p>
<p>Furthermore, GetHashCode() isn't guaranteed to return unique values for all possible object states. It's conceivable (though unlikely) that two object states could result in the same HashCode (which does, after all, only have an int's worth of possible states; see <a href="http://en.wikipedia.org/wiki/Pigeonhole_principle" rel="nofollow noreferrer">the Pigeonhole Principle</a> for more details).</p>
<p>If you can ensure that Equals() checks all of the appropriate fields, then you could possibly clone the object to record its state and then check it with Equals() against the new state to see if its changed.</p>
<p>BTW: Your mention of serialization gave me an idea. You could serialize the object, record it, and then when you check for object changing, repeat the process and compare the serialized values. That would let you check for state changes without having to make any code changes to your object. However, this isn't a great solution, because:</p>
<ol>
<li>It's probably very inefficient</li>
<li>It's prone to serialization changes in the object; you might get false positives on the object state change.</li>
</ol>
|
<p>I personally would say go with the plan you have.. A good hash code is the best way to see if an object is "as-is".. Theres tons of hashing algorithms you can look at, check out the obvious <a href="http://en.wikipedia.org/wiki/Hash_function" rel="nofollow noreferrer">Wikipedia page</a> on hash functions and go from there..</p>
<p>Override GetHashCode and go for it! Just make sure <em>ALL</em> the elements of the information make up part of the hash :)</p>
| 5,519
|
<p>In the company that i work, we develop all the GUI in C#, but the application kernel is mainly developed in Delphi 5 (for historical reasons), with a lot of components made in COM+. Related to this very specific sort of application a I two questions:</p>
<ul>
<li><p>Experienced guys in Delphi and/or COM, do you have any workrounds to work with the buggy TLB interface ?
Some of the bugs are: IDE crashing during edition of a large TLB, lost of methods IDs, TLB corruption, etc.
Here, we haven't found any good solution. Actually we tried do upgrade do the new 2007 version. But the new IDE TLB interface has the same bugs that we found before.</p></li>
<li><p>How do you control TLBs versions ? The TLB file is in a binary format and conflict resolutions are very hard to do. We tried to do it exporting the interfaces descriptions to IDL and commiting into CVS, but we didn't found any good way to generate TLBs from IDL using Delphi. Additionaly, the MIDL tool provided by Microsoft, didn't parse correctly the IDL files that we exported from delphi.</p></li>
</ul>
|
<p>I think you should have a good look at Delphi 2009.</p>
<p>Delphi 2009 has changes to the COM support, including a text-based replacement for the binary TLB files.</p>
<p>You can read more on <a href="http://chrisbensen.blogspot.com/2008/07/tiburn-sneak-peek-com_23.html" rel="nofollow noreferrer">Chris Bensen's blog</a>.</p>
|
<p>Same experience with the TLB interface here: we simply stopped using it.</p>
<p>We work with several separate IDL files (hand-build) for different parts of our framework, making use of the #include construct to include them into the IDL of the actual application, then generate the single tlb using MIDL and tlibimp it. If the application has no IDL of it's own, pre-compiled version of the different framework TLB files are available.</p>
<p>Whenever the framework enters a new version, a script is run to re-generate the GUIDS on all necessary interfaces in the IDL files. </p>
<p>This has served us well for many years, and for us to move over the new Delphi 2009 IDL/TLB toolset will have to be not only integrated into the IDE, but also versatile when it comes to automated builds and whatnot. Can't wait to get my hands dirty with some experiments!</p>
| 3,759
|
<p>Are there any rapid Database protoyping tools that don't require me to declare a database schema, but rather create it based on the way I'm using my entities.</p>
<p>For example, assuming an empty database (pseudo code):</p>
<pre><code>user1 = new User() // Creates the user table with a single id column
user1.firstName = "Allain" // alters the table to have a firstName column as varchar(255)
user2 = new User() // Reuses the table
user2.firstName = "Bob"
user2.lastName = "Loblaw" // Alters the table to have a last name column
</code></pre>
<p>Since there are logical assumptions that can be made when dynamically creating the schema, and you could always override its choices by using your DB tools to tweak it later.</p>
<p>Also, you could generate your schema by unit testing it this way.</p>
<p>And obviously this is only for prototyping.</p>
<p>Is there anything like this out there?</p>
|
<p><a href="http://code.google.com/appengine/" rel="nofollow noreferrer">Google's Application Engine</a> works like this. When you download the toolkit you get a local copy of the database engine for testing.</p>
|
<p>May be not exactly responding to your <em>general</em> question, but if you used <a href="http://www.hibernate.org" rel="nofollow noreferrer">(N)Hibernate</a> then you can automatically generate the database schema from your hbm mapping files.</p>
<p>Its not done directly from your code as you seem to be wanting but Hibernate Schema generation seems to work well for us </p>
| 5,215
|
<p>I want to create an allocator which provides memory with the following attributes:</p>
<ul>
<li>cannot be paged to disk. </li>
<li>is incredibly hard to access through an attached debugger</li>
</ul>
<p>The idea is that this will contain sensitive information (like licence information) which should be inaccessible to the user. I have done the usual research online and asked a few other people about this, but I cannot find a good place start on this problem.</p>
<p><strong>Updates</strong></p>
<p><a href="https://stackoverflow.com/questions/8451/secure-memory-allocator-in-c#27194">Josh</a> mentions using <code>VirtualAlloc</code> to set protection on the memory space. I have created a custom allocator ( shown below ) I have found the using the <code>VirtualLock</code> function it limits the amount of memory I can allocate. This seems to be by design though. Since I am using it for small objects this is not a problem.</p>
<pre><code>//
template<class _Ty>
class LockedVirtualMemAllocator : public std::allocator<_Ty>
{
public:
template<class _Other>
LockedVirtualMemAllocator<_Ty>& operator=(const LockedVirtualMemAllocator<_Other>&)
{ // assign from a related LockedVirtualMemAllocator (do nothing)
return (*this);
}
template<class Other>
struct rebind {
typedef LockedVirtualMemAllocator<Other> other;
};
pointer allocate( size_type _n )
{
SIZE_T allocLen = (_n * sizeof(_Ty));
DWORD allocType = MEM_COMMIT;
DWORD allocProtect = PAGE_READWRITE;
LPVOID pMem = ::VirtualAlloc( NULL, allocLen, allocType, allocProtect );
if ( pMem != NULL ) {
::VirtualLock( pMem, allocLen );
}
return reinterpret_cast<pointer>( pMem );
}
pointer allocate( size_type _n, const void* )
{
return allocate( _n );
}
void deallocate(void* _pPtr, size_type _n )
{
if ( _pPtr != NULL ) {
SIZE_T allocLen = (_n * sizeof(_Ty));
::SecureZeroMemory( _pPtr, allocLen );
::VirtualUnlock( _pPtr, allocLen );
::VirtualFree( _pPtr, 0, MEM_RELEASE );
}
}
};
</code></pre>
<p>and is used</p>
<pre><code> //a memory safe std::string
typedef std::basic_string<char, std::char_traits<char>,
LockedVirtualMemAllocato<char> > modulestring_t;
</code></pre>
<p><a href="https://stackoverflow.com/questions/8451/secure-memory-allocator-in-c#38708">Ted Percival</a> mentions mlock, but I have no implementation of that yet.</p>
<p>I found <a href="http://www.schneier.com/book-practical.html" rel="noreferrer">Practical Cryptography by Neil Furguson and Bruce Schneier</a> quite helpful as well.</p>
|
<p>You can't really protect against memory access. You can probably prevent paging if you are running as an admin or as the system, but you cannot prevent the admin or system from reading your memory. Even if you could somehow completely block other processes from reading your memory (which you can't), another process could still actually inject a new thread into your process and read the memory that way.</p>
<p>Even if you could somehow completely lock down your process and guarantee that the OS would <em>never</em> allow anyone else to access your process, you still don't have full protection. The entire OS could be running in a virtual machine, which could be paused and inspected at any time.</p>
<p>You <em>cannot</em> protect memory contents from the owner of the system. Hollywood and the music industry have been aching for this for years. If it were possible, they'd already be doing it.</p>
|
<p>@Derek: Oh, but with trusted computing, you can use <a href="http://en.wikipedia.org/wiki/Trusted_Computing#Memory_curtaining" rel="nofollow noreferrer">memory curtaining</a>! :-P</devils-advocate></p>
| 2,989
|
<p>Back in the old days, Help was not trivial but possible: generate some funky .rtf file with special tags, run it through a compiler, and you got a WinHelp file (.hlp) that actually works really well.</p>
<p>Then, Microsoft decided that WinHelp was not hip and cool anymore and switched to CHM, up to the point they actually axed WinHelp from Vista.</p>
<p>Now, CHM maybe nice, but everyone that tried to open a .chm file on the Network will know the nice "Navigation to the webpage was canceled" screen that is caused by security restrictions.</p>
<p>While there are ways to make CHM work off the network, this is hardly a good choice, because when a user presses the Help Button he wants help and not have to make some funky settings.</p>
<p>Bottom Line: I find CHM absolutely unusable. But with WinHelp not being an option anymore either, I wonder what the alternatives are, especially when it comes to integrate with my Application (i.e. for WinHelp and CHM there are functions that allow you to directly jump to a topic)?</p>
<p>PDF has the disadvantage of requiring the Adobe Reader (or one of the more lightweight ones that not many people use). I could live with that seeing as this is kind of standard nowadays, but can you tell it reliably to jump to a given page/anchor?</p>
<p>HTML files seem to be the best choice, you then just have to deal with different browsers (CSS and stuff).</p>
<p><em>Edit:</em> I am looking to create my own Help Files. As I am a fan of the "No Setup, Just Extract and Run" Philosophy, i had that problem many times in the past because many of my users will run it off the network, which causes exactly this problem.</p>
<p>So i am looking for a more robust and future-proof way to provide help to my users without having to code a different help system for each application i make.</p>
<p>CHM is a really nice format, but that Security Stuff makes it unusable, as a Help system is supposed to provide help to the user, not to generate even more problems.</p>
|
<p>HTML would be the next best choice, ONLY IF you would serve them from a public web server. If you tried to bundle it with your app, all the files (and images (and stylesheets (and ...) ) ) would make CHM look like a gift from gods.</p>
<p>That said, when actually bundled in the installation package, (instead of being served over the network), I found the CHM files to work nicely.</p>
<p>OTOH, another pitfall about CHM files: Even if you try to open a CHM file on a <strong>local</strong> disk, you may bump into the security block if you initially downloaded it from somewhere, because the file could be marked as "came from external source" when it was obtained.</p>
|
<p>I use a commercial package called AuthorIT that can generate a number of different formats, such as chm, html, pdf, word, windows help, xml, xhtml, and some others I have never heard of (does dita ring a bell?).
It is a content management system oriented towards the needs of technical documentation writers.
The advantage is that you can use and re-use the same content to build a set of guides, and then generate them in different formats.</p>
<p>So the bottom line relative to the question of choosing chm or html or whatever is that if you are using this you are not locked into a given format, but you can provide several among which the user can choose, and you can even add more formats as you go along, at no extra cost.</p>
<p>If you just have one guide to create it won't be worth your while, but if you have a documentation set to manage then it is the best to my knowledge. Their support is very helpful also.</p>
| 2,355
|
<p>I had a plugin installed in Visual Studio 2008, and it created some extra dockable windows. I have uninstalled it, and I can't get rid of the windows it created - I close them, but they always come back. They're just empty windows now, since the plugin is no longer present, but nothing I've tried gets rid of them. I've tried:</p>
<ul>
<li>Window -> Reset Window Layout</li>
<li>Deleting the .suo files in my project directories</li>
<li>Deleting the Visual Studio 9.0 folder in my Application Settings directory</li>
</ul>
<p>Any ideas?</p>
|
<p>Have you tried this? In Visual Studio go to <strong>Tools</strong> > <strong>Import and Export Settings</strong> > <strong>Reset all settings</strong></p>
<p>Be sure you <strong>back up</strong> your settings before you do this. I made the mistake of trying this to fix an issue and didn't realize it would undo all my appearance settings and toolbars as well. Took a lot of time to get back to the way I like things.</p>
|
<p><code>Window -> Reset Window Layout</code> didn't exist for me. For anybody looking in 2022 or later, I finally found the answer! The crucial information, buried in a VSCode update release note, was right at the bottom of <a href="https://code.visualstudio.com/updates/v1_64#_workbench" rel="nofollow noreferrer">this section</a>. Here it is if the link breaks in the future:</p>
<blockquote>
<p>If you'd like to reset all views back to the default layout, you can run <code>Views: Reset View Locations</code> from the Command Palette.</p>
</blockquote>
| 4,652
|
<p>for example this code</p>
<pre><code>var html = "<p>This text is <a href=#> good</a></p>";
var newNode = Builder.node('div',{className: 'test'},[html]);
$('placeholder').update(newNode);
</code></pre>
<p>casues the p and a tags to be shown, how do I prevent them from being escaped?</p>
|
<p>The last parameter to Builder.node is "Array, List of other nodes to be appended as children" according to the <a href="http://github.com/madrobby/scriptaculous/wikis/builder" rel="nofollow noreferrer">Wiki</a>. So when you pass it a string it is treated like text.</p>
<p>You could use:</p>
<pre><code>var a = Builder.node('div').update("<a href='#'>foo</a>")
</code></pre>
<p>Where the link is text or:</p>
<pre><code>var a = Builder.node('div', {'class':'cool'},
[Builder.node('div', {'class': 'another_div'})]
);
</code></pre>
<p>And you could use just Prototypes <a href="http://www.prototypejs.org/api/element" rel="nofollow noreferrer">new Element()</a> (Available as of version 1.6).</p>
<pre><code>var a = new Element('div').insert(
new Element('div', {'class': 'inner_div'}).update("Text in the inner div")
);
</code></pre>
|
<p>You can use this solution: <a href="http://sviudes.blogspot.com/2009/08/como-usar-etiquetas-html-con.html" rel="nofollow noreferrer">http://sviudes.blogspot.com/2009/08/como-usar-etiquetas-html-con.html</a></p>
| 9,679
|
<p>I have over a million text files compressed into 40 zip files. I also have a list of about 500 model names of phones. I want to find out the number of times a particular model was mentioned in the text files. </p>
<p>Is there any python module which can do a regex match on the files without unzipping it. Is there a simple way to solve this problem without unzipping?</p>
|
<p>There's nothing that will automatically do what you want.</p>
<p>However, there is a python zipfile module that will make this easy to do. Here's how to iterate over the lines in the file.</p>
<pre><code>#!/usr/bin/python
import zipfile
f = zipfile.ZipFile('myfile.zip')
for subfile in f.namelist():
print subfile
data = f.read(subfile)
for line in data.split('\n'):
print line
</code></pre>
|
<p>You could loop through the zip files, reading individual files using the zipfile module and running your regex on those, eliminating to unzip all the files at once. </p>
<p>I'm fairly certain that you can't run a regex over the zipped data, at least not meaningfully.</p>
| 3,505
|
<p>I've been trying to get pretty charts to work in GWT on our internal network.</p>
<p>Playing around with <a href="http://gwt-ext.com" rel="noreferrer">GWT-Ext</a>'s charts is nice, but it requires flash and is really messy to control (it seems buggy, in general). </p>
<p>I'd like to hear about something that works with the least amount of dependencies and it also must work without a connection to the web (so, Google' charts API isn't a solution).</p>
<p><strong>Edit:</strong> Indeed, I would rather a library that is all client-side.</p>
|
<p>Googling for "GWT +sparklines" has gotten me to <a href="http://code.google.com/p/gchart/" rel="noreferrer">gchart</a>, which seems like what I need.<br>
From what I understand - it's all client side and requires nothing more than their JAR file.</p>
|
<p>Do you want something that has a server side component or entirely client driven? The best ones I have seen are all flash, alas. I have done little tricks with JS and GWT before, but there is only sophisticated I will get before I go hunting for a library to do it for me.</p>
| 2,722
|
<p>In my C# program, I have a thread that represents a running test, which can be aborted by a click on a button labeled "Interrupt execution". In order for the thread (and therefore the test) to terminate in an elegant manner (and do some vital work beforehand), this button is enabled only in some well-defined moments, in which I catch <code>ThreadAbortedException</code>, do <code>Thread.ResetAbort()</code> and die beautifully (that is, the thread).</p>
<p>The problem is that, in the time window in which aborting is possible, there are some tasks that need to be done from start to finish once initiated, and, so, I fear TAE. Locks don't provide a solution for this, and, although finally blocks do, I don't find it elegant to wrap important code in the following manner:</p>
<pre><code>try {
} finally {
// vital code
}
</code></pre>
<p>However, I didn't find any other solution.</p>
<p>Is this another way to delay the interference of <code>ThreadAbortException</code> until the end of the block?</p>
|
<p>The situations under which a ThreadAbortException will be generated can be complex. A better option might be to ask why you are using ThreadAbortExceptions at all.</p>
<p>A better pattern would be to simply use a flag to indicate to the running thread that it should abort, and then test the flag regularly while it is working. If it is set you can throw an exception at that point if you want.</p>
<p>With this pattern you are totally in control of when the thread will act on the abort, and don't have to worry about the critical operations being interrupted.</p>
|
<p>Use <a href="http://msdn.microsoft.com/en-us/library/system.threading.thread.begincriticalregion.aspx" rel="nofollow noreferrer">Thread.BeginCriticalRegion()</a> </p>
<blockquote>
<p>Notifies a host that execution is about to enter a region of code in which the effects of a thread abort or unhandled exception might jeopardize other tasks in the application domain. </p>
</blockquote>
<pre><code>Thread.BeginCriticalRegion()
//do important stuff here
Thread.EndCriticalRegion()
</code></pre>
| 6,932
|
<p>We have a couple of mirrored SQL Server databases.</p>
<p>My first problem - the key problem - is to get a notification when the db fails over. I don't <em>need</em> to know because, erm, its mirrored and so it (almost) all carries on working automagically but it would useful to be advised and I'm currently getting failovers when I don't think I should be so it want to know when they occur (without too much digging) to see if I can determine why.</p>
<p>I have services running that I could fairly easily use to monitor this - so the alternative question would be "How do I programmatically determine which is the principal and which is the mirror" - preferably in a more intelligent fashion than just attempting to connect each in turn (which would mostly work but...).</p>
<p>Thanks, Murph</p>
<p>Addendum: </p>
<p>One of the answers queries why I don't need to know when it fails over - the answer is that we're developing using ADO.NET and that has automatic failover support, all you have to do is add <code>Failover Partner=MIRRORSERVER</code> (where MIRRORSERVER is the name of your mirror server instance) to your connection string and your code will fail over transparently - you may get some errors depending on what connections are active but in our case very few.</p>
|
<p>Right, </p>
<p>The two answers and a little thought got me to something approaching an answer.</p>
<p>First a little more clarification:</p>
<p>The app is written in C# (2.0+) and uses ADO.NET to talk to SQL Server 2005.
The mirror setup is two W2k3 servers hosting the Principal and the Mirror plus a third server hosting an express instance as a monitor. The nice thing about this is a failover is all but transparent to the app using the database, it will throw an error for some connections but fundamentally everything will carry on nicely. Yes we're getting the odd false positive but the whole point is to have the system carry on working with the least amount of fuss and mirror <em>does</em> deliver this very nicely.</p>
<p>Further, the issue is not with serious server failure - that's usually a bit more obvious but with a failover for other reasons (c.f. the false positives above) as we do have a couple of things that can't, for various reasons, fail over and in any case so we can see if we can identify the circumstance where we get false positives.</p>
<p>So, given the above, simply checking the status of the boxes is not quite enough and chasing through the event log is probably overly complex - the answer is, as it turns out, fairly simple: sp_helpserver</p>
<p>The first column returned by sp_helpserver is the server name. If you run the request at regular intervals saving the <em>previous</em> server name and doing a comparison each time you'll be able to identify when a change has taken place and then take the appropriate action.</p>
<p>The following is a console app that demonstrates the principal - although it needs some work (e.g. the connection ought to be non-pooled and new each time) but its enough for now (so I'd then accept this as "the" answer"). Parameters are Principal, Mirror, Database</p>
<pre><code>using System;
using System.Data.SqlClient;
namespace FailoverMonitorConcept
{
class Program
{
static void Main(string[] args)
{
string server = args[0];
string failover = args[1];
string database = args[2];
string connStr = string.Format("Integrated Security=SSPI;Persist Security Info=True;Data Source={0};Failover Partner={1};Packet Size=4096;Initial Catalog={2}", server, failover, database);
string sql = "EXEC sp_helpserver";
SqlConnection dc = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand(sql, dc);
Console.WriteLine("Connection string: " + connStr);
Console.WriteLine("Press any key to test, press q to quit");
string priorServerName = "";
char key = ' ';
while(key.ToString().ToLower() != "q")
{
dc.Open();
try
{
string serverName = cmd.ExecuteScalar() as string;
Console.WriteLine(DateTime.Now.ToLongTimeString() + " - Server name: " + serverName);
if (priorServerName == "")
{
priorServerName = serverName;
}
else if (priorServerName != serverName)
{
Console.WriteLine("***** SERVER CHANGED *****");
Console.WriteLine("New server: " + serverName);
priorServerName = serverName;
}
}
catch (System.Data.SqlClient.SqlException ex)
{
Console.WriteLine("Error: " + ex.ToString());
}
finally
{
dc.Close();
}
key = Console.ReadKey(true).KeyChar;
}
Console.WriteLine("Finis!");
}
}
}
</code></pre>
<p>I wouldn't have arrived here without a) asking the question and then b) getting the responses which made me actually <strong>think</strong></p>
<p>Murph</p>
|
<p>If the failover logic is in your application you could write a status screen that shows which box you're connected by writing to a var when the first connection attempt fails.</p>
<p>I think your best bet would be a ping daemon/cron job that checks the status of each box periodically and sends an email if one doesn't respond. </p>
| 4,800
|
<p>The problem I'm trying to solve is "What's at this position?"</p>
<p>It's fairly trivial to get the x/y position (offset) of a DIV, but what about the reverse? How do I get the id of a DIV (or any element) given an x/y position?</p>
|
<p>Use a JQuery selector to filter the list of all DIVs for one that matches your position criteria?</p>
|
<p>this might be a little too processor intensive but going over the whole list of div elements on a page, finding their positions and sizes then testing if they're under the mouse. i don't think i'd want to do that to a browser though.</p>
| 7,142
|
<p>I'm going to start a new project - rewriting an existing system (PHP + SQL Server) from scratch because of some very serious limitations by design.</p>
<p>We have some quite good knowledge of SQL Server (currently we're using SQL Server 2000 in existing system) and we would like to employ its newer version (2008 I guess) in our new project.</p>
<p>I am really fond of technologies that Java offers - particularly Spring Framework and Wicket and I am quite familiar with Java from others projects and assignments before.
Therefore, we consider using Java and Microsoft SQL Server.</p>
<p>There are two JDBC drivers for SQL Server - jTDS and Microsoft's one - <a href="http://msdn.microsoft.com/en-us/data/aa937724.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/data/aa937724.aspx</a>. I think we should test both of them.<br/></p>
<p>Are there any limitations in such solution I should know of? Has someone experience with such a technology combination?</p>
|
<p>I've worked on a project using MSQL Server in conjunction with a Java Stack. It works very well and as long, since JDBC shouldn't really care about your database. We used ehcache together with Hibernate and had problems with the MS JDBC Driver, so we switched to jtds and it works really good.</p>
<p>It's quite a while ago, so you still might wanna give the MS driver a chance...</p>
|
<p>The JDBC driver works well with SQL Server 2008, I've not had any problems with it. The version that you need to download depends on the version of the JRE you have installed. JRE6 uses JDBC4, JRE7 uses JDBC4.1, etc. Once you download the correct driver from Microsoft and run the installer you will need to copy the
<strong>sqljdbc_auth.dll</strong> from the <strong>\auth</strong> directory to the <strong>c:\windows\system32</strong> directory. Then can then use this code to make a connection:</p>
<p>In your header:</p>
<pre><code>import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
</code></pre>
<p>and in your class:</p>
<pre><code>public class connectToSQL {
public void connectToDB() throws Exception {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://<IPADDRESS>:<PORT>;DatabaseName=<NAME OF DATABASE TO CONNECT TO>;IntegratedSecurity=false";
Connection con = DriverManager.getConnection(connectionUrl, "<SQL SERVER USER LOGIN>", "<SQL SERVER PASSWORD>");
Statement s = con.createStatement();
ResultSet r = s.executeQuery("SELECT * FROM <TABLENAME TO SELECT FROM>");
while (r.next()) {
System.out.println(r.getString(1));
}
}
}
</code></pre>
| 2,847
|
<p>How can I construct a MSBuild ItemGroup to exclude .svn directories and all files within (recursively). I've got:</p>
<pre><code><ItemGroup>
<LibraryFiles Include="$(LibrariesReleaseDir)\**\*.*" Exclude=".svn" />
</ItemGroup>
</code></pre>
<p>At the moment, but this does not exclude anything!</p>
|
<p>Thanks for your help, managed to sort it as follows:</p>
<pre><code><ItemGroup>
<LibraryFiles Include="$(LibrariesReleaseDir)\**\*.*"
Exclude="$(LibrariesReleaseDir)\**\.svn\**" />
</ItemGroup>
</code></pre>
<p>Turns out the pattern matching basically runs on files, so you have to exclude everything BELOW the <code>.svn</code> directories (<code>.svn\\**</code>) for MSBuild to exclude the <code>.svn</code> directory itself.</p>
|
<p>I've run into some glitches using the Include/Exclude approach, so here's something that's worked for me instead:
</p>
<pre><code><ItemGroup>
<MyFiles Include=".\PathToYourStuff\**" />
<MyFiles Remove=".\PathToYourStuff\**\.svn\**" />
</ItemGroup>
</code></pre>
| 9,775
|
<p>Using the obsolete System.Web.Mail sending email works fine, here's the code snippet:</p>
<pre><code> Public Shared Sub send(ByVal recipent As String, ByVal from As String, ByVal subject As String, ByVal body As String)
Try
Dim Message As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
Message.To = recipent
Message.From = from
Message.Subject = subject
Message.Body = body
Message.BodyFormat = MailFormat.Html
Try
SmtpMail.SmtpServer = MAIL_SERVER
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
critical_error("Email sending failed, reason: " + ehttp.ToString)
End Try
Catch e As System.Exception
critical_error(e, "send() in Util_Email")
End Try
End Sub
</code></pre>
<p>and here's the updated version:</p>
<pre><code>Dim mailMessage As New System.Net.Mail.MailMessage()
mailMessage.From = New System.Net.Mail.MailAddress(from)
mailMessage.To.Add(New System.Net.Mail.MailAddress(recipent))
mailMessage.Subject = subject
mailMessage.Body = body
mailMessage.IsBodyHtml = True
mailMessage.Priority = System.Net.Mail.MailPriority.Normal
Try
Dim smtp As New Net.Mail.SmtpClient(MAIL_SERVER)
smtp.Send(mailMessage)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
</code></pre>
<p>I have tried many different variations and nothing seems to work, I have a feeling it may have to do with the SmtpClient, is there something that changed in the underlying code between these versions?</p>
<p>There are no exceptions that are thrown back.</p>
|
<p>I've tested your code and my mail is sent successfully. Assuming that you're using the same parameters for the old code, I would suggest that your mail server (MAIL_SERVER) is accepting the message and there's a delay in processing or it considers it spam and discards it.</p>
<p>I would suggest sending a message using a third way (telnet if you're feeling brave) and see if that is successful.</p>
<p>EDIT: I note (from your subsequent answer) that specifying the port has helped somewhat. You've not said if you're using port 25 (SMTP) or port 587 (Submission) or something else. If you're not doing it already, using the sumission port may also help solve your problem.</p>
<p><a href="http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol" rel="nofollow noreferrer">Wikipedia</a> and <a href="https://www.rfc-editor.org/rfc/rfc4409" rel="nofollow noreferrer">rfc4409</a> have more details.</p>
|
<p>Have you tried adding </p>
<pre><code>smtp.UseDefaultCredentials = True
</code></pre>
<p>before the send?</p>
<p>Also, what happens if you try changing:</p>
<pre><code>mailMessage.From = New System.Net.Mail.MailAddress(from)
mailMessage.To.Add(New System.Net.Mail.MailAddress(recipent))
</code></pre>
<p>to this:</p>
<pre><code>mailMessage.From = New System.Net.Mail.MailAddress(from,recipent)
</code></pre>
<p>-- Kevin Fairchild</p>
| 7,556
|
<p>I'm trying to open a new browser tab with the results of a POST request. I'm trying to do so using a function containing the following code:</p>
<pre><code>var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interface
s.nsIWindowMediator);
var browserWindow = windowManager.getMostRecentWindow("navigator:browser");
var browser = browserWindow.getBrowser();
if(browser.mCurrentBrowser.currentURI.spec == "about:blank")
browserWindow.loadURI(url, null, postData, false);
else
browser.loadOneTab(url, null, null, postData, false, false);
</code></pre>
<p>I'm using a string as url, and JSON data as postData. Is there something I'm doing wrong?</p>
<p>What happens, is a new tab is created, the location shows the URL I want to post to, but the document is blank. The Back, Forward, and Reload buttons are all grayed out on the browser. It seems like it did everything except executed the POST. If I leave the postData parameter off, then it properly runs a GET.</p>
<p>Build identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1</p>
|
<p>Something which is less Mozilla specific and should work reasonably well with most of the browsers:</p>
<ul>
<li>Create a hidden form with the fields set up the way you need them</li>
<li>Make sure that the "target" attribute of the form is set to "_BLANK"</li>
<li>Submit the form programatically</li>
</ul>
|
<p>try with addTab instead of loadOneTab, and remove the last parameter. </p>
<p>Check out <a href="http://developer.mozilla.org/en/Code_snippets/Tabbed_browser" rel="nofollow noreferrer">this page</a> over at the Mozilla Development Center for information on how to open tabs. </p>
<p>You could use this function, for example:</p>
<pre><code>function openAndReuseOneTabPerURL(url) {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var browserEnumerator = wm.getEnumerator("navigator:browser");
// Check each browser instance for our URL
var found = false;
while (!found && browserEnumerator.hasMoreElements()) {
var browserInstance = browserEnumerator.getNext().getBrowser();
// Check each tab of this browser instance
var numTabs = browserInstance.tabContainer.childNodes.length;
for(var index=0; index<numTabs; index++) {
var currentBrowser = browserInstance.getBrowserAtIndex(index);
if ("about:blank" == currentBrowser.currentURI.spec) {
// The URL is already opened. Select this tab.
browserInstance.selectedTab = browserInstance.tabContainer.childNodes[index];
// Focus *this* browser
browserInstance.focus();
found = true;
break;
}
}
}
// Our URL isn't open. Open it now.
if (!found) {
var recentWindow = wm.getMostRecentWindow("navigator:browser");
if (recentWindow) {
// Use an existing browser window
recentWindow.delayedOpenTab(url, null, null, null, null);
}
else {
// No browser windows are open, so open a new one.
window.open(url);
}
}
}
</code></pre>
| 5,684
|
<p>When launching a thread or a process in .NET or Java, is there a way to choose which processor or core it is launched on? How does the shared memory model work in such cases?</p>
|
<p>If you're using multiple threads, the operating system will automatically take care of using multiple cores.</p>
|
<p>I have used this in a couple of programs because my core 0 was kind of messed up.</p>
<pre><code>// Programmatically set process affinity
var process = System.Diagnostics.Process.GetCurrentProcess();
// Set Core 0
process.ProcessorAffinity = new IntPtr(0x0001);
</code></pre>
<p>or</p>
<pre><code>// Set Core 1
process.ProcessorAffinity = new IntPtr(0x0002);
</code></pre>
<p>More on this in "<a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.processoraffinity.aspx" rel="nofollow noreferrer">Process.ProcessorAffinity Property</a>".</p>
| 5,777
|
<p>I am using the E3D v6 hotend with the titan extruder. Everytime I go to do a test print, just enough stringy filament oozes comes out of the hotend "right before" it lays down the first layer. I have no idea why it oozes out the little bit of filament before it prints.... The unwanted filament builds up while some of the first layer is done. As a result, what has been printed or about to be printed get stuck together as it tries to do the rest of the print....</p>
<p><a href="https://i.stack.imgur.com/ezHBV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ezHBV.jpg" alt="enter image description here"></a></p>
|
<p>As the filament in the melt chamber heats up, it's going to inevitably ooze a little bit. Make sure you watch for this and clean it off as the hot-end heats up, and setup you slicing software to print a skirt, which will print a few loops around the outside of your print, separated by a few mm, to deal with ooze and get filament flowing properly.</p>
<p>If it oozes a lot, try reducing your print temperature a bit.</p>
|
<p>In general, it's a bit normal to have <em>some</em> filament ooze during warm-up. However, if it seems to be an abnormal amount, you may want to consider reducing your target temperature.</p>
<p>Keep in mind that ideal extrusion temperatures are subjective to the source of your filament. Not all filament is of the same material quality and differing degrees of purity. Sometimes, the same filament will be of different quality from the same source. It might be worth dedicating the first bit of each spool to a bar test to determine what the appropriate extrusion temperature should be.</p>
<p>A simple test would be to use the control panel on your machine or use your software (whichever is easiest for you):</p>
<ul>
<li>Manually set the extruder to <strong>extrude filament</strong></li>
<li><strong>Stop</strong> the extruder</li>
<li><strong>Clean</strong> excess material from nozzle</li>
<li><strong>Watch</strong> for ooze</li>
<li>Gradually <strong>reduce</strong> the temperature</li>
<li><strong>Repeat</strong> until the amount of ooze is an appropriate to your liking</li>
</ul>
<p>Also remember that there will be some left-over material from a previous spool when swapping spools.</p>
| 332
|
<p>Depending on my mood I seem to waffle back and forth between wanting a Lisp-1 and a Lisp-2. Unfortunately beyond the obvious name space differences, this leaves all kinds of amusing function name/etc problems you run into. Case in point, trying to write some code tonight I tried to do (map #'function listvar) which, of course, doesn't work in CL, at all. Took me a bit to remember I wanted mapcar, not map. Of course it doesn't help when slime/emacs shows map IS defined as something, though obviously not the same function at all.</p>
<p>So, pointers on how to minimize this short of picking one or the other and sticking with it?</p>
|
<p><a href="http://www.lispworks.com/documentation/HyperSpec/Body/f_map.htm" rel="nofollow noreferrer">Map</a> is more general than mapcar, for example you could do the following rather than using mapcar:</p>
<pre><code>(map 'list #'function listvar)
</code></pre>
<p>How do I keep scheme and CL separate in my head? I guess when you know both languages well enough you just know what works in one and not the other. Despite the syntactic similarities they are quite different languages in terms of style.</p>
|
<p>I'm definitely aware that there are syntactic differences, though I'm certainly not fluent enough yet to automatically use them, making the code look much more similar currently ;-).</p>
<p>And I had a feeling your answer would be the case, but can always hope for a shortcut <_<.</p>
| 5,151
|
<p>is it possible to display ⇓ entity in ie6? It is being display in every browser but not IE 6.I am writing markup such as: </p>
<pre><code><span>&#8659;</span>
</code></pre>
|
<p>According to <a href="https://web.archive.org/web/20080221144246/http://www.ackadia.com:80/web-design/character-code/character-code-symbols.php" rel="nofollow noreferrer">this page</a>, that symbol doesn't show in IE6 at all. </p>
<pre><code>Symbol Character Numeric Description
⇓ &dArr; &#8659; Down double arrow - - * Doesn't show with MS IE6
</code></pre>
<p>If you really need that particular symbol, you may just have to go for a small graphic of the arrow - not an ideal solution, but if you need it to display in IE6 then that may be your only option.</p>
|
<p>Yes, it is possible... But you'll need to explicitly tell IE which font to find it in. For instance:</p>
<pre><code><span style="font-family:Arial Unicode MS"> &#8659; </span>
</code></pre>
<p>should produce ⇓ in most browsers.</p>
| 8,563
|
<p>I have a 3D print where there are 5 holes with a diameter of 4 mm in a cup, and I would like liquid to flow through all 5 holes at once while slowly draining the cup (by slowly I mean: just take a few seconds and not drain instantly). Therefore the holes can not be very large.</p>
<p>When I fill water in the cup it drains fine until there is a small amount of water left, and then it just stops with a small layer of water flowing over the holes.</p>
<p>I'm guessing it is due to surface tension and not enough pressure from water above to push the water through...</p>
<p>Is there a hole design that fixes this problem? I don't know what to Google or if this is the right place to ask the question. It just takes too long to guess my way through and print every attempt at the right size or shape of hole (which I have done so far and still got nothing).</p>
|
<p>What you encounter there is a combination of Adhesion, Cohesion, and Capillary Force.</p>
<p>Cohesion is what holds the water together. Adhesion is the force to retain water against a wall or hanging from a pen's end, it is proportional to the surface wetted. Capillary Force is the resulting effect where water moves up through a thin tube, it is anti-proportional to the diameter and in the opposite direction of the weight (force). Their relation can be shown in this picture, where a droplet hangs on the end of a glass rod, which has a capillary in it:</p>
<p><a href="https://i.stack.imgur.com/Q9iYq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Q9iYq.png" alt="enter image description here" /></a></p>
<p>How to reduce the water sticking in the cup then?</p>
<ul>
<li>Make the straight part of the bore as short as possible. This can be done by having a thin cup. The shorter the hole, the less surface there is the water can adhere to vertically, and you might overcome capillary force.</li>
<li>Smooth the hole. Maybe print it 3.5 mm and drill it up to your 4 mm diameter. This reduces adhesion.</li>
<li>Smooth the inside surface. Reducing the adhesion to the inside by having less steps.</li>
<li>Chamfer the inside of the holes. This alters the whole geometry and flow setup in the very low water level case, especially when the surface separates into several areas, above each hole. Then the larger volume belonging to each hole on the inner side means there is a little more pressure and you can get out some more water - and it also shortens the distance the hole has to bridge.</li>
<li>make sure there is some slope everywhere inside so that the water will collect in one of the holes.</li>
</ul>
<p>An example for a (non measured) design which relies heavily on chamfering to guide the water to the already chamfered holes and then keeps the straight section as short as possible could look like this: the central hole has a very wide chamfer, the whole plate directs water to the center and each of the other holes has a chamfer to guide out water.</p>
<p><a href="https://i.stack.imgur.com/wMaIe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wMaIe.png" alt="enter image description here" /></a></p>
<p>However, there is a lower limit to where just tweaking the design will workd, which is based on cohesion. Cohesion is what results in surface tension and viscosity. You can only shift those limiting factors by altering the properties of the liquid, for example by adding an agent that lowers the surface tension and viscosity (soap).</p>
|
<p>If it is possible to add a downward pointing thin needle (hair, AWG-40 wire etc.) to the edge of (each) hole, do it. The droplets will smoothly glide along it to its end, where the needle circumference becomes so tiny that surface tension cannot hold the droplet anymore. Surface tension won't have a chance!</p>
<p>With a very thin needle and funnel-like hydrophobic surface of the vessel, you may get rid of virtually any (microliter) amount of water. It can be hard to make it by 3D-printing, though.</p>
| 1,762
|
<p>I'm trying to reduce the form spam on our website. (It's actually pretty recent).</p>
<p>I seem to remember reading somewhere that the spammers aren't executing the Javascript on the site.</p>
<p>Is that true?
And if so, then could you simply check for javascript being disabled and then figure it's <em>likely</em> that it's spam?</p>
|
<p>There are still a large number of people that run with Javascript turned off.</p>
<p>Alternatively, I have had decent success with stopping form spam using CSS. Basically, include an input field and label that is hidden using CSS (<code>display: none;</code>) and once submitted, check if anything has been entered in the field. </p>
<p>I generally label the field as a spam filter with an instruction to <em>not</em> put anything in the field, but all newer browsers will properly hide the block.</p>
<ul>
<li>More: <a href="http://www.modernblue.com/web-design-blog/fighting-spam-with-css/" rel="nofollow noreferrer">Fighting Spam with CSS</a></li>
</ul>
<p><a href="http://recaptcha.net/" rel="nofollow noreferrer">reCAPTCHA</a> is also surprisingly easy to implement.</p>
|
<p>I can't remember where I've seen this method but spam bots like to fill out forms. Have you considered putting a form field that is hidden with javascript (and says don't fill this field if the user doesn't have JavaScript). This way if something fills in this field you can ignore it as spam.</p>
| 7,563
|
<p>I am working on a small webapp and I want to use Groovy to write some unit testing for my app. Most of my coding is done on Eclipse and I really want to run all the unit testing with the graphical test runner within Eclipse (I really like the green bar :) )</p>
<p>Sadly, after 4 hours of try-and-error, I'm still not able to setup properly. I tried to use the Eclipse Junit4 test runner to run a Groovy file with method annotated for testing using <code>@Test</code>. But it keeps complaining <code>NoClassDefFoundException</code></p>
<p>Anyone can help? </p>
<p>Here is content of my groovy file, named simpleTest.groovy</p>
<pre><code>import org.junit.Test
import static org.junit.Assert.assertEquals
class simpleTest{
@Test
void trial(){
assertEquals 6, 3+3
}
}
</code></pre>
<p>Anyone can help?</p>
|
<p>You might want to give the updated plugin a try, see the <a href="http://blog.springsource.com/2009/07/30/a-groovier-eclipse-experience" rel="nofollow noreferrer">the recent blog post</a> for more details. The theme of this alpha release is <em>providing an optimized edit/save/compile/test experience</em>, which seems to be your exact use case.</p>
<p><img src="https://i.stack.imgur.com/0joPq.png" alt="Groovy Eclipse 2.0"></p>
|
<p>Unfortunately, the Groovy Eclipse plugin is pretty horrible at giving actual helpful information to let you know what is going wrong with your setup. I'm going to assume you already did the verification to make sure the plugin is actually building your Groovy files (i.e. doing a sample with no dependencies, checking the properly output directory, etc...) After that, it's a lot of really small configuration verification...I've run into problems where the particular "runner" I'm using in Eclipse (i.e. in the Run menu) doesn't have the write class name defined there or for some reason my project didn't get the JUnit library dependency properly inserted into it. </p>
<p>Ultimately, it can be a configuration headache, but long term you'll end up saving some time and gaining some cool functionality if you can knock it out...</p>
| 3,124
|
<p>I'm working on a projects which involves a lot of database writes, I'd say (<em>70% inserts and 30% reads</em>). This ratio would also include updates which I consider to be one read and one write. The reads can be dirty (e.g. I don't need 100% accurate information at the time of read).<br>
The task in question will be doing over 1 million database transactions an hour. </p>
<p>I've read a bunch of stuff on the web about the differences between MyISAM and InnoDB, and MyISAM seems like the obvious choice to me for the particular database/tables that I'll be using for this task. From what I seem to be reading, InnoDB is good if transactions are needed since row level locking is supported.</p>
<p>Does anybody have any experience with this type of load (or higher)? Is MyISAM the way to go?</p>
|
<p>I have briefly <a href="http://developer99.blogspot.com/2011/07/mysql-innodb-vs-myisam.html" rel="noreferrer">discussed</a> this question in a table so you can conclude whether to go with <strong>InnoDB</strong> or <strong>MyISAM</strong>.</p>
<p>Here is a small overview of which db storage engine you should use in which situation:</p>
<pre>
MyISAM InnoDB
----------------------------------------------------------------
Required full-text search Yes 5.6.4
----------------------------------------------------------------
Require transactions Yes
----------------------------------------------------------------
Frequent select queries Yes
----------------------------------------------------------------
Frequent insert, update, delete Yes
----------------------------------------------------------------
Row locking (multi processing on single table) Yes
----------------------------------------------------------------
Relational base design Yes
</pre>
<p><strong>Summary</strong></p>
<ul>
<li>In almost all circumstances, <strong>InnoDB</strong> is the best way to go</li>
<li>But, frequent reading, almost no writing, use <strong>MyISAM</strong></li>
<li>Full-text search in MySQL <= 5.5, use <strong>MyISAM</strong></li>
</ul>
|
<p>bottomline: if you are working offline with selects on large chunks of data, MyISAM will probably give you better (much better) speeds.</p>
<p>there are some situations when MyISAM is infinitely more efficient than InnoDB: when manipulating large data dumps offline (because of table lock). </p>
<p>example: I was converting a csv file (15M records) from NOAA which uses VARCHAR fields as keys. InnoDB was taking forever, even with large chunks of memory available.</p>
<p>this an example of the csv (first and third fields are keys).</p>
<pre><code>USC00178998,20130101,TMAX,-22,,,7,0700
USC00178998,20130101,TMIN,-117,,,7,0700
USC00178998,20130101,TOBS,-28,,,7,0700
USC00178998,20130101,PRCP,0,T,,7,0700
USC00178998,20130101,SNOW,0,T,,7,
</code></pre>
<p>since what i need to do is run a batch offline update of observed weather phenomena, i use MyISAM table for receiving data and run JOINS on the keys so that i can clean the incoming file and replace VARCHAR fields with INT keys (which are related to external tables where the original VARCHAR values are stored).</p>
| 4,049
|
<p>I just received my Wanhao Duplicator i3 PLUS. Everything prints and functions fine via SD card and the display but when connecting to my Mac computer the printer seems to restart.</p>
<ul>
<li>Baud Rate: 115200</li>
<li>Serial Port: <code>/dev/tty.wchusbserial1420</code></li>
</ul>
<p>Any ideas what it could be?</p>
|
<p>I don't know that printer. But Arduino has a feature that a USB connection causes a reset. The Idea is that this helps when doing software update as the Arduino Boot loader will be active for one second after that reset.</p>
<p>This can be disabled, but needs hardware modification.</p>
|
<p>That is normal on most printers. They restart if you connect.</p>
<p>As you have an SD card slot I would recommend using it rather than your computer. If your connected computer goes to sleep it would also reset the connection after wakeup.</p>
| 353
|
<p>How can I tell from the assembly name, or assembly class (or others like it), whether an assembly is part of the <a href="http://en.wikipedia.org/wiki/.NET_Framework" rel="noreferrer">.NET</a> framework (that is, <code>System.windows.Forms</code>)?</p>
<p>So far I've considered the PublicKeyToken, and CodeBase properties, but these are not always the same for the whole framework.</p>
<p>The reason I want this information is to get a list of assemblies that my EXE file is using that need to be on client machines, so I can package the correct files in a setup file without using the Visual Studio setup system. The problem is, I don't want to pick up any .NET framework assemblies, and I want it to be an automatic process that is easy to roll out whenever a major update is finished.</p>
<p>The ultimate solution would be that there is an IsFramework property... :)</p>
|
<p>No, it doesn't begin with "System". You could check "WindowsBase" which is a framework assembly.</p>
<p>You can't also check the PublicKeyToken, because there are other Microsoft assemblies signed with the "default" keys, but they are not part of the .NET Framework (Visual Studio assemblies).</p>
<p>The best way of doing it is to get a collection of installed .NET frameworks and check if the target assembly is part of their RedistList (<code>RedistList\FrameworkList.xml</code>).</p>
<p>FrameworkList.xml can be found in:</p>
<ul>
<li>.NET 2.0: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\RedistList</li>
<li>.NET 3.x: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v<em>VersionNumber</em>\RedistList</li>
<li>.NET 4.x: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v<em>VersionNumber</em>\RedistList</li>
<li>.NET Core: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v<em>VersionNumber</em>\RedistList</li>
</ul>
|
<p>You could use reflection to look at the publisher of the assembly, and coordinate that with the assembly's path. If you find an assembly whose publisher is Microsoft, and which exists somewhere below <code>C:\Windows\Microsoft.NET\Framework</code> it's a safe bet it's part of the runtime.</p>
<p>On second thought, the publisher may not even be necessary. Anything under that path should be part of the runtime (barring a misbehaving application that's diddling where it shouldn't be).</p>
| 7,538
|
<p>I'm using <code>int</code> as an example, but this applies to any value type in .Net</p>
<p>In .Net 1 the following would throw a compiler exception:</p>
<pre><code>int i = SomeFunctionThatReturnsInt();
if( i == null ) //compiler exception here
</code></pre>
<p>Now (in .Net 2 or 3.5) that exception has gone.</p>
<p>I know why this is:</p>
<pre><code>int? j = null; //nullable int
if( i == j ) //this shouldn't throw an exception
</code></pre>
<p>The problem is that because <code>int?</code> is nullable and <code>int</code> now has a implicit cast to <code>int?</code>. The syntax above is compiler magic. Really we're doing:</p>
<pre><code>Nullable<int> j = null; //nullable int
//compiler is smart enough to do this
if( (Nullable<int>) i == j)
//and not this
if( i == (int) j)
</code></pre>
<p>So now, when we do <code>i == null</code> we get:</p>
<pre><code>if( (Nullable<int>) i == null )
</code></pre>
<p>Given that C# is doing compiler logic to calculate this anyway why can't it be smart enough to not do it when dealing with absolute values like <code>null</code>?</p>
|
<p>I don't think this is a compiler problem <em>per se</em>; an integer value is never null, but the idea of equating them isn't invalid; it's a valid function that always returns false. And the compiler knows; the code</p>
<pre><code>bool oneIsNull = 1 == null;
</code></pre>
<p>compiles, but gives a compiler warning: <code>The result of the expression is always 'false' since a value of type 'int' is never equal to 'null' of type '<null>'</code>.</p>
<p>So if you want the compiler error back, go to the project properties and turn on 'treat warnings as errors' for this error, and you'll start seeing them as build-breaking problems again.</p>
|
<p>The warning is new (3.5 I think) - the error is the same as if I'd done <code>1 == 2</code>, which it's smart enough to spot as never true.</p>
<p>I suspect that with full 3.5 optimisations the whole statement will just be stripped out, as it's pretty smart with never true evaluations.</p>
<p>While I might want <code>1==2</code> to compile (to switch off a function block while I test something else for instance) I don't want <code>1==null</code> to.</p>
| 8,809
|
<p>I have an SQL server database that I am querying and I only want to get the information when a specific row is null. I used a where statement such as:</p>
<pre><code>WHERE database.foobar = NULL
</code></pre>
<p>and it does not return anything. However, I know that there is at least one result because I created an instance in the database where 'foobar' is equal to null. If I take out the where statement it shows data so I know it is not the rest of the query.</p>
<p>Can anyone help me out?</p>
|
<p>Correct syntax is WHERE database.foobar IS NULL. See <a href="http://msdn.microsoft.com/en-us/library/ms188795.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms188795.aspx</a> for more info</p>
|
<p>Is it an SQL Server database?
If so, use <code>IS NULL</code> instead of making the comparison (<a href="http://msdn.microsoft.com/en-us/library/aa933227(SQL.80).aspx" rel="nofollow noreferrer">MSDN</a>).</p>
| 4,856
|
<p>I'm considering switching to a Dvorak-based keyboard layout, but one optimized for programming (mostly) Java and python (e.g. <a href="http://www.siteuri.ro/dvorak/DDvorak.aspx" rel="noreferrer">DDvorak</a>, <a href="http://www.kaufmann.no/roland/dvorak/" rel="noreferrer">Programmer Dvorak</a>, etc.). What particular keyboard would be best for such an undertaking? I'd consider either natural or straight keyboards.</p>
<p>Thanks.</p>
|
<p>I <em>strongly</em> discourage you from learning a layout that has been heavily optomized for any one programming language (or even a class of them..) it's much, much easier to change languages than keylayouts, and you'll have a lot of trouble finding the tweaked layouts on any random computers you need to use.</p>
<p>That said, I've used dvorak for years (something like 7-8 years now) on a <a href="http://www.kinesis-ergo.com/contoured.htm" rel="noreferrer">Kinesis Contoured keyboard</a> and it works wonderfully. The kinesis is programmable, switches between qwerty/dvorak, and you can remap the keys all you want (so you could try out ddvorak or programmer dvorak pretty easily, without making software changes, if you wanted).</p>
<p>The contoured keyboard also forces you to touch-type more "correctly", since you can't easily reach across the keyboard with the wrong hand.</p>
|
<p>Do you use a natural keyboard, or a straight one? Keyboard preference can be intensely personal, but many higher-end keyboards have keys fitted specifically for the location of the key (slant and curvature), meaning for Dvorak you'll need to ignore the labels, move the keys and eliminate that advantage, or go with something like the <a href="http://www.daskeyboard.com/" rel="nofollow noreferrer">blank das keyboard</a></p>
| 9,304
|
<p>Is there a way to make psycopg and postgres deal with errors without having to reestablish the connection, like MySQLdb? The commented version of the below works with MySQLdb, the comments make it work with Psycopg2:</p>
<pre><code>results = {'felicitas': 3, 'volumes': 8, 'acillevs': 1, 'mosaics': 13, 'perat\xe9': 1, 'representative': 6....}
for item in sorted(results):
try:
cur.execute("""insert into resultstab values ('%s', %d)""" % (item, results[item]))
print item, results[item]
# conn.commit()
except:
# conn=psycopg2.connect(user='bvm', database='wdb', password='redacted')
# cur=conn.cursor()
print 'choked on', item
continue
</code></pre>
<p>This must slow things down, could anyone give a suggestion for passing over formatting errors? Obviously the above chokes on apostrophes, but is there a way to make it pass over that without getting something like the following, or committing, reconnecting, etc?:</p>
<pre><code>agreement 19
agreements 1
agrees 1
agrippa 9
choked on agrippa's
choked on agrippina
</code></pre>
|
<p>VMWare server includes the command line tool "vmware-cmd", which can be used to perform virtually any operation that can be performed through the console.</p>
<p>In this case you would simply add a "vmware-cmd susepend" to your script before starting your backup, and a "vmware-cmd start" after the backup is completed.</p>
<p>We use vmware-server as part of our build system to provide a known environment to run automated DB upgrades against, so we end up rolling back state as part of each build (driven by CruiseControl), and have found this interface to be rock solid.</p>
<pre><code>Usage: /usr/bin/vmware-cmd <options> <vm-cfg-path> <vm-action> <arguments>
/usr/bin/vmware-cmd -s <options> <server-action> <arguments>
Options:
Connection Options:
-H <host> specifies an alternative host (if set, -U and -P must also be set)
-O <port> specifies an alternative port
-U <username> specifies a user
-P <password> specifies a password
General Options:
-h More detailed help.
-q Quiet. Minimal output
-v Verbose.
Server Operations:
/usr/bin/vmware-cmd -l
/usr/bin/vmware-cmd -s register <config_file_path>
/usr/bin/vmware-cmd -s unregister <config_file_path>
/usr/bin/vmware-cmd -s getresource <variable>
/usr/bin/vmware-cmd -s setresource <variable> <value>
VM Operations:
/usr/bin/vmware-cmd <cfg> getconnectedusers
/usr/bin/vmware-cmd <cfg> getstate
/usr/bin/vmware-cmd <cfg> start <powerop_mode>
/usr/bin/vmware-cmd <cfg> stop <powerop_mode>
/usr/bin/vmware-cmd <cfg> reset <powerop_mode>
/usr/bin/vmware-cmd <cfg> suspend <powerop_mode>
/usr/bin/vmware-cmd <cfg> setconfig <variable> <value>
/usr/bin/vmware-cmd <cfg> getconfig <variable>
/usr/bin/vmware-cmd <cfg> setguestinfo <variable> <value>
/usr/bin/vmware-cmd <cfg> getguestinfo <variable>
/usr/bin/vmware-cmd <cfg> getid
/usr/bin/vmware-cmd <cfg> getpid
/usr/bin/vmware-cmd <cfg> getproductinfo <prodinfo>
/usr/bin/vmware-cmd <cfg> connectdevice <device_name>
/usr/bin/vmware-cmd <cfg> disconnectdevice <device_name>
/usr/bin/vmware-cmd <cfg> getconfigfile
/usr/bin/vmware-cmd <cfg> getheartbeat
/usr/bin/vmware-cmd <cfg> getuptime
/usr/bin/vmware-cmd <cfg> getremoteconnections
/usr/bin/vmware-cmd <cfg> gettoolslastactive
/usr/bin/vmware-cmd <cfg> getresource <variable>
/usr/bin/vmware-cmd <cfg> setresource <variable> <value>
/usr/bin/vmware-cmd <cfg> setrunasuser <username> <password>
/usr/bin/vmware-cmd <cfg> getrunasuser
/usr/bin/vmware-cmd <cfg> getcapabilities
/usr/bin/vmware-cmd <cfg> addredo <disk_device_name>
/usr/bin/vmware-cmd <cfg> commit <disk_device_name> <level> <freeze> <wait>
/usr/bin/vmware-cmd <cfg> answer
</code></pre>
|
<p>If I recall correctly, VMWare Server has a scripting interface, available via Perl or COM. You might be able to use that to automatically pause the VMs before running the backup.</p>
<p>If your backup software was shadow-copy aware, that might work, too.</p>
| 9,609
|
<p>I have been sold on mod_wsgi and apache rather than mod_python.
I have all the parts installed (django, apache, mod_wsgi) but have run into a problem deploying.</p>
<p>I am on osx 10.5 with apache 2.2 and django 1.0b2, mod_wsgi-2.3</p>
<p>My application is called tred.</p>
<p>Here are the relevant files:
httpd-vhosts (included in httpd-conf)</p>
<pre>
NameVirtualHost tred:80
ServerName tred
Alias /admin_media /usr/lib/python2.5/site-packages/django/contrib/admin/media
Order allow,deny
Allow from all
Alias /media /Users/dmg/Sites/tred/media
Order allow,deny
Allow from all
Alias / /Users/dmg/Sites/tred/
Order allow,deny
Allow from all
WSGIScriptAlias / /Users/dmg/Sites/tred/mod_wsgi-handler.wsgi
WSGIDaemonProcess tred user=dmg group=staff processes=1 threads=10
WSGIProcessGroup tred
</pre>
<p>mod_wsgi-handle.wsgi</p>
<pre>
import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..')
os.environ['DJANGO_SETTINGS_MODULE'] = 'tred.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
</pre>
<p>When I go to <a href="http://tred" rel="noreferrer">http://tred</a> I get a directory listing rather than the rendered website. I think I have followed the tutorials correctly but it is obviously not right. What can I do to make this work?</p>
|
<p>What happens if you remove the <code>Alias /</code> directive?</p>
|
<p>try following this tutorial - <a href="http://singlas.in/5-step-tutorial-for-using-django-with-apache-and-mod_wsgi/" rel="nofollow">http://singlas.in/5-step-tutorial-for-using-django-with-apache-and-mod_wsgi/</a></p>
<p>you are trying to host apache /var/www/ folder and the Django app both at root (/). Since Alias directive takes precedence over WSGIScriptAlias, it is rendering apache directory.</p>
<p>you can try to host the django app at /app. Alternatively host the /var/www/ folder at a different location like /public</p>
| 5,739
|
<p>I want to use Lucene (in particular, Lucene.NET) to search for email address domains.</p>
<p>E.g. I want to search for "@gmail.com" to find all emails sent to a gmail address.</p>
<p>Running a Lucene query for "*@gmail.com" results in an error, asterisks cannot be at the start of queries. Running a query for "@gmail.com" doesn't return any matches, because "foo@gmail.com" is seen as a whole word, and you cannot search for just parts of a word.</p>
<p>How can I do this?</p>
|
<p>No one gave a satisfactory answer, so we started poking around Lucene documentation and discovered we can accomplish this using custom Analyzers and Tokenizers.</p>
<p>The answer is this: create a WhitespaceAndAtSymbolTokenizer and a WhitespaceAndAtSymbolAnalyzer, then recreate your index using this analyzer. Once you do this, a search for "@gmail.com" will return all gmail addresses, because it's seen as a separate word thanks to the Tokenizer we just created.</p>
<p>Here's the source code, it's actually very simple:</p>
<pre><code>class WhitespaceAndAtSymbolTokenizer : CharTokenizer
{
public WhitespaceAndAtSymbolTokenizer(TextReader input)
: base(input)
{
}
protected override bool IsTokenChar(char c)
{
// Make whitespace characters and the @ symbol be indicators of new words.
return !(char.IsWhiteSpace(c) || c == '@');
}
}
internal class WhitespaceAndAtSymbolAnalyzer : Analyzer
{
public override TokenStream TokenStream(string fieldName, TextReader reader)
{
return new WhitespaceAndAtSymbolTokenizer(reader);
}
}
</code></pre>
<p>That's it! Now you just need to rebuild your index and do all searches using this new Analyzer. For example, to write documents to your index:</p>
<pre><code>IndexWriter index = new IndexWriter(indexDirectory, new WhitespaceAndAtSymbolAnalyzer());
index.AddDocument(myDocument);
</code></pre>
<p>Performing searches should use the analyzer as well:</p>
<pre><code>IndexSearcher searcher = new IndexSearcher(indexDirectory);
Query query = new QueryParser("TheFieldNameToSearch", new WhitespaceAndAtSymbolAnalyzer()).Parse("@gmail.com");
Hits hits = query.Search(query);
</code></pre>
|
<p>You could a separate field that indexes the email address reversed:
Index 'foo@gmail.com' as 'moc.liamg@oof'
Which enables you to do a query for "moc.liamg@*" </p>
| 3,952
|
<p>It feels like my print is almost there, I spent a long time fine tuning the calibration with a fantastic set of G-code files from <a href="https://www.youtube.com/watch?v=_EfWVUJjBdA" rel="nofollow noreferrer">Chuck Hellebuyck</a>.</p>
<p>I am using an Ender 3, on which I have modified the heatbed to carry a glass sheet, otherwise factory standard. The prints are done on the bare glass. When I printed a window some 14 feet (~4.5 meters) away was open to the cold New York winter. The cooling fan on the Ender 3 is mounted on the right side of the hotend and uses a simple declector, it can be seen in picture 2.</p>
<p>However, my print is not perfect yet. I'm using 1.75 mm PLA at a temperature of 200 °C for the 0.4 mm nozzle and a bed temperature of 60 °C. Out of the 4 corners, 3 printed perfectly, the back-left one did lift.</p>
<p>What do I need to do to fix the bed adhesion issue?</p>
<p><a href="https://i.stack.imgur.com/uLYsM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uLYsM.jpg" alt="One failing corner of the print"></a></p>
<p><a href="https://i.stack.imgur.com/NA5I2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NA5I2.jpg" alt="Good sides and hotend on the gantry above"></a></p>
<p><a href="https://i.stack.imgur.com/eCuVz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eCuVz.jpg" alt="Another angle of bad side"></a></p>
<p><a href="https://i.stack.imgur.com/k8Ehk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k8Ehk.jpg" alt="top down"></a></p>
|
<p>Based on the pictures, this looks like the bed wasn't clean enough, thus why it didn't adhere correctly in some spots. The lifted corner is the worst, but I can see a couple more spots where the PLA didn't stick well enough, though the brim prevented it to completely lift off the bed.</p>
<p>I would advise you to not print with the window open, even if it's only slightly ajar. Weather conditions and temperature will affect the quality of the print, even if it's only a small variation in temperature. I've had enough failed prints due to a shift in temperature to know that, even though PLA isn't affected as much than ABS by temperature changes through a print.</p>
<p>You might also try to increase the bed temperature a bit, up to 70°C or 80°C. I've looked at the recommended temperature for PLA with my UM3E and it says 80°C for the glass bed.</p>
<p>You should always make sure that the glass bed is clean: ie no dust on it and no grease. Yes, touching it with your fingers will leave a thin greasy residue in the form of fingerprints, and even one fingerprint can prevent good adhesion and result in the problem you had.</p>
<p>There are various products to clean glass beds, I've personally found out that the cheap yellow-colored window cleaner from Karcher works wonder. Do not use the standard blue colored window cleaner products: the blue one has a chemical in it that is made with the express intent to prevent anything to adhere to the glass, which is obviously not what we want. The yellow-colored cleaner doesn't have that chemical, and it cleans without depositing an anti-adhesion film on the glass.</p>
<p>If a thorough cleaning isn't sufficient, you can look into various adhesive products. While there is quite a lot of adhesive solutions marketed as being specifically for 3D printing, with insane prices most of the time, I've found that a simple UHU glue stick works wonders. I usually do not need glue when printing PLA, but I use it for Nylon, ABS and other filament that absolutely require it and it's a breeze to work with, and it cleans easily with soap and warm water.</p>
|
<p>I work with a glass surface on my machine and use a drop of superglue to attach the
corners after the first layer is complete. The biggest contributors to not sticking are :</p>
<ol>
<li>Bed not level.</li>
<li>Temperature of filament not hot enough.</li>
<li>First layer print speed is too fast.</li>
<li>Heated Bed not hot enough to compensate for cold room. Try enclosing print area.</li>
<li>Head is snagging on print edges (no retraction when moving) and ripping print loose.</li>
<li>Print bed surface is not clean. Use acetone or ammonia for cleaning glass. Alcohol leaves an oily residue.</li>
</ol>
<p>If you are printing on painters tape, make sure the bed is very clean when you put the tape
down. Then make sure you rub the tape down well so it doesn't pull off of the print bed
surface during printing. Then clean the tape surface to get the oil from your hands off of
the tape. </p>
<p>I use Glass Build Plate Wizard spray for delicate prints and a heated bed. It releases after the print plate cools down. That eliminates the need to chip the print loose. It releases itself after a few minutes.</p>
| 1,159
|
<p>My current project is to write a web application that is an equivalent of an existing desktop application. </p>
<p>In the desktop app at certain points in the workflow the user might click on a button and then be shown a form to fill in. Even if it takes a little time for the app to display the form, expert users know what the form will be and will start typing, knowing that the app will "catch up with them".</p>
<p>In a web application this doesn't happen: when the user clicks a link their keystrokes are then lost until the form on the following page is dispayed. Does anyone have any tricks for preventing this? Do I have to move away from using separate pages and use AJAX to embed the form in the page using something like <a href="http://code.google.com/webtoolkit/" rel="nofollow noreferrer">GWT</a>, or will that still have the problem of lost keystrokes?</p>
|
<p>Keystrokes won't have an effect until the page has loaded, javascript has been processed and the text field is then focused.</p>
<p>Basically what you are really asking is; <strong>how do I speed up a web application to increase response times?</strong> Your anwser is AJAX! </p>
<p>Carefully think about the most common actions in the application and use AJAX to minimise the reloading of webpages. Remember, don't over-use AJAX. Using too much javascript can hinder usability just as much as it can improve it.</p>
<p>Related reading material: </p>
<ul>
<li><a href="http://www.useit.com/papers/responsetime.html" rel="nofollow noreferrer">Response Times: The Three Important Limits</a> - Great article from the usability king, Jacon Neilson. </li>
<li><a href="http://ajaxian.com/archives/ajax-usability-mistakes" rel="nofollow noreferrer">Ajax Usability Mistakes</a> </li>
<li><a href="http://experiencedynamics.blogs.com/site_search_usability/2007/12/ajax-usability.html" rel="nofollow noreferrer">AJAX Usability Checklist</a></li>
</ul>
|
<p>AJAX or plugin are your only chances.</p>
| 8,693
|
<p>I have a datalist with a OnDeleteCommand="Delete_Command".</p>
<p>I want the delete a record with multiple primary Keys but I do not know how to access it from the Delete_Command event.</p>
<p>If I use DataKeyField I'm limited to only one key.
Any workarounds for this?</p>
|
<p>You can access all of the keys:</p>
<pre><code>gridView.DataKeys[rowNum][dataKeyName]
</code></pre>
<p>where rowNum is e.RowIndex from the gridView_RowDeleting event handler, and dataKeyName is the key you want to get:</p>
<pre><code><asp:GridView ID="gridView" runat="server" DataKeyNames="userid, id1, id2, id3" OnRowDeleting="gridView_RowDeleting">
protected void gridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
gridView.DataKeys[e.RowIndex]["userid"]...
gridView.DataKeys[e.RowIndex]["id1"]...
gridView.DataKeys[e.RowIndex]["id2"]...
gridView.DataKeys[e.RowIndex]["id3"]...
}
</code></pre>
|
<p>Oh, sorry, I missed it.</p>
<p>AFAIK there is no such a possibility by default. Maybe you can create a composite key from your primary keys, like </p>
<blockquote>
<p>Key1UnderscoreKey2UnderscoreKey3</p>
</blockquote>
<p>and split it in the event handler. So this is a DIY multi-key handler for DataList :-)</p>
<p>Edit: The underscore got lost during format, it replaces with italic text. So instead of "underscore" word use real underscores</p>
| 3,987
|
<p>Does anybody have an overview of what things should be calibrated (and in what order) for a certain 3d printer or after changing the printing material?</p>
<p>I only know about:</p>
<ul>
<li>calibrating the extruder steps per mm, e.g. <a href="https://www.youtube.com/watch?v=YUPfBJz3I6Y" rel="nofollow noreferrer">Tom's youtube tutorial</a></li>
<li>determining the print temperature, e.g. <a href="https://www.youtube.com/watch?v=FSOPsRiiOZk" rel="nofollow noreferrer">RepRap Neo's youtube tutorial</a></li>
<li>calibrating the extrusion multiplier (for each different filament), e.g. <a href="https://www.youtube.com/watch?v=cnjE5udkNEA" rel="nofollow noreferrer">RepRap 101's youtube tutorial</a></li>
</ul>
<p>How to calibrate/determine the maximum speeds or accelerations?</p>
|
<p>How to Calibrate. Oh man that is a good 2-3 page long blog post.. So I will try to give you the bullet point section. </p>
<p>High level</p>
<ul>
<li>Mechanical </li>
<li>Firmware </li>
<li>Software</li>
<li>repeat</li>
</ul>
<p>Mechanical
Level everything. Bed. The X axis. Make sure there is no binding, etc. Also make sure the surface you are on is flat before leveling the printer by it.</p>
<p>Firmware
Get that printer moving. This is where you do you Steps per MM. I like <a href="http://reprap.org/wiki/Triffid_Hunter's_Calibration_Guide" rel="nofollow noreferrer">Triffids guide</a>.</p>
<p>Now is when you go into the software and start setting your slicer settings. This includes your filament measurements etc. You should go back 2-3 times between this step and the previous to make sure your extruding EXACTLY what you think you are. As mentioned by others filament calculation is hard. You need to measure across a lot of material. Take the averages. You will never get it perfect as the plastic is never perfect. Picking a solid supplier is a factor here too. </p>
<p>Once you think you have that all working. Repeat. Start at step one. </p>
<p>After your done looping though you will start with the slicer calibrations. Which is the meat of your question. You will take collections like <a href="http://www.thingiverse.com/thing:533472" rel="nofollow noreferrer">this one</a> or <a href="http://www.thingiverse.com/thing:52946" rel="nofollow noreferrer">this one</a> and tweak settings until you can pass each test. Do your tests in this order</p>
<ol>
<li><a href="http://www.thingiverse.com/thing:1637" rel="nofollow noreferrer">single wall test</a></li>
<li><a href="http://www.thingiverse.com/thing:271736" rel="nofollow noreferrer">hollow cube</a></li>
<li><a href="http://www.thingiverse.com/thing:2064" rel="nofollow noreferrer">solid cube</a> Here is a <a href="http://www.thingiverse.com/thing:24238" rel="nofollow noreferrer">Bonus solid cube</a></li>
<li><a href="http://www.thingiverse.com/thing:12925" rel="nofollow noreferrer">bridging test</a> (honestly I rarely do this one..) </li>
<li><a href="http://www.thingiverse.com/thing:342198" rel="nofollow noreferrer">part fitting test</a></li>
</ol>
<p>Now for testing when switching material. Honestly its best to start with their settings, and tweak them. I like to have a spread sheet of xy speed, Z lift, temps. Massage it till you are happy. The firmware settings like jerk and acceleration will be less of a factor between materials. Get it perfect once and don't touch it (till you decide it is not perfect).</p>
<p>You will be testing the new material with the same STLs as I mentioned in the precious section. You also might want to look into Simplify 3d (no affiliation) if you get really into it. Also SAVE THE SETTINGS. Nothing sucks more then losing all this work and having to recreate these profiles for materials. Do not trust slic3r to back them up, or to not randomly delete them. Hard lesson there.</p>
<p>Far as max speeds and accelleration..</p>
<p>Max speed will really be a function of how fast can you hear up plastic. If you have a e3d with Volcano mod you can really crank the speed up. So you go to the point where your extruder just cannot hit target temps AND you are unable to print solid infill. Far as acceleration and jerk. When you knock your extruder causing your print to shift, then you know it is accelerating / jerking too hard.</p>
<p>Best of luck! Let me know if I can clear up a section for you.</p>
|
<p>Recalibrating your machine for the new filament diameter is a good idea. Filament diameters vary slightly between manufacturers. </p>
| 478
|
<p>When I press F5 in Visual Studio 2008, I want Google Chrome launched as the browser that my ASP.NET app runs in. May I know how this can be done?</p>
|
<p>Right click on an .aspx file and click "Browse with..." then select Chrome and click "Set as Default." You can select more than one browser in the list if you want.</p>
<p>There's also this really great <a href="http://visualstudiogallery.msdn.microsoft.com/bb424812-f742-41ef-974a-cdac607df921/" rel="noreferrer">WoVS Default Browser Switcher Visual Studio extension</a>.</p>
|
<p>In case you are using Visual Studio 2019: To change default browser
type defaults in home, then click browser.</p>
<p>See this picture:</p>
<p><a href="https://i.stack.imgur.com/qVaJp.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qVaJp.jpg" alt="defaults apps" /></a></p>
<p><a href="https://learn.microsoft.com/en-us/answers/questions/31013/browser-selection-in-visual-studio-2019.html" rel="nofollow noreferrer">Reference/Source</a></p>
| 8,365
|
<p>I need to know how much space occupies all the databases inside an SQL Server 2000. I did some research but could not found any script to help me out.</p>
|
<p>Source: <a href="http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1313431,00.html" rel="noreferrer">http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1313431,00.html</a>
Works with SQL2000,2005,2008</p>
<pre><code>USE master;
GO
IF OBJECT_ID('dbo.sp_SDS', 'P') IS NOT NULL
DROP PROCEDURE dbo.sp_SDS;
GO
CREATE PROCEDURE dbo.sp_SDS
@TargetDatabase sysname = NULL, -- NULL: all dbs
@Level varchar(10) = 'Database', -- or "File"
@UpdateUsage bit = 0, -- default no update
@Unit char(2) = 'MB' -- Megabytes, Kilobytes or Gigabytes
AS
/**************************************************************************************************
**
** author: Richard Ding
** date: 4/8/2008
** usage: list db size AND path w/o SUMmary
** test code: sp_SDS -- default behavior
** sp_SDS 'maAster'
** sp_SDS NULL, NULL, 0
** sp_SDS NULL, 'file', 1, 'GB'
** sp_SDS 'Test_snapshot', 'Database', 1
** sp_SDS 'Test', 'File', 0, 'kb'
** sp_SDS 'pfaids', 'Database', 0, 'gb'
** sp_SDS 'tempdb', NULL, 1, 'kb'
**
**************************************************************************************************/
SET NOCOUNT ON;
IF @TargetDatabase IS NOT NULL AND DB_ID(@TargetDatabase) IS NULL
BEGIN
RAISERROR(15010, -1, -1, @TargetDatabase);
RETURN (-1)
END
IF OBJECT_ID('tempdb.dbo.##Tbl_CombinedInfo', 'U') IS NOT NULL
DROP TABLE dbo.##Tbl_CombinedInfo;
IF OBJECT_ID('tempdb.dbo.##Tbl_DbFileStats', 'U') IS NOT NULL
DROP TABLE dbo.##Tbl_DbFileStats;
IF OBJECT_ID('tempdb.dbo.##Tbl_ValidDbs', 'U') IS NOT NULL
DROP TABLE dbo.##Tbl_ValidDbs;
IF OBJECT_ID('tempdb.dbo.##Tbl_Logs', 'U') IS NOT NULL
DROP TABLE dbo.##Tbl_Logs;
CREATE TABLE dbo.##Tbl_CombinedInfo (
DatabaseName sysname NULL,
[type] VARCHAR(10) NULL,
LogicalName sysname NULL,
T dec(10, 2) NULL,
U dec(10, 2) NULL,
[U(%)] dec(5, 2) NULL,
F dec(10, 2) NULL,
[F(%)] dec(5, 2) NULL,
PhysicalName sysname NULL );
CREATE TABLE dbo.##Tbl_DbFileStats (
Id int identity,
DatabaseName sysname NULL,
FileId int NULL,
FileGroup int NULL,
TotalExtents bigint NULL,
UsedExtents bigint NULL,
Name sysname NULL,
FileName varchar(255) NULL );
CREATE TABLE dbo.##Tbl_ValidDbs (
Id int identity,
Dbname sysname NULL );
CREATE TABLE dbo.##Tbl_Logs (
DatabaseName sysname NULL,
LogSize dec (10, 2) NULL,
LogSpaceUsedPercent dec (5, 2) NULL,
Status int NULL );
DECLARE @Ver varchar(10),
@DatabaseName sysname,
@Ident_last int,
@String varchar(2000),
@BaseString varchar(2000);
SELECT @DatabaseName = '',
@Ident_last = 0,
@String = '',
@Ver = CASE WHEN @@VERSION LIKE '%9.0%' THEN 'SQL 2005'
WHEN @@VERSION LIKE '%8.0%' THEN 'SQL 2000'
WHEN @@VERSION LIKE '%10.0%' THEN 'SQL 2008'
END;
SELECT @BaseString =
' SELECT DB_NAME(), ' +
CASE WHEN @Ver = 'SQL 2000' THEN 'CASE WHEN status & 0x40 = 0x40 THEN ''Log'' ELSE ''Data'' END'
ELSE ' CASE type WHEN 0 THEN ''Data'' WHEN 1 THEN ''Log'' WHEN 4 THEN ''Full-text'' ELSE ''reserved'' END' END +
', name, ' +
CASE WHEN @Ver = 'SQL 2000' THEN 'filename' ELSE 'physical_name' END +
', size*8.0/1024.0 FROM ' +
CASE WHEN @Ver = 'SQL 2000' THEN 'sysfiles' ELSE 'sys.database_files' END +
' WHERE '
+ CASE WHEN @Ver = 'SQL 2000' THEN ' HAS_DBACCESS(DB_NAME()) = 1' ELSE 'state_desc = ''ONLINE''' END + '';
SELECT @String = 'INSERT INTO dbo.##Tbl_ValidDbs SELECT name FROM ' +
CASE WHEN @Ver = 'SQL 2000' THEN 'master.dbo.sysdatabases'
WHEN @Ver IN ('SQL 2005', 'SQL 2008') THEN 'master.sys.databases'
END + ' WHERE HAS_DBACCESS(name) = 1 ORDER BY name ASC';
EXEC (@String);
INSERT INTO dbo.##Tbl_Logs EXEC ('DBCC SQLPERF (LOGSPACE) WITH NO_INFOMSGS');
-- For data part
IF @TargetDatabase IS NOT NULL
BEGIN
SELECT @DatabaseName = @TargetDatabase;
IF @UpdateUsage <> 0 AND DATABASEPROPERTYEX (@DatabaseName,'Status') = 'ONLINE'
AND DATABASEPROPERTYEX (@DatabaseName, 'Updateability') <> 'READ_ONLY'
BEGIN
SELECT @String = 'USE [' + @DatabaseName + '] DBCC UPDATEUSAGE (0)';
PRINT '*** ' + @String + ' *** ';
EXEC (@String);
PRINT '';
END
SELECT @String = 'INSERT INTO dbo.##Tbl_CombinedInfo (DatabaseName, type, LogicalName, PhysicalName, T) ' + @BaseString;
INSERT INTO dbo.##Tbl_DbFileStats (FileId, FileGroup, TotalExtents, UsedExtents, Name, FileName)
EXEC ('USE [' + @DatabaseName + '] DBCC SHOWFILESTATS WITH NO_INFOMSGS');
EXEC ('USE [' + @DatabaseName + '] ' + @String);
UPDATE dbo.##Tbl_DbFileStats SET DatabaseName = @DatabaseName;
END
ELSE
BEGIN
WHILE 1 = 1
BEGIN
SELECT TOP 1 @DatabaseName = Dbname FROM dbo.##Tbl_ValidDbs WHERE Dbname > @DatabaseName ORDER BY Dbname ASC;
IF @@ROWCOUNT = 0
BREAK;
IF @UpdateUsage <> 0 AND DATABASEPROPERTYEX (@DatabaseName, 'Status') = 'ONLINE'
AND DATABASEPROPERTYEX (@DatabaseName, 'Updateability') <> 'READ_ONLY'
BEGIN
SELECT @String = 'DBCC UPDATEUSAGE (''' + @DatabaseName + ''') ';
PRINT '*** ' + @String + '*** ';
EXEC (@String);
PRINT '';
END
SELECT @Ident_last = ISNULL(MAX(Id), 0) FROM dbo.##Tbl_DbFileStats;
SELECT @String = 'INSERT INTO dbo.##Tbl_CombinedInfo (DatabaseName, type, LogicalName, PhysicalName, T) ' + @BaseString;
EXEC ('USE [' + @DatabaseName + '] ' + @String);
INSERT INTO dbo.##Tbl_DbFileStats (FileId, FileGroup, TotalExtents, UsedExtents, Name, FileName)
EXEC ('USE [' + @DatabaseName + '] DBCC SHOWFILESTATS WITH NO_INFOMSGS');
UPDATE dbo.##Tbl_DbFileStats SET DatabaseName = @DatabaseName WHERE Id BETWEEN @Ident_last + 1 AND @@IDENTITY;
END
END
-- set used size for data files, do not change total obtained from sys.database_files as it has for log files
UPDATE dbo.##Tbl_CombinedInfo
SET U = s.UsedExtents*8*8/1024.0
FROM dbo.##Tbl_CombinedInfo t JOIN dbo.##Tbl_DbFileStats s
ON t.LogicalName = s.Name AND s.DatabaseName = t.DatabaseName;
-- set used size and % values for log files:
UPDATE dbo.##Tbl_CombinedInfo
SET [U(%)] = LogSpaceUsedPercent,
U = T * LogSpaceUsedPercent/100.0
FROM dbo.##Tbl_CombinedInfo t JOIN dbo.##Tbl_Logs l
ON l.DatabaseName = t.DatabaseName
WHERE t.type = 'Log';
UPDATE dbo.##Tbl_CombinedInfo SET F = T - U, [U(%)] = U*100.0/T;
UPDATE dbo.##Tbl_CombinedInfo SET [F(%)] = F*100.0/T;
IF UPPER(ISNULL(@Level, 'DATABASE')) = 'FILE'
BEGIN
IF @Unit = 'KB'
UPDATE dbo.##Tbl_CombinedInfo
SET T = T * 1024, U = U * 1024, F = F * 1024;
IF @Unit = 'GB'
UPDATE dbo.##Tbl_CombinedInfo
SET T = T / 1024, U = U / 1024, F = F / 1024;
SELECT DatabaseName AS 'Database',
type AS 'Type',
LogicalName,
T AS 'Total',
U AS 'Used',
[U(%)] AS 'Used (%)',
F AS 'Free',
[F(%)] AS 'Free (%)',
PhysicalName
FROM dbo.##Tbl_CombinedInfo
WHERE DatabaseName LIKE ISNULL(@TargetDatabase, '%')
ORDER BY DatabaseName ASC, type ASC;
SELECT CASE WHEN @Unit = 'GB' THEN 'GB' WHEN @Unit = 'KB' THEN 'KB' ELSE 'MB' END AS 'SUM',
SUM (T) AS 'TOTAL', SUM (U) AS 'USED', SUM (F) AS 'FREE' FROM dbo.##Tbl_CombinedInfo;
END
IF UPPER(ISNULL(@Level, 'DATABASE')) = 'DATABASE'
BEGIN
DECLARE @Tbl_Final TABLE (
DatabaseName sysname NULL,
TOTAL dec (10, 2),
[=] char(1),
used dec (10, 2),
[used (%)] dec (5, 2),
[+] char(1),
free dec (10, 2),
[free (%)] dec (5, 2),
[==] char(2),
Data dec (10, 2),
Data_Used dec (10, 2),
[Data_Used (%)] dec (5, 2),
Data_Free dec (10, 2),
[Data_Free (%)] dec (5, 2),
[++] char(2),
Log dec (10, 2),
Log_Used dec (10, 2),
[Log_Used (%)] dec (5, 2),
Log_Free dec (10, 2),
[Log_Free (%)] dec (5, 2) );
INSERT INTO @Tbl_Final
SELECT x.DatabaseName,
x.Data + y.Log AS 'TOTAL',
'=' AS '=',
x.Data_Used + y.Log_Used AS 'U',
(x.Data_Used + y.Log_Used)*100.0 / (x.Data + y.Log) AS 'U(%)',
'+' AS '+',
x.Data_Free + y.Log_Free AS 'F',
(x.Data_Free + y.Log_Free)*100.0 / (x.Data + y.Log) AS 'F(%)',
'==' AS '==',
x.Data,
x.Data_Used,
x.Data_Used*100/x.Data AS 'D_U(%)',
x.Data_Free,
x.Data_Free*100/x.Data AS 'D_F(%)',
'++' AS '++',
y.Log,
y.Log_Used,
y.Log_Used*100/y.Log AS 'L_U(%)',
y.Log_Free,
y.Log_Free*100/y.Log AS 'L_F(%)'
FROM
( SELECT d.DatabaseName,
SUM(d.T) AS 'Data',
SUM(d.U) AS 'Data_Used',
SUM(d.F) AS 'Data_Free'
FROM dbo.##Tbl_CombinedInfo d WHERE d.type = 'Data' GROUP BY d.DatabaseName ) AS x
JOIN
( SELECT l.DatabaseName,
SUM(l.T) AS 'Log',
SUM(l.U) AS 'Log_Used',
SUM(l.F) AS 'Log_Free'
FROM dbo.##Tbl_CombinedInfo l WHERE l.type = 'Log' GROUP BY l.DatabaseName ) AS y
ON x.DatabaseName = y.DatabaseName;
IF @Unit = 'KB'
UPDATE @Tbl_Final SET TOTAL = TOTAL * 1024,
used = used * 1024,
free = free * 1024,
Data = Data * 1024,
Data_Used = Data_Used * 1024,
Data_Free = Data_Free * 1024,
Log = Log * 1024,
Log_Used = Log_Used * 1024,
Log_Free = Log_Free * 1024;
IF @Unit = 'GB'
UPDATE @Tbl_Final SET TOTAL = TOTAL / 1024,
used = used / 1024,
free = free / 1024,
Data = Data / 1024,
Data_Used = Data_Used / 1024,
Data_Free = Data_Free / 1024,
Log = Log / 1024,
Log_Used = Log_Used / 1024,
Log_Free = Log_Free / 1024;
DECLARE @GrantTotal dec(11, 2);
SELECT @GrantTotal = SUM(TOTAL) FROM @Tbl_Final;
SELECT
CONVERT(dec(10, 2), TOTAL*100.0/@GrantTotal) AS 'WEIGHT (%)',
DatabaseName AS 'DATABASE',
CONVERT(VARCHAR(12), used) + ' (' + CONVERT(VARCHAR(12), [used (%)]) + ' %)' AS 'USED (%)',
[+],
CONVERT(VARCHAR(12), free) + ' (' + CONVERT(VARCHAR(12), [free (%)]) + ' %)' AS 'FREE (%)',
[=],
TOTAL,
[=],
CONVERT(VARCHAR(12), Data) + ' (' + CONVERT(VARCHAR(12), Data_Used) + ', ' +
CONVERT(VARCHAR(12), [Data_Used (%)]) + '%)' AS 'DATA (used, %)',
[+],
CONVERT(VARCHAR(12), Log) + ' (' + CONVERT(VARCHAR(12), Log_Used) + ', ' +
CONVERT(VARCHAR(12), [Log_Used (%)]) + '%)' AS 'LOG (used, %)'
FROM @Tbl_Final
WHERE DatabaseName LIKE ISNULL(@TargetDatabase, '%')
ORDER BY DatabaseName ASC;
IF @TargetDatabase IS NULL
SELECT CASE WHEN @Unit = 'GB' THEN 'GB' WHEN @Unit = 'KB' THEN 'KB' ELSE 'MB' END AS 'SUM',
SUM (used) AS 'USED',
SUM (free) AS 'FREE',
SUM (TOTAL) AS 'TOTAL',
SUM (Data) AS 'DATA',
SUM (Log) AS 'LOG'
FROM @Tbl_Final;
END
RETURN (0)
GO
</code></pre>
|
<p>I know this might sound a little arcanine but why not just stat the directory that contains the database.</p>
| 3,399
|
<p>I'm hosting Python script with Python for Delphi components inside my Delphi application. I'd like to create background tasks which keep running by script.</p>
<p>Is it possible to create threads which keep running even if the script execution ends (but not the host process, which keeps going on). I've noticed that the program gets stuck if the executing script ends and there is thread running. However if I'll wait until the thread is finished everything goes fine.</p>
<p>I'm trying to use "threading" standard module for threads.</p>
|
<p>Python has its own threading module that comes standard, if it helps. You can create thread objects using the threading module.</p>
<p><a href="https://docs.python.org/2/library/threading.html" rel="nofollow noreferrer">threading Documentation</a></p>
<p><a href="https://docs.python.org/3/library/threading.html" rel="nofollow noreferrer">thread Documentation</a></p>
<p>The thread module offers low level threading and synchronization using simple Lock objects.</p>
<p>Again, not sure if this helps since you're using Python under a Delphi environment.</p>
|
<p>Threads by definition are part of the same process. If you want them to keep running, they need to be forked off into a new process; see os.fork() and friends.</p>
<p>You'll probably want the new process to end (via exit() or the like) immediately after spawning the script.</p>
| 8,907
|
<p>Usually Flash and Flex applications are embedded on in HTML using either a combination of <code>object</code> and <code>embed</code> tags, or more commonly using JavaScript. However, if you link directly to a SWF file it will open in the browser window and without looking in the address bar you can't tell that it wasn't embedded in HTML with the size set to 100% width and height.</p>
<p>Considering the overhead of the HTML, CSS and JavaScript needed to embed a Flash or Flex application filling 100% of the browser window, what are the downsides of linking directly to the SWF file instead? What are the upsides?</p>
<p>I can think of one upside and three downsides: you don't need the 100+ lines of HTML, JavaScript and CSS that are otherwise required, but you have no plugin detection, no version checking and you lose your best SEO option (progressive enhancement).</p>
<p><em>Update</em> don't get hung up on the 100+ lines, I simply mean that the the amount of code needed to embed a SWF is quite a lot (and I mean including libraries like SWFObject), and it's just for displaying the SWF, which can be done without a single line by linking to it directly.</p>
|
<p>Upsides for linking directly to SWF file:</p>
<ul>
<li>Faster access</li>
<li>You know it's a flash movie even before you click on the link</li>
<li>Skipping the html & js files (You won't use CSS to display 100% flash movie anyway)</li>
</ul>
<p>Downsides:</p>
<ul>
<li>You have little control on movie defaults.</li>
<li>You can't use custom background colors, transparency etc.</li>
<li>You can't use flashVars to send data to the movie from the HTML</li>
<li>Can't use fscommand from the movie to the page</li>
<li>Movie proportions are never the same as the user's window's aspect ratio</li>
<li>You can't compensate for browser incompetability (The next new browser comes out and you're in trouble)</li>
<li>No SEO</li>
<li>No page title, bad if you want people to bookmark properly.</li>
<li>No plugin information, download links etc.</li>
<li>If your SWF connects to external data sources, you might have cross domain problems.</li>
<li>Renaming the SWF file will also rename the link. Bad for versioning.</li>
</ul>
<p>In short, for a complicated application - always use the HTML. For a simple animation movie you can go either way.</p>
|
<p>Adobe should be ashamed of themselves with the standard embed, which defeats the puprose of convention over configuration. Check ^swfobject (as mentioned above) or <a href="http://code.google.com/p/swfin/" rel="nofollow noreferrer">swfin</a></p>
| 7,756
|
<p>Any information on how to display the ODBC connections dialog and get the chosen ODBC back?</p>
|
<pre><code>// a_RootKey is Microsoft.Win32.RegistryKey
// DSN is a class not provided in this code sample - you can see what properties are needed from the usage below.
List<DSN> DsnList = new List<DSN>();
Microsoft.Win32.RegistryKey SearchKey = a_RootKey.OpenSubKey("SOFTWARE\\ODBC\\ODBC.INI\\ODBC Data Sources");
if (SearchKey != null)
{
foreach (string DsnName in SearchKey.GetValueNames() )
{
if ( (string)SearchKey.GetValue(DsnName) == "SQL Server" )
{
Microsoft.Win32.RegistryKey anotherkey = a_RootKey.OpenSubKey("SOFTWARE\\ODBC\\ODBC.INI\\" + DSNName);
DSN dsn = new DSN();
dsn.Name = DSNName;
dsn.Server = (string)anotherkey.GetValue("Server");
dsn.Database = (string)anotherkey.GetValue("Database");
dsn.Driver = (string)anotherkey.GetValue("Driver");
DsnList.Add(dsn);
}
}
}
return DsnList;
</code></pre>
|
<p>OK since no one seems to have an answer, how about iterating throught the ODBC connections by DBSource, I.e. SQLServer or MySQL</p>
| 9,015
|
<p>I am new to 3D printing which we all are/were at some point. I have <strong>no</strong> clue how to address the issue which likely is reason why I haven't found the solution yet. So if you see that this question has been posted elsewhere, please link it! Thanks!</p>
<p>I have had this issue for a while, however right now, one minute ago, it worked kind of. The text below is a description of the problem that very often occurs!</p>
<p>So the issue is basically the extruder. I have a Flashforge Adventurer 3. In it's software you have a <em>"Load"</em> and <em>"Change"</em> option which you change and load filament with. When I load filament it goes through the tube but it never exits the extruder. The common answer is that the nozzle is clogged. I have honestly checked this, it isn't the problem. I have cleaned it as Flashforge says and I have also been using really small metallic pins to push out <strong>all</strong> the filament. So that isn't the issue.</p>
<p>Sometimes the filament also gets stuck inside the tube. Or the Bowden tube I think it is called.</p>
<p>I did a test 10 minutes ago, it went through the tube smoothly. No filament came out at the other end however. I then changed the filament, which means I pulled it back. I then saw that a part of the filament had gotten stuck at the end of the tube. It didn't pull all the filament back, a very small bit of the filament had somehow gotten stuck?</p>
<p>As it doesn't extrude filament when I load the filament it has nothing with the calibration to do what I know. So my own conclusion would be that something between the tube and extruder is going crazy. And I know, that isn't a good conclusion. However I don't know how to address it as I said before.</p>
<p>I know that it's hard to troubleshoot a text, so I will upload a video for you guys reading this. I really just want my 3D printer working again as the company said it probably isn't anything wrong with the machine..</p>
<p>When the machine starts working again it prints, but not good. Here is a video of how hit prints a big "F". <a href="https://youtu.be/kis_jNTRgI0" rel="nofollow noreferrer">Link</a>. Sometimes it stops extruding filament for a while then it starts to extrude again..</p>
<p>There is also an image of the print below![<img src="https://i.stack.imgur.com/UeGmj.jpg" alt="Image" /></p>
<p>The machine is printing at 195 °C! I appreciate all the help I can get, I just want my machine fully working again.</p>
<hr />
<p>Here is a video of the Bowden tube: <a href="https://youtu.be/lFGUK6hUmkA" rel="nofollow noreferrer">Link</a></p>
<p>Here is a video of the extruder issue: <a href="https://youtu.be/Y6u2Pi2xINk" rel="nofollow noreferrer">Link</a></p>
<p>Here are two videos regarding the cold pull, I "try" to speak English so you get more information this time! <a href="https://youtu.be/ZfnNGwdTufI" rel="nofollow noreferrer">Link</a> <a href="https://youtu.be/IQmYHiYgoEo" rel="nofollow noreferrer">Link 2</a></p>
|
<p>This is opinion-based, but the volcano has drawbacks that affect print quality, mine is oozier and sloppier than a V6 with the shorter, more precise melt zone. It isn’t a slam dunk upgrade, more of a special applications part. I think there is no point to using a Volcano unless you’re running big nozzles fast, like .8 mm.</p>
<p>Your 5 mm<sup>3</sup>/s throughput is low, the V6 is generally known as a ~13 mm<sup>3</sup>/s volumetric throughput, vs the Volcano at 25 mm<sup>3</sup>/s. This is due to the low temperature you favor, possibly something not ideal with your extruder. I could see...</p>
<ul>
<li><p>just living with the slow speed. I realize I vastly prefer print quality over print speed because one takes no human interaction and the other does.</p>
</li>
<li><p>do what everyone else does. go hotter, plastic viscosity goes way down even with a 5-10 degree increase</p>
</li>
<li><p>increase extruder torque. If you can increase stepper current safely (know the limit for your driver and motor!) with a trim pot on the stepper driver, you may be able to get more torque before the motor skips steps. This can increase motor temperature. If you get more torque, at some point the filament will slip and get carved up by the extruder’s hobbed gear. Double geared extruder designs like Bondtech can grip the filament from both sides and get more traction on the filament if you want to get diabolical shoving the filament.</p>
</li>
<li><p>use a larger nozzle for faster printing at your preferred temp. I’m loving the .6 mm nozzle for bigger prints. It has most of the detail of the .4 mm but double the plastic comes out. A larger nozzle hole means less pressure in the nozzle at a given temp and extruder feed rate</p>
</li>
</ul>
<p>If you think the extruder might not be all it can be, try heating up the nozzle hotter than usual, and get the extruder going slow and steady, and pull a little on the filament by hand, see if it skips steps easily with a little resistance. It should pull pretty strong. I had a failing wire to my extruder that manifested in wimpy extrusion.</p>
|
<p>Yes, the Volcano or the Super Volcano allow for larger flow rate (typically when using larger nozzles), that is where they were designed for. Just the nozzle will not help you, you need this larger nozzle shaft to be inside a Volcano heater block, else you cannot transfer the heat.</p>
<p>According to measurements from Metaform, the volumetric flow of a Volcano hotend is larger than the regular E3D V6 hotend.</p>
<p><a href="https://i.stack.imgur.com/5p6Le.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5p6Le.png" alt="enter image description here" /></a></p>
| 1,653
|
<p>What's the most useful hack you've discovered for Mozilla's new <a href="https://wiki.mozilla.org/Labs/Ubiquity" rel="nofollow noreferrer">Ubiquity</a> tool?
</p>
|
<p>"translate this" and "edit-page". I think I'd find the Google Apps features useful if they supported hosted domains.</p>
|
<p>My co-worker has had 3 blue-screens on his machine since installing it. Not totally convinced this is what did it, but it's the only thing he's changed today. I'm uninstalling it for now (and so is he).</p>
| 5,108
|
<p>Here's an interesting problem. On a recently installed Server 2008 64bit I opened IE and through the Tools -> Options I changed the homepage to iGoogle.com. Clicked okay and then clicked the homepage button. IE crashes.</p>
<p>Now you'd think that I could just remove iGoogle as the homepage but when I open IE it immediately goes to that page and crashes on open.</p>
<p>Obviously I'd prefer to find a solution to why IE is crashing on the iGoogle page but just to get IE running again I need to remove iGoogle as the homepage. Is there anyway to do this without opening IE?</p>
|
<p>Control Panel -> Internet Options</p>
|
<p>Not sure about IE7 on Windows Server 2008, but for IE6 the start page is stored in a registry key "Start Page" in HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main.</p>
| 8,882
|
<p>My gcc build toolchain produces a .map file. How do I display the memory map graphically?</p>
|
<p>Here's the beginnings of a script in Python. It loads the map file into a list of Sections and Symbols (first half). It then renders the map using HTML (or do whatever you want with the <code>sections</code> and <code>symbols</code> lists).</p>
<p>You can control the script by modifying these lines:</p>
<pre><code>with open('t.map') as f:
colors = ['9C9F84', 'A97D5D', 'F7DCB4', '5C755E']
total_height = 32.0
</code></pre>
<p>map2html.py</p>
<pre><code>from __future__ import with_statement
import re
class Section:
def __init__(self, address, size, segment, section):
self.address = address
self.size = size
self.segment = segment
self.section = section
def __str__(self):
return self.section+""
class Symbol:
def __init__(self, address, size, file, name):
self.address = address
self.size = size
self.file = file
self.name = name
def __str__(self):
return self.name
#===============================
# Load the Sections and Symbols
#
sections = []
symbols = []
with open('t.map') as f:
in_sections = True
for line in f:
m = re.search('^([0-9A-Fx]+)\s+([0-9A-Fx]+)\s+((\[[ 0-9]+\])|\w+)\s+(.*?)\s*$', line)
if m:
if in_sections:
sections.append(Section(eval(m.group(1)), eval(m.group(2)), m.group(3), m.group(5)))
else:
symbols.append(Symbol(eval(m.group(1)), eval(m.group(2)), m.group(3), m.group(5)))
else:
if len(sections) > 0:
in_sections = False
#===============================
# Gererate the HTML File
#
colors = ['9C9F84', 'A97D5D', 'F7DCB4', '5C755E']
total_height = 32.0
segments = set()
for s in sections: segments.add(s.segment)
segment_colors = dict()
i = 0
for s in segments:
segment_colors[s] = colors[i % len(colors)]
i += 1
total_size = 0
for s in symbols:
total_size += s.size
sections.sort(lambda a,b: a.address - b.address)
symbols.sort(lambda a,b: a.address - b.address)
def section_from_address(addr):
for s in sections:
if addr >= s.address and addr < (s.address + s.size):
return s
return None
print "<html><head>"
print " <style>a { color: black; text-decoration: none; font-family:monospace }</style>"
print "<body>"
print "<table cellspacing='1px'>"
for sym in symbols:
section = section_from_address(sym.address)
height = (total_height/total_size) * sym.size
font_size = 1.0 if height > 1.0 else height
print "<tr style='background-color:#%s;height:%gem;line-height:%gem;font-size:%gem'><td style='overflow:hidden'>" % \
(segment_colors[section.segment], height, height, font_size)
print "<a href='#%s'>%s</a>" % (sym.name, sym.name)
print "</td></tr>"
print "</table>"
print "</body></html>"
</code></pre>
<p>And here's a bad rendering of the HTML it outputs:</p>
<p><img src="https://i.imgur.com/jsGhtBn.png" alt="Map"></p>
|
<p>I've written a C# program to display the information in a Map file along with information not usually present in the map file (like static symbols provided you can use <code>binutils</code>). The code is available <a href="https://github.com/govind-mukundan/MapViewer" rel="nofollow noreferrer">here</a>. In short it parses the map file and also uses <code>BINUTILS</code> (if available) to gather more information. To run it you need to download the code and run the project under visual studio, browse to the map file path and click <code>Analyze</code>.</p>
<p>Note: Only works for <code>GCC/LD</code> map files</p>
<p>Screenshot:
[<img src="https://i.stack.imgur.com/W9uZ9.png" alt="3]"></p>
| 7,084
|
<p>I have been learning C++ for a while now, I find it very powerful. But, the problem is the the level of abstraction is not much and I have to do memory management myself.
What are the languages that I can use which uses a higher level of abstraction.</p>
|
<p>Java, C#, Ruby, Python and JavaScript are probably the big choices before you.</p>
<p><a href="http://en.wikipedia.org/wiki/Java_(programming_language)" rel="noreferrer">Java</a> and <a href="http://en.wikipedia.org/wiki/C_Sharp" rel="noreferrer">C#</a> are not hugely different languages. This big difference you'll find from C++ is memory management (i.e. objects are automatically freed when they are no longer referenced). You would chose these if you were interested in desktop style applications, or keen on static typing (and you'd probably choose between them based on how you feel towards Microsoft and the Windows platform). In both cases you'll find much richer standard libraries than you'll be used to from C++.</p>
<p><a href="http://en.wikipedia.org/wiki/Python_(programming_language)" rel="noreferrer">Python</a> and <a href="http://en.wikipedia.org/wiki/Ruby_(programming_language)" rel="noreferrer">Ruby</a> take a step away from static typing, into a world where you can call and method on any object (and fail at runtime if it's not there). That is both a blessing (a lot less boilerplate code) and a curse (the compiler can't catch those errors for you anymore). Once again, you'll find they have richer standard libraries, and are higer level again than Java / C#. Performance is the main downfall, with Python being somewhat faster than Ruby as I understand it. To choose between them, you'd probably choose Ruby if you're interesting in web development for the Ruby on Rails framework community, and otherwise go with Python.</p>
<p><a href="http://en.wikipedia.org/wiki/JavaScript" rel="noreferrer">JavaScript</a> is even more different from C++ in that it does away with classes entirely. Objects are simply cloned from other objects and can have methods and properties added to them at runtime. Very flexible, but also very easy to make into a total mess. JavaScript is the only real choice if you're interested in running applications in a browser, which is really coming into its own as a platform. You'll find the standard libraries available rather limited if you're not doing a lot with the browser, but there are quite a few good frameworks which fill in some of the gaps.</p>
<p>Some other interesting, though more niche choices are</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Smalltalk" rel="noreferrer">Smalltalk</a> - More or less in the Ruby and Python camp, and significantly faster as I understand it. Be careful though _ I've seen lots of good engineers learn Smalltalk and never come back ;)</li>
<li><a href="http://en.wikipedia.org/wiki/Objective-C" rel="noreferrer">Objective-C</a> - When C went object oriented, C++ went one way (static typing), and Objective-C went the other (dynamic typing). It's quite Smalltalk inspired, and has a good standard library if you're in Mac / iPhone land. In terms of memory management, unlike everything else I've listed, it's not garbage collected (though that's now an option on Mac OS X 10.5), but it does have a reference counting scheme which makes life significantly simpler than managing memory by hand.</li>
<li><a href="http://en.wikipedia.org/wiki/Lisp_programming_language" rel="noreferrer">Lisp</a> - I've never learnt it myself beyond what I needed for minor Emacs hacking. As I understand it, the libraries were nice in their day, but though the language remains supremely elegant, they've fallen a little behind the times.</li>
<li><a href="http://en.wikipedia.org/wiki/Haskell_(programming_language)" rel="noreferrer">Haskel</a> - If you wanted a complete break from objects and classes, Haskel and it's functional approach is an interesting way to go (or Lisp as above, or <a href="http://en.wikipedia.org/wiki/F_Sharp_programming_language" rel="noreferrer">F#</a> if you are in .Net land). Basically, you're giving up loops and variables in favour of doing everything recursively. Takes some time to wrap your mind around, and probably isn't practical for most real world applications, but it's a good one to learn.</li>
<li><a href="http://en.wikipedia.org/wiki/Eiffel_(programming_language)" rel="noreferrer">Eiffel</a> - I love it - Very clean syntax, and designed for serious engineering type systems. Statically types like C# and Java, and with a weaker standard library, but it will make you really think about language and class library design.</li>
<li><a href="http://en.wikipedia.org/wiki/ActionScript" rel="noreferrer">ActionScript</a> and <a href="http://en.wikipedia.org/wiki/Adobe_Flex" rel="noreferrer">Flex</a> - The programming interface to Flash, which is based on what seems to be a statically typed version of JavaScript. I've played with it a bit, and it's quite slick if you're interested in developing media based applications. You can also push beyond the browser with Flex and into the <a href="http://en.wikipedia.org/wiki/Adobe_Integrated_Runtime" rel="noreferrer">Air</a> platform to build real desktop apps.</li>
</ul>
|
<p>Since you are already into C++, next step would be to learn .Net through <a href="http://www.ondotnet.com/pub/a/dotnet/2003/01/13/intromcpp.html" rel="nofollow noreferrer">managed C++</a> or managed extensions for C++..this will get you a step in the big world of .Net framework..Once you understand the framework, makes it more comfortable to learn other .Net languages like C#, VB.Net etc.</p>
<p><em>One of the areas that MC++ excels in, and is in fact unique in amongst the .NET languages, is the ability to take an existing unmanaged (C++) application, recompile it with the /clr switch, have it generate MSIL and then run under the CLR. This extraordinary feat is aptly termed "It Just Works (IJW)!" There are some limitations, but for the most part, the application will just run. The C++ code can consist of old-fashioned printf statements, MFC, ATL, or even templates!</em></p>
| 8,623
|
<p>Both are mathematical values, however the float does have more precision. Is that the only reason for the error - the difference in precision? Or is there another potential (and more serious) problem?</p>
|
<p>It's because the set of integer values does not equal the set of float values for the 'int' and 'float' types. For example, the float value 0.5 has no equal in the integer set and the integer value 4519245367 might not exist in the set of values a float can store. So, the checker flags this as an issue to be checked by the programmer.</p>
|
<p>If you need to get around this (you have a legitimate reason and are happy none of the issues mentioned in the other answers are an issue for you) then just cast from one type to another.</p>
| 5,894
|
<p>My company has tried to adopt the scrum methodology with mixed success. Theses are some areas where we've had issues. How do you handle these? </p>
<ol>
<li>Tracking requirements from
Product Marketing through to product. We're trying out JIRA to track all requirements individually and assigning a release to each one as it is picked for implementation.</li>
<li>Who creates stories? Product
Management who doesn't know enough
to create effectively small stories,
developers who may not have domain
knowledge, an analyst in between?</li>
<li>Functional specs
<ol>
<li>do you write them or just try to get them into a story
definition?</li>
<li>Do you write functional
specs per story? Per feature?</li>
<li>How do you see the relationship between functional specs and stories?</li>
</ol></li>
<li>answering the question from people
with VP in their title "what are we
going to get by [8 months from
now]?"</li>
</ol>
|
<p>Let's see if my take adds anything (not certain by any means...)</p>
<ol>
<li><p>I'm not sure about the "assigning a release to each one" thing. I thought the idea was to put a "price" on each story/function point/unit of development and pick what goes into the current sprint. Everything else is backlog - you can offer some indication of remaining effort (see <a href="http://www.fogcreek.com/FogBugz/learnmore.html?section=PredictShipDates" rel="nofollow noreferrer">evidence based scheduling</a> in FogBugz) but I don't think you should be allocating to specific sprints - you don't know what'll be in the backlog by the time you get there, for one thing. All you know is that it's going to change, so why waste time on it?</p></li>
<li><p>There should be a designated user representative. Or more than one, if domain knowledge can't be concentrated in one individual. But someone from the business domain should be in charge overall of deciding what goes into a sprint, subject to the effort available, of course. There can be a place for a Business Analyst type, but they need to be domain experts. If your user(s) can't write stories, even with your help (it's a co-operative thing, or should be) then you all need help. Consider getting a coach involved for a sprint or two.</p></li>
<li><p>You won't be writing functional specs in an Agile environment. You'll be writing code. Your user will be on hand at all times (or you're already exposed to significant risk) and they're your spec. The story tells you "what", and is going to be a small enough unit of work that you should be able to decide on "how" fairly quickly. And refactor. Always refactor. It's not an overhead, it's part of the process and your design won't evolve satisfactorily without it.</p></li>
<li><p>If you have VPs (hey, I'm a VP, we're not all bad!) who ask that sort of question, then parts of your company are not getting it yet. Choose someone (the person best able to deal with non-techies, perhaps, or maybe the person least able, since they clearly need the practice) to explain it to them. If what's built is important to them, perhaps their questions are an indication that someone's not as involved as they should be.</p></li>
</ol>
|
<p>If you are going to do anything in regards writing or designing code, one of the things you should always do, is write a spec, irrespective of whatever methodology you are using, wether it is Scrum, XP, Agile or SDLC. Many people who say that writing specs is so unagile and a monument to wasteful bureaucratic paperwork. The simple fact is that they are misguided when they say that code is the spec. </p>
<p>The clear fact is that a spec allows you to formulate your ideas and designs beforehand, and its much easier to change a spec than it is to change a program, especially if you are working outside the confines of simple LOB application. Specs ensure you have a clearer understanding of what is required when you start coding. </p>
<p>Its been show time and time again that teams that use specs, design better software.
In my opinion, if you hear anybody say the code is the spec, that is dogma, plain and simple, and is storing up huge maintainability problems for the future. </p>
<p>As an aside, I don't have anything against the Agile Manifesto or light management process centric methods like Scrum. I've used it in the past few years a number of times,
and it delivers. I've also seen good software down the drain, where an agile focus would have saved it. But it is no panacea or silver bullet. </p>
| 3,617
|
<p>Using C# .NET 2.0, I have a composite data class that does have the <code>[Serializable]</code> attribute on it. I am creating an <code>XMLSerializer</code> class and passing that into the constructor:</p>
<pre><code>XmlSerializer serializer = new XmlSerializer(typeof(DataClass));
</code></pre>
<p>I am getting an exception saying: </p>
<blockquote>
<p>There was an error reflecting type.</p>
</blockquote>
<p>Inside the data class there is another composite object. Does this also need to have the <code>[Serializable]</code> attribute, or by having it on the top object, does it recursively apply it to all objects inside?</p>
|
<p>Look at the inner exception that you are getting. It will tell you which field/property it is having trouble serializing. </p>
<p>You can exclude fields/properties from xml serialization by decorating them with the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.xml.serialization.xmlignoreattribute" rel="noreferrer"><code>[XmlIgnore]</code></a> attribute. </p>
<p><code>XmlSerializer</code> does not use the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.serializableattribute" rel="noreferrer"><code>[Serializable]</code></a> attribute, so I doubt that is the problem.</p>
|
<p>Also note that you cannot serialize user interface controls and that any object you want to pass onto the clipboard must be serializable otherwise it cannot be passed across to other processes.</p>
| 8,549
|
<p>I'm (surprisingly) having a problem getting my PEI substrate to stick to the heated bed surface. The ABS item being printed stuck great to the PEI surface. I've not seen anyone else post on this problem, but perhaps someone has seen it.</p>
<p>Note, this is the PRINT SURFACE warping, not the item being printed. That part went great with no delamination even on a large flat bottom.</p>
<p>I'm using 3M 468 adhesive to attach a PEI plastic sheet directly to the heated surface of my Flashforge Creator Pro printer. The heated bed is anodized black and the adhesive is a sheet cut to the requisite 6" X 9". It seemed fine and looked pretty good with few air bubbles when first attached, but the first print caused the edges of the PEI plastic to warp up from the corners of the bed. </p>
<p>It appears that the weak link is that the PEI detached from the adhesive. While this was not uniform, removal of the PEI sheet showed that 95% of the adhesive was still attached to the print bed.</p>
<p>The PEI has one glossy side and one matte side, and I chose to apply the adhesive to the matte side to get the glossy surface. Does this make a difference?</p>
<p>I applied the adhesive to the PEI surface just as it was after removing the protective plastic coating. I figured this was a clean as it was ever going to get.</p>
<p>I'd definitely appreciate some ideas on this.</p>
|
<p>Perhaps this is due to the aluminum build plate warping/crowning as it heats? I use a PEI print surface on my Monoprice Maker Select (Wanhao Di3), which has an 8.5"x8.5" build plate, and I've had no issues with the PEI coming unstuck. However, instead of attaching mine directly to the aluminum heated build plate, I attached it (using 3M 468) to a piece of Borosilicate glass, which is then attached to my aluminum build plate using silicone thermal heatsink pads. The rational for using a Borosilicate glass print surface is that a heated metal build surface is going to warp or move some, as the heat is coming from one side; the glass will not warp and so you have a completely flat surface on which to print (and the heatsink pads help make up the difference in surface geometry). I used <a href="http://3dprinterwiki.info/wiki/wanhao-duplicator-i3/duplicator-i3-basic-mods/adding-a-glass-bed/" rel="nofollow noreferrer">this 3dprinterwiki article</a> as the basis for my glass bed mod, and applied the PEI/adhesive using another source (which I've forgotten, possibly <a href="http://reprap.org/wiki/PEI_build_surface" rel="nofollow noreferrer">the RepRap wiki</a>). While the first link is Wanhao Di3 specific, it covers the idea. Make sure you tweak your z-endstops if needed on your particular machine, as adding the glass plat raises the bed height by several mm.</p>
<p>Please note that I'm theorizing - I did not ever try applying my PEI directly to my aluminum build plate, so I have no direct comparison. But the use of glass to eliminate build plate warping/crowning is fairly well documented. See also <a href="https://3dprinting.stackexchange.com/a/506/2541">this 3DPSE Answer</a>.</p>
|
<p>I never used one, but the thing that makes two parts stick together is the atmospheric pressure. The glue is just a thing that, even if it does not make any chemical bond, is keeping the air out. A pure example of that is if you put water in a glass and then put another one on it. Although the water is not glue you can't easily pull it up and if the surface is big you can't at all. It is the atmospheric pressure that keeps them together and the water keeps the air out ;). I suggest try the other side and see I'm just guessing . Good luck!!!</p>
| 493
|
<p>I'm trying to come up with a design for a thread pool with a lot of design requirements for my job. This is a real problem for working software, and it's a difficult task. I have a working implementation but I'd like to throw this out to SO and see what interesting ideas people can come up with, so that I can compare to my implementation and see how it stacks up. I've tried to be as specific to the requirements as I can.</p>
<p>The thread pool needs to execute a series of tasks. The tasks can be short running (<1sec) or long running (hours or days). Each task has an associated priority (from 1 = very low to 5 = very high). Tasks can arrive at any time while the other tasks are running, so as they arrive the thread pool needs to pick these up and schedule them as threads become available.</p>
<p>The task priority is completely independant of the task length. In fact it is impossible to tell how long a task could take to run without just running it.</p>
<p>Some tasks are CPU bound while some are greatly IO bound. It is impossible to tell beforehand what a given task would be (although I guess it might be possible to detect while the tasks are running).</p>
<p>The primary goal of the thread pool is to maximise throughput. The thread pool should effectively use the resources of the computer. Ideally, for CPU bound tasks, the number of active threads would be equal to the number of CPUs. For IO bound tasks, more threads should be allocated than there are CPUs so that blocking does not overly affect throughput. Minimising the use of locks and using thread safe/fast containers is important.</p>
<p>In general, you should run higher priority tasks with a higher CPU priority (ref: SetThreadPriority). Lower priority tasks should not "block" higher priority tasks from running, so if a higher priority task comes along while all low priority tasks are running, the higher priority task will get to run.</p>
<p>The tasks have a "max running tasks" parameter associated with them. Each type of task is only allowed to run at most this many concurrent instances of the task at a time. For example, we might have the following tasks in the queue:</p>
<ul>
<li>A - 1000 instances - low priority - max tasks 1</li>
<li>B - 1000 instances - low priority - max tasks 1</li>
<li>C - 1000 instances - low priority - max tasks 1</li>
</ul>
<p>A working implementation could only run (at most) 1 A, 1 B and 1 C at the same time.</p>
<p>It needs to run on Windows XP, Server 2003, Vista and Server 2008 (latest service packs).</p>
<hr>
<p>For reference, we might use the following interface:</p>
<pre><code>namespace ThreadPool
{
class Task
{
public:
Task();
void run();
};
class ThreadPool
{
public:
ThreadPool();
~ThreadPool();
void run(Task *inst);
void stop();
};
}
</code></pre>
|
<p>So what are we going to pick as the basic building block for this. Windows has two building blocks that look promising :- I/O Completion Ports (IOCPs) and Asynchronous Procedure Calls (APCs). Both of these give us FIFO queuing without having to perform explicit locking, and with a certain amount of built-in OS support in places like the scheduler (for example, IOCPs can avoid some context switches).</p>
<p>APCs are perhaps a slightly better fit, but we will have to be slightly careful with them, because they are not quite "transparent". If the work item performs an alertable wait (::SleepEx, ::WaitForXxxObjectEx, etc.) and we accidentally dispatch an APC to the thread then the newly dispatched APC will take over the thread, suspending the previously executing APC until the new APC is finished. This is bad for our concurrency requirements and can make stack overflows more likely.</p>
|
<p>@DrPizza - this is a very good question, and one that strikes right to the heart of the problem. There are a few reasons why QueueUserWorkItem and the Windows NT thread pool was ruled out (although the Vista one does look interesting, maybe in a few years).</p>
<p>Firstly, we wanted to have greater control over when it starts up and stops threads. We have heard that the NT thread pool is reluctant to start up a new thread if it thinks that the tasks are short running. We could use the WT_EXECUTELONGFUNCTION, but we really have no idea if the task is long or short</p>
<p>Secondly, if the thread pool was already filled up with long running, low priority tasks, there would be no chance of a high priority task getting to run in a timely manner. The NT thread pool has no real concept of task priorities, so we can't do a QueueUserWorkItem and say "oh by the way, run this one right away".</p>
<p>Thirdly, (according to MSDN) the NT thread pool is not compatible with the STA apartment model. I'm not sure quite what this would mean, but all of our worker threads run in an STA.</p>
| 5,939
|
<p><strong>Is it possible to use <code>OpenID</code> for <em>both</em> <code>.NET</code> web sites and <code>PHP</code> websites (Apache/Linux)?</strong> </p>
<p>I have a manager that wants <em>single sign-on for access to any/all web sites, regardless of which web server hosts a web site</em>. </p>
<p>I create <code>.NET</code> web apps and the <code>PHP</code> web sites/apps are done by another programmer. </p>
<p>How would I go about using <code>OpenID</code> for a <code>.NET</code> web app? </p>
<p>What about for the <code>PHP</code> programmer?</p>
|
<p>For .NET: <a href="http://code.google.com/p/dotnetopenid/" rel="nofollow noreferrer">http://code.google.com/p/dotnetopenid/</a></p>
<p>For PHP: <a href="http://openidenabled.com/php-openid/" rel="nofollow noreferrer">http://openidenabled.com/php-openid/</a></p>
|
<p>use the following library:</p>
<p><a href="http://code.google.com/p/dotnetopenid" rel="nofollow noreferrer">http://code.google.com/p/dotnetopenid</a></p>
| 9,124
|
<p>I have class method that returns a list of employees that I can iterate through. What's the best way to return the list? Typically I just return an ArrayList. However, as I understand, interfaces are better suited for this type of action. Which would be the best interface to use? Also, why is it better to return an interface, rather than the implementation (say ArrayList object)? It just seems like a lot more work to me.</p>
|
<p>Personally, I would use a <a href="http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx" rel="nofollow noreferrer">List</a><Employee> for creating the list on the backend, and then use <a href="http://msdn.microsoft.com/en-us/library/5y536ey6.aspx" rel="nofollow noreferrer">IList</a> when you return. When you use interfaces, it gives you the flexability to change the implementation without having to alter who's using your code. If you wanted to stick with an ArrayList, that'd be a non-generic <a href="http://msdn.microsoft.com/en-us/library/system.collections.ilist.aspx" rel="nofollow noreferrer">IList</a>.</p>
|
<p>Return type for your method should be <code>IList<Employee></code>. </p>
<p>That means that the caller of your method can use anything that <code>IList</code> offers but cannot use things specific to <code>ArrayList</code>. Then if you feel at some point that <code>LinkedList</code> or <code>YourCustomSuperDuperList</code> offers better performance or other advantages you can safely use it within your method and not screw callers of it.</p>
<p>That's roughly interfaces 101. ;-)</p>
| 5,062
|
<p>The first language I learnt was PHP, but I have more recently picked up Python. As these are all 'high-level' languages, I have found them a bit difficult to pick up. I also tried to learn Objective-C but I gave up.</p>
<p>So, what language should I learn to bridge between Python to C</p>
|
<p>It's not clear why you need a bridge language. Why don't you start working with C directly? C is a very simple language itself. I think that hardest part for C learner is pointers and everything else related to memory management. Also C lang is oriented on structured programming, so you will need to learn how to implement data structures and algorithms without OOP goodness. Actually, your question is pretty hard, usually people go from low level langs to high level and I can understand frustration of those who goes in other direction.</p>
|
<p>I'm feeling your pain, I also learned PHP first and I'm trying to learn C++, it's not easy, and I am really struggling, It's been 2 years since I started on c++ and Still the extent of what I can do is cout, cin, and math.</p>
<p>If anyone reads this and wonders where to start, START LOWER.</p>
| 7,166
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.