instruction
stringlengths 21
27.8k
| chosen
stringlengths 18
28.2k
| rejected
stringlengths 18
33.6k
| __index_level_0__
int64 0
50k
|
|---|---|---|---|
<p>I need to create an empty .mdb file, so that I can then run ADO commands on it (<em>not</em> ADO.NET). Is there a way to create an empty mdb using ADO?</p>
|
<p>Here are some code snippets that work: </p>
<pre><code> string sADOProvider = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
ADOX.CatalogClass cat = new ADOX.CatalogClass();
string sCreate = MainForm.sADOProvider + sFullPath;
cat.Create(sCreate);
// The point of this code is to unlock the access file after we
// create it. You can tell it is unlocked if the .ldb file disappears.
System.Runtime.InteropServices.Marshal.ReleaseComObject(cat);
cat = null;
GC.Collect();
</code></pre>
|
<p>Not sure about creating it directly via ADO, but if Access is installed on the machine you could use Access to create the file via COM.</p>
<p>below is an early and late bound example. Both methods have their advantages / disadvantages.</p>
<pre><code>Option Explicit
Sub CreateMDBEarlyBound()
'' Remember to set your reference to "Microsoft Access XX.0 Object Library"
Dim acApp As Access.Application
Set acApp = New Access.Application
acApp.NewCurrentDatabase ("c:\temp\MyDB-early.mdb")
Set acApp = Nothing
End Sub
Sub CreateMDBLateBound()
Dim acApp As Object
On Error Resume Next
Set acApp = GetObject(, "Access.Application")
On Error GoTo 0 '' turn off the resume next
If acApp Is Nothing Then
Set acApp = CreateObject("Access.Application")
End If
acApp.NewCurrentDatabase "c:\temp\MyDB-late.mdb"
Set acApp = Nothing
End Sub
</code></pre>
| 37,664
|
<p>I'm writing Application A and DLL B, both in C#.NET. How do I do the following: </p>
<ol>
<li>A calls function in B </li>
<li>Want B to use delegate/callback to update status in UI of A </li>
</ol>
<p>This is <em>not</em> about BackgroundWorker...that part works fine in A. What I can't see is how to let B know what function to call in A.</p>
|
<p>To expand on Rob Prouse's answer, you need to declare a delegate and then pass a matching method into it.</p>
<p>In B:</p>
<pre><code>public delegate void CallbackDelegate(string status);
public void DoWork(string param, CallbackDelegate callback)
{
callback("status");
}
</code></pre>
<p>In A:</p>
<pre><code>public void MyCallback(string status)
{
// Update your UI.
}
</code></pre>
<p>And when you call the method:</p>
<pre><code>B.DoWork("my params", MyCallback);
</code></pre>
|
<p>Pass in the callback object in the call A make to B. Use an interface (or tightly bound libraries). Make sure the callback object is thread aware and thread safe.</p>
| 36,679
|
<p>I have a C# object with a critical resource that needs to be flushed very specific points in time making it a bad candidate to leave around for the garbage collector to take care of whenever it gets around to it, how should I handle this? Is there something like C++'s delete operator that will let me manually kill the instance of this object when needed?</p>
|
<p>You are looking for <a href="http://msdn.microsoft.com/en-us/library/system.idisposable.aspx" rel="noreferrer"><code>IDisposable</code></a>. Here is an example class that implements this.</p>
<pre><code>class MyDisposableObject : IDisposable
{
public MyDisposableObject()
{
}
~MyDisposableObject()
{
Dispose(false);
}
private bool disposed;
private void Dispose(bool disposing)
{
if (!this.disposed)
{
if (disposing)
{
// Dispose of your managed resources here.
}
// Dispose of your unmanaged resources here.
this.disposed = true;
}
}
void IDisposable.Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
</code></pre>
<p>To use it, you can do something like this:</p>
<pre><code>public void DoingMyThing()
{
using (MyDisposableObject obj = new MyDisposableObject())
{
// Use obj here.
}
}
</code></pre>
<p>The <a href="http://msdn.microsoft.com/en-us/library/yh598w02.aspx" rel="noreferrer"><code>using</code></a> keyword makes sure that the <a href="http://msdn.microsoft.com/en-us/library/system.idisposable.dispose.aspx" rel="noreferrer"><code>Dispose()</code></a> method on <a href="http://msdn.microsoft.com/en-us/library/system.idisposable.aspx" rel="noreferrer"><code>IDisposable</code></a> gets called at the end of its scope.</p>
|
<p>Google for the IDisposable interface. This is the only mechanism available to you. It's tailor made if your critical resource is unmanaged. If it's a managed resource, could you be more specific about what needs to be "flushed".</p>
| 22,853
|
<p>I would like to test out the new SP1 in my development server and then install it for my production server. But I wonder what it had enhance to the ASP.NET portion specifically as that is where my concerns are. </p>
<p>I read the docs found in the SP1 Download page but it seens a bit too general to me, not much on the ASP.NE portion. Anyone have any clues on this?</p>
|
<p><a href="http://weblogs.asp.net/scottgu/archive/2008/05/12/visual-studio-2008-and-net-framework-3-5-service-pack-1-beta.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/scottgu/archive/2008/05/12/visual-studio-2008-and-net-framework-3-5-service-pack-1-beta.aspx</a></p>
<p>There is a section in there on the improvements for web development.. it can be vague as well but has links to videos and further information. I suggest checking it out.</p>
|
<p>Short list:</p>
<p>ASP.NET: Dynamic Data now included in .Net 3.5 and all necessary project templates for VS also available
ASP.NET: History support added. Now we can control AJAX pages behavior on Back/Forward buttons pressed in very simple manner that was shown previously on MS demos
ASP.NET: Script Combining feature added to reduce the number of requests and improving page load time. Before this moment we used custom approach for client scripts combining
VS2008: Added richer support of JavaScript code formatting and Intellisense, especially for separated .js files</p>
<p>more on blog: <a href="http://dimarzionist.wordpress.com/2008/05/13/full-list-of-changes-in-sp1-beta/" rel="nofollow noreferrer">http://dimarzionist.wordpress.com/2008/05/13/full-list-of-changes-in-sp1-beta/</a></p>
| 10,479
|
<p>For the moment my batch file look like this:</p>
<pre><code>myprogram.exe param1
</code></pre>
<p>The program starts but the DOS Window remains open. How can I close it?</p>
|
<p>You can use the exit keyword. Here is an example from one of my batch files:</p>
<pre><code>start myProgram.exe param1
exit
</code></pre>
|
<p>If this batch file is something you want to run as scheduled or always; you can use windows schedule tool and it doesn't opens up in a window when it starts the batch file. </p>
<p>To open <code>Task Scheduler</code>:</p>
<ul>
<li>Start -> Run/Search -> <code>'cmd'</code></li>
<li>Type <code>taskschd.msc</code> -> enter</li>
</ul>
<p>From the right side, click <code>Create Basic Task</code> and follow the menus.</p>
<p>Hope this helps.</p>
| 42,029
|
<p>A Windows Forms application of ours pulls records from a view on SQL Server through ADO.NET and a SOAP web service, displaying them in a data grid. We have had several cases with ~25,000 rows, which works relatively smoothly, but a potential customer needs to have many times that much in a single list.</p>
<p>To figure out how well we scale right now, and how (and how far) we can realistically improve, I'd like to implement a simulation: instead of displaying actual data, have the SQL Server send fictional, random data. The client and transport side would be mostly the same; the view (or at least the underlying table) would of course work differently. The user specifies the amount of fictional rows (e.g. 100,000).</p>
<p>For the time being, I just want to know how long it takes for the client to retrieve and process the data and is just about ready to display it.</p>
<p>What I'm trying to figure out is this: how do I make the SQL Server send such data?</p>
<p>Do I:</p>
<ol>
<li>Create a stored procedure that has to be run beforehand to fill an actual table?</li>
<li>Create a function that I point the view to, thus having the server generate the data 'live'?</li>
<li>Somehow replicate and/or randomize existing data?</li>
</ol>
<p>The first option sounds to me like it would yield the results closest to the real world. Because the data is actually 'physically there', the <code>SELECT</code> query would be quite similar performance-wise to one on real data. However, it taxes the server with an otherwise meaningless operation. The fake data would also be backed up, as it would live in one and the same database — unless, of course, I delete the data after each benchmark run.</p>
<p>The second and third option tax the server <em>while</em> running the actual simulation, thus potentially giving unrealistically slow results.</p>
<hr>
<p>In addition, I'm unsure how to create those rows, short of using a loop or cursor. I can use <code>SELECT top <n> random1(), random2(), […] FROM foo</code> if <code>foo</code> actually happens to have <code><n></code> entries, but otherwise I'll (obviously) only get as many rows as <code>foo</code> happens to have. A <code>GROUP BY newid()</code> or similar doesn't appear to do the trick.</p>
|
<p>For data for testing CRM type tables, I highly recommend <a href="http://www.fakenamegenerator.com" rel="nofollow noreferrer">fakenamegenerator.com</a>, you can get 40,000 fake names for free.</p>
|
<p>If you want results you can rely on you need to make the testing scenario as realistic as possible, which makes option 1 by far your best bet. As you point out if you get results that aren't good enough with the other options you won't be sure that it wasn't due to the different database behaviour.</p>
<p>How you generate the data will depend to a large degree on the problem domain. Can you take data sets from multiple customers and merge them into a single mega-dataset? If the data is time series then maybe it can be duplicated over a different range. </p>
| 5,757
|
<p>So I am trying to accomplish something like this:</p>
<pre><code>SELECT * FROM table WHERE status_id IN (1,3,4);
</code></pre>
<p>using Zend_Db_Select... can't find how to do it :( Is it at all possible?</p>
|
<p>you can also use it like this:</p>
<pre><code>$data = array(1,3,4);
$select->where('status_id IN(?)', $data);
</code></pre>
<p>you dont need to implode array, and it's safer</p>
|
<pre><code>This solution works well with zf2
$ids = array('1', '2', '3', '4', '5', '6', '7', '8');
$select->where(array("app_post_id"=> $ids));
</code></pre>
<p>or</p>
<pre><code> $ids = array('1', '2', '3', '4', '5', '6', '7', '8');
$sql = new Sql($this->adapter);
$select = $sql->select();
$select->from('app_post_comments');
$select->where(array("app_post_id"=> $ids));
// echo $select->getSqlString($this->adapter->getPlatform());
// exit;
$statement = $sql->prepareStatementForSqlObject($select);
$result = $statement->execute();
$resultSet = new ResultSet();
$resultSet->initialize($result);
$resultSet->buffer()->toArray();
echo '<pre>';
print_r($resultSet);
exit;
return $resultSet;
</code></pre>
| 44,121
|
<p>Is it possible to use the Asp.Net MVC framework within SharePoint sites?</p>
|
<p>In ScottGu's <a href="http://weblogs.asp.net/scottgu/archive/2008/02/12/asp-net-mvc-framework-road-map-update.aspx" rel="noreferrer">blog from February 2008</a>, he writes:</p>
<blockquote>
<p>Currently MVC doesn't directly
integrate with SharePoint. That is
something we'll be looking at
supporting in the future though.</p>
</blockquote>
<p>There's a project on CodePlex for getting ASP.NET MVC to work in SharePoint:
<a href="http://www.codeplex.com/SharePointMVC" rel="noreferrer">http://www.codeplex.com/SharePointMVC</a></p>
|
<p>I don't believe so, although you can upload standard ASPX files into SharePoint and have them operate I'm pretty sure that the URL rewritting is where it would come unstuck.</p>
| 9,631
|
<p>I have a function pointer defined by:</p>
<pre><code>typedef void (*EventFunction)(int nEvent);
</code></pre>
<p>Is there a way to handle that function with a specific instance of a C++ object?</p>
<pre><code>class A
{
private:
EventFunction handler;
public:
void SetEvent(EventFunction func) { handler = func; }
void EventOne() { handler(1); }
};
class B
{
private:
A a;
public:
B() { a.SetEvent(EventFromA); } // What do I do here?
void EventFromA(int nEvent) { // do stuff }
};
</code></pre>
<p><strong>Edit:</strong> Orion pointed out the options that Boost offers such as:</p>
<pre><code>boost::function<int (int)> f;
X x;
f = std::bind1st(
std::mem_fun(&X::foo), &x);
f(5); // Call x.foo(5)
</code></pre>
<p>Unfortunately Boost is not an option for me. Is there some sort of "currying" function that can be written in C++ that will do this kind of wrapping of a pointer to a member function in to a normal function pointer?</p>
|
<p>Run away from raw C++ function pointers, and use <a href="http://msdn.microsoft.com/en-us/library/bb982519.aspx" rel="nofollow noreferrer"><code>std::function</code></a> instead.</p>
<p>You can use <a href="http://www.boost.org/doc/libs/1_36_0/doc/html/function/tutorial.html#id2903300" rel="nofollow noreferrer"><code>boost::function</code></a> if you are using an old compiler such as visual studio 2008 which has no support for C++11.<br>
<code>boost:function</code> and <code>std::function</code> are the same thing - they pulled quite a bit of boost stuff into the std library for C++11.</p>
<p>Note: you may want to read the boost function documentation instead of the microsoft one as it's easier to understand</p>
|
<p>It's somewhat unclear what you're trying to accomplish here. what is clear is that function pointers is not the way. </p>
<p>maybe what you're looking for is pointer to method.</p>
| 18,252
|
<p>I have a table defined (see code snippet below). How can I add a constraint or whatever so that the LastUpdate column is automatically updated anytime the row is changed?</p>
<pre><code>CREATE TABLE dbo.Profiles
(
UserName varchar(100) NOT NULL,
LastUpdate datetime NOT NULL CONSTRAINT DF_Profiles_LastUpdate DEFAULT (getdate()),
FullName varchar(50) NOT NULL,
Birthdate smalldatetime NULL,
PageSize int NOT NULL CONSTRAINT DF_Profiles_PageSize DEFAULT ((10)),
CONSTRAINT PK_Profiles PRIMARY KEY CLUSTERED (UserName ASC),
CONSTRAINT FK_Profils_Users FOREIGN KEY (UserName) REFERENCES dbo.Users (UserName) ON UPDATE CASCADE ON DELETE CASCADE
)
</code></pre>
|
<p>I agree with the others -- set a default value of GetDate() on the LastUpdate column and then use a trigger to handle any updates.</p>
<p>Just something simple like this:</p>
<pre><code>CREATE TRIGGER KeepUpdated on Profiles
FOR UPDATE, INSERT AS
UPDATE dbo.Profiles
SET LastUpdate = GetDate()
WHERE Username IN (SELECT Username FROM inserted)
</code></pre>
<p>If you want to get really fancy, have it evaluate what's being changed versus what's in the database and only modify LastUpdate if there was a difference.</p>
<p>Consider this...</p>
<ul>
<li><p><strong>7am</strong> - User 'jsmith' is created with a last name of 'Smithe' (oops), LastUpdate defaults to 7am</p></li>
<li><p><strong>8am</strong> - 'jsmith' emails IT to say his name is incorrect. You immediately perform the update, so the last name is now 'Smith' and (thanks to the trigger) LastUpdate shows 8am</p></li>
<li><p><strong>2pm</strong> - Your slacker coworker finally gets bored with StumbleUpon and checks his email. He sees the earlier message from 'jsmith' regarding the name change. He runs: <em>UPDATE Profiles SET LastName='Smith' WHERE Username='jsmith'</em> and then goes
back to surfing MySpace. The trigger doesn't care that the last name was already 'Smith', however, so LastUpdate now shows 2pm.</p></li>
</ul>
<p>If you just blindly change LastUpdate whenever an update statement runs, it's TECHNICALLY correct because an update did happen, but it probably makes more sense to actually compare the changes and act accordingly. That way, the 2pm Update statement by the coworker would still run, but LastUpdate would still show 8am.</p>
<p>--Kevin</p>
|
<p>My suggestion would be to create a stored procedure which defaults the lastUpdate to getdate(). </p>
<p>I've tried to avoid triggers in the past because pre-SQL2005 locating and editing them was a pain in the rump. Especially for developers who are new to your project. </p>
<p>Also add that as the default value for your column definition.</p>
| 5,663
|
<p>With generics, is there ever a reason to create specific derived EventArg classes</p>
<p>It seems like now you can simply use them on the fly with a generic implementation.</p>
<p>Should i go thorugh all of my examples and remove my eventArg classes (StringEventArgs, MyFooEventArgs, etc . .)</p>
<pre><code>public class EventArgs<T> : EventArgs
{
public EventArgs(T value)
{
m_value = value;
}
private T m_value;
public T Value
{
get { return m_value; }
}
}
</code></pre>
|
<p>What you are describing are essentially <a href="http://en.wikipedia.org/wiki/Tuple" rel="noreferrer">tuples</a>, grouped values used for a particular purpose. They are a useful construct in <a href="http://en.wikipedia.org/wiki/Functional_programming" rel="noreferrer">functional programming</a> and support that style very well.</p>
<p>The downside is that their values are not named, and they require context to be understood. <code>EventArgs</code> by their very nature are often consumed far away from their relevant context. Therefore, tuple-esque <code>EventArgs</code> can be very confusing for the consumer.</p>
<p>Let's say we have an event indicating some division has been completed, and it carries the numerator, denominator, and result:</p>
<pre><code>public event EventHandler<EventArgs<double, double, double>> Divided;
</code></pre>
<p>The event handler has some ambiguity:</p>
<pre><code>private void OnDivided(object sender, EventArgs<double, double, double> e)
{
// I have to just "know" this - it is a convention
var numerator = e.Value1;
var denominator = e.Value2;
var result = e.Value3;
}
</code></pre>
<p>This would be much clearer with an <code>EventArgs</code> representing the event:</p>
<pre><code>private void OnDivided(object sender, DividedEventArgs e)
{
var numerator = e.Numerator;
var denominator = e.Denominator;
var result = e.Result;
}
</code></pre>
<p>Generic reusable <code>EventArgs</code> classes ease development of the mechanism at the expense of expressing intent.</p>
|
<p>As TcKs already said: Use <code>EventArgs<T></code> if you only need to pass one value, otherwise derive from <code>EventArgs</code> (or <code>EventArgs<T></code>, whatever you want).</p>
| 40,133
|
<p>I have a TCP server that is listening on a particular interface only. I want that after the <code>accept()</code> call if the incoming connection was from <code>xxx.xxx.xxx.0</code> subnet then the data should go through intf1 otherwise the data should be sent through intf2 which is where my server is listening. </p>
<p>Both the interfaces have the same route settings and priority. All the networks are accessible from both the interfaces.</p>
<p>One way out could be to add a new route through intf1 with higher priority, but I want this to be a code based decision. </p>
<p>The code is in pure C written on Linux.</p>
|
<p>While it's not exactly the pure C option that you're looking for perhaps you could use an <a href="http://www.netfilter.org/" rel="nofollow noreferrer">iptables</a> rule upon receipt of the accept().</p>
<p>(although a quick look at /lib/iptables shows that you might be in luck)</p>
<p>I'm imagining a rule that would redirect all tcp traffic to your nominated device. You could possibly even make the rule aware of the socket state so that you didn't need to nominate the interface after the accept().</p>
<hr>
<p>All of this applies until I spot the obvious flaw in the scheme, slap my head and say "D'oh!"</p>
|
<p>Unfortunately your options are limited, as the TCP/IP stack is implemented in the kernel and your interface is the routing table. Your best bet is to manually assign a route.<br/></p>
<p>You could also use the netlink library to add/remove routes on-the-fly, but some portion of the TCP packets are going to go across the 'wrong' interface until the call is made. You will probably come up against routing issues when your packets with the original interface's address are emitted via another interface.</p>
| 14,560
|
<p>I have an <code>ICollection<T></code> called <code>foos</code> in my class which I want to expose as read-only (see <a href="https://stackoverflow.com/questions/284090/how-to-get-a-readonlycollectiont-of-the-keys-in-a-dictionaryt-s">this question</a>). I see that the interface defines a property <code>.IsReadOnly</code>, which seems appropriate... My question is this: how do I make it obvious to the consumer of the class that <code>foos</code> is read-only? </p>
<p>I don't want to rely on them remembering to query <code>.IsReadOnly</code> before trying a not-implemented method such as <code>.Add()</code>. Ideally, I would like to expose <code>foos</code> as a <code>ReadOnlyCollection<T></code>, but it does not implement <code>IList<T></code>. Should I expose <code>foo</code> via a method called, for example, <code>GetReadOnlyFooCollection</code> rather than via a property? If so, would this not confuse someone who then expects a <code>ReadOnlyCollection<T></code>? </p>
<p>This is C# 2.0, so extension methods like <code>ToList()</code> are not available...</p>
|
<p>You can make "foos" a ReadOnlyCollection like this:</p>
<pre><code>ReadOnlyCollection<T> readOnlyCollection = foos.ToList<T>().AsReadOnly();
</code></pre>
<p>Then you can expose it as a property of your class.</p>
<p>EDIT:</p>
<pre><code> class FooContainer
{
private ICollection<Foo> foos;
public ReadOnlyCollection<Foo> ReadOnlyFoos { get { return foos.ToList<Foo>().AsReadOnly();} }
}
</code></pre>
<p>Note: You should remember that once you get the ReadOnlyFoos collection is no longer "synchronized" with your foos ICollection. See the <a href="https://stackoverflow.com/questions/284090/how-to-get-a-readonlycollectiont-of-the-keys-in-a-dictionaryt-s">thread you referenced</a>.</p>
|
<p>Return a T[]:</p>
<pre><code>private ICollection<T> items;
public T[] Items
{
get { return new List<T>(items).ToArray(); }
}
</code></pre>
| 36,219
|
<p>I need to create a internal website and can't figure out if we should be writing our own, or using an existing framework.</p>
<p>Most of the website will essentially be a front end to a database. We need to have a number of people enter data into forms. We then want to be able to show different views of all this data -- including running small queries (e.g. how many resources do we have with attribute 'X'). As is usually the case with this, we will want to tweak the UI on a regular basis.</p>
<p>There actual data design is not a simple 1:1 mapping of resource to entry. For example, we might track several attributes for one item as the "base set of data" for that item. Then we could have several additional sets of data. </p>
<p>Imagine a recipe application. You might have a recipse for a starter. This could then be referenced by several other recipes that need that same information.</p>
<p>I feel like this is best suited for a general framework (Ruby on Rails, Django, etc), but I wonder if it might not be good for a "traditional" CMS platform like Drupal? I specifically mention Drupal since the people that would develop this have the most knowledge using php and MySql.</p>
<p>I usually lean towards wanting to use an existing platform, but am interested in other people's thoughts. To give you an idea of scope, I would imagine if we wrote this from scratch we are probably talking about 3-5 weeks of development.</p>
<p>Would you recommend writing our own, or using an existing framework? If you would suggest using something that exists what would you recommend?</p>
<p>Would you consider this to be best suited for a straight framework or a straight CMS?</p>
<p>Thanks!</p>
|
<p>It's possible that Drupal will be a good solution for you, though you'll probably need a few key additional modules like the "Content Creation Kit" (CCK) and "Views".</p>
<p>Unlike other web CMS systems (WordPress, Exponent, phpNuke), Drupal treats your entries as a "pool" of content, from which you pull various subsets for different areas of your site.</p>
<p>There is a lot of documentation for Drupal (almost too much), the biggest problem is finding the piece that's relevant to what you're trying to achieve. Diving on to one of the interactive IRC channels can be a good idea, as the community is quite helpful and is almost always willing to give you a pointer in the right direction.</p>
<p>The power, flexiblity and capability of Drupal is both its biggest strength and weakness - I know it took me a bit of effort to get my head around key concepts, and I'm far from being a Drupal Expert.</p>
<p>One last comment: Having written my own CMS from scratch, which I abandoned in favour of Drupal, I'd suggest your 3-5 week estimate is likely on the light side.</p>
|
<p>Stay away from Drupal for any site that requires customized functionality. I recently used Drupal for a website at work, and it was VERY difficult to figure out how to get it to do what I wanted it to do. There is a lot of documentation out there, but all of it is unhelpful -- it answers very specific questions about specific issues but does not provide any context as to how you would approach building the site as a whole. If you're a programmer, using a more general framework will probably work better, as CMS's are designed for a specific kind of site, and if you want your site to have non-standard functionality you are going to be fighting the system instead of working with it. If your developers are most experienced in PHP, try one of the PHP frameworks that mimics the architecture of Rails -- e.g. cakePHP or CodeIgniter.</p>
| 40,779
|
<p>I'm currently looking into options for creating a client API for a RESTfull application. Up until now we have had WCF services to allow all application to connect to the Business Layer and we're growing dissatisfied with it.</p>
<p>We already have most of the infrastructure in place for the web (html and json requests) but we need to access the services from other applications (some will be linked against the main web app models library, others won't be).</p>
<p>I've been reading about WADL <a href="http://searchsoa.techtarget.com/tip/0,289483,sid26_gci1265367,00.html" rel="nofollow noreferrer">here</a> and <a href="https://wadl.dev.java.net/wadl2java.html" rel="nofollow noreferrer">here</a> and it seems like it would be beneficial. We could generate the wadl, the client libraries and use it to check javascript urls.</p>
<p>I would like to know what others have used, what worked and what didn't.</p>
|
<p>A good rest client API is a set of wrappers around curl, wget, or your language specific HTTP libraries. You might need some extra methods or functions to deal with the specifics of your application as well (i.e. specialized XML/JSON parsing), but that should be about it.</p>
|
<p><a href="http://www.mulesoft.org/display/IBEANS/Home" rel="nofollow noreferrer">iBeans</a> is a new open source project that is attempting to provide a solution to this. iBeans (Integration Beans) are client APIs for RESTful or other services. Currently iBeans does require a server (you can drop the framework into Tomcat quite easily) and can be used from Javascript or java applications.</p>
| 31,082
|
<p>Is it possible to have a singleton in a factory method? I have many domains using the factory method. How do I work around with this. Please help me with an example.</p>
|
<p>In this example, I believe you would want to synchronize your getInstance() method to ensure two threads do not simultaneously enter it. Otherwise two threads can end up inside the block where the singleton is instantiated which is very problematic. The only issue with this solution is you pay a premium for the synchronization of the method every time getInstance() is called.
Example:</p>
<pre><code>public static synchronized Singleton getInstance()
{
// since whole method is synchronized only 1 thread can
// enter the following block ensuring only one instance
// is ever created. however we pay a synchronization
// penalty every time this method is called.
if(mInstance==null) {
mInstance=new Singleton();
}
return mInstance;
}
</code></pre>
<p>Alternatively you could also switch to use eager initialization of the singleton instance rather than lazy initialization if initializing is cheap which guarantees concurrency as well as not paying a synchronized penalty for invoking the getInstance() method.
Example:</p>
<pre><code>// no synchronization penalty, but penalty for eager init
private static Singleton mInstance = new Singleton();
public static Singleton getInstance()
{
return mInstance;
}
</code></pre>
<p>The most optimized approach is to use double-checked locking, something you need Java 1.5 or newer to use reliably due to differing implementations of the volatile keyword in 1.4 or older JVMs (please refer to "Head First Design Patterns" chapter 5 p.182 published by O'Reilly Media, Inc. -- that is where I first read about this.)
Example:</p>
<pre><code>private volatile static Singleton mInstance;
private Singleton(){}
public static Singleton getInstance()
{
if(mInstance==null) {
synchronized (Singleton.class) {
// only pay synchronization penalty once
if(mInstance==null){
mInstance=new Singleton();
}
}
}
return mInstance;
}
</code></pre>
|
<p>This example is not a formal Factory Pattern (GoF) but is still helpful if you use it like a <a href="https://rads.stackoverflow.com/amzn/click/com/0321356683" rel="nofollow noreferrer" rel="nofollow noreferrer">Static Factory Method</a></p>
<pre><code>abstract class Product {}
class ConcreteProduct extends Product{}
class ProductSupportFactory {
private static ProductSupportFactory instance = null;
private ConcreteProduct product = null;
static {
instance = new ProductSupportFactory();
}
private ProductSupportFactory() {
product = new ConcreteProduct(); //object initialization
}
public static ProductSupportFactory getInstance(){
return instance;
}
public ConcreteProduct getProduct() {
return product;
}
public void setProduct(ConcreteProduct product) {
this.product = product;
}
}
public class ProductConsumer {
public static void main(String args[]){ //client
ConcreteProduct uniqueInstance = ProductSupportFactory.getInstance().getProduct();
ConcreteProduct sharedInstance = ProductSupportFactory.getInstance().getProduct(); //same object hash
}
}
</code></pre>
| 46,419
|
<p>Following up on <a href="https://stackoverflow.com/questions/189893/is-there-any-way-to-get-code-folding-in-delphi-7">this</a> question, I'm working on a large Delphi 7 codebase which was not written very nicely. </p>
<p>I'm looking at code like this, as a small example:</p>
<pre><code> if FMode=mdCredit then begin
Panel8.Caption:='Credit';
SpeedButton3.Enabled:=false;
SpeedButton4.Enabled:=false;
SpeedButton5.Enabled:=false;
SpeedButton5.Enabled:=false;
SpeedButton6.Visible:=False;
SpeedButton10.Visible:=False;
end;
</code></pre>
<p>Followed by another 6 very similar blocks. The whole thing is in this style.
So I'm thinking that this would be much easier to read if the controls were named sensibly.</p>
<p>I could just use a global search and replace, but I'll run into problems when multiple forms use the same names, and also I'd have to be careful to change (eg) SpeedButton10 before SpeedButton1.</p>
<p>Is there some plugin which has the ability to perform a "smart" rename for me?</p>
<p><strong>Edit:</strong><br>
Sorry, I should have mentioned this before: I tried both GExperts and Castalia's "Rename Component" feature, but they both seem to be intended for use when adding the component to the form initially. </p>
<p>They don't do a search+replace in the code, or rename existing events (SpeedButtonXClick() -> cmdCreditClick()). </p>
<p>Have I missed something?</p>
|
<p>Not exactly a plug-in, but you can use one of the more recent versions of Delphi and the refactoring feature in there. Maybe you could use the free <a href="http://www.turboexplorer.com/" rel="nofollow noreferrer">Turbo Edition</a> . . . </p>
<p>You might try <a href="http://www.modelmakertools.com/" rel="nofollow noreferrer">ModelMaker</a> for Delphi 7. It has refactoring support that might work for you. </p>
|
<p>The <a href="http://conferences.codegear.com/article/32128#RenameSymbol" rel="nofollow noreferrer">Rename Symbol</a> refactoring in recent Delphi versions will work across units in a project. Since you say Delphi 7 I guess that's not going to help you, and in the past I've just used <a href="http://www.textpad.com" rel="nofollow noreferrer">TextPad</a>, a great editor that (like many others) will do powerful search/replace across files (with or without confirmation).</p>
<p>HTH</p>
<p>Edit: Craig's right - GExperts will do this, as will <a href="http://twodesks.com/castalia/refactoring.html" rel="nofollow noreferrer">Castalia</a>.</p>
| 25,375
|
<p>When serializing/de-serializing certain classes I've come across the need to flag or mark certain properties as CDATA elements (due to their content). I am currently handling this like so:</p>
<pre><code> <XmlElement("MessageText")> _
Public Property XmlContentLeft() As XmlCDataSection
Get
Dim doc As New XmlDataDocument()
Dim cd As XmlCDataSection = doc.CreateCDataSection(Me.MessageText)
Return cd
End Get
Set(ByVal value As XmlCDataSection)
Me.MessageText = value.Value
End Set
End Property
<XmlIgnore()> _
Public Property MessageText() As String
Get
Return _messageText
End Get
Set(ByVal value As String)
_messageText= value
End Set
End Property
</code></pre>
<p>Now while this works great it has drawbacks -- I now have duplicate properties for anything I want to be a CDATA element and I have to write extra code for these properties.</p>
<p>So my question is whether or not there is a better way to do this? I don't want to have to write custom schemas or serialization routines for each class. In an ideal scenario I'd be able to add an attribute to these properties so they are automatically treated as CDATA elements. </p>
|
<p>Two things:</p>
<p>1) You can simplify your existing CDATA code like this:</p>
<pre><code><XmlElement("MessageText")> _
Public Property XmlContentLeft() As XmlCDataSection
Get
return GetCData(Me.MessageText)
End Get
Set(ByVal value As XmlCDataSection)
Me.MessageText = value.Value
End Set
End Property
' this method is re-usable by any property that needs CData
Private Function GetCData(ByVal value As String) As XmlCDataSection
Static doc As New XmlDataDocument()
return doc.CreateCDataSection(value)
End Function
<XmlIgnore()> _
Public Property MessageText() As String
Get
Return _messageText
End Get
Set(ByVal value As String)
_messageText= value
End Set
End Property
</code></pre>
<p>Of course that's actually more code than you posted, but note that your CData property is now much simpler. Also, my use of <code>Static</code> isn't a typo or C# mistake. VB.Net has a little-known <code>Static</code> keyword for creating members in functions. This way the XmlDataDocument is only created once for the entire class and doesn't pollute your class's private namespace.</p>
<p>2) The serializer should already properly escapes character data. Do you really need it to be CData? Anything you serialize should be properly deserialized to match the original, even things like code strings. The only case I can thing where you might <em>need</em> a CDATA section is if you have to conform to a schema that's expecting it.</p>
|
<p>I had a similar problem - a client needed XML from a webservice with strings wrapped in horrible CData tags, this is totally unneccessary but they didn't want to recode their client so I had to make my XML conform.</p>
<p>The way I worked it was to retype the (string) properties I wanted to appear as CDATA to my own custom type "XmlCDataString".</p>
<p>I then implemented IXmlSerializable on that type and shoved a couple of Narrowing and Widening conversion operator overloads in so that the properties still work as much like Strings as possible.</p>
<pre><code>Imports System.Xml.Serialization
Imports System.Xml
<Serializable()> _
Public Class XmlCDataString
Implements IXmlSerializable
Private _strValue As String = Nothing
Public Sub New()
End Sub
Public Sub New(ByVal strValue As String)
_strValue = strValue
End Sub
Public Property StringValue() As String
Get
Return _strValue
End Get
Set(ByVal value As String)
_strValue = value
End Set
End Property
Public Shared Widening Operator CType(ByVal strValue As String) As XmlCDataString
Return New XmlCDataString(strValue)
End Operator
Public Shared Narrowing Operator CType(ByVal cdata As XmlCDataString) As String
Return cdata.StringValue
End Operator
Public Function GetSchema() As System.Xml.Schema.XmlSchema Implements System.Xml.Serialization.IXmlSerializable.GetSchema
Throw New NotImplementedException
End Function
Public Sub ReadXml(ByVal reader As System.Xml.XmlReader) Implements System.Xml.Serialization.IXmlSerializable.ReadXml
' TODO
End Sub
Public Sub WriteXml(ByVal writer As System.Xml.XmlWriter) Implements System.Xml.Serialization.IXmlSerializable.WriteXml
Dim doc As XmlDocument
Dim xmlCData As XmlCDataSection
Dim serializer As XmlSerializer
doc = New XmlDataDocument()
xmlCData = doc.CreateCDataSection(_strValue)
serializer = New XmlSerializer(GetType(XmlCDataSection))
serializer.Serialize(writer, xmlCData)
End Sub
End Class
</code></pre>
<p>The properties I am then serializing to CData I have to retype as follows (using your example):</p>
<pre><code>Private _messageText As XmlCDataString
Public Property MessageText() As XmlCDataString
Get
Return _messageText
End Get
Set(ByVal value As XmlCDataString)
_messageText= value
End Set
End Property
</code></pre>
<p>That worked for me!</p>
| 36,072
|
<p>For example for the following XML</p>
<pre><code> <Order>
<Phone>1254</Phone>
<City>City1</City>
<State>State</State>
</Order>
</code></pre>
<p>I might want to find out whether the XElement contains "City" Node or not. </p>
|
<p>Just use the other overload for <a href="http://msdn.microsoft.com/en-us/library/bb348975.aspx" rel="noreferrer">Elements</a>.</p>
<pre><code>bool hasCity = OrderXml.Elements("City").Any();
</code></pre>
|
<p>David's is the best but if you want you can write your own predicate if you need some custom logic <code>OrderXML.Elements("City").Exists(x=>x.Name =="City")</code></p>
| 29,700
|
<p>I would like to know how people implement the following data structures in C# without using the base class library implementations:-</p>
<ul>
<li>Linked List</li>
<li>Hash Table</li>
<li>Binary Search Tree</li>
<li>Red-Black Tree</li>
<li>B-Tree</li>
<li>Binomial Heap</li>
<li>Fibonacci Heap</li>
</ul>
<p>and any other fundamental data structures people can think of!</p>
<p>I am curious as I want to improve my understanding of these data structures and it'd be nice to see C# versions rather than the typical C examples out there on the internet!</p>
|
<p>There's a series of <a href="http://msdn.microsoft.com/en-us/vcsharp/aa336800.aspx" rel="nofollow noreferrer">MSDN articles</a> on this subject. However, I haven't really read the text myself. I believe that the collections framework by .NET has a broken interface and cannot be extended very well.</p>
<p>There's also <a href="http://www.itu.dk/research/c5/" rel="nofollow noreferrer">C5</a>, a libray that I am investigating right now.</p>
<p>For the reason mentioned above, I've had the project to implement my own collections library for .NET but I've stopped this project after the first benchmark revealed that even a straightforward, non-thread-safe generic <code>Vector</code> implementation is slower than the native <code>List<T></code>. Since I've taken care not to produce any inefficient IL code, this means that .NET is simply not suited (yet) for writing on-par replacements for intrinsic data structures, and that the .NET framework has to use some behind-the-scenes knowledge to optimize the builtin collection classes.</p>
|
<p>Check out <a href="https://github.com/SSCLI" rel="nofollow noreferrer">Rotor 2</a> or use <a href="https://www.red-gate.com/products/dotnet-development/reflector/" rel="nofollow noreferrer">reflector</a> too see how Microsoft did it!!!</p>
<p>also you can check <a href="https://referencesource.microsoft.com/#mscorlib/system/collections/generic/list.cs" rel="nofollow noreferrer">Microsoft reference source</a></p>
| 7,072
|
<p>What are the differences, and pros & cons, between 3D printers with varying layouts for moving head vs. moving build plate?</p>
<p>Example layouts would include:</p>
<ul>
<li>X Head; YZ Bed; </li>
<li>XY Head; Z Bed; </li>
<li>XYZ Head; </li>
<li>etc.</li>
</ul>
<p>In particular, what are their respective strengths, weaknesses, specializations, maintenance considerations, etc.?</p>
|
<p>Without going into too much detail, since this is a very exhaustive topic, I'll write some pro's of each down from the top of my head:</p>
<p>Cartesian XZ hotend, Y bed (eg. Prusa Mendel):</p>
<ul>
<li>easy to build (relatively)</li>
<li>easy to maintain</li>
<li>easy to modify</li>
<li>understandable kinematics</li>
<li>with the right frame, no x-y-z orthogonality (90 degree angles) needs to be adjusted</li>
<li>affordable</li>
<li>bad for timelapse recordings</li>
<li>print quality will theoretically always be inferior at the same speeds and accelerations to kinematics that have less mass to move (heavy printbeds will lead to ghosting)</li>
<li>z-wobble is only existent in this approach</li>
<li>big build-plates are no option for this design (last feasible size might be 20x30 cm)</li>
</ul>
<p>Cartesian XY hotend, Z bed (core-XY, sparkcube, Ultimaker, Makerbot)</p>
<ul>
<li>less mass to be moved -> faster print speeds possible</li>
<li>almost no size limitaions</li>
<li>construction is easy to enclose in most models due to the cubic frame</li>
<li>looks almost always professional</li>
<li>enclosure can be hard to modify due to constraints in space</li>
</ul>
<p>XYZ hotend (Delta bots)</p>
<ul>
<li>master of circles</li>
<li>less mass to be moved -> faster print speeds possible</li>
<li>impressive to watch</li>
<li>more load on the processing unit due to more complicated kinematics (32 bit needed for fast print speeds and responsive control with display)</li>
<li>kinematics not easily understandable</li>
<li>error-cause search can be very complicated</li>
<li>more accurate in the center than on the outer limits due to the kinematic approach</li>
</ul>
<p>The list is for sure not complete, and as a major disclaimer: print quality will always, with every approach, depend more on the setup and calibration of the printer than on the model. There are people around that produce great prints from an acrylic frame cartesian printer and lots of people that produce mediocre results with expensive printers in fancy designs.</p>
<p>I will add some links to the list items when I find the time, for now you have to believe me. I am highly appreciating corrections and additions!</p>
|
<p>I think this is simple, breaking it into simple parts... It is much easier to calibrate a machine where each axis does one thing. For instance, the Ultimaker; one of the few XY-on-the-same-axis printers... It has such a crazy complicated pulley system. If one thing gets out of whack, everything will start binding. Thankfully this doesn't happen as they did a good job, but it comes at a price. All the double pulleys and double rods - that costs money.</p>
<p>However if you break it into smaller bits then less will go wrong. </p>
<p>When I upgraded my MendelMax 1.5 to use a PBC linear solid slide for the X axis, it instantly solved all my issues with the rods binding (two rods into one big slide).</p>
<p>To quote my coworker,</p>
<blockquote>
<p>It's like balancing a stool. Is it easier to balance a 4 legged stool or a 3?</p>
</blockquote>
<p>Following from that, there is probably a good hour's worth of mechanical engineering information that can be said in regards to the linear motion itself. I would rather calibrate one axis at at time, and not worry about weird behavior caused by a XYZ head.</p>
| 319
|
<p>How would I go about creating a web app login handler in C#? </p>
<p>In Java I would use a JSP that posts the username and password to a servlet, which then delegates to a POJO - for the db lookup and validation. If validation fails the servlet forwards onto the login.jsp for another attempt, if successfull then forwards to the secure resource.</p>
|
<p>Look into <a href="https://learn.microsoft.com/en-us/previous-versions/msp-n-p/ff647070(v=pandp.10)" rel="nofollow noreferrer"><strong>Forms Authentication</strong></a>.</p>
|
<p>In asp.net web form model each page posts back to itself. create an function that is tied to a button click to do the db lookup and validation.</p>
<p>Here is an example in VB.net that can be easily converted to c# using a vb to c# converter:</p>
<p><a href="http://www.sitepoint.com/article/securing-passwords-database/" rel="nofollow noreferrer">http://www.sitepoint.com/article/securing-passwords-database/</a></p>
| 15,756
|
<pre><code>#!/bin/bash
hello()
{
SRC=$1
DEST=$2
for IP in `cat /opt/ankit/configs/machine.configs` ; do
echo $SRC | grep '*' > /dev/null
if test `echo $?` -eq 0 ; then
for STAR in $SRC ; do
echo -en "$IP"
echo -en "\n\t ARG1=$STAR ARG2=$2\n\n"
done
else
echo -en "$IP"
echo -en "\n\t ARG1=$SRC ARG2=$DEST\n\n"
fi
done
}
hello $1 $2
</code></pre>
<p>The above is the shell script which I provide source (SRC) & desitnation (DEST) path. It worked fine when I did not put in a SRC path with wild card '<em>'. When I run this shell script and give '</em>'.pdf or '*'as follows:</p>
<pre><code>root@ankit1:~/as_prac# ./test.sh /home/dev/Examples/*.pdf /ankit_test/as
</code></pre>
<p>I get the following output:</p>
<pre><code>192.168.1.6
ARG1=/home/dev/Examples/case_Contact.pdf ARG2=/home/dev/Examples/case_howard_county_library.pdf
</code></pre>
<p>The DEST is /ankit_test/as but DEST also get manupulated due to '*'. The expected answer is </p>
<pre><code>ARG1=/home/dev/Examples/case_Contact.pdf ARG2=/ankit_test/as
</code></pre>
<p>So, if you understand what I am trying to do, please help me out to solve this BUG.
I'll be grateful to you.</p>
<p>Thanks in advance!!!</p>
<p>I need to know exactly how I use '*.pdf' in my program one by one without disturbing DEST.</p>
|
<p>The shell will expand wildcards unless you escape them, so for example if you have </p>
<pre><code>$ ls
one.pdf two.pdf three.pdf
</code></pre>
<p>and run your script as</p>
<pre><code>./test.sh *.pdf /ankit__test/as
</code></pre>
<p>it will be the same as </p>
<pre><code>./test.sh one.pdf two.pdf three.pdf /ankit__test/as
</code></pre>
<p>which is not what you expect. Doing</p>
<pre><code>./test.sh \*.pdf /ankit__test/as
</code></pre>
<p>should work.</p>
|
<p>There's no need to spawn a shell to look at the <code>$?</code> variable, you can evaluate it directly.</p>
<p>It should just be:</p>
<pre><code>if [ $? -eq 0 ]; then
</code></pre>
| 32,225
|
<p>I've heard of "error" when using floating point variables. Now I'm trying to solve this puzzle and I think I'm getting some rounding/floating point error. So I'm finally going to figure out the basics of floating point error.</p>
<p>What is a simple example of floating point/rounding error (preferably in C++) ?</p>
<p>Edit: For example say I have an event that has probability p of succeeding. I do this event 10 times (p does not change and all trials are independent). What is the probability of exactly 2 successful trials? I have this coded as:</p>
<pre><code>double p_2x_success = pow(1-p, (double)8) * pow(p, (double)2) * (double)choose(8, 2);
</code></pre>
<p>Is this an opportunity for floating point error?</p>
|
<p>Picture is worth a thousand words - try to draw equation <code>f(k)</code> :<br> <img src="https://i.stack.imgur.com/bZcxI.gif" alt="enter image description here"> <br>and you will get such XY graph (X and Y are in logarithmic scale).<br>
<img src="https://i.stack.imgur.com/UVWuE.png" alt="enter image description here">
<br>If computer could represent 32-bit floats without rounding error then for every <code>k</code> we should get zero. But instead error increases with bigger values of k because of floating point error accumulation.</p>
<p>hth!</p>
|
<p>I think Ruby has a good example in <a href="https://ruby-doc.org/stdlib-2.5.1/libdoc/bigdecimal/rdoc/BigDecimal.html" rel="nofollow noreferrer">its documentation</a>:</p>
<pre class="lang-rb prettyprint-override"><code>sum = 0
10_000.times do
sum = sum + 0.0001
end
print sum #=> 0.9999999999999062
</code></pre>
| 31,016
|
<p>I am adding a webpart to the webpart gallery as part of a feature within a solution.</p>
<p>When the webpart is added to the gallery, the webparts Description field is being overwritten by an empty string. </p>
<p>I have added a description to everywhere I can think of, including:</p>
<ol>
<li>The webpart itself. myWebpart.webpart <code><property name="Description" type="string">my description</property></code></li>
<li>The feature.xml <code>Description="mywebpart description"</code></li>
<li>The feature.xml <code><Property Key="Description" Value="mywebpart description"></Property></code></li>
<li>The webpartManifest.xml (specified in the feature) <code><File ...><Property Name=Description" Value="mywebpart description"></code></li>
</ol>
<p>I have run out of ideas of where to put the description so it will appear in the Description field of the web part gallery when the solution is deployed.</p>
<p>Do you have any ideas?</p>
|
<p>Check the following blog, it describes the whole process:
<a href="http://www.sharepointblogs.com/nicksevens/archive/2007/11/23/adding-custom-webparts-in-a-sharepoint-site-definition.aspx" rel="nofollow noreferrer">Adding custom webparts in a Sharepoint Site Definition</a></p>
<p>Specially notice the custom property <em>TextToDisplay</em> (I think you've gone through all the other steps).</p>
|
<p>Actually, all the steps were correct, except that the property name for the webpart was mis-spelt as "<strong>Decription</strong>".</p>
<p>Doh</p>
| 15,830
|
<p>I am using the jQuery Cookie plugin (<a href="http://plugins.jquery.com/project/cookie" rel="noreferrer">download</a> and <a href="http://stilbuero.de/jquery/cookie/" rel="noreferrer">demo</a> and <a href="http://plugins.jquery.com/files/jquery.cookie.js.txt" rel="noreferrer">source code with comments</a>) to set and read a cookie. I'm developing the page on my <strong>local machine</strong>.</p>
<p>The following code will successfully set a cookie in FireFox 3, IE 7, and Safari (PC). But <strong>if the browser is Google Chrome AND the page is a local file</strong>, it does not work.</p>
<pre><code>$.cookie("nameofcookie", cookievalue, {path: "/", expires: 30});
</code></pre>
<p><strong>What I know</strong>:</p>
<ul>
<li>The plugin's <a href="http://stilbuero.de/jquery/cookie/" rel="noreferrer">demo</a> works with Chrome.</li>
<li>If I put my code on a web server (address starting with http://), it works with Chrome.</li>
</ul>
<p>So the cookie fails only <strong>for Google Chrome on local files</strong>.</p>
<p><strong>Possible causes</strong>:</p>
<ul>
<li>Google Chrome doesn't accept cookies from web pages on the hard drive (paths like file:///C:/websites/foo.html)</li>
<li>Something in the plugin implentation causes Chrome to reject such cookies</li>
</ul>
<p>Can anyone confirm this and identify the root cause?</p>
|
<p>Chrome doesn't support cookies for local files (or, like Peter Lyons mentioned, localhost*) unless you start it with the --enable-file-cookies flag. You can read a discussion about it at <a href="http://code.google.com/p/chromium/issues/detail?id=535" rel="noreferrer">http://code.google.com/p/chromium/issues/detail?id=535</a>.</p>
<p>*Chrome <em>does</em> support cookies if you use the local IP address (127.0.0.1) directly. so in the localhost case, that could be an easier workaround.</p>
|
<p>If you use chrominum this is the command to enable local cookies</p>
<blockquote>
<p>chromium-browser --enable-file-cookies</p>
</blockquote>
<p>It's the same thing for chrome</p>
<p>Hope this help you !</p>
| 43,474
|
<p>I wish to migrate a website to windows 2008 platform, is there any obvious pitfalls i should be aware of?</p>
<p>code base is c# 3.5,asp.net with ms ajax.</p>
|
<p>I googled a bit and found this link:</p>
<p><a href="http://weblogs.asp.net/steveschofield/archive/2008/09/04/iis6-to-iis7-migration-tips-tricks.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/steveschofield/archive/2008/09/04/iis6-to-iis7-migration-tips-tricks.aspx</a></p>
<p>Biggest Issue i find is that 3rd party components needs to have 64bit version ready to get most of benefits.</p>
|
<p>Don't let the wacked user interface put you off (but it will drive you dilly)</p>
| 12,857
|
<p>I'm working on building an app to scan directly from TWAIN scanner to a Java applet. I'm already aware of <a href="http://www.gnome.sk/Twain/jtp.html" rel="noreferrer">Morena</a> and <a href="http://asprise.com/product/jtwain/" rel="noreferrer">JTwain</a>, but they cost money. I need free. I could re-invent the wheel with JNI, but it seems like someone has probably already done this as a FOSS tool.</p>
<p>Is anyone familiar with a <strong>free</strong> tool that can get a Java applet to read directly from a TWAIN scanner?</p>
|
<p>Calling the TWAIN API from anything except C/C++ is going to be a major pain, it relies entirely on complicated C structures that you have to replicate exactly in memory. If you need only fairly basic scanning, you could use something like <a href="https://github.com/twall/jna/" rel="nofollow noreferrer">GitHub site</a> to call my old free 'EZTwain Classic' DLL (google for eztw32.dll)</p>
|
<p>I've actually purchased the chestysoft activeX control. Been using it for about 3 years. Works great but as with all ActiveX you are restricted to IE. And this one is 32-bit only.
I'm looking into a flash approach now. Since flash can capture from a camera why not from a scanner. If I remember I'll report back what I find.</p>
| 3,249
|
<p>I'm developing a solution which uses an ActiveX control (a commercial one which we bought and that I did not develop). I need to develop the proper installation pages to simulate what happens when a user who has never visited the site and does not have the add-on installed comes to the page.</p>
<p>I've found the "Manage Add-Ons" bit in Internet Options and I'm not having any luck.</p>
<p>In IE7, I see an ability to enable or disable any control and a "Delete ActiveX" option, but it's disabled for this particular control.</p>
<p>In IE8 Beta 2, the "Manage Add-Ons" bit has been completely reworked and I no longer see an option to delete the control. Each control has a "Properties" dialog and I can "Remove" it, but the button doesn't appear to do anything (could be related to how "Delete ActiveX" doesn't work for this on in IE7).</p>
<p>It looks like maybe this control is installed in such a way that merely deleting it from IE won't work or isn't allowed, but it's not a control with its own entry on the Add/Remove Programs menu in XP, so I can't uninstall it that way either.</p>
<p>How can I delete/remove (not disable) this ActiveX control in IE so that I can simulate what happens when people come to the site and the ActiveX control hasn't been installed yet? I figure there must be a way to "purge" IE of it.</p>
|
<p>You could unregister the control with</p>
<pre><code>regsvr32 /u badboy.ocx
</code></pre>
<p>at the command line. Though i would suggest testing these things in a vmware.</p>
|
<p>Tools > Manage Add-ons, right click "Name" header and enable the "In Folder" section. go to the directory for the plugin you're interested in. Right click the plugin file, and click "remove".</p>
| 21,790
|
<p>I am thinking on deploying multiple (and different) web applications on the same server using the following schema:</p>
<p>www.mydomain.com/app1</p>
<p>www.mydomain.com/app2</p>
<p>Is this a good practice? Any recommendations?</p>
|
<p>I don't see any glaring reasons why you should <em>not</em> do it this way. After all, not every website is dedicated to just a single task or application. Another approach would be to use subdomains, like:</p>
<p>app1.mydomain.com<br>
app2.mydomain.com</p>
<p>Yahoo and Google both use these, for example. The folder approach is a good way to get things up and running for testing though.</p>
|
<p>If the applications are all related to the domain, I see no problem with doing things this way.</p>
| 27,174
|
<p>Will everything go to the cloud? If so, in which direction? Google-Gears? Flash,AIR,JavaFX?</p>
<hr />
<h3>See also: <a href="https://stackoverflow.com/questions/655365/does-desktop-development-matter">Does desktop development matter?</a></h3>
|
<p>I've been asking this question for nearly a decade. In my business we build and sell both Windows and Web apps that do roughly the same thing. Four years ago I would have told you that we'd be 80-20 in favor of web apps by now. However, in terms of the numbers shipped, we are still about 60-40 in favor of the Windows apps. </p>
<p>While I once thought that the real barrier to the acceptance of software as a service was simply a desire for a better, richer user interface (which Silverlight, Air, etc. would solve), I'm now inclined to think that there are a lot of people who simply prefer a one-time purchase and local control over a web connected subscription model. Because this preference is rooted in personal perceptions of value for the money, I don't think that technology will change anything as quickly as we technologists think it will. Thus, I'd wager that Windows apps are with us for longer than we developers will ever expect; another 10 years at least.</p>
|
<p>Google has introduced <a href="http://googleblog.blogspot.com/2009/07/introducing-google-chrome-os.html" rel="nofollow noreferrer">Google Chrome OS</a> as a bet that the desktop applications will no longer be essential.</p>
| 47,192
|
<p>I'm just in the process of parsing some text and can't remember what the escape character is for a tab in C#?</p>
|
<p>Easy one! "\t"</p>
<p>Edit: In fact, here's something official: <a href="http://msdn.microsoft.com/en-us/library/h21280bw.aspx" rel="noreferrer">Escape Sequences</a></p>
|
<p>For someone who needs quick reference of <strong>C# Escape Sequences</strong> that can be used in <code>string</code> literals:</p>
<blockquote>
<p>\t Horizontal tab (ASCII code value: 9)</p>
<p>\n Line feed (ASCII code value: 10)</p>
<p>\r Carriage return (ASCII code value: 13)</p>
<p>\' Single quotation mark</p>
<p>\" Double quotation mark</p>
<p>\\ Backslash</p>
<p>\? Literal question mark</p>
<p>\x12 ASCII character in hexadecimal notation (e.g. for 0x12)</p>
<p>\x1234 Unicode character in hexadecimal notation (e.g. for 0x1234)</p>
</blockquote>
<p>It's worth mentioning that these (in most cases) are universal codes. So \t is 9 and \n is 10 char value on Windows and Linux. But newline sequence is not universal. On Windows it's \n\r and on Linux it's just \n. That's why it's best to use <code>Environment.Newline</code> which gets adjusted to current OS settings. With .Net Core it gets really important.</p>
| 2,762
|
<p>I'm trying to skin HTML output which I don't have control over. One of the elements is a <code>div</code> with a <code>style="overflow: auto"</code> attribute.<br>
Is there a way in CSS to force that <code>div</code> to use <code>overflow: hidden;</code>?</p>
|
<p>You can add <code>!important</code> to the end of your style, like this:</p>
<pre class="lang-css prettyprint-override"><code>element {
overflow: hidden !important;
}
</code></pre>
<p>This is something you should not rely on normally, but in your case that's the best option. Changing the value in Javascript strays from the best practice of separating markup, presentation, and behavior (html/css/javascript).</p>
|
<p>As far as I know, styles on the actual HTML elements override anything you can do in separate CSS style.</p>
<p>You can, however, use Javascript to override it.</p>
| 13,007
|
<p>I'm attempting to fulfill a rather difficult reporting request from a client, and I need to find away to get the difference between two DateTime columns in minutes. I've attempted to use trunc and round with various <a href="http://www.ss64.com/orasyntax/fmt.html" rel="noreferrer">formats</a> and can't seem to come up with a combination that makes sense. Is there an elegant way to do this? If not, is there <b>any</b> way to do this?</p>
|
<pre><code>SELECT date1 - date2
FROM some_table
</code></pre>
<p>returns a difference in days. Multiply by 24 to get a difference in hours and 24*60 to get minutes. So</p>
<pre><code>SELECT (date1 - date2) * 24 * 60 difference_in_minutes
FROM some_table
</code></pre>
<p>should be what you're looking for</p>
|
<p>Use <code>timestampdiff</code> at <code>where</code> clause.</p>
<p>Example:</p>
<pre class="lang-sql prettyprint-override"><code>Select * from tavle1,table2 where timestampdiff(mi,col1,col2).
</code></pre>
| 25,266
|
<p>Whats the available solutions for PHP to create word document in linux environment?</p>
|
<h3>real Word documents</h3>
<p>If you need to produce "real" Word documents you need a Windows-based web server and COM automation. I highly recommend <a href="http://www.joelonsoftware.com/items/2008/02/19.html" rel="noreferrer">Joel's article</a> on this subject.</p>
<h3><em>fake</em> HTTP headers for tricking Word into opening raw HTML</h3>
<p>A rather common (but unreliable) alternative is:</p>
<pre><code>header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment; filename=document_name.doc");
echo "<html>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=Windows-1252\">";
echo "<body>";
echo "<b>Fake word document</b>";
echo "</body>";
echo "</html>"
</code></pre>
<p>Make sure you don't use external stylesheets. Everything should be in the same file.</p>
<p>Note that this does <strong>not</strong> send an actual Word document. It merely tricks browsers into offering it as download and defaulting to a <code>.doc</code> file extension. Older versions of Word may often open this without any warning/security message, and just import the raw HTML into Word. PHP sending sending that misleading <code>Content-Type</code> header along does not constitute a real file format conversion.</p>
|
<p>There are 2 options to create quality word documents. Use COM to communicate with word (this requires a windows php server at least). Use openoffice and it's API to create and save documents in word format.</p>
| 15,192
|
<p>Does any one know of a free tool or library to convert multi page tiffs to pdf in Asp.Net 1.1?</p>
|
<p>how about <a href="http://pdfsharp.com/PDFsharp/" rel="nofollow noreferrer">PDFSharp</a>, or <a href="http://itextsharp.sourceforge.net/" rel="nofollow noreferrer">iTextSharp</a>? I usually search sf.net first when looking for a free library.</p>
|
<p>Persist software's ASPPDFlib.dll might be of your help. <a href="http://www.asppdf.com/download.html" rel="nofollow noreferrer">http://www.asppdf.com/download.html</a></p>
| 43,647
|
<p>I want to setup a statistics monitoring platform to watch a specific service, but I'm not quiet sure how to go about it. Processing the intercepted data isn't my concern, just how to go about it. One idea was to setup a proxy between the client application and the service so that all TCP traffic went first to my proxy, the proxy would then delegate the intercepted messages to an awaiting thread/fork to pass the message on and recieve the results. The other was to try and sniff the traffic between client & service.</p>
<p>My primary goal is to avoid any serious loss in transmission speed between client & application but get 100% complete communications between client & service.</p>
<p>Environment: UBuntu 8.04</p>
<p>Language: c/c++</p>
<p>In the background I was thinking of using a sqlite DB running completely in memory or a 20-25MB memcache dameon slaved to my process.</p>
<p>Update:
Specifically I am trying to track the usage of keys for a memcache daemon, storing the # of sets/gets success/fails on the key. The idea is that most keys have some sort of separating character [`|_-#] to create a sort of namespace. The idea is to step in between the daemon and the client, split the keys apart by a configured separator and record statistics on them. </p>
|
<p>Exactly what are you trying to track? If you want a simple count of packets or bytes, or basic header information, then <code>iptables</code> will record that for you:</p>
<pre><code>iptables -I INPUT -p tcp -d $HOST_IP --dport $HOST_PORT -j LOG $LOG_OPTIONS
</code></pre>
<p>If you need more detailed information, look into the <code>iptables ULOG</code> target, which sends each packet to userspace for analysis.</p>
<p>See <a href="http://www.netfilter.org" rel="nofollow noreferrer">http://www.netfilter.org</a> for <em>very</em> thorough docs.</p>
|
<p>iptables provides <strong>libipq</strong>, a userspace packet queuing library. From the manpage:</p>
<blockquote>
<p>Netfilter provides a mechanism for
passing packets out of the stack for
queueing to userspace, then receiving
these packets back into the kernel
with a verdict specifying what to do
with the packets (such as ACCEPT or
DROP). These packets may also be
modified in userspace prior to
reinjection back into the kernel.</p>
</blockquote>
<p>By setting up tailored <strong>iptables</strong> rules that forward packets to libipq, in addition to specifying the verdict for them, it's possible to do packet inspection for statistics analysis.</p>
<p>Another viable option is manually sniff packets by means of libpcap or PF_PACKET socket with the socket-filter support.</p>
| 34,564
|
<p>I am looking for a good JavaScript library for parsing XML data. It should be much easier to use than the built-in <a href="http://www.w3schools.com/Xml/xml_parser.asp" rel="nofollow noreferrer">XML DOM parsers</a> bundled with the browsers.</p>
<p>I got spoiled a bit working with JSON and am looking forward to something on similar lines for XML.</p>
|
<p><strong>Disclaimer:</strong> I am the author if the open-source <a href="https://github.com/highsource/jsonix" rel="nofollow noreferrer">Jsonix</a> library which <em>may</em> be suitable for the task.</p>
<hr>
<p>A couple of years ago I was also looking for a good XML<->JSON parsing/serialization library for JavaScript. I needed to process XML documents conforming to rather complex XML Schemas. In Java, I routinely use <a href="https://jaxb.java.net/" rel="nofollow noreferrer">JAXB</a> for the task so I was looking for something similar:</p>
<blockquote>
<p><a href="https://stackoverflow.com/questions/3819192/is-there-a-javascript-api-for-xml-binding-analog-to-jaxb-for-java">Is there a JavaScript API for XML binding - analog to JAXB for Java?</a></p>
</blockquote>
<p>I failed to find such a tool back then.</p>
<p>So I wrote <a href="https://github.com/highsource/jsonix" rel="nofollow noreferrer"><strong>Jsonix</strong></a> which I consider to be a JAXB analog for JavaScript.</p>
<p>You may find <a href="https://github.com/highsource/jsonix" rel="nofollow noreferrer">Jsonix</a> suitable, if you're interested in the following features:</p>
<ul>
<li>XML<->JSON conversion is based on a <strong>declaraive mapping</strong> between XML and JSON structures</li>
<li>This <strong>mapping</strong> can be <strong>generated from an XML Schema</strong> or written manually</li>
<li><strong>Bidirectional</strong> - supports parsing as well as serialization (or unmarshalling/marshalling in other terms).</li>
<li>Support <strong>elements</strong>, <strong>attributes</strong> and also considers <strong>namespaces</strong> defined in the XML document.</li>
<li>Strictly typed.</li>
<li>Strictly structured.</li>
<li>Support almost all of the <strong>XML Schema built-in types</strong> (including special types like <code>QName</code>).</li>
<li>Works in <strong>browsers</strong> as well as <strong>Node.js</strong>, also compatible to <a href="http://requirejs.org/" rel="nofollow noreferrer"><strong>RequireJS</strong></a>/<a href="https://github.com/amdjs/amdjs-api/wiki/AMD" rel="nofollow noreferrer"><strong>AMD</strong></a> (also to <a href="https://github.com/jrburke/amdefine" rel="nofollow noreferrer"><code>amdefine</code></a> in Node.js)</li>
<li>Has <a href="http://confluence.highsource.org/display/JSNX/User+Guide" rel="nofollow noreferrer">extensive documentation</a>.</li>
</ul>
<p>However, Jsonix <em>may be an overkill</em>, if your XML is rather simple, does not have an XML Schema or if you're not interested in strict typing or structures. Check your requirements.</p>
<p><strong>Example</strong></p>
<p>Try it <a href="http://jsfiddle.net/lexi/LP3DC/" rel="nofollow noreferrer">in JSFiddle</a>.</p>
<p>You can take a <a href="http://www.w3.org/TR/xmlschema-0/#po.xsd" rel="nofollow noreferrer">purchase order schema</a> and generate a mapping for it using the following command:</p>
<pre><code>java -jar node_modules/jsonix/lib/jsonix-schema-compiler-full.jar
-d mappings -p PO purchaseorder.xsd
</code></pre>
<p>You'll get a <code>PO.js</code> file which describes mappings between XML and JavaScript structures. Here's a snippet from this mapping file to give you an impression:</p>
<pre class="lang-javascript prettyprint-override"><code>var PO = {
name: 'PO',
typeInfos: [{
localName: 'PurchaseOrderType',
propertyInfos: [{
name: 'shipTo',
typeInfo: 'PO.USAddress'
}, {
name: 'billTo',
typeInfo: 'PO.USAddress'
}, {
name: 'comment'
}, {
name: 'orderDate',
typeInfo: 'Calendar',
type: 'attribute'
}, ...]
}, {
localName: 'USAddress',
propertyInfos: [ ... ]
}, ...],
elementInfos: [{
elementName: 'purchaseOrder',
typeInfo: 'PO.PurchaseOrderType'
}, ... ]
};
</code></pre>
<p>Having this mapping file you can parse the <a href="https://github.com/highsource/jsonix/blob/master/fiddles/po/demo.response.xml" rel="nofollow noreferrer">XML</a>:</p>
<pre class="lang-javascript prettyprint-override"><code>// First we construct a Jsonix context - a factory for unmarshaller (parser)
// and marshaller (serializer)
var context = new Jsonix.Context([PO]);
// Then we create a unmarshaller
var unmarshaller = context.createUnmarshaller();
// Unmarshal an object from the XML retrieved from the URL
unmarshaller.unmarshalURL('po.xml',
// This callback function will be provided
// with the result of the unmarshalling
function (unmarshalled) {
// Alice Smith
console.log(unmarshalled.value.shipTo.name);
// Baby Monitor
console.log(unmarshalled.value.items.item[1].productName);
});
</code></pre>
<p>Or serialize your JavaScript object as XML:</p>
<pre class="lang-javascript prettyprint-override"><code>// Create a marshaller
var marshaller = context.createMarshaller();
// Marshal a JavaScript Object as XML (DOM Document)
var doc = marshaller.marshalDocument({
name: {
localPart: "purchaseOrder"
},
value: {
orderDate: { year: 1999, month: 10, day: 20 },
shipTo: {
country: "US",
name: "Alice Smith",
street: "123 Maple Street",
city: "Mill Valley",
state: "CA",
zip: 90952
},
billTo: { /* ... */ },
comment: 'Hurry, my lawn is going wild!',
items: { /* ... */ }
}
});
</code></pre>
<p>You can try it <a href="http://jsfiddle.net/lexi/LP3DC/" rel="nofollow noreferrer">in JSFiddle</a> to see how it works in practice.</p>
<hr>
<p><strong>Additional disclaimer:</strong> this answer is high-voted because of the <a href="https://meta.stackoverflow.com/questions/276942/correcting-my-own-spam-answer-is-it-fine-now">following discussion</a> on meta. <em>So please be aware of the "meta-effect".</em> High votes here do not necessarily mean that Jsonix is good, applicable or recommended by the community. Do not be mislead by the high votes.</p>
|
<p>Have you tried <a href="http://xmljs.sourceforge.net/" rel="nofollow noreferrer">XML for SCRIPT</a>. I have to admit, that I have never used it personally, but I have heard/read a few good things about it.</p>
<p>Give it a try and maybe share your experience here?</p>
| 10,906
|
<p>I have a set of multiple assemblies (one assembly is to be used as an API and it depends on other assemblies). I would like to merge all assemblies into one single assembly but prevent all assemblies except the API one to be visible from the outside.</p>
<p>I will then obfuscate this assembly with Xenocode. From what I have seen, it is impossible to internalize assembly with Xenocode.</p>
<p>I have seen ILMerge from Microsoft, but was unable to figure if it can do what I want.
<a href="http://research.microsoft.com/~mbarnett/ILMerge.aspx" rel="nofollow noreferrer">http://research.microsoft.com/~mbarnett/ILMerge.aspx</a></p>
|
<p>I know Xenocode can merge assemblies into one but I am not sure if it will internalize other non-primary assemblies.</p>
<p>I have found the /internalize switch in ILMerge that "internalize" all assemblies except the primary one. Pretty useful!</p>
|
<p>I suggest you look at the <code>InternalsVisibleTo</code> attribute on <a href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx" rel="nofollow noreferrer" title="MSDN">MSDN</a>.</p>
<p>You can mark everything in all the assemblies (except the API assembly) as <code>internal</code> instead of <code>public</code>, then reshow them to just your API assembly.</p>
<p>Having done that, using ILMerge should give you a single assembly with just the API classes visible.</p>
| 4,627
|
<p>I am trying to download an xml.gz file from a remote server with HttpsURLConnection in java, but I am getting an empty response. Here is a sample of my code:</p>
<pre><code>URL server = new URL("https://www.myurl.com/path/sample_file.xml.gz");
HttpsURLConnection connection = (HttpsURLConnection)server.openConnection();
connection.connect();
</code></pre>
<p>When I try to get an InputStream from the connection, it is empty. (If I try connection.getInputStream().read() I get -1) The file I am expecting is approximately 50MB. </p>
<p>To test my sanity, I aslo tried entering the exact same url in my browser, and it did return the file I needed. Am I missing something? Do I have to set some sort of parameter in the connection? Any help/direction is much appreciated. </p>
|
<p>Is any exception being logged? Is the website presenting a self-signed SSL certificate, or one that is not signed by a CA? There are several reasons why it might work fine in your browser (the browser might have been told to accept self-signed certs from that domain) and not in your code.</p>
<p>What are the results of using <a href="http://curl.haxx.se/" rel="nofollow noreferrer">curl</a> or <a href="http://www.gnu.org/software/wget/" rel="nofollow noreferrer">wget</a> to fetch the URL?</p>
<p>The fact that the InputStream is empty / result from the InputStream.read() == -1 implies that there is nothing in the stream to read, meaning that the stream was not able to even be set up properly.</p>
<p><strong>Update</strong>: <a href="http://www.howardism.org/Technical/Java/SelfSignedCerts.html" rel="nofollow noreferrer">See this page</a> for some info on how you can deal with invalid/self-signed certificates in your connection code. Or, if the site is presenting a certificate but it is invalid, you can import it into the keystore of the server to tell Java to trust the certificate. <a href="http://www.chrissearle.org/blog/technical/adding_self_signed_https_certificates_java_keystore" rel="nofollow noreferrer">See this page for more info</a>.</p>
|
<p>Turns out the download wasn't working because the remote server was redirecting me to a new url to download the file. Even though connection.setFollowRedirects(true) was set, I still had to manually set up a new connection for the redirected URL as follows:</p>
<pre><code>if (connection.getResponseCode() == 302 && connection.getHeaderField("location") != null){
URL server2 = new URL(connection.getHeaderField("location"));
HttpURLConnection connection2 = (HttpURLConnection)server2.openConnection();
connection2.connect();
InputStream in = connection2.getInputStream();
}
</code></pre>
<p>After that, I was able to retrieve the file from the input stream. Thanks for all your help guys!</p>
| 29,791
|
<p>I've been using Visio 2002/2003 Enterprise Architect to do my database schema design visually and then forward-generate the DDL to create the database.</p>
<p>I wanted to switch to Visio 2007, but while it does have database diagramming support, it <em>doesn't</em> have the ability to generate DDL. Bummer.</p>
<p>I am really disappointed because it seems like Microsoft has completely abandoned this feature. You can't do it in Visual Studio (that I've found). You can sorta do it with SQL Server Management Studio if you insert database diagrams into your database, but any edits to the schema immediately take effect.</p>
<p>Has anyone found a good program to do this? I'm hoping to find one that is free and can generate DDL/SQL for SQL Server.</p>
|
<p>Unfortunately, I have recently faced the same problem, hoping that MS would provide a new version of Visio Enterprise Architect since I have used it FOREVER to do ERDs/database design. Since this does not seem to be forthcoming from them however, I have been forced to research other tools. The ones I checked out included the following:</p>
<ul>
<li>Embarcadero ER/Studio</li>
<li>Visual Paradigm DB Visual Architect</li>
<li>Altova DatabaseSpy</li>
<li>Dezign for Databases</li>
<li>Sybase PowerDesigner</li>
</ul>
<p>Also, I tried to check out DevGEMS Data Modeler but kept getting "the setup files are corrupted" after downloading it. I never considered ERWin as the interface seems too old school/legacy plus it is too expensive. Just when I had almost given up all hope of finding a well-rounded but [relatively] cheap alternative I came across <strong><a href="http://www.modelright.com" rel="noreferrer">ModelRight</a></strong>. I find it curious that I haven't heard more about this company given that their product is EXCELLENT and inexpensive (under $1000 for multi-DB support or under $500 for a single DB type) compared to other high-end DB modeling tools. Further, the company was founded by one of the first developers to work on ERwin (see their company's "About" page for more info).</p>
<p>To make a long story short, if you want to save yourself a day's worth of research on this subject, check out ModelRight FIRST and go from there. BTW, for full disclosure - I have no affiliation with the ModelRight company! ;^)</p>
<p>P.S. - From what I can tell currently, VS 2010 isn't going to offer a full DB modeling environment but only enough to support the Entity Framework which I am not currently sold on (especially having spent the time to roll my own ORM layer).</p>
|
<p>Visual Studio 2010 Beta 1 has some pretty cool tools for data modeling, especially the <a href="http://msdn.microsoft.com/en-us/library/bb399249(VS.100).aspx" rel="nofollow noreferrer">ADO .Net Entity Data Model Tools</a>. And yes, you can generate DDL from the models.</p>
| 34,355
|
<p>My C# project - we'll call it the SuperUI - used to make use of a class from an external assembly. Now it doesn't, but the compiler won't let me build the project without the assembly reference in place. Let me elaborate.</p>
<p>This project used to throw and catch a custom exception class - the <code>SuperException</code> - which was derived from the standard System.Exception and lived in a separate, precompiled assembly, <code>SuperAssembly.DLL</code>, which I referenced.</p>
<p>Eventually, I decided this was a pointless exercise and replaced all <code>SuperExceptions</code> with a System.SuitableStandardException in each case. I removed the reference to <code>SuperException.DLL</code>, but am now met with the following on trying to compile the project:</p>
<blockquote>
<p>The type 'SuperException' is defined in an assembly that is not referenced. You must add a reference to assembly 'SuperException, Version=1.1.0.0 (...)'</p>
</blockquote>
<p>The source file referenced by the error doesn't seem relevant; it's the project namespace that gets highlighted in the IDE.</p>
<p>Now, here's the thing:</p>
<ol>
<li>All uses of <code>SuperException</code> have been eliminated from the project's code.</li>
<li>Compared to another project that compiles fine without a reference to <code>SuperException.DLL</code>, I only reference one more assembly - and <code>that</code> references nothing that my project doesn't reference itself. While it's possible that any of these dependencies could throw <code>SuperExceptions</code>, I'm only catching the base Exception class and in any case... the other project builds fine!</li>
<li>I've done Visual Studio's "Clean Solution" and cleared everything out by hand, many times.</li>
</ol>
<p>It's not the end of the world to include this reference, I just don't see why it's necessary any more. Nrrrgg. Any pointers welcome!</p>
|
<p>It's likely a transitive reference, where some type method call returns an instance of SuperException boxed ("downcast") as e.g. Exception, but from inspecting the code in the transitively included code, i.e. code from your external method calls, the compiler knows that you need to be able to have information about that type at some point. </p>
<p>Resharper would tell you where it's the case that you need to add a reference, and you could use Lütz Roeder's aka RedGate's Reflector to scan compiled IL for a reference to this type in two ways: 1) use the search-facility, 2) open each public type you're using and for that one which requires the "ghost" assembly, it will ask you to specify its location.</p>
<p>This most often happends to me when I reference Castle.Windsor but not Castle.MicroKernel. :p</p>
|
<p><code>grep -R SuperException *</code> in the base of your project (get <code>grep</code> from somewhere first) just to be sure.</p>
| 3,060
|
<p>I'm interested in designing & 3D printing as a hobby (e.g. printing chess sets, small toys for family etc.)</p>
<p>Conducting a Google search has brought up a range of small, cheap printers, but beyond that I don't know how to differentiate them.</p>
<p>E.g. selling points include:</p>
<ul>
<li>"liquid light-sensitive resin"</li>
<li>"partially assembled" with "very few parts and minor configuration"</li>
<li>"Wi-Fi enabled"</li>
</ul>
<p>My question is, <strong>which features are going to benefit a small-scale, new enthusiast to 3D printing?</strong></p>
<p>PS. The software I intend to use is Windows 10 3D design</p>
<p>PPS. I'm not a graphic designer by any means, just a new enthusiast.</p>
|
<p>Here are few things to consider from my point of view</p>
<hr>
<p><strong>Printing technology</strong></p>
<p>The first thing that you need to take into account is printing technology. The most common[citation needed] right now is Fused Filament Fabrication. "Liquid light-sensitive resin" is being used in Stereolitography and Digital Light Processing - the SLA printers I found are less common and more expensive than FFF ones.</p>
<hr>
<p><strong>Price</strong></p>
<p>Need to decide on budget. You can buy printer for 60k USD and 400 USD. Quality is somehow linked to price but that's not a rule. You can buy a shitty printer for a lot of money.</p>
<hr>
<p><strong>Printing area</strong></p>
<p>Bigger allows you to print bigger things. You need to ask yourself how big things you really want to print. Remember that 3d printing is quite slow process - how often you will want to print big things that will take 60hrs+ to finish?</p>
<hr>
<p><strong>Printing materials</strong></p>
<p>What kind of materials you want to print with? Some materials will need higher temperatures so check the max hot-end temperature, some will require heated bed.</p>
<hr>
<p><strong>Assembled or DIY kit</strong></p>
<p>You can usually get kits for self-assembly cheaper than Ready-To-Print machines. However, it will require additional skills (i.e. soldering), tools and time to assemble. I am not sure if I would buy DIY kit for commercial use, but as an enthusiast I immensely enjoyed putting my Rostock Max together.</p>
<hr>
<p><strong>Reviews and reputation</strong></p>
<p>It is generally safe to buy printer that already has some users. Beware of new magical Kickstarter printers which will "change the 3d printing forever".
Reddit /r/3dprinting suggests that your new printer should meet 3 criteria:</p>
<ul>
<li>Printer passes the youtube test - has lots of youtube evidence that this particular printer is working.</li>
<li>Printer is out of the pre-order phase. This means that all pre-orders have been delivered.</li>
<li>Printer has a reputation of working well among current users.</li>
</ul>
<p>I found it to be a very good set of rules.</p>
<hr>
<p><strong>Upgrade capabilities</strong></p>
<p>That's very user-dependent, but this point is very important to me. I want to be able to change and improve certain parts of my printer. Check if you can switch the extruder, replace the hot-end etc. </p>
<hr>
<p><strong>Support</strong></p>
<p>I think one of the most important points. See if you can find a forum for your printer and how active community is. It will be immensely helpful if something goes wrong (and it will).
Also, company support is very important. What will happen if you need a replacement part or your printer will stop working altogether?</p>
<hr>
<p>This list is definitely not complete.
There are many more things that might be taken into account like configuration (delta or XY), multiple extruders, closed cases etc.</p>
|
<p>One of the biggest questions you should ask yourself is: What is your end goal? </p>
<ol>
<li><p>Is it to get your printer and immediately print something (pre-assembled). </p></li>
<li><p>Is it to learn about 3d printing by constructing a kit, encountering all kinds of potential issues getting it working, then once it is working getting everything all dialed in and then getting good prints. </p></li>
</ol>
<p>The 2nd option requires less initial investment but may take considerable time and frustration. (I did this 6 months ago)</p>
| 122
|
<p>In the past, some of my projects have required me to create a movie version of a fullscreen Flash application. The easiest way to do this has been to get a screen capture. However, capturing anything over 1024x768 has resulted in choppy video, which is unacceptable. I understand that there are hardware based solutions for capturing fullscreen video, but I have not been able to find out what these are. My output needs to be scalable up to 1920x1080 and result in an uncompressed AVI file with no choppy-ness.</p>
|
<p>Various professional products support full HD capture:</p>
<p><a href="http://www.decklink.com/products/hd/" rel="nofollow noreferrer">http://www.decklink.com/products/hd/</a></p>
<p><a href="http://www.aja.com/" rel="nofollow noreferrer">http://www.aja.com/</a></p>
<p>There are others. Capturing the full, uncompressed digital or analog stream is a pretty heavy requirement.</p>
<p>-Adam</p>
|
<p>With a bit of luck your graphic adapter already has a analog video output. You could hook up a dvd recorder and just digitze the video signal on a stand alone hardware box.</p>
<p>That won't give you 1920x1080 though.</p>
<p>If you really need to get captures higher than dvd resolution you need professional (and <em>incredible</em> expensive) video capture equipment.</p>
<h1>edit:</h1>
<p>Btw - if you want to capture 1920x1080 in true color at 30 frames per second uncompressed you have to somehow store around <strong>237 megabytes per second</strong>. Just to give you an idea how much data you have to deal with...</p>
| 13,522
|
<p>I have been trying to make some small signs, and to highlight the text by changing between black and white filament at a layer just above where the text comes out of the back plate.</p>
<p>I've used Cura 4.12 and the "change filament" script to make the printer pause at the right layer. The change and purge process works fine, no issue there.</p>
<p>However the second colour adheres poorly to the first. Doesn't matter if I print Black then White, or White then Black. Both filaments are the same brand.</p>
<ul>
<li>Should I dab gluestick into the print at the same time as changing colour? (read on)</li>
<li>Is there some way to re-preheat the object and get a better adhesion?</li>
</ul>
<p>To save the print I've used superglue to stick the letters back on that have fallen off, but is definitely not ideal.</p>
<hr />
<p>Here's an example:</p>
<p><a href="https://i.stack.imgur.com/RgUOS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RgUOS.jpg" alt="enter image description here" /></a></p>
<p>The loose letters are held on well enough for printing, but only barely. They can knock loose at a touch of a finger afterward.</p>
<p>I have tried changing filament on the first layer that is not the back board, and one or two layers up the letters. One print I even changed filament a layer too low, and surprisingly that did not have adhesion problems. Perhaps it is merely a function of surface contact area ?</p>
<p>Gluestick on the exposed surface while changing filament was useless - the whole thing simply didn't stick and the second colour never got any adhesion at all, merely wiping off.</p>
<p>As for timing, it seems to make little difference if I'm there waiting for the last layer to print, or if I let the printer sit for half an hour before noticing and changing colour. The bed stays hot at 50 degrees, and the hot end is permitted to cool off.</p>
<p>There is a heating cycle, and then a purge/discharge-into-air that shows the transition between colours, so its not that the filament has lost a prime.</p>
<p>At the moment, a much more effective solution is to use a paint marker and colour-in the top layer with a contrasting colour.</p>
|
<p>It might be worth a try to manually kick the flow rate setting up 5-10 % and temperature about 5 °C for the first layer after the filament change, then returning to the original settings. Consider too killing or reducing the cooling fan speed for the first layer only. The benefit of a skirt to get things flowing is not available when starting on the second color.</p>
<p>Another approach would be to make the letter-layer a negative image so it would be more of a flat, contiguous piece with letter shaped holes in it. Printing time and filament usage would both be somewhat higher, however, unless the thickness of the letter-layer was reduced. It would only need to be a few layers thick.</p>
<p>Color order could be changed with this method too if black letters on a white field is the desired scheme.</p>
|
<p>After much fiddling about, the only positive conclusion I could come up with was to not make the letters too thin. A chunky thick letter has more surface area to adhere, whereas a thin spidery letter is too fragile.</p>
<p>So print fewer words on each label, make the words more-bold, and if they still fall off after printing then CA glue/superglue is good enough to hold them together.</p>
| 2,067
|
<p>My little site should be pooling list of items from a table using the active user's location as a filter. Think <a href="http://craigslist.org" rel="nofollow noreferrer">Craigslist</a>, where you search for "dvd' but the results are not from all the DB, they are filtered by a location you select. My question has 2 levels:</p>
<ol>
<li>should I go a-la-craigslist, and ask users to use a city level location? My problem with this is that you need to generate what seems to me a hard coded, hand made list of locations. </li>
<li>should I go a-la-zipCode. The idea of just asking the user to type his zipcode, and then pool all items that are in the same or in a certain distance from his zip code.</li>
</ol>
<p>I seem to prefer the zip code way as it seems more elegant solution, but how on earth do one goes about creating a DB of all zip codes and implement the function that given zip code 12345, gets all zipcodes in 1 mile distance?</p>
<p>this should be fairly common "task" as many sites have a need similar to mine, so I am hoping not to re-invent the wheel here.</p>
|
<p>Getting a Zip Code database is no problem. You can try this free one:
<a href="http://zips.sourceforge.net/" rel="nofollow noreferrer">http://zips.sourceforge.net/</a></p>
<p>Although I don't know how current it is, or you can use one of many providers. We have an annual subscription to <a href="http://www.ZipCodeDownload.com" rel="nofollow noreferrer">ZipCodeDownload.com</a>, and for maybe $100 we get monthly updates with the latest Zip Code data complete with Lat/Longs of the centroid of the zip code. </p>
<p>As for querying for all zips within a certain radius, you are going to need a spatial library of some sort. If you just have a table of zips with lats/longs, you will need a database-oriented mechanism. SQL Server 2008 has the capability built in, and there are <a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=MsSqlSpatial" rel="nofollow noreferrer">open source libraries</a> and <a href="http://www.spatialdb.com/default.aspx?AspxAutoDetectCookieSupport=1" rel="nofollow noreferrer">commercial libraries</a> that will add such capabilities to SQL Server 2005. The open source database PostgreSQL has a project, PostGIS that adds this capability to that database. It is here: <a href="http://postgis.refractions.net/" rel="nofollow noreferrer">http://postgis.refractions.net/</a></p>
<p>Other database platforms probably have similar projects, but those are the ones I am aware of. With one of these DB based libraries you should be able to directly query for any zip codes (or any rows of any kind that have lat/long columns) within a given radius.</p>
<p>If you want to go a different route you can use spatial tools with a mapping library. There are open source options here as well, such as <a href="http://www.codeplex.com/SharpMap" rel="nofollow noreferrer">SharpMap</a> and <a href="http://opensourcegis.org/" rel="nofollow noreferrer">many others</a> (<a href="http://www.google.com/search?q=Open+Source+GIS+tools" rel="nofollow noreferrer">Google can help out</a>) that can use the free Tiger maps for the united states as the data source. However, this route is somewhat more complicated and possibly less performant if all you need is a radius search.</p>
<p>Finally, you may want to look into a web service. This, as you say, is a common need, and I imagine there are any number ob web services that you can subscribe to that can provide all zip codes in a given radius from a provided zip code. A quick Google search turned up this:
<a href="http://www.zip-codes.com/free-zip-code-tools.asp#radius" rel="nofollow noreferrer">http://www.zip-codes.com/free-zip-code-tools.asp#radius</a>
But there are <a href="http://www.google.com/search?q=all+zip+codes+in+radius" rel="nofollow noreferrer">MANY resources to be had for the searching</a> on this subject.</p>
|
<blockquote>
<p>how on earth do one [...] implement the function that given zip code 12345, gets all zipcodes in 1 mile distance?</p>
</blockquote>
<p>Here is a sample on how to do that:</p>
<p><a href="http://www.codeproject.com/KB/cs/zipcodeutil.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/cs/zipcodeutil.aspx</a></p>
| 3,389
|
<p>We have been trying Scrum but for a while now and are trying to formalize it within as our own version of Agile Application Development. Here's how our current process works. There are two main drawbacks to it as it stands right now. Wanted to get input on whether you have a similar approach and if the community has any practical tips for the impediments we currently have.</p>
<ul>
<li>Scrum team = 4 Developers, 2 QA, 1 Tech Writer, 1 PO(PM), 1 Scrum Master (Engg Dir) </li>
<li>Release = 3 Sprints</li>
<li>Sprint = 2 weeks</li>
</ul>
<p>PO and customers create product backlog of user stories and related acceptance criteria.<br>
1 week Sprint planning at the start of each iteration</p>
<ul>
<li>Day 1# Estimate the Sprint backlog and agree on priority</li>
<li>Day 2-5# Scrum team discuss stories and work on the details of each story in the Sprint backlog (get the details on the story, process flows if any, identify UE guidelines to apply, details for UI items/fields/widgets and their behavior if anything specific is required, understand acceptance criteria and create tests) </li>
<li>2 week Sprint with 15 min daily scrum</li>
<li>Repeat 3 week cycle</li>
</ul>
<p>The two major drawbacks we're having in this are: </p>
<ol>
<li>The details that are discussed in the spring planning week are not captured effectively and get noted on a wiki. Since there is no standard format for capturing such details in Scrum, often time is wasted in daily scrum or subsequent meetings are required to further understand story details. Whats the best way of capturing story details for a functionally fairly complex product in sprint planning? Most of the issues seem to be around UI and developers inability to decide how screens/fields should be laid out without detailed mocks. </li>
<li>How do you anticipate critical showstopper bugs that come back from customers when team is in a sprint cycle. Currently the Dev folks have to be pulled away into supporting these Red Account issues that crop up thus disrupting the sprint.</li>
</ol>
<p>Any inputs on how we can improve this? </p>
|
<ol>
<li>There is no "standard" Agile plan. Plans aren't important.. planning is. What i mean by that is adapt your plan regularly to reflect ground realities. Formulating a plan, having it blessed by the powers to be and then strapping on developers hasn't worked traditionally.</li>
<li>Sprint planning shouldn't go over a day if I'm not mistaken. One of the key ideas of scrum is that you don't spend too much time planning. If they do, stop and reconvene when you have better clarity.. dont trudge on.
<ul>
<li>Get prioritized set of stories from customer ~3 hrs</li>
<li>developers huddle to estimate ~3 hrs</li>
<li>show estimates and let customers change their bucket to reflect business needs (within sprint quota) ~rem time.</li>
</ul></li>
</ol>
<p>Documenting decisions:</p>
<ul>
<li>Get a good scribe? Someone who can type away as fast as 4 people talk.. get the core statements/decisions in a high-visibility area like a chart.. or a wiki.. whatever works for you </li>
</ul>
<p>UX Study:</p>
<ul>
<li>Try to pipeline UX work. Make sure the UX people have already worked UI Details,Mock screens, workflows, etc. by the time the devs get to it. UX is working on stories for Iteration n+1 when the devs are working on iteration n. A bit difficult but can be done if UX is causing a lot of "thrashing" for you.</li>
</ul>
<p>Bug-Duty: </p>
<ul>
<li>One approach is to make all bugs as regular backlog items for the next iteration. Get Customer buy-in on which ones need to go in during sprint planning.</li>
<li>If that is not feasible, Trend bug-inflows, rate of fixing and plan for it. Keep x days marked away for the fix-on-demand devs dedicated for these requests.</li>
</ul>
<p>Scope for improvement:
<strong>You need a dedicated person in the "customer" role</strong> (or coach/BA who can front for the customer) that the developers can get in touch with on a real-time basis. Daily scrum meetings should be timeboxed to 30 mins and shouldn't include story "clarifications". Stick to the 3 questions - What did you do yesterday? What are you doing today? Any obstacles you need help with?<br>
The dev or sub-team in charge of a specific story should work with the Customer/Front in case of doubts <em>while they are working on the specific task</em>. They are responsible for extracting out the details as part of the development effort. They can request for help from other devs who have worked in related areas too if that helps. Work together with the customer to stay on the right track.<br>
HTH</p>
|
<p>Why are you sprint planning meetings a week long? The goal of sprint planning is to get just enough detail to feel comfortable as a team with the features you can get done and commit to doing them. This usually takes less than a day (~4 hours). The actual implementation details are discovered just in time by the devs during the sprint. That is why it is so important that they have access to the PO and the users. If you are asking where to capture the details, then you are designing to much in the planning meeting. The details should go directly into code during the sprint as they are worked out. </p>
<p>What would be a showstopper? The PO sees the progress at the end of each sprint (2 weeks) and then decides if the business value is enough to warrant a release. If there were any critical issues then the PO would probably not release that sprint. Hopefully you can get your PO and maybe users to look at the product on a daily basis as features are completed and thus reduce the probability of issues at the end of a sprint.</p>
| 23,894
|
<p>I have an application that's using Oracle.DataAccess to connect. I've already discovered that the footprint can be lessened by using ODAC 11 with xcopy deployment. That's already a big win.</p>
<p>Ideally, though, we would like to not have to alter any path variables and have all the ODAC files in a subdirectory underneath the application's folder. Is it possible to do this without changing the PATH variable? Is there some way to set a temporary PATH variable? Could we copy all of the files necessary to the application folder?</p>
<p>The general idea is that we want to isolate our ODAC files as much as possible from other applications that might be running on the same client.</p>
|
<p><a href="http://msdn.microsoft.com/en-us/library/z46c489x.aspx" rel="nofollow noreferrer">System.Environment.SetEnvironmentVariable</a> allows you to modify the process environment block. Whether that's enough for notoriously PITA Oracle is anyone's guess, though. ;)</p>
|
<p>Yes you can, see <a href="http://ora-00001.blogspot.com/2010/01/odpnet-minimal-non-intrusive-install.html" rel="nofollow noreferrer">http://ora-00001.blogspot.com/2010/01/odpnet-minimal-non-intrusive-install.html</a> for details.</p>
| 43,998
|
<p>I have a circular dependency between two functions. I would like each of these functions to reside in its own dll. Is it possible to build this with visual studio?</p>
<pre><code>foo(int i)
{
if (i > 0)
bar(i -i);
}
</code></pre>
<p>-> should compile into foo.dll</p>
<pre><code>bar(int i)
{
if (i > 0)
foo(i - i);
}
</code></pre>
<p>-> should compile into bar.dll</p>
<p>I have created two projects in visual studio, one for foo and one for bar. By playing with the 'References' and compiling a few times, I managed to get the dll's that I want. I would like to know however whether visual studio offers a way to do this in a clean way.</p>
<p>If foo changes, bar does not need to be recompiled, because I only depend on the signature of bar, not on the implementation of bar. If both dll's have the lib present, I can recompile new functionality into either of the two and the whole system still works.</p>
<p>The reason I am trying this is that I have a legacy system with circular dependencies, which is currently statically linked. We want to move towards dll's for various reasons. We don't want to wait until we clean up all the circular dependencies. I was thinking about solutions and tried out some things with gcc on linux and there it is possible to do what I suggest. So you can have two shared libraries that depend on each other and can be built independent of each other.</p>
<p>I know that circular dependencies are not a good thing to have, but that is not the discussion I want to have.</p>
|
<p>The reason it works on Unix-like systems is because they perform actual linking resolution at load time. A shared library does not know where its function definition will come from until it's loaded into a process. The downside of this is that you don't know either. A library can find and call functions in any other library (or even the main binary that launched the process in the first place). Also by default everything in a shared library is exported.</p>
<p>Windows doesn't work like that at all. Only explicitly exported things are exported, and all imports must be resolved at library link-time, by which point the identity of the DLL that will supply each imported function has been determined. This requires an import library to link against.</p>
<p>However, you can (with some extra work) get around this. Use <code>LoadLibrary</code> to open any DLL you like, and then use <code>GetProcAddress</code> to locate the functions you want to call. This way, there are no restrictions. But the restrictions in the normal method are there for a reason.</p>
<p>As you want to transition from static libraries to DLLs, it sounds like you're assuming that you should make each static library into a DLL. That's not your only option. Why not start moving code into DLLs only when you identify it as a self-contained module that fits into a layered design with no circularity? That way you can begin the process now but still attack it a piece at a time.</p>
|
<p>It is not possible to do cleanly. Because they both depend on each other, if A changes, then B must be recompiled. Because B was recompiled, it has changed and A needs to be recompiled and so on.</p>
<p>That is part of the reason circular dependencies are bad and whether you want to or not, you cannot leave that out of the discussion.</p>
| 47,360
|
<p>How do I obtain the serial number of the CPU in a PC?</p>
|
<p>I have the ultimate answer for this without any external libraries. Simply type this:</p>
<p><strong>wmic bios get serialnumber</strong></p>
<p>This will give you the Serial Number on the PCs chassis ;)
(found in microsoft's knowledge base)</p>
<p>Regards!</p>
|
<p>You can use <a href="http://en.wikipedia.org/wiki/CPUID" rel="nofollow noreferrer">CPUID</a> command.</p>
| 11,583
|
<p>I currently have a silverlight application which rotates through several graphs of live data. Each page has two user controls though: one for an info box at the top and another for the graph to display. I have tried to add a background image to the master page that they are displayed on so that the image is behind everything but as soon as they load, they overwrite the image with their blank canvas.</p>
<p>So far attempts to make the background of the user controls transparent have had no effect.</p>
<p>Any help would be greatly appreciated.</p>
|
<p>You need to set the background to be transparent on the host control itself, not just in the xaml files that get loaded. If you're using the object tag you would do something like:</p>
<pre><code><object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="[your xap file]"/>
<param name="background" value="transparent" />
....
</object>
</code></pre>
<p>Because the actual silverlight host control has a background color, if you don't set it to be transparent it will default to white which will overwrite your background regardless of if your canvas is transparent.</p>
|
<p>There is surely something inside the user controls that has a white background, you could probably find it using Blend, or maybe using <a href="http://firstfloorsoftware.com/silverlightspy/" rel="nofollow noreferrer">Silverlight Spy</a>. Spy is a great app that allows you to see the visual tree of a running app, among other things.</p>
| 30,234
|
<p>May I request you to clarify the issue I have with QTP err object.</p>
<p>I am trying to capture the screen shot of an object on which error occured.
I use the code <code>object.captureBitmap(filename)</code> to achieve this.</p>
<p>I would like to know if it is possible to get the screen shot of the entire page with the err object higlighted.</p>
|
<p>You can get this in your results file. go to tools->options and select the run tab. Check the box "Save still image captures to results" and select either always or for errors. When you run your test it will show the full screen and highlight the object it has a problem with, if it could find it.</p>
|
<p>(if I'm not too late with my reply)</p>
<p>Use CaptureBitmap method for both problem object and parent of the object.
Then you can display it in a variety of ways using simple html page automatically generated.</p>
<p>Albert</p>
| 15,473
|
<p>Can someone explain how exactly prepared connection pooling using dbcp can be used? (with some example code if possible). I've figured out how to turn it on - passing a KeyedObjectPoolFactory to the PoolableConnectionFactory.
But how should the specific prepared statements be defined after that?
Right now I'm only using a PoolingDataSource to get connections from the pool. How do I use the prepared statements from the pool?</p>
|
<p>Well talking about getting connection from the pool vs getting "not-pooled" connection, do you have any change in your code :)? I bet you do not. Same way with prepared statements. Your code should not change. So, there is no useful code example to this.</p>
<p>You should read docs for your JDBC Datasource implementation and see what developers have to say about pooling. There is no other source of reliable info on this.</p>
<p>From <a href="http://commons.apache.org/dbcp/configuration.html" rel="noreferrer">here</a>:
This component has also the ability to pool PreparedStatements. When enabled a statement pool will be created for each Connection and PreparedStatements created by one of the following methods will be pooled:</p>
<pre><code>* public PreparedStatement prepareStatement(String sql)
* public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
</code></pre>
<p>So, you just keep using prepareStatement() call and your dbcp will in theory take care of pooling (i.e. if you are trying to create "select * from users u where u.name like :id", it will try to find this statement in the pool first)</p>
|
<p>Here's basic code I use.</p>
<pre><code> GenericObjectPool connectionPool = new GenericObjectPool(null);
connectionPool.setMinEvictableIdleTimeMillis(1000 * 60 * 30);
connectionPool.setTimeBetweenEvictionRunsMillis(1000 * 60 * 30);
connectionPool.setNumTestsPerEvictionRun(3);
connectionPool.setTestOnBorrow(true);
connectionPool.setTestWhileIdle(false);
connectionPool.setTestOnReturn(false);
props = new Properties();
props.put("user", username);
props.put("password", password);
ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(url, props);
PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, connectionPool, null, "SELECT 1", false, true);
PoolingDataSource dataSource = new PoolingDataSource(connectionPool);
</code></pre>
| 35,661
|
<p>I need to concatenate two <code>String</code> arrays in Java.</p>
<pre><code>void f(String[] first, String[] second) {
String[] both = ???
}
</code></pre>
<p>Which is the easiest way to do this?</p>
|
<p>Here's a simple method that will concatenate two arrays and return the result:</p>
<pre><code>public <T> T[] concatenate(T[] a, T[] b) {
int aLen = a.length;
int bLen = b.length;
@SuppressWarnings("unchecked")
T[] c = (T[]) Array.newInstance(a.getClass().getComponentType(), aLen + bLen);
System.arraycopy(a, 0, c, 0, aLen);
System.arraycopy(b, 0, c, aLen, bLen);
return c;
}
</code></pre>
<p>Note that it will not work with primitive data types, only with object types.</p>
<p>The following slightly more complicated version works with both object and primitive arrays. It does this by using <code>T</code> instead of <code>T[]</code> as the argument type.</p>
<p>It also makes it possible to concatenate arrays of two different types by picking the most general type as the component type of the result.</p>
<pre><code>public static <T> T concatenate(T a, T b) {
if (!a.getClass().isArray() || !b.getClass().isArray()) {
throw new IllegalArgumentException();
}
Class<?> resCompType;
Class<?> aCompType = a.getClass().getComponentType();
Class<?> bCompType = b.getClass().getComponentType();
if (aCompType.isAssignableFrom(bCompType)) {
resCompType = aCompType;
} else if (bCompType.isAssignableFrom(aCompType)) {
resCompType = bCompType;
} else {
throw new IllegalArgumentException();
}
int aLen = Array.getLength(a);
int bLen = Array.getLength(b);
@SuppressWarnings("unchecked")
T result = (T) Array.newInstance(resCompType, aLen + bLen);
System.arraycopy(a, 0, result, 0, aLen);
System.arraycopy(b, 0, result, aLen, bLen);
return result;
}
</code></pre>
<p>Here is an example:</p>
<pre><code>Assert.assertArrayEquals(new int[] { 1, 2, 3 }, concatenate(new int[] { 1, 2 }, new int[] { 3 }));
Assert.assertArrayEquals(new Number[] { 1, 2, 3f }, concatenate(new Integer[] { 1, 2 }, new Number[] { 3f }));
</code></pre>
|
<p>In Haskell you can do something like that <code>[a, b, c] ++ [d, e]</code> to get <code>[a, b, c, d, e]</code>. These are Haskell lists concatenated but that'd very nice to see a similar operator in Java for arrays. Don't you think so ? That's elegant, simple, generic and it's not that difficult to implement.</p>
<p>If you want to, I suggest you to have a look at Alexander Hristov's work in his <a href="http://www.ahristov.com/tutoriales/java-compiler/duplicating-lexer.html" rel="nofollow">Hacking the OpenJDK compiler</a>. He explains how to modify javac source to create a new operator. His example consists in defining a '**' operator where <code>i ** j = Math.pow(i, j)</code>. One could take that example to implement an operator that concatenates two arrays of same type.<br></p>
<p>Once you do that, you are bound to your customized javac to compile your code but the generated bytecode will be understood by any JVM. <br><br>Of course, you can implement your own array concatenatation method at your source level, there are many examples on how to do it in the other answers !<br>
<br>
There are so many useful operators that could be added, this one would be one of them.</p>
| 10,594
|
<p>The following bit of code catches the EOS Exception</p>
<pre><code>using (var reader = new BinaryReader(httpRequestBodyStream)) {
try {
while (true) {
bodyByteList.Add(reader.ReadByte());
}
} catch (EndOfStreamException) { }
}
</code></pre>
<p>So why do I still receive first-chance exceptions in my console? </p>
<blockquote>
<p>A first chance exception of type 'System.IO.EndOfStreamException' occurred in mscorlib.dll</p>
</blockquote>
<p>Is there a way to hide these first chance exception messages?</p>
|
<p>To avoid seeing the messages, right-click on the output window and uncheck "Exception Messages".</p>
<p>However, seeing them happen might be nice, if you're interested in knowing when exceptions are thrown without setting breakpoints and reconfiguring the debugger.</p>
|
<p>I think the stream is throwing this exception, so your try is scoped to narrow to catch it.</p>
<p>Add a few more try catch combos around the different scopes until you catch it where its actually being thrown, but it appears to be happening either at our outside of your using, since the stream object is not created in the using's scope.</p>
| 8,273
|
<p>I have a Windows executable (say <code>program.exe</code>) and I want to provide users with 2 launchers that will pass different arguments to it.</p>
<pre><code>program.exe -a
program.exe -b
</code></pre>
<p>I can easily do this with 2 batch files, but I would rather provide users with 2 .exe files as they are more likely to be used correctly without editing.</p>
<p>Is there an easy way to create such an executable?</p>
|
<p>Why create new executables?
Why not just create desktop shortcuts to launch the single exe.</p>
|
<p>If you are using .Net you can read the information presented as parameters from another application or batch file. It's part of the Framework. Here it is is VB.NET</p>
<p>For Each Arg As String In Environment.GetCommandLineArgs()
//Process the arguments
Next Arg</p>
| 20,110
|
<p>We should have a full release of asp.net MVC well before .NET 4.0 and VS 10 come out, right? </p>
<p>I'm really hoping MS can keep MVC as dynamic as other more open frameworks are.</p>
|
<p>Yes, MVC 1.0 RTM will ship as a fully supported Out-of-Band Framework before .NET 4.0 and VS 10 are released. We want to keep it dynamic as well and will continue to ship updates via CodePlex, as we did with 1.0. At least that's our current plan.</p>
|
<p>I don't think it will have much impact, other than the fact that the MVC Framework will be part of the .NET Framework. The work being done on MVC should continue to be made available through CodePlex, even after the official release of both frameworks.</p>
| 38,532
|
<p>I want to print this <a href="https://www.thingiverse.com/thing:2213410" rel="nofollow noreferrer">heat tower calibration test</a>.</p>
<p>The instructions say to change the temperature every 25 layers. It also tells me to use G-Code command <code>M104 Sxxx</code></p>
<p>First, is there a way to specify this command using Ultimaker Cura?</p>
<p>If not, how do I do so in the G-code file? </p>
<p>I see that the G-code file is just a plain text file with a command per line presumably. Do I just insert <code>M104 S225</code> at one point and then <code>M104 S220</code>...?
If so, how do I know where the 25th layer is?</p>
|
<p>Every time you see a Z movement that matches the layer height (eg. 0.20 mm) you can assume that is the end/start of one "layer".
It should have a line like:</p>
<pre><code>;Layer count: 17
;LAYER:0. ; mine has this as the first layer
M107
G0 F2400 X67.175 Y61.730 Z0.250. ; moves to Z0.250 mm for the first layer, with layer thickness 0.25 mm
</code></pre>
<p>Then later:</p>
<pre><code>;LAYER:1
M106 S255
G0 F2400 X78.078 Y69.627 Z0.550 ; 2nd layer.
</code></pre>
<p>So search for "Z" or "Layer" and once you've seen 25 of these "small" movements (comparing to previous Z movement?), insert your line of code at the end of the layer commands. Don't confuse it with large Z-movements, that may correspond to move up/retract filaments.
Depending on your goals for the print, maybe you also want to insert a wait time - say a minute or two for the new temp to stabilize? Here is the line for that:</p>
<pre><code>G4 P200 ; Sit still doing nothing for 200 milliseconds.
</code></pre>
|
<p>Every time you see a Z movement that matches the layer height (eg. 0.20 mm) you can assume that is the end/start of one "layer".
It should have a line like:</p>
<pre><code>;Layer count: 17
;LAYER:0. ; mine has this as the first layer
M107
G0 F2400 X67.175 Y61.730 Z0.250. ; moves to Z0.250 mm for the first layer, with layer thickness 0.25 mm
</code></pre>
<p>Then later:</p>
<pre><code>;LAYER:1
M106 S255
G0 F2400 X78.078 Y69.627 Z0.550 ; 2nd layer.
</code></pre>
<p>So search for "Z" or "Layer" and once you've seen 25 of these "small" movements (comparing to previous Z movement?), insert your line of code at the end of the layer commands. Don't confuse it with large Z-movements, that may correspond to move up/retract filaments.
Depending on your goals for the print, maybe you also want to insert a wait time - say a minute or two for the new temp to stabilize? Here is the line for that:</p>
<pre><code>G4 P200 ; Sit still doing nothing for 200 milliseconds.
</code></pre>
| 1,181
|
<p>I've got a Dell XPS M1330 with a 2.2ghz processor, 4gig ram, GeForce 8400M, and a 64GB SSD disk.</p>
<p>I'm primarily doing web-development, sharepoint development, integration (Microsoft BI tools) and biztalk. I use virtual machines for these purposes. I've been using Vista 32Bit up until now but I'm considering moving to 64bit to squeeze that little extra ram out of the box.</p>
<p>I'd like to hear if anyone has been using 64bit vista under the same circumstances and if anything should hold me back. Have in mind that this is the laptop I use at work.</p>
|
<p>I have recently switched from a Vista 32 bit development machine to a Vista 64 bit development machine, with a quad-core intel processor, and 6gb of ram. THe performance improvements have been quite impressive, and thus far, no "issues" with any development tools that I have been using.</p>
|
<p><a href="http://www.basicinstructions.net/images/basic081009.gif" rel="nofollow noreferrer">http://www.basicinstructions.net/images/basic081009.gif http://www.basicinstructions.net/images/basic081009.gif</a></p>
<p>Sorry about that.</p>
| 22,949
|
<p>This has got to be something I just missed, but how do I add a tool tip to a label?</p>
<p>I saw something on the web about handling the mouse hover event, but how would I even handle it in code?</p>
|
<p>Add in your form the TooTip from the ToolBox than click once in your label and you'll see ToolTip in the property box.</p>
|
<pre><code>button = new Button();
button.Content = "Hover over me.";
tt = new ToolTip();
tt.Content = "Created with C#";
button.ToolTip = tt;
cv2.Children.Add(button);
</code></pre>
<p>from <a href="http://msdn.microsoft.com/en-us/library/ms754034.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms754034.aspx</a></p>
| 32,881
|
<p>With the Ajax Control Toolkit, one can easily drag and drop all types of great extender onto controls, but they register a boatload of JavaScript to do it. </p>
<ol>
<li>How do I control this? </li>
<li>If the <code>ScriptManager</code> is in the <code>MasterPage</code>, is there anyway to control the loading of a script on one page that isn't in another?</li>
</ol>
<p>For example: calendar extender is on one page, but the script for it gets loaded on every page that is a child of the master page.</p>
|
<p><strong>SubSonic</strong></p>
<p>Pros:</p>
<ul>
<li>Nice and simple</li>
<li>Scaffolding</li>
</ul>
<p>Cons:</p>
<ul>
<li>Method signatures often accept string parms (though you're encouraged to use DAO string constants) which can be abused.</li>
</ul>
<p>Keep in mind:</p>
<ul>
<li>Requires Website project for no-code, hands-off model generation (needs the BuildProvider).</li>
</ul>
<p><strong>Linq To SQL</strong></p>
<p>Pros:</p>
<ul>
<li>Syntactic sugar in the IDE</li>
<li>MS supported</li>
<li>View the SQL to be executed in the IDE </li>
<li>Allows different levels of fiddling in the model, from auto-generation to explicit definitions down to object properties.</li>
</ul>
<p>Cons:</p>
<ul>
<li>Complex. You need to learn new concepts like the DataContext to be effective.</li>
</ul>
<p>Keep in mind:</p>
<ul>
<li>Some stackoverflow users <a href="https://stackoverflow.com/questions/252683/is-linq-to-sql-doa">question Linq to SQL's continued support</a>.</li>
</ul>
<p>Also evaluate the <a href="http://msdn.microsoft.com/en-us/library/aa697427(vs.80).aspx" rel="nofollow noreferrer">ADO.NET Entity Framework</a> and <a href="http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework" rel="nofollow noreferrer">here</a>.</p>
|
<p>The biggest risk with linq to sql is that Microsoft will grow tired of it and abandon it. There is a lot of speculation that this has already happened and that only the entity framework will be updated. Subsonic does not suffer from this and worse case you have the source code to make your edits.</p>
| 31,147
|
<p>As usual, some background information first:</p>
<p>Database A (Access database) - Holds a table that has information I need from only two columns. The information from these two columns is needed for an application that will be used by people that cannot access database A.</p>
<p>Database B (Access database) - Holds a table that contains only two columns (mirrors to what we need from table A). Database B is accessible to all users of the application. One issue is that on of the column names is not the same as it is in the table from Database A.</p>
<p>What I need to do is transfer the necessary data via a utility that will run automatically, say once a week (the two databases don't need to be totally in sync, just close). The transfer utility will be run from a user account that has access to both databases (obviously).</p>
<p>Here's the approach I've taken (again if there is a better way, please suggest away):</p>
<ol>
<li><p>Grab the data from database A. It is only the two columns from the necessary table.</p></li>
<li><p>Write the data out to [tablename].txt file using a DataReader object and WriterStream object. I've done this so I can use a schema.ini file and force the data columns to have the same name as they will be in Database B.</p></li>
<li><p>Create a DataSet object, containing a DataTable that mirrors the table from Database B.</p></li>
<li><p>Suck the information from the .txt file into the DataTable using the Microsoft.Jet.OLEDB.4.0 provider with extended properties of text, hdr=yes and fmt=delimited (to match how I have the schema.ini file setup and the .txt file setup). I'm using a DataAdapter to fill the DataTable.</p></li>
<li><p>Create another DataSet object, containing a DataTable that mirrors the table from Database B. </p></li>
<li><p>Suck in the information from Database B so that it contains all the current data found in the table that needs to be updated from Database A. Again I'm using a DataAdapter to fill this DataTable (a different one from Step 5, since they are both using different data sources).</p></li>
<li><p>Merge the DataTable that holds the data from Database A (or the .txt file, technically).</p></li>
<li><p>Update Database B's table with the changes.</p></li>
</ol>
<p>I've written update, delete and insert commands manually for the DataAdapter that is repsonsible for talking to Database B. However, this logic is never used because the DataSet-From-Database-B.Merge(Dataset-From-TxtFile[tableName]) doesn't flip the HasChanges flag. This means the DataSet-From-Database-B.Update doesn't fire any of the commands.</p>
<p>So is there any way I can get the data from DataSet-From-TxtFile to merge and apply to Database B using the method I'm using? Am I missing a crucial step here?</p>
<p>I know I could always delete all the records from Database B's table and then just insert all the records from the text file (even if I had to loop through each record in the DataSet and apply row.SetAdded to ensure it triggers the HasChanges flag), but I'd rather have it apply ONLY the changes each time.</p>
<p>I'm using c# and the 2.0 Framework (which I realize means I can use DataTables and TableAdapters instead of DataSets and DataAdapters since I'm only dealing with a single table, but anyway).</p>
<p>TIA</p>
|
<p>Setting aside for a moment that I would use SQLServer and only have a single table with multiple views controlling who could see what information in it to avoid the whole synchronization problem...</p>
<p>I think that @Mitchel is correct here. Just write a program that connects to both databases, load A table and B table, respectively. Then, for each element (column pair) in A make sure it is in B. If not, then insert it in B. Then, for each element in B, make sure it is in A. If not, then remove it from B. The save B. I don't see the need to go to a file first.</p>
<p>Pseudocode:</p>
<pre><code>DataTable A = load table from A
DataTable B = load table from B
foreach row in A
col1 = row[col1]
col2 = row[col2]
matchRow = B.select( "col1 = " + col1 + " and col2 = " + col2)
if not matchRow exists
add new row to B with col1,col2
end
end
foreach row in B
col1 = row[col1]
col2 = row[col2]
matchRow = A.select( "col1 = " + col1 + " and col2 = " + col2)
if not matchRow exists
remove row from B
end
end
update B
</code></pre>
|
<p>Why not simply use a data reader, and loop through the records, doing manual inserts if needed into database B?</p>
<p>Rather than working with datasets, merging, etc..</p>
| 28,983
|
<p>I have reasonable experience to manage my own server, so gogrid style management is not a problem. But seems mosso is a tag cheaper somewhat- except the very difficult to access compute cycles terms. Anyone could share about this would be very welcomed.</p>
|
<p>It's simple, Mosso is just like a "reseller" hosting. They provide you everything whitelabel from billing to control panel then you sell it back to customers.</p>
<p>If you are developer, I recommend you choose GoGrid. Firstly, Mosso doesn't provide SSH access. Secondly, if you are RoR/Mongrel user, you are capped to limited RAM (unless you pay extra in addition to $100). Moreover, GoGrid allows you to choose server image (CentOS, Redhat, Windows) with some out-of-the-box support for RoR and LAMP.</p>
<p>Somemore, GoGrid provides you initial credits ($50 or $95 if you use MS-WEBFWRD) for you to try out before actually paying for it.</p>
|
<p>Mosso does not give you Admin control over the "servers" anymore...</p>
| 22,818
|
<p>I want to be able to quickly check whether I both have sudo access and my password is already authenticated. I'm not worried about having sudo access specifically for the operation I'm about to perform, but that would be a nice bonus.</p>
<p>Specifically what I'm trying to use this for is a script that I want to be runnable by a range of users. Some have sudo access. All know the root password.</p>
<p>When they run my script, I want it to use sudo permissions without prompting for a password if that is possible, and otherwise to fall back to asking for the <em>root</em> password (because they might not have sudo access).</p>
<p>My first non-working attempt was to fork off <code>sudo -S true</code> with STDIN closed or reading from /dev/null. But that still prompts for the password and waits a couple of seconds.</p>
<p>I've tried several other things, including waiting 0.3sec to see whether it succeeded immediately, but everything I try ends up failing in some situation. (And not because my timeout is too short.) It's difficult to figure out what goes on, because I can't just strace like I normally would.</p>
<p>One thing I <em>know</em> doesn't work is to close STDIN or attach it to a pipe before running <code>sudo -S true</code>. I was hoping that would make the password prompt immediately fail, but it still prompts and behaves strangely. I think it might want a terminal.</p>
|
<p>With newer versions of <a href="http://www.sudo.ws/sudo/sudo.man.html" rel="nofollow"><code>sudo</code></a> there's an option for this purpose:</p>
<pre><code>sudo -n true
</code></pre>
<p>I use <code>true</code> here for a no-op, but you could use any command.</p>
|
<pre><code>getent group admin | grep $particular_user
</code></pre>
<p>You could use whoami to get the current user.</p>
<p>Edit: But that doesn't help you find if you're still authed to do sudo tasks... Hmm..</p>
| 14,871
|
<p>We run a large online community in the Netherlands. Because of that we send a lot of mail to the hotmail email addresses of our members.
Recently we have noticed that not all mail is reaching our members, because we have hit a certain limit or so it seems.</p>
<p>Google doesn't give a solution (yet) but we see a lot of others having the same problem.
Note, We have added (since long) SPF records for our domain, in TXT and SPF types.
What else can we do to tackle this problem?</p>
<p>// Ryan</p>
|
<p>421 means that the service is not <em>currently</em> available, and that the client <strong>should try again</strong>. This could be for any number of reasons, including trying to discourage you from too frequent mailing if Hotmail thinks you might be a spambot. </p>
<p>Why not simply let your outbound smtpd queue the mails and try again? </p>
<p>Why is "not all mail reaching your members"? Don't you try again if you get a 421 response?</p>
<p>EDIT: Do what <a href="https://stackoverflow.com/questions/343300/how-to-fix-the-421-rp-001-the-mail-server-ip-connecting-to-windows-live-hotmail-s/570757#570757">sqook says.</a></p>
|
<p>The only real way to "get around" this is to become a good e-mail citizen. Make it easy for people to unsubscribe from your notifications, establish complaint feedback loops with the major mail providers, remove bouncing e-mails from your list automatically, don't send people e-mails they don't want to receive. Failing to adhere to these simple requirements makes you look like a spammer, and providers like Hotmail will treat you like one.</p>
| 44,646
|
<p>I've seen a good bit of setuptools bashing on the internets lately. Most recently, I read James Bennett's <a href="http://www.b-list.org/weblog/2008/dec/14/packaging/" rel="noreferrer">On packaging</a> post on why no one should be using setuptools. From my time in #python on Freenode, I know that there are a few souls there who absolutely detest it. I would count myself among them, but I do actually use it.</p>
<p>I've used setuptools for enough projects to be aware of its deficiencies, and I would prefer something better. I don't particularly like the egg format and how it's deployed. With all of setuptools' problems, I haven't found a better alternative.</p>
<p>My understanding of tools like <a href="http://pip.openplans.org/" rel="noreferrer">pip</a> is that it's meant to be an easy_install replacement (not setuptools). In fact, pip uses some setuptools components, right?</p>
<p>Most of my packages make use of a setuptools-aware setup.py, which declares all of the dependencies. When they're ready, I'll build an sdist, bdist, and bdist_egg, and upload them to pypi.</p>
<p>If I wanted to switch to using pip, what kind of changes would I need to make to rid myself of easy_install dependencies? Where are the dependencies declared? I'm guessing that I would need to get away from using the egg format, and provide just source distributions. If so, how do i generate the egg-info directories? or do I even need to?</p>
<p>How would this change my usage of virtualenv? Doesn't virtualenv use easy_install to manage the environments?</p>
<p>How would this change my usage of the setuptools provided "develop" command? Should I not use that? What's the alternative?</p>
<p>I'm basically trying to get a picture of what my development workflow will look like.</p>
<p>Before anyone suggests it, I'm not looking for an OS-dependent solution. I'm mainly concerned with debian linux, but deb packages are not an option, for the reasons Ian Bicking outlines <a href="http://blog.ianbicking.org/2008/12/14/a-few-corrections-to-on-packaging/" rel="noreferrer">here</a>.</p>
|
<p>pip uses Setuptools, and doesn't require any changes to packages. It actually installs packages with Setuptools, using:</p>
<pre><code>python -c 'import setuptools; __file__="setup.py"; execfile(__file__)' \
install \
--single-version-externally-managed
</code></pre>
<p>Because it uses that option (<code>--single-version-externally-managed</code>) it doesn't ever install eggs as zip files, doesn't support multiple simultaneously installed versions of software, and the packages are installed flat (like <code>python setup.py install</code> works if you use only distutils). Egg metadata is still installed. pip also, like easy_install, downloads and installs all the requirements of a package. </p>
<p><em>In addition</em> you can also use a requirements file to add other packages that should be installed in a batch, and to make version requirements more exact (without putting those exact requirements in your <code>setup.py</code> files). But if you don't make requirements files then you'd use it just like easy_install.</p>
<p>For your <code>install_requires</code> I don't recommend any changes, unless you have been trying to create very exact requirements there that are known to be good. I think there's a limit to how exact you can usefully be in <code>setup.py</code> files about versions, because you can't really know what the future compatibility of new libraries will be like, and I don't recommend you try to predict this. Requirement files are an alternate place to lay out conservative version requirements.</p>
<p>You can still use <code>python setup.py develop</code>, and in fact if you do <code>pip install -e svn+http://mysite/svn/Project/trunk#egg=Project</code> it will check that out (into <code>src/project</code>) and run <code>setup.py develop</code> on it. So that workflow isn't any different really.</p>
<p>If you run pip verbosely (like <code>pip install -vv</code>) you'll see a lot of the commands that are run, and you'll probably recognize most of them.</p>
|
<p>For starters, pip is really new. New, incomplete and largely un-tested in the real world. </p>
<p>It shows great promise but until such time as it can do everything that easy_install/setuptools can do it's not likely to catch on in a big way, certainly not in the corporation. </p>
<p>Easy_install/setuptools is big and complex - and that offends a lot of people. Unfortunately there's a really good reason for that complexity which is that it caters for a huge number of different use-cases. My own is supporting a large ( > 300 ) pool of desktop users, plus a similar sized grid with a frequently updated application. The notion that we could do this by allowing every user to install from source is ludicrous - eggs have proved themselves a reliable way to distribute my project.</p>
<p>My advice: Learn to use setuptools - it's really a wonderful thing. Most of the people who hate it do not understand it, or simply do not have the use-case for as full-featured distribution system.</p>
<p>:-)</p>
| 48,128
|
<p>Is there any way to split a long string of HTML after N words? Obviously I could use:</p>
<pre><code>' '.join(foo.split(' ')[:n])
</code></pre>
<p>to get the first n words of a plain text string, but that might split in the middle of an html tag, and won't produce valid html because it won't close the tags that have been opened.</p>
<p>I need to do this in a zope / plone site - if there is something as standard in those products that can do it, that would be ideal.</p>
<p>For example, say I have the text:</p>
<pre><code><p>This is some text with a
<a href="http://www.example.com/" title="Example link">
bit of linked text in it
</a>.
</p>
</code></pre>
<p>And I ask it to split after 5 words, it should return:</p>
<pre><code><p>This is some text with</p>
</code></pre>
<p>7 words:</p>
<pre><code><p>This is some text with a
<a href="http://www.example.com/" title="Example link">
bit
</a>
</p>
</code></pre>
|
<p>Take a look at the <a href="http://code.djangoproject.com/browser/django/trunk/django/utils/text.py" rel="noreferrer">truncate_html_words</a> function in django.utils.text. Even if you aren't using Django, the code there does exactly what you want.</p>
|
<p>I was going to mention the base <a href="http://docs.python.org/library/htmlparser.html#module-HTMLParser" rel="nofollow noreferrer">HTMLParser</a> that's built in Python, since I'm not sure what the end-result your trying to get to is, it may or may not get you there, you'll work with the handlers primarily</p>
| 46,987
|
<p>Emacs Lisp function often start like this:</p>
<pre><code>(lambda () (interactive) ...
</code></pre>
<p>What does "(interactive)" do?</p>
|
<p>Just to clarify (it is in the quoted docs <a href="https://stackoverflow.com/questions/378942/what-does-interactive-mean-in-an-emacs-lisp-function#378960">that Charlie cites</a>) <code>(interactive)</code> is not just for key-bound functions, but for any function. Without <code>(interactive)</code>, it can only be called programmatically, not from <code>M-x</code> (or via key-binding).</p>
<p><strong>EDIT:</strong> Note that just adding "(interactive)" to a function won't necessarily make it work that way, either -- there could be many reasons functions are not interactive. Scoping, dependencies, parameters, etc.</p>
|
<p>One of the "gotchas" that <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Interactive-Codes.html" rel="nofollow noreferrer">this</a> clarifies is that the <em>argument</em> to <code>interactive</code> is actually a kind of mini-formatting language (like for <code>printf</code>) that specifies the following (for the surrounding function's input):</p>
<ol>
<li>schema (number of arguments and their type)</li>
<li>source (e.g., marked-region in buffer and/or user input, etc.)</li>
</ol>
<p>For example,</p>
<blockquote>
<p><code>'r'</code>
Point and the mark, as two numeric arguments, smallest first.</p>
</blockquote>
<p>means that the <code>interactive</code>-annotated function needs exactly two arguments.
e.g. this will work</p>
<pre class="lang-lisp prettyprint-override"><code>(defun show-mark (start stop)
(interactive "r")
(print start)
(print stop))
</code></pre>
<p>This will break:</p>
<pre class="lang-lisp prettyprint-override"><code>(defun show-mark (start)
(interactive "r")
(print start))
</code></pre>
<blockquote>
<pre class="lang-lisp prettyprint-override"><code>Wrong number of arguments: ((t) (start) (interactive "r") (print start)), 2
</code></pre>
</blockquote>
| 49,642
|
<p>I am writing a simple xml string to an MSMQ from a VB6 app, but when I attempt to read the message off the queue in C# using the XmlMessageFormatter I get the following error:</p>
<p>"Name cannot begin with the '.' character"</p>
<p>How do I successfully read these messages using .Net code?</p>
|
<p>I believe that you have to use the ActiveXMessageFormatter, and not the XmlMessageFormatter. The XmlMessageFormatter is for sending objects between .net applications. What you are sending is not xml but string. And not a .net string. According to the documentation of the ActiveXMessageFormatter it is for:</p>
<blockquote>
<p>Serializes or deserializes primitive
data types and other objects to or
from the body of a Message Queuing
message, using a format that is
compatible with the MSMQ ActiveX
Component</p>
</blockquote>
<p>When you send from vb6 you are using the msmq com interface. Which is another name for ActiveX interface. After you receive the string with the ActiveXMessageFormatter. Convert it to xml object explicitly.</p>
|
<p>first inspect your data to make sure it really is as the error message implies. If it is, first read the data as text or binary, remove the offending '.', then use the xmlmessageformatter</p>
| 33,894
|
<p>What are the differences between a <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/HashMap.html" rel="noreferrer"><code>HashMap</code></a> and a <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Hashtable.html" rel="noreferrer"><code>Hashtable</code></a> in Java?</p>
<p>Which is more efficient for non-threaded applications?</p>
|
<p>There are several differences between <a href="http://java.sun.com/javase/7/docs/api/java/util/HashMap.html" rel="noreferrer"><code>HashMap</code></a> and <a href="http://java.sun.com/javase/7/docs/api/java/util/Hashtable.html" rel="noreferrer"><code>Hashtable</code></a> in Java:</p>
<ol>
<li><p><code>Hashtable</code> is <a href="https://stackoverflow.com/questions/1085709/what-does-synchronized-mean">synchronized</a>, whereas <code>HashMap</code> is not. This makes <code>HashMap</code> better for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones.</p></li>
<li><p><code>Hashtable</code> does not allow <code>null</code> keys or values. <code>HashMap</code> allows one <code>null</code> key and any number of <code>null</code> values.</p></li>
<li><p>One of HashMap's subclasses is <a href="http://java.sun.com/javase/7/docs/api/java/util/LinkedHashMap.html" rel="noreferrer"><code>LinkedHashMap</code></a>, so in the event that you'd want predictable iteration order (which is insertion order by default), you could easily swap out the <code>HashMap</code> for a <code>LinkedHashMap</code>. This wouldn't be as easy if you were using <code>Hashtable</code>.</p></li>
</ol>
<p>Since synchronization is not an issue for you, I'd recommend <code>HashMap</code>. If synchronization becomes an issue, you may also look at <a href="http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ConcurrentHashMap.html" rel="noreferrer"><code>ConcurrentHashMap</code></a>.</p>
|
<p>The Hashtable class is synchronized, that is, it is designed to be used by applications that handle multiple or multithreaded process. Synchronized classes are less efficient in the classical case of an application to a process, so the Hashmap class is faster in general.
The HashTable class does not accept the Null value, either for keys or for values, while the HashMap class allows a single key with Null and as many as null as possible.</p>
| 6,170
|
<p>I'm creating an app that needs to be accessed by both a web front end hosted on an internal network and also run as a scheduled task. Nothing will need to be accessed outside of our internal systems and once the app is up and running we don't envision anything changing for some time.</p>
<p>My initial thought is to create a DLL encapsulating the bulk of the necessary functionality and then call it via both a Web Forms interface for manual execution, and a console app running as an automated (daily) scheduled task.</p>
<p>Another suggestion has been to expose a Web Service for the core functionality instead, but as the app will never need to be called by an external resource I think the extra effort required in implementing a Web Service might not be worth the hassle. The DLL solution should also be substantially faster(?).</p>
<p>My question is which route would you choose? Are there any pros/cons that I haven't covered? Any glaring omissions?</p>
<p><strong>Disclaimer:</strong> I'm new to .Net but due to one of our developers being involved in a serious accident I've been asked to step up to the plate.</p>
|
<p>Personally, I say go with the DLL. It will be fast and simple.</p>
<p>With a web service, you will need to think about your network, firewalls, performance, etc. It also makes it harder to debug since you won't be able to step into the web service from your clients, you will have to set breakpoints on both sides of the calls.</p>
<p>The other problem with web services for you is that you need to be much more robust handling failures. With a DLL, you know a call to a method is going to succeed, but with a web service, you will need to be prepared for that call to fail or time out whenever you make any call across.</p>
<p>Lastly, if you find a need for a web service at a later date, you should be able to fairly easily convert the DLL into a web service with minimal retrofitting.</p>
|
<p>Wow wow wow. They all share one DB? If that's the case, no, no, and no. If the DB is NOT shared, then it's definately DLL.</p>
<p>The correct choice is Web Service. The reason is very simple too.</p>
<p>1) Consistency of domain model and business logic. Lets say you store an enum in a column, and you add an enum and deploy to one application. It will now break the other two applications.</p>
<p>2) Ease of deployment. One change = one deployment. If it's a dll, one change = 3 deploy.</p>
<p>3) DB transactions and concurrency control. A lot easier to resolve it in one app domain.</p>
<p>As for Cons suggested by others, I find them being too partial.</p>
<p>1) Difficulty in debugging across app domain. You should publish the possible exceptions through WSDL as fault exceptions. The calling client should handle those fault exceptions appropriately as well. It's also incredibly easy to setup unit tests and mocks on both calling client and server. Breakpoint is not the correct way to debug and work with distributed applications. You can, and it's not difficult. I just don't believe that's the correct approach.</p>
<p>2) Performance. WCF allows you to set different bindings through configuration. From basic http (which is easier to debug) all the way down to named pipe which you can use to obtain near-native call performance. This decision can (nearly. There are a few quirks with different binding that you need to take into consideration.) be decided after development too.</p>
<p>3) Security. Saying WCF doesn't handle security is hilariously wrong.</p>
<p>Lastly, real cons from me:</p>
<p>1) More complex. Agreed. Different context makes application design more difficult. That goes two ways tho. This complexity enforces clear separation of tiers. Presentation context should stay where they are, at presentation level.</p>
<p>2) Require more planning. Designing contracts for WCF Web Services is an art in itself.</p>
<p>3) Management overhead for configuration. Can be daunting for newer developers, but I hope you can get over this hurdle quickly. WCF configuration is a double edged sword, powerful, yet complex (for some).</p>
<p>My personal experience is, anytime a DB is shared and the DLL is used across multiple app domains, I regret that I didn't hammer the dev team enough to go with Web Services route.</p>
<p>So what was your final decision? It's been four years now.</p>
| 38,331
|
<p>I often access shared network folders in Powershell to grab files etc. But if the share requires a username/password, Powershell does not prompt me for these, unlike Windows Explorer. If I connect to the folder first in Windows Explorer, Powershell will then allow me to connect. </p>
<p>How can I authenticate myself in Powershell?</p>
|
<p>At first glance one really wants to use <a href="http://technet.microsoft.com/en-us/library/ee176915.aspx" rel="noreferrer"><code>New-PSDrive</code></a> supplying it credentials. </p>
<pre><code>> New-PSDrive -Name P -PSProvider FileSystem -Root \\server\share -Credential domain\user
</code></pre>
<h3>Fails!</h3>
<pre>New-PSDrive : Cannot retrieve the dynamic parameters for the cmdlet. Dynamic parameters for NewDrive cannot be retrieved for the 'FileSystem' provider. The provider does not support the use of credentials. Please perform the operation again without specifying credentials.</pre>
<p>The documentation states that you can provide a <code>PSCredential</code> object but if you look closer the cmdlet does not support this yet. Maybe in the next version I guess. </p>
<p>Therefore you can either use <code>net use</code> or the <code>WScript.Network</code> object, calling the <a href="http://msdn.microsoft.com/en-us/library/8kst88h6(VS.80).aspx" rel="noreferrer"><code>MapNetworkDrive</code></a> function:</p>
<pre><code>$net = new-object -ComObject WScript.Network
$net.MapNetworkDrive("u:", "\\server\share", $false, "domain\user", "password")
</code></pre>
<hr>
<h2>Edit for <a href="http://technet.microsoft.com/en-us/library/hh849829.aspx" rel="noreferrer">New-PSDrive in PowerShell 3.0</a></h2>
<p>Apparently with newer versions of PowerShell, the <code>New-PSDrive</code> cmdlet works to map network shares with credentials!</p>
<pre><code>New-PSDrive -Name P -PSProvider FileSystem -Root \\Server01\Public -Credential user\domain -Persist
</code></pre>
|
<p><a href="https://devblogs.microsoft.com/powershell/improving-the-filesystem-provider-through-community-feedback/" rel="nofollow noreferrer">PowerShell 3 supports this out of the box</a> now.</p>
<p>If you're stuck on PowerShell 2, you basically have to use the legacy <code>net use</code> command (as suggested earlier).</p>
| 38,928
|
<p>I have an unmanaged C dll I call from a C# class library that encrypts a string value into an encrypted string that contains non-ascii characters. I need to take the data and write its binary values to a file, but C# treats text as <code>string</code> rather than a <code>byte[]</code>. </p>
<p>The encrypted value commonly contains special characters (<code>\r</code>, <code>\O</code>, etc). When I do this converting the returned string to C# using some type of codeset (ascii, utf-7, utf-16) it writes the special character values as the Windows interpreted values instead their actual binary representation. </p>
<p>My question is how can I pull the data from the unmanaged dll into a <code>byte[]</code> rather than a string so I can write that to file using the <code>BinaryWriter</code>?</p>
<p>Thanks.</p>
|
<p>If I understand you correctly, I think you want Encoding.GetBytes() probably with UTF8?</p>
|
<p>Are you using P/Invoke? Hmm... Perhaps the specifying [MarshalAs(UnmanagedType.*)] would help.
Also, you could create an intermediary C function that instead exposes the encrypted data as (void *). That should be easier to get into a byte[].</p>
| 23,614
|
<p>Why do I have to specify <code>runat="server"</code> on all my ASP.NET controls when it is a mandatory attribute and <code>server</code> is the only option available in my limited knowledge of ASP.NET, and I get an error if I don't use it?</p>
<p>I do understand that I can optionally use it on my HTML tags, and I do understand the client/server paradigm and what it is actually specifying.</p>
<p>Is it a redundant tag that could just be implied by the control being an ASP.NET control, or is there an underlying reason?</p>
|
<p>I've always believed it was there more for the understanding that you can mix ASP.NET tags and HTML Tags, and HTML Tags have the option of either being <code>runat="server"</code> or not. It doesn't hurt anything to leave the tag in, and it causes a compiler error to take it out. The more things you imply about web language, the less easy it is for a budding programmer to come in and learn it. That's as good a reason as any to be verbose about tag attributes.</p>
<p>This conversation was had on Mike Schinkel's <a href="http://mikeschinkel.com/blog/whyrunatserverforaspnetpart2/" rel="noreferrer">Blog</a> between himself and Talbot Crowell of Microsoft National Services. The relevant information is below (first paragraph paraphrased due to grammatical errors in source):</p>
<blockquote>
<p><em>[...]</em> but the importance of <code><runat="server"></code> is more for consistency and extensibility. </p>
<p>If the developer has to mark some tags (viz. <code><asp: /></code>) for the ASP.NET Engine to ignore, then there's also the potential issue of namespace collisions among tags and future enhancements. By requiring the <code><runat="server"></code> attribute, this is negated.</p>
</blockquote>
<p>It continues:</p>
<blockquote>
<p>If <code><runat=client></code> was required for all client-side tags, the parser would need to parse all tags and strip out the <code><runat=client></code> part.</p>
</blockquote>
<p>He continues: </p>
<blockquote>
<p>Currently,
If my guess is correct, the parser
simply ignores all text (tags or no
tags) unless it is a tag with the
<code>runat=server</code> attribute or a “<code><%</code>”
prefix or ssi “<code><!– #include</code>… <em>(...)</em>
Also, since ASP.NET is designed to
allow separation of the web designers
(foo.aspx) from the web developers
(foo.aspx.vb), the web designers can
use their own web designer tools to
place HTML and client-side JavaScript
without having to know about ASP.NET
specific tags or attributes.</p>
</blockquote>
|
<p><code>runat="Server"</code> indicates a postback to the server will occur for the HTML "control."</p>
<p>Web Forms use <code>postback</code> constantly to signal the server to process a page control event.</p>
<p><code>.NET</code> <code>MVC</code> pages DO NOT use <code>postback</code> (except for a form <code>"submit"</code>). <code>MVC</code> relies on <code>JQUERY</code> to manage the page on the client side (thus bypassing the need for a lot of <code>postback</code> messages to the server).</p>
<p>So:
<code>.NET</code> Web Forms... use <code>"runat"</code> attribute a lot in the page markup.</p>
<p><code>.NET</code> <code>MVC</code> hardly ever uses <code>"runat"</code> attribute in the page markup.</p>
<p>Hope this helps clarify why <code>runat</code> is necessary...</p>
| 39,096
|
<p>If you were the administrator of an Apache web server, what protocol(s) would you prefer to provide, for the web developers to upload static files (html/gif/css/...), with the goal of maximum security ?<br>
If you were the web developer/graphic designer, what protocols would you prefer to be available at the Apache server, to upload static files ?</p>
|
<p>SCP is what I'd go with.</p>
<p>You can even use Filezilla for it and pretend it's unsecure FTP: <a href="http://filezilla-project.org/" rel="nofollow noreferrer">http://filezilla-project.org/</a></p>
|
<p>I use ssh config to limit users to sftp on a development server then use version control to review the changes and move them to production with got format-patch</p>
| 15,858
|
<p>As JavaScript frameworks like jQuery make client side web applications richer and more functional, I've started to notice one problem...</p>
<p><strong>How in the world do you keep this organized?</strong></p>
<ul>
<li>Put all your handlers in one spot and write functions for all the events?</li>
<li>Create function/classes to wrap all your functionality?</li>
<li>Write like crazy and just hope it works out for the best?</li>
<li>Give up and get a new career?</li>
</ul>
<p>I mention jQuery, but it's really any JavaScript code in general. I'm finding that as lines upon lines begin to pile up, it gets harder to manage the script files or find what you are looking for. Quite possibly the biggest propblems I've found is there are so many ways to do the same thing, it's hard to know which one is the current commonly accepted best practice.</p>
<p>Are there any general recommendations on the best way to keep your <strong>.js</strong> files as nice and neat as the rest of your application? Or is this just a matter of IDE? Is there a better option out there?</p>
<hr>
<p><strong>EDIT</strong></p>
<p>This question was intended to be more about code organization and not file organization. There has been some really good examples of merging files or splitting content around.</p>
<p>My question is: what is the current commonly accepted best practice way to organize your actual code? What is your way, or even a recommended way to interact with page elements and create reuseable code that doesn't conflict with each other?</p>
<p>Some people have listed <strong>namespaces</strong> which is a good idea. What are some other ways, more specifically dealing with elements on the page and keeping the code organized and neat?</p>
|
<p>It would be a lot nicer if javascript had namespaces built in, but I find that organizing things like Dustin Diaz describes <a href="http://www.dustindiaz.com/namespace-your-javascript/" rel="noreferrer">here</a> helps me a lot. </p>
<pre><code>var DED = (function() {
var private_var;
function private_method()
{
// do stuff here
}
return {
method_1 : function()
{
// do stuff here
},
method_2 : function()
{
// do stuff here
}
};
})();
</code></pre>
<p>I put different "namespaces" and sometimes individual classes in separate files. Usually I start with one file and as a class or namespace gets big enough to warrant it, I separate it out into its own file. Using a tool to combine all you files for production is an excellent idea as well.</p>
|
<p>I use a custom script inspired by Ben Nolan's behaviour (I can't find a current link to this anymore, sadly) to store most of my event handlers. These event handlers are triggered by the elements className or Id, for example.
Example:</p>
<pre><code>Behaviour.register({
'a.delete-post': function(element) {
element.observe('click', function(event) { ... });
},
'a.anotherlink': function(element) {
element.observe('click', function(event) { ... });
}
});
</code></pre>
<p>I like to include most of my Javascript libraries on the fly, except the ones that contain global behaviour. I use <a href="http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.headscript" rel="nofollow noreferrer">Zend Framework's headScript() placeholder helper</a> for this, but you can also <a href="http://ajaxpatterns.org/On-Demand_Javascript" rel="nofollow noreferrer">use javascript to load other scripts on the fly</a> with <a href="http://ajile.iskitz.com/" rel="nofollow noreferrer">Ajile</a> for example.</p>
| 30,704
|
<p>I am developing a web application that contains a great deal of reporting. The reports are fairly basic, but some have multiple datasets or embedded charts. One of the key requirements is that each report can be exported to Excel. The Excel version of the report is disconnected and should look the same (or very similar) to the web report. That includes formmating of values, cell styles, number of rows/columns, charts, etc.</p>
<p>The problem I've encountered is that the ASP.Net reporting tools I've looked at do a great job in creating the report, but the export to Excel is not as robust as I'd like. The ASP.Net spreadsheet tools do a great job generating an Excel sheet, but they don't offer a way to view the information in a browser without downloading them locally and viewing them in Excel.</p>
<p>Any suggestions? Thanks!</p>
|
<p>MS Reporting Services that comes with SQL server produces pretty high fidelity Excel spreadsheets.</p>
<p>Otherwise you could do this with MOSS Enterprise using Excel Services and the Excel Viewer web part.</p>
|
<p>If you only want to generate Excel documents which are just cell data and not charts you can use the XML markup for Excel, no not the OpenXML spec version but the standard Microsoft Excel XML format.</p>
<p>I've got an example of how to achieve that on my blog: <a href="http://www.aaron-powell.com/blog.aspx?id=1237" rel="nofollow noreferrer">http://www.aaron-powell.com/blog.aspx?id=1237</a>. If you do want to do charting I'm not 100% sure if it's supported that way.</p>
| 29,229
|
<p>I own an Ender 3, it's about 3 years old and the issues I have with extrusion, leaking and filament blockage are monstrous.</p>
<p>Examples of problems like this are filament flow issues, filament blockage, and filament leaking out of the sides.</p>
<p>Problems like this take all day to fix, and in the end, they are never really fixed. Everything is so overbearingly finicky.</p>
<p>Not only that, but it seems one of its parts breaks down about every week (this may just be due to its age but I thought I would note it.)</p>
<p>It seems I run into the exact same problems every single time I 3D print. Nothing ever seems to go right. I am getting really tired of it, and I'm wondering if these kinds of problems aren't so frequent/ as big of a deal with more expensive (better) 3D printers, or if this is just normal.</p>
|
<p>No not at all. The only way to eliminate issues is to practice and break things and learning how to fix it. I have 2 CR-10s, 1 CR-10S5, 1 CR-10 MINI, and 2 Anycubic Photons. They are all heavily modified, and the one thing i learned is that modifications only add to the problems</p>
|
<p>I use a German RepRap printer, which is very expensive compared to many of the printers in the questions on this list. I still see similar printing issues on a RepRap to other printers. The settings often control the issues. The RepRap however has a much larger print area that most of the printers referred to on this list.</p>
| 2,052
|
<p>Does anyone know if it's possible to open a file in the file system via a link in a WebBrowser component? I'm writing a little reporting tool in which I display a summary as HTML in a WebBrowser component with a link to a more detailed analysis which is saved as an Excel file on disk. </p>
<p>I want the user to be able to click that link within the web-browser (currently just a standard href tag with file://path.xls as the target) and get a prompt to open the file.
If I open my page in IE, this works, but in the WebBrowser control (C# Windows Forms, .Net 2.0) nothing happens.</p>
<p>I don't know if I need some additional permissions/trust or somesuch - has anyone done this successfully or could anyone suggest how to debug this?</p>
|
<p>I also tested Ross's solution and it worked for me too.</p>
<p>But here's another approach, instead of using the built-in functionality that popups a dialog box asking you to download, open or cancel the download, you can use your own C# code in your application (not the HTML page) to directly open the file (or maybe do something else).</p>
<p>As per <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.objectforscripting.aspx" rel="nofollow noreferrer">Microsoft MSDN</a> example:</p>
<pre><code>using System;
using System.Windows.Forms;
using System.Security.Permissions;
[PermissionSet(SecurityAction.Demand, Name="FullTrust")]
[System.Runtime.InteropServices.ComVisibleAttribute(true)]
public class Form1 : Form
{
private WebBrowser webBrowser1 = new WebBrowser();
private Button button1 = new Button();
[STAThread]
public static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
public Form1()
{
button1.Text = "call script code from client code";
button1.Dock = DockStyle.Top;
button1.Click += new EventHandler(button1_Click);
webBrowser1.Dock = DockStyle.Fill;
Controls.Add(webBrowser1);
Controls.Add(button1);
Load += new EventHandler(Form1_Load);
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.AllowWebBrowserDrop = false;
webBrowser1.IsWebBrowserContextMenuEnabled = false;
webBrowser1.WebBrowserShortcutsEnabled = false;
webBrowser1.ObjectForScripting = this;
// Uncomment the following line when you are finished debugging.
//webBrowser1.ScriptErrorsSuppressed = true;
webBrowser1.DocumentText =
"<html><head><script>" +
"function test(message) { alert(message); }" +
"</script></head><body><button " +
"onclick=\"window.external.Test('called from script code')\">" +
"call client code from script code</button>" +
"</body></html>";
}
public void Test(String message)
{
MessageBox.Show(message, "client code");
}
private void button1_Click(object sender, EventArgs e)
{
webBrowser1.Document.InvokeScript("test",
new String[] { "called from client code" });
}
}
</code></pre>
|
<p>I just tried this with a link that looks like
<a href="file:///C:\temp\browsertest\bin\Debug\testing.xls">Test</a></p>
<p>and it worked as expected. </p>
<p>Are you specifying the full path to the xls?</p>
| 42,155
|
<p>I've only been able to find two thus far, namely <a href="http://tinyradius.sourceforge.net/" rel="nofollow noreferrer">TinyRadius</a>, which itself discourages production use and <a href="http://www.axlradius.com/" rel="nofollow noreferrer">AXL</a>, which is pay-only.</p>
<p><a href="http://coova.org/wiki/index.php/JRadius" rel="nofollow noreferrer">JRadius</a> seems tied to <a href="http://freeradius.org/" rel="nofollow noreferrer">FreeRADIUS</a>, which isn't a library and will need a lot of cajoling to function like one.</p>
|
<p>List from <a href="http://freeradius.org/related/opensource.html" rel="nofollow noreferrer">http://freeradius.org/related/opensource.html</a> (not copying the descriptions because the page says it's copyright <em>rolleyes</em>):</p>
<p>Cistron - <a href="http://www.radius.cistron.nl/" rel="nofollow noreferrer">http://www.radius.cistron.nl/</a></p>
<p>GNU Radius - <a href="http://www.gnu.org/software/radius/" rel="nofollow noreferrer">http://www.gnu.org/software/radius/</a></p>
<p>FreeRADIUS - <a href="http://freeradius.org/" rel="nofollow noreferrer">http://freeradius.org/</a></p>
<p>JRadius - <a href="http://www.coova.org/JRadius" rel="nofollow noreferrer">http://www.coova.org/JRadius</a></p>
<p>ICRADIUS - <a href="http://www.icradius.org/" rel="nofollow noreferrer">http://www.icradius.org/</a></p>
<p>OpenRADIUS - <a href="http://www.openradius.net/" rel="nofollow noreferrer">http://www.openradius.net/</a></p>
<p>XtRADIUS - <a href="http://xtradius.sourceforge.net/" rel="nofollow noreferrer">http://xtradius.sourceforge.net/</a></p>
<p>YARD RADIUS - <a href="http://sourceforge.net/projects/yardradius" rel="nofollow noreferrer">http://sourceforge.net/projects/yardradius</a></p>
|
<p>The Apache Directory project (<a href="http://directory.apache.org" rel="nofollow">http://directory.apache.org</a>) is looking into this as people are intending to donate some java code. If and when this is successfully concluded, we (the Directory community) will most probably start a sub project and build a community to further this code into a full-fledged java based Open Source Radius server.</p>
| 10,182
|
<p>Is it doable to set up a non-domain-based (standalone) Windows Server 2008 as an SSTP VPN (Secure Socket Layer Tunneling Protocol VPN)?</p>
<p>I'd like to enable remote users to access a network via SSL-based VPN (currently using PPTP) by making an SSTP VPN connection via a Win2k8 server. Most of the docs seem to include running in an AD domain with an in-house Certificate Authority to enable this feature.</p>
<p>Is it possible to do this with a stand-alone Win2k8 server? If so, how?</p>
|
<p>you connect with host address for sstp. you can use standard web certificate from any ssl cert provider. that host address need to resolve to your vpn server. </p>
<p>step-by-step guide
<a href="http://www.windowsecurity.com/articles/Configuring-Windows-Server-2008-Remote-Access-SSL-VPN-Server-Part2.html" rel="nofollow noreferrer">http://www.windowsecurity.com/articles/Configuring-Windows-Server-2008-Remote-Access-SSL-VPN-Server-Part2.html</a></p>
|
<p>My understanding is that the certificate used as part of the authentication hasto come from Active Directory Certificate Services, and there is no way to get it from any other source (I'll admit to not trying too hard to figure out if it was possible, I was investigating SSTP for another VPN related project)</p>
<p>Setting up the 2008 server as a standalone AD controller would get around the issue; the client systems don't need to be in the domain. </p>
| 14,139
|
<p>This is only happening on the live server. On multiply development servers the image is being created as expected.</p>
<p>LIVE:
Red Hat</p>
<pre><code>$ php --version
PHP 5.2.6 (cli) (built: May 16 2008 21:56:34)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
</code></pre>
<p>GD Support => enabled
GD Version => bundled (2.0.34 compatible)</p>
<p>DEV:
Ubuntu 8</p>
<pre><code>$ php --version
PHP 5.2.4-2ubuntu5.3 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 23 2008 06:44:49)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
</code></pre>
<p>GD Support => enabled
GD Version => 2.0 or higher</p>
<pre><code><?php
$image = imagecreatetruecolor($width, $height);
// Colors in RGB
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
imagefilledrectangle($image, 0, 0, $width, $height, $white);
imagettftext($image, $fontSize, 0, 0, 50, $black, $font, $text);
imagegif($image, $file_path);
?>
</code></pre>
<p>In a perfect world I would like the live server and the dev server to be running the same distro, but the live server must be Red Hat. </p>
<p>My question is does anyone know the specific differences that would cause the right most part of an image to be cut off using the bundled version of GD?</p>
<p>EDIT: I am not running out of memory. There are no errors being generated in the logs files. As far as php is concerned the image is being generated correctly. That is why I believe it to be a GD specific problem with the bundled version.</p>
|
<p>Maybe you are running out of memory or something similar? Did you double check all logfiles, etc.? </p>
|
<p>Is it 100% consistent and always at the same place? If not, it might be a resource issue -- time to execute the script or memory limitation. Try tweaking the php.ini settings, rebooting web server, testing. </p>
| 15,685
|
<p>Derik Whitaker posted an <a href="http://devlicio.us/blogs/derik_whittaker/archive/2008/10/22/how-is-interacting-with-your-data-repository-in-your-controller-different-or-better-than-doing-it-in-your-code-behind.aspx" rel="noreferrer">article</a> a couple of days ago that hit a point that I've been curious about for some time: <strong>should business logic exist in controllers?</strong></p>
<p>So far all the ASP.NET MVC demos I've seen put repository access and business logic in the controller. Some even throw validation in there as well. This results in fairly large, bloated controllers. Is this really the way to use the MVC framework? It seems that this is just going to end up with a lot of duplicated code and logic spread out across different controllers.</p>
|
<p>Business logic should really be in the model. You should be aiming for fat models, skinny controllers.</p>
<p>For example, instead of having:</p>
<pre><code>public interface IOrderService{
int CalculateTotal(Order order);
}
</code></pre>
<p>I would rather have:</p>
<pre><code>public class Order{
int CalculateTotal(ITaxService service){...}
}
</code></pre>
<p>This assumes that tax is calculate by an external service, and requires your model to know about interfaces to your external services.</p>
<p>This would make your controller look something like:</p>
<pre><code>public class OrdersController{
public OrdersController(ITaxService taxService, IOrdersRepository ordersRepository){...}
public void Show(int id){
ViewData["OrderTotal"] = ordersRepository.LoadOrder(id).CalculateTotal(taxService);
}
}
</code></pre>
<p>Or something like that.</p>
|
<p>If u use Dependency Injectors your business logic will go to them and hence you will get neat and clean controllers.</p>
| 29,113
|
<p>I've created a generic lookless control with virtual property:</p>
<pre><code>public abstract class TestControlBase<TValue> : Control
{
public static readonly DependencyProperty ValueProperty;
static TestControlBase()
{
ValueProperty = DependencyProperty.Register("Value", typeof(TValue),
typeof(TestControlBase<TValue>));
}
protected TestControlBase()
{
Focusable = false;
Value = default(TValue);
}
public virtual TValue Value
{
get
{
return (TValue)GetValue(ValueProperty);
}
set
{
SetValue(ValueProperty, value);
}
}
}
</code></pre>
<p>Then I've made a control derived from it and overrided Value property:</p>
<pre><code>public class TestControl : TestControlBase<int>
{
public override int Value
{
get
{
return base.Value;
}
set
{
base.Value = value;
}
}
}
</code></pre>
<p>So I use it in a Window XAML:</p>
<pre><code> <TestControls:TestControl />
</code></pre>
<p>When I open window in designer all is OK, but when I put mouse cursor to this line, or to this control in designer I receive exception:</p>
<pre><code>Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
Ambiguous match found.
at System.RuntimeType.GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
at System.Type.GetProperty(String name)
at MS.Internal.ComponentModel.DependencyPropertyKind.get_IsDirect()
at MS.Internal.ComponentModel.DependencyPropertyKind.get_IsAttached()
at MS.Internal.ComponentModel.APCustomTypeDescriptor.GetProperties(Attribute[] attributes)
at MS.Internal.ComponentModel.APCustomTypeDescriptor.GetProperties()
at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultExtendedTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties()
at System.ComponentModel.TypeDescriptor.GetPropertiesImpl(Object component, Attribute[] attributes, Boolean noCustomTypeDesc, Boolean noAttributes)
at System.ComponentModel.TypeDescriptor.GetProperties(Object component)
at MS.Internal.Model.ModelPropertyCollectionImpl.GetProperties(String propertyNameHint)
at MS.Internal.Model.ModelPropertyCollectionImpl.<GetEnumerator>d__0.MoveNext()
at MS.Internal.Designer.PropertyEditing.Model.ModelPropertyMerger.<GetFirstProperties>d__0.MoveNext()
at MS.Internal.Designer.PropertyEditing.PropertyInspector.UpdateCategories(Selection selection)
at MS.Internal.Designer.PropertyEditing.PropertyInspector.OnSelectionChangedIdle()
</code></pre>
<p>Who know this problem? Please explain :) I have no ideas except that WPF Designer doesn't like generics. If I replace generics by <code>Object</code> all is OK.</p>
|
<p>Ivan,</p>
<p>Maybe the answer is a little bit late to you but other people can use it too.
I had the same problem and got very disappointed when I read that this is a bug. But after some googleing I found a <a href="http://jamescrisp.org/2008/05/26/wpf-control-inheritance-with-generics/" rel="nofollow noreferrer">blog</a> that shows a way to use this kind of inheritance. It seems that the problem is solved including some properties in the xaml.
I hope it helps.</p>
|
<p>I think there is nothing you can do. It's just a bug. Same thing happens when developing WF controls.</p>
<p>My colleague from work who is developing windows forms controls makes second control which is not generic. It's just a workaround but it works. If you want to work in designer just comment generic (<>), after your work is done, uncomment it.</p>
<p>I hope it will help you :)</p>
| 49,430
|
<p>In a macro for Visual Studio 6, I wanted to run an external program, so I typed:</p>
<pre><code>shell("p4 open " + ActiveDocument.FullName)
</code></pre>
<p>Which gave me a type mismatch runtime error. What I ended up having to type was this:</p>
<pre><code>Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
strResult = wshShell.Run("p4 open " + ActiveDocument.FullName)
</code></pre>
<p>What is going on here? Is that nonsense really necessary or have I missed something?</p>
|
<p>As <a href="https://stackoverflow.com/questions/20272/why-doesnt-shell-work-in-vbscript-in-vs6#20304">lassevk</a> pointed out, VBScript is not Visual Basic.</p>
<p>I believe the only built in object in VBScript is the WScript object.</p>
<pre><code>WScript.Echo "Hello, World!"
</code></pre>
<p>From the docs</p>
<blockquote>
<p>The WScript object is the root object of the Windows Script Host
object model hierarchy. It never needs to be instantiated before invoking its
properties and methods, and it is always available from any script file.</p>
</blockquote>
<p>Everything else must be created via the CreateObject call. Some of those objects are <a href="http://msdn.microsoft.com/en-us/library/f51wc7hz(VS.85).aspx" rel="nofollow noreferrer">listed here</a>.</p>
<p>The Shell object is one of the <em>other</em> objects that you need to create if you want to call methods on it.</p>
<p>One caveat, is that RegExp is <em>sort of</em> built in, in that you can instantiate a RegExp object like so in VBScript:</p>
<pre><code>Dim r as New RegExp
</code></pre>
|
<p>VB6 uses & to concatenate strings rather than +, and you'll want to make sure the file name is encased in quotes in case of spaces. Try it like this: </p>
<pre><code>Shell "p4 open """ & ActiveDocument.FullName & """"
</code></pre>
| 4,064
|
<p>I have a web service in C# that I have deployed on IIS 6.0. I want to view the data going out and coming to this web service.</p>
<p>I know about MS SOAP toolkit, but it seems to be deprecated by MS. Does anyone know about any other good tool other than MS soap toolkit. I cannot afford to spend money on any tool, so I need FREE tools if any.</p>
|
<p>You can use <a href="http://www.wireshark.org/" rel="nofollow noreferrer">wireshark</a> to analyze your network traffic.</p>
<p>And you can also use <a href="http://www.soapui.org/" rel="nofollow noreferrer">SoapUI</a> to send SOAP Commands to your webservice.</p>
|
<p>It is not clear (to me) from your question, whether this is a one time debugging exercise you are after or a logging-style solution for your app. </p>
<p>For the former I use either <a href="http://irg.cs.ohiou.edu/software/tcptrace/download.html" rel="nofollow noreferrer">TCPTrace</a> (free) or <a href="http://www.ieinspector.com/httpanalyzer/" rel="nofollow noreferrer">HttpAnalyzer</a> </p>
| 47,270
|
<p>Is it possible with the wmd editor to add a button to let the user upload an image to the web server and place the corresponding img markdown in the textbox? If not, will another good inplace editor do it? Context: I'm using asp.net mvc, C# and I am a true beginner with javascript.</p>
|
<p>A brief perusal of the <a href="http://wmd-editor.com/features" rel="nofollow noreferrer">WMD</a> seems to indicate that this feature is not supported directly and that the control is not particularly pluggable.</p>
<p>That being said, there's nothing stopping you from creating a button/upload-field/whatever that sends an image to your servers and injects the appropriate:</p>
<pre><code><img src="http://your.server.com/path/to/attachments/..." />
</code></pre>
<p>Into the control's underlying textarea.</p>
|
<p>I wrote a <a href="http://jordanarseno.com/blog/8/uploading-images-with-wmd-editor" rel="nofollow">blog post</a> that explains how I solved this. In the post, I use PHP - if you're comfortable converting my PHP logic into ASP.NET, you may find it helpful!</p>
| 49,122
|
<p>I have the occasion to produce Drupal web sites using development, staging, and production environments. Keeping the code in sync between the sites is a simple task using subversion. What is not so simple is propagating changes to the database data (not just the schema) between installations.</p>
<p>The reason for this will be familiar to any Drupal developer. Drupal stores certain configuration settings in the database, specifically related to CCK fields, Views, and other modules that allow things to be set dynamically using the admin interface. Simply syncing the schema isn't enough - essential information is also in the data.</p>
<p>What I'm looking for is a way to sync these database changes so that if one developer makes CCK field changes on the staging server, they can be propagated down to local development environments for more work, and eventually up to the production environment.</p>
<p>Is there a tool that will do this? What is your process for handling single or multiple developers on a project like this?</p>
|
<p>For basic data sync: I use mysqldump to dump all data to a .sql file on a nightly basis. The script then checks it in to the version control system. This is cronned up in a simple bash script but you could do something similar on almost any platform...</p>
<p>I've just read a little further and I'm not sure if my method will help. I've never had to merge a SQL dump so I can't comment on how effectively it is managed.</p>
<p>While you should be able to push changes out (schema, new data) to the staging/production server, you might have more hassle pulling changes back into dev. As I say - merging may or may not be possible. I just don't know.</p>
|
<p>Use database versioning system. For this you need a VersionInfo table in the database and all of your sql ddl and dml queries in xml format along with version info. Now you only a simple .net tool which will check the VersionInfo table and run all the queries from xml which are added after that version and update the version to current in versionInfo.</p>
| 41,545
|
<p>I am uploading multiple files using the BeginGetRequestStream of HttpWebRequest but I want to update the progress control I have written whilst I post up the data stream. </p>
<p>How should this be done, I have tried calling Dispatch.BeginInvoke (as below) from within the loop that pushes the data into the stream but it locks the browser until its finished so it seems to be in some sort of worker/ui thread deadlock. </p>
<p>This is a code snippet of pretty much what I am doing:</p>
<pre><code>class RequestState
{
public HttpWebRequest request; // holds the request
public FileDialogFileInfo file; // store our file stream data
public RequestState( HttpWebRequest request, FileDialogFileInfo file )
{
this.request = request;
this.file = file;
}
}
private void UploadFile( FileDialogFileInfo file )
{
UriBuilder ub = new UriBuilder( app.receiverURL );
ub.Query = string.Format( "filename={0}", file.Name );
// Open the selected file to read.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create( ub.Uri );
request.Method = "POST";
RequestState state = new RequestState( request, file );
request.BeginGetRequestStream( new AsyncCallback( OnUploadReadCallback ), state );
}
private void OnUploadReadCallback( IAsyncResult asynchronousResult )
{
RequestState state = (RequestState)asynchronousResult.AsyncState;
HttpWebRequest request = (HttpWebRequest)state.request;
Stream postStream = request.EndGetRequestStream( asynchronousResult );
PushData( state.file, postStream );
postStream.Close();
state.request.BeginGetResponse( new AsyncCallback( OnUploadResponseCallback ), state.request );
}
private void PushData( FileDialogFileInfo file, Stream output )
{
byte[] buffer = new byte[ 4096 ];
int bytesRead = 0;
Stream input = file.OpenRead();
while( ( bytesRead = input.Read( buffer, 0, buffer.Length ) ) != 0 )
{
output.Write( buffer, 0, bytesRead );
bytesReadTotal += bytesRead;
App app = App.Current as App;
int totalPercentage = Convert.ToInt32( ( bytesReadTotal / app.totalBytesToUpload ) * 100 );
// enabling the following locks up my UI and browser
Dispatcher.BeginInvoke( () =>
{
this.ProgressBarWithPercentage.Percentage = totalPercentage;
} );
}
}
</code></pre>
|
<p>I was going to say that, I didn't think that Silverlight 2's HttpWebRequest supported streaming, because the request data gets buffered into memory entirely. It had been a while since the last time I looked at it though, therefore I went back to see if Beta 2 supported it. Well turns out it does. I am glad I went back and read before stating that. You can enable it by setting AllowReadStreamBuffering to false. Did you set this property on your HttpWebRequest? That could be causing your block.</p>
<ul>
<li><a href="http://shrinkster.com/11cn" rel="nofollow noreferrer">MSDN Reference</a></li>
<li><a href="http://www.wilcob.com/Wilco/View.aspx?NewsID=212" rel="nofollow noreferrer">File upload component for Silverlight and ASP.NET</a></li>
</ul>
<p>Edit, found another reference for you. You may want to follow this approach by breaking the file into chunks. This was written last March, therefore I am not sure if it will work in Beta 2 or not.</p>
|
<p>Thanks for that, I will take a look at those links, I was considering chunking my data anyway, seems to be the only way I can get any reasonable progress reports out of it.</p>
| 3,421
|
<p>I am building a physics simulation engine and editor in Windows. I want to build the editor part using Qt and I want to run the engine using SDL with OpenGL.</p>
<p>My first idea was to build the editor using only Qt and share as much code with the engine (the resource manager, the renderer, the maths). But, I would also like to be able to run the simulation inside the editor. <strong>This means I also have to share the simulation code which uses SDL threads.</strong></p>
<p>So, my question is this: Is there a way to have an the render OpenGL to a Qt window by using SDL?</p>
<p>I have read on the web that it might be possible to supply SDL with a window handle in which to render. Anybody has experience dong that?</p>
<p>Also, the threaded part of the simulator might pose a problem since it uses SDL threads.</p>
|
<p>This is a simplification of what I do in my project. You can use it just like an ordinary widget, but as you need, you can using it's m_Screen object to draw to the SDL surface and it'll show in the widget :)</p>
<pre><code>#include "SDL.h"
#include <QWidget>
class SDLVideo : public QWidget {
Q_OBJECT
public:
SDLVideo(QWidget *parent = 0, Qt::WindowFlags f = 0) : QWidget(parent, f), m_Screen(0){
setAttribute(Qt::WA_PaintOnScreen);
setUpdatesEnabled(false);
// Set the new video mode with the new window size
char variable[64];
snprintf(variable, sizeof(variable), "SDL_WINDOWID=0x%lx", winId());
putenv(variable);
SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
// initialize default Video
if((SDL_Init(SDL_INIT_VIDEO) == -1)) {
std:cerr << "Could not initialize SDL: " << SDL_GetError() << std::endl;
}
m_Screen = SDL_SetVideoMode(640, 480, 8, SDL_HWSURFACE | SDL_DOUBLEBUF);
if (m_Screen == 0) {
std::cerr << "Couldn't set video mode: " << SDL_GetError() << std::endl;
}
}
virtual ~SDLVideo() {
if(SDL_WasInit(SDL_INIT_VIDEO) != 0) {
SDL_QuitSubSystem(SDL_INIT_VIDEO);
m_Screen = 0;
}
}
private:
SDL_Surface *m_Screen;
};
</code></pre>
<p>Hope this helps</p>
<p>Note: It usually makes sense to set both the min and max size of this widget to the SDL surface size.</p>
|
<p>Rendering onto opengl from QT is trivial (and works very well)
No direct experience of SDL but there is an example app here about mixing them.
<a href="http://www.devolution.com/pipermail/sdl/2003-January/051805.html" rel="nofollow noreferrer">http://www.devolution.com/pipermail/sdl/2003-January/051805.html</a></p>
<p>There is a good article about mixing QT widgewts directly with the opengl here
<a href="http://doc.trolltech.com/qq/qq26-openglcanvas.html" rel="nofollow noreferrer">http://doc.trolltech.com/qq/qq26-openglcanvas.html</a> a bit beyond what you strictly need but rather clever!</p>
| 14,448
|
<p>I need to construct some rather simple SQL, I suppose, but as it's a rare event that I work with DBs these days I can't figure out the details.</p>
<p>I have a table 'posts' with the following columns:</p>
<blockquote>
<p>id, caption, text</p>
</blockquote>
<p>and a table 'comments' with the following columns:</p>
<blockquote>
<p>id, name, text, post_id</p>
</blockquote>
<p>What would the (single) SQL statement look like which retrieves the captions of all posts which have one or more comments associated with it through the 'post_id' key? The DBMS is MySQL if it has any relevance for the SQL query.</p>
|
<pre>select p.caption, count(c.id)
from posts p join comments c on p.id = c.post_id
group by p.caption
having count (c.id) > 0</pre>
|
<p>You're basically looking at performing a subquery --</p>
<p><code>SELECT p.caption FROM posts p WHERE (SELECT COUNT(*) FROM comments c WHERE c.post_id=p.id) > 1;</code></p>
<p>This has the effect of running the <code>SELECT COUNT(*)</code> subquery for each row in the posts table. Depending on the size of your tables, you might consider adding an additional column, <code>comment_count</code>, into your <code>posts</code> table to store the number of corresponding <code>comments</code>, such that you can simply do</p>
<p><code>SELECT p.caption FROM posts p WHERE comment_count > 1</code></p>
| 36,750
|
<p>I'm hearing about a lot of companies that act like they're agile but the only agile thing they do is the Scrum process. Is this enough to be considered agile? Using Scrum alone seems like the perfect excuse for a bad manager to get more meetings more often. Should I be weary of such companies?</p>
|
<p>Agile is a big, vague concept. Lots of things are Agile.</p>
<p>Scrum is a specific set of techniques for doing sprints and releases. It's agile because it fits the Agile Manifesto.</p>
<p>There are lots of other specific Agile techniques (all of the xDD's, for example.)</p>
<p>When in doubt, compare the companies actual practices against the <a href="http://agilemanifesto.org/" rel="nofollow noreferrer">Agile Manifesto</a>. </p>
|
<p>Scrum provides you with a framework to fix/improve your development process. It should be considered as a starting point to "<a href="http://www.hans-eric.com/2007/08/13/is-your-team-jelled/" rel="nofollow noreferrer">jelled team</a>" and more productive team. Most likely you will go beyond standard Scrum practices soon, but as a starting point it has some attractive properties:</p>
<ol>
<li>It is very easy to understand</li>
<li>It can be applied to almost any project and team</li>
<li>There are quite many people who make money and help companies with Scrum adoption</li>
</ol>
<p>Also there it is <a href="http://www.targetprocess.com/blog/2008/10/agile-development-future-will-lean.html" rel="nofollow noreferrer">really not so important to know whether Scrum = agile</a>. It is better to focus on better productivity and do not bother yourself with such questions.</p>
| 20,421
|
<p>Right now my ant task looks like.</p>
<pre><code><javadoc sourcepath="${source}" destdir="${doc}">
<link href="http://java.sun.com/j2se/1.5.0/docs/api/" />
</javadoc>
</code></pre>
<p>And I'm getting this warning:</p>
<pre><code>javadoc: warning - Error fetching URL: http://java.sun.com/j2se/1.5.0/docs/api/package-list
</code></pre>
<p>How do I get the javadoc to properly link to the API? I am behind a proxy.</p>
|
<p>You probably need the <a href="http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html" rel="noreferrer">http.proxyHost and http.proxyPort system properties</a> set. For example, <code>ANT_OPTS="-Dhttp.proxyHost=proxy.y.com" ant doc</code></p>
<p>Alternatively, you could set the "offline" flag and provide a package list, but that could be a pain for the Java core.</p>
|
<p>You can also use the "offline" mode that allows you to build (faster!) without accessing the internet. Please see this answer: <a href="https://stackoverflow.com/a/24089805/366749">https://stackoverflow.com/a/24089805/366749</a></p>
| 7,631
|
<p>I want to write a function that takes an array of letters as an argument and a number of those letters to select. </p>
<p>Say you provide an array of 8 letters and want to select 3 letters from that. Then you should get:</p>
<pre><code>8! / ((8 - 3)! * 3!) = 56
</code></pre>
<p>Arrays (or words) in return consisting of 3 letters each.</p>
|
<p><a href="http://portal.acm.org/citation.cfm?id=1036677&dl=&coll=" rel="noreferrer">Art of Computer Programming Volume 4: Fascicle 3</a> has a ton of these that might fit your particular situation better than how I describe.</p>
<h2>Gray Codes</h2>
<p>An issue that you will come across is of course memory and pretty quickly, you'll have problems by 20 elements in your set -- <sup>20</sup>C<sub>3</sub> = 1140. And if you want to iterate over the set it's best to use a modified gray code algorithm so you aren't holding all of them in memory. These generate the next combination from the previous and avoid repetitions. There are many of these for different uses. Do we want to maximize the differences between successive combinations? minimize? et cetera.</p>
<p>Some of the original papers describing gray codes:</p>
<ol>
<li><a href="http://portal.acm.org/citation.cfm?id=2422.322413" rel="noreferrer">Some Hamilton Paths and a Minimal Change Algorithm</a></li>
<li><a href="http://portal.acm.org/citation.cfm?id=49203&jmp=indexterms&coll=GUIDE&dl=GUIDE&CFID=81503149&CFTOKEN=96444237" rel="noreferrer">Adjacent Interchange Combination Generation Algorithm</a></li>
</ol>
<p>Here are some other papers covering the topic:</p>
<ol>
<li><a href="http://www.cs.uvic.ca/%7Eruskey/Publications/EHR/HoughRuskey.pdf" rel="noreferrer">An Efficient Implementation of the Eades, Hickey, Read Adjacent Interchange Combination Generation Algorithm</a> (PDF, with code in Pascal)</li>
<li><a href="http://portal.acm.org/citation.cfm?doid=355826.355830" rel="noreferrer">Combination Generators</a></li>
<li><a href="http://www4.ncsu.edu/%7Esavage/AVAILABLE_FOR_MAILING/survey.ps" rel="noreferrer">Survey of Combinatorial Gray Codes</a> (PostScript)</li>
<li><a href="https://link.springer.com/content/pdf/10.1007/BF02248780.pdf" rel="noreferrer">An Algorithm for Gray Codes</a></li>
</ol>
<h2>Chase's Twiddle (algorithm)</h2>
<p>Phillip J Chase, `<a href="http://portal.acm.org/citation.cfm?id=362502" rel="noreferrer">Algorithm 382: Combinations of M out of N Objects</a>' (1970)</p>
<p><a href="http://www.netlib.no/netlib/toms/382" rel="noreferrer">The algorithm in C</a>...</p>
<h2>Index of Combinations in Lexicographical Order (Buckles Algorithm 515)</h2>
<p>You can also reference a combination by its index (in lexicographical order). Realizing that the index should be some amount of change from right to left based on the index we can construct something that should recover a combination.</p>
<p>So, we have a set {1,2,3,4,5,6}... and we want three elements. Let's say {1,2,3} we can say that the difference between the elements is one and in order and minimal. {1,2,4} has one change and is lexicographically number 2. So the number of 'changes' in the last place accounts for one change in the lexicographical ordering. The second place, with one change {1,3,4} has one change but accounts for more change since it's in the second place (proportional to the number of elements in the original set).</p>
<p>The method I've described is a deconstruction, as it seems, from set to the index, we need to do the reverse – which is much trickier. This is how <a href="http://portal.acm.org/citation.cfm?id=355739" rel="noreferrer">Buckles</a> solves the problem. I wrote some <a href="https://stackoverflow.com/questions/561/using-combinations-of-sets-as-test-data#794">C to compute them</a>, with minor changes – I used the index of the sets rather than a number range to represent the set, so we are always working from 0...n.
Note:</p>
<ol>
<li>Since combinations are unordered, {1,3,2} = {1,2,3} --we order them to be lexicographical.</li>
<li>This method has an implicit 0 to start the set for the first difference.</li>
</ol>
<h2>Index of Combinations in Lexicographical Order (McCaffrey)</h2>
<p>There is <a href="https://web.archive.org/web/20170325012457/https://msdn.microsoft.com/en-us/library/aa289166.aspx" rel="noreferrer">another way</a>:, its concept is easier to grasp and program but it's without the optimizations of Buckles. Fortunately, it also does not produce duplicate combinations:</p>
<p>The set <a href="https://i.stack.imgur.com/Txetz.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/Txetz.gif" alt="x_k...x_1 in N" /></a> that maximizes <a href="https://i.stack.imgur.com/HOj5o.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/HOj5o.gif" alt="i = C(x_1,k) + C(x_2,k-1) + ... + C(x_k,1)" /></a>, where <a href="https://i.stack.imgur.com/vIeiI.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/vIeiI.gif" alt="C(n,r) = {n choose r}" /></a>.</p>
<p>For an example: <code>27 = C(6,4) + C(5,3) + C(2,2) + C(1,1)</code>. So, the 27th lexicographical combination of four things is: {1,2,5,6}, those are the indexes of whatever set you want to look at. Example below (OCaml), requires <code>choose</code> function, left to reader:</p>
<pre class="lang-fs prettyprint-override"><code>(* this will find the [x] combination of a [set] list when taking [k] elements *)
let combination_maccaffery set k x =
(* maximize function -- maximize a that is aCb *)
(* return largest c where c < i and choose(c,i) <= z *)
let rec maximize a b x =
if (choose a b ) <= x then a else maximize (a-1) b x
in
let rec iterate n x i = match i with
| 0 -> []
| i ->
let max = maximize n i x in
max :: iterate n (x - (choose max i)) (i-1)
in
if x < 0 then failwith "errors" else
let idxs = iterate (List.length set) x k in
List.map (List.nth set) (List.sort (-) idxs)
</code></pre>
<h2>A small and simple combinations iterator</h2>
<p>The following two algorithms are provided for didactic purposes. They implement an iterator and (a more general) folder overall combinations.
They are as fast as possible, having the complexity O(<sup>n</sup>C<sub>k</sub>). The memory consumption is bound by <code>k</code>.</p>
<p>We will start with the iterator, which will call a user provided function for each combination</p>
<pre class="lang-fs prettyprint-override"><code>let iter_combs n k f =
let rec iter v s j =
if j = k then f v
else for i = s to n - 1 do iter (i::v) (i+1) (j+1) done in
iter [] 0 0
</code></pre>
<p>A more general version will call the user provided function along with the state variable, starting from the initial state. Since we need to pass the state between different states we won't use the for-loop, but instead, use recursion,</p>
<pre class="lang-fs prettyprint-override"><code>let fold_combs n k f x =
let rec loop i s c x =
if i < n then
loop (i+1) s c @@
let c = i::c and s = s + 1 and i = i + 1 in
if s < k then loop i s c x else f c x
else x in
loop 0 0 [] x
</code></pre>
|
<p><a href="http://sss.chaoslab.ru/git/?p=misc.git;a=blob;f=main.cpp;h=a04b0db9b61ea67e4f5904702ca83481383ccb70;hb=080158c9c2eeb805eec9439cd01d0cb3e8c43d01" rel="nofollow">My implementation in c/c++</a></p>
<pre><code>#include <unistd.h>
#include <stdio.h>
#include <iconv.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int opt = -1, min_len = 0, max_len = 0;
char ofile[256], fchar[2], tchar[2];
ofile[0] = 0;
fchar[0] = 0;
tchar[0] = 0;
while((opt = getopt(argc, argv, "o:f:t:l:L:")) != -1)
{
switch(opt)
{
case 'o':
strncpy(ofile, optarg, 255);
break;
case 'f':
strncpy(fchar, optarg, 1);
break;
case 't':
strncpy(tchar, optarg, 1);
break;
case 'l':
min_len = atoi(optarg);
break;
case 'L':
max_len = atoi(optarg);
break;
default:
printf("usage: %s -oftlL\n\t-o output file\n\t-f from char\n\t-t to char\n\t-l min seq len\n\t-L max seq len", argv[0]);
}
}
if(max_len < 1)
{
printf("error, length must be more than 0\n");
return 1;
}
if(min_len > max_len)
{
printf("error, max length must be greater or equal min_length\n");
return 1;
}
if((int)fchar[0] > (int)tchar[0])
{
printf("error, invalid range specified\n");
return 1;
}
FILE *out = fopen(ofile, "w");
if(!out)
{
printf("failed to open input file with error: %s\n", strerror(errno));
return 1;
}
int cur_len = min_len;
while(cur_len <= max_len)
{
char buf[cur_len];
for(int i = 0; i < cur_len; i++)
buf[i] = fchar[0];
fwrite(buf, cur_len, 1, out);
fwrite("\n", 1, 1, out);
while(buf[0] != (tchar[0]+1))
{
while(buf[cur_len-1] < tchar[0])
{
(int)buf[cur_len-1]++;
fwrite(buf, cur_len, 1, out);
fwrite("\n", 1, 1, out);
}
if(cur_len < 2)
break;
if(buf[0] == tchar[0])
{
bool stop = true;
for(int i = 1; i < cur_len; i++)
{
if(buf[i] != tchar[0])
{
stop = false;
break;
}
}
if(stop)
break;
}
int u = cur_len-2;
for(; u>=0 && buf[u] >= tchar[0]; u--)
;
(int)buf[u]++;
for(int i = u+1; i < cur_len; i++)
buf[i] = fchar[0];
fwrite(buf, cur_len, 1, out);
fwrite("\n", 1, 1, out);
}
cur_len++;
}
fclose(out);
return 0;
}
</code></pre>
<p>here my implementation in c++, it write all combinations to specified files, but behaviour can be changed, i made in to generate various dictionaries, it accept min and max length and character range, currently only ansi supported, it enough for my needs</p>
| 15,544
|
<p>After asking <a href="https://stackoverflow.com/questions/186196/what-project-files-shouldnt-be-checked-into-svn">this question</a> I was advised not to check in binaries into subversion. My question is then what do I do with 3rd party dlls that are required to be in the bin folder? I need to be able checkout a working copy and have that run as a website with all dlls, etc intact.</p>
|
<p>The answers to your other question suggest you don't commit any <strong>generated</strong> files to subversion. DLLs in the bin folder are often built as part of the application, therefore, they should be regenerated rather than stored in subversion.</p>
<p>If the DLLs are 3rd party DLLs for which you don't have the source code then I would store them in subversion. You should put everything in subversion that is needed to recreate the application. That means your source code and 3rd party libraries or programs.</p>
|
<p>In fact SVN does stores binaries a lot more efficient than CVS, for more info see the <a href="http://subversion.tigris.org/faq.html#binary-files" rel="nofollow noreferrer">SVN-FAQ</a></p>
| 23,263
|
<p>A common argument against using .NET for high volume, transactional enterprise systems is that IIS does not compare to the likes of Weblogic and websphere for java. Is this true? Unfortunately for .NET web apps IIS is the only option as an application server. Does anyone have any arguments against this? I would like to promote .NET more in the enterprise and need some help putting my case forward.</p>
<p>Thanks</p>
|
<p>I've been coding ASP.NET for 6 years now and prior to getting into the field I was a network engineer. IMO, ASP.NET on IIS is faster out of the box than most of those other platforms. However, it's easy to screw up performance with mediocre programming skills, and it is possible that a highly tuned platform could beat a standard IIS configuration.</p>
<p>Honestly, I don't put much stock in the whole debate about which platform has the higher potential performance, because I've never had to address the issue, and I've developed sites which received upwards of 2-3 million hits an hour without hiccups.</p>
|
<p>Actually, running ASP.NET on Mono/Apache is starting to become popular.</p>
<p>Personally I stick to IIS because that's what I know, but if you are already a Linux shop I would recommend Mono without hesitation.</p>
| 42,489
|
<p>Our project uses Cruise Control to both build and hot deploy a web application to a remote server (via FTP) running Tomcat in the form of a .war file. Unfortunately, "hot" deploys don't appear to work properly, causing us to reboot Tomcat in response to each deployment. We would really like to do this auto-magically, much like the build itself. Is there an easy way to do this?</p>
<p>Side note: both machines are running Windows (XP or server, I think).</p>
<p>Side note 2: Performance doesn't really matter. This is an integration box.</p>
|
<p>if you have regularly scheduled builds you could easily put something in the cron like this</p>
<pre><code>crontab -e
</code></pre>
<p>then stop tomcat at say 1:30 am</p>
<pre><code>30 1 * * * ./path_to_tamcat/bin/catalina.sh stop
</code></pre>
<p>then start it up again 2 mins later</p>
<pre><code>32 1 * * * ./path_to_tamcat/bin/catalina.sh start
</code></pre>
<p>granted this isn't the best for irregular deployment, but you could easily have regular deployment with scheduled restart. </p>
|
<p>It sounds a bit to me like you are using the little Tomcat deployment manager thing. I basically have no experience with that, just so you know. That said, where I work we use two settings.</p>
<p>In the server.xml file, the context has the attribute <em>reloadable="true"</em>.</p>
<p>All we have to do is place the WAR file in the right spot and Tomcat unpacks it and reloads it, no problem.</p>
<p>Now when I looked it up, the <a href="http://tomcat.apache.org/tomcat-5.5-doc/config/context.html" rel="nofollow noreferrer">official configuration reference</a> says:</p>
<blockquote>
<p>"This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications."</p>
</blockquote>
<p>Like I said, we've never had problems. Our systems process a large number of requests and we don't seem to have a problem. We've never benchmarked the two configurations against each other though.</p>
<p>You might want to give it a try. At least you would learn if it is happy enough to reload things when done that way. You can check the performance as well to see if it's a problem for you.</p>
<p>I should note that every once in a while things just don't go right and we have to restart Tomcat anyway, but that's relatively rare.</p>
<p>If this works, all you need to do is have a script copy the WAR in the right spot and monitor to make sure things work. After enough deploys Tomcat will run out of permgen space, so you have to be aware that you might need to restart Tomcat by hand anyway.</p>
<p>Other random guesses:</p>
<ol>
<li>Are you FTPing directly into the final WAR location? Maybe Tomcat is just trying to open it too early?</li>
<li>Are you getting any kind of error message? Maybe that could help you track the problem down?</li>
<li>Have you tried other versions of Tomcat (if available to you)? Maybe 5.5 doesn't have the problem (or 5.0 if you're on 5.5)? Maybe just a newer point release?</li>
</ol>
| 13,072
|
<p>I am familiar with inserting text nodes after or before a given reference node. But, I would like to know how to insert a tag between text in a given node. For example, </p>
<pre><code>Before insertion: <p>Lorem dolor</p>
After insertion: <p>Lorem <span>ipsum</span> dolor</p>
</code></pre>
<p>The span node must be inserted after N characters (I don't need user's cursor selection position) within another another node. Is that possible?</p>
|
<p>You need to get the text into a variable then remove it from the DOM.
Split it, then insert the first part, then your span node then the second part.</p>
<pre><code>var p = document.getElementById('myParagraph');
var text = p.childNodes[0];
// Split the text
var len = 5
var text1 = text.nodeValue.substr(0, len);
var text2 = text.nodeValue.substr(len);
var span = document.createElement('span');
span.appendChild(document.createTextNode(' dolor'));
// Remove the existing text
p.removeChild(p.childNodes[0]);
// Put the new text in
p.appendChild(document.createTextNode(text1));
p.appendChild(span);
p.appendChild(document.createTextNode(text2));
</code></pre>
|
<p>You could check a nodes <code>innerHTML</code> property and modify that. Alternatively you might look at <code>childNodes</code> collection and work with elements there (deleting the old text node and inserting new nodes in its place).</p>
| 48,911
|
<p>Greetings!</p>
<p>I have some XML like this:</p>
<pre><code><Root>
<AlphaSection>
.
.
.
</AlphaSection>
<BetaSection>
<Choices>
<SetA>
<Choice id="choice1">
<Title>Choice 1 Title</Title>
<Body>Choice 1 Body</Body>
</Choice>
<Choice id="choice2">
<Title>Choice 2 Title</Title>
<Body>Choice 2 Body</Body>
</Choice>
</SetA>
<SetB>
<Choice id="choice3">
<Title>Choice 3 Title</Title>
<Body>Choice 3 Body</Body>
</Choice>
<Choice id="choice4">
<Title>Choice 4 Title</Title>
<Body>Choice 4 Body</Body>
</Choice>
</SetB>
</Choices>
</BetaSection>
<GammaSection>
.
.
.
</GammaSection>
</Root>
</code></pre>
<p>I'm currently doing the following to retrieve the ID of each choice:</p>
<pre><code>var choiceList = myXDoc.Root
.Element("BetaSection")
.Descendants("Choice")
.Select(element => new
{
ID = element.Attribute("id").Value,
// Title = ?
// Body = ?
});
</code></pre>
<p>I'd also like to get the values in the Title and Body child nodes of each Choice. How would I go about it? Thanks.</p>
|
<pre><code>element => new {
ID = element.Attribute("id").Value,
Title = element.Element("Title").Value,
Body = element.Element("Body").Value
});
</code></pre>
|
<p>Also XElement provides a bunch of typecast overloads so you do things like...</p>
<pre><code>element => new {
ID = (string)element.Attribute("id"),
title = (string)element.Element("Title"),
Body = (string)element.Element("Body")
});
</code></pre>
| 44,062
|
<p>I'd like to call caspol from within a script inside a custom action in
an msi (setup project). I'd prefer a standard msi to ClickOnce,
because with a standard msi I can install drivers & associate
filetypes with our application whereas with ClickOnce I can't.</p>
<p>When I execute the caspol command from the command line it succeeds,
but from within vbscript it always fails with the error "Fehler:
Unbekannte Mitgliedschaftsbedingung - -url.." - which translates as
"Error: Unknown membership condition: -url". To further clarify: A
copy & paste of the generated command works fine on the command line
directly on the local drive of a virgin virtual machine, as local
administrator, as part of a workgroup.</p>
<p>I have two ideas:
1. I'm no vbscript king, so maybe I've missed quotes or made some
other sort of syntax error.
2. Caspol recognises that I'm running it from within a script and
halts with an intentionally nonsensical error.</p>
<p>Personally, I believe it's just a dumb syntax error.</p>
<p>Here's my script:</p>
<pre><code>set sh = CreateObject("Wscript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
dim command
dim location
dim retVal
location = fso.GetFile(Wscript.ScriptFullName).ParentFolder
'%windir%\microsoft.net\framework\v2.0.50727\caspol.exe -pp off -m -addgroup 1 –url file://COMPUTER/SHARE/* FullTrust -name sbw2
command = fso.GetSpecialFolder(0) & "\microsoft.net\framework\v2.0.50727\caspol.exe -pp off -m -ag 1 –url file://"
for each s in Split(location, "\")
if Len(s) > 0 then
command = command & s & "/"
end if
next
command = command & "* FullTrust -name sbw2"
'DEBUG
'command = fso.GetSpecialFolder(0) & "\microsoft.net\framework\v2.0.50727\caspol.exe -m -ag 1 –url file://mjlaptop/sbw2/* FullTrust"
Wscript.StdOut.WriteLine VbClrf
Wscript.StdOut.WriteLine command
Wscript.StdOut.WriteLine VbClrf
Set output = sh.Exec(command)
dim text
while Not output.StdOut.AtEndOfStream
text = text & output.StdOut.Read(1)
Wend
Wscript.StdOut.WriteLine text
</code></pre>
<p>Thanks in advance,</p>
<p>Matt </p>
|
<p>What filetype do you do this in? And what is the output of ':set'?</p>
<p>If you copy your texts to an empty file, it formats it the way you want it. I have smartindent and autoindent enabled, so you could try that. (set si, set ai)</p>
|
<p>I had the same problem. I looked at my settings like this:</p>
<p>:set</p>
<p>I didn't have cindent set, but I did have smartindent. So, based on the above:</p>
<p>:set nosmartindent</p>
<p>Then the unwanted indentation on the last line (just as described above) was fixed. </p>
<p>Thanks for the help!</p>
| 37,718
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.