instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Does anyone know of a similar product to Citrix Server that'll run on the Mac OS?</p>
<p>Essentially, I'm looking to allow multiple remote users to log in to the same OSX Server at the same time (with full visual desktop, not SSH).</p>
| <p>OS X's Quartz window server has no remoting abilities, unlike <a href="http://en.wikipedia.org/wiki/Display_PostScript" rel="nofollow noreferrer">its predecessor</a>. X11 <em>does</em>, but 'native' OS X applications don't use that; of the few Mac apps typically run in X11 (such as GIMP or CrossOver), none are speci... | <p>John Vasileff,</p>
<p>Back to My Mac is a tunnelling / NAT traversal technique that enables the use of any networking (including VNC-based remote control). iChat screen sharing, Finder Screen Sharing and Remote Desktop all use VNC. Apple does not offer any non-VNC solutions.</p>
| 7,098 |
<p>I'm working on an app which scrapes data from a website and I was wondering how I should go about getting the data. Specifically I need data contained in a number of div tags which use a specific CSS class - Currently (for testing purposes) I'm just checking for </p>
<pre><code>div class = "classname"
</code></pre... | <p>Another library that might be useful for HTML processing is jsoup.
Jsoup tries to clean malformed HTML and allows html parsing in Java using jQuery like tag selector syntax.</p>
<p><a href="http://jsoup.org/">http://jsoup.org/</a> </p>
| <p>If your HTML is well-formed, you can easily employ an XML parser to do the job for you... If you're only reading, <a href="http://en.wikipedia.org/wiki/SAX" rel="nofollow noreferrer">SAX</a> would be ideal.</p>
| 29,446 |
<p>What does the "class" part of a template statement do?</p>
<p>Example:</p>
<pre><code>template <class T>
class Something
{
public:
Something(const T &something);
}
</code></pre>
<p>And what else can go there? I usually only see "class".</p>
| <p>The <code>class</code> keyword means the same thing as the <code>typename</code> keyword for the most part. They both indicates that T is a type.</p>
<p>The only difference between the keywords <code>class</code> and <code>typename</code> is that <code>class</code> can be used to provide class template template arg... | <p>You can also use the following as template arguments:</p>
<ul>
<li>any integral type <code>short, int, long, bool</code>, etc.
<li>pointers to objects or functions
<li>references to objects or functions
<li>pointers to member objects or member functions
</ul>
<p>A few examples:</p>
<pre><code>template<typename... | 45,373 |
<p>How would you store formatted blocks of text (line breaks, tabs, lists - etc.) in a database (nothing specific) to be displayed on the web (XHTML) while maintaining a level of abstraction so that the data can be used in other applications or if the structure of the website were to change in the future?</p>
| <p>This actually has very little to do with CodeIgniter and a lot with how mysql_fetch_assoc provides the query results.</p>
<p>The solution is that you should rename the columns inside the query using <code>"AS"</code>, e.g.</p>
<pre><code>select type_of_source.description as type_of_source_description, orig... | <p>I recommend not to use it that way instead, you can rename output columns with <code>AS</code>.</p>
| 22,659 |
<p>I'm loading a <strong><em>SQL Server 2000</em></strong> database into my new <strong><em>SQL Server 2005</em></strong> <strong><em>instance</em></strong>. <strong><em>As expected, the full-text catalogs don't come with it.</strong> <strong>How can I rebuild them?</em></strong></p>
<p>Right-clicking my full text cat... | <p>Try it using SQL.</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/ms189520%28SQL.90%29.aspx" rel="nofollow noreferrer">CREATE FULLTEXT CATALOG</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ms176095%28SQL.90%29.aspx" rel="nofollow noreferrer">ALTER FULLTEXT CATALOG</a></li>
</ul>
<p>He... | <p>Thanks, that helped because it showed what was wrong: My file paths were different. Here's how I fixed it:</p>
<p>1) Load database from SQL 2000 backup</p>
<p>2) Set compatibility mode to SQL 2005</p>
<pre><code>USE mydb
GO
ALTER DATABASE mydb SET COMPATIBILITY_LEVEL = 90
GO
</code></pre>
<p>3) Get the filegrou... | 7,016 |
<p>Is it possible to access the crash log over the application? The last.fm client showed me today a "we found a crash log" altert with the option to send it, so I think it must be possible.</p>
| <p>Here the description of the solution I found: <a href="http://www.restoroot.com/Blog/2008/10/18/crash-reporter-for-iphone-applications/" rel="nofollow noreferrer">Crash Reporter for iPhone Applications</a></p>
| <p>@stephen I think the poster was asking about an iPhone app finding a crash log without access to a Mac/PC…</p>
<p>And I think the answer is - this was possible on 2.0 - but Apple clamped down on 2.1 and now prevent your app from accessing the logs. :-(</p>
| 25,415 |
<p>I have good knowledge on C++ (not C) and recently bought a Symbian-based phone.
This gave me reasons to start learning on how to program this beast.</p>
<p>I have searched for Symbian programming tutorials but there is so much knowledge that it is hard to choose best for startup.</p>
<p>So I'm asking for hints, ti... | <p>I will merely point out a few resources that I used when I embarked on the journey to become a Symbian Developer.</p>
<ol>
<li>The <a href="http://developer.symbian.com/main/learning/" rel="nofollow noreferrer">Learning Centre</a> at Symbian Developer portal. There are all manners of documents, whitepapers, and tut... | <p>You are the exact intended audience for a recent Symbian Press book :
<a href="http://www.quickrecipesonsymbianos.com" rel="nofollow noreferrer">http://www.quickrecipesonsymbianos.com</a></p>
<p>It is meant as an introduction into the Symbian development ecosystem for developers who haven't targetted mobile phones ... | 24,451 |
<p>For parsing player commands, I've most often used the <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#split%28java.lang.String%29" rel="noreferrer">split</a> method to split a string by delimiters and then to then just figure out the rest by a series of <code>if</code>s or <code>switch</code>... | <p>I assume you're trying to make the command interface as forgiving as possible. If this is the case, I suggest you use an algorithm similar to this:</p>
<ol>
<li>Read in the string
<ul>
<li>Split the string into tokens</li>
<li>Use a dictionary to convert synonyms to a common form </li>
<li>For example, convert "hi... | <p>A simple string tokenizer on spaces should work, but there are really many ways you could do this.</p>
<p>Here is an example using a tokenizer:</p>
<pre><code>String command = "kick person";
StringTokenizer tokens = new StringTokenizer(command);
String action = null;
if (tokens.hasMoreTokens()) {
action = tok... | 2,509 |
<p>I'm passing around some objects through web service and some of them contain java.sql.Date. Because Date doesn't have empty constructor it doesn't want to get serialized. </p>
<p>First part of a question is easy: what is the best way to pass a date between client and service? </p>
<p>Second part is bit trickier: O... | <p>Serializing the long returned by Date.getTime() as previously suggested will work. You should however note that if your server is in another time zone than the client, the date you'll reconstruct on the other side will be different. If you want want to reconstruct exact same date object you also need to send your ti... | <p>First, if you are using web services, it means you are serializing to XML and not your regular Java serialization (but some other library for marshaling and unmarshaling). So the question is lacking some information.</p>
<p>Second, if you have control over your InputStream & OutputStream try extending ObjectOut... | 13,988 |
<p>I found <a href="https://stackoverflow.com/questions/122778/capture-console-output-for-debugging-in-vs">this question</a>, but what I want to know is different - does the output from Console.WriteLine go anywhere when debugging? I know that for it to go to the output window I should should Debug.WriteLine() or other... | <p>The console can redirect it's output to any textwriter. If you implement a textwriter that writes to Diagnostics.Debug, you are all set.</p>
<p>Here's a textwriter that writes to the debugger.</p>
<pre><code>using System.Diagnostics;
using System.IO;
using System.Text;
namespace TestConsole
{
public class Deb... | <p>Console.writeline() goes to a console window: the black command / dos prompt.</p>
| 31,154 |
<p>I'm using subclipse in Flex Builder 3, and recently received this error when trying to commit:</p>
<p><code>svn: Checksum mismatch for '/Users/redacted/Documents/Flex Builder 3/path/to/my/file.mxml'; expected: 'f8cb275de72776657406154dd3c10348', actual: 'null'</code></p>
<p>I worked around it by:</p>
<ol>
<li>Com... | <p>The file in the .svn directory that keeps track of what you have checked out, when, what revision, and from where, has gotten corrupted somehow, for that particular file.</p>
<p>This is no more dangerous or critical than the normal odd file problem, and can be because of various problems, like a subversion program ... | <p>here's how i fixed the issue - v simple, but as per jsh above, need to be sure your copy is the best one.</p>
<p>simply</p>
<ol>
<li>make a copy all problem files, in the same folder.</li>
<li>delete the old ones with svn rm</li>
<li>commit. </li>
<li>then rename the copies back to the original file names.</li>
<l... | 2,794 |
<p>I have a Table called <em>Product</em> and I have the Table <em>StorageHistory</em>.</p>
<p>Now, Product contains a reference to StorageHistory in it's mappings</p>
<pre><code><set name="StorageHistories" lazy="false">
<key column="ProductId" />
<one-to-many class="StorageHistory" />
</set... | <p>I always do the following in the ctor of the parent object:</p>
<p>histories = new HashedSet();</p>
<p>This covers the Save() use case. The Load()/Get() etc usecase is covered by NHibernate as you stated.</p>
| <p>Why not?</p>
<pre><code>private ISet _StorageHistories;
public virtual ISet StorageHistories {
protected set { _StorageHistories = value;}
get { if (_StorageHistories == null) _StorageHistories = new HashSet();
return _StorageHistories;
}
}
</code></pre>
<p>Of course if you go through the... | 32,231 |
<p>In a simple dialog app, using designer, I've set up the usual shortcut keys for cut, copy, paste and delete in the edit menu.</p>
<p>My problem is that I only want to handle delete events when a certain tree control is in focus. Otherwise, in my datagrid control for example, I want delete to work as usual.</p>
<p>... | <p>It seems that if you want to use the shortcut keys for menu items, that <code>keycombination</code> is taken throughout your form, no matter if you set up your <code>eventhandler</code> to not do anything unless a certain tree control is in focus (there is no way to set the key-event as <code>.Handled=false</code>).... | <p>If you're only going to have one form and only one datagrid,
the simplest method would be to fire off your datagrid delete events from the click event invoked by your menu item. Whichever row is current (bindingsource) or selected (datagrid), you can delete programmatically.</p>
| 46,813 |
<p>I have been experimenting with Lambda expressions in Oxygene. Very simple recursive lambda expression to calculate a fibonacci number :</p>
<pre><code>var fib : Func<int32, int32>;
fib := n -> iif(n > 1, fib(n - 1) + fib(n - 2), n);
fib(3);
</code></pre>
<p>When I run this code I get a nullreferenceexc... | <p>You aren't doing anything wrong. If anything, the compiler should warn you about using fib, an unassigned variable, inside the body of the lambda.</p>
<p>However the compiler ought to be capturing fib as a location, so that when the assignment completes and the delegate is later invoked, fib is properly assigned an... | <p>Prism handles the capture of local variables differently then native Delphi or C#.
In those 2 all references in your code of those locals will be mapped to fields of the compiler generated class that will hold your anonymous method.
In prism, these locals stay ordinary locals, yet the fields of this hidden fields ar... | 33,973 |
<p>I commonly find myself extracting common behavior out of classes into helper/utility classes that contain nothing but a set of static methods. I've often wondered if I should be declaring these classes as abstract, since I can't really think of a valid reason to ever instantiate these? </p>
<p>What would the Pros... | <p>You could just declare a private constructor that does nothing.</p>
<p>The problem with declaring the class "abstract" is that the abstract keyword usually means that class is intended to be subclassed and extended. That's definitely not what you want here.</p>
| <p>No, but if your language supports it, there's a strong argument to be made that in most cases they should (can) be declared as 'static'... Static tells the compiler that they cannot be instantiated, and that all methods in them must be static. </p>
<p>Abstract is for classes that DO have instance-based implementa... | 39,880 |
<p>Whenever I start our Apache Felix (OSGi) based application under SUN Java ( build 1.6.0_10-rc2-b32 and other 1.6.x builds) I see the following message output on the console (usually under Ubuntu 8.4):</p>
<blockquote>
<p>Warning: The encoding 'UTF-8' is not supported by the Java runtime.</p>
</blockquote>
<p>I'... | <p>According <a href="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html" rel="noreferrer">the documentation</a> "Every implementation of the Java platform is required to support the following standard charsets... US-ASCII, ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE, UTF-16." So I doubt that Sun have relea... | <p>Try a different (stable release) JVM. I had this problem once and it turned out that the machine was running a beta version JVM that indeed did not support UTF-8, contrary to the requirement in the API docs.</p>
| 21,350 |
<p>Is there a mandatory relationship between a Controller Action and a View? I mean is it necessary to have a physical View (.aspx page) for each Action inside a Controller class?</p>
| <p>There is no mandatory relationship between the Controller Action and a view. The controller is responsible for returning an ActionResult. The most usual way of doing this is by using a View, but they aren't hard wired. A view could be shared across Controllers for instance.</p>
<p>Also a Controller, can deal with t... | <p>You can also return things like ContentResult in an action:</p>
<pre><code>public ContentResult Index()
{
return Content("Foobar!");
}
</code></pre>
<p>If this was called directly, this would be similar to:</p>
<pre><code>Response.Write("Foobar!");
Response.End();
</code></pre>
| 29,600 |
<p>Long time ago, I saved a sentence from a Java reference book: <em>"Java has no mechanism to handle deadlock. it won't even know deadlock occurred." (Head First Java 2nd Edition, p.516)</em></p>
<p>So, what is about it? Is there a way to catch deadlock case in Java? I mean, is there a way that our code understands a... | <p>Since JDK 1.5 there are very useful methods in the <code>java.lang.management</code> package to find and inspect deadlocks that occurs. See the <code>findMonitorDeadlockedThreads()</code> and <code>findDeadlockedThreads()</code> method of the <code>ThreadMXBean</code> class.</p>
<p>A possible way to use this is to ... | <p>After so long, i am able to write the simplest example of Deadlock.
Comments are welcome. </p>
<pre><code>Class A
{
synchronized void methodA(B b)
{
b.last();
}
synchronized void last()
{
SOP(“ Inside A.last()”);
}
}
Class B
{
synchronized void methodB(A a)
{
a.last();
}
synchron... | 26,686 |
<p>I have an idea for a web-based service. The implementation is very complex. There will be very few users, and the traffice will be fairly low, but the server-side code could require a lot of resources. Ideally I'd need to have as much control over the servers as possible.</p>
<p>How should I arrange hosting for thi... | <p>Most reputable hosters have no real interest in their customer's business ideas because they're in the business of hosting. Any hoster stealing business ideas would quickly lose out on reputation if they crossed that line.</p>
<p>Speak to a company that does dedicated servers and chew the fat with them about your r... | <p>A lot of hosting providers are able to provide you with a dedicated server or VPS (Virtual Private Server) where you run a virtual machine on shared hardware. I have used <a href="http://www.hostmysite.com/" rel="nofollow noreferrer">HostMySite</a> for VPS in the past and the service was very good. Dedicated and VPS... | 37,274 |
<p>I have a web site that is a customer to customer (C2C) service. Example, a user is looking for a hockey card of Gordie Howe and another customer wants to sell a Gordie Howe hockey card. If they sell the card 100$, I'd like to have 90$ that goes to the seller and 10$ that goes to me for providing the service (some ki... | <p>Have the $100 go to you and you cut a check to the customer monthly for their proceeds.</p>
| <p>No, I don't believe so.</p>
| 43,797 |
<p>Suppose I have a process which spawns exactly one child process. Now when the parent process exits for whatever reason (normally or abnormally, by kill, ^C, assert failure or anything else) I want the child process to die. How to do that correctly?</p>
<hr>
<p>Some similar question on stackoverflow:</p>
<ul>
<li>... | <p>Child can ask kernel to deliver <code>SIGHUP</code> (or other signal) when parent dies by specifying option <code>PR_SET_PDEATHSIG</code> in <code>prctl()</code> syscall like this:</p>
<p><code>prctl(PR_SET_PDEATHSIG, SIGHUP);</code></p>
<p>See <code>man 2 prctl</code> for details.</p>
<p>Edit: This is Linux-only... | <p>If parent dies, PPID of orphans change to 1 - you only need to check your own PPID.
In a way, this is polling, mentioned above.
here is shell piece for that:</p>
<pre class="lang-bash prettyprint-override"><code>check_parent () {
parent=`ps -f|awk '$2=='$PID'{print $3 }'`
echo "parent:$parent"
... | 36,070 |
<p>this is a more "can it be done" rather than a "how is it done" question. I'm looking at building a service (middle tier, .net, providing data abstraction and some business logic) that will be used by multiple internal client systems on different platforms. E.g. one client might be a web site, another client some j... | <p>Methods are synchronous by default. To make them asynch, you need to add this attribute [OperationContract(AsyncPattern=true)] and return an IAsynchResult, just like you would if you were doing BeginIvoke() with winforms. (read more here <a href="http://msdn.microsoft.com/en-us/library/ms734701.aspx" rel="nofollow n... | <p>Setting up async operations on your WCF service can be done as Ninja posted by setting AsyncPattern=true or it can be done on the client side by telling svcutil to generate the async end points by setting the correct command line argument or by checking the "Generate asynchronous operations" option in the GUI versio... | 46,024 |
<p><strong>NOTE:</strong> Using .NET 2.0, and VS2005 as IDE</p>
<p>Hello all,</p>
<p>I'm working on logging webservice calls to our database, and finally got the SoapExtension configured and running using a very stripped-down implementation that was ported over from another project. I've set it up in the configurati... | <p>After some trial and error, I have been able to solve this issue. While I do not entirely understand why, the SoapMessage object is not completely initialized at the BeforeDeserialize stage. Both the Action and MethodInfo properties throw errors at this stage.</p>
<p>However, during the AfterSerialize stage, thes... | <p>According to MSDN the method information is only available during AfterDeserialization and BeforeSerialization. So that would be part of the problem.</p>
| 28,024 |
<p>I am having issue with my new printer it is not printing circles correctly although I have change firmware and stepping of motor
advise if anyone know the solution.
<a href="https://i.stack.imgur.com/7egRT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7egRT.jpg" alt="enter image description here... | <p>Possible causes for the printer not printing correct dimensions:</p>
<ul>
<li>Incorrect number of steps/mm in firmware settings</li>
<li>Belts are not tight enough</li>
<li>Pulley slips on the shaft</li>
</ul>
<p>Looking at the picture, I would go for the first case, because distortion looks regular. Try checking ... | <p>This could be because your belts are either old or not tight enough. Try adjust or replacing the belts and try again. </p>
| 685 |
<p>I need a way to determine the space remaining on a disk volume using python on linux, Windows and OS X. I'm currently parsing the output of the various system calls (df, dir) to accomplish this - is there a better way?</p>
| <pre><code>import ctypes
import os
import platform
import sys
def get_free_space_mb(dirname):
"""Return folder/drive free space (in megabytes)."""
if platform.system() == 'Windows':
free_bytes = ctypes.c_ulonglong(0)
ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(dirname), None, No... | <p>I Don't know of any cross-platform way to achieve this, but maybe a good workaround for you would be to write a wrapper class that checks the operating system and uses the best method for each.</p>
<p>For Windows, there's the <a href="http://aspn.activestate.com/ASPN/docs/ActivePython/2.2/PyWin32/win32api__GetDiskF... | 7,484 |
<p>I've seen with Microsoft COM and XPCOM, at least from what I've read and gathered so far, that the implementations of interfaces in a component have to essentially be in the single class that derives all the virtual interfaces. Is this correct? What am I missing?</p>
<p>Is there a way to have multiple objects (poss... | <p>This should be possible, although probably not supported by the standard high-level wrappers. Most of the wrappers (ATL, MFC, etc.) only support mapping a COM object to a single class. However, QueryInterface is allowed to return a different pointer and calls COM object code, so the first COM object could load a dif... | <p>Yes, ATL supports <a href="http://msdn.microsoft.com/en-us/library/wh8b86c9(VS.80).aspx" rel="nofollow noreferrer">tear-off interfaces</a>
This allows to imlement the interface in another class that is instantiated only when the interface is requested. Since it passes only an interface, I guess it can be put into a... | 29,161 |
<p>I have a big string (let's call it a CSV file, though it isn't actually one, it'll just be easier for now) that I have to parse in C# code.<br>
The first step of the parsing process splits the file into individual lines by just using a <code>StreamReader</code> object and calling <code>ReadLine</code> until it's thr... | <p>Since this isn't a true CSV file, does it have any sort of schema?</p>
<p>From your example, it looks like you have:
int, int, int, int, string , bool, bool, int</p>
<p>With that making up your record / object.</p>
<p>Assuming that your data is well formed (I don't know enough about your source to know how valid ... | <p><strong>EDIT:</strong> Sorry, I've misinterpreted your post. If you're looking for a regex, then here is one:</p>
<pre><code>content = Regex.Replace(content, "'([^']*)\n([^']*)'", "'\1TOKEN\2'");
</code></pre>
<p>There might be edge cases and that two problems but I think it should be ok most of the time. What the... | 5,303 |
<p>I had setup my clients & server for passwordless login.
Like passwordless login by copying RSA key of server to all client's /root/.ssh/id-rsa.pub. but this, I have done manually. I like to automate this process using shell script and providing password to the machines through script.
If this problem is solved t... | <p>This script comes in Debian (and derivatives) machines, to distribute the keys. It's called ssh-copy-id. You'd use it like this:</p>
<pre><code>ssh-copy-id [-i identity_file] [user@]machine
</code></pre>
<p>Then you'd enter the password and the copying would be done. You would do this one time only and then could ... | <p>If you need to push updates/changes to multiple computers in a network then you may want to consider looking at something like <a href="http://puppet.reductivelabs.com/" rel="nofollow noreferrer">Puppet</a> that works outside the normal channels.</p>
| 27,772 |
<p>I need to store a tree data structure in my database, for which I plan on using <a href="http://code.google.com/p/django-treebeard/" rel="noreferrer">django-treebeard</a> or possibly <a href="http://code.google.com/p/django-mptt/" rel="noreferrer">django-mptt</a>. My source of confusion is that each node could be o... | <p>How about using a <a href="http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#id1" rel="nofollow noreferrer">generic relation</a> from the model which will hold the tree structure to the content object for the node it represents?</p>
<pre><code>from django.db import models
from django.contrib.contenttyp... | <p>If a tree structure is an integral part of your application, consider using something else than a relational database. Maybe neo4j?</p>
| 37,140 |
<p>I think most C++ programmers here would agree that polluting the global namespace is a bad idea, but are there times when this rule can be ignored?</p>
<p>For example, I have a type that I need to use all over a particular application - should I define it thus:</p>
<pre><code>mytypes.h
typedef int MY_TYPE;
foo.c... | <p>I use namespaces for partitioning library code from application-specific code, and in a big project to partition the various modules that make up the project.</p>
<p>The global namespace is thus useful for application-specific types and functions that are used across multiple modules in the application.</p>
<p>So,... | <p>I don't agree with using the global namespace at all (well, except for <code>main</code>, of course). For things that are used across the whole application, you can simply use <code>using namespace</code> at the top of your <code>.cpp</code> files, after all the relevant <code>#include</code> lines.</p>
| 33,608 |
<p>I'd like to have a java.utils.Timer with a resettable time in java.I need to set a once off event to occur in X seconds. If nothing happens in between the time the timer was created and X seconds, then the event occurs as normal. </p>
<p>If, however, before X seconds has elapsed, I decide that the event should occu... | <p>According to the <a href="http://java.sun.com/javase/6/docs/api/java/util/Timer.html" rel="noreferrer"><code>Timer</code></a> documentation, in Java 1.5 onwards, you should prefer the <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html" rel="noreferrer"><code>Schedule... | <p>Here is the example for Resetable Timer . Try to change it for your convinence...</p>
<pre><code>package com.tps.ProjectTasks.TimeThread;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
im... | 5,193 |
<p>I have an application used by pretty tech-savey people and they want small island of programmability so I've used embedded Iron Python.</p>
<p>However, since IronPython 2.0 Eval() doesn't work any more. Specifically I can't both load modules and inject local variables.</p>
<p>There is a work around where I can sti... | <p>Could you be a little more specific about the problem, and maybe provide a code example? The "eval"-style functionality is definitely still present, though as you've noticed, the hosting interface has changed considerably since 1.0.</p>
<p>This works in beta 5:</p>
<pre><code>ScriptEngine engine = Python.CreateEn... | <p>This example may help you: <a href="http://www.voidspace.org.uk/ironpython/dlr_hosting.shtml" rel="nofollow noreferrer">http://www.voidspace.org.uk/ironpython/dlr_hosting.shtml</a></p>
| 24,300 |
<p>Table1:
Everything including the kitchen sink. Dates in the wrong format (year last so you cannot sort on that column), Numbers stored as VARCHAR, complete addresses in the 'street' column, firstname and lastname in the firstname column, city in the lastname column, incomplete addresses, Rows that update preceeding ... | <p>I am not a MySQL person, so this is coming out of left field.</p>
<p>But I think the log files might be the answer.</p>
<p>Thankfully, you really only need to know 2 things from the log.</p>
<p>You need the record/rowid, and you need the operation.</p>
<p>In most DB's, and I assume MySQL, there's an implicit co... | <p>you might be able to use maatkit's mk-table-sync tool to synchronise a staging database (your database is only very small, after all). This will "duplicate the mess"</p>
<p>You could then write something that, after the sync, does various queries to generate a set of more sane tables that you can then report off.</... | 12,679 |
<p>I have the following code for my masterpage:</p>
<pre><code><%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/x... | <p>Use the following in your css for the footer div:</p>
<pre><code>bottom:0px;
position:absolute;
</code></pre>
| <p>Check these related questions for solutions:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/42294/how-do-you-get-the-footer-to-stay-at-the-bottom-of-a-web-page">How do you get the footer to stay at the bottom of a Web page?</a></li>
<li><a href="https://stackoverflow.com/questions/159487/can-not-get-css-... | 38,203 |
<p>Hopefully this will not spark a religious war...</p>
<p>We have a web based app in RoR based on an earlier version we build in .net 2.0. So we currently have both .net and RoR skills in house. </p>
<p>We want to add a RIA app that interfaces with the rails web app. This should be capable of running offine, with so... | <p>A choice between Flex/Silverlight should depend on your skills and what you want the RIA to do.</p>
<p>There's a fair comparison here: <a href="http://extremeblue.wordpress.com/2008/04/28/flex-vs-silverlight-my-views/" rel="nofollow noreferrer">http://extremeblue.wordpress.com/2008/04/28/flex-vs-silverlight-my-view... | <p>Go with SilverLight. It's way cool. ;)</p>
| 17,920 |
<p>What new features in java 7 is going to be implemented?
And what are they doing now?</p>
| <h2>Java SE 7 <a href="http://www.oracle.com/technetwork/java/javase/jdk7-relnotes-418459.html" rel="noreferrer">Features and Enhancements</a> from JDK 7 Release Notes</h2>
<p>This is the Java 7 new features summary from the <a href="http://openjdk.java.net/projects/jdk7/features/" rel="noreferrer">OpenJDK 7 features ... | <p>The following list contains links to the the enhancements pages in the Java SE 7.</p>
<pre><code>Swing
IO and New IO
Networking
Security
Concurrency Utilities
Rich Internet Applications (RIA)/Deployment
Requesting and Customizing Applet Decoration in Dragg able Applets
Embedding JNLP File in Applet Tag
... | 26,304 |
<p>I have three tables, A, B, C, where A is many to one B, and B is many to one C. I'd like a list of all C's in A. </p>
<p>My tables are something like this: A[id, valueA, lookupB], B[id, valueB, lookupC], C[id, valueC]. I've written a query with two nested SELECTs, but I'm wondering if it's possible to do INNER JOIN... | <p>I did a test on MS SQL 2005 using the following tables: A 400K rows, B 26K rows and C 450 rows.</p>
<p>The estimated query plan indicated that the basic inner join would be 3 times slower than the nested sub-queries, however when actually running the query, the basic inner join was twice as fast as the nested queri... | <p>Is this what you mean?</p>
<pre><code>SELECT DISTINCT C.valueC
FROM
C
INNER JOIN B ON C.id = B.lookupC
INNER JOIN A ON B.id = A.lookupB
</code></pre>
| 19,508 |
<p>I have been a developer for 10+ years and so far my IIS knowledge is just enough for deploying stuff on it and get it running. Recently I have been playing with IIS 6 and realize the huge difference on the worker process model. I think I would need some good guide to update my knowledge in this area. Any good articl... | <p><a href="http://iistuner.codeplex.com" rel="noreferrer">IIS Tuner</a> is an open source tool for tuning IIS 6, 7 and 7.5 </p>
| <p>David Wang has some great articles on the inner workings of IIS6. For various reasons his blog was split over two sites:</p>
<p><a href="http://blogs.msdn.com/david.wang/default.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/david.wang/default.aspx</a></p>
<p><a href="http://w3-4u.blogspot.com/" rel="nofoll... | 23,545 |
<p>We have a large ASP (classic ASP) application and we would like to convert it to .NET in order to work on further releases. It makes no sense continuing to use ASP as it is obsolete, and we don't want to rewrite it from scratch (Joel Spolsky tells you <a href="http://www.joelonsoftware.com/articles/fog0000000069.htm... | <p>Well,
I used to work for the company where all web apps were classic ASP.
When decision was made to move to .NET we had to find a way to transform 168(!) web apps into this new framework.
I tried all the tools available at the time to do this and all failed.</p>
<p>Best way is to build a new web server and start th... | <p>gmStudio is a comprehensive VB6/ASP/COM to .NET upgrade tool. It can read, analyze, interpret, rewrite and restructure (as C# or VB.NET) individual pages+includes or entire sites. </p>
<p>The technology has been in active development since 2007 and we have used it to help us rewrite sites ranging from a few hundr... | 13,624 |
<p>I'm trying to use System.IO.File.Replace to update a file, and it's throwing System.IOException if the destination file is on a NAS.</p>
<p>According to <a href="http://msdn.microsoft.com/en-us/library/9d9h163f(VS.80).aspx" rel="nofollow noreferrer">MSDN</a>, if the destination file is on a different volume, this m... | <p>You could ensure the replace is always on the same volume by using Copy, then Replace.
Or just catch the error and try it.</p>
<pre><code>catch IOException
File.Copy( src,dest+".tmp", true )
File.Replace( dest+".tmp", dest, dest_backup )
</code></pre>
| <p>If you have a chance that the files will be on separate volumes, it's best to write your own simple copy routine that reads from one stream and writes out to the other. This handles cross-volume copies, allows you to catch the other exceptions you might hit and is pretty simple to implement.</p>
| 42,321 |
<p>What is the best way to free resources (in this case unlock the ReadWriteLock) when leaving the scope ? How to cover all possible ways (return, break, exceptions etc)?</p>
| <p>A try/finally block is the closest thing that you can get to this behaviour:</p>
<pre><code>Lock l = new Lock();
l.lock(); // Call the lock before calling try.
try {
// Do some processing.
// All code must go in here including break, return etc.
return something;
} finally {
l.unlock();
}
</code></... | <p>A nicer way to do it is to use the try-with-resources statement, which lets you mimick C++'s <a href="https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization" rel="nofollow noreferrer">RAII mechanism</a>:</p>
<pre><code>public class MutexTests {
static class Autolock implements AutoCloseable {
... | 18,312 |
<p>I want to convert a string into a double and after doing some math on it, convert it back to a string.</p>
<p>How do I do this in Objective-C?</p>
<p>Is there a way to round a double to the nearest integer too?</p>
| <p>You can convert an NSString into a double with </p>
<pre><code>double myDouble = [myString doubleValue];
</code></pre>
<p>Rounding to the nearest int can then be done as</p>
<pre><code>int myInt = (int)(myDouble + (myDouble>0 ? 0.5 : -0.5))
</code></pre>
<p>I'm honestly not sure if there's a more streamlined ... | <p>This is the easiest way I know of:</p>
<pre><code>float myFloat = 5.3;
NSInteger myInt = (NSInteger)myFloat;
</code></pre>
| 20,510 |
<p>I am attempting to print a model that is too tall to print up-right and it has a large flat side that would be my first layer but ultimately would be the side of the object and I'd like it to look presentable. I'm using wood PLA, so I intend to sand and stain it.</p>
<p>I've had no issues with adhesion when using a... | <p>The motor is mounted in a fixed position no matter if it's on top or bottom.
You can imagine the lead screw as a rod hanging down and supporting the bed in the Z direction only, because all of the XY rigidity comes from the Liner rails the bed is attached to it works just as well if the stiff rod is under compressio... | <p>The motor is mounted in a fixed position no matter if it's on top or bottom.
You can imagine the lead screw as a rod hanging down and supporting the bed in the Z direction only, because all of the XY rigidity comes from the Liner rails the bed is attached to it works just as well if the stiff rod is under compressio... | 2,019 |
<p>This question is related to a previous post of mine <a href="https://stackoverflow.com/questions/227225/is-injecting-dao-into-entities-a-bad-thing">Here</a>. Basically, I want to inject a DAO into an entity i.e. </p>
<pre><code>public class User
{
IUserDAO userDAO;
public User()
{
userDAO = IoCCon... | <p>you could also do something simple like this with CSS:</p>
<pre><code><asp:Panel DefaultButton="myButton" runat="server">
<asp:TextBox ID="myTextBox" runat="server" />
<asp:Button ID="myButton" runat="server" onclick="myButton_Click" style="display: none; " />
</asp:Panel>
</code></... | <p>Use the TextChanged event, and set the AutoPostBack property to true.</p>
| 28,466 |
<p>I've <strong>inherited</strong> a web app that I've just discovered stores over 300,000 usernames/passwords in plain text in a SQL Server database. I realize that this is a Very Bad Thing™.</p>
<p>Knowing that I'll have to update the login and password update processes to encrypt/decrypt, and with the smallest imp... | <p>EDIT (2016): use <a href="https://en.wikipedia.org/wiki/Argon2" rel="nofollow noreferrer">Argon2</a>, <a href="https://en.wikipedia.org/wiki/Scrypt" rel="nofollow noreferrer">scrypt</a>, <a href="https://en.wikipedia.org/wiki/Bcrypt" rel="nofollow noreferrer">bcrypt</a>, or <a href="https://en.wikipedia.org/wiki/PBK... | <p>To hash the password you can use the <a href="http://msdn.microsoft.com/en-us/library/ms174415.aspx" rel="nofollow noreferrer">HashBytes</a> function. Returns a varbinary, so you'd have to create a new column and then delete the old varchar one.</p>
<p>Like</p>
<pre><code>ALTER TABLE users ADD COLUMN hashedPasswor... | 36,577 |
<p>We have this set of data that we need to get the average of a column. a <code>select avg(x) from y</code> does the trick. However we need a more accurate figure.</p>
<p>I figured that there must be a way of filtering records that has either too high or too low values(spikes) so that we can exclude them in calculati... | <p>There are three types of average, and what you are originally using is the mean - the sum of all the values divided by the number of values.</p>
<p>You might find it more useful to get the mode - the most frequently occuring value:</p>
<pre><code>select name,
(select top 1 h.run_duration
from sy... | <p>in sql server there's also the STDEV function so maybe that can be of some help...</p>
| 45,881 |
<p>I would like to execute a stored procedure within a stored procedure, e.g. </p>
<pre><code>EXEC SP1
BEGIN
EXEC SP2
END
</code></pre>
<p>But I only want <code>SP1</code> to finish after <code>SP2</code> has finished running so I need to find a way for <code>SP1</code> to wait for <code>SP2</code> to finish before... | <p>T-SQL is not asynchronous, so you really have no choice but to wait until SP2 ends. Luckily, that's what you want.</p>
<pre><code>CREATE PROCEDURE SP1 AS
EXEC SP2
PRINT 'Done'
</code></pre>
| <p>Thats how it works stored procedures run in order, you don't need begin just something like</p>
<pre><code>exec dbo.sp1
exec dbo.sp2
</code></pre>
| 20,551 |
<p>I've recently designed a non-self-aligning caged deep-groove ball bearing. Now I'd love to get one 3D printed.</p>
<p>However, assembling those can be tricky and I highly doubt it's even plausible to print them. All the components themselves can be printed without a problem, but I'm not sure whether I'll be able to... | <p>No, that's not (entirely) true. There might be some loss of quality if you print multiple objects at once, because when the printhead "hops" from one object to another it might leave a mark or ooze out some material. Also, a large number of retractions in a short period of time might lead to inconsistent extrusion.<... | <p>Just to add to the other answers already here, I've also had problems with layer adhesion when filling up the print bed on an extrusion printer. The longer the print head spends working on details around a single layer, the more chance the layer has to cool off before the next layer gets started. I've started to s... | 426 |
<p>I have an application where the user selects the dates of a first statement and a last statement. Example, first statement = 1/1/08, last statement = 12/1/08, should equal 12 statements.</p>
<p>However, when using the following code, the result is 11:</p>
<pre><code>numPayments = DateDiff(DateInterval.Month, CDate... | <p>Add 1, as you write. ;) </p>
<p>The difference between 1/1/2008 and 12/1/2008 is 11 months. No changing that. ;)</p>
| <p>You could try this one. Hope this is very helpful.</p>
<pre><code>Dim myDate As Date
Dim dateNow As Date
Dim nextMonth As Date
myDate = Now
dateNow = Format(myDate, "MM/dd/yyyy")
nextMonth = DateAdd(DateInterval.Month, 5, dateNow) 'compute the next 5 months from date now. Let say, #12/6/2012# the result will be #5... | 33,944 |
<p>I have a automated (Visual Build) build process that runs: </p>
<p>A set of automated smoke tests (AutoIT) that enters data into a .Net WinForm app that writes to a cleanly seeded MS SQL 2005 DB. </p>
<p>A SQL query that returns the data I want. </p>
<pre><code>SELECT i.ID, i.firstname, i.lastname, i.ModDate
FROM... | <p>The automation tool TestComplete does this well: <a href="http://www.automatedqa.com/products/testcomplete/" rel="nofollow noreferrer">http://www.automatedqa.com/products/testcomplete/</a> </p>
| <p>So, why don't you use NUnit tests project to be with build right after main project testing?
You can easily test SQL data for assertion there.</p>
| 45,009 |
<p>Assuming I have fonts installed which have the appropriate glyphs in them, is there a command shell for Windows XP that will display Unicode characters? At a minimum, two things that should display Unicode correctly:</p>
<ul>
<li>Directory listings. I don't care what I have to type (dir, ls, get-childitem, etc.), s... | <p>This was a major issue in PowerShell v1. Version 2 is shipping with a "graphical shell" that corrects the problem, which is ultimately not with PowerShell, but with the Windows console host (which Cmd.exe also uses). You can get the current CTP for PowerShell v2, if you want.</p>
<p>Actually, PowerShell v2.0 was fi... | <p>Also from
<a href="https://stackoverflow.com/questions/10764920/utf-16-on-cmd-exe">UTF-16 on cmd.exe</a></p>
<pre><code> Open/run cmd.exe
Click on the icon at the top-left corner
Select properties
Then "Font" bar
Select "Lucida Console" and OK.
Write Chcp 10000 at the prompt
Finally dir /... | 49,683 |
<p>ASP.NET 3.5 SP1 adds a great new ScriptCombining feature to the ScriptManager object as demonstrated on <a href="http://www.asp.net/learn/3.5-SP1/video-296.aspx?wwwaspnetrdirset=1" rel="nofollow noreferrer">this video</a>. However he only demonstrates how to use the feature with the ScriptManager on the same page. I... | <p>Give this a shot:</p>
<pre><code> ScriptReference SRef = new ScriptReference();
SRef.Path = "~/Scripts/Script.js";
ScriptManager.GetCurrent(Page).CompositeScript.Scripts.Add(SRef);
</code></pre>
<p>That will get the current scriptmanager (even if it is on a master page) and add a script reference to t... | <p>You can also do this in markup using <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanagerproxy.aspx" rel="nofollow">ScriptManagerProxy</a>.</p>
<p>You can add the ScriptManager to the master page e.g.</p>
<pre><code><asp:ScriptManager ID="ScriptManager" runat="server">
<Composi... | 33,688 |
<p>I am using Oracle BPEL Process manager and have a task assigned to a group of users.
I try to mark it approved using Java class oracle.bpel.services.workflow.task.ITaskService.updateTaskOutcome(). This works if the task is assigned to an individual user, but if the task is assigned to a group of users, I get an err... | <p>use <code>updateTaskOutcomes()</code> method instead of <code>updateTaskOutcome()</code> when it is assigned to multiple users</p>
| <p>Your first problem seems obvious, you cannot approve a task that it is assigned to a group without first acquiring. Otherwise, which member of the group had approved the task?</p>
<p>Your second problem is that you are acquiring the task with one user and trying to approve it with another user. </p>
<p>To actual... | 40,545 |
<p>I'm having an amazing amount of trouble starting and stopping a service on my remote server from my msbuild script.</p>
<p>SC.EXE and the ServiceController MSBuild task don't provide switches to allow a username/password so they won't authenticate, so I'm using RemoteService.exe from www.intelliadmin.com</p>
<p>-A... | <p>Often, you can connect to the IPC$ "pseudo-share" on the machine to help establish the credentials before running commands like SC.EXE. Use a command like:</p>
<pre><code>C:\> net use \\xx.xx.xx.xx\ipc$ * /user:username
</code></pre>
<p>The <code>*</code> tells it to prompt you for the password.</p>
| <p>If I understand your scenario correctly, it could help running the script with a domain account which is administrator on your remote machine (or better: has the right to start and stop the service).</p>
| 4,492 |
<p>Use HttpWebRequest to download web pages without key sensitive issues</p>
| <p>[update: I don't know why, but both examples below now work fine! Originally I was also seeing a 403 on the page2 example. Maybe it was a server issue?]</p>
<p>First, <code>WebClient</code> is easier. Actually, <a href="http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/139... | <p>I also got strange results ... First, the</p>
<blockquote>
<p><a href="http://en.wikipedia.org/wiki/" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/</a>'Abadilah</p>
</blockquote>
<p>didn't work and after some failed tries it started working.</p>
<p>The second url,</p>
<blockquote>
<p><a href="http:... | 34,777 |
<p>I'm trying to squeeze a little better quality out of my time lapses generated by OctoPrint.</p>
<p>I'm using the Raspberry Pi Camera Module V2 with a Pi 3. I've already edited the Octopi config to get 720p resolution, but the encoding during time lapse rendering is horrific. Blocky as hell.</p>
<p>Right now the en... | <p>You can learn a lot just by reading the forums. I'll just list a few that are quite popular...</p>
<p><a href="http://forums.reprap.org/" rel="nofollow">Reprap Forums</a> - Has a ton of information on DIY printers including build logs and posts dealing with many issues.</p>
<p><a href="http://www.soliforum.com" r... | <p>ADDITIVE MANUFACTURING TECHNOLOGIES
3D Printing, Rapid Prototyping, and
Direct Digital Manufacturing</p>
<p>Springer</p>
<p>I think its a perfect book. A lot of details to all technologies.
*Beware there is math and physics involved.</p>
<p><a href="https://i.stack.imgur.com/52f1O.jpg" rel="nofollow noreferrer"><... | 272 |
<p>I have the string </p>
<pre><code>a.b.c.d
</code></pre>
<p>I want to count the occurrences of '.' in an idiomatic way, preferably a one-liner.</p>
<p>(Previously I had expressed this constraint as "without a loop", in case you're wondering why everyone's trying to answer without using a loop).</p>
| <p>My 'idiomatic one-liner' for this is:</p>
<pre><code>int count = StringUtils.countMatches("a.b.c.d", ".");
</code></pre>
<p>Why write it yourself when it's already in <a href="http://commons.apache.org/lang/" rel="noreferrer">commons lang</a>?</p>
<p>Spring Framework's oneliner for this is:</p>
<pre><code>int oc... | <pre><code>public class OccurencesInString { public static void main(String[] args) { String str = "NARENDRA AMILINENI"; HashMap occur = new HashMap(); int count =0; String key = null; for(int i=0;i<str.length()-1;i++){ key = String.valueOf(str.charAt(i)); if(occur.containsKey(key)){ count = (Integer)occur.get(key);... | 34,783 |
<p>The following code compiles correctly under VC++ 8 on XPSP3, but running it causes a runtime error. </p>
<p>My header looks like:</p>
<pre><code>#include <stdexcept>
#include <iterator>
#include <list>
template<typename T>
class test_generator
{
public:
typedef T result_type;
... | <p>The <code>test_generator</code> constructor initialises the <code>value</code> iterator to reference the first element in the <code>tests</code> list (which is a member of <code>test_generator</code>).</p>
<p>When you call <code>std::generate_n</code>, a copy of the <code>test</code> is made (because the object is ... | <p>I haven't figured out what's causing the exception so far, but you may wish to have <code>return *value++</code> in your <code>operator()</code>. :-)</p>
| 28,617 |
<p>I have a WCF service with the following configuration:</p>
<pre><code><system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MetadataEnabled">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadat... | <p>I think I found out what the problem is.</p>
<p>If I browse to the URL:</p>
<blockquote>
<p><a href="http://localhost/myservice/contract" rel="noreferrer">http://localhost/myservice/contract</a></p>
</blockquote>
<p>with the <strong>WcfTestClient</strong> application I can successfully retrieve the service meta... | <p>I was able to fix the "400 Bad Request" problem by switching my WCF service from running off of Visual Studio Development Server to using Local IIS Web server (right click on the project --> properties --> web tab --> radio button under "Servers"). I hope this helps someone out there because it took me two days to ... | 41,882 |
<p>This posting here (<a href="https://stackoverflow.com/questions/156044/how-do-you-manage-database-revisions-on-a-medium-sized-project-with-branches">How do you manage database revisions on a medium sized project with branches?</a>) got me wondering how best to work on a web project using branching and deploying to d... | <p>Branching is handy if you expect the work to NOT be completed on time, and you do not have a sufficient body of tests to make continuous integration work. I tend to see branch-crazy development in shops where the programming tasks are far too big to complete predictably and so management wants to wait until just be... | <p>We use SVN in the shop I work at. While we do C++ development, version management is pretty universal. The following is our approach, you can decide what, if any of it, is reasonable for your approach.</p>
<p>For us, ALL development occurs in a branch. We branch for every bug and every feature. Ideally, that br... | 18,889 |
<p>This is a <em>super basic</em> question but I'm trying to execute a Query that I'm building via some form values against the MS Access database the form resides in. I don't think I need to go through ADO formally, but maybe I do.</p>
<p>Anyway, some help would be appreciated. Sorry for being a n00b. ;)</p>
| <p>You can use the following DAO code to query an Access DB:</p>
<pre><code>Dim rs As DAO.Recordset
Dim db As Database
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM Attendance WHERE ClassID = " & ClassID)
do while not rs.EOF
'do stuff
rs.movenext
loop
rs.Close
Set rs = Nothing
</code></pre>
<... | <p>This is what I ended up coming up with that actually works. </p>
<pre><code>Dim rs As DAO.Recordset
Dim db As Database
Set db = CurrentDB
Set rs = db.OpenRecordset(SQL Statement)
While Not rs.EOF
'do stuff
Wend
rs.Close
</code></pre>
| 16,204 |
<p>I have a Ruby script that generates a UTF8 CSV file remotely in a Linux machine and then transfers the file to a Windows machine thru SFTP. </p>
<p>I then need to open this file with Excel, but Excel doesn't get UTF8, so I always need to open the file in a text editor that has the capability to convert UTF8 to ANSI... | <pre><code>ascii_str = yourUTF8text.unpack("U*").map{|c|c.chr}.join
</code></pre>
<p>assuming that your text really does fit in the ascii character set.</p>
| <p>I had a similar issue trying to generate CSV files from user-generated content on the server. I found the <a href="https://github.com/norman/unidecoder" rel="noreferrer">unidecoder</a> gem which does a nice job of transliterating unicode characters into ascii.</p>
<p>Example:</p>
<pre><code>"olá, mundo!".to_ascii ... | 32,956 |
<p>For some reasons, I would like to do an explicit quoting of a string value (becoming a part of constructed SQL query) instead of waiting for implicit quotation performed by <code>cursor.execute</code> method on contents of its second parameter.</p>
<p>By "implicit quotation" I mean:</p>
<pre><code>value = "Unsafe ... | <p>Ok, so I was curious and went and looked at the source of psycopg2. Turns out I didn't have to go further than the examples folder :)</p>
<p>And yes, this is psycopg2-specific. Basically, if you just want to quote a string you'd do this:</p>
<pre><code>from psycopg2.extensions import adapt
print adapt("Hello Worl... | <p>If you use django you might want to use the quoting function which is automatically adapted to the currently configured DBMS :</p>
<pre><code>from django.db import backend
my_quoted_variable = backend.DatabaseOperations().quote_name(myvar)
</code></pre>
| 39,934 |
<p>A class has a property (and instance var) of type NSMutableArray with synthesized accessors (via <code>@property</code>). If you observe this array using:</p>
<pre><code>[myObj addObserver:self forKeyPath:@"theArray" options:0 context:NULL];
</code></pre>
<p>And then insert an object in the array like this:</p>
<... | <blockquote>
<p>But shouldn't the synthesized accessors automatically return such a proxy object?</p>
</blockquote>
<p>No.</p>
<blockquote>
<p>What's the proper way to work around this--should I write a custom accessor that just invokes <code>[super mutableArrayValueForKey...]</code>?</p>
</blockquote>
<p>No. Im... | <p>You need to wrap your <code>addObject:</code> call in <code>willChangeValueForKey:</code> and <code>didChangeValueForKey:</code> calls. As far as I know, there's no way for the NSMutableArray you're modifiying to know about any observers watching its owner.</p>
| 38,820 |
<p>In my Windows XP Task Manager, some processes display a higher value in the Mem Usage column than the VMSize. My Firefox instance, for example shows 111544 K as mem usage and 100576 K as VMSize. </p>
<p>According to the help file of Task Manager Mem Usage is the working set of the process and VMSize is the committe... | <p><strong>Virtual Memory</strong></p>
<p>Assume that your program (eg Oracle) allocated 100 MB of memory upon startup - your VM size goes up by 100 MB though no additional physical / disk pages are touched. ie VM is nothing but memory book keeping. </p>
<p>The total available physical memory + paging file memory is ... | <p>You might find some explaination in <a href="http://blogs.msdn.com/ntdebugging/archive/2007/10/10/the-memory-shell-game.aspx" rel="nofollow noreferrer">The Memory Shell Game</a></p>
<p><strong>Working Set</strong> (A) – This is a set of virtual memory pages (that are committed) for a process and are located in phys... | 31,469 |
<p>I have some code with multiple functions very similar to each other to look up an item in a list based on the contents of one field in a structure. The only difference between the functions is the type of the structure that the look up is occurring in. If I could pass in the type, I could remove all the code dupli... | <p>If you ensure that the field is placed in the same place in each such structure, you can simply cast a pointer to get at the field. This technique is used in lots of low level system libraries e.g. BSD sockets.</p>
<pre><code>struct person {
int index;
};
struct clown {
int index;
char *hat;
};
/* we're not... | <p>I'm a little rusty on c, but try using a void* pointer as the variable type in the function parameter. Then pass the address of the structure to the function, and then use it he way that you would.</p>
<pre><code>void foo(void* obj);
void main()
{
struct bla obj;
...
foo(&obj);
...
}
void foo(void* o... | 9,335 |
<p>The art in question is <a href="https://www.instagram.com/p/CIfsO2ZD7Rj/" rel="nofollow noreferrer">https://www.instagram.com/p/CIfsO2ZD7Rj/</a> . I Think the concept artist, Jean Giraud, is dead.</p>
| <p>While better fitted to our friends at <a href="https://law.stackexchange.com/questions/tagged/copyright">law.SE</a>, the general gist is: <strong>No.</strong></p>
<p>Art is protected by copyright, and any adaption (<em>derivative work</em>) requires the OK from the right holders <em>per se</em>. Only 70-75 years aft... | <p>This is something that might have a precedent, where the line is blurry, someone might have already tried, and in that case the judge's decision in that court case is the official interpretation of the law towards that specific scenario.</p>
<p>There might also be definitive laws regarding "derived works".... | 1,794 |
<p>This is my link:
<a href="https://stackoverflow.com/questions/219986/c-class-from-a-sql-database-table">link text</a></p>
<p>Thought about it and this was my additional question:</p>
<p>Now If i am going against stored procedures, is there an easy way without using T4, LLCodeGen, Codesmith, subsonic, etc..to obtai... | <p>Look into something called the Object-Relational Mappings, or ORM. There are lots of good tools that will automate most of the data layer code for you: NHibernate, Castle Active Record, <a href="http://subsonicproject.com/" rel="nofollow noreferrer">SubSonic</a> etc.</p>
| <p>Adding to Joel Coehoorn's ORM list, you could also consider <a href="http://subsonicproject.com/" rel="nofollow noreferrer">SubSonic</a>. I've found it to be insanely easy to use, and it supports direct access to your procs, views and tables as you deem necessary.</p>
<p>You'd be much better off using an existing t... | 27,354 |
<p>Does anyone know how to get the MS Office 2007 .NET C# Interop libraries to work with Vista? </p>
<p>I have a .NET C# application that I have setup to run as a Windows service. This program will open up a Word or Excel template depending on the situation and modify its contents and then save the document back ou... | <p>You should really avoiding running the Office clients as server side apps. Consider using xml as file format (xlsx for Office 2007, or using the Excel workbook xsd for (somewhat) older versions.) Then you would be freed from using the Excel API on the server.</p>
| <p>Do you have the primary interop assemblies installed on the server? These are usually located in the GAC and not included in the bin directory when you build your program, so they would need to be installed locally on the server.</p>
| 29,853 |
<p>I'm trying to find out whether there is a way to reliably determine when a managed thread is about to terminate. I'm using a third-party library that includes support for PDF documents and the problem is that in order to use the PDF functionality, I have to explicitly initialize the PDF component, do the work, then... | <p>You don't want to wrap <code>System.Thread</code> per se - just compose it with your <code>PDFWidget</code> class that is doing the work:</p>
<pre><code>class PDFWidget
{
private Thread pdfWorker;
public void DoPDFStuff()
{
pdfWorker = new Thread(new ThreadStart(ProcessPDF));
pdfWorker.S... | <p>Wouldn't you just wrap your PDF usage with a finally (if it's a single method), or in an IDisposable?</p>
| 18,485 |
<p>Can somebody please provide me some important aspects I should be aware of while handling Unicode strings in C#?</p>
| <p>Keep in mind that C# strings are sequnces of Char, UTF-16 code units. They are <em>not</em> Unicode code-points. Some unicode code points require two Char's, and you should not split strings between these Chars.</p>
<p>In addition, unicode code points may combine to form a single language 'character' -- for insta... | <p>More details can be found on this thread:</p>
<p><a href="http://discuss.joelonsoftware.com/default.asp?dotnet.12.189999.12" rel="nofollow noreferrer">http://discuss.joelonsoftware.com/default.asp?dotnet.12.189999.12</a></p>
| 17,416 |
<p>Sadly, I am not able to "repair" my 3D printer. Every time, I want to print something that takes a bit longer to print, the extrusion stops at some point during the print (the first few layers are great), no under-extrusion whatsoever before that critical point.</p>
<p>I already tried temperature variation (185-220... | <p>To fight heat creep, you must understand why this is happening.</p>
<p>Heat creeps up the hotend assembly (into the cold end) as a result of incorrect settings or hardware setup causing the filament to prematurely soften and swell.</p>
<p>It is important to reduce the heat travelling upwards in the first place rathe... | <p>Cooling the hot-end heat sink may be the key. My first step would be to try ducting so the all the air from the fan flows through the fins of the heatsink. To keep it easy and be a quick experiment, use cardboard (or business cards) and tape. Check the controls to be sure the fan is running at full power. You sh... | 1,211 |
<p>I have a program that is running a basic RMISecurityManager in all its threads. But I would like to do more control to several threads and set another SecurityManager specially for these threads.</p>
<p>How can I do that ? ...if this is possible !?</p>
<p>thank you by advance.</p>
<p>Edit : I have found my soluti... | <p>It doesn't make a great deal of sense. What if code (malicious or not) causes execution on a different thread? This can even happen within the Java library, with security context transferred (which may use <code>java.security.AccessController.getContext</code>/<code>doPrivileged</code>).</p>
<p>Applets do use a sli... | <p>The SecurityManager performs checks based on the security context of the running thread, perhaps you want to make your SecurityManager to behave differently based on whatever it finds in the context?</p>
<p>Or maybe, you want to implement your <a href="http://en.wikipedia.org/wiki/Strategy_pattern" rel="nofollow no... | 37,709 |
<p>Accepting the possibility of extreme ridicule, I must admit that I really miss sun Teamware's filemerge tool. I have switched from solaris to red hat linux, and find myself regularly missing filemerge (not to be confused with the Apple tool of the same name), as well as the solaris version of pstack (which worked on... | <p>gdb -ex bt program_file core_file should print out the stack trace of the core file.</p>
<p>As for filemrege, there's a bunch of open source stuff:</p>
<p>tkdiff
meld
mgdiff
kdiff3</p>
| <p>meld is great</p>
| 40,069 |
<p>I recently started diving into low level OS programming. I am (very slowly) currently working through two older books, XINU and Build Your Own 32 Bit OS, as well as some resources suggested by the fine SO folks in my previous question, <a href="https://stackoverflow.com/questions/43180/how-to-get-started-in-operatin... | <p>Looking into the <a href="http://msdn.microsoft.com/en-us/library/ms801597.aspx" rel="nofollow noreferrer">IoConnectInterrupt</a> function you can find the ProcessorEnableMask that will select the cpu's that allowed to run the <a href="http://msdn.microsoft.com/en-us/library/ms795727.aspx" rel="nofollow noreferrer">... | <p>In the old days the interrupt went to all processors. In modern times some kinds of hardware can be programmed by an OS to send an interrupt to one particular processor. Of course if you could choose a processor dynamically instead of statically, you wouldn't want to send the interrupt to whichever processor initi... | 38,596 |
<p>I need to write a regular expression that finds javascript files that match </p>
<pre><code><anypath><slash>js<slash><anything>.js
</code></pre>
<p>For example, it should work for both :</p>
<ul>
<li>c:\mysite\js\common.js (Windows)</li>
<li>/var/www/mysite/js/common.js (UNIX)</li>
</ul>
... | <p>Does <code>Pattern.quote(File.separator)</code> do the trick?</p>
<p>EDIT: This is available as of Java 1.5 or later. For 1.4, you need to simply escape the file separator char:</p>
<pre><code>"\\" + File.separator
</code></pre>
<p>Escaping punctuation characters will not break anything, but escaping letters or n... | <p>I've tested gimel's answer on a Unix system - putting <code>"\\" + File.separator</code> works fine - the resulting <code>"\/"</code> in the pattern correctly matches a single <code>"/"</code></p>
| 30,069 |
<p>Does anyone know the bare minimum files required for Ext JS 2.2? I know the ExtJS site has a feature to <a href="http://extjs.com/products/extjs/build/" rel="noreferrer">"build"</a> a small version of ExtJS (ext.js) as a replacement for ext-all.js but that's for minimizing the size of ExtJS on the client. I'm intere... | <p>This link explains the include order
<a href="http://extjs.com/learn/Ext_Getting_Started#What_is_the_proper_include_order_for_my_JavaScript_files.3F" rel="nofollow noreferrer">What is the proper include order for my JavaScript files?</a></p>
<p>This is the minimum include set</p>
<pre><code><link rel="styleshee... | <p>Ext Core<br><a href="http://extjs.com/products/extcore/" rel="nofollow noreferrer">http://extjs.com/products/extcore/</a></p>
| 26,347 |
<p>The 1.0 spec for OpenCL just came out a few days ago (Spec is <a href="http://www.khronos.org/registry/cl/" rel="noreferrer">here</a>) and I've just started to read through it. I want to know if it plays well with other high performance multiprocessing APIs like OpenMP (<a href="http://openmp.org/wp/" rel="noreferr... | <p>OpenMP and OpenCL are distinct, but can be made to work together. Neither of them should "break" the other.</p>
<p>For the sake of argument, let's assume there's a tradeoff between minimizing changes to an existing codebase and performance or computing power. OMP is "easy" in that you can apply it "magically" to ... | <ol>
<li>?</li>
<li>?</li>
<li>OpenCL is supposed to be written directly in C99 afaik? There are header files available now for it anyhow.</li>
<li>?</li>
</ol>
| 46,455 |
<p>From C#, is it possible to detect the number of context switches that occurred while executing a block of code on a particular thread? Ideally, I'd like to know how many times and what CPU my thread code was scheduled on.</p>
<p>I know I can use tools like <a href="http://msdn.microsoft.com/en-us/magazine/cc163437.... | <p>It sounds like you may be looking for a programmatic solution, but if not, Microsoft's <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx" rel="nofollow noreferrer">Process Explorer</a> tool will tell you very easily the number of context switches for a particular thread.</p>
<p>Once in the tool... | <p>I've never done this, but here are a few leads that might help:</p>
<ol>
<li><p>The .NET profiler APIs might allow you to hook in? The <a href="http://msdn.microsoft.com/en-us/library/ms230818.aspx" rel="nofollow noreferrer">ICorProfilerCallback</a> interface has RuntimeThreadSuspended and RuntimeThreadResumed call... | 18,857 |
<p>I am using <a href="http://msdn.microsoft.com/en-us/library/bb386987.aspx" rel="noreferrer">SqlMetal</a> to general my DataContext.dbml class for my ASP.net application using LinqToSql. When I initially created the DataContext.dbml file, Visual Studio used this to create a related DataContext.designer.cs file. This ... | <p>The designer.cs file is normally maintained automatically as you make changes to the DBML within Visual Studio. If VS isn't running when you recreate the DBML it may not know.</p>
<p>Check that the .DBML file in Visual Studio has Custom Tool property set to MSLinqToSQLGenerator. If it isn't, then set it to that. ... | <p>Not sure how It did it, but here are some things I worked on to get it back.</p>
<p>Something had it locked, so it generated a new db.designer.cs file (db1.designer.cs).</p>
<p>I had beyond compare open, comparing that file to the previous one (BC isn't supposed to lock and I don't think it was the problem, never ... | 16,161 |
<p>Does anyone know how to acess a url from a windows application?.</p>
<p>I have an address <a href="http://serverport/Page.I" rel="nofollow noreferrer">http://serverport/Page.I</a> want to acess this page from my windows application.</p>
<p>Regards,
Harsh Suman</p>
| <p>It's not clear what you want to do with the page.</p>
<p>If you want to display it on the form, you can use a <code>WebBrowser</code> control.</p>
<p>If you want to get the response and process it, use the <code>System.Net.WebClient</code> class.</p>
| <p>I'm not sure what you're asking for,so I just give the answer to yet another way to interpret the question. </p>
<p>If you simply want to launch the default browser (to display a local or online html manual etc.), in windows (and probably similar in other OS'es) you can use some kind of "execute interface" to execu... | 46,314 |
<p>Any pointers on how to initiate serial communication with the iphone? Or any other idea to interact with external hardware?</p>
| <p>The only supported way to connect external hardware to the iPhone is through the iPod accessory protocol, through the 30-pin connector. Details on that program are at <a href="http://developer.apple.com/ipod/accessories.html" rel="nofollow noreferrer">http://developer.apple.com/ipod/accessories.html</a>. It isn't ... | <p>It depends on what you want to do. For an SSH terminal connection I reccomend TouchTerm (search the appstore).</p>
<p>I have no experience with electrical connections, but you can find the pinout of the iPod/iPhone connector here:
<a href="http://pinouts.ru/PortableDevices/ipod_pinout.shtml" rel="nofollow noreferre... | 20,625 |
<p>What is the fastest way to share data structures between Java and C#? I want something where I can literally send a "car" object or a "foo" object and have it serialized and deserialized on both server and client.</p>
| <p>WSDL (SOAP) is <em>fairly</em> interchangeable. If you want something less chatty, anything like Google's "protocol buffers", "ICE" (ZeroC), etc offer interchangeable binary serialization and code generation.</p>
<p>For .NET / C#, there are currently two viable protocol buffers implementations <a href="http://code.... | <p>It looks like the <a href="http://www.ikvm.net/" rel="nofollow noreferrer">IKVM</a> seems like a good idea. But if that doesn't meet your needs especially since it is still in development. However, Uri's post points you in a good direction with the use of xml and passing messages, which can be built back together o... | 47,594 |
<h2>Summary</h2>
<p>Hi All,<br />
OK, further into my adventures with custom controls...</p>
<p>In summary, here is that I have learned of three main "classes" of custom controls. Please feel free to correct me if any of this is wrong!</p>
<ol>
<li><strong>UserControls</strong> - Which inherit from <em>UserCo... | <p>I say go ahead with the custom rendered control. I find that in most cases the composite can be easier done and used in a UserControl, but anything beyond that and you'd need to have a finer degree of control (pun unintended) to merit your own rendering strategy.</p>
<p>There maybe controls that are simple enough t... | <p>You might be able to make use of this technique to make design-time easier:</p>
<p><a href="http://aspadvice.com/blogs/ssmith/archive/2007/10/19/Render-User-Control-as-String-Template.aspx" rel="nofollow noreferrer">http://aspadvice.com/blogs/ssmith/archive/2007/10/19/Render-User-Control-as-String-Template.aspx</a>... | 3,815 |
<p>I'm using <a href="http://en.wikipedia.org/wiki/JSLint" rel="noreferrer">JSLint</a> to go through JavaScript, and it's returning many suggestions to replace <code>==</code> (two equals signs) with <code>===</code> (three equals signs) when doing things like comparing <code>idSele_UNVEHtype.value.length == 0</code> i... | <p>The strict equality operator (<code>===</code>) behaves identically to the abstract equality operator (<code>==</code>) except no type conversion is done, and the types must be the same to be considered equal.</p>
<p>Reference: <a href="http://www.c-point.com/javascript_tutorial/jsgrpComparison.htm" rel="noreferrer... | <pre><code>var a = new String("123");
var b = "123";
alert(a === b); // returns false !! (but they are equal and of the same type)
</code></pre>
<p>Saw this in one of the answers.
<code>a</code> and <code>b</code> are not really the same type in this case, if you will check <code>typeof(a)</code>
you will get <em>'o... | 46,894 |
<p>I was under the impression that the test methods in a unit test class <a href="http://www.eggheadcafe.com/articles/visual_studio_2005_unit_test_order_methods.asp" rel="noreferrer">would be executed in the order that they appear in the class file.</a> Apparently this is not true. It also doesn't appear to be purely b... | <p>I was able to track down the answer.</p>
<p><a href="http://social.msdn.microsoft.com/Forums/en-US/vststest/thread/867b3896-5862-4ef0-bf26-ddbd835a02ee/" rel="noreferrer">According to Microsoft employee Guillermo Serrato</a>:</p>
<blockquote>
<p>MSTest executes all tests
synchronously, the order is
nondeterm... | <p>It shouldn't matter what order they run in ... if your tests depend on another test running first, your tests are flawed :-)</p>
| 36,768 |
<p>Most electronics use micro-controllers like an AVR, but I'm seeing ARM chips in new electronics. ARM chips are said to be more powerful, but in what areas related to 3D printing could this help? What are the features that the AVR struggles with and where an ARM could be better?</p>
<p>High Speed movement? Delta pr... | <p>3D printer controllers have to do a lot of stuff very, very fast. Performing kinematics and dynamics calculations while sending many thousands of precisely-synchronized step pulses per second is <em>really, really hard</em>. The 8bit AVR line of microcontrollers used in older 3D printer controllers is basically a la... | <p>AVR processors are 8 bit - thus they can only fetch data from memory 8 bits at a time - while an ARM is 32 bit and can fetch data 32 bits at a time. Position resolution requires a 24 bit value minimum - this means the AVR takes 3 data fetches for the position - whereas the ARM takes 1 data fetch.</p>
<p>Worse still... | 192 |
<p>Is it possible to chain static methods together using a static class? Say I wanted to do something like this:</p>
<pre><code>$value = TestClass::toValue(5)::add(3)::subtract(2)::add(8)::result();
</code></pre>
<p>. . . and obviously I would want $value to be assigned the number 14. Is this possible?</p>
<p><stron... | <p>I like the solution provided by Camilo above, essentially since all you're doing is altering the value of a static member, and since you do want chaining (even though it's only syntatic sugar), then instantiating TestClass is probably the best way to go.</p>
<p>I'd suggest a Singleton pattern if you want to restric... | <p>Use PHP 7! If your web provider cannot --> change provider! Don't lock in past.</p>
<pre><code>final class TestClass {
public static $currentValue;
public static function toValue($value) {
self::$currentValue = $value;
return __CLASS__;
}
public static function add($value) {
... | 15,225 |
<p>Something I do often if I'm storing a bunch of string values and I want to be able to find them in O(1) time later is:</p>
<pre><code>foreach (String value in someStringCollection)
{
someDictionary.Add(value, String.Empty);
}
</code></pre>
<p>This way, I can comfortably perform <strong>constant-time</strong> l... | <p>If you're using .Net 3.5, try <a href="http://msdn.microsoft.com/en-us/library/bb359438.aspx" rel="nofollow noreferrer">HashSet</a>. If you're not using .Net 3.5, try <a href="http://www.itu.dk/research/c5/" rel="nofollow noreferrer">C5</a>. Otherwise your current method is ok (bool as @leppie suggests is better, or... | <p>I should probably make this a question, because I see the problem so often. What makes you think that dictionaries are O(1)? Technically, the only thing likely to be something like O(1) is access into a standard integer-indexed fixed-bound array using an integer index value (there being no look-up in arrays implem... | 42,871 |
<p>I'm trying to order items based on an attribute value:</p>
<pre><code><xsl:apply-templates select="Question">
<xsl:sort order="ascending" select="@Value"></xsl:sort>
</xsl:apply-templates>
</code></pre>
<p>This does order them, but I could have values like 1,2,3, ... 10, 11, ... 20 and ... | <p>If you know that every question has a multi-part number, you could handle them with two <code><xsl:sort></code> instructions:</p>
<pre><code><xsl:apply-templates select="Question">
<xsl:sort select="substring-before(@Value, '.')" data-type="number" />
<xsl:sort select="substring-after(@Valu... | <p>For <a href="http://www.w3schools.com/xsl/el_sort.asp" rel="nofollow noreferrer">sorting</a> numbers you can use this:</p>
<pre><code><xsl:template match="employees">
<xsl:apply-templates>
<xsl:sort select="salary" data-type="number"/>
</xsl:apply-templates>
</xsl:template>
</c... | 25,730 |
<p>I've written a program that counts lines, words, and characters in a text: it does this with threads. It works great sometimes, but not so great other times. What ends up happening is the variables pointing to the number of words and characters counted sometimes come up short and sometimes don't.</p>
<p>It seems to... | <p>A different threaded design would make it easier to find and fix this kind of problem, and be more efficient into the bargain. This is a longish response, but the summary is "if you're doing threads in Java, check out <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/package-summary.html" rel="n... | <p>Sounds like a good question to me... I think the problem might be related to the atomicity of the chars += and words += - several threads could be calling that at the same time - do you do anything to ensure that there is no interleaving.</p>
<p>That is:</p>
<p>Thread 1, has chars = 10, wants to add 5</p>
<p>Thr... | 36,923 |
<p>How do you process information in Java that was input from a file. For Example: suppose you have a file input.txt. The contents of this file is:
abcdefghizzzzjklmnop
azzbcdefghijklmnop</p>
<p>My hope would be that the information would be put into the argument array of strings such that the following code would... | <p>You should be able to read the input data from <code>System.in</code>.</p>
<p>Here's some quick-and-dirty example code. <code>javac Test.java; java Test < Test.java</code>:</p>
<pre><code>class Test
{
public static void main (String[] args)
{
byte[] bytes = new byte[1024];
try
{
... | <p>I'm not sure why you want to pass the contents of a file as command line arguments unless you're doing some weird testbed.</p>
<p>You could write a script that would read your file, generate a temporary script in which the java command is followed by your needs. </p>
| 23,916 |
<p>C++: Since a struct is a class with everything "public", are default -ctors created and called?</p>
<p>The reason I ask is to understand the overhead, if any, that C++ may have over C, when structs are used. An opinion I have heard is that classes have some overhead that structs don't, in C++, but I question this.<... | <p>In C++ there's no difference except the default visibilty of struct members is public, while class members default to private.</p>
<p>In terms of performance, struct construction will be just as fast as class construction.
Actual speed will of course depend on what your struct contains. If you are moving a C struc... | <p>Good question! My reading of Stroustrup would tend agree with Roddy's answer. However, <em>I think</em> whether or not the ctor is called depends to a certain extent on how the struct is created. For example, if you create the structs via <strong>malloc</strong>, I don't believe the constructor is called, whereas... | 31,101 |
<p>I'm trying to perform a simple INSERT and return the identity (auto-incrementing primary key). I've tried</p>
<pre><code>cmd.CommandText = "INSERT INTO Prototype ( ParentID ) VALUES ( NULL ); SELECT SCOPE_IDENTITY();";
</code></pre>
<p>and I receive the following error</p>
<pre>EnvironmentError: SQLite error
no s... | <p>Check out the <a href="http://www.sqlite.org/faq.html#q1" rel="noreferrer">FAQ</a>. The <a href="http://www.sqlite.org/c3ref/last_insert_rowid.html" rel="noreferrer">sqlite3_last_insert_rowid()</a> function will do it. Careful of triggers though.</p>
| <p>The <code>last_insert_rowid()</code> results in the row id from the very LAST insert into ANY table. Definitely not thread-safe as mentioned in other answers.</p>
<p>If you absolutely <em>need</em> to make sure that you are getting the correct row id returned, regardless of threads, async etc (for example, if you i... | 39,139 |
<p>37 Signal's <em>Getting Real</em> convinced me that wireframing and writing functional specification documents are middleman steps unnecessary for building web applications and dynamic websites. </p>
<p>Is the overhead for these steps worth its weight? Is prototyping in HTML/CSS or even PhotoShop documents (so desi... | <p>"Fail to plan is plan to fail" - or something like that.</p>
<p>Wireframing is not limited to web-apps; it is pervasively used wherever a high-level overview of any system is needed (it's just called something else). </p>
<p>Functional specs, when you know what is to be done & how to do it would indeed be over... | <p>I believe it depends on how well you understand what you are trying to do. If you are working for a client and they haven't expressed much in the way of requirements you may want an approach with extremely quick iterations. If you already have a good understanding and can produce something more substantial without w... | 24,930 |
<p>I have been using the CSLA framework for couple of years now for windows applications. With ASP .NET MVC / AJAX / jQuery out now, would there be any use for the CSLA framework (which is strongly Object Oriented ) in web apps?</p>
| <p>Abstracting the presentation layer is a fairly easy concept once you have the hang of n-tier architecture. Just focus on differentiating "domain logic" from "application logic". Domain logic is common across your different platforms, and application logic is platform-specific. For example, data v... | <p>I would look at using the provider model to establish the database connections in your application.</p>
<p>I would start by looking at the examples and detail provided in the Microsoft Data Application Block, I think it will help get you part of the way there.</p>
| 29,072 |
<p>In essence I'd like to store some rows in a temporary variable for the life of a procedure in MySQL.</p>
<p>My procedure will grab a column of foreign keys at the beginning of the procedure. Once I'm done working with them I want to update the table to indicate that they have been processed. There may be inserts in... | <p>Try setting the DispId attribute of the property to be 0, as described here in the <a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dispidattribute(VS.71).aspx" rel="nofollow noreferrer">MSDN documentation</a>.</p>
| <p>Thanks to Rob Walker's tip, I got it working by adding the following method and attribute to MyCollection:</p>
<pre><code>[DispId(0)]
public string Item(string key) {
return this[key];
}
</code></pre>
<p>Edit: See <a href="https://stackoverflow.com/a/311946/3195477">this better solution</a> which uses an index... | 38,329 |
<p>How can <strong><code>REVOKE</code></strong> operations on a table be audited in Oracle? Grants can be audited with...</p>
<pre><code>AUDIT GRANT ON *schema.table*;
</code></pre>
<p>Both grants and revokes on system privileges and rolls can be audited with...</p>
<pre><code>AUDIT SYSTEM GRANT;
</code></pre>
<p>... | <p>According to Oracle Support all revokes can be audited by doing the following:<br /></p>
<ol>
<li>Set the parameter <code>audit_sys_operations</code> to <code>true</code>.<br /></li>
<li>Set the parameter <code>audit_trail</code> to <code>db_extended</code>.<br /></li>
<li>Run audit grant table;</li>
</ol>
<p>This... | <p>This can't be done.</p>
| 27,495 |
<p>I have read a lot of popular standards manuals for open source PHP projects.</p>
<p>A lot enforce underscores for variables spaces, and a lot enforce camelCase.</p>
<p>Should global functions and variables be named differently to class methods/properties?</p>
<p>I know the most important thing is consistency, but... | <p>I find camelCase a little more pleasant to type, because I find the underscore a bit awkward to type.</p>
<p>Don't use global variables.</p>
<p>I avoid procedural coding in PHP, I find OOP is easier to keep things organized. Besides, doesn't PHP have enough stuff in it's global namespace already?</p>
<p>Generally... | <p>Yes, the most important thing is consistency. If you are the lone developer, stick with a method. If you are working with a team, talk to the other team members. Differentiating between globals, functions/methods and classes will make reading the code much easier. For some people camelCase is easier than using_under... | 47,231 |
<p>I am just trying to dip my toes in this Ajax thing. I have a very basic question</p>
<p>I have seen the UI plugin(<a href="http://interface.eyecon.ro/docs/drag" rel="nofollow noreferrer">http://interface.eyecon.ro/docs/drag</a>) for jQuery, where you can drag and drop frames, stretch things, animate etc. So basical... | <p>Collect the state into an object, serialize it to <a href="http://www.json.org" rel="nofollow noreferrer">JSON</a>, do an HTTP POST using <a href="http://docs.jquery.com/Ajax" rel="nofollow noreferrer">AJAX</a> to a script on your server which saves it appropriately.</p>
<p>Load it with the reverse method (you can ... | <p>Yes Nilesh - the <a href="http://jquery.bassistance.de/api-browser/#height" rel="nofollow noreferrer">height()</a> and <a href="http://jquery.bassistance.de/api-browser/#width" rel="nofollow noreferrer">width()</a> methods. I'm not aware of a native method that provides positional data, although there may well be a ... | 25,315 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.