instruction
stringlengths 21
27.8k
| chosen
stringlengths 18
28.2k
| rejected
stringlengths 18
33.6k
| __index_level_0__
int64 0
50k
|
|---|---|---|---|
<p>I am having difficulty determining if the body of a text email message is base64 encoded.
if it is then use this line of code;
making use of jython 2.2.1</p>
<pre><code>dirty=base64.decodebytes(dirty)
</code></pre>
<p>else continue as normal.</p>
<p>This is the code I have atm. What line of code will allow me to extract this from the email: </p>
<p>"Content-Transfer-Encoding: base64" </p>
<pre><code>import email, email.Message
import base64
def _get_email_body(self):
try:
parts=self._email.get_payload()
check=parts[0].get_content_type()
if check=="text/plain":
part=parts[0].get_payload()
enc = part[0]['Content-Transfer-Encoding']
if enc == "base64":
dirty=base64.decodebytes(dirty)
elif check=="multipart/alternative":
part=parts[0].get_payload()
enc = part[0]['Content-Transfer-Encoding']
if part[0].get_content_type()=="text/plain":
dirty=part[0].get_payload()
if enc == "base64":
dirty=base64.decodebytes(dirty)
else:
return "cannot obtain the body of the email"
else:
return "cannot obtain the body of the email"
return dirty
except:
raise
</code></pre>
<p>OKAY this code works now! thanks all</p>
|
<p>Try:</p>
<pre><code>enc = msg['Content-Transfer-Encoding']
</code></pre>
<p>It's a header so you won't be able to get it looking at the body. You should be able to get at the same place you find out the Subject.</p>
|
<p>It is a header but you have to get the payload first from the message.</p>
<p>It'll be:</p>
<pre><code>header = msg.get_payload()[0]
header['Content-Transfer-Encoding']
</code></pre>
<p>I'm using Python 3</p>
| 42,077
|
<p>What is the difference between <code>IQueryable<T></code> and <code>IEnumerable<T></code>?</p>
<hr>
<p>See also <a href="https://stackoverflow.com/questions/2433306/whats-the-difference-between-iqueryable-and-ienumerable?rq=1">What's the difference between IQueryable and IEnumerable</a> that overlaps with this question.</p>
|
<p>The primary difference is that the LINQ operators for <code>IQueryable<T></code> take <code>Expression</code> objects instead of delegates, meaning the custom query logic it receives, e.g., a predicate or value selector, is in the form of an expression tree instead of a delegate to a method.</p>
<ul>
<li><code>IEnumerable<T></code> is great for working with sequences that are iterated in-memory, but</li>
<li><code>IQueryable<T></code> allows for out-of memory things like a remote data source, such as a database or web service.</li>
</ul>
<h3>Query execution:</h3>
<ul>
<li><p>Where the execution of a query is going to be performed <strong>"in process"</strong>, typically all that's required is the code (as code) to execute each part of the query.</p>
</li>
<li><p>Where the execution will be performed <strong>out-of-process</strong>, the logic of the query has to be represented in data such that the LINQ provider can convert it into the appropriate form for the out-of-memory execution - whether that's an LDAP query, SQL or whatever.</p>
</li>
</ul>
<p>More in:</p>
<ul>
<li><a href="https://web.archive.org/web/20200720162730/https://social.technet.microsoft.com/wiki/contents/articles/19666.net-framework-ienumerable-t-vs-iqueryable-t.aspx" rel="noreferrer">LINQ : <code>IEnumerable<T></code> and <code>IQueryable<T></code></a></li>
<li><a href="https://web.archive.org/web/20201127014808/https://odetocode.com/Articles/738.aspx" rel="noreferrer">C# 3.0 and LINQ</a>.</li>
<li>"<a href="https://stackoverflow.com/questions/2876616/returning-ienumerablet-vs-iqueryablet/2876655#2876655">Returning <code>IEnumerable<T></code> vs <code>IQueryable<T></code></a>"</li>
<li><a href="https://www.codeproject.com/Articles/646361/Reactive-Programming-For-NET-And-Csharp-Developers" rel="noreferrer">Reactive Programming for .NET and C# Developers - An Introduction To <code>IEnumerable</code>, <code>IQueryable</code>, <code>IObservable</code>, and <code>IQbservable</code></a></li>
<li>2008: "<a href="https://web.archive.org/web/20170708130544/http://bartdesmet.net/blogs/bart/archive/2008/08/15/the-most-funny-interface-of-the-year-iqueryable-lt-t-gt.aspx" rel="noreferrer">THE MOST FUNNY INTERFACE OF THE YEAR … <code>IQUERYABLE<T></code></a>" from <a href="http://bartdesmet.net" rel="noreferrer">Bart De Smet</a>.</li>
</ul>
<p><img src="https://i.stack.imgur.com/2DAqv.jpg" alt="http://www.codeproject.com/KB/cs/646361/WhatHowWhere.jpg" /></p>
|
<p>ienumerable:when we want to deal with inprocess memory, i.e without dataconnection
iqueryable:when to deal with sql server, i.e with data connection
ilist : operations like add object, delete object etc</p>
| 31,493
|
<p>Is there a way to programmatically find the location of the current user's Outlook .pst file(s) through an API call or registry entry?</p>
|
<p>With <a href="http://www.dimastr.com/redemption/" rel="noreferrer">Outlook Redemption</a>, you can iterate the message stores in VBA using <code>RDOStores</code>collection, accessible via the <code>RDOSession.Stores</code> property.</p>
<p>I am looking into the possibility of doing something similar in out-of-the-box VBA...</p>
<p>EDIT:</p>
<p>Obviously, the path to the PST is encoded in the StoreId string. Google turned up <a href="http://www.devnewsgroups.net/group/microsoft.public.office.developer.outlook.vba/topic42609.aspx" rel="noreferrer">this</a>:</p>
<pre><code>Sub PstFiles()
Dim f As MAPIFolder
For Each f In Session.Folders
Debug.Print f.StoreID
Debug.Print GetPathFromStoreID(f.StoreID)
Next f
End Sub
Public Function GetPathFromStoreID(sStoreID As String) As String
On Error Resume Next
Dim i As Long
Dim lPos As Long
Dim sRes As String
For i = 1 To Len(sStoreID) Step 2
sRes = sRes & Chr("&h" & Mid$(sStoreID, i, 2))
Next
sRes = Replace(sRes, Chr(0), vbNullString)
lPos = InStr(sRes, ":\")
If lPos Then
GetPathFromStoreID = Right$(sRes, (Len(sRes)) - (lPos - 2))
End If
End Function
</code></pre>
<p>Just tested, works as designed.</p>
|
<p>The path should be somewhere under:</p>
<blockquote>
<p>[HKEY_CURRENT_USER\Software\Microsoft\Windows
NT\CurrentVersion\Windows Messaging
Subsystem\Profiles\Outlook]</p>
</blockquote>
<p>Maybe this helps a bit.</p>
| 23,802
|
<p>It seems like searching with CAML and SPQuery doesn't work properly against custom metadata, when searching for SPFolders instead of files, or when searching for custom content types. I've been using U2U to test a variety of queries, and just not getting anywhere. The doc's aren't very complete on the topic, and google isn't helping either.</p>
<p>In one test, I'm trying to locate any SPFolders in the tree that are a specific custom content-type. If I understand CAML correctly, this should work:</p>
<pre><code><Query>
<Where>
<Eq>
<FieldRef Name='ContentType' />
<Value Type='Text'>CustomTypeName</Value>
</Eq>
</Where>
</Query>
</code></pre>
<p>In another test, I'm trying to locate any SPFolder that has a custom metadata property set to a specific value.</p>
<pre><code><Query>
<Where>
<Eq>
<FieldRef Name='CustomProp' />
<Value Type='Text'>SpecificPropValue</Value>
</Eq>
</Where>
</Query>
</code></pre>
<p>In both cases, I'm setting the root for the search to a document library that contains folders, which contain folders, which contain folders (phew.) Also, I'm setting the SPQuery to search recursively.</p>
<p>The folder I'm searching for a two steps down are the farthest down in the tree. I don't want to iterate all the way in to manually locate the folders in question.</p>
<p><strong>EDIT</strong> It might also be helpful to know that I'm using both SPList.GetItems with an SPQuery as an argument, and SPWeb.GetSiteData with an SPSiteDataQuery as an argument. At the moment it appears that folders aren't included in the search-set for either of these queries.</p>
<p>Any help would be greatly appreciated.</p>
|
<p>After more research, I'm answering my own question.</p>
<p>Apparently the methods that I'm using to query don't return SPFolders as items in the result set. Only list items are returned, basically just documents.</p>
<p>My fix was to execute a CAML query for all the documents with a certain metadata tag/value, and then using the parent folder of the first one as the representative folder for the set. Works well enough for my needs.</p>
|
<p>Try adding <a href="http://www.codeplex.com/spm" rel="nofollow noreferrer">SharePoint Manager</a> and <a href="http://www.codeplex.com/SPCamlViewer" rel="nofollow noreferrer">Stramit CAML Viewer</a> to your toolset.</p>
<p>I have found both to be very important for figuring out CAML problems.</p>
| 21,047
|
<p>SQL Server 2005 introduced <a href="http://msdn.microsoft.com/en-us/library/ms175887.aspx" rel="nofollow noreferrer">Database Mail</a> for sending e-mail messages from the SQL Server Database Engine in a robust fashion. Database Mail comes with a number of interesting <a href="http://msdn.microsoft.com/en-us/library/ms188023.aspx" rel="nofollow noreferrer">views</a> like <code>sysmail_allitems</code>, <code>sysmail_sentitems</code>, <code>sysmail_faileditems</code>, <code>sysmail_unsentitems</code>, <code>sysmail_mailattachments</code> and <code>sysmail_event_log</code>. Is there any known stand-alone and friendly web front-end (preferably in ASP.NET) on top of these views that can be used by administrators (and ideally also users) for trouble-shooting and monitoring?</p>
|
<p>No there is not. You can query the DMVs manually to view the data within them. Setting up any sort of pretty interface wouldn't be of much use as you can't do anything with those DMVs besides look at them.</p>
<p>Database mail is a pretty robust system.</p>
<p>What specific issues are you trying to troubleshoot?</p>
|
<p>None that I know of. What kind of users would be poking around in the back-end - what would they be doing? Once things are set up, the mail process seems to run pretty smoothly. Are you having frequent problems?</p>
| 46,989
|
<p>I'm currently working on an application with a frontend written in Adobe Flex 3. I'm aware of <a href="http://code.google.com/p/as3flexunitlib/" rel="noreferrer">FlexUnit</a> but what I'd really like is a unit test runner for Ant/NAnt and a runner that integrates with the Flex Builder IDE (AKA Eclipse). Does one exist? </p>
<p>Also, are there any other resources on how to do Flex development "the right way" besides the <a href="http://labs.adobe.com/wiki/index.php/Cairngorm" rel="noreferrer">Cairngorm microarchitecture</a> example?</p>
|
<p>The <a href="http://code.google.com/p/dpuint/" rel="noreferrer">dpUint</a> testing framework has a test runner built with AIR which can be integrated with a build script.</p>
<p>There is also my <a href="http://developer.iconara.net/objectlib/flexunitautomation.html" rel="noreferrer">FlexUnit</a> automation kit which does more or less the same for FlexUnit. It has an Ant macro that makes it possible to run the tests as a part of an Ant script, for example:</p>
<pre><code><target name="run-tests" depends="compile-tests">
<flexunit swf="${build.home}/tests.swf" failonerror="true"/>
</target>
</code></pre>
|
<p>An alternative to FlexUnit is the <a href="http://www.asunit.org/" rel="nofollow noreferrer">AsUnit</a> testing tools. There are versions for actionscript 2 and 3. It also has good integration with <a href="http://www.projectsprouts.org/" rel="nofollow noreferrer">Project Sprouts</a>, which is a build tool for Flex and Flash similar to ant, however it uses ruby rake tasks and includes excellent dependency management along the lines of maven.</p>
<p>No IDE integration that I know of however.</p>
| 2,440
|
<p>Anyone have any good urls for templates or diagram examples in Visio 2007 to be used in software architecture?</p>
|
<p><a href="http://softwarestencils.com/uml/index.html" rel="noreferrer">Here is a link</a> to a Visio Stencil and Template for UML 2.0.</p>
|
<p>There should be templates already included in Visio 2007 for software architecture but you might want to check out <a href="http://office.microsoft.com/en-us/templates/CT102115841033.aspx" rel="nofollow noreferrer">Visio 2007 templates</a>.</p>
| 4,055
|
<p>I'm trying to put together a blog, and have gone with SubText and I've just installed SyntaxHighlighter but it doesn't seem to work properly. SubText or FCKEditor seems to tamper with the HTMl, inlineing everything in the pre tags and placing line-breaks at the end of each line.</p>
<p>Bad times!</p>
<p>Anyone know how to stop this?</p>
|
<p>in FCKEditor its related to a bug in IE where innerHTML is rendered incorrectly in <strong>pre</strong> tags. Its a common problem.</p>
<p>I've written a plugin for FCKEditor that uses SyntaxHighlighter to format code correctly. You can read about it <a href="http://www.psykoptic.com/blog/post/2008/12/01/Code-Syntax-Highlight-Plugin-for-FCKeditor.aspx" rel="nofollow noreferrer">here</a>.</p>
|
<p>This is caused by how each browser implements HTML design mode, and unfortunately, they all seem to mangle perfectly good HTML. There's no option to prevent this behavior, but some post processing could be done with JavaScript using regular expressions to tidy things up (or using a <a href="http://ejohn.org/blog/pure-javascript-html-parser/" rel="nofollow noreferrer">JS HTML parser</a>.)</p>
| 11,823
|
<p>Not entirely sure what's going on here; any help would be appreciated.</p>
<p>I'm trying to create a new .NET MVC web app. I was pretty sure I had it set up correctly, but I'm getting the following error:</p>
<pre><code>The type 'System.Web.Mvc.ViewPage' is ambiguous: it could come from assembly
'C:\MyProject\bin\System.Web.Mvc.DLL' or from assembly
'C:\MyProject\bin\MyProject.DLL'. Please specify the assembly explicitly in the type name.
</code></pre>
<p>The source error it reports is as follows:</p>
<pre><code>Line 1: <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
Line 2:
Line 3: <asp:Content ID="indexContent" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
</code></pre>
<p>Anything stand out that I'm doing completely wrong?</p>
|
<p>Are you using a CodeBehind file, I don't see CodeBehind="" attribute where you are specifying the Inherits from? Then you have to point inherits to the class name of the codebehind.</p>
<p>Example:</p>
<pre><code><%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="MvcApplication4.Views.Home.Index" %>
</code></pre>
<p>Make sure the Inherits is fully qualified. It should be the namespace followed by the class name.</p>
|
<p>No this should be a structural error message.</p>
<p>Check <a href="http://trikks.wordpress.com/2011/08/26/the-type-is-ambiguous-it-could-come-from-assembly-or-from-assembly-please-specify-the-assembly-explicitly-in-the-type-name/" rel="nofollow">http://trikks.wordpress.com/2011/08/26/the-type-is-ambiguous-it-could-come-from-assembly-or-from-assembly-please-specify-the-assembly-explicitly-in-the-type-name/</a></p>
| 7,107
|
<p>I have the following situation:</p>
<p>I have a certain function that runs a loop and does stuff, and error conditions may make it exit that loop.
I want to be able to check whether the loop is still running or not.</p>
<p>For this, i'm doing, for each loop run:</p>
<pre><code>LastTimeIDidTheLoop = new Date();
</code></pre>
<p>And in another function, which runs through SetInterval every 30 seconds, I want to do basically this:</p>
<pre><code>if (LastTimeIDidTheLoop is more than 30 seconds ago) {
alert("oops");
}
</code></pre>
<p>How do I do this?</p>
<p>Thanks!</p>
|
<p>what about:</p>
<pre><code>newDate = new Date()
newDate.setSeconds(newDate.getSeconds()-30);
if (newDate > LastTimeIDidTheLoop) {
alert("oops");
}
</code></pre>
|
<p>Create a date object and use setSeconds().</p>
<pre><code>controlDate = new Date();
controlDate.setSeconds(controlDate.getSeconds() + 30);
if (LastTimeIDidTheLoop > controlDate) {
...
</code></pre>
| 45,300
|
<p>We offer a number of online services. We are required to develop a system which provides a quick/simple experience for users if they are transferred from one service (on <code>domain1.com</code>) to another service (on <code>domain2.com</code>).</p>
<p>Is there a safe and secure way to log a user in automatically once he has been transferred to the new service?</p>
<p>Yell at me if the solution below is completely insecure/wrong.</p>
<p>We were considering a system similar to that provided by a number of online services for password recovery - they are emailed a link with a unique hash which expires, that allows them to change their password.</p>
<p>The <code>domain1.com</code> site would generate a unique hash and store it in a database with the hash linked to a user along with an expire datetime field.</p>
<p>The user will be transferred to <code>domain2.com/auto/?hash=d41d8cd98f00b204e9800998ecf8427e</code></p>
<p><code>domain2.com</code> would next make a request to <code>domain1.com</code> with the hash to get the information about the user. <code>domain1.com</code> would then remove the hash from the database. <code>domain2.com</code> would log the user in and set cookies, etc.</p>
<p>Could something based on OpenID or OAuth achieve the same results?</p>
|
<p><strong>Single sign-on</strong> (SSO) is conceptually pretty simple.</p>
<ul>
<li>User hits <code>domain1.com</code>.</li>
<li><code>domain1.com</code> sees there's no session cookie.</li>
<li><code>domain1.com</code> redirects to <code>sso.com</code></li>
<li><code>sso.com</code> presents login page, and take credentials</li>
<li><code>sso.com</code> sets session cookie for the user</li>
<li><code>sso.com</code> then redirects back to <code>domain1</code> to a special url (like <code>domain1.com/ssologin</code>)</li>
<li>the <code>ssologin</code> URL contains a parameter that is basically "signed" by the <code>sso.com</code>. It could be as simple as a base64 of encrypting the loginid using a shared secret key.</li>
<li><code>domain1.com</code> takes the encrypted token, decrypts it, uses the new login id to log in the user.</li>
<li><code>domain1</code> sets the session cookie for the user.</li>
</ul>
<p>Now, the next case.</p>
<ul>
<li>User hits <code>domain2.com</code>, which follows <code>domain1</code> and redirects to <code>sso.com</code></li>
<li><code>sso.com</code> already has a cookie for the user, so does not present the login page</li>
<li><code>sso.com</code> redirects back to <code>domain2.com</code> with the encrypted information</li>
<li><code>domain2.com</code> logs in the user.</li>
</ul>
<p>That's the fundamentals of how this works. You can make it more robust, more feature rich (for example, this is <strong>SSOn</strong>, but not <strong>SSOff</strong>, user can "log out" of <code>domain1</code>, but still be logged in to <code>domain2</code>). You can use <strong>public keys</strong> for signing credentials, you can have requests to transfer more information (like authorization rights, etc) from the SSO server. You can have more intimate integration, such as the domains routinely checking that the user still has rights from the SSO server.</p>
<p>But the <strong>cookie handshake</strong> via the browser using redirects is the key foundation upon which all of these SSO solutions are based.</p>
|
<p>What about SEO?
It looks like every request before succesfull login is redirected to other domain and back.
I would tell that this is very ugly.
What headers should you send? 301 to SSO and then back 301 to original page? So search bot is "requested" to change his index for that page twice?</p>
| 44,509
|
<h1>Outline</h1>
<p>OK, I have Google'd this and already expecting a big fat <strong>NO!!</strong> But I thought I should ask since I know sometimes there can be the odd little gem of knowledge lurking around in peoples heads ^_^</p>
<p>I am working my way through some excercises in a book for study, and this particular exercise is User Controls. I have cobbled together a control and would like to set the DefaultEvent for it (having done this for previous controls) so when I double-click it, the default event created is whatever I specify it to be. </p>
<p><strong>NOTE:</strong> This is a standard User Control (.ascx), <em>NOT</em> a custom rendered control.</p>
<h2>Current Code</h2>
<p>Here is the class & event definition:</p>
<pre><code>[System.ComponentModel.DefaultEvent("OKClicked")]
public partial class AddressBox : System.Web.UI.UserControl
{
public event EventHandler OKClicked;
</code></pre>
<h2>Current Result</h2>
<p>Now, when I double click the the control when it is on a ASPX page, the following is created:</p>
<pre><code> protected void AddressBox1_Load(object sender, EventArgs e)
{
}
</code></pre>
<p>Not quite what I was expecting! So, my question:</p>
<h2>Is it possible to define a DefaultEvent for a UserControl? Is it a hack? If it's [not] supported, is there a reason?</h2>
<hr>
<p><strong>Side Note</strong>: How do we put underscores in code? I cant seem to put and escape char in?</p>
|
<p>I think to be honest you a better just boning up on your standard design patterns and applying them to the individual problems that you face in developing your UI.</p>
<p>While there are common UI "themes" (such as dealing with modifier keys) the actual implementation may vary widely.</p>
<p>I have O'Reilly's <a href="http://www.amazon.co.uk/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.co.uk%2FHead-First-Design-Patterns%2Fdp%2F0596007124%2Fref%3Dpd_bbs_sr_1%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1218730650%26sr%3D1-1&tag=robcthegeek-21&linkCode=ur2&camp=1634&creative=6738" rel="nofollow noreferrer">Head First Design Patterns</a> and <a href="http://www.amazon.co.uk/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.co.uk%2FHead-First-Design-Patterns-Poster%2Fdp%2F0596102143%2Fref%3Dpd_bbs_sr_3%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1218730650%26sr%3D1-3&tag=robcthegeek-21&linkCode=ur2&camp=1634&creative=6738" rel="nofollow noreferrer">The Poster</a>, which I have found invaluable!</p>
<h3>Shameless Plug : These links are using my associates ID.</h3>
|
<p>I don't think the that benefit of design patterns come from trying to find a design pattern to fit a problem. You can however use some heuristics to help clean up your design in this quite a bit, like keeping the UI as decoupled as possible from the rest of the objects in your system.</p>
<p>There is a pattern that might help out in this case, the <a href="http://en.wikipedia.org/wiki/Observer_pattern" rel="nofollow noreferrer">Observer Pattern</a>.</p>
| 3,240
|
<p>For this directory structure:</p>
<pre><code>.
|-- README.txt
|-- firstlevel.rb
`-- lib
|-- models
| |-- foo
| | `-- fourthlevel.rb
| `-- thirdlevel.rb
`-- secondlevel.rb
3 directories, 5 files
</code></pre>
<p>The glob would match: </p>
<pre><code>firstlevel.rb
lib/secondlevel.rb
lib/models/thirdlevel.rb
lib/models/foo/fourthlevel.rb
</code></pre>
|
<p>Apologies if I've missed the real point of the question but, if I was using sh/bash/etc., then I would probably use <em>find</em> to do the job:</p>
<pre><code>find . -name '*.rb' -type f
</code></pre>
<p>Globs can get a bit nasty when used from within a script and <em>find</em> is much more flexible.</p>
|
<p>Looks like it can't be done from <code>bash</code></p>
<p>If you using <code>zsh</code> then</p>
<pre><code>ls **/*.rb
</code></pre>
<p>will produce the correct result. </p>
<p>Otherwise you can hijack the <code>ruby</code> interpreter (and probably those of other languages) </p>
<pre><code>ruby -e "puts Dir.glob('**/*.rb')"
</code></pre>
<p>Thanks to Chris and Gaius for your answers.</p>
| 6,625
|
<p>In (Visual Basic, .NET):</p>
<pre><code> Dim result As Match = Regex.Match(aStr, aMatchStr)
If result.Success Then
Dim result0 As String = result.Groups(0).Value
Dim result1 As String = result.Groups(1).Value
End If
</code></pre>
<p>With: aStr equal to (whitespace is normal space and there are seven spaces between <code>n</code> and <code>(</code>):</p>
<pre><code>"AMEVDIEERPK + 7 Oxidation &nbsp; &nbsp; &nbsp; (M)"
</code></pre>
<p>Why does <code>result1</code> become an empty string for aMatchStr equal to</p>
<pre><code>"\s*(\d*).*?Oxidation\s+\(M\)"
</code></pre>
<p>but becomes "7" for <code>aMatchStr</code> equal to</p>
<pre><code>"\s*(\d*)\s*Oxidation\s+\(M\)"
</code></pre>
<p>?</p>
<p>(<code>result0</code> becomes equal to "AMEVDIEERPK + 7 Oxidation (M)")</p>
<p>(This is from <a href="http://msquant.sourceforge.net/" rel="nofollow noreferrer">MSQuant</a>, <a href="http://pmortensen.eu/1/MSQuant/MSQsrcWWW,1.5,2008-12-19/MascotResultParser.vb.html" rel="nofollow noreferrer">MascotResultParser.vb</a>, function <code>modificationParseMatch()</code>).</p>
|
<p>I think it's because the matching starts at the first character and moves on from there... </p>
<p>For your first regular expression:</p>
<pre><code>Does "AMEVDIEERPK + 7 Oxidation (M)" match "\s*(\d*).*?Oxidation\s+(M)"? Yes.. stop matching.
</code></pre>
<p>For your second regular expression:</p>
<pre><code>Does "AMEVDIEERPK + 7 Oxidation (M)" match "\s*(\d*)\s*Oxidation\s+(M)"? No...
Does "MEVDIEERPK + 7 Oxidation (M)" match "\s*(\d*)\s*Oxidation\s+(M)"? No...
Does "EVDIEERPK + 7 Oxidation (M)" match "\s*(\d*)\s*Oxidation\s+(M)"? No...
...
Does " 7 Oxidation (M)" match "\s*(\d*)\s*Oxidation\s+(M)"? Yes
</code></pre>
<p>If for the first regular expression you'd used <code>\d+</code> instead of <code>\d*</code> you'd have got a better result.</p>
<p>This is not <em>exactly</em> how regular expressions work, but you get the idea.</p>
|
<p>". * ?" in this example will always match zero characters, since "* ?" does shortest possible match. As a result, since the thing right before the 'O' is a space, "\ d *" can match 0 digits.</p>
<p>(Sorry about the spaces in the quotes; the auto-formatter was eating my syntax.)</p>
<p>Reference: <em><a href="http://msdn.microsoft.com/en-us/library/3206d374.aspx" rel="nofollow noreferrer">Quantifiers in Regular Expressions</a></em> (MSDN)</p>
| 43,232
|
<p>I need to style links for a Blackberry browser that has disabled CSS.</p>
<p>The following is what I try to achieve: </p>
<pre><code><style type="text/css">
a.hover {
border:0;
}
a {
text-decoration: none;
}
</style>
</code></pre>
<p>Is it even possible, just using html?</p>
|
<p>You can only set the color.</p>
<pre><code><body link="XXX" alink="YYY" vlink="ZZZ">
</code></pre>
<p>XXX being the color used for links, YYY the color when mouse hovers the link and ZZZ the color for already visited links. Color can be given in hex notation just like with stylesheets</p>
<pre><code>#AABBCC
</code></pre>
<p>You cannot set whether links are underlined or not, or have a border or not. This is totally up to the browser... unless these devices have some special, secret non-standard HTML.</p>
|
<p><code>tex-decoration:bilnk</code>; this makes your text blink-blink, like rapper</p>
| 38,316
|
<p>We have the following simple Stored Procedure that runs as an overnight SQL server agent job. Usually it runs in 20 minutes, but recently the MatchEvent and MatchResult tables have grown to over 9 million rows each. This has resulted in the store procedure taking over 2 hours to run, with all 8GB of memory on our SQL box being used up. This renders the database unavailable to the regular queries that are trying to access it.</p>
<p>I assume the problem is that temp table is too large and is causing the memory and database unavailablity issues.</p>
<p>How can I rewrite the stored procedure to make it more efficient and less memory intensive?</p>
<p>Note: I have edited the SQL to indicate that there is come condition affecting the initial SELECT statement. I had previously left this out for simplicity. Also, when the query runs CPU usage is at 1-2%, but memoery, as previously stated, is maxed out</p>
<p><pre><code>
CREATE TABLE #tempMatchResult
(
matchId VARCHAR(50)
)</p>
<p>INSERT INTO #tempMatchResult
SELECT MatchId FROM MatchResult WHERE SOME_CONDITION</p>
<p>DELETE FROM MatchEvent WHERE<br>
MatchId IN (SELECT MatchId FROM #tempMatchResult)</p>
<p>DELETE FROM MatchResult WHERE
MatchId In (SELECT MatchId FROM #tempMatchResult)</p>
<p>DROP TABLE #tempMatchResult
</pre></code></p>
|
<p>There's probably a lot of stuff going on here, and it's not all your query. </p>
<p>First, I agree with the other posters. Try to rewrite this without a temp table if at all possible.</p>
<p>But assuming that you need a temp table here, you have a BIG problem in that you have no PK defined on it. It's vastly going to expand the amount of time your queries will take to run. Create your table like so instead:</p>
<pre><code>CREATE TABLE #tempMatchResult (
matchId VARCHAR(50) NOT NULL PRIMARY KEY /* NOT NULL if at all possible */
);
INSERT INTO #tempMatchResult
SELECT DISTINCT MatchId FROM MatchResult;
</code></pre>
<p>Also, make sure that your TempDB is sized correctly. Your SQL server may very well be expanding the database file dynamically on you, causing your query to suck CPU and disk time. Also, make sure your transaction log is sized correctly, and that it is not auto-growing on you. Good luck.</p>
|
<p>Looking at the code above, why do you need a temp table?</p>
<pre>
<code>
DELETE FROM MatchEvent WHERE
MatchId IN (SELECT MatchId FROM MatchResult)
DELETE FROM MatchResult
-- OR Truncate can help here, if all the records are to be deleted anyways.
</code>
</pre>
| 28,219
|
<p>Can Eclipse make parameters for generated methods (overwriting, implementing interface, etc.) final, and if so, how?</p>
<p>If I'm not mistaken, IntelliJ had an option for it. I could not find something similar in Eclipse.</p>
<p>I have become accustomed to making parameters final manually, but I am hoping for an automatic solution.</p>
|
<p>AFAIK, that is not possible. I've not found any option to customize it under <code>Window > Preferences > Java > Editor > Templates or under Window > Preferences > Java > Code Style > Code Templates</code>.</p>
<p>Anyway, Eclipse 3.3+ comes with "save actions", an alternative mechanism for doing that. Under <code>Preferencens > Java > Editors > Save</code> actions it is possible to configure "additional save actions". On the code style tab there is an option to automatically add final modifiers to private fields, method parameters and local variables.</p>
|
<p>There's cleanup options under 'Project' -> 'Preferences' -> 'Java Code Style' -> 'Clean up', but these can be applied after code has been generated...</p>
| 24,418
|
<p>I have the following class in C++:</p>
<pre><code>class a {
const int b[2];
// other stuff follows
// and here's the constructor
a(void);
}
</code></pre>
<p>The question is, how do I initialize b in the initialization list, given that I can't initialize it inside the body of the function of the constructor, because b is <code>const</code>?</p>
<p>This doesn't work:</p>
<pre><code>a::a(void) :
b([2,3])
{
// other initialization stuff
}
</code></pre>
<p>Edit: The case in point is when I can have different values for <code>b</code> for different instances, but the values are known to be constant for the lifetime of the instance.</p>
|
<p>Like the others said, ISO C++ doesn't support that. But you can workaround it. Just use std::vector instead.</p>
<pre><code>int* a = new int[N];
// fill a
class C {
const std::vector<int> v;
public:
C():v(a, a+N) {}
};
</code></pre>
|
<p>You can't do that from the initialization list, </p>
<p>Have a look at this:</p>
<p><a href="http://www.cprogramming.com/tutorial/initialization-lists-c++.html" rel="nofollow noreferrer">http://www.cprogramming.com/tutorial/initialization-lists-c++.html</a></p>
<p>:)</p>
| 19,563
|
<p>The case goes as following:
You have a Boolean property called FullScreenEnabled. You enter some method, and the code within this method is executed iff FullScreenEnabled is true. Which of the 2 approaches below do you use in your everyday programming:</p>
<pre><code> private bool FullScreenEnabled { get; set; }
// Check if FullScreenEnabled is false and return;
private void Case1()
{
if (FullScreenEnabled == false)
{
return;
}
// code to be executed goes here!
}
// Surround the code by an if statement.
private void Case2()
{
if (FullScreenEnabled)
{
// code to be executed goes here!
}
}
</code></pre>
|
<pre><code>private void MyMethod(bool arg){
if(arg)
return;
//do stuff
};
</code></pre>
<p>(for voting)</p>
|
<pre><code>private void MyMethod(bool arg){
if(!arg){
//do stuff
}
}
</code></pre>
<p>(for voting)</p>
| 17,555
|
<pre><code>var i : integer;
i := 1234567;
</code></pre>
<p>Given the above, I want the string "1,234,567" as output (assuming UK locale). IntToStr just gives me "1234567". I'm sure there's a one-liner for this, but I can't find it...</p>
|
<p>Try the format function.</p>
<pre><code>Label1.Caption := Format('%.0n', [i + 0.0]);
</code></pre>
|
<pre><code>stringreplace(format('%n',[1234567.0]),'.00','',[]);
</code></pre>
| 37,850
|
<p>I have an application that is using Windows Authentication and a SqlRoleProvider for user authentication and role management respectively. It is working fine with my test users that I have added to the database as defaults. The application requires users to login (using Windows credentials) and then be able to use this internal application as a basic "user". If the user needs to be added to a high level role, an admin would be responsible for this after the first log in.</p>
<p>With that said, how would I add a user to the default role when they first log in? Logically, I know that I would need to call Roles.IsUserInRole() and then add them if they are not; however, where would I do this? I'm having trouble locating which event in the Global.asax to use.</p>
<p>Thanks</p>
<p><strong>EDIT:</strong>
To expand the scenario a bit, I'm not using a full membership provider system due to requirements on writing new providers to allow the connection string to be stored outside of the web.config. I am not using any form of registration or login page and letting the Windows Integrated Authentication in IIS handle the authentication aspects while my enhanced SqlRoleProvider manages the user roles. The system is working fine for users that I have setup roles via hard coded tests. I am just looking for a way to add new users (who would be authenticated by IIS) to be immediately added to a default "Users" role. I think I found it; however, am now examining ways to make it not fire upon every request for performance reasons.</p>
|
<p>I was able to locate the solution after digging and playing around a bit more. I added the following code to my Global.asax file and it is accomplishing what I am hoping for.</p>
<pre><code>protected void WindowsAuthentication_OnAuthenticate(object sender, WindowsAuthenticationEventArgs e)
{
if (!Roles.IsUserInRole(e.Identity.Name, "Users"))
{
Roles.AddUsersToRole(new string[] { e.Identity.Name }, "Users");
}
}
</code></pre>
<p>I'm concerned since this code fires with every page request. Is there a better way to limit when this occurs? Should I just add this code to the landing page's page_load event instead of the Global.asax?</p>
|
<p>I would add the default role to the user directly after the user was fetched.</p>
<p>Something like such:</p>
<pre><code>user = Membership.GetUser()
if (user != null)
{
// default role
string[] defaultRoles = {"MyRole"};
AddUsersToRoles(user, defaultRoles);
}
</code></pre>
| 46,120
|
<p>I have a function in which I get en external resource from the web using cocoa's Url object. And it works fine on the simulator, but occasionally fails on the device itself (it's a google query so the resource obviously does exist). Which leads me to believe that there is some internal timeout barrier on the hardware, but haven't read that such a barrier exists or not.</p>
<p>Anyone else encountered similar issues? Or knows if the timeout is documented or can be changed?</p>
|
<p>iPhone imposes a timeout for application launch. So if you perform an extensive processing in applicationDidFinishLaunching: for instance, the application will be terminated and a crash log will be produced. Unfortunately I've found no mention of it in the official documentation.</p>
<p>After the launch process has completed, I'm not aware of any timeouts that limit function execution time. I've tried it on the device with putting sleep for 30 seconds in the main thread and it works fine.</p>
|
<p>I know iPhone OS will kill an app if it uses too much memory, so I wouldn't be surprised if it uses the same policy if an app is unresponsive to events for too long.</p>
<p>If you were writing a desktop app, the problem would manifest as a spinning rainbow beach ball cursor, and your app would not respond to mouse clicks. Mac OS X wouldn't terminate your app, but it would offer to Force Quit it if you ctrl-clicked its icon in the Dock.</p>
<p>The main problem here is that you are tying up the event processing thread. You have two options:</p>
<ol>
<li>Use non-blocking I/O, so instead of doing the web request in one call you use an API which fetches the data in the background and then calls a method you specify when it's done.</li>
<li>Use blocking I/O on a separate thread. Do the web request just like you are doing now, but in a separate thread, then signal the main thread when you are done.</li>
</ol>
| 20,459
|
<p>I need to perform a complicated calculation. In my case it seemed most natural to create a Calculator class (abstracted using a strategy pattern).</p>
<p>To perform the calculation the class needs to accept about 20 inputs, some of which are optional, some of which could change in the future etc. Once the <strong>Calculate()</strong> method is called, about 20 different variables need to be outputted.</p>
<p>There are a number of ways this can be achieved.</p>
<ul>
<li>Inputs passed in as parameters to a calculate method</li>
<li>Inputs passed in through properties of the Calculator</li>
<li>Inputs wrapped up into their own class, then passed to Calculate() method.</li>
<li>Outputs returned by Calculate(), wrapped up in a class</li>
<li>Outputs populated into a parameter passed to the Calculate() method</li>
<li>Outputs retrieved from public properties of the Calculator, after Calculate() has been called</li>
</ul>
<p>There are pros and cons to all these methods.
How would you do it?</p>
<p>UPDATE:
Thanks for the feedback.</p>
<p>The purpose of this calculator is to generate a quote. The inputs are things such as the customer's address, interest rates, target profit, additional fees, product id etc The output includes the quote, the actual profit, more fees etc.</p>
<p>I have gone ahead and created ICalculateInput and ICalculateOutput interfaces and their concrete classes, and the system works very well now. The Calculator class also inherits from an ICalculator interface (as the calculations involved differ enormously depending on the company the product is sourced from).</p>
|
<p>Most people suggest using a "Parameter Class", and a "Result Class". I agree with this approach, but it seems to me that your parameters fall into several categories. Perhaps you could create a parameter class for the required parameters, and a separate parameter class for the optional parameters or groups of optional parameters. This way, you could create different methods depending on what kind of calculation you require;</p>
<pre><code>Result calculate(RequiredArgs requiredArgs) {
...
}
Result calculate(RequiredArgs requiredArgs, OptionalArgs optionalArgs) {
}
Result calculate(RequiredArgs requiredArgs, OptionalArgs optionalArgs, OtherOptionalArgs oOpitonalArgs) {
}
</code></pre>
<p>This will make your API easier to use. If you don't want to create classes for the different groups, you could also use Maps, but this will require more validation code in the calculation engine. Normally I would prefer parameter classes, but would have to know more about your particular problem to be decisive.</p>
<p>I would not store the calculation result in the calculation engine itself, because of thread safety and object reusability. It's much easier to maintain code that is stateless.</p>
|
<p>You haven't mentioned the language, but I'll assume c#.
I would probably pass them in as a struct (or class) and return the outputs the same way.</p>
<p>Alternatively, I'd find some way to refactor it and simplify the expected input/output.</p>
| 45,712
|
<p>I want to print a lemon squeezer and I would prefer to use PET-G. I don't know if it is safe to use, because lemons contain lots of citric acid. Does it dissolve PETG? I haven't found an answer anywhere on the Internet. There are generally few things that dissolve PETG. These are aromatic compounds like toluene, phenol etc.</p>
<p>I know my model will be food safe, as PETG is food safe, I'm using one without a dye and my nozzle is made out of steel, not brass. I think bacteria growth inside little gaps/between layers is impossible, because the citric acid is quite strong and will kill nearly all of the germs.</p>
|
<p>According to <a href="http://kmac-plastics.net/data/chemical/petg-chemical.htm#.XV7Vokd7m4o" rel="nofollow noreferrer">kmac-plastics</a>, PETG is stable at temperatures below 50°C specifically for citric acid (also acetic acid) and others on the linked list. It is also safe with diesel oil and many alcohols. The list is illuminating with respect to the variation of tested compounds.</p>
|
<p>The PETG is food safe (plastic water bottles are made of them), however the colour additives may not be a) stable, or b) food safe. If you are going to make a lemon squeezer then I would suggest that you use a virgin material that is just pet-g with no additives.</p>
<p>However, you could only ever use it one. Any food particles that get stuck in between the fine layers of the printed part, will cause bacterial growth. If the walls are porous then the juice can get inside of the part and create a breathing ground.</p>
| 1,444
|
<p>The following SQL separates tables according to their relationship. The problem is with the tables that sort under the 3000 series. Tables that are part of foreign keys and that use foreign keys. Anyone got some clever recursive CTE preferably or a stored procedure to do the necessary sorting?? Programs connectiong to the database are not considered a solution. </p>
<p>Edit: I posted the answer in the "answers" based on the first solution
Free "right answer" to be had for anyone reposting my own "right" answer!</p>
<pre><code>WITH
AllTables(TableName) AS
(
SELECT OBJECT_SCHEMA_NAME(so.id) +'.'+ OBJECT_NAME(so.id)
FROM dbo.sysobjects so
INNER JOIN sys.all_columns ac ON
so.ID = ac.object_id
WHERE
so.type = 'U'
AND
ac.is_rowguidcol = 1
),
Relationships(ReferenceTableName, ReferenceColumnName, TableName, ColumnName) AS
(
SELECT
OBJECT_SCHEMA_NAME (fkey.referenced_object_id) + '.' +
OBJECT_NAME (fkey.referenced_object_id) AS ReferenceTableName
,COL_NAME(fcol.referenced_object_id,
fcol.referenced_column_id) AS ReferenceColumnName
,OBJECT_SCHEMA_NAME (fkey.parent_object_id) + '.' +
OBJECT_NAME(fkey.parent_object_id) AS TableName
,COL_NAME(fcol.parent_object_id, fcol.parent_column_id) AS ColumnName
FROM sys.foreign_keys AS fkey
INNER JOIN sys.foreign_key_columns AS fcol ON
fkey.OBJECT_ID = fcol.constraint_object_id
),
NotReferencedOrReferencing(TableName) AS
(
SELECT TableName FROM AllTables
EXCEPT
SELECT TableName FROM Relationships
EXCEPT
SELECT ReferenceTableName FROM Relationships
),
OnlyReferenced(Tablename) AS
(
SELECT ReferenceTableName FROM Relationships
EXCEPT
SELECT TableName FROM Relationships
),
-- These need to be sorted based on theire internal relationships
ReferencedAndReferencing(TableName, ReferenceTableName) AS
(
SELECT r1.Tablename, r2.ReferenceTableName FROM Relationships r1
INNER JOIN Relationships r2
ON r1.TableName = r2.ReferenceTableName
),
OnlyReferencing(TableName) AS
(
SELECT Tablename FROM Relationships
EXCEPT
SELECT ReferenceTablename FROM Relationships
)
SELECT TableName, 1000 AS Sorting FROM NotReferencedOrReferencing
UNION
SELECT TableName, 2000 AS Sorting FROM OnlyReferenced
UNION
SELECT TableName, 3000 AS Sorting FROM ReferencedAndReferencing
UNION
SELECT TableName, 4000 AS Sorting FROM OnlyReferencing
ORDER BY Sorting
</code></pre>
|
<p>Thank you for a working solution NXC. You put me on the right track to solve the problem using a recursive CTE.</p>
<pre><code>WITH
TablesCTE(TableName, TableID, Ordinal) AS
(
SELECT
OBJECT_SCHEMA_NAME(so.id) +'.'+ OBJECT_NAME(so.id) AS TableName,
so.id AS TableID,
0 AS Ordinal
FROM dbo.sysobjects so INNER JOIN sys.all_columns ac ON so.ID = ac.object_id
WHERE
so.type = 'U'
AND
ac.is_rowguidcol = 1
UNION ALL
SELECT
OBJECT_SCHEMA_NAME(so.id) +'.'+ OBJECT_NAME(so.id) AS TableName,
so.id AS TableID,
tt.Ordinal + 1 AS Ordinal
FROM
dbo.sysobjects so
INNER JOIN sys.all_columns ac ON so.ID = ac.object_id
INNER JOIN sys.foreign_keys f
ON (f.parent_object_id = so.id AND f.parent_object_id != f.referenced_object_id)
INNER JOIN TablesCTE tt ON f.referenced_object_id = tt.TableID
WHERE
so.type = 'U'
AND
ac.is_rowguidcol = 1
)
SELECT DISTINCT
t.Ordinal,
t.TableName
FROM TablesCTE t
INNER JOIN
(
SELECT
TableName as TableName,
Max (Ordinal) as Ordinal
FROM TablesCTE
GROUP BY TableName
) tt ON (t.TableName = tt.TableName AND t.Ordinal = tt.Ordinal)
ORDER BY t.Ordinal, t.TableName
</code></pre>
<p>For thoose wondering what this is useable for: I will use it to safely empty a database without violating any foreign key relations. (By truncating in descending order)
I will also be able to safely fill the tables with data from another database by filling the tables in ascending order.</p>
|
<p>This causes problems with self-referencing tables. You'll need to manually exclude any foreign keys that point to self referencing tables.</p>
<pre><code>INNER JOIN sys.foreign_keys f
ON (f.parent_object_id = so.id AND f.parent_object_id != f.referenced_object_id)
/* Manually exclude self-referencing tables - they cause recursion problems*/
and f.object_id not in /*Below are IDs of foreign keys*/
( 1847729685,
1863729742,
1879729799
)
INNER JOIN TablesCTE tt
</code></pre>
| 45,858
|
<p>Which of <a href="http://en.wikipedia.org/wiki/Crystal_Reports" rel="noreferrer">Crystal Reports</a> and <a href="http://en.wikipedia.org/wiki/SQL_Server_Reporting_Services" rel="noreferrer">SSRS</a> (SQL Server Reporting Services) is better to use?</p>
|
<p>On the one-hand, Crystal Reports is a steaming pile of expensive and overhyped donkey poo, and on the other hand SSRS actually fulfils all the promises that CR marketing makes - and it's free.</p>
<p>My contempt for CR stems from many years of being obliged to use the horrible thing. There's really no point in detailing the utter odiousness of CR when I can give you references like <a href="http://secretgeek.net/CrystalDodo.asp" rel="noreferrer">Clubbing the Crystal Dodo</a> or <a href="http://unbecominglevity.blogharbor.com/blog/_archives/2005/12/21/1474036.html" rel="noreferrer">Crystal Reports Sucks Donkey Dork</a> (not as funny but rather more literate and substantiated with technical details).</p>
<p>Free?! Yup. You don't even have to buy MS SQL Server to get it - you can install SQL Express with Advanced Services. This is available as a <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=B5D1B8C3-FDA5-4508-B0D0-1311D670E336&displaylang=en" rel="noreferrer">download that includes SQL Server Reporting Services</a>. While SQL Express is limited in the number of concurrent users it can support, the following observations are salient:</p>
<ul>
<li><p>The licence for SSRS obtained as
part of SQL Express only requires
that it be deployed as part of SQL
Express. There is nothing forbidding
connection to other data sources or
requiring that a report obtain data
from SQL Server.</p></li>
<li><p>The abovementioned version of SSRS
has no intrinsic restrictions on
user connections. All limitations
are imposed on the SQL Express
database engine.</p></li>
<li><p>SSRS uses ADO.NET, which includes,
out of the box, drivers for Oracle,
Jet (Access), OLEDB and ODBC</p></li>
</ul>
<p>Thus you can connect the free version of SSRS to any back-end to which you can connect ADO.NET, which includes (for example) MySQL. I am told by Rory in a comment below that this is "not supported". That's true but I can't find anything in the licence that forbids it and while the drivers are not supplied <em>by SSExpress</em> they certainly <em>are</em> supplied by most versions of Visual Studio and you can ship them in your setup kit. This may not be an expressly supported configuration but so what? Even if you did have a full MSSQL licence it would be asking a bit much to expect Microsoft to help you talk to some third party database (not to mention a bit weird).</p>
<p>I use SSRS extensively at work both for inward facing reports and for outward facing reports embedded in ASP.NET applications that provide bureau services to large numbers of paying customers. In our case it happens that the backing store is a licensed copy of Microsoft SQL Server 2008, but this is incidental to the technical merits of our reporting solution.</p>
<p>There is a long list of capabilities that Crystal Reports claims to support but which either don't work or which require a staggeringly expensive licence if you want more than five users. You can't even trust CR to do SQL correctly. <code>SELECT COUNT(*) FROM SOMETABLE WHERE 1=0</code> should produce a result of zero but it it produces <em>one</em>. The built-in query engine is defective, and a team that screws up something a bunch of amateurs can do for free (eg MySQL) has no hope of getting anything you'd describe as performance out of their code.</p>
<p>And they don't. The evil thing leaks memory like a bucket with no bottom, and if you use SQL profiling tools you will find it is <a href="http://unbecominglevity.blogharbor.com/blog/_archives/2005/12/21/1474036.html" rel="noreferrer">spectacularly inefficient.</a></p>
<p>As for the alleged support, I can personally attest that dialog resize bugs have gone uncorrected for <em>decades</em> after they were first publicly documented. If you get out your credit card and pay the extortionate ransoms demanded (I too would want handsome pay to support such a horror) you will find yourself talking to someone who claims his name is David, but inexplicably pronounces it "Dah-feet", and who doesn't even understand your question, much less have an answer.</p>
<p>The SSRS support situation is fairly similar, but it actually works so you don't really need much. </p>
<p>SSRS, on the other hand, does everything that CR claims to. It is not without bugs, but they are delightfully few, and they seldom survive more than one release cycle. </p>
<p>The SSRS designer UI is hosted within the Visual Studio IDE. It is attractively presented in typical Microsoft style, but more than this it is quite well thought out, incorporating several simple but fundamental departures from traditional report designers. For example, to present tabular data you define a table rather than fiddling about with individual text boxes. As a result you don't have to screw around trying to line them up, and putting borders on them is a trivial stylesheet exercise.</p>
<p>SSRS actually does all the things CR claims to, it's inexpensive, there is extensive reliable technical documentation, it's designed to be extended (also documented) and you can connect it to anything for which you can get an ODBC driver. This is a no brainer.</p>
<h2>Some shortcomings of SSRS</h2>
<ul>
<li>It is not obvious how to bind fields in page headers and footers. </li>
<li>It is not possible (so far as I know) to position relative to the bottom of a page. This is a genuine problem for certain types of report, and one for which I can think of no workaround.</li>
<li>There's no support for expando horizontal rollups in cross-tabulations.</li>
<li>There's no direct support for report headers and footers. Use Rectangle objects at top and bottom of the report layout, with pagebreaking properties set appropriately. Or use subreports. The people who complain about this obviously haven't tried very hard.</li>
<li>Lack of support for overlapping group intervals (the CR grouping system can do this) <strong>UPDATE</strong> SSRS 2008 R2 now supports this. It's buried in the grouping edit dialog. Look up "group variables" and <a href="http://blogs.msdn.com/b/robertbruckner/archive/2008/07/20/using-group-variables-in-reporting-services-2008-for-custom-aggregation.aspx" rel="noreferrer">read this</a>.</li>
</ul>
<p>It actually looks like overlapping groups can be done with SSRS2005 too, although I never knew that. I wonder did anyone ever crack the bottom-relative positioning issue?</p>
|
<p>For those who are comparing the old Crystal Reports XI and Reporting Service 1.0 please see this 2005 post:</p>
<p>SQL Server Reporting Services and Crystal Reports: A Competitive Analysis
<a href="http://www.crystalreportsbook.com/SSRSandCR_Conclusion.asp" rel="nofollow noreferrer">http://www.crystalreportsbook.com/SSRSandCR_Conclusion.asp</a></p>
| 20,336
|
<p>I'm trying to build a better username/password field for my workplace and would like to be able to complain when they have their caps lock on.</p>
<p>Is this possible? And if so I'd like to have it detected before the client types their first letter.</p>
<p>Is there a non-platform specific way to do this?</p>
|
<p>Try this, from java.awt.Toolkit, returns a boolean:</p>
<pre><code>Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK)
</code></pre>
|
<p>here is some info on the class
<a href="http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Toolkit.html#getLockingKeyState(int)" rel="nofollow noreferrer">http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Toolkit.html#getLockingKeyState(int)</a></p>
| 11,402
|
<p>I'm trying to get udp multicast data using sockets and c++ (c). I have a server with 2 network cards so I need to bind socket to specific interface. Currently I'm testing on another server that has only one network card.</p>
<p>When I use INADDR_ANY I can see the udp data, when I bind to specific interface I don't see any data. Function inet_addr is not failing (I removed checking for return value for now).</p>
<p>Code is below.
On a server with one network card, my IP address is 10.81.128.44. I receive data when I run as:
./client 225.0.0.37 12346</p>
<p>This gives me no data:
./client 225.0.0.37 12346 10.81.128.44</p>
<p>Any suggestions? (Hope the code compiles, I removed comments ...)</p>
<pre><code> #include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <time.h>
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
#define HELLO_PORT 12345
#define HELLO_GROUP "225.0.0.37"
#define MSGBUFSIZE 256
int main(int argc, char *argv[])
{
string source_iface;
string group(HELLO_GROUP);
int port(HELLO_PORT);
if (!(argc < 2)) group = argv[1];
if (!(argc < 3)) port = atoi(argv[2]);
if (!(argc < 4)) source_iface = argv[3];
cout << "group: " << group << " port: " << port << " source_iface: " << source_iface << endl;
int fd;
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
perror("socket");
exit(1);
}
u_int yes = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0)
{
perror("Reusing ADDR failed");
exit(1);
}
struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = (source_iface.empty() ? htonl(INADDR_ANY) : inet_addr(source_iface.c_str()));
if (bind(fd,(struct sockaddr *)&addr, sizeof(addr)) < 0)
{
perror("bind");
exit(1);
}
struct ip_mreq mreq;
mreq.imr_multiaddr.s_addr = inet_addr(group.c_str());
mreq.imr_interface.s_addr = (source_iface.empty() ? htonl(INADDR_ANY) : inet_addr(source_iface.c_str()));
if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0)
{
perror("setsockopt");
exit(1);
}
socklen_t addrlen;
int nbytes;
char msgbuf[MSGBUFSIZE];
while (1)
{
memset(&msgbuf, 0, MSGBUFSIZE);
addrlen = sizeof(addr);
if ((nbytes = recvfrom(fd, msgbuf, MSGBUFSIZE, 0, (struct sockaddr *)&addr, &addrlen)) < 0)
{
perror("recvfrom");
exit(1);
}
cout.write(msgbuf, nbytes);
cout.flush();
}
return 0;
}
</code></pre>
<p>Thanks in advance ...</p>
|
<p>After some searching and testing I found out <a href="http://www.kohala.com/start/mcast.api.txt" rel="noreferrer">here</a> that when <strong>binding</strong> udp multicast socket we specify port and leave address empty e.g. specify <code>INADDR_ANY</code>.</p>
<p>So the following</p>
<pre><code>addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = (source_iface.empty() ?
htonl(INADDR_ANY) :
inet_addr(source_iface.c_str()));
</code></pre>
<p>should be look like:</p>
<blockquote>
<p><strong>COMMENT</strong>: If I understand your code you
should be binding to your multicast
address not the wildcard address. If
you bind to the wildcard address you
will be able to receive unicast
packets on your multicast port.
Binding to your multicast address will
prevent this and ensure you only get
multicast packets on that port.</p>
<p><strong>EDIT</strong>: Fixed the code based on above comment, binding to multicast address,
stored in 'group', as opposed to
INADDR_ANY to receive only multicast packets sent to
multicast address.</p>
</blockquote>
<pre><code>addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = (group.empty() ?
htonl(INADDR_ANY) :
inet_addr(group.c_str()));
</code></pre>
<p>This solved the problem. Adding <code>IP_MULTICAST_IF</code> will not help because that is for selecting specific interface for sending udp data, the problem above was on receiving side.</p>
|
<p>I think you need to add IP_MULTICAST_IF</p>
<pre><code> struct ip_mreq multi;
multi.imr_multiaddr.s_addr = inet_addr(group.c_str());
multi.imr_interface.s_addr = (source_iface.empty() ?
htonl(INADDR_ANY): inet_addr(source_iface.c_str()));
status = setsockopt(me->ns_fd, IPPROTO_IP, IP_MULTICAST_IF,
(char *)&multi.imr_interface.s_addr,
sizeof(multi.imr_interface.s_addr));
</code></pre>
<p>I hope that helps.</p>
| 47,228
|
<p>How would I only allow users authenticated via Python code to access certain files on the server?</p>
<p>For instance, say I have <code>/static/book.txt</code> which I want to protect. When a user accesses <code>/some/path/that/validates/him</code>, a Python script deems him worthy of accessing <code>/static/book.txt</code> and redirects him to that path.</p>
<p>How would I stop users who bypass the script and directly access <code>/static/book.txt</code>?</p>
|
<p><a href="http://en.wikipedia.org/wiki/Comparison_of_SSH_clients" rel="nofollow noreferrer">wikipedia's comparison of ssh clients</a> has columns for tunnelling, SOCKS etc. may help you find something suitable</p>
|
<p>you can just set-up any application to start with windows and auto-connect your tunnel on startup. I personnally use Easytunnel... just checked the option to connect all tunnels on startup, and set-up windows to start Easytunnel on bootup. It works great, tho you'll need to set-up your server's inactivity timeout, or you will be disconnected every 10 minutes or so.</p>
<p>Hope you get it working!</p>
| 48,690
|
<p>I assume 100 bytes is too small and can slow down larger file transfers with all of the writes, but something like 1MB seems like it may be too much. Does anyone have any suggestions for an optimal chunk of bytes per write for sending data over a network?</p>
<p>To elaborate a bit more, I'm implementing something that sends data over a network connection and show the progress of that data being sent. I've noticed if I send large files at about 100 bytes each write, it is extremely slow but the progress bar works out very nicely. However, if I send at say 1M per write, it is much faster, but the progress bar doesn't work as nicely due to the larger chunks being sent.</p>
|
<p>If you can, just let the IP stack handle it; most OSes have a lot of optimization already built in. Vista, for example, will dynamically alter various parameters to maximize throughput; second-guessing the algorithm is unlikely to be beneficial.</p>
<p>This is especially true in higher-order languages, far from the actual wire, like C#; there are enough layers between you and actual TCP/IP packets that I would expect your code to have relatively little impact on throughput.</p>
<p>At worst, test various message sizes in various situations for yourself; few solutions are one-size-fits-all.</p>
|
<p>One empirical test you can do, if you haven't already, is of course to use a sniffer (tcpdump, Wireshark etc.) and look at what packet sizes are achieved when using other software for up/downloading. That might give you a hint.</p>
| 39,089
|
<p>I am in a Windows Desktop application and I have a data stream and a mime type in the database. Is there a better way than writing it to a temp folder and launching the default editor for it?</p>
<p>If I have to use the temp folder how can I get the file extension from the MIME type in a C# Windows Desktop application? </p>
|
<p>Lookup the MIME type in <code>HKEY_CLASSES_ROOT\MIME\Database\Content Type</code> to find out the corresponding file extension and go from there. Some starter links:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/ms775147(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms775147(VS.85).aspx</a></li>
<li><a href="http://bitworking.org/news/Atom_Auto_Sub_How_To" rel="nofollow noreferrer">http://bitworking.org/news/Atom_Auto_Sub_How_To</a></li>
</ul>
<p>If that is not enough, maybe <a href="http://en.wikipedia.org/wiki/Libmagic" rel="nofollow noreferrer">libmagic</a> (used by the <code>file</code> command line tool) or its database can be of use to you, even though it is quite UNIX:y.</p>
|
<p>It depends on what you want to do with that data stream. If all you want to do is open the default program for that file type, writing a temp file and calling Process.Start on it isn't a bad way to go. If you're looking to perform other operations on the data... well, it depends what operations you had in mind.</p>
| 39,433
|
<p>This loop is slower than I would expect, and I'm not sure where yet. See anything?</p>
<p>I'm reading an Accces DB, using client-side cursors. When I have 127,000 rows with 20 columns, this loop takes about 10 seconds. The 20 columns are string, int, and date types. All the types get converted to ANSI strings before they are put into the ostringstream buffer.</p>
<pre><code>void LoadRecordsetIntoStream(_RecordsetPtr& pRs, ostringstream& ostrm)
{
ADODB::FieldsPtr pFields = pRs->Fields;
char buf[80];
::SYSTEMTIME sysTime;
_variant_t var;
while(!pRs->EndOfFile) // loop through rows
{
for (long i = 0L; i < nColumns; i++) // loop through columns
{
var = pFields->GetItem(i)->GetValue();
if (V_VT(&var) == VT_BSTR)
{
ostrm << (const char*) (_bstr_t) var;
}
else if (V_VT(&var) == VT_I4
|| V_VT(&var) == VT_UI1
|| V_VT(&var) == VT_I2
|| V_VT(&var) == VT_BOOL)
{
ostrm << itoa(((int)var),buf,10);
}
else if (V_VT(&var) == VT_DATE)
{
::VariantTimeToSystemTime(var,&sysTime);
_stprintf(buf, _T("%4d-%02d-%02d %02d:%02d:%02d"),
sysTime.wYear, sysTime.wMonth, sysTime.wDay,
sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
ostrm << buf;
}
}
pRs->MoveNext();
}
}
</code></pre>
<p>EDIT: After more experimentation...</p>
<p>I know now that about half the time is used by this line:<br>
var = pFields->GetItem(i)->GetValue();</p>
<p>If I bypass the Microsoft generated COM wrappers, will my code be faster? My guess is no.</p>
<p>The othe half of the time is spent in the statements which convert data and stream it into the ostringstream.</p>
<p>I don't know right now as I write this whether it's the conversions or the streaming that is taking more time.</p>
<p>Would it be faster if I didn't use ostringstream and instead managed my own buffer, with my own logic to grow the buffer (re-alloc, copy, delete)? Would it be faster if my logic made a pessimistic guesstimate and reserved a lot of space for the ostringstream buffer up front? These might be experiments worth trying.</p>
<p>Finally, the conversions themselves. None of the three stand out in my timings as being bad. One answer says that my itoa might be slower than an alternative. Worth checking out.</p>
|
<p>I can't tell from looking at your code, someone more familiar with COM/ATL may have a better answer.</p>
<p>By trial n error I would find the slow code by commenting out inner loop operations out until you see perf spike, then you have your culprit and should focus on that.</p>
|
<p>Try profiling. If you don't have a profiler a simple way could be to wrap all calls in your loop you think may take some time with something like the following:</p>
<pre><code>#define TIME_CALL(x) \
do { \
const DWORD t1 = timeGetTime();\
x;\
const DWORD t2 = timeGetTime();\
std::cout << "Call to '" << #x << "' took " << (t2 - t1) << " ms.\n";\
}while(false)
</code></pre>
<p>So now you can say:</p>
<pre><code>TIME_CALL(var = pFields->GetItem(i)->GetValue());
TIME_CALL(ostrm << (const char*) (_bstr_t) var);
</code></pre>
<p>and so on...</p>
| 34,100
|
<p>How is your javaScript code organized? Does it follow patterns like MVC, or something else? </p>
<p>I've been working on a side project for some time now, and the further I get, the more my webpage has turned into a full-featured application. Right now, I'm sticking with <a href="http://jquery.com" rel="noreferrer">jQuery</a>, however, the logic on the page is growing to a point where some organization, or dare I say it, "architecture" is needed. My first approach is "MVC-ish":</p>
<ul>
<li>The 'model' is a JSON tree that gets extended with helpers</li>
<li>The view is the DOM plus classes that tweak it</li>
<li>The controller is the object where I connect events handling and kick off view or model manipulation</li>
</ul>
<p>I'm very interested, however, in how other people have built more substantial javaScript apps. I'm not interested in GWT, or other server-oriented approaches... just in the approach of "javaScript + <generic web service-y thingy here>"</p>
<p>Note: earlier I said javaScript "is not really OO, not really functional". This, I think, distracted everyone. Let's put it this way, because javaScript is unique in many ways, and I'm coming from a strongly-typed background, I don't want to force paradigms I know but were developed in very different languages.</p>
|
<p>..but Javascript has many facets that <strong>are</strong> OO.</p>
<p>Consider this:</p>
<pre><code>var Vehicle = jQuery.Class.create({
init: function(name) { this.name = name; }
});
var Car = Vehicle.extend({
fillGas: function(){
this.gas = 100;
}
});
</code></pre>
<p>I've used this technique to create page-level javascript classes that have their own state, this helps keep it contained (and I often identify areas that I can reuse and put into other classes).</p>
<p>This is also especially useful when you have components/server controls that have their own script to execute, but when you might have multiple instances on the same page. This keeps the state separate.</p>
|
<p>Not 100% sure what you mean here, but I will say that after doing ASP.NET for the last 6 years, my web pages are now mostly driven by JavaScript once the basic page rendering is done by the server. I use JSON for everything (have been for about 3 years now) and use <a href="http://www.mochikit.com" rel="nofollow noreferrer"><strong>MochiKit</strong></a> for my client-side needs.</p>
<p>By the way, JavaScript <em>is</em> OO, but since it uses prototypical inheritance, people don't give it credit in that way. I would also argue that it is functional as well, it all depends on how you write it. If you are really interested in functional programming styles, check out <a href="http://www.mochikit.com" rel="nofollow noreferrer"><strong>MochiKit</strong></a> - you may like it; it leans quite a bit towards the functional programming side of JavaScript.</p>
| 5,249
|
<p>In a .NET WinForms app, how do I get a specific drive's icon (C:\ for example) for whatever version of Windows the client might be running?</p>
|
<p>I don't know if it will work, but you could try <a href="http://www.codeguru.com/csharp/csharp/cs_misc/icons/article.php/c4261" rel="nofollow noreferrer">this</a>, pointing at the drive root.</p>
|
<p><a href="http://msdn.microsoft.com/en-us/library/bb762179(VS.85).aspx" rel="nofollow noreferrer">SHGetFileInfo</a> is how the operating system exposes information about objects in the file system. How you go about calling it from a .NET WinForms app? I can't help you there.</p>
| 49,032
|
<p>In relation to <a href="https://stackoverflow.com/questions/283431/why-would-an-command-not-recognized-error-occur-only-when-a-window-is-populated">another question</a>, how do you account for paths that may change? For example, if a program is calling a file in the same directory as the program, you can simply use the path ".\foo.py" in *nix. However, apparently Windows likes to have the path hard-coded, e.g. "C:\Python_project\foo.py".</p>
<p>What happens if the path changes? For example, the file may not be on the C: drive but on a thumb drive or external drive that can change the drive letter. The file may still be in the same directory as the program but it won't match the drive letter in the code.</p>
<p>I want the program to be cross-platform, but I expect I may have to use <strong>os.name</strong> or something to determine which path code block to use.</p>
|
<p>Simple answer: You work out the absolute path based on the environment.</p>
<p>What you really need is a few pointers. There are various bits of runtime and environment information that you can glean from various places in the standard library (and they certainly help me when I want to deploy an application on windows).</p>
<p>So, first some general things:</p>
<ol>
<li><code>os.path</code> - standard library module with lots of cross-platform path manipulation. Your best friend. "Follow the os.path" I once read in a book.</li>
<li><code>__file__</code> - The location of the current module.</li>
<li><code>sys.executable</code> - The location of the running Python.</li>
</ol>
<p>Now you can fairly much glean anything you want from these three sources. The functions from os.path will help you get around the tree:</p>
<ul>
<li><code>os.path.join('path1', 'path2')</code> - join path segments in a cross-platform way</li>
<li><code>os.path.expanduser('a_path')</code> - find the path <code>a_path</code> in the user's home directory</li>
<li><code>os.path.abspath('a_path')</code> - convert a relative path to an absolute path</li>
<li><code>os.path.dirname('a_path')</code> - get the directory that a path is in</li>
<li>many many more...</li>
</ul>
<p>So combining this, for example:</p>
<pre><code># script1.py
# Get the path to the script2.py in the same directory
import os
this_script_path = os.path.abspath(__file__)
this_dir_path = os.path.dirname(this_script_path)
script2_path = os.path.join(this_dir_path, 'script2.py')
print script2_path
</code></pre>
<p>And running it:</p>
<pre><code>ali@work:~/tmp$ python script1.py
/home/ali/tmp/script2.py
</code></pre>
<p>Now for your specific case, it seems you are slightly confused between the concept of a "working directory" and the "directory that a script is in". These can be the same, but they can also be different. For example the "working directory" can be changed, and so functions that use it might be able to find what they are looking for sometimes but not others. <code>subprocess.Popen</code> is an example of this.</p>
<p>If you always pass paths absolutely, you will never get into working directory issues.</p>
|
<p>I figured out by using <strong>os.getcwd()</strong>. I also learned about using <strong>os.path.join</strong> to automatically determine the correct path format based on the OS. Here's the code:</p>
<pre><code>def openNewRecord(self, event): # wxGlade: CharSheet.<event_handler>
"""Create a new, blank record sheet."""
path = os.getcwd()
subprocess.Popen(os.path.join(path, "TW2K_char_rec_sheet.py"), shell=True).stdout
</code></pre>
<p>It appears to be working. Thanks for the ideas.</p>
| 36,406
|
<p>When providing a link to a PDF file on a website, is it possible to include information in the URL (request parameters) which will make the PDF browser plugin (if used) jump to a particular bookmark instead of just opening at the beginning?</p>
<p>Something like: <a href="http://www.somehost.com/user-guide.pdf?bookmark=chapter3" rel="noreferrer">http://www.somehost.com/user-guide.pdf?bookmark=chapter3</a> ?</p>
<p>If not a bookmark, would it be possible to go to a particular page?</p>
<p>I'm assuming that if there is an answer it may be specific to Adobe's PDF reader plugin or something, and may have version limitations, but I'm mostly interested in whether the technique exists at all.</p>
|
<p>Yes, you can link to specific pages by number or named locations and that will always work <strong>if the user's browser uses Adobe Reader as plugin for viewing PDF files</strong>.</p>
<p>For a specific page by number:</p>
<pre><code><a href="http://www.domain.com/file.pdf#page=3">Link text</a>
</code></pre>
<p>For a named location (destination):</p>
<pre><code><a href="http://www.domain.com/file.pdf#nameddest=TOC">Link text</a>
</code></pre>
<p><br/></p>
<p>To create destinations within a PDF with Acrobat:</p>
<ol>
<li>Manually navigate through the PDF for the desired location</li>
<li>Go to View > Navigation Tabs > Destinations</li>
<li>Under Options, choose Scan Document</li>
<li>Once this is completed, select New Destination from the Options menu and enter an appropriate name </li>
</ol>
|
<p><a href="http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf#page=5&zoom=auto,-169,394" rel="noreferrer" title="PDF Open Parameters">PDF Open Parameters</a> documents the available URL fragments you can use.</p>
| 15,275
|
<p>What is the standard encoding of C++ source code? Does the C++ standard even say something about this? Can I write C++ source in Unicode?</p>
<p>For example, can I use non-ASCII characters such as Chinese characters in comments? If so, is full Unicode allowed or just a subset of Unicode? (e.g., that 16-bit first page or whatever it's called.)</p>
<p>Furthermore, can I use Unicode for strings? For example:</p>
<pre><code>Wstring str=L"Strange chars: â Țđ ě €€";
</code></pre>
|
<p>Encoding in C++ is quite a bit complicated. Here is my understanding of it.</p>
<p>Every implementation has to support characters from the <em>basic source character set</em>. These include common characters listed in §2.2/1 (§2.3/1 in C++11). These characters should all fit into one <code>char</code>. In addition implementations have to support a way to name other characters using a way called <code>universal-character-names</code> and look like <code>\uffff</code> or <code>\Uffffffff</code> and can be used to refer to Unicode characters. A subset of them are usable in identifiers (listed in Annex E). </p>
<p>This is all nice, but the mapping from characters in the file, to source characters (used at compile time) is implementation defined. This constitutes the encoding used. Here is what it says literally (C++98 version):</p>
<blockquote>
<p>Physical source file characters are
mapped, in an implementation-defined
manner, to the basic source character
set (introducing new-line characters
for end-of-line indicators) if
necessary. Trigraph sequences (2.3)
are replaced by corresponding
single-character internal
representations. Any source file
character not in the basic source
character set (2.2) is replaced by the
universal-character-name that des-
ignates that character. (An
implementation may use any internal
encoding, so long as an actual
extended character encountered in the
source file, and the same extended
character expressed in the source file
as a universal-character-name (i.e.
using the \uXXXX notation), are
handled equivalently.)</p>
</blockquote>
<p>For gcc, you can change it using the option <code>-finput-charset=charset</code>. Additionally, you can change the execution character used to represet values at runtime. The proper option for this is <code>-fexec-charset=charset</code> for char (it defaults to <code>utf-8</code>) and <code>-fwide-exec-charset=charset</code> (which defaults to either <code>utf-16</code> or <code>utf-32</code> depending on the size of <code>wchar_t</code>). </p>
|
<p>AFAIK It's not standardized as you can put any type of characters in wide strings.
You just have to check that your compiler is set to Unicode source code to make it work right.</p>
| 42,977
|
<p>We're looking for a way to log any call to stored procedures in Oracle, and see what parameter values were used for the call.</p>
<p>We're using Oracle 10.2.0.1</p>
<p>We can log SQL statements and see the bound variables, but when we track stored procedures we see bind variables B1, B2, etc. but no values.</p>
<p>We'd like to see the same kind of information we've seen in MS SQL Server Profiler.</p>
<p>Thanks for any help</p>
|
<p>You could take a look at the <a href="http://download-west.oracle.com/docs/cd/A87860_01/doc/appdev.817/a76936/dbms_app.htm" rel="noreferrer">DBMS_APPLICATION_INFO package</a>. This allows you to "instrument" your PL/SQL code with whatever information you want - but it does entail adding calls to each procedure to be instrumented.</p>
<p>See also <a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:767025833873" rel="noreferrer">this AskTom thread</a> on using DBMS_APPLICATION_INFO to monitor PL/SQL.</p>
|
<p>Yes, I think I should have used the term 'trace'</p>
<p>I'll try to describe what we've done:</p>
<p>Using the enterprise manager (as dbo) we've gone to a session, and started a trace</p>
<p>start trace
Enable wait info, bind info</p>
<p>Run an operation on our application that hits the DB</p>
<p>Finish the trace, run this on the output:</p>
<p>tkprof .prc output2.txt sys=no record=record.txt explain=dbo@DBINST/PW</p>
<p>What we're wanting to see is, "these procedures were called with these parameters" What we're getting is:</p>
<pre><code>Begin dbo.UPKG_PACKAGENAME.PROC(:v0, :v1, :v2 ...); End;
/
Begin dbo.UPKG_PACKAGENAME.PROC2(:v0, :v1, :v2 ...); End;
/
...
</code></pre>
<p>So we can trace the procedures that were called, but we don't get the actual parameter values, just the :v0, etc.</p>
<p>My understanding is that what we've done is the same as the alter system statement, but please let us know if that's not the case.</p>
<p>Thanks</p>
| 31,217
|
<p>I am starting a new <strong>client/server</strong> project at work and I want to start using some of the newer technologies I've been reading about, LINQ and Generics being the main ones. Up until now I have been developing these types of applications with MySQL as clients were unwilling to pay the large licence costs for MSSQL. </p>
<p>I have played around a small amount with the express versions but have never actually developed anything with them. The new application will not have more than 5 concurrent connections but will be needed for daily reporting.</p>
<ol>
<li><p>Can MSSQL 2005 express still be downloaded? I cant seem to find it on the microsoft site. I would be hesitant to use MSSQL 2008 on a project so soon after its release.</p></li>
<li><p>Are the express version adequate for my needs, I'm sure loads of people reading this have used them. Did you encounter any problems?</p></li>
</ol>
|
<p>The answer to the question on any project in regards to what platform/technologies to use is: <strong>What does everyone know best?</strong></p>
<ol>
<li><p>Yes express <a href="http://www.microsoft.com/express/2005/sql/download/" rel="nofollow noreferrer">can still be downloaded</a>.</p></li>
<li><p>Will it fit your requirements? That depends on your requirements, of course. I have deployed MSSQL2005 Express on several enterprise level projects which I knew had a fixed database size that would never be exceeded (Express has a limit of each database of 4Gb). Also keep in mind there are other hardware constraints such as a 1 cpu limit.</p></li>
</ol>
<p>Another thing to consider is if you need the Enterprise level tools that come with a paid edition of SQL Server. If you are moving a lot of flat data around you are stuck writing your own Bulk Copy Procs, which rule the house, but its an extra step, no doubt.</p>
|
<p>Note sure about #2 but you can download <a href="http://www.microsoft.com/sql/editions/express/default.mspx" rel="nofollow noreferrer">SQL Server Express 2005 here</a>.</p>
| 4,646
|
<p>I'm currently developing a website and my client wants the text of various articles to overflow into two columns. Kind of like in a newspaper? So it would look like:</p>
<pre class="lang-none prettyprint-override"><code>Today in Wales, someone actually Nobody was harmed in
did something interesting. the incident, although one
Authorities are baffled by this elderly victim is receiving
development and have arrested the counselling.
perpetrator.
</code></pre>
<p>Is there a way I can do this with just CSS alone? I'd prefer not to have to use multiple divs. I'm open to using JavaScript too, but I'm <em>really</em> bad at that, so help would be appreciated. I was thinking maybe JavaScript could count how many <p>'s there are in the content div, and then move the second half of them to be floated right based on that?</p>
|
<p>The good news is that there is a <a href="http://www.w3.org/TR/css3-multicol/" rel="nofollow noreferrer">CSS-only solution</a>. If it was implemented, it would look like this:</p>
<pre><code>div.multi {
column-count: 3
column-gap: 10px;
column-rule: 1px solid black;
}
</code></pre>
|
<p>First off, i don't think just css can do that, but i would love to be proven wrong.</p>
<p>Second, just counting paragraphs won't help you at all, you need at least all the heights and calculate the middle of the text height based on that, but you'd have to account for window resizing etc. I don't think there is a reasonably simple off the shelf solution. Unfortunately i'm pessimistic about finding a perfect solution to this problem, But it is an interesting one.</p>
| 23,670
|
<p>In my database, I have an entity table (let's call it Entity). Each entity can have a number of entity types, and the set of entity types is static. Therefore, there is a connecting table that contains rows of the entity id and the name of the entity type. In my code, EntityType is an enum, and Entity is a Hibernate-mapped class.<br>
in the Entity code, the mapping looks like this:</p>
<pre><code>@CollectionOfElements
@JoinTable(
name = "ENTITY-ENTITY-TYPE",
joinColumns = @JoinColumn(name = "ENTITY-ID")
)
@Column(name="ENTITY-TYPE")
public Set<EntityType> getEntityTypes() {
return entityTypes;
}
</code></pre>
<p>Oh, did I mention I'm using annotations?<br>
Now, what I'd like to do is create an HQL query or search using a Criteria for all Entity objects of a specific entity type.<p>
<a href="http://opensource.atlassian.com/projects/hibernate/browse/HHH-869?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel" rel="nofollow noreferrer">This</a> page in the Hibernate forum says this is impossible, but then this page is 18 months old. Can anyone tell me if this feature has been implemented in one of the latest releases of Hibernate, or planned for the coming release?</p>
|
<p>HQL:</p>
<pre><code>select entity from Entity entity where :type = some elements(entity.types)
</code></pre>
<p>I think that you can also write it like:</p>
<pre><code>select entity from Entity entity where :type in(entity.types)
</code></pre>
|
<p>Is your relationship bidirectional, i.e., does <code>EntityType</code> have an <code>Entity</code> property? If so, you can probably do something like <code>entity.Name from EntityType where name = ?</code></p>
| 7,185
|
<p>I have run across an XML Schema with the following definition:</p>
<pre><code><xs:simpleType name="ClassRankType">
<xs:restriction base="xs:integer">
<xs:totalDigits value="4"/>
<xs:minInclusive value="1"/>
<xs:maxInclusive value="9999"/>
</xs:restriction>
</xs:simpleType>
</code></pre>
<p>However, it seems to me that <code>totalDigits</code> is redundant. I am somewhat new to XML Schema, and want to make sure I'm not missing something.</p>
<p>What is the actual behavior of <code>totalDigits</code> vs. <code>maxInclusive</code>?</p>
<p>Can <code>totalDigits</code> always be represented with a combination of <code>minInclusive</code> and <code>MaxInclusive</code>? </p>
<p>How does <code>totalDigits</code> affect negative numbers?</p>
|
<blockquote>
<p>can totalDigits always be represented with a combination of minInclusive and MaxInclusive?</p>
</blockquote>
<p>In this case, yes. As you're dealing with an integer, the value must be a whole number, so you have a finite set of values between <code>minInclusive</code> and <code>maxInclusive</code>. If you had decimal values, <code>totalDigits</code> would tell you how many numbers in total that value could have.</p>
<blockquote>
<p>How does totalDigits affect negative numbers?</p>
</blockquote>
<p>It is the total number of digits allowed in the number, and is not affected by decimal points, minus signs, etc. From <a href="http://www.auxy.com/study/xml_notes/04.Adding_XSD_restrictions/" rel="noreferrer">auxy.com</a>:</p>
<blockquote>
<p>The number specified by the value attribute of the <code><xsd:totalDigits></code> facet will restrict the total number of digits that are allowed in the number, on both sides of the decimal point.</p>
</blockquote>
|
<p>totalDigits is the total number of digits the number can have, including decimal numbers. So a totalDigits of 4 would allow 4.345 or 65.43 or 932.1 or a 4 digit whole integer as in the example above. Same for negative. Any of those previous examples can all be made negative and still validate as a totalDigits of 4.</p>
<p>max and min inclusive/exclusive limit the range of the numbers. The maxinclusive might seem be a little redundant in your example, but the mininclusive makes certain the number is greater than 0.</p>
| 20,330
|
<p>We have recently implemented Transparent Data Encryption in SQL Server 2008 for local databases on our developers laptops to keep them protected in the case a laptop is stolen or lost. This works fine. </p>
<p>Now we are trying to figure out a way to have the certificate expire everyday, forcing an automated process (a script at logon maybe) to go out to a network path and grab a new certificate with an expiration for a day later. This would ensure that if something unforeseen happened, the data would not be usable the next day.</p>
<p>I also looked into using a Cryptographic provider but there doesn't appear to be any "providers" out there. Maybe I'm wrong.</p>
<p>I am open to suggestions. If there is a better way please let me know. Thanks!</p>
|
<p>Short answer: No</p>
<p>Long answer: Once a message (piece of data) is encrypted, that same key will decrypt the same encrypted message, regardless of what time the decryption algorithm is applied. If the key is changed every day, the data must be decrypted with the old key and re-encrypted with the new. If this process doesn't occur (i.e. someone stops the piece of code that performs the re encryption from running), the old key will still work. Even if you do create a cryptographic provider to check the date, someone else can create a new provider to perform the decryption without first checking the date.</p>
|
<p>Without additional detail I fail to understand how your TDE setup will protect data in case it is lost or stolen. </p>
<p>If you are not using full disk encryption (via Bitlocker, Truecrypt, etc) then I as an attacker in physical possession of your hardware can easily reset the local admin password, boot up the laptop and access the SQL Server instance with the local admin credentials. At that point I am a sysadmin on the database server and am able to extract any data I want or to turn off TDE.</p>
<p>In addition since all of the encryption keys and certificates are stored locally it is relatively easy for an attacker in physical possession of the device to gain access to them. TDE is only meaningful for data protection when you physically separate the Database Encryption Key protectors (stored in the master database) from the encrypted database.</p>
<p>If you are using full disk encryption than the usage of TDE is not providing any additional deterrent to an attacker and is only adversely affecting system performance of your developers laptops.</p>
| 24,335
|
<p>I am releasing a database build to SQL Server 2000 via a batch file using isql. The batch file is used so multiple files are released consistently to different SQL Servers (development, test, live).</p>
<p>The SQL Server uses ANSI code page 1252 (from sp_helpsort) but isql is an OEM client using code page 437. This means that all extended characters (with ASCII code > 128) are converted when the scripts are run, leading to inconsistent results when characters like “£” are included in the script. Differences are explained in this <a href="http://support.microsoft.com/?scid=kb;EN-US;153449" rel="nofollow noreferrer">Microsoft knowledgebase article</a>.</p>
<p>Possible solutions are: -</p>
<ul>
<li>Save the script using Unicode and
use osql.</li>
<li>Turn off the AutoAnsiToOem setting using the SQL Server Client Network Utility (that writes a registry key).</li>
</ul>
<p>Both these options rely on various people doing things consistently. All have to select the same code page option when saving a file OR all people performing the builds have to have the same option set for AutoAnsiToOem.</p>
<p>Is there a way to force the use of a code page either in the SQL script OR in the batch file that calls it, so that the build is always released consistently, regardless of how the file is saved or the various settings of whoever performs the release?</p>
|
<p><code>isql</code> is obsolete. It isn't included in SQL Server 2005 or later, because it uses the DB-Library connections, which are also obsolete. For the reasons why, and the effects this has, see <a href="http://msdn.microsoft.com/en-us/library/aa174595(SQL.80).aspx" rel="nofollow noreferrer">Connecting Early Version Clients to SQL Server 2000</a>.</p>
<p><code>osql</code> uses ODBC connections to connect to SQL Server. For completeness, this has been supplemented by <code>sqlcmd</code> in SQL Server 2005, which uses OLE DB with the SQL Native Client provider.</p>
|
<p>Further to the accepted answer, I have tested using sqlcmd against a SQL Server 2000 database and it works. You obviously have to run sqlcmd from a machine with the SQL Server 2005 client tools installed.</p>
| 14,601
|
<p>Java SE 6 (64 bit only) is now on OS X and that is a good thing. As I understand it since Eclipse is still Carbon and thus 32 bit, it cannot be used for 1.6 on Leopard, only 1.5. </p>
<p>Does anyone know if NetBeans 6.x can be used with Java SE 6 on Leopard utilizing its JVM?</p>
|
<p>Yes, you should be able to. </p>
<p>A number of blogs have reported running Netbeans on 1.6 as well as the the problems they had with earlier versions of NB. The NB issue tracker also has a number of bugs that have been fixed that affected 1.6 on Mac OS.</p>
<p>If you have trouble getting it to run, you might also try <a href="http://www.nabble.com/Netbeans.org-f2602.html" rel="nofollow noreferrer">the Netbeans forum</a>.</p>
|
<p>I haven't tried it yet, but can't think of any reason why not.</p>
| 21,016
|
<p>Are there any good reasons not to use \u0000 as a delimiter within a Java String? I would be encoding and decoding the string myself.</p>
<p>This is for saving a list of user-inputted (I'm expecting input to be typed?) strings to an Eclipse preference and reading it back. The list may be variable size so I don't think I can save each item to its own preference.</p>
|
<p>There used to be some libraries which erroneously handled Java strings as null terminated. I don't know if it's still true but it's worth keeping such things in mind. Especially if you interop with external libraries that will handle strings as null terminated.</p>
|
<p>Sounds like you are trying to use it to store a list. Why not use <code>ArrayList<String></code> ? Having a <code>\u0000</code> in a String is bad. Consider using a byte array. </p>
<p>As you say its for saving something in the eclipse settings, i wouldn't use embedded NULs, since the files seem to be user-readable (in my ~/.eclipse at least). What do you want to save? You could stringize the items ("item 2" "item 2") for example. Just don't complicate it too much. </p>
| 41,206
|
<p>I want to use the same functionality available when a Panel.AutoScroll is true, but with the scrollbars invisible.</p>
<p>To do so I need to know how can I scroll to left/right up/down using functions in my code.</p>
|
<p>You should be able to use the VerticalScroll and HorizontalScroll properties of the component:</p>
<pre><code>c.HorizontalScroll.Value += 100;
c.VerticalScroll.Value = c.VerticalScroll.Maximum;
</code></pre>
|
<p>There's probably a property on the panel to do this, alternatively you can loop through all the panels children and adjust their positions.</p>
<p>Eg. to move all controls 10 px:</p>
<pre><code>int xoffset = 10;
foreach(Control c in panel1.Controls)
c.Location.X += xoffset;
</code></pre>
<p>The controls can be moved to negative positions to make them move out of the panel, similarly they can have location values bigger than the panels size to make them move out of the panel.</p>
| 32,863
|
<p>I currently am trying to write a Python program using scheme semantics so I can later translate it into Scheme without relying on a lot of Pythonic stuff.</p>
<p>I'm trying solve the sliding puzzle problem (where you have 9 slots and 8 tiles arranged in a square) using a*, depth first, and breadth first search algorithm. I did this ~11 years ago in some AI class in Lisp, but basically at the time I had no idea about lisp, I hated it with all my heart, and only in retrospect do I realize I was programming "C" in Lisp. The prof didn't help in this matter.</p>
<p>I have a python function which can swap two tiles easily: </p>
<pre><code>def swap(p, (r1, c1), (r2, c2)):
# Swaps *any* two locations and returns new configuration
# Does not concern itself with zero location, etc
# Not sure how to do this functionally
p_p = p[:]
temp = p_p[r1][c1]
p_p[r1][c1] = p_p[r2][c2]
p_p[r2][c2] = temp
return p_p
</code></pre>
<p>I'd like to turn this into something you might find in SICP, avoiding side effects, etc. </p>
<p>But this brings up a question. Everything I read in SICP is loops via recursion. I didn't see anything in accessing arrays/vectors/lists in constant time. I can imagine a loopish/recursive way to read an element, but I find it harder to imagine a way to create a new list with a certain element changed, without invoking side-effect producing things like set!, and without resorting to crazy if/then/else clauses concerning which element should be changed. This of course gets more confusing when considering a 2d array. In this case the solution with python is obvious because of its native support for multidimensional arrays.</p>
<p>In C/C++/Python/Matlab/Lua/anything else, accessing lists/arrays via the [i] syntax is easy, and directly translates to a hardware-oriented pointer lookup somewhere underneath. I don't understand how scheme does this, given the atomic operations defined in the SICP version of scheme, which all seem very loop-and-search oriented. How do the vector and list array access functions work to get constant time access? (I'm a total newbie here, so I'm not ever sure what functions I'd be talking about). Is there a C or Assembly library someplace which is secretly being accessed? Are there any inherent constant-time semantics in scheme which could be used for list/array/vector access, and which would allow me a guilt-free way of using that idiom in Python for the moment? </p>
<p>How would can I rewrite the above function in python using Schemish semantics? How would I rewrite the above function in Scheme?</p>
|
<p>I wrote an 8-puzzle solver in Lisp about a year ago. I just used a list of 3 lists, each sublist with 3 elements being the numbers. It's not constant time, but it is portable.</p>
<p>Anyways, if you are really interested in doing this functionally (Scheme doesn't require you to) what is easiest to do is to create some helper functions that will get a specific value given row/col and 'set' a value given row/col. Instead of modifying the original data structure, the set operation will construct the new state based on the old state.</p>
<p>Then you can write a swap operation based on these get and set operations. Here's what I wrote about a year ago in Common Lisp, but it's easily convertible to Scheme:</p>
<pre><code>; getval
;
; This function takes a position (r . c) where and returns the corresponding
; number in the 8-puzzle state. For example, if you wanted (1 . 2) from
; ((1 2 3) (4 5 6) (7 8 9)), the value would be 6. The r and c values begin
; at 0.
;
; parameters: pos The position to get
; state The 8-puzzle state
; returns: The value at pos in state
(defun getval (pos state)
(if (null state) 'no-value
(if (= 0 (car pos))
(if (= 0 (cdr pos))
(caar state)
(getval (cons (car pos) (- (cdr pos) 1)) (list (cdar state))))
(getval (cons (- (car pos) 1) (cdr pos)) (cdr state)))))
; setval
;
; This function returns a state where the value at pos is replaced by val.
; Like getval, this function is zero-based. Accessing beyond the size of
; the state is undefined (and probably broken)
;
; parameters: pos Position to set
; val Value to set
; state State to modify
; returns: New state where pos is val
(defun setval (pos val state)
(if (null state) '()
(if (= 0 (car pos))
(if (= 0 (cdr pos))
(cons (cons val (cdar state)) (cdr state))
(let ((temp (setval (cons (car pos) (- (cdr pos) 1)) val
(cons (cdar state) (cdr state)))))
(cons (cons (caar state) (car temp)) (cdr temp))))
(cons (car state) (setval (cons (- (car pos) 1) (cdr pos)) val (cdr state))))))
; state-swap
;
; This function takes a state and two positions and returns a new state with
; the values in those two positions swapped.
;
; parameters: state State to swap within
; a Position to swap with b
; b Position to swap with a
; return: State with a swapped with b
(defun state-swap (state a b)
(let ((olda (getval a state)) (oldb (getval b state)))
(setval a oldb (setval b olda state))))
</code></pre>
|
<p>Cool, thanks for the lisp code. I'll need to study it to make sure I get it.</p>
<p>As for the first answer, the first time I was "writing c" in lisp because that's the only way I knew how to program and didn't have a clue why anyone would use lisp. This time around, I've been playing around with scheme, but wanted to use python so if I got stuck on something I could "cheat" and use something pythonish, then while waiting for usenet answers go on to the next part of the problem.</p>
| 45,149
|
<p>My installer build "signs" a DLL using a Code Signing certificate during the build process. </p>
<p>I've noticed that if I try to build twice in succession, the second build fails because the DLL is already signed so signcode chokes. Obviously I can fix this by signing a copy of the DLL in the build, but the problem intrigued me: </p>
<p>Is it possible to "unsign" a DLL, and if not, why not...?</p>
|
<pre><code>signtool remove /s C:\path\to.exe.or.dll
</code></pre>
<p><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa387764(v=vs.85).aspx" rel="noreferrer">signtool</a> is available in Windows SDK, and must be at least from Windows 8 SDK kit (version 6.2.9200.20789) to have the <code>remove</code> command supported.</p>
|
<p>Check if your build tool supports "Re-signing". This should replace all existing signatures.</p>
<p>If not, you can use <a href="http://www.cgsoftlabs.ro/studpe.html" rel="nofollow">Stud_PE</a> to remove the signature block.
Open the DLL or EXE in Stud_PE, go to the sections tab, right click the digital signature section and select "Delete section". However, this needs user interaction. Old versions of the tool could destroy the file.</p>
| 44,329
|
<p>I recently got a KP3S Kingroon 3D printer and have been trying to set it up.</p>
<p>After a couple of test prints, the Y-axis seems to only move in one direction. At first, I thought it was a motor issue, but when I go into the manual move directions for the Y-axis it seems that both inputs lead to the motor spinning in the same direction.</p>
<p>We have ruled out endstops as a possible issue. I think it might be a hardware issue but lack the skills to confirm the exact issue.</p>
<pre><code>Send:17:40:57.724: @moveRel Y10.00
Send:17:40:57.724: N31 G1 Y10.00 F6000
Send:17:40:57.728: @updatePrinterState
Send:17:41:00.824: @moveRel Y-10.00
Send:17:41:00.824: N35 G1 Y0.00 F6000
Send:17:41:00.828: @updatePrinterState
Send:17:41:07.445: @moveRel Y10.00
Send:17:41:07.445: N43 G1 Y10.00 F6000
Send:17:41:07.449: @updatePrinterState
Send:17:41:09.482: @moveRel Y-10.00
Send:17:41:09.482: N46 G1 Y0.00 F6000
Send:17:41:09.486: @updatePrinterState
</code></pre>
<p>Even though it states that it is increasing and decreasing by 10 it only decreases by 10.</p>
<p>I have updated the firmware to Marlin. I tested switching X and Y inputs and believe the breakdown occurs at the Y input signal.</p>
<p>attached is a picture of the mother board.</p>
<p><a href="https://i.stack.imgur.com/nhmP2.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nhmP2.gif" alt="picture of mother board" /></a></p>
<p>I am unsure of how to best fix this?</p>
|
<p>The answer might just be replace the mother board.</p>
<p>If I understood everything correctly there are 5 things to check to break down the problem:</p>
<ul>
<li>the motor,</li>
<li>the cable,</li>
<li>the stepper connection,</li>
<li>the software input, and</li>
<li>the firmware.</li>
</ul>
<p>Using Repetier I disproved that the software was broken. By switching the X stepper and Y stepper cables, the motor and connection cable were proven to work. By flashing new firmware it was shown that it was without question that the firmware was the issue.</p>
<p>The backup extractor (E1) is not operational on this board. So it is either the stepper of the mother board.</p>
|
<p>The question body has changed to rule out broken endstops. As a generic answer for steppers only going into a single direction, if an axis of a 3D printer only moves in one direction it usually implies that the end stop of that axis is triggered. If triggered, the firmware doesn’t allow the stepper to move to the direction of the end stop.</p>
<p>Check the end stop lever and cables. Optionally connect a USB cable and send the G-code <a href="https://reprap.org/wiki/G-code#M119:_Get_Endstop_Status" rel="nofollow noreferrer"><code>M119</code></a> over a <a href="https://3dprinting.stackexchange.com/questions/10573/what-is-a-printer-console-terminal">terminal</a>.</p>
<p>If the endstops are functioning correctly (reporting “open” or “triggered” corresponding to the state of the endstop), a Google search on the World Wide Web shows that people that had these exact problems had issues with the controller board, replacing the board helped their issue. If this is a recent purchase it is advised to contact the seller for support rather than fiddling with the board or the firmware.</p>
<p>In case the board has a spare unused stepper driver (not very unlikely if you have <a href="https://www.google.nl/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwiX5PGlv4b1AhURDuwKHU5JBuQQFnoECBMQAQ&url=https%3A%2F%2Fnl.aliexpress.com%2Fitem%2F1005001621822311.html&usg=AOvVaw1uT5ZgSK04dlnQvoBgHSKF" rel="nofollow noreferrer">this controller board</a>), the firmware could be altered to use the spare for Y movement. <a href="https://3dprinting.stackexchange.com/a/5786/">E.g. <code>E1</code> could be used for <code>Y</code>.</a></p>
| 2,083
|
<p>I have an application where I perform hundreds of thousands of calculations. Currently all of our values are Doubles. I am utilizing JFormula engine for most of the calculations, and have noticed the api takes a double parameter, so there is some autoboxing taking place when I pass in a Double. I have read some articles, and created some simple tests, and do notice a performance hit, but am still trying to figure out it the time it takes to go through my code and fix this, will be worth any performance improvements. I am wondering if anyone else has had any experience with something similar and performance gains by using primitives?</p>
|
<p>As well as the other suggestions (which are good - profiling and benchmarking are very important) I'd say that if JFormula is doing <em>anything</em> significant within each method call then the boxing/unboxing when making the call is likely to be insignificant. Unboxing in particular is fast as it doesn't require any memory allocation - just copying the existing value from the box, really.</p>
<p>In short: certainly do the tests, but I wouldn't <em>expect</em> the hit to be significant.</p>
|
<p>What you can try is to make simple benchmarks with and without autoboxing. run them through a time-profiler (visualvm recommended). Find the time difference and scale it to your program to find approximate time hit in your program</p>
| 29,806
|
<p>We have a POST to a PL/SQL database procedure that (a) does some database operations based on the POST parameters and (b) redirects the user to a page showing the results.</p>
<p>The problem is, when the user does a browser "refresh" of the results page, that still has the original request, so it calls the database procedure and resends the parameters. </p>
<p>There are things we can do with saving state so bad things don't happen if the request gets sent in again. But that got me wondering. </p>
<p>Is there a way to tell the browser to set the url to the redirect call, not the original user request? This would probably be in either the redirect itself, or in Javascript on the target page. </p>
|
<p>see <a href="http://www.decompile.com/cpp/faq/file_and_line_error_string.htm" rel="noreferrer">http://www.decompile.com/cpp/faq/file_and_line_error_string.htm</a>
specifically:</p>
<pre><code>#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define AT __FILE__ ":" TOSTRING(__LINE__)
</code></pre>
<p>so your problem can be solved by doing
<code>sscanf(buf, "%" TOSTRING(MAX_LEN) "s", val);</code></p>
|
<p>While some of the above "work", personally I'd recommend just using a simple string API instead of the dreck that comes in libc. There are a number of portable APIs, some of which are also optimized for ease of inclusion in your project ... and some like <a href="http://www.and.org/ustr/" rel="nofollow noreferrer">ustr</a> have tiny space overhead and support for stack variables.</p>
| 29,753
|
<p>A brief search shows that all available (uUnix command line) tools that convert from xsd (XML Schema) to rng (RelaxNG) or rnc (compact RelaxNG) have problems of some sort.</p>
<p>First, if I use rngconv:</p>
<pre><code>$ wget https://msv.dev.java.net/files/documents/61/31333/rngconv.20060319.zip
$ unzip rngconv.20060319.zip
$ cd rngconv-20060319/
$ java -jar rngconv.jar my.xsd > my.rng
</code></pre>
<p>It does not have a way to de-normalize elements so all end up being alternative start elements (it also seems to be a bit buggy).</p>
<p>Trang is an alternative, but it doesn't support xsd files on the input only on the output (why?). It supports DTD, however. Converting to DTD first comes to mind, but a solid xsd2dtd is hard to find as well. The one below:</p>
<pre><code> $ xsltproc http://crism.maden.org/consulting/pub/xsl/xsd2dtd.xsl in.xsd > out.dtd
</code></pre>
<p>Seems to be buggy.</p>
<p>All this is very surprising. For all these years of XML (ab)use, there no decent command line tools for these trivial basic tasks? Are people using only editors? Do those work? I much prefer command line, especially because I'd like to automate these tasks.</p>
<p>Any enlightening comments on this?</p>
|
<p>Converting XSD is a very hard task; the XSD specification is a bit of a nightmare and extremely complex. From some quick <a href="http://www.tbray.org/ongoing/When/200x/2006/11/27/Choose-Relax" rel="nofollow noreferrer">research,</a> it seems that it is easy to go from RelaxNG to XSD, but that the reverse may not be true or even possible (which explains your question about Trang).</p>
<p>I don't understand your question about editors - if you are asking if most people end up converting between XSD and RNG by hand, then yes, I expect so.</p>
<p>The best advice may be to avoid XSD if possible, or at least use RNG as the definitive document and generate the XSD from that. You might also want to take a look at <a href="http://www.schematron.com/" rel="nofollow noreferrer">schematron</a>.</p>
|
<p>Again, regarding editors: I see that there's no way to do this with Oxygen which seems to be a popular tool.</p>
| 14,836
|
<p>I am looking to purchase a new development PC. My budget is not more than $1,000 USD (including monitor). I am open to laptop (desktop replacement type) or the traditional desktop PC would do just fine.</p>
<p>My primary development environment will be Microsoft, Visual Studio 2008 (and support of older Visual Studio 6 code as well). SQL Server 2005, 2008 as well as legacy support of SQL Server 2000. Microsoft Office 2003, potential to install 2007 but support as far back as Office 2000. The software I will wrote and support will be Windows XP mostly, but some Vista. I am going to have to assume there are 64-bit implementations out there to install to.</p>
<p>My first confusion begins with choosing AMD or Intel. My concern is that there is a compatibility issue with building software using Visual Studio in an AMD environment. I dont have any evidence, its just a concern that hopefully someone will clear up for me.</p>
<p>Last, I am confused about 32-bit and 64-bit installations. Should I stick with the least common denominator (32-bit) even though 64-bit is steadily gaining ground? I am aware that the 64-bit operating systems will address over 4G of RAM and that I like because I would like to set up as many Virtual Machines for test environments as possible, and may have many active at once..</p>
<p>I am not looking for the dream machine, just a machine with a monitor and the best processor for about $1000 that will allow me to write software for the majority of machines out there.</p>
|
<p>There are some instruction level differences between AMD and Intel but nothing that Visual Studio is going to uncover. Perhaps if you were developing with Sun Studio you might run into them (I have!). </p>
<p>I would go for a 64 bit machine and run 32 bit VMs on it if you feel the need to do testing in that environment. The common feeling around here seems to be that the highest level of Vista you can afford is the platform on which to develop. </p>
|
<p>Get 4 gigs rams minimum equal that you need a system that can handle more than 3 gigs (so 64bits OS). Rams is cheap and IDE with all others software (debugging, testing, database client, etc) will require you some rams if you want something fast.</p>
| 18,744
|
<p>The current guidlelines for explicit member implementation recommend:</p>
<ul>
<li>Using explicit members to approximate private interface implementations. <em>If you need to implement an interface for only infrastructure reasons and you <strong>never</strong> expect developers to directly call methods on that interface from this type then implement the members explicitly to 'hide' them from public view</em>.</li>
<li>Expose an alternative way to access any explicitly implemented members that subclasses are allowed to override.</li>
</ul>
<p>A good example of this is when you want to implement the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.ixmlserializable.aspx" rel="nofollow noreferrer">IXmlSerializable</a> interface. The <strong>ReadXml</strong> and <strong>WriteXml</strong> methods are expected to be called by the XmlSerializer and are not typically called directly by developers. </p>
<p>When providing an alternative way to access explicitly members you wish to allow to be overridden, it seems to make sense to call the explicitly implemented member so as to avoid code duplication. Consider the following:</p>
<pre><code>using System;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
namespace Demo
{
/// <summary>
/// Demonstrates explicit implementation of the IXmlSerializable interface.
/// </summary>
[Serializable(), XmlRoot(ElementName = "foo")]
public class Foo : IXmlSerializable
{
//============================================================
// IXmlSerializable Implementation
//============================================================
#region GetSchema()
/// <summary>
/// Returns an <see cref="XmlSchema"/> that describes the XML representation of the object.
/// </summary>
/// <returns>
/// An <see cref="XmlSchema"/> that describes the XML representation of the object that is
/// produced by the <see cref="IXmlSerializable.WriteXml(XmlWriter)"/> method and consumed by the <see cref="IXmlSerializable.ReadXml(XmlReader)"/> method.
/// </returns>
/// <remarks>This method is reserved and should not be used.</remarks>
XmlSchema IXmlSerializable.GetSchema()
{
return null;
}
#endregion
#region ReadXml(XmlReader reader)
/// <summary>
/// Generates an object from its XML representation.
/// </summary>
/// <param name="reader">The <see cref="XmlReader"/> stream from which the object is deserialized.</param>
/// <exception cref="ArgumentNullException">The <paramref name="reader"/> is a <b>null</b> reference (Nothing in Visual Basic).</exception>
void IXmlSerializable.ReadXml(XmlReader reader)
{
// Class state values read from supplied XmlReader
}
#endregion
#region WriteXml(XmlWriter writer)
/// <summary>
/// Converts an object into its XML representation.
/// </summary>
/// <param name="writer">The <see cref="XmlWriter"/> stream to which the object is serialized.</param>
/// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a <b>null</b> reference (Nothing in Visual Basic).</exception>
void IXmlSerializable.WriteXml(XmlWriter writer)
{
// Current class state values written using supplied XmlWriter
}
#endregion
//============================================================
// Public Methods
//============================================================
#region WriteTo(XmlWriter writer)
/// <summary>
/// Saves the current <see cref="Foo"/> to the specified <see cref="XmlWriter"/>.
/// </summary>
/// <param name="writer">The <see cref="XmlWriter"/> stream to which the <see cref="Foo"/> is serialized.</param>
/// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a <b>null</b> reference (Nothing in Visual Basic).</exception>
public void WriteTo(XmlWriter writer)
{
writer.WriteStartElement("foo");
((IXmlSerializable)this).WriteXml(writer);
writer.WriteEndElement();
}
#endregion
}
}
</code></pre>
<p>My question is in regards to how expensive the boxing of the <strong>WriteXml</strong> method is in this implementation. Is <em>((IXmlSerializable)this).WriteXml(writer)</em> going to significantly hinder performance? </p>
|
<p>There's no boxing taking place in your example... it's just a cast, and it's resolvable at compile time, so it should not have any impact on performance at all.</p>
<p><strong>Edit:</strong> Looking at it with ILDASM, the interface cast will give you a virtual method call versus a regular method call, but this is negligible (there is still no boxing involved).</p>
<p><strong>Edit 2:</strong> If you use a struct instead of a class, THEN you will get a box going through the interface, with much more of a performance penalty.</p>
|
<p>Why not just have them both call a private method that performs the function of the explicitly implemented interface?</p>
<pre><code>public void IXmlSerializable.WriteXml( XmlWriter writer )
{
InternalWriteXml( writer );
}
public void WriteTo(XmlWriter writer)
{
writer.WriteStartElement("foo");
InternalWriteXml(writer);
writer.WriteEndElement();
}
private void InternalWriteXml( XmlWriter writer )
{
...
}
</code></pre>
| 43,130
|
<p>From wikipedia: </p>
<blockquote>
<p>the cross product is a binary operation on two vectors in a <strong>three-dimensional</strong> Euclidean space that results in another vector which is perpendicular to the plane containing the two input vectors.</p>
</blockquote>
<p>Given that the definition is only defined in three (<a href="https://en.wikipedia.org/wiki/Seven-dimensional_cross_product#Consequences_of_the_defining_properties" rel="noreferrer">or seven, one and zero</a>) dimensions, how does one calculate the cross product of two 2d vectors?</p>
<p>I have seen two implementations. One returns a new vector (but only accepts a single vector), the other returns a scalar (but is a calculation between two vectors).</p>
<p>Implementation 1 (returns a scalar):</p>
<pre><code>float CrossProduct(const Vector2D & v1, const Vector2D & v2) const
{
return (v1.X*v2.Y) - (v1.Y*v2.X);
}
</code></pre>
<p>Implementation 2 (returns a vector):</p>
<pre><code>Vector2D CrossProduct(const Vector2D & v) const
{
return Vector2D(v.Y, -v.X);
}
</code></pre>
<p>Why the varying implementations? What would I use the scalar implementation for? What would I use the vector implementation for?</p>
<p>The reason I ask is because I'm writing a Vector2D class myself and don't know which method to use.</p>
|
<p>Implementation 1 returns the magnitude of the vector that would result from a regular 3D cross product of the input vectors, taking their Z values implicitly as 0 (i.e. treating the 2D space as a plane in the 3D space). The 3D cross product will be perpendicular to that plane, and thus have 0 X & Y components (thus the scalar returned is the Z value of the 3D cross product vector).</p>
<p>Note that the magnitude of the vector resulting from 3D cross product is also equal to the <em>area</em> of the parallelogram between the two vectors, which gives Implementation 1 another purpose. In addition, this area is signed and can be used to determine whether rotating from V1 to V2 moves in an counter clockwise or clockwise direction. It should also be noted that implementation 1 is the determinant of the 2x2 matrix built from these two vectors.</p>
<p>Implementation 2 returns a vector perpendicular to the input vector still in the same 2D plane. Not a cross product in the classical sense but consistent in the "give me a perpendicular vector" sense.</p>
<p>Note that 3D euclidean space is closed under the cross product operation--that is, a cross product of two 3D vectors returns another 3D vector. Both of the above 2D implementations are inconsistent with that in one way or another.</p>
<p>Hope this helps...</p>
|
<p>I'm using 2d cross product in my calculation to find the new correct rotation for an object that is being acted on by a force vector at an arbitrary point relative to its center of mass. (The scalar Z one.)</p>
| 30,233
|
<p>I have a site, foo.com, that makes ajax requests to bar.foo.com. Will this work.</p>
<p>Also, if foo is a secure connection, https, does bar.foo.com need to be https too? Can these two sites use different certificates?</p>
|
<p>With plain-http AJAX: You are talking about doing cross-domain XMLHttpRequest, which is not permitted by browsers. There's a <a href="https://wiki.mozilla.org/Cross_Site_XMLHttpRequest" rel="noreferrer">W3C proposal pending</a> to implement this in a secure way in the future (partially implemented by IE8, IIRC), but it's definitely not possible at present.</p>
<p>There are, however, workarounds for doing it securely: <a href="http://www2007.org/program/paper.php?id=801" rel="noreferrer">Subspace</a> (which uses iframes and <code>document.domain</code>), the <a href="http://softwareas.com/cross-domain-communication-with-iframes" rel="noreferrer">fragment identifier technique</a> (again, uses iframes) and <a href="http://www.sitepen.com/blog/2008/07/22/windowname-transport/" rel="noreferrer"><code>window.name</code> technique</a> (again, iframes!).</p>
<p>As far as SSL goes, you can buy separate certificates for the domain and subdomain, or a single wildcard (*.foo.com) cert that covers them both (naturally, the wildcard cert will be more expensive).</p>
<p>If you have an HTTPS page that requests items from other domains, all will be well as long as everything is HTTPS. That means that if you use one of the iframe workarounds, you have to specify an <code>https://</code> scheme URL in the <code>src</code> attribute of the iframe.</p>
<p>A final, less efficient, workaround is to have a script on <code>https://foo.com</code> that proxies requests to insecure <code>http://bar.foo.com</code>. (This also solves the XHR cross-domain problem, so you can ignore the other workarounds.) Of course, that means you're sending the XHR request to <code>https://foo.com/someurl</code>, it's then hitting <code>http://bar.foo.com/someurl</code>, receiving the response and sending it back to the browser, so performance-wise you're much better off just moving the server-side functionality of bar.foo.com onto foo.com, if you have that option. But if you can't move the server script, then proxying is the way to go.</p>
<p><strong>EDIT:</strong> I changed the last 3 grafs after doing some extra testing and getting an iframe AJAX workaround (the #fragmentidentifier one) to work across different HTTPS domains. You <em>can</em> do SSL cross-domain AJAX using iframes as long as everything is <code>https</code> and the <code>https</code> scheme is used in the iframe <code>src</code>. Summarizing:</p>
<ol>
<li>Short answer: no, true cross-domain XHR not allowed</li>
<li>Workaround with
iframes: more efficient, need 2 SSL
certs (or wildcard cert), somewhat
complicated</li>
<li>Workaround with proxy:
less efficient, can do with 1 or 2
SSL certs (1 with backend request to bar.foo.com via http), somewhat complicated</li>
</ol>
|
<p>Most browsers will, depending on their security/privacy setting, block any outside call made - and only allow AJAX calls made to the same domain. Even subdomains are blocked, because on shared environments they might pose a real threat.</p>
<p>In short: only make AJAX calls through the same domain (perhaps call a page, that in turn calls another page from another domain - through curl/fopen/...), or you'll run into troubles. That also answers your SSL question - it doesn't matter what SSL you're using, or whether they're the same - calls will get blocked, despite the SSL.</p>
| 28,655
|
<p>Expanding on <a href="https://stackoverflow.com/questions/7535/sql-server-2008-compatability-with-sql-server-2005">this question</a>, what is the best way to develop against both SQL Server 2005 and SQL Server 2008?</p>
<p>I'd like to see if I could just use Orcas technology on my current Vista 64 machine and since SQL Server 2005 wants to install a stub version of Visual Studio 2005, I'd like to avoid using it. However, most places where my technology would be deployed are on SQL Server 2005 for the foreseeable future.</p>
<p>So what would be the best course of action:</p>
<ol>
<li>Install SQL Server 2008 only on my development machine and just be cognizant of the 2008-specific abilities</li>
<li>Install SQL Server 2008 and SQL Server 2005 on separate instances on my development machine and develop against either depending on what the production project requires</li>
<li>Install SQL Server 2008 only on my development machine and install SQL Server 2005 on a different machine (like a test server)</li>
<li>Install SQL Server 2005 only on my development machine and install SQL Server 2008 on a different machine (like a test server)</li>
</ol>
|
<p>The safest practice is to code against the oldest database server you support. This version is the one that will be far more likely to give you trouble. By and large the new versions of the db will have backwards compatibility to support your TSQL and constructs. It is far to simple to introduce unsupported code into the mix when using a newer version db then your target. </p>
|
<p>The referenced question suggests changing the database compatibility level, this is a short term solution that would not be automated easily. </p>
<p>Its important to have automated testing, and if your reading stackoverflow, you probably agree. </p>
<p>I would say get both MS SQL Server 2005 and 2008 running.<br>
Then, assuming you run unit tests, always unit test your database code against both servers. </p>
| 14,803
|
<p>I'm going to be building an application within the next six months that will be functioning as a 2-way video-conferencing system, as well as sharing some other data back and forth. I'll probably be using some sort of relatively expensive USB webcam, and am aware of the USB Video Class Device standard, which seems to the way to go.</p>
<p>Now, what can I use to program against that (or some other direction)? OS is not that important as it is not decided (will choose to fit overall needs), nor is language. Network will be VPN, worst case 256kbps symmetrical. Ideally it would handle encoding and compression too, but basically I'm just looking for some sort of starting point to begin research (have just found TAPI and H.323 so far, not sure of best way to program them).</p>
|
<p>with gnome, you have <a href="http://ekiga.org" rel="nofollow noreferrer">ekiga</a>. You can cross compile it for win32 too. It uses OPAL (Open Phone Abstraction Library) underneath. Maybe the tool itself will suit your needs, otherwise you can adapt it (OSS) or you can only keep low level API</p>
|
<p>I agree with PW.</p>
<ul>
<li>OPAL is an excellent choice. </li>
<li>It supports audio and video devices</li>
<li>It compiles on windows, linux, and a few others</li>
</ul>
<p>Also
- I recommend using the SIP protocol (as opposed to H323)
- You don't need to use Ekiga. Ekiga is a front-end to OPAL. You can take a look at the OPAL samples, and build up from those.</p>
| 23,096
|
<p>OK. This is a bit of a vanity app, but I had a situation today at work where I was in a training class and the machine was set to lock every 10 minutes. Well, if the trainers got excited about talking - as opposed to changing slides - the machine would lock up.</p>
<p>I'd like to write a teeny app that has nothing but a taskbar icon that does nothing but move the mouse by 1 pixel every 4 minutes. </p>
<p>I can do that in 3 ways with Delphi (my strong language) but I'm moving to C# for work and I'd like to know the path of least resistance there.</p>
|
<p><strong>for C# 3.5</strong></p>
<p>without notifyicon therefore you will need to terminate this application in task manager manually</p>
<pre><code>using System;
using System.Drawing;
using System.Windows.Forms;
static class Program
{
static void Main()
{
Timer timer = new Timer();
// timer.Interval = 4 minutes
timer.Interval = (int)(TimeSpan.TicksPerMinute * 4 / TimeSpan.TicksPerMillisecond);
timer.Tick += (sender, args) => { Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y + 1); };
timer.Start();
Application.Run();
}
}
</code></pre>
|
<p>(Windows 10 / .Net 5 / C# 9.0)</p>
<p>Instead of faking activity, you could</p>
<blockquote>
<p>inform the system that it is in use, thereby preventing the system
from entering sleep or turning off the display while the application
is running</p>
</blockquote>
<p>using <a href="https://learn.microsoft.com/fr-fr/windows/win32/api/winbase/nf-winbase-setthreadexecutionstate" rel="nofollow noreferrer">SetThreadExecutionState</a>, as described on <a href="https://www.pinvoke.net/default.aspx/kernel32.setthreadexecutionstate" rel="nofollow noreferrer">PInvoke.net</a> :</p>
<pre><code>using System;
using System.Runtime.InteropServices;
using System.Threading;
namespace VanityApp
{
internal static class Program
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern ExecutionState SetThreadExecutionState(ExecutionState esFlags);
[Flags]
private enum ExecutionState : uint
{
ES_AWAYMODE_REQUIRED = 0x00000040,
ES_CONTINUOUS = 0x80000000,
ES_DISPLAY_REQUIRED = 0x00000002,
ES_SYSTEM_REQUIRED = 0x00000001
}
private static void Main()
{
using AutoResetEvent autoResetEvent = new AutoResetEvent(false);
using Timer timer = new Timer(state => SetThreadExecutionState(ExecutionState.ES_AWAYMODE_REQUIRED | ExecutionState.ES_CONTINUOUS | ExecutionState.ES_DISPLAY_REQUIRED | ExecutionState.ES_SYSTEM_REQUIRED), autoResetEvent, 0, -1);
autoResetEvent.WaitOne();
}
}
}
</code></pre>
<p>The Timer is a <a href="https://learn.microsoft.com/en-us/dotnet/api/system.threading.timer" rel="nofollow noreferrer">System.Threading.Timer</a>, with its handy constructor, and it uses <a href="https://learn.microsoft.com/en-us/dotnet/api/system.threading.waithandle.waitone" rel="nofollow noreferrer">AutoResetEvent.WaitOne()</a> to avoid exiting immediately.</p>
| 2,410
|
<p>I'm modifying a mature CGI application written in Perl and the question of content encoding has come up. The browser reports that the content is iso-8859-1 encoded and the application is declaring iso-8859-1 as the charset in the HTTP headers but doesn't ever seem to <em>actually do</em> the encoding. None of the various encoding techniques described in the perldoc tutorials (<a href="http://perldoc.perl.org/Encode.html" rel="nofollow noreferrer">Encode</a>, <a href="http://perldoc.perl.org/encoding.html" rel="nofollow noreferrer">Encoding</a>, <a href="http://perldoc.perl.org/open.html" rel="nofollow noreferrer">Open</a>) are used in the code so I'm a little confused as to how the document is actually being encoded. </p>
<p>As mentioned, the application is quite mature and likely predates many of the current encoding methods. Does anyone know of any legacy or deprecated techniques I should be looking for? To what encoding does Perl assume/default to when no direction is provided by the developer?</p>
<p>Thanks</p>
|
<p>By default Perl handles strings as being byte sequences, so if you read from a file, and print that to STDOUT, it will produce the same byte sequence. If your templates are Latin-1, your output will also be Latin-1.</p>
<p>If you use a string in text string context (like with <code>uc</code>, <code>lc</code> and so on) perl assumes Latin-1 semantics, unless the string has been decoded before.</p>
<p><a href="http://perlgeek.de/en/article/encodings-and-unicode" rel="nofollow noreferrer">More on Perl, charsets and encodings</a></p>
|
<p>If the browser reports the content as iso-8859-1, maybe your perl script didn't output the correct headers to specify the charset?</p>
| 21,637
|
<p>How do I detect when my Compact Framework application is being smart-minimized (smart minimize is what happens when the user clicks the "X" button in the top-right corner on a Pocket PC)?</p>
<p>The Deactivate event isn't the right way because it occurs in circumstances other than minimization, such as when a message box or another form is shown on top of the main form. And the form's WindowState doesn't help because there is no "Minimized" WindowState on .NET CF.</p>
<p>I heard that by setting MinimizeBox = false, my app will be closed instead of minimized. But I actually don't want my app to close, I just want to know when it has been minimized.</p>
|
<p>I think the way to go here is processing the <a href="http://msdn.microsoft.com/en-us/library/aa922525.aspx" rel="nofollow noreferrer">WM_ACTIVE</a> message and then checking if the fMinimized parameter is not zero. You can find more information on how to declare this messages in your code in <a href="http://www.pinvoke.net/default.aspx/Enums/WindowsMessages.html" rel="nofollow noreferrer">here</a>.</p>
<p>I will try figure out how to exactly code this in C# and prove the hypothesis. However you maybe faster than me and figure it out. </p>
<p>Also check the functions <a href="http://msdn.microsoft.com/en-us/library/ms960018.aspx" rel="nofollow noreferrer">DefWindowProc</a> and <a href="http://msdn.microsoft.com/en-us/library/ms915527.aspx" rel="nofollow noreferrer">WindowProc</a>, which are used to process the messages. Functions are declared in your code like this:</p>
<p>First have the include:</p>
<pre><code>using System.Runtime.InteropServices;
</code></pre>
<p>then in the class declare like this</p>
<pre><code>[DllImport("coredll.dll")]
static extern IntPtr DefWindowProc(IntPtr hWnd, uint uMsg, UIntPtr wParam,
IntPtr lParam);
</code></pre>
<hr>
<p>There is another thing you could do, this is more a "philosophical" workaround. INMO the smart minimize X is confusing for users, that is why I don't like to include it. Instead I provide a button at the right lower corner of the form that says "close" or "back", which uses the close method of the form. I used it in all forms to keep a standard. This is less ambiguous for windows users because they may assume that the X in windows mobile is the same X in windows for PC.</p>
<p>If for some reason you need to minimize your app or send it to the background use the following code:</p>
<pre><code>using System.Runtime.InteropServices;
...
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
[DllImport("coredll.dll")]
static extern int ShowWindow(IntPtr hWnd, int nCmdShow);
const int SW_MINIMIZED = 6;
...
...
public void HideForm()
{
ShowWindow(this.Handle, SW_MINIMIZED);
}
}
</code></pre>
|
<p>What exactly do you mean by smart-minimized? I suppose you mean your app being automatically minimised on no activity for some time? Well, I don't think that there is an event for that.</p>
<p>The author of this <a href="http://blogs.msdn.com/windowsmobile/archive/2005/08/03/447404.aspx" rel="nofollow noreferrer">blog spot</a> uses the Deactivate event for turning internal process on and off. This is acceptable for animation and other similar processes and the cases of a message box or another form popping up are no problems. If however, your process must not be stopped unless the application closes or 'smart-minimizes', you could try starting a timer on deactivate events. If the form isn't activated back for a specific interval, then it would be safe to stop the internal process.</p>
<p>Of course in designing your solution you need to take Power Management into consideration. Have a look at <a href="http://#" rel="nofollow noreferrer">this</a> and of course also OpenNetCF for power notifications.</p>
| 47,751
|
<p>I'm trying to make a script that sleeps my wireless card in linux. For that I'm using the <code>deepsleep</code> command of <code>iwpriv</code>:</p>
<pre><code>iwpriv wlan0 deepsleep 1
</code></pre>
<p>The problem is that this command only works if the wireless card is disconnected and disassociated. When it's connected there is no problem because if I disconnect, it disassociates automatically. But if it's disconnected, sometimes it associates (but not connects) automatically to unencrypted networks, so I cannot run the <code>iwpriv</code> command. The only fix I have found is to change the mode first to Ad-Hoc and then to Managed before sleep the card:</p>
<pre><code>iwconfig wlan0 mode ad-hoc
iwconfig wlan0 mode managed
iwpriv wlan0 deepsleep 1
</code></pre>
<p>But I think it's a bit tricky.</p>
<p>Does exist a more direct way to disassociate a wireless card in linux?</p>
|
<p>Many drivers use the convention that associating with the NULL AP disconnects from the current AP. Add to this a brief delay, and you might have what you want. For example,</p>
<pre><code>iwconfig wlan0 ap 00:00:00:00:00:00
sleep 1
iwpriv wlan0 deepsleep 1
</code></pre>
<p>Typically, it shouldn't take more than 250-500 milliseconds to disconnect from an AP, but a fractional sleep command (e.g. sleep 0.25) isn't portable.</p>
|
<p>I don't have a fix, but you could try setting the ESSID of the card to a random string and hope that no access points nearby use that ESSID. That should prevent autoconnecting to any unencrypted network found. Not a solution, but maybe a better band-aid.</p>
| 27,317
|
<p>How can I get data from a database that I can only access through an ODBC Data Source (DSN) in T-SQL MS SQL Server, any version?</p>
|
<p>After reading the following, I decided to create SSIS packages to get data from another data source via DSN. </p>
<blockquote>
<p>With Linked Servers, you have a little
more flexibility, but also some
additional security concerns. You are
linking to the other data source as a
specific user, with that user's
authority to the linked server. If
all you need is Read-only access to a
few views, that user should only be
granted that authority to those
objects. This isn't so bad, you have
total control of the authority you
grant to that user, but you have to
manage it and realize that granting
too much authority could be a security
concern.</p>
<p>Consider using a linked server with
read-only rights to copy data from
specific tables/view into permanent
tables in the other database in lieu
of an SSIS package. You can execute a
job periodically to copy the
appropriate data from the linked
server to the local database and
reference the local tables within your
application. It will likely be easier
to implement and maintain than an SSIS
package, and could potentially be
updated later to make it a live
solution.</p>
</blockquote>
<p><a href="http://www.eggheadcafe.com/software/aspnet/32465151/linked-servers-versus-ssi.aspx" rel="nofollow noreferrer">Source</a></p>
|
<p>The selecting is the easy part, but the real question is how do you connect to the datasource. </p>
<p>First, where are you selecting data from? Are you writing code, or just using the Query analyzer tool (2000) or Management Studio (2005)?</p>
<p>You'll need to setup your connection to the database regardless. If you need help with the connectionstrings to a DSN, the site www.connectionstrings.com is very helpful. Otherwise, from a query tool there will be dialog boxes or wizards to help you.</p>
| 30,191
|
<p>I'm relatively new to the Python world, but this seems very straight forward.</p>
<p>Google is yelling at me that this code needs to be optimized:</p>
<pre><code>class AddLinks(webapp.RequestHandler):
def post(self):
# Hash the textarea input to generate pseudo-unique value
hash = md5.new(self.request.get('links')).hexdigest()
# Seperate the input by line
allLinks = self.request.get('links').splitlines()
# For each line in the input, add to the database
for x in allLinks:
newGroup = LinkGrouping()
newGroup.reference = hash
newGroup.link = x
newGroup.put()
# testing vs live
#baseURL = 'http://localhost:8080'
baseURL = 'http://linkabyss.appspot.com'
# Build template parameters
template_values = {
'all_links': allLinks,
'base_url': baseURL,
'reference': hash,
}
# Output the template
path = os.path.join(os.path.dirname(__file__), 'addLinks.html')
self.response.out.write(template.render(path, template_values))
</code></pre>
<p>The dashboard is telling me that this is using a ton of CPU.</p>
<p>Where should I look for improvements?</p>
|
<p>The main overhead here is the multiple individual puts to the datastore. If you can, store the links as a single entity, as Andre suggests. You can always split the links into an array and store it in a ListProperty.</p>
<p>If you do need an entity for each link, try this:</p>
<pre><code># For each line in the input, add to the database
groups = []
for x in allLinks:
newGroup = LinkGrouping()
newGroup.reference = hash
newGroup.link = x
groups.append(newGroup)
db.put(groups)
</code></pre>
<p>It will reduce the datastore roundtrips to one, and it's the roundtrips that are really killing your high CPU cap.</p>
|
<p>How frequently is this getting called? This doesn't look that bad... especially after removing the duplicate request.</p>
| 31,124
|
<p>I'm working on a programming problem which boils down to a set of an equation and inequality:</p>
<pre><code>x[0]*a[0] + x[1]*a[1] + ... x[n]*a[n] >= D
x[0]*b[0] + x[1]*b[1] + ... x[n]*b[n] = C
</code></pre>
<p>I want to solve for the values of <code>X</code> that will give the absolute minimum of <code>C</code>, given the input <code>D</code> and lists and <code>A</code> and <code>B</code> consisting of <code>a[0 - n]</code> and <code>b[0 - n ]</code>.</p>
<p>I'm doing the problem at the moment in Python, but the problem in general is language-agnostic.</p>
<p>CLARIFICATION UPDATE: the coefficients <code>x[0 - n]</code> are restricted to the set of non-negative integers.</p>
|
<p>This looks like a <a href="http://en.wikipedia.org/wiki/Linear_programming" rel="noreferrer">linear programming</a> problem. The <a href="http://en.wikipedia.org/wiki/Simplex_algorithm" rel="noreferrer">Simplex algorithm</a> normally gives good results. It basically walks the boundaries of the subspace delimited by the inequalities, looking for the optimum.</p>
<p>Think of it visually: each inequality denotes a half-space, a plane in n-dimensional space that you have to be on the right side of. Your utility function is what you're trying to optimize. If the space is closed, the optimum is going to be at one of the apexes of the closed space; if it's open, it's possible that the optimum is infinite.</p>
|
<p>This <a href="http://www.lindo.com/" rel="nofollow noreferrer">company</a> has a tool to do that sort of thing.</p>
| 28,122
|
<p>With my jquery I'm trying to make the transition from a message to a loading function easy on the eyes by animate the opasity of the message out, inserting the loading.gif and animating the opacity back in. It fails.</p>
<pre><code>$('#powerSearchSubmitButton').click(function(ev) {
startLoad();
return false;
});
function startLoad() {
$('.message').each(function(i) {
$(this).animate({opacity: 0}, 500, function() {
$(this).html("<img src=\"/content/pics/loadingBig.gif\" alt=\"loading\" style=\"opacity:0\"/>");
$(this).animate({opacity: 1},500);
});
};
return true;
};
</code></pre>
<p>When I leave out the <code>.html()</code> call, it works fine (except off course the image is not there; So I think that it is beacuse the html isn't inserted with <code>opacity:0;</code> But when I inserted it with <code>style="opacity:0"</code> it cannot fade back in...</p>
<p>What am I doing wrong?</p>
|
<p>Try this:</p>
<pre><code>$(this).fadeOut(500, function() {
$(this).html("<img src='content/pics/loadingBig.gif' alt='loading'/>");
});
$(this).fadeIn(500);
</code></pre>
|
<p>Apply the animation to a container instead, or use the .css() method to set the opacity (inline styles might interfere with jQuery's ability to animate the corresponding properties).</p>
| 44,198
|
<p>We are currently having two UI design for internet and intranet the underlying reason being is that they both serve different purpose so they have different UI design.</p>
<p>But however users want to have a more synchronized look and feel between internet and intranet.</p>
<p>What are the reasons you all can think of in have different user interface/outlook for internet and intranet?</p>
|
<p>The browsers being to access the web pages may be a reason.
While (big) corporate intranets may be Windows dominated and hence Internet Explorer may be a safe assumption to make, out in the (wild,wild) internet, one can't be sure and have to design more inter-operable content.</p>
|
<p>If the functionality of the two is significantly different, then I believe the UI must also be different.</p>
<p>You can make the two similar by use of colours, menu positioning, themes and so on.</p>
| 30,068
|
<p>let's assume i have a self referencing hierarchical table build the classical way like this one:</p>
<pre><code>CREATE TABLE test
(name text,id serial primary key,parent_id integer
references test);
insert into test (name,id,parent_id) values
('root1',1,NULL),('root2',2,NULL),('root1sub1',3,1),('root1sub2',4,1),('root
2sub1',5,2),('root2sub2',6,2);
testdb=# select * from test;
name | id | parent_id
-----------+----+-----------
root1 | 1 |
root2 | 2 |
root1sub1 | 3 | 1
root1sub2 | 4 | 1
root2sub1 | 5 | 2
root2sub2 | 6 | 2
</code></pre>
<p>What i need now is a function (preferrably in plain sql) that would take the id of a test record and
clone all attached records (including the given one). The cloned records need to have new ids of course. The desired result
would like this for example:</p>
<pre><code>Select * from cloningfunction(2);
name | id | parent_id
-----------+----+-----------
root2 | 7 |
root2sub1 | 8 | 7
root2sub2 | 9 | 7
</code></pre>
<p>Any pointers? Im using PostgreSQL 8.3.</p>
|
<p>Pulling this result in recursively is tricky (although possible). However, it's typically not very efficient and there is a <em>much</em> better way to solve this problem.</p>
<p>Basically, you augment the table with an extra column which traces the tree to the top - I'll call it the "Upchain". It's just a long string that looks something like this:</p>
<pre><code>name | id | parent_id | upchain
root1 | 1 | NULL | 1:
root2 | 2 | NULL | 2:
root1sub1 | 3 | 1 | 1:3:
root1sub2 | 4 | 1 | 1:4:
root2sub1 | 5 | 2 | 2:5:
root2sub2 | 6 | 2 | 2:6:
root1sub1sub1 | 7 | 3 | 1:3:7:
</code></pre>
<p>It's very easy to keep this field updated by using a trigger on the table. (Apologies for terminology but I have always done this with SQL Server). Every time you add or delete a record, or update the parent_id field, you just need to update the upchain field on that part of the tree. That's a trivial job because you just take the upchain of the parent record and append the id of the current record. All child records are easily identified using LIKE to check for records with the starting string in their upchain.</p>
<p>What you're doing effectively is trading a bit of extra write activity for a <em>big</em> saving when you come to read the data.</p>
<p>When you want to select a complete branch in the tree it's trivial. Suppose you want the branch under node 1. Node 1 has an upchain '1:' so you know that any node in the branch of the tree under that node must have an upchain starting '1:...'. So you just do this:</p>
<pre><code>SELECT *
FROM table
WHERE upchain LIKE '1:%'
</code></pre>
<p>This is <em>extremely</em> fast (index the upchain field of course). As a bonus it also makes a lot of activities extremely simple, such as finding partial trees, level within the tree, etc.</p>
<p>I've used this in applications that track large employee reporting hierarchies but you can use it for pretty much any tree structure (parts breakdown, etc.)</p>
<p>Notes (for anyone who's interested):</p>
<ul>
<li>I haven't given a step-by-step of the SQL code but once you get the principle, it's pretty simple to implement. I'm not a great programmer so I'm speaking from experience.</li>
<li>If you already have data in the table you need to do a one time update to get the upchains synchronised initially. Again, this isn't difficult as the code is very similar to the UPDATE code in the triggers.</li>
<li>This technique is also a good way to identify circular references which can otherwise be tricky to spot.</li>
</ul>
|
<p>This sounds like an exercise from "SQL For Smarties" by Joe Celko... </p>
<p>I don't have my copy handy, but I think it's a book that'll help you quite a bit if this is the kind of problems you need to solve.</p>
| 17,301
|
<p>I'm creating a Firefox extension for demo purposes.
I to call a specific JavaScript function in the document from the extension.
I wrote this in my HTML document (not inside extension, but a page that is loaded by Firefox):</p>
<pre><code>document.funcToBeCalled = function() {
// function body
};
</code></pre>
<p>Then, the extension will run this on some event:</p>
<pre><code>var document = Application.activeWindow.activeTab.document;
document.funcToBeCalled();
</code></pre>
<p>However it raises an error saying that <code>funcToBeCalled</code> is not defined.</p>
<p>Note: I could get an element on the document by calling <code>document.getElementById(id);</code></p>
|
<p>It is for security reasons that you have limited access to the content page from extension. See <a href="http://developer.mozilla.org/en/docs/XPCNativeWrapper" rel="noreferrer">XPCNativeWrapper</a> and <a href="http://developer.mozilla.org/en/Safely_accessing_content_DOM_from_chrome" rel="noreferrer">Safely accessing content DOM from chrome</a>,</p>
<p>If you control the page, the best way to do this is set up an event listener in the page and dispatch an event from your extension (addEventListener in the page, dispatchEvent in the extension).</p>
<p>Otherwise, see <a href="http://groups.google.com/group/mozilla.dev.extensions/msg/bdf1de5fb305d365" rel="noreferrer">http://groups.google.com/group/mozilla.dev.extensions/msg/bdf1de5fb305d365</a></p>
|
<p>You can do it, but you need to have control over the page and be able to raise the privilege level for the script. <a href="http://developer.mozilla.org/en/How_to_Build_an_XPCOM_Component_in_Javascript" rel="nofollow noreferrer">Mozilla Documentation gives an example</a> - search for "Privilege" on the page.</p>
| 18,264
|
<p>In reading about Perl 6, I see a feature being trumpeted about, where you no longer have to do:</p>
<pre><code>return "0 but true";
</code></pre>
<p>...but can instead do:</p>
<pre><code>return 0 but True;
</code></pre>
<p>If that's the case, how does truth work in Perl 6? In Perl 5, it was pretty simple: 0, "", and undef are false, everything else is true.</p>
<p>What are the rules in Perl 6 when it comes to boolean context?</p>
|
<p>See <a href="http://dev.perl.org/perl6/doc/design/syn/S12.html#Roles" rel="noreferrer">Synopsis 12: Roles</a>.</p>
<p>The rules are the same, but the "but" copies the 0 and applies a role to the copy that causes it to be true in boolean context.</p>
<p>You can do the same thing with overload in Perl 5.</p>
|
<p>One false value that gets neglected nearly everywhere is "0". I recently made this painful discovery that "0" is <strong>false</strong> in PERL 5. Gee. A non-empty string that's false. I was really hoping that would change in PERL6, but I guess not.</p>
<pre><code>> if ( "0" ) { say "True" } else { say "False" }
False
</code></pre>
<p>The ||= idiom clobbered some strings I really wasn't expecting:</p>
<pre><code>$ perl -e '$x = "0"; $x ||= ""; print ">>$x<<\n";'
>><<
</code></pre>
| 15,224
|
<p>I am going to start a C# project from scratch that will consist of several modules so it <strong>can be sold by modules</strong> of an existing PHP/ASP/MySQL/Oracle/MS SQL application that manages to show 3D objects and create 2D and 3D CAD files from a web app that the user can use to create all the stuff.</p>
<p><strong>My question is</strong>, to start from ground zero, and having the "sell" point of view, it should be a good programming method that I should implement, design patterns, unit testing, etc... how will I know how to apply them, and is there any good tutorial / "show me the way" kind'a thing to know about these things, like... </p>
<ul>
<li>what classes should I make available to be overridden by the client so I can provide extensibility in our modules?</li>
<li>what kind of "package" should I use to "sell"? DLL, CAB, MSI? </li>
<li>should I use SubSonic / NHibernate so the user can generate their own DAL? Our prototype implementation will use only Oracle.</li>
</ul>
<p>I'm kinda lost right now, I know what to do, but not how I can accomplish it (having this perfect coding path in mind).</p>
<p>Any good programming ideas are gladly appreciated :)</p>
|
<p>For a quick hit of each of your explicit questions I would say.</p>
<p>As for the how of integration, learn inversion of control principals and how it is used for extensibility purposes. Keep an eye on MEF, Microsoft Extensibility Framework. As for the what, your integration points will depend mostly on the type of application you are writing and your target audience. It also depends on how much control you want to give third parties. Reflector for example has a great, almost wide open plugin structure in place.</p>
<p>DLL's and CABs are libraries and storage formats respectively. By themselves, they don't do much. MSI's are one form of installer and can contain the DLLs that will make up your application. Regardless of the type of installer you have, the easier it is to use, the more people that will try your product.</p>
<p>The data layer itself doesn't necessarily matter so much. People probably won't be creating their own data layers for your application and if they do, they should be able to use what ever they want if your extensibility framework is doing its job. More importantly is that whatever DAL you do decide on, you need to check to see if it is capable of running on different databases if that is important to you and how much work it takes. You also need to make sure the features you use in the DAL work for all of the databases you want to support. NHibernate has several features that don't work in all of the databases it runs on.</p>
|
<p>First make something that works, then get feedback from potential customers.</p>
| 38,929
|
<p>I have a ListBox and I want to add a context menu to each item in the list. I've seen the "solution" to have the right click select an item and suppress the context menu if on white space, but this solution feels dirty. </p>
<p>Does anyone know a better way?</p>
|
<p>Just to elaborate a little further to what Frans has said...Even though the ListBox owns the ContextMenuStrip, you can still customize the items in the menu strip at the time it's opening. Thus customizing it's contents based on the mouse position within the listbox.</p>
<p>The example below selects the item in the listbox based on a right mouse click and then customizes a context menu strip based on the item the user right-clicked on. This is a simple example but should get you going: Add a listbox to a form and add this code:</p>
<pre><code>#region Private Members
private ContextMenuStrip listboxContextMenu;
#endregion
private void Form1_Load( object sender, EventArgs e )
{
//assign a contextmenustrip
listboxContextMenu = new ContextMenuStrip();
listboxContextMenu.Opening +=new CancelEventHandler(listboxContextMenu_Opening);
listBox1.ContextMenuStrip = listboxContextMenu;
//load a listbox
for ( int i = 0; i < 100; i++ )
{
listBox1.Items.Add( "Item: " + i );
}
}
private void listBox1_MouseDown( object sender, MouseEventArgs e )
{
if ( e.Button == MouseButtons.Right )
{
//select the item under the mouse pointer
listBox1.SelectedIndex = listBox1.IndexFromPoint( e.Location );
if ( listBox1.SelectedIndex != -1)
{
listboxContextMenu.Show();
}
}
}
private void listboxContextMenu_Opening( object sender, CancelEventArgs e )
{
//clear the menu and add custom items
listboxContextMenu.Items.Clear();
listboxContextMenu.Items.Add( string.Format( "Edit - {0}", listBox1.SelectedItem.ToString() ) );
}
</code></pre>
<p>Hope that help.</p>
|
<pre><code>//Create and Initialize the contextMenuStrip component
contextMenuStrip_ListaAulas = new ContextMenuStrip();
//Adding an Item
contextMenuStrip_ListaAulas.Items.Add("Modificar");
//Binding the contextMenuStrip with the ListBox
listBox_Aulas.ContextMenuStrip = contextMenuStrip_ListaAulas;
//The solution below
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
//select the item under the mouse pointer
listBox_Aulas.SelectedIndex = listBox_Aulas.IndexFromPoint(e.Location);
//if the selected index is an item, binding the context MenuStrip with the listBox
if (listBox_Aulas.SelectedIndex != -1)
{
listBox_Aulas.ContextMenuStrip = contextMenuStrip_ListaAulas;
}
//else, untie the contextMenuStrip to the listBox
else
{
listBox_Aulas.ContextMenuStrip = null;
}
}
</code></pre>
| 49,341
|
<p>I have a client who is interested in adding in electronic signature support to a long (40 question) seller application form. I'm a little stumped on whether there is an existing standard or process that's out there that folks in the financial world would expect to see?</p>
<p>I could certainly add in a system where we generate a bunch of text based on their responses, have the applicant sign it with their private key and upload a public key- but that seems like a lot to ask of people. Do non-nerds even have PGP installed these days?</p>
<p>Is there a standard approach to this out there? Anyone work in the financial world that's done this and had it work well?</p>
|
<p>What purpose is the signature trying to fill? Are you trying to verify that the form actually came from a specific seller? (If so, you would have to know their public key ahead of time.) Are you trying to hold the seller accountable for their answers at a later date? (In that case, you might need some kind of third-party involved.)</p>
<p>Sometimes people ask for electronic signatures just because they sound neat.</p>
|
<p>If these forms are meant to be shared throught to a general public you'll need to know (and can validate, that's the hardest part) all the producers of these amount of certificates people could use to sign these forms, and it's almost impossible.</p>
<p>With closed environments (like functionaries, doctors...) where all the users are suposed to hold a certificate (with a pre-known CA you trust) and you should be sure the form is sended by someone trusted (non repudation, integrity...) it's a better scenario to sign a form, otherwise I do not recomend you to use signed forms to achieve your goal.</p>
| 17,088
|
<p><a href="http://99-bottles-of-beer.net/" rel="nofollow noreferrer">99 bottles of beers</a> made me realize that ADA, Erlang and Smalltalk were not so odd languages after all.</p>
<p>There are plenty of unusual tools and I supposed that a lot of them are even used :-)</p>
<p>Have you ever worked with very original technologies ? If yes, let us know in which context, and what did you think about it. Funny snippets strongly expected.</p>
|
<p>I've been working professionally with <strong><a href="http://www.dyalog.com/" rel="nofollow noreferrer">Dyalog</a> <a href="http://en.wikipedia.org/wiki/APL_(programming_language)" rel="nofollow noreferrer">APL</a></strong> for almost three years now. It's always fun and challenging to learn a completely different language, and the language has its advantages. But I'm more annoyed than intrigued by it nowadays.</p>
<p>Some particular drawbacks:</p>
<ul>
<li>There's almost noone outside the office to ask if you're stuck. There's almost no resources, tips and tricks available online. And noone else in the world has probably done what you're doing anyway.</li>
<li>You have to reinvent the wheel all the time, since there's really no class/function library to use. (This can be fun for a geek like me, but not very productive.)</li>
<li>You constantly have to write workarounds or avoid using "modern" features, since the IDE and interpreter are closed-source, and the vendor is too small to have the resources to fixing all bugs.</li>
</ul>
|
<p>I haven't worked with any unusual technologies but I believe Ada is still very much alive within the defence/aerospace/high reliability circles. It's something I would like to pick up one day.</p>
| 13,996
|
<p>I have what I thought would be a simple question.</p>
<p>I don't have an auto leveling probe, I do my leveling manually with 4 screws and a piece of paper (I measured the thickness to 0.1 mm).</p>
<p>For the longest time I would have trouble with the first layer, sometimes having to give the bed screws a quarter turn to bring the bed up a bit. I would see that the nozzle seemed quite far away from the bed. This went on for the longest time and I just chalked it up to the quality of my printer.</p>
<p>I realized recently that when I level the bed, I am inserting a piece of paper in between the nozzle and the bed. Obviously, I should be taking the thickness into account as a 0.1mm thick piece of paper accounts for 50 % higher than the nozzle should be for a 0.2 mm first layer height.</p>
<p>My question is, how do I set (either in Cura or directly in Marlin config) the z home offset to account for the 0.1 mm thickness of my calibration paper?</p>
|
<p>It is preferred to get the distance correct by hardware changes (leveling screws). But it is possible to do it with software. You can not only change the Z offset in the slicer or in the configuration of Marlin, but also with G-code commands. </p>
<p>The "paper drag" method is perfect for determining the correct Z level. Once you leveled with the paper, you do not need to create an offset to account for the paper thickness, however, there are purists that do that. So basically, what we call Z=0 is in fact Z="paper thickness", unless you are a purist. But a slightly larger gap makes printing much easier. Too small heights cause e.g. rippling effects or too much pressure build-up in the nozzle. In order to change your offset after leveling, you could try one of the following methods. This is sometimes a useful method for creating a little extra offset for printing PETG, but personally I do not do that.</p>
<p><strong>In Ultimaker Cura</strong>:
Open the plugin manager ("Toolbox"->"Browse packages...") and install "Z Offset Setting", a new parameter will be available in the "Build Plate Adhesion" settings menu called "Z Offset". (See also <a href="/a/5939/5740">this older, not up-to-date answer</a>)</p>
<p><strong>In Marlin configuration file</strong>, modify the MANUAL_Z_HOME_POS constant:</p>
<pre><code>//#define MANUAL_Z_HOME_POS 0
</code></pre>
<p><strong>In G-code</strong>:</p>
<p>By adding the following lines to your start G-code (see e.g. <a href="/a/4746/5740">this answer</a>) using the <a href="http://marlinfw.org/docs/gcode/G092.html" rel="nofollow noreferrer"><code>G92</code></a> G-code command:</p>
<pre><code>G0 Z0.2 ; Move the head to 0.2 mm (so now 0.3 on your machine)
G92 Z0 ; Call this Z = 0
</code></pre>
<p>or when you are able to connect to the printer over USB using a printer terminal (e.g. Pronterface, Repetier or OctoPrint) using the <a href="http://marlinfw.org/docs/gcode/M206.html" rel="nofollow noreferrer"><code>M206</code></a> G-code command:</p>
<pre><code>M206 Z-0.2 ; Will raise the Z height by 0.2 mm
M500 ; Stores the offset in memory
</code></pre>
<p>Alternatively, when you cannot connect through a terminal, putting the last 2 lines in a text file and saving that as a <code>.gcode</code> file on an SD card and "printing" the file will also store the new offset (if <code>M500</code> is enabled in the configuration file: <code>#define EEPROM_SETTINGS // Enable for M500 and M501 commands</code>)</p>
|
<p>You don't! Level the bed such that you know the nozzle is above the bed. Stop the print. Disable the steppers. Let it all cool down. Tram the bed (or what you call level). Then start the print again. It doesn't matter what first layer height your slicer thinks it is. All that matters is that it sticks and doesn't elephant foot. Note, if you are using glue stick or white glue (like I do) the thickness of the glue layer will be different between the edge of the glass (I assume you're using glass, otherwise you're never going to get a good tram) and the starting position of the prints. </p>
| 1,074
|
<p>I'm currently in the process of becoming a maintainer of a small open source project (a Facebook toolkit), and of course, one of the responsibilities is to answer user questions on our forum. While I'm happy to help users learn how to work with our toolkit and deal with issues they may run into (which may eventually indicate bugs in our code), a significant amount of the questions seem to have less to do with our toolkit specifically, and more to do with knowing how to program in general.</p>
<p>I'd like to help the people asking these questions, but I don't really have the time to be a full-on programming teacher. I don't want to just ignore them. They're not asking to be spoon-fed everything; they just don't know where to begin to solve their problems. Is there some way I can point them in the right direction without offending them, and without spending all my time trying to teach our users general programming skills?</p>
|
<p>Make a FAQ page or a tutorial covering some of the basics, that will eliminate quite a lot of questions.</p>
|
<p>Make a FAQ page or a tutorial covering some of the basics, that will eliminate quite a lot of questions.</p>
| 35,857
|
<p>This might be an interesting question. I need to test that if I can successfully upload and fetch the PDF file. This works for the text based files but I just wanted to check for PDF. For this unit test to run I need a PDF file. There are couple of options. I can create a dummy PDF file and store it some folder and read that file and save the file to the system. But now, my unit test is dependent on the PDF file. So, anyone who runs the unit test must have the PDF file which is kinda bad. </p>
<p>Another way for me is to create a PDF file. This is not a big deal as I can simply create a dummy file with the .pdf extension OR I can even use some PDF third party tool to create PDF file. </p>
<p>Another way also is to embed the PDF document as an embedded resource and then extract that from the assembly. </p>
<p>What do you think is the best way to handle this issue? </p>
|
<p>Save a PDF file with your tests in a resources directory. Your tests should be as simple as possible, and creating a file is just one more point that could fail.</p>
|
<p>My concern is that if I place a file in a different directory.. let's say resources under unit tests then don't I need the complete path to the file to access it. I am running my tests manually. Also, when I move to a different machine and place my solution in a folder with different name then the path to the file gets messed up. </p>
<p>Unless there is some way that I can access the project's folder from within my application (there should be). </p>
| 19,095
|
<p>This is kind of an unorthodox question. </p>
<p>I'm kinda new to using IDA Pro.<br>
Is there a way to edit the assembly code and then have IDA save the result as an executable?<br>
Is there some kind of plugin maybe that does that? because it seems that IDA doesn't want to save as an EXE.<br>
Or do I need to manually edit it in some other way?</p>
|
<p>Version 6.1+ (maybe 6.2+) of IDA Pro will allow you to apply your patches directly to the input file. Equally, it allows you to revert the changes back.</p>
|
<p>I've seen somewhere else that you'd have to produce a .diff file from there then open with a text editor and use another program to patch the original file.</p>
| 42,395
|
<p>Some RepRap models use only a single motor for the Z axis, others use two.</p>
<p>For example, there is the <a href="http://reprap.org/wiki/3drag" rel="noreferrer">3drag</a> that has only one motor and a smooth rod on the other side. There are modifications that add a threaded rod on the other side that is connected to the motor axis with a belt - which seems to be a really good solution.</p>
<p>Other printers, like the <a href="http://reprap.org/wiki/Prusa_i3" rel="noreferrer">Prusa i3</a> or the Mendel90 have two Z motors. And after playing around with a two motor model, I find it pretty annoying when they get out of sync and I need to calibrate the axis and the print bed again. So two motors seem more like an disadvantage to me.</p>
<p>Could someone please shed some light on why most RepRaps have two Z motors (nowadays)?</p>
|
<p>There are three main options here for Mendel style ZX gantries:</p>
<ul>
<li>One Z screw and motor, which is similar to a cantilevered design but somewhat more stable because of the opposite smooth rod</li>
<li>Two Z screws and two motors</li>
<li>Two Z screws and one motor, with belt synchronization of the two sides</li>
</ul>
<p><strong>Of all of these, running two screws off one motor is clearly superior in reliability and user-friendliness.</strong> There is no risk of the two sides of the Z stage going out of sync. One motor running at higher current will generally out-perform two motors splitting one driver's current via parallel wiring, because one motor with twice the torque can push much harder when one side of the gantry binds up or hits a rough spot. </p>
<p>The only real downside to the single motor, double screw approach is that it requires more engineering and parts. A closed-loop timing belt must be run between the two screws, with associated pulleys, tensioner, and support bearings. In comparison, using a separate motor for each screw is very simple. It adds a stepper and a shaft coupler, but saves a lot of vitamins and design complexity.</p>
<p>Two-motor, two-screw solutions are lower-cost and simpler to design. That's why they're used. End of story.</p>
<p>One-motor, one-screw Mendel style printers are quite rare. The passive side of the Z mechanism does add a little bit of stability to the X stage, but not a lot. It's possible to rack the X stage out of square with the bed and bind up the gantry. In order to work at all, they require a very wide/tall bearing footprint on the driven side to resist torque exerted on the driven side by the weight of the X stage and extruder carriage. So it's true that they don't have synchronization issues, but additional design challenges and undesirable flexure modes are introduced. It's much more common for one-screw designs to simply cantilever out the X stage, like a SmartRap or Printrbot Simple. </p>
|
<p>The general concept is to provide additional stability during the print. In the case of the 3drag machine you mentioned, you could run the risk of the -X- axis sagging due to the weight of the print head and/or additional wear on the rod or bearings on the one side (smooth side) as a result of the off balance weight. However, you may find "hacks" like <a href="http://www.thingiverse.com/thing:538770" rel="nofollow">this</a> can potentially help reduce the affects by providing a bit more stability.</p>
<p>Having two -Z- axis motors with the threaded rods can help ensure stability of the -X- axis during print and can, overall, reduce wear on the mechanical components.</p>
| 218
|
<p>A word of warning: I'm a n00b to <code>git</code> in general. My team uses feature branches in <code>svn</code>, and I'd like to use <code>git-svn</code> to track my work on a particular feature branch. I've been (roughly) following <a href="http://andy.delcambre.com/2008/03/04/git-svn-workflow.html" rel="noreferrer">Andy Delcambre's post</a> to set up my local <code>git</code> repo, but those instructions seem to have led <code>git</code> to pick the <code>svn</code> branch that had changed most recently as the remote repository; the problem is that's not the branch I care about. How do I control which branch <code>git-svn</code> uses? Or am I approaching this completely wrong?</p>
<p>UPDATE: I did use the <code>-T</code>, <code>-b</code>, and <code>-t</code> options (in my case because the <code>svn</code> repo has multiple projects, but I want the <code>git</code> repo to contain only the project I'm working on).</p>
|
<p>Muchas gracias to Bart's Blog for this handy <a href="http://www.jukie.net/~bart/blog/svn-branches-in-git" rel="noreferrer">reference for svn branches in git</a>. Apparently all I needed was to specify a remote branch when creating the <code>git</code> branch, e.g., </p>
<pre><code>git checkout -b git-topic-branch-foo foo
</code></pre>
<p>where <code>foo</code> is the name of the remote branch.</p>
|
<p>I use git-svn but I haven't used the features that interoperate with SVN branches. Having said that, I notice that the tutorial you were following didn't use the <a href="http://git-scm.com/docs/git-svn" rel="nofollow noreferrer">-T, -b, -t</a> options to git svn init. These options tell git-svn what the upstream trunk/branches/tags directories are named, which might be important in your situation.</p>
| 23,423
|
<p>I need to create feature which will iterate through all subsites of site collection and add some sample content to each of them (sample content=new pages,images,documents,possibly some lists). There is solution that uses recursion to loop through sites (it can be found <a href="http://blog.rafelo.com/2008/07/iterating-through-sharepoint-web.html" rel="nofollow noreferrer">here</a>). </p>
<p>So i'm asking:</p>
<ol>
<li>Did any of you implemented something similar, maybe in different way?</li>
<li>What was the performance of such iteration?</li>
</ol>
<p>I can't really say how many subsites can be present in site collection, since this feature should be used in more projects. But i guess the number of subsites shouldn't excess 100 or such. </p>
|
<p>That is a very common method of performing looping of sites and web parts.</p>
<p>Speed with 100 sub-sites will not be a problem. It is really quick, if you do alot of processing that can slow it down.</p>
<p>The one thing to watch is the disposal of items if you leave the open or don't close you can suck all the memory from the WFE, especially if alot of users reload the page at the same time.
See <a href="http://www.sharepointnutsandbolts.com/2008/06/disposing-sharepoint-objects-what-they.html" rel="nofollow noreferrer">http://www.sharepointnutsandbolts.com/2008/06/disposing-sharepoint-objects-what-they.html</a> and <a href="http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx</a> for examples they also have the disposal tool at <a href="http://blogs.msdn.com/sharepoint/archive/2008/11/12/announcing-spdisposecheck-tool-for-sharepoint-developers.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/sharepoint/archive/2008/11/12/announcing-spdisposecheck-tool-for-sharepoint-developers.aspx</a></p>
|
<p>You can look at the answer I gave to <a href="https://stackoverflow.com/questions/633633/sharepoint-how-can-i-find-all-the-pages-that-host-a-particular-web-part">this</a> question. I think I've used the correct dispose patterns for that piece of code.</p>
| 48,520
|
<p>Even though chrome runs tabs as different processes it appears to not support this... any ideas or documentation I might have missed?</p>
|
<p>Try two different incognito windows.</p>
|
<p>If you want to stay logged in for a period of time, the best thing to do is to create a new profile for each set of credentials. Click the face icon in the top right-hand corner and select "new user."</p>
<p><img src="https://i.stack.imgur.com/SoVNQ.png" alt="creating a new profile"></p>
<p>If you just want to log-in with different credentials once, it might be easier to use incognito mode, as rmmh said.</p>
| 6,226
|
<p>I’m currently using the OpenNETCF.Desktop.Communication.dll to copy files from my desktop to a CE device, but I keep getting an error:</p>
<p>‘Could not create remote file’ </p>
<p>My development environment is VS2005 (VB.NET)</p>
<p>My code:</p>
<pre><code>ObjRapi.Connect()
ObjRapi.CopyFileToDevice("C:\results.txt", "\results.txt")
ObjRapi.Dispose()
ObjRapi.Disconnect()
</code></pre>
<p>Has anyone run into this and did you manage to get around it. </p>
<p>Thanks</p>
|
<p>I have run into this once before but I can't really remember what was causing it.</p>
<p>The only thing I can think of from looking at your code is this line:</p>
<pre><code>ObjRapi.CopyFileToDevice("C:\results.txt", "\ \results.txt")
</code></pre>
<p>I'm not sure but you could try and change the destination path to something different. Something like this:</p>
<pre><code>ObjRapi.CopyFileToDevice("C:\results.txt", "\My Documents\results.txt")
</code></pre>
<p>I can't really test this at the moment but I really don't see why it wouldn't work.</p>
<p>EDIT: I just had a look at some code that I have writen using the RAPI,when I do any copying my line looks like this:</p>
<pre><code>ObjRapi.CopyFileToDevice("C:\results.txt", "\My Documents\results.txt",True)
</code></pre>
<p>The boolean on the end is an overwrite switch, setting that to true may work.</p>
|
<p>You have to use the following code:</p>
<pre><code>op.CopyFileToDevice(@"C:\results.txt", @"\Temp\results.txt");
</code></pre>
<p>In your code you are not mentioning the path where you want to copy the file.</p>
<p>Hope this will help you.</p>
| 35,022
|
<p>I'm using the following as a way of seeing listing the various methods in my developement</p>
<pre><code>print basename(__FILE__) . "::serve_table()"
</code></pre>
<p>is there any function that's able to return the name of a class method so I don't have to trpe it each time?</p>
|
<p>Use <code>__FUNCTION__</code> and <code>__LINE__</code> and <code>__CLASS__</code> and <code>__METHOD__</code></p>
|
<p>I'm not understanding if you need a way to list all the methods of a class or if you need to retrieve the method name you have just called.</p>
<p>If the former, using reflection:</p>
<pre><code>$class = new ReflectionCLass("classname");
$methods = $class->getMethods();
foreach($methods as $m)
print $m->getName();
</code></pre>
| 42,638
|
<p>How can this line in Java be translated to Ruby:<br>
String className = "java.util.Vector";<br>
...<br>
Object o = Class.forName(className).newInstance(); </p>
<p>Thanks!</p>
|
<pre><code>Object::const_get('String').new()
</code></pre>
|
<p>If you're using ActiveSupport (i.e. Rails), there is a method added to <code>String</code> that does this:</p>
<pre><code>"String".constantize.new
</code></pre>
| 19,048
|
<p>I am testing a couple of workflows for their workflow history cleanup time intervals. The workflow History needs to be retained for a specific number of days. I have implemented the solutions recommended <a href="http://mdablog.spaces.live.com/Blog/cns!B0C40902E1212960!796.entry" rel="nofollow noreferrer">here</a> </p>
<p>My problem is that, now I need to test my code to see if the workflow history is getting cleaned up after the exact number of days. </p>
<p>I came to know that the workflow history is cleanep up by a timer job called "Workflow Auto Cleanup" which runs daily.</p>
<p>But in my case, the workflow History cleanup does not seem to run, because, in "Central Administration > Operations > Timer Job Definitions > Edit Timer Job" , the last run time is shown as "N\A"</p>
<p>Is there anything I am missing here? What should I do to make this timer job run properly?</p>
<p>Update: Checking the SharePoint logs gives this message:
"Upgrade job definition already exists, waiting for the existing upgrade to complete"</p>
|
<p>This link should sort you out...</p>
<p><a href="http://weblogs.asp.net/danlewis/archive/2008/09/06/determine-which-version-of-sharepoint-is-installed.aspx" rel="nofollow noreferrer">Determining sharepoint versions</a></p>
<p>Edit: The article has now disappeared, so see Dan's answer below</p>
|
<p>Check this article on "How to check if SharePoint Standard or SharePoint Enterprise is installed?"</p>
<blockquote>
<p>The SKU key is nothing but a GUID as you can see in the above table, so we can easily retrieve this information using the below code, use a visual webpart and add this Render method in your UserControl.ascx.cs file.</p>
</blockquote>
<pre><code>protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
const string SHAREPOINT2010FOUNDATION = “BEED1F75-C398-4447-AEF1-E66E1F0DF91E”;
const string SHAREPOINT2010STANDARD = “3FDFBCC8-B3E4-4482-91FA-122C6432805C”;
const string SHAREPOINT2010ENTERPRISE = “D5595F62-449B-4061-B0B2-0CBAD410BB51″;
SPFarm _spFarm = SPFarm.Local;
IEnumerable<Guid> _guid = _spFarm.Products;
foreach (var item in _guid)
{
string _skuID = item.ToString();
writer.Write(“<div>\n”);
if (_skuID.Equals(SHAREPOINT2010STANDARD, StringComparison.CurrentCultureIgnoreCase))
{
writer.Write(“<span>” + _skuID + ” – You have SharePoint 2010 Standard Edition” + “</span>\n”);
}
if (_skuID.Equals(SHAREPOINT2010ENTERPRISE,StringComparison.CurrentCultureIgnoreCase))
{
writer.Write(“<span>” + _skuID + ” – You have SharePoint 2010 Enterprise Edition” + “</span>\n”);
}
if (_skuID.Equals(SHAREPOINT2010FOUNDATION, StringComparison.CurrentCultureIgnoreCase))
{
writer.Write(“<span>” + _skuID + ” – You have SharePoint 2010 Foundation” + “</span>\n”);
}
writer.Write(“</div>\n”);
}
}
</code></pre>
| 45,463
|
<p>I would like to create a blog where my Twitter updates essentially create blog posts, with a comment thread. If there isn't blog software that does this right now (I did some searching but couldn't find the commenting aspect) what would be the simplest approach and starting blog software to do this?</p>
<p>Potentially an alternate approach to this would be a blog interface that could auto-update my Twitter feed with the title text. </p>
<p>Whatever the solution, I'd like it to be fully automated so that it is roughly no more work than currently updating my Twitter feed using the Twitter web interface. Note: I'm also interested in 'normal' blog posting via the default blog web admin interface.</p>
|
<p>Most projects of reasonable size should have a programming/coding standards document that dictates common conventions and naming guidelines that should be followed.</p>
<p>Another way to help with this is through code reviews. Obviously some coordination among reviewers is required (the document helps with that, too). Code reviews help keep the greener devs and senior devs alike on track and act as an avenue to enforce the coding standards.</p>
|
<p>Divide your packages/modules into logical groups and use descriptive and concise names. Avoid generic names except if they are really counters etc. Create conventions for groups of functions or functionality and stick to them.</p>
| 13,732
|
<p>I am using Visual C++ 2005 Express Edition and get the following linker errors:</p>
<pre><code>19>mylib1.lib(mylibsource1.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " (__imp_?_Raise@exception@std@@QBEXXZ) referenced in function "protected: static void __cdecl std::vector<class mytype,class std::allocator<class mytype> >::_Xlen(void)" (?_Xlen@?$vector@Vmytype@@V?$allocator@Vmytype@@@std@@@std@@KAXXZ)
19>mylib2.lib(mylibsource2.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " (__imp_?_Raise@exception@std@@QBEXXZ)
19>mylib1.lib(mylibsource1.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const *,int)" (__imp_??0exception@std@@QAE@PBDH@Z) referenced in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z)
19>mylib2.lib(mylibsource2.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const *,int)" (__imp_??0exception@std@@QAE@PBDH@Z)
</code></pre>
<p>I turned off exceptions in generated code, and I am using before including the vector header file:</p>
<pre><code>#define _HAS_EXCEPTIONS 0
</code></pre>
<p>A few Google results turned up some stuff, but no "aha!" solutions that worked for me.</p>
<p>EDIT:</p>
<p>As noted "_HAS_EXCEPTIONS 0" doesn't turn off exceptions, per se. What it does is, at least in the vector header file, is call _Raise on an exception object instead of calling the C++ "throw". In my case, it can't link to the exception object's _Raise function since I am not including the correct library. What that library is, though, is not obvious.</p>
|
<p>Adding this line:</p>
<pre><code>#define _STATIC_CPPLIB
</code></pre>
<p>before including the vector header seems to do the trick.</p>
|
<p>The third error makes it clear that <code>#define the _HAS_EXCEPTIONS 0</code> does not affect . Now, might include (makes sense, sharing code might reduce the size of your executable). That would explain why you still have errors if you define it before <em>your</em> inclusion of . This kind of defines should be done in your project settings.</p>
<p>Note that _HAS_EXCEPTIONS is an unsupported feature in Visual Studio. It does not turn off exceptions as such.</p>
| 31,037
|
<p>Here's the XML file i'm working on:</p>
<pre><code><list>
<activity>swimming</activity>
<activity>running</activity>
<activity>soccer</activity>
</list>
</code></pre>
<p>The index.php, page that shows the list of activities with checkboxes, a button to delete the checked activities, and a field to add new activities:</p>
<pre><code><html>
<head></head>
<body>
<?php
$xmldoc = new DOMDocument();
$xmldoc->load('sample.xml', LIBXML_NOBLANKS);
$count = 0;
$activities = $xmldoc->firstChild->firstChild;
//prints the list of activities, with checkboxes on the left for each item
//the $count variable is the id to each entry
if($activities!=null){
echo '<form name=\'erase\' action=\'delete.php\' method=\'post\'>' . "\n";
while($activities!=null){
$count++;
echo " <input type=\"checkbox\" name=\"activity[]\" value=\"$count\"/>";
echo ' '.$activities->textContent.'<br/>'."\n";
$activities = $activities->nextSibling;
}
echo ' <input type=\'submit\' value=\'erase selected\'>';
echo '</form>';
}
?>
//section used for inserting new entries. this feature is working as expected.
<form name='input' action='insert.php' method='post'>
insert activity:
<input type='text name='activity'/>
<input type='submit' value='send'/>
<br/>
</form>
</body>
</html>
</code></pre>
<p>the delete.php, which is not working as expected:</p>
<pre><code><?php
$xmldoc = new DOMDocument();
$xmldoc->load('sample.xml', LIBXML_NOBLANKS);
$atvID = $_POST['activity'];
foreach($atvID as $id){
$delnode = $xmldoc->getElementsByTagName('activity');
$xmldoc->firstChild->removeChild($delnode->item($id));
}
$xmldoc->save('sample.xml');
?>
</code></pre>
<p>I've tested the deletion routine without the loop, using an hard-coded arbitrary id, and it worked. I also tested the $atvID array, and it printed the selected id numbers correctly. When it is inside the loop, here's the error it outputs:</p>
<blockquote>
<p>Catchable fatal error: Argument 1
passed to DOMNode::removeChild() must
be an instance of DOMNode, null given
in
/directorypath/delete.php
on line 9</p>
</blockquote>
<p>What is wrong with my code?</p>
|
<p>the DOMNodeList items are indexed starting with 0;
You need to move the $count++ to the end of the while loop in the output step.</p>
|
<p>In addition to moving $count++ to the end of the while loop, it might be a good idea to have delete.php check to make sure the $_POST['activity'] is numeric and within the specified range, just to ensure there are no fatal error messages generated on your page.</p>
| 23,788
|
<p>I've been kicking around this idea for a while and would like to read your thoughts.</p>
<p>I'd like to create a .NET service to send and track email messages.</p>
<p>My rough ideas:</p>
<ol>
<li><p>Within various applications, serialize instances of .NET email (System.Net.Mail.MailMessage) objects and put them into a database or file system queue</p></li>
<li><p>The mail service/process polls the queue and sends the emails</p></li>
<li><p>Enforce subscribe/unsubscribe lists/rules</p></li>
<li><p>Track opens, bounces, out-of-office auto-replies, etc.</p></li>
<li><p>Report statuses back to the original applications</p></li>
</ol>
<p>Does anyone have advice for how I should get started or what issues I may have? Is there off-the-shelf software/service I should look at?</p>
|
<p>You will need to learn everything you can about the SMTP protocol, even if you are using higher level tools that do most of the work for you. In my own experience with processing outbound and inbound emails with .NET, I didn't really "get it" until I learned to telnet to port 25 of an SMTP server and send en email by issuing the commands myself.</p>
<p>If you are sending lots of emails out and you need to monitor NDRs (non-deliverable reports), you will have to set the SMTP envelope sender address to your own server and parse all of those emails when they come in to figure out what happened.</p>
<p>The System.Net email classes don't allow you to set the MAIL FROM in the conversation with the MTA without also setting the From address in the email header to the same thing, so you will need to use a 3rd party library like <a href="http://www.aspnetemail.com/" rel="nofollow noreferrer">aspNetEmail</a> if you need those addresses to be different.</p>
<p><a href="http://www.listnanny.net/" rel="nofollow noreferrer">ListNanny</a> is another tool that is helpful to parse NDRs, among other functions.</p>
<p>I'm not sure about serializing the MailMessage objects. I think it would be simpler to just store the separate data elements themselves and then instantiate MailMessage objects when you need them.</p>
|
<p>You may find some of the answers to <a href="https://stackoverflow.com/questions/124304/handling-undelivered-emails-in-webapp">Handling undelivered emails in webapp</a> useful.</p>
| 19,870
|
<p>I've got a form where I have two radio buttons and two interchangeable controls (made up of a ListView and a handful of buttons). Based on which radio button is selected I want to display the proper control to the user.</p>
<p>The way I'm doing this now is just loading both controls and setting up an OnRadioButtonSelectionChanged() method which gets called at form load (to set the initial state) and at any time the selection is changed. This method just sets the visible property on each control to the proper value.</p>
<p>This seems to work well enough, but I was curious as to if there was a better or more common way of doing it?</p>
|
<p>Yep, that's pretty much how I do it. I would set the CheckedChanged event of both radio buttons to point at a single event handler and would place the following code to swap out the visible control.</p>
<pre><code>private void OnRadioButtonCheckedChanged(object sender, EventArgs e)
{
Control1.Visible = RadioButton1.Checked;
Control2.Visible = RadioButton2.Checked;
}
</code></pre>
|
<p>Well you could also use databinding... seems a bit more elegant to me. Suppose you have two radiobuttons "rbA" and "rbB" and two textboxes "txtA" and "txtB". And you want to have txtA visible only when rbA is checked and txtB visible only when rbB is checked. You could do it like so :</p>
<pre><code>private void Form1_Load(object sender, EventArgs e)
{
txtA.DataBindings.Add("Visible", rbA, "Checked");
txtB.DataBindings.Add("Visible", rbB, "Checked");
}
</code></pre>
<p>However... I observed that using UserControls instead of TextBoxes breaks the functionality and I should go read on the net why..</p>
<p>LATER EDIT : </p>
<p>The databinding works two-ways! : If you programatically set (from somewhere else) the visibility of the txtA to false the rbA will become unchecked. That's the beauty of Databinding.</p>
| 15,880
|
<p>I'm writing an iPhone app that takes a photo and then uploads it to a server. How do I upload a photo to a server with Cocoa? I suppose I use NSUrl somewhere.</p>
<p>Thanks!</p>
|
<p>Header:</p>
<pre><code>@interface EPUploader : NSObject {
NSURL *serverURL;
NSString *filePath;
id delegate;
SEL doneSelector;
SEL errorSelector;
BOOL uploadDidSucceed;
}
- (id)initWithURL: (NSURL *)serverURL
filePath: (NSString *)filePath
delegate: (id)delegate
doneSelector: (SEL)doneSelector
errorSelector: (SEL)errorSelector;
- (NSString *)filePath;
@end
</code></pre>
<p>Main:</p>
<pre><code>#import "EPUploader.h"
#import <zlib.h>
static NSString * const BOUNDRY = @"0xKhTmLbOuNdArY";
static NSString * const FORM_FLE_INPUT = @"uploaded";
#define ASSERT(x) NSAssert(x, @"")
@interface EPUploader (Private)
- (void)upload;
- (NSURLRequest *)postRequestWithURL: (NSURL *)url
boundry: (NSString *)boundry
data: (NSData *)data;
- (NSData *)compress: (NSData *)data;
- (void)uploadSucceeded: (BOOL)success;
- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
@end
@implementation EPUploader
/*
*-----------------------------------------------------------------------------
*
* -[Uploader initWithURL:filePath:delegate:doneSelector:errorSelector:] --
*
* Initializer. Kicks off the upload. Note that upload will happen on a
* separate thread.
*
* Results:
* An instance of Uploader.
*
* Side effects:
* None
*
*-----------------------------------------------------------------------------
*/
- (id)initWithURL: (NSURL *)aServerURL // IN
filePath: (NSString *)aFilePath // IN
delegate: (id)aDelegate // IN
doneSelector: (SEL)aDoneSelector // IN
errorSelector: (SEL)anErrorSelector // IN
{
if ((self = [super init])) {
ASSERT(aServerURL);
ASSERT(aFilePath);
ASSERT(aDelegate);
ASSERT(aDoneSelector);
ASSERT(anErrorSelector);
serverURL = [aServerURL retain];
filePath = [aFilePath retain];
delegate = [aDelegate retain];
doneSelector = aDoneSelector;
errorSelector = anErrorSelector;
[self upload];
}
return self;
}
/*
*-----------------------------------------------------------------------------
*
* -[Uploader dealloc] --
*
* Destructor.
*
* Results:
* None
*
* Side effects:
* None
*
*-----------------------------------------------------------------------------
*/
- (void)dealloc
{
[serverURL release];
serverURL = nil;
[filePath release];
filePath = nil;
[delegate release];
delegate = nil;
doneSelector = NULL;
errorSelector = NULL;
[super dealloc];
}
/*
*-----------------------------------------------------------------------------
*
* -[Uploader filePath] --
*
* Gets the path of the file this object is uploading.
*
* Results:
* Path to the upload file.
*
* Side effects:
* None
*
*-----------------------------------------------------------------------------
*/
- (NSString *)filePath
{
return filePath;
}
@end // Uploader
@implementation EPUploader (Private)
/*
*-----------------------------------------------------------------------------
*
* -[Uploader(Private) upload] --
*
* Uploads the given file. The file is compressed before beign uploaded.
* The data is uploaded using an HTTP POST command.
*
* Results:
* None
*
* Side effects:
* None
*
*-----------------------------------------------------------------------------
*/
- (void)upload
{
NSData *data = [NSData dataWithContentsOfFile:filePath];
ASSERT(data);
if (!data) {
[self uploadSucceeded:NO];
return;
}
if ([data length] == 0) {
// There's no data, treat this the same as no file.
[self uploadSucceeded:YES];
return;
}
// NSData *compressedData = [self compress:data];
// ASSERT(compressedData && [compressedData length] != 0);
// if (!compressedData || [compressedData length] == 0) {
// [self uploadSucceeded:NO];
// return;
// }
NSURLRequest *urlRequest = [self postRequestWithURL:serverURL
boundry:BOUNDRY
data:data];
if (!urlRequest) {
[self uploadSucceeded:NO];
return;
}
NSURLConnection * connection =
[[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
if (!connection) {
[self uploadSucceeded:NO];
}
// Now wait for the URL connection to call us back.
}
/*
*-----------------------------------------------------------------------------
*
* -[Uploader(Private) postRequestWithURL:boundry:data:] --
*
* Creates a HTML POST request.
*
* Results:
* The HTML POST request.
*
* Side effects:
* None
*
*-----------------------------------------------------------------------------
*/
- (NSURLRequest *)postRequestWithURL: (NSURL *)url // IN
boundry: (NSString *)boundry // IN
data: (NSData *)data // IN
{
// from http://www.cocoadev.com/index.pl?HTTPFileUpload
NSMutableURLRequest *urlRequest =
[NSMutableURLRequest requestWithURL:url];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:
[NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundry]
forHTTPHeaderField:@"Content-Type"];
NSMutableData *postData =
[NSMutableData dataWithCapacity:[data length] + 512];
[postData appendData:
[[NSString stringWithFormat:@"--%@\r\n", boundry] dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:
[[NSString stringWithFormat:
@"Content-Disposition: form-data; name=\"%@\"; filename=\"file.bin\"\r\n\r\n", FORM_FLE_INPUT]
dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:data];
[postData appendData:
[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundry] dataUsingEncoding:NSUTF8StringEncoding]];
[urlRequest setHTTPBody:postData];
return urlRequest;
}
/*
*-----------------------------------------------------------------------------
*
* -[Uploader(Private) compress:] --
*
* Uses zlib to compress the given data.
*
* Results:
* The compressed data as a NSData object.
*
* Side effects:
* None
*
*-----------------------------------------------------------------------------
*/
- (NSData *)compress: (NSData *)data // IN
{
if (!data || [data length] == 0)
return nil;
// zlib compress doc says destSize must be 1% + 12 bytes greater than source.
uLong destSize = [data length] * 1.001 + 12;
NSMutableData *destData = [NSMutableData dataWithLength:destSize];
int error = compress([destData mutableBytes],
&destSize,
[data bytes],
[data length]);
if (error != Z_OK) {
NSLog(@"%s: self:0x%p, zlib error on compress:%d\n",__func__, self, error);
return nil;
}
[destData setLength:destSize];
return destData;
}
/*
*-----------------------------------------------------------------------------
*
* -[Uploader(Private) uploadSucceeded:] --
*
* Used to notify the delegate that the upload did or did not succeed.
*
* Results:
* None
*
* Side effects:
* None
*
*-----------------------------------------------------------------------------
*/
- (void)uploadSucceeded: (BOOL)success // IN
{
[delegate performSelector:success ? doneSelector : errorSelector
withObject:self];
}
/*
*-----------------------------------------------------------------------------
*
* -[Uploader(Private) connectionDidFinishLoading:] --
*
* Called when the upload is complete. We judge the success of the upload
* based on the reply we get from the server.
*
* Results:
* None
*
* Side effects:
* None
*
*-----------------------------------------------------------------------------
*/
- (void)connectionDidFinishLoading:(NSURLConnection *)connection // IN
{
NSLog(@"%s: self:0x%p\n", __func__, self);
[connection release];
[self uploadSucceeded:uploadDidSucceed];
}
/*
*-----------------------------------------------------------------------------
*
* -[Uploader(Private) connection:didFailWithError:] --
*
* Called when the upload failed (probably due to a lack of network
* connection).
*
* Results:
* None
*
* Side effects:
* None
*
*-----------------------------------------------------------------------------
*/
- (void)connection:(NSURLConnection *)connection // IN
didFailWithError:(NSError *)error // IN
{
NSLog(@"%s: self:0x%p, connection error:%s\n",
__func__, self, [[error description] UTF8String]);
[connection release];
[self uploadSucceeded:NO];
}
/*
*-----------------------------------------------------------------------------
*
* -[Uploader(Private) connection:didReceiveResponse:] --
*
* Called as we get responses from the server.
*
* Results:
* None
*
* Side effects:
* None
*
*-----------------------------------------------------------------------------
*/
-(void) connection:(NSURLConnection *)connection // IN
didReceiveResponse:(NSURLResponse *)response // IN
{
NSLog(@"%s: self:0x%p\n", __func__, self);
}
/*
*-----------------------------------------------------------------------------
*
* -[Uploader(Private) connection:didReceiveData:] --
*
* Called when we have data from the server. We expect the server to reply
* with a "YES" if the upload succeeded or "NO" if it did not.
*
* Results:
* None
*
* Side effects:
* None
*
*-----------------------------------------------------------------------------
*/
- (void)connection:(NSURLConnection *)connection // IN
didReceiveData:(NSData *)data // IN
{
NSLog(@"%s: self:0x%p\n", __func__, self);
NSString *reply = [[[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding]
autorelease];
NSLog(@"%s: data: %s\n", __func__, [reply UTF8String]);
if ([reply hasPrefix:@"YES"]) {
uploadDidSucceed = YES;
}
}
@end
</code></pre>
<p>Usage:</p>
<pre><code> [[EPUploader alloc] initWithURL:[NSURL URLWithString:@"http://yourserver.com/uploadDB.php"]
filePath:@"path/to/some/file"
delegate:self
doneSelector:@selector(onUploadDone:)
errorSelector:@selector(onUploadError:)];
</code></pre>
|
<p>If you want to upload multiple images then <a href="http://iphoneapp-dev.blogspot.com/2011/05/this-example-shows-how-to-upload-images.html" rel="nofollow">this demo</a> is good option.</p>
| 15,229
|
<p>I frequently run into large, non-template classes in C++ where simple methods are defined directly in the class body in the header file instead of separately in the implementation file. For example:</p>
<pre><code>class Foo {
int getBar() const { return bar; }
...
};
</code></pre>
<p>Why do this? It seems like there are disadvantages. The implementation is not as hidden as it should be, the code is less readable, and there would also be an increased burden on the compiler if the class's header file is included in many different places.</p>
<p>My guess is that people intend for these functions to be inlined in other modules, which could improve performance significantly. However, I've heard newer compilers can do inlining (and other interprocedural optimizations) at link-time across modules. How broad is the support for this kind of link-time optimization, and does it actually make these kind of definitions unnecessary? Are there any other good reasons for these definitions?</p>
|
<p>The C++ standard says that methods defined inside the class definition are <code>inline</code> by default. This results in obvious performance gains for simplistic functions such as getters and setters. Link-time cross-module optimization is harder, although some compilers can do it.</p>
|
<p>You answered your own question, they are indeed inline methods.</p>
<p>Reasons to use them are performance. </p>
| 33,458
|
<p>How do I insert a current_timestamp into an SQL Server 2005 database datable with a timestamp column?</p>
<p>It should be simple but I cannot get it to work. Examples would be much appreciated.</p>
|
<p>if you can execute a query from PHP then it should just be a matter of using 'getdate()' ;</p>
<pre><code>update MyTable set MyColumn=getdate();
</code></pre>
<p>or</p>
<pre><code>insert into MyTable (MyColumn) values (getdate());
</code></pre>
|
<p>If you explain the error you are receiving (and post your insert or update code), it might make it easier to see what your problem is. One possible issue is that you must be inserting into a datetime field (or in 2008 you could use a date field as well). Occasionally people think that they can insert the current date into a timestamp field but even though the name of this data type seems as if it should be date related, this data type actaully has nothing to do with dates and times and cannot accept date data.</p>
| 29,621
|
<p>Everyone I talk to who knows (knew) about it claims it was the greatest thing since sliced bread. Why did it fail? Or, if it didn't fail, who's using it now?</p>
|
<p>Check out <a href="http://www.gigaspaces.com" rel="noreferrer">GigaSpaces</a>. It's a quite successful Jini/Javaspaces implementation.</p>
<p>I think Jini has a great model, but it is stuck with Java. Web-services is more appealing because it works with standarized protocols, even though Jini service discovery is more natural.</p>
|
<p>Zeroconf and other discovery protocols are similarly referred to as the greatest thing since sliced bread; it's just that the flavor keeps changing.</p>
| 6,661
|
<p>Now that most of the major browsers support full page zoom (at present, the only notable exception being Google Chrome), are liquid or elastic layouts no longer needed? Is the relative pain of building liquid/elastic layouts worth the effort? Are there any situations where a liquid layout would still be of benefit? Is full page zoom the real solution it at first appears to be?</p>
|
<p>Yes, because there are a vast variety of screens out there commonly ranging from 15" to 32".
There is also some variation in what people consider a "comfortable" font size.
All of which adds up to quite a range of sizes that your content will need to fit into.</p>
<p>If anything, liquid layout is becoming even more necessary as we scale up to huge monitors, and down to cellphone devices.</p>
|
<p>Liquid layouts can cause usability problems, though.</p>
<p>Content containers that become too wide become exceptionally difficult to read.</p>
<p>Many blogs have fixed width content containers specifically for this reason.</p>
<p>Alternatively, you can create multi-column content containers so that you get an effect like a newspaper, with its multiple columns of thin containers of text. This can be difficult to do, though.</p>
| 8,767
|
<p>I'm using a UITableView to show some data from an array. This array can be changed at any time by other threads. (I believe that whether the array is mutable, or just replaced entirely, doesn't make a difference.) Access to the array itself is threadsafe.</p>
<p>What's the proper way to ensure thread safety with regard to the tableview? I'm worried, for example, that I might change the array to be shorter just before cellForRowAtIndexPath is called, leading to an NSRangeException.</p>
<p>Should I...</p>
<ol>
<li>Enforce that the array is only changed on the main thread? (Seems ugly.)</li>
<li>Maintain a shadow array and update this on the main thread through KVO observing?</li>
<li>??? There must be a better solution...</li>
</ol>
|
<p>From your description, you really have TWO different data sets:</p>
<ul>
<li>The actual data, as it exists in your model</li>
<li>The data that's displayed to the user</li>
</ul>
<p>Thus, you already have, in effect, a 'shadow' array (virtual shadow, which may be stretching the metaphor too far). I'd say your best bet is to formalize this arrangement, and keep a 'display' array that only gets modified in the main thread. In it, you can have objects from your 'real' array; since they're only pointers, you won't be giving up too much memory.</p>
<p>Threading is evil.</p>
|
<p>I have the same situation. I have an array of C++ objects that provide the info in the tableview.</p>
<p>As Ben referred to, I also have a temporary "shadow" array into which new information is downloaded over the Internet. When the query is complete, I reconcile that array with the one backing the tableview, which is quite fast. The question is how to protect the array during that reconciliation.</p>
<p>I'm doing the reconciliation on the main thread, but I'm not sure that's sufficient to protect from conflicts, especially if the user taps on an entry while there's a query pending; the underlying object he's viewing details for might be blown away.</p>
<p>There's a similar question to yours (and mine) here:
<a href="https://stackoverflow.com/questions/3374979/update-uitableview-using-threads">Update UITableView using threads</a></p>
<p>but the answers berate the poster for taking too long with his background operation, instead of answering his question.</p>
<p>I'm going to use an NSLock, and acquire it before altering the array and in all of the UITableView delegate methods, unless somebody has a better idea.</p>
| 43,114
|
<p>I've started using Vim to develop Perl scripts and am starting to find it very powerful. </p>
<p>One thing I like is to be able to open multiple files at once with:</p>
<pre><code>vi main.pl maintenance.pl
</code></pre>
<p>and then hop between them with:</p>
<pre><code>:n
:prev
</code></pre>
<p>and see which file are open with:</p>
<pre><code>:args
</code></pre>
<p>And to add a file, I can say: </p>
<pre><code>:n test.pl
</code></pre>
<p>which I expect would then be added to my list of files, but instead it wipes out my current file list and when I type <code>:args</code> I only have <code>test.pl</code> open.</p>
<p>So how can I add and remove files in my args list?</p>
|
<p>Why not use tabs (introduced in Vim 7)?
You can switch between tabs with <code>:tabn</code> and <code>:tabp</code>,
With <code>:tabe <filepath></code> you can add a new tab; and with a regular <code>:q</code> or <code>:wq</code> you close a tab.
If you map <code>:tabn</code> and <code>:tabp</code> to your <kbd>F7</kbd>/<kbd>F8</kbd> keys you can easily switch between files.</p>
<p>If there are not that many files or you don't have Vim 7 you can also split your screen in multiple files: <code>:sp <filepath></code>. Then you can switch between splitscreens with <kbd>Ctrl</kbd>+<kbd>W</kbd> and then an arrow key in the direction you want to move (or instead of arrow keys, <kbd>w</kbd> for next and <kbd>W</kbd> for previous splitscreen)</p>
|
<p>if you're on osx and want to be able to click on your tabs, use MouseTerm and SIMBL (taken from <a href="http://ayaz.wordpress.com/2010/10/19/using-mouse-inside-vim-on-terminal-app/" rel="nofollow noreferrer">here</a>). Also, check out this <a href="https://stackoverflow.com/questions/1727261/scrolling-inside-vim-in-macs-terminal?rq=1">related discussion</a>.</p>
| 7,720
|
<p>Should I keep project filesm like Eclipse's .project, .classpath, .settings, under version control (e.g. Subversion, GitHub, CVS, Mercurial, etc)?</p>
|
<p>You do want to keep in version control <strong>any portable setting files</strong>,<br>
meaning:<br>
Any file which has no absolute path in it.<br>
That includes:</p>
<ul>
<li>.project, </li>
<li>.classpath (<em>if no absolute path used</em>, which is possible with the use of IDE variables, or user environment variables)</li>
<li><strong>IDE settings</strong> (which is where i disagree strongly with the 'accepted' answer). Those settings often includes <strong>static code analysis rules</strong> which are vitally important to enforce consistently for any user loading this project into his/her workspace. </li>
<li>IDE specific settings recommandations must be written in a big README file (and versionned as well of course).</li>
</ul>
<p>Rule of thumb for me:<br>
You must be able to load a project into a workspace and have in it everything you need to properly set it up in your IDE and get going in minutes.<br>
No additional documentation, wiki pages to read or what not.<br>
Load it up, set it up, go.</p>
|
<p>It seems like these project files can change over time as you work on a project so yes, I place them under version control.</p>
| 14,151
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.