instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p><a href="http://tomcat.apache.org/tomcat-5.5-doc/deployer-howto.html" rel="noreferrer">Tomcat documentation</a> says: </p>
<p>The locations for Context Descriptors are;</p>
<p>$CATALINA_HOME/conf/[enginename]/[hostname]/context.xml<br>
$CATALINA_HOME/webapps/[webappname]/META-INF/context.xml</p>
<p>On my server, ... | <p>For the files you listed, the simple answer assuming you are using all the defaults, the order is (note the <strong>conf</strong>/Catalina/localhost):</p>
<pre><code>...tomcat/conf/context.xml
...tomcat/conf/Catalina/localhost/myapp.xml
...tomcat/webapps/myapp/META-INF/context.xml
</code></pre>
<p>I'm basing this ... | <p>I haven't found any official documentation, but I have observed the load order to be:</p>
<pre><code>1 tomcat_home/conf/context.xml
2 tomcat_home/webapps/myapp/META-INF/context.xml
</code></pre>
<p>Where #2 is the last one applied (so its settings override all previous ones, where applicable).</p>
<p>I have never... | 41,717 |
<p>A very well known major drawback of using CGI is poor webserver performance. But how secure are CGI (mainly C/C++) based applications? Are there any major security holes in CGI architecture built on C/C++? </p>
<p>I would like to know some real life implementations of CGI based web apps/web sites. One that I know o... | <p>The major security hole I would see anywhere, C/C++ included, would be not using a standard, open CGI library, not reading its documentation, and thinking you're secure anyway.</p>
<ul>
<li>don't re-invent the wheel. Use a CGI library. Some languages have this built-in (PHP probably does), others have it included... | <p>Many sites are CGI based. Many PHP sites that are located on hosting are run in CGI mode - mod_php is hard to used in shared environment - no suid.</p>
<p>In general, running as CGI has lower performance, but better for security - you have no access to webserver internals (as with mod_perl and mod_php) so using vul... | 25,835 |
<p>In .NET there is the <code>CultureInfo</code> class in the <code>System.Globalization</code> namespace. It has two similar properties both returning values of the <code>CultureInfo</code> type: <code>CurrentCulture</code> and <code>CurrentUICulture</code>.</p>
<p>What is the difference between them? </p>
<p>Which ... | <p><code>CurrentCulture</code> is the .NET representation of the default user locale of the system. This controls default number and date formatting and the like.</p>
<p><code>CurrentUICulture</code> refers to the default user interface language, a setting introduced in Windows 2000. This is primarily regarding the UI... | <p><strong>Differences:</strong></p>
<ol>
<li><a href="https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.currentculture" rel="noreferrer"><code>CurrentCulture</code></a> is for formatting of dates and currency while <a href="https://msdn.microsoft.com/en-us/library/system.threading.thread.curr... | 42,634 |
<p>I'm trying to read the contents of a text file, in this case a list of computer names (Computer1, computer2 etc,) and I thought that StreamReader would be what you would use but when I do the following:</p>
<pre><code>StreamReader arrComputer = new StreamReader(FileDialog.filename)();
</code></pre>
<p>I got this e... | <p>You need to import the <code>System.IO</code> namespace. Put this at the top of your .cs file:</p>
<pre><code>using System.IO;
</code></pre>
<p>Either that, or explicitly qualify the type name:</p>
<pre><code>System.IO.StreamReader arrComputer = new System.IO.StreamReader(FileDialog.filename);
</code></pre>
| <p>You need to add a reference to the System.IO assembly. You can do this via the "My Project" properties page under the References tab.</p>
| 35,251 |
<p>I was wondering about the best way to manage projects dependencies from ant. What are the pros and cons of the Maven Ant task and of Ivy?</p>
| <p>Since what you're wanting to do is add dependency management to an existing Ant project, that's precisely what Ivy's designed to do. Dependency management is a big part of Maven, but far from all of it. Maven is more of a project-oriented tool that does several other things in addition to dependencies. It would be w... | <p>I've just spent 2 days reading through the Ivy documentation and I have to say, USE MAVEN if you have any kind of choice. Ivy is complete and utter garbage as far as I can tell. I just wasted 2 days trying to incorporate it into my build and am cutting my losses now. Why?</p>
<ul>
<li>Ivy is a half-assed attempt at... | 41,212 |
<p>I'm wonder what the best way to convert a byte array (length 4) to an integer is in vb.net? I'm aware of BitConverter, but it seems like quite a waste to do a function call to do something that should be able to be done by copying 4 bytes of memory. Along the same lines, what about converting a single/double from i... | <p>"Copying bytes of memory" is something that .NET isn't particularly suited for (and VB.NET even less so). So, unless switching to C is an option for you, a function call is pretty much unavoidable for this.</p>
<p>BitConverter is a well-thought-out, tested function. Of course, you can avoid it by doing something li... | <p>You can block copy byte[] to int[] using System.Buffer class.</p>
| 28,097 |
<p>Running Mongrel 1.1.5 on Rails 2.1.2 using PostgreSQL 8.3 via ruby-pg 0.7.9 on OS X 10.4 server...</p>
<p>Added restful_authentication and exception_notification, the latter of which appears to be doing me no good when Mongrel simply dies with "Illegal instruction" every time I select /RESOURCE_NAME/new.</p>
<p>Do... | <p>You probably want to create a "UNIQUE" constraint on the field "Domain" - this constraint will raise an error if you create two rows that have the same domain in the database. For an explanation, see <a href="http://www.w3schools.com/sql/sql_unique.asp" rel="nofollow noreferrer">this tutorial in W3C school</a> -</p>... | <p>I'm not really sure I understood your question, but perhaps you are looking for SQL's <a href="http://www.w3schools.com/sql/sql_unique.asp" rel="nofollow noreferrer">"UNIQUE" constraint</a>. If the query tries to insert a pre-existing value to a field, you (PHP) will be notified about this constraint breach.</p>
| 34,877 |
<p>I am a bit confused why this code compiles. I leave out the "necessary" <code>#include <OpenGL/gl.h></code> and still the program can compile. How is this possible when my program is calling functions from the GL library, without including them.</p>
<pre><code>int main(int argc, char** argv)
{
glClearC... | <p>glClearColor isn't a macro so you don't <em>need</em> the headers to define it. If you add warnings:</p>
<pre><code>gcc -o test -Wall -W test.c -framework GLUT -framework OpenGL
</code></pre>
<p>Then you'll get a warning about the implicit declaration of glClearColor. You also won't be able to use any macros as th... | <p>This actually relates to the classic C&R hello world snippet:<br>
<a href="http://en.wikipedia.org/wiki/Hello_world#History" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Hello_world#History</a></p>
| 34,977 |
<p>Many of us need to deal with user input, search queries, and situations where the input text can potentially contain profanity or undesirable language. Oftentimes this needs to be filtered out.</p>
<p>Where can one find a good list of swear words in various languages and dialects? </p>
<p>Are there APIs available ... | <p><a href="http://blog.codinghorror.com/obscenity-filters-bad-idea-or-incredibly-intercoursing-bad-idea/" rel="noreferrer">Obscenity Filters: Bad Idea, or Incredibly Intercoursing Bad Idea?</a></p>
<p>Also, one can't forget <a href="http://habitatchronicles.com/2007/03/the-untold-history-of-toontowns-speedchat-or-bloc... | <p>Don't.</p>
<p>Because:</p>
<ul>
<li><strong><a href="http://www.urbandictionary.com/define.php?term=clbuttic" rel="nofollow noreferrer">Clbuttic</a></strong></li>
<li>Profanity is not OMG EVIL</li>
<li>Profanity cannot be effectively defined</li>
<li>Most people quite probably don't appreciate being "protected" fr... | 34,461 |
<p>I am developing a website using SQL Server Express on my development machine. My web hosting company is providing me with SQL Server 2005.</p>
<p>At the moment all I have is a database that I develop with and a database that is on the live server. I do not have the original scripts to generate the schema but I can ... | <p>Deploy schema changes as DDL upgrade scripts and, if you haven't already, add a table to contain the schema version number which you update at the end of each upgrade script.</p>
<p>EDIT: Yes, all your scripts should go into source control, including DDL scripts.</p>
| <p>I typically keep a testing copy of the live database on my local or virtual development box, which I flush routinely from the prod database down to testing. The testing copy is meant for my total exploitation. When I have something that I believe is ready for deployment, I move it to my development dataset, which ... | 31,370 |
<p>I've recently become aware that there's a distinction between IP multicasting (which apparently doesn't work that well on the public internet) and application multicasting (which is apparently used in IRC and PSYC, per <a href="http://en.wikipedia.org/wiki/Multicast" rel="nofollow noreferrer">http://en.wikipedia.org... | <p>The purpose of IP level multicasting is to reduce bandwidth for common network segments where many users wish to receive the same traffic. It's usually limited to one particular subnet and an IP router won't propagate the multicast beyond the subnet. This is done for scalability reasons - it wouldn't be a good i... | <p>Another example of application multicasting is using <a href="http://www.jgroups.org/" rel="nofollow noreferrer">JGroups</a> in <a href="http://en.wikipedia.org/wiki/Amazon_Elastic_Compute_Cloud" rel="nofollow noreferrer">Amazon EC2</a> or <a href="http://en.wikipedia.org/wiki/Google_App_Engine" rel="nofollow norefe... | 31,959 |
<p><a href="http://www.springframework.net/" rel="nofollow noreferrer">Spring.NET</a> 1.2.0 M1 comes with several XSD files for the <objects> node, database stuff, etc. However, it is an incomplete collection because it does not seem to include <spring> (used in <code>App.config</code>), <context>, o... | <p>They don't exist for or or the other top level elements that are used in App.config. Please enter a JIRA issue for Spring <a href="http://jira.springframework.org/secure/BrowseProject.jspa?id=10020" rel="nofollow noreferrer">here</a> as well as for Common Logging - <a href="http://sourceforge.net/tracker/?group_i... | <p>Have you tried using the XSD tool to reverse engineer an XML output file into the XSD you need? I did something similar when writing my own tool for log4net to get an XSD file.</p>
| 27,613 |
<p>Inside an asp.net page, should I use</p>
<pre><code><html><title>My page's title from México</title></html>
</code></pre>
<p>Or </p>
<pre><code><html><title>My page&rsquo;s title from M&eacute;xico</title></html>
</code></pre>
<p>Both examples have the same... | <p>I'm having a similar issue. You might be able to do something like this:</p>
<pre><code>SET arithabort arith_overflow off
SET @the_date = CAST(@date_string AS DATETIME)
IF @the_date is NULL
set @the_date = getdate()
SET arithabort arith_overflow on
</code></pre>
<p>However, this doesn't work well in a select.... | <p>Found <a href="http://blog.sqlauthority.com/2007/07/12/sql-server-validate-field-for-date-datatype-using-function-isdate/" rel="nofollow noreferrer">this in the second result</a> in Google when searching for "validate date string sql".</p>
<pre><code>----Invalid date
SELECT ISDATE('30/2/2007')
RETURNS : 0 (Zero)
--... | 3,050 |
<p>This is a C# console application. I have a function that does something like this:</p>
<pre><code>static void foo()
{
Application powerpointApp;
Presentation presentation = null;
powerpointApp = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
}
</code></pre>
<p>That's all it does.... | <p>It could be the certificate revocation list - the time-out on this is 15 seconds.
Is there anything in the event log? Can you check if any network connections are happening during the time-out?</p>
<p><a href="http://blogs.conchango.com/anthonysteele/archive/2007/02/07/Delay-when-starting-up-a-web-service.aspx" rel... | <p>Just guessing, but it is probably the time for PowerPoint to start up after the interop assemblies have loaded.</p>
| 35,324 |
<p>The problem: I have a class which contains a template method <code>execute</code> which calls another method <code>_execute</code>. Subclasses are supposed to overwrite <code>_execute</code> to implement some specific functionality. This functionality should be documented in the docstring of <code>_execute</code>.
... | <p>Well, if you don't mind copying the original method in the subclass, you can use the following technique.</p>
<pre><code>import new
def copyfunc(func):
return new.function(func.func_code, func.func_globals, func.func_name,
func.func_defaults, func.func_closure)
class Metaclass(type):
... | <p>Well the doc-string is stored in <code>__doc__</code> so it wouldn't be too hard to re-assign it based on the doc-string of <code>_execute</code> after the fact.</p>
<p>Basically:</p>
<p><code></p>
<pre>
class MyClass(object):
def execute(self):
'''original doc-string'''
self._execute()
class... | 9,737 |
<p>Can somebody please give me an example of a unidirectional @OneToOne primary-key mapping in Hibernate ? I've tried numerous combinations, and so far the best thing I've gotten is this :</p>
<pre><code>@Entity
@Table(name = "paper_cheque_stop_metadata")
@org.hibernate.annotations.Entity(mutable = false)
public class... | <p>I saved <a href="http://forum.hibernate.org/viewtopic.php?p=2381079" rel="nofollow noreferrer">this discussion</a> when I implemented a couple of @OneToOne mappings, I hope it can be of use to you too, but we don't let Hibernate create the database for us.</p>
<p>Note the GenericGenerator annotation.</p>
<p>Anyway... | <p>You should stay away from hibernate's OneToOne mapping, it is very dangerous. see <a href="http://opensource.atlassian.com/projects/hibernate/browse/HHH-2128" rel="nofollow noreferrer">http://opensource.atlassian.com/projects/hibernate/browse/HHH-2128</a></p>
<p>you are better off using ManyToOne mappings.</p>
| 40,594 |
<p>I've been struggling coming up with a good solution to separate my testing data from unit
tests (hard coded values). Until it dawned on me that I could create beans with spring
and use those beans to hold my data. </p>
<p>Are there any draw backs to coding my unit tests this way? Albeit they run a bit slower
... | <p>That was an interesting one...<br>
<strong>The OnInfoMessage event from the ADOConnection works but the Devil is in the details!</strong></p>
<p><strong>Main points:</strong><br>
use CursorLocation = clUseServer instead of the default clUseClient.<br>
use Open and not ExecProc with your ADOStoredProc.<br>
use NextR... | <p>Some enhancements to Francois' code (as tested with DXE2) to cater for multiple print statements and the results from a variable number of selects. The changes are subtle.</p>
<pre><code>procedure TForm1.ADOConnection1InfoMessage(Connection: TADOConnection;
const Error: Error; var EventStatus: TEventStatus);
var
... | 31,749 |
<p>I need write an update statement that used multiple tables to determine which rows to update, since in Oracle, multiple tables aren't allowed. The following query will return a "ORA-00971: Missing SET keyword" error</p>
<pre><code>UPDATE
TABLE1 a,
TABLE2 b
SET
a.COL1 = 'VALUE'
WHERE
a.FK = b.PK
AND b.COL... | <p>Another option:</p>
<pre><code>UPDATE TABLE1 a
SET a.COL1 = 'VALUE'
WHERE a.FK IN
( SELECT b.PK FROM TABLE2 b
WHERE b.COL2 IN ('SET OF VALUES')
)
</code></pre>
<p>Your second example would work if (a) the view included the <strong>declared</strong> PK of TABLE1:</p>
<pre><code>UPDATE
(
SELECT
a.COL1... | <p>Each row in the result set of the query in your UPDATE clause must map back to one and only one row in the table you are trying to update, and in a way that Oracle can follow automatically. Since the query is really a view, one way to think about it is that Oracle needs to be able to join the view back to the targe... | 28,494 |
<pre><code>class Foo
{
static bool Bar(Stream^ stream);
};
class FooWrapper
{
bool Bar(LPCWSTR szUnicodeString)
{
return Foo::Bar(??);
}
};
</code></pre>
<p><code>MemoryStream</code> will take a <code>byte[]</code> but I'd <em>like</em> to do this without copying the data if possible.</p>
| <p>You can avoid the copy if you use an <a href="http://msdn.microsoft.com/en-us/library/system.io.unmanagedmemorystream.aspx" rel="nofollow noreferrer"><code>UnmanagedMemoryStream()</code></a> instead (class exists in .NET FCL 2.0 and later). Like <code>MemoryStream</code>, it is a subclass of <code>IO.Stream</code>, ... | <p>If I had to copy the memory, I think the following would work:</p>
<pre><code>
static Stream^ UnicodeStringToStream(LPCWSTR szUnicodeString)
{
//validate the input parameter
if (szUnicodeString == NULL)
{
return nullptr;
}
//get the length of the string
size_t lengthInWChars = wcslen(szUnic... | 6,392 |
<p>I have what is essentially a jagged array of name value pairs - i need to generate a set of unique name values from this. the jagged array is approx 86,000 x 11 values.
It does not matter to me what way I have to store a name value pair (a single string "name=value" or a specialised class for example KeyValuePair).<... | <p><strong>I have it running in 0.34 seconds</strong> down from 9+ minutes</p>
<p>The problem is when comparing the KeyValuePair structs.
I worked around it by writing a comparer object, and passing an instance of it to the Dictionary.</p>
<p>From what I can determine, the KeyValuePair.GetHashCode() returns the hashc... | <p>if you don't need any specific correlation between each key/value pair and the unique values you're generating, you could just use a GUID? I'm assuming the problem is that your current 'Key' isn't unique in this jagged array.</p>
<pre><code>Dictionary<System.Guid, KeyValuePair<string, string>> myDict
... | 28,837 |
<p>I'm designing a multi-tiered database driven web application – SQL relational database, Java for the middle service tier, web for the UI. The language doesn't really matter.</p>
<p>The middle service tier performs the actual querying of the database. The UI simply asks for certain data and has no concept that it's ... | <p>The very first question should be:</p>
<p>¿The user needs to, or is capable of, manage this amount of data?</p>
<p>Although the result set should be paged, if its potentially size is so huge, the answer will be "probably not", so the UI shouldn't try to show it.</p>
<p>I worked on J2EE projects on Health Care Sys... | <p>In ASP.NET I would use server-side paging, where you only retrieve the page of data the user has requested from the data store. This is opposed to retrieving the entire result set, putting it into memory and paging through it on request.</p>
| 28,696 |
<p>Do you have any strategies for retrofitting unit tests onto a code base that currently has no unit tests ?</p>
| <p>Read <a href="https://rads.stackoverflow.com/amzn/click/com/0131177052" rel="noreferrer" rel="nofollow noreferrer">Working Effectively With Legacy Code by Feathers</a>.</p>
<p>Jimmy Bogard has a <a href="http://www.lostechies.com/blogs/jimmy_bogard/archive/tags/Refactoring/default.aspx" rel="noreferrer">good blog s... | <p>Is it possible that we are in a panic and are getting confused between unit tests and performance tests? Is it that your application works fine with few users, but starts throwing errors when under heavier load? If so, unit tests are not the answer. Unit tests != Load tests.</p>
<p>If unit tests are in fact the ... | 6,436 |
<p>I've done this before in C++ by including sqlite.h but is there a similarly easy way in C#?</p>
| <p><a href="https://www.nuget.org/packages/Microsoft.Data.Sqlite" rel="nofollow noreferrer">Microsoft.Data.Sqlite</a> by Microsoft has over 9000 downloads every day, so I think you are safe using that one.</p>
<p>Example usage from <a href="https://learn.microsoft.com/dotnet/standard/data/sqlite/" rel="nofollow norefer... | <p>if you have any problem with the library you can use <code>Microsoft.Data.Sqlite;</code></p>
<pre><code> public static DataTable GetData(string connectionString, string query)
{
DataTable dt = new DataTable();
Microsoft.Data.Sqlite.SqliteConnection connection;
Microsoft.Da... | 4,560 |
<p>[<em>Of course, the question is not restricted to a specific "friend" implementation, feel free though to point out implementation specifics if relevant</em>]</p>
<p>Reading through the unanswered questions, I stumbled upon the <a href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.interna... | <p>I've made extensive use of this technique - it means that my unit tests can test aspects of the code library that aren't visible to normal consumers.</p>
<p>While using <code>[InternalsVisibleTo]</code> does increase coupling, I believe the (minor) increase is well worth the gains.</p>
<p>My unit tests are already... | <p>I think using <code>InternalsVisibleToAttribute</code> to enable unit testing is perfectly reasonable. My "unit" in "unit testing" is a class, and that includes <code>internal</code> classes, so I want to test them. <a href="https://stackoverflow.com/questions/34571/whats-the-best-way-of-unit-testing-private-metho... | 32,651 |
<p>A quick question about elf file headers, I can't seem to find anything useful on how to add/change fields in the elf header. I'd like to be able to change the magic numbers and to add a build date to the header, and probably a few other things. </p>
<p>As I understand it the linker creates the header information, ... | <p>I don't know of linker script commands that can do this, but you can do it post-link using the <strong>objcopy</strong> command. The <strong>--add-section</strong> option can be used to add a section containing arbitrary data to the ELF file. If the ELF header doesn't contain the fields you want, just make a new s... | <p>In Linux Console:</p>
<p>$ man ld</p>
<p>$ ld --verbose</p>
<p>HTH</p>
| 28,886 |
<p>Lets assume my classes are loaded from a compressed .war file or loaded elsewhere,
how can I discover all the resources in a given package? Enumerating files will not really work, since this is a war file. Most likely this will involve using the current classloader?</p>
<p>Is there a library out there that does ... | <p>Yes. You can use <code>ClassLoader.getResources("")</code>;<br/><br/>
Or you could use ferret API:
<br/>
<a href="https://www.ohloh.net/p/pureperfect-ferret">https://www.ohloh.net/p/pureperfect-ferret</a></p>
<p>This API allows you to scan the class path as well as arbitrary archives and directories using the Visi... | <p>I do this:
- before packaging, <code>ls myResources/*.ext > myResources/list.txt</code>
- then just read the file first</p>
| 22,565 |
<p>Can anybody explain the idea behind JSP custom tag libraries and the JSP 2 tag files?</p>
<p>Are they just different ways to do the same thing?</p>
<p>How do they compare? What are their pros and cons, and which is better?</p>
| <p>I <3 tag files, but that lead developer of JSTL is smoking crack if they really said that. You CANNOT re-write all tag library tags as tag file tags, for one very important reason: tag files can't do:</p>
<p>return EVAL_BODY_INCLUDE;</p>
<p>In other words, tag files only have three options for their body-conte... | <p><strong>Problems Developing Custom Tags</strong></p>
<p>Traditional custom tags require Java programming
skills.</p>
<p>All but the simplest custom tags are not easy to write.</p>
<p>The purpose of JSP, in contrast to servlets, is to use
markup language to manage layout with embedded
dynamic content.</p>
<p>Havi... | 28,289 |
<p>Is there any way to save an object using Hibernate if there is already an object using that identifier loaded into the session?</p>
<ul>
<li>Doing <code>session.contains(obj)</code> seems to only return true if the session contains that exact object, not another object with the same ID.</li>
<li>Using <code>merge(o... | <p>Have you tried calling .SaveOrUpdateCopy()?
It should work in all instances, if there is an entity by the same id in the session or if there is no entity at all. This is basically the catch-all method, as it converts a transient object into a persistent one (Save), updates the object if it is existing (Update) or e... | <p>How about:</p>
<pre><code>session.replicate(entity, ReplicationMode.OVERWRITE);
</code></pre>
<p>?</p>
| 4,599 |
<p>How do I detect if the system has a default recording device installed?
I bet this can be done through some calls to the Win32 API, anyone has any experience with this?</p>
<p>I'm talking about doing this through code, not by opening the control panel and taking a look under sound options.</p>
| <p>Using the <a href="https://www.microsoft.com/en-in/download/details.aspx?id=6812" rel="nofollow noreferrer">DirectX SDK</a>, you can call DirectSoundCaptureEnumerate, which will call your DSEnumCallback function for each DirectSoundCapture device on the system. The first parameter passed to your DSEnumCallback is a... | <p>There is an Open Source Audio API called <a href="http://www.portaudio.com/" rel="nofollow noreferrer">PortAudio</a> that has a method you could use. I think the method is called Pa_GetDeviceInfo() or something.</p>
| 6,263 |
<p>I have a <a href="http://en.wikipedia.org/wiki/Pseudorandom_number_generator" rel="nofollow noreferrer">pseudorandom number generator</a> (PRNG) with nice properties which uses six <code>UInt32</code>s as state. I need to come up with a reasonable way to seed it. Two obvious possibilities are: 1) generate six random... | <p>If it needs <code>UInt32</code>, then <code>Random</code> is more convenient? just <code>Next()</code>, <code>Next()</code>, <code>Next()</code> etc (and cast)... (use the same <code>Random</code> instance however - don't create <code>new Random()</code> each time).</p>
<p>It depends on what the intent is as to whe... | <p>Try this for your seed value...</p>
<pre><code>(UInt32)Math.Pow(System.DateTime.Now.TimeOfDay.TotalMilliseconds, 11.0 / 7.0)
</code></pre>
<p>It just raises the current time's milliseconds to the 11/7th power, which is just arbitrary.
You can experiment with other fractions to see if they work better for you.</p>... | 48,279 |
<p>We are using SourceForge Enterprise Edition 4.4 in one of our project.</p>
<p>My question is, in CollabNet SFEE (SourceForge Enterprise Edition 4.4), how will we get attachments associated with an Artifacts Using SFEE SOAP API?</p>
<p>We have made our own .net 2.0 client. We are not using .net SDK provided by Coll... | <p>If you commit with a message you can add "[artf1000]" (where artf1000 is your artifact number) to the beginning or end of your commit message. Then it will associate to that artifact you can also do this with documents using doc1000, to get the id of the item you can use the URL it is what is after the <a href="http... | <p>You can cheat a little bit and have a look at the scripts from SFEE. Log into your SFEE via SSH and take a look at the following script: </p>
<pre><code>/usr/local/sourceforge/sourceforge_home/integration/post-commit.py
</code></pre>
<p>Maybe it helps...</p>
| 5,885 |
<p>I have a multi file C program. I'd like the user to be able to specify different debugging levels at run time.</p>
<p>What is the best way to implement this?</p>
<p>I was thinking of having a debug(level, "message") type function exported and used everywhere. Any better/other ideas?</p>
| <p>Jonathan's suggestion is good but since C99 we have variadic macros so one doesn't need to use double braces for debug macro.</p>
<p>There is a light version of logging header I use:</p>
<pre><code>#define LOG_FATAL (1)
#define LOG_ERR (2)
#define LOG_WARN (3)
#define LOG_INFO (4)
#define LOG_DBG ... | <p>There is a very good C port of log4j, <a href="http://log4c.sourceforge.net/" rel="nofollow noreferrer">log4c</a>.</p>
| 42,494 |
<p>I am running following <code>PHP</code> code to interact with a MS Access database.</p>
<pre><code>$odbc_con = new COM("ADODB.Connection");
$constr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . $db_path . ";";
$odbc_con -> open($constr);
$rs_select = $odbc_con -> execute ("SELECT * FROM Main");
</code... | <p>ADODB has its own rules for what recordcount is returned depending on the type of recordset you've defined. See:</p>
<p><a href="http://support.microsoft.com/kb/194973" rel="nofollow noreferrer">MS Knowledge Base article 194973</a></p>
<p><a href="http://www.w3schools.com/ADO/prop_rs_recordcount.asp" rel="nofollow... | <p>If you're using a dynamic cursor type of connection, then it could actually change. Someone may delete a record from that database while you're browsing through pages of records. To avoid, use a static sort of snapshot cursor. I have this bookmarked which will explain it well. This always got me and the bookmark... | 15,388 |
<p>Is a Star-Schema design essential to a data warehouse? Or can you do data warehousing with another design pattern?</p>
| <p>Using <a href="http://en.wikipedia.org/wiki/Star_schema" rel="noreferrer">star schemas</a> for a data warehouse system gets you several benefits and in most cases it is appropriate to use them for the top layer. You may also have an operational data store (ODS) - a normalised structure that holds 'current state' an... | <p>It's possible to do without. However, you will make life hard for yourself -- your organization will want to use standard tools that live on top of DWs, and those tools will expect a star schema -- a lot of effort will be spent fitting a square peg in a round hole.</p>
<p>A lot of database-level optimizations assu... | 13,529 |
<p>I've just created a new Windows XP VM on my Mac using VMware Fusion. The VM is using NAT to share the host's internet connection.</p>
<p>How do I access a Rails application, which is accessible on the Mac itself using <code>http://localhost:3000</code>?</p>
| <p>On the XP machine, find your IP address by going to the command prompt and typing <code>ipconfig</code>. Try replacing the last number with 1 or 2. For example, if your IP address is 192.168.78.128, use <a href="http://192.168.78.1:3000" rel="noreferrer">http://192.168.78.1:3000</a>.</p>
| <ol>
<li>On the XP machine, Start -> Connect To -> Show all connections.</li>
<li>Double click Local Area Connection.</li>
<li>Click the Support tab.</li>
<li>Take the Default Gateway IP <code><gateway-ip</code>> and hit http://<code><gateway-ip</code>>:3000 in your browser.</li>
</ol>
<p>Gotcha: You must have h... | 8,669 |
<p>What is the difference between the selectitem and selectitems tags in jsf?</p>
| <p>The difference is exactly what you would expect. The <code>selectitem</code> tag adds a single item to the HTML list while <code>selectitems</code> adds multiple items.</p>
<p>From <a href="http://www.jsftoolbox.com/documentation/help/12-TagReference/core/f_selectItem.html" rel="nofollow noreferrer">JSF Core Tag Re... | <p>Its also nice to remember that the f:selectItems can point to a SelectItem, an array or Collection of SelectItem objects, or a Map mapping labels to values.</p>
| 42,818 |
<p>A program receives a list of Messages (base type). Each message in the list has to be processed according to it's type (descendant type). However, different messages need different inputs in order to be processed correctly.</p>
<p>What is the following technique called? (I haven't checked this code in a compiler... | <p>They are both examples of the <em>factory method</em> pattern. The only difference is that the second example has the method in its own static class. </p>
<p>This would be an example of the <em>abstract factory</em> pattern:</p>
<pre><code>abstract class MessageProcessorFactory
{ public abstract MessageProcessor ... | <p>In my understanding <em>factory method</em> defnies the abstract type of class with which to work with but delegates the creation of the concrete type to the succeeding/implementing classes.
<em>Abstract factory</em> would define an interface for a manufactorer of a set of corresponding classes.
A <em>builder</em> ... | 22,219 |
<p>How can I create a file dsn for connecting to an AS400 system using the iSeries ODBC driver?</p>
<p>The iSeries ODBC driver allows many settings to be configured. Where can I find a list of all properties that can be set in the file DSN?</p>
| <p><em>Driver={iSeries Access ODBC Driver};System=server;Uid=user;Pwd=password;</em></p>
<p>Where server is the system to connect (either IP address or hostname), username and password.</p>
<p>You can have a .dsn file like this:</p>
<pre><code>[ODBC]
DRIVER=iSeries Access ODBC Driver
System=server;
Uid=user;
Pwd=pas... | <p>I just discovered you can create a file DSN using the ODCB Administration tool, for any type of ODBC driver.</p>
| 46,763 |
<p>I'm starting a new project here (Windows Forms). What's the best option today for a small (free as in beer) DBMS?</p>
<p>I've used SQL Server Express on the past projects, but time and time again I hear people saying that the product from Oracle is faster and more powerful.</p>
<p>It will be used in a small compan... | <p>I would go for the <strong>SQL Server Express</strong> solution, unless you absolutely have to use a feature in Oracle that SQL Server does not have and you have no usable workaround.</p>
<p>Example of Oracle's strengths: </p>
<ul>
<li>Analytical Functions in Oracle ROCK!</li>
<li><a href="http://en.wikipedia.org... | <p>Is this any use:</p>
<p><a href="https://web.archive.org/web/1/http://downloads.techrepublic%2ecom%2ecom/5138-9592-6028761.html" rel="nofollow noreferrer">https://web.archive.org/web/1/http://downloads.techrepublic%2ecom%2ecom/5138-9592-6028761.html</a></p>
<p>NB Registration is required</p>
| 3,115 |
<p>I'm using Office Automation in .NET. It is leaving behind the excel.exe program. I know the fix - it is all about explicitely defining the variables. Once defined, I can properly de-allocate the ram and the GC will clean them up.</p>
<p>The problem is, I have literally thousands of lines of code to go through. So I... | <p><a href="http://www.automatedqa.com/techpapers/net_allocation_profiler.asp" rel="nofollow noreferrer">http://www.automatedqa.com/techpapers/net_allocation_profiler.asp</a></p>
| <p>Just to be clear, you need to explicitly Quit Excel after you are done using it through automation. If you don't an instance will keep running, even if your variables go out of scope and garbage collection runs. I believe the command it Quit():</p>
<pre><code>Excel.ApplicationClass excel = new Excel.ApplicationCl... | 44,385 |
<p>When you cut or break a PLA model (for example to remove support) it often leaves an ugly while mark where the removed piece was connected.</p>
<p>Sanding also tend to leave dull white scratches on the sanded surface.</p>
<p>What can I do to restore the white areas to the original filament color?</p>
| <p>A quick blast from a heat gun will very slightly reflow the surface texture and eliminate white marks. </p>
<p>However, it's important to avoid over-heating the perimeter layers or you'll see them soften and sag into the infill. So wait for the heat gun to get fully hot and then use a short duration of high heat. L... | <p>Note that on lighter colours these light scratches can be hard to see. On white PLA they're almost invisible unless you hold it against the light at an angle and look at the specular reflection.</p>
<p>I've had some luck on a flat surface (the face of a game tile I printed) by going through various grades of sand p... | 202 |
<p>When should I include PDB files for a production release? Should I use the <code>Optimize code</code> flag and how would that affect the information I get from an exception?</p>
<p>If there is a noticeable performance benefit I would want to use the optimizations but if not I'd rather have accurate debugging info. ... | <p>When you want to see source filenames and line numbers in your stacktraces, generate PDBs using the pdb-only option. Optimization is separate from PDB generation, i.e. you can optimize <em>and</em> generate PDBs without a performance hit.</p>
<p>From <a href="http://msdn.microsoft.com/en-us/library/8cw0bt21(VS.80).... | <p>There is no need to include them in your distribution, but you should definitely be building them and keeping them. Otherwise debugging a crash dump is practically impossible.</p>
<p>I would also turn on optimizations. Whilst it does make debugging more difficult the performance gains are usually very non-trivial d... | 6,325 |
<p>I'm completely new at C# and NUnit.</p>
<p>In Boost.Test there is a family of <code>BOOST_*_THROW</code> macros. In Python's test module there is <code>TestCase.assertRaises</code> method.</p>
<p>As far as I understand it, in C# with NUnit (2.4.8) the only method of doing exception test is to use <code>ExpectedExc... | <p>I'm surprised I haven't seen this pattern mentioned yet. David Arno's is very similar, but I prefer the simplicity of this:</p>
<pre><code>try
{
obj.SetValueAt(-1, "foo");
Assert.Fail("Expected exception");
}
catch (IndexOutOfRangeException)
{
// Expected
}
Assert.IsTrue(obj.IsValid());
</code></pre>
| <p>I've always adopted the following approach:</p>
<pre><code>bool success = true;
try {
obj.SetValueAt(-1, "foo");
} catch () {
success = false;
}
assert.IsFalse(success);
...
</code></pre>
| 32,132 |
<p>In my second year of University we were "taught" Haskell, I know almost nothing about it and even less about functional programming.</p>
<p>What is functional programming, why and/xor where would I want to use it instead of non-functional programming and am I correct in thinking that C is a non-functional programmi... | <p>One key feature in a functional language is the concept of first-class functions. The idea is that you can pass functions as parameters to other functions and return them as values.</p>
<p>Functional programming involves writing code that does not change state. The primary reason for doing so is so that successive ... | <p>I find <a href="http://blog.jenkster.com/2015/12/what-is-functional-programming.html" rel="nofollow">What Is Functional Programming?</a> to be useful</p>
<blockquote>
<p>Functional programming is about writing pure functions, about removing
hidden inputs and outputs as far as we can, so that as much of our
co... | 4,401 |
<p>I am very new in the 3D printing scene.
After a lot of searching for my specific problem (and didn't find any answers, of course) I decided to reach out.</p>
<p>I bought a Creality Ender 3 Pro in November and after a few days of lovely prints
I decided to upgrade the printer with a glass bed and "Aluminum Dual... | <p>This is an older Ender 3 Pro, they at one point came with these press-fit gears, these are not intended to be removed which is a poor design decision. I would recommend buying a new motor than going through the hassle of removing it.</p>
| <p>Same problem here. I removed it by force using a pliers and a hammer, then drill a spot on the shaft using ikea drill. Everything works fine so far.</p>
| 1,811 |
<p>How do you configure cruiseControl to send out emails that contains the error log whenever a build fails? I've gotten it to send out emails to users when the build fails, but it does not include the actual error that caused the build to fail. I know that if I only configure it to send out emails to the users that ... | <p>You can check if \cruisecontrol.net\server\xsl\compile.xsl is the same as \cruisecontrol.net\webdashboard\xsl\compile.xsl.</p>
<p>Compile.xsl is the default file used to print the error messages from your error log. The one in \webdashboard\ is used for the web dashboard (as the name implies) and the one under \ser... | <p>The build log is getting generated. I can see the error. It's just not included in the email.</p>
| 29,093 |
<p>I'm interested in learning some (ideally) database agnostic ways of selecting the <em>n</em>th row from a database table. It would also be interesting to see how this can be achieved using the native functionality of the following databases: </p>
<ul>
<li>SQL Server</li>
<li>MySQL</li>
<li>PostgreSQL</li>
<li>SQLit... | <p>There are ways of doing this in optional parts of the standard, but a lot of databases support their own way of doing it.</p>
<p>A really good site that talks about this and other things is <a href="http://troels.arvin.dk/db/rdbms/#select-limit" rel="noreferrer">http://troels.arvin.dk/db/rdbms/#select-limit</a>.</p... | <p>unbelievable that you can find a SQL engine executing this one ...</p>
<pre><code>WITH sentence AS
(SELECT
stuff,
row = ROW_NUMBER() OVER (ORDER BY Id)
FROM
SentenceType
)
SELECT
sen.stuff
FROM sentence sen
WHERE sen.row = (ABS(CHECKSUM(NEWID())) % 100) + 1
</code></pre>
| 3,730 |
<p>There is a case where a map will be constructed, and once it is initialized, it will never be modified again. It will however, be accessed (via get(key) only) from multiple threads. Is it safe to use a <code>java.util.HashMap</code> in this way?</p>
<p>(Currently, I'm happily using a <code>java.util.concurrent.Co... | <p>Your idiom is safe <strong>if and only if</strong> the reference to the <code>HashMap</code> is <em>safely published</em>. Rather than anything relating the internals of <code>HashMap</code> itself, <em>safe publication</em> deals with how the constructing thread makes the reference to the map visible to other threa... | <p><a href="http://www.docjar.com/html/api/java/util/HashMap.java.html" rel="nofollow noreferrer">http://www.docjar.com/html/api/java/util/HashMap.java.html</a></p>
<p>here is the source for HashMap. As you can tell, there is absolutely no locking / mutex code there.</p>
<p>This means that while its okay to read from... | 12,973 |
<p>I wonder if there is any good guideline for system administrators to calculate the resources needed to host an ASP.NET website? I want to do some estimates on the processing power needed so I know what kind of VPS/Cloud I need to get.</p>
| <p>Load testing will be your best solution.</p>
<p>Applications differ in how they scale depending on a large number of variables including types of problem solving, approach to solution and other factors.</p>
<p>100 concurrent users consuming 10% CPU does not mean 500 concurrent at 50%, it could be 20% or it could b... | <p>Totally depends on the application. <br><br>
If your looking at requirements for a specific application, then put it on whatever hardware you have that looks like a server, start perfmon running with a good selection of counters & then run some automated tools for load testing, performing some common tasks agai... | 23,134 |
<p>I am looking for a Java open source beautifier or reformatter for SQL that I can use to clean up DDL statements that I am generating with <a href="http://www.openarchitectureware.org" rel="nofollow noreferrer">openArchitectureWare</a>.</p>
<p>Nothing in the answer to "<a href="https://stackoverflow.com/questions/20... | <p><strong>UPDATE 2:</strong></p>
<p><code>org.hibernate.jdbc.util.BasicFormatterImpl</code> got moved in release 4.0. It is now located at: <code>org.hibernate.engine.jdbc.internal.BasicFormatterImpl</code>.</p>
<p><strong>UPDATE 1:</strong></p>
<p>Technology marches on. As noted by Alex, <strong><code>org.hibernat... | <p>You could just use a <a href="http://antlr.org/grammar/list" rel="nofollow noreferrer">SQL grammar</a> and build the AST with <a href="http://antlr.org" rel="nofollow noreferrer">antlr</a>. Then you can output the tree in any format you like.</p>
| 40,282 |
<p><strong>First a bit of background.</strong> </p>
<p>I have been working on the MS platform for my entire development career. Up until 2 weeks ago, I had never booted any other OS than 98/XP/Vista. I started using VSS long long ago, and made the change to SVN about 2 years ago. With SVN I use TortiseSVN and use the ... | <p>For plugins, I'd personally recommend just sticking them in the vendor folder and add them to SVN as if you'd written the code yourself. Piston was also a great solution, but switched away from it when all the common plugins started moving to github (piston has been unreliable since then)</p>
<p>For gems, hopefully... | <p>Orion mentioned having to rebuild gems that have been vendored when sharing them between different OS's - you can use the gems:build rake task to rebuild them automatically.</p>
| 36,126 |
<p>This most be the second most simple rollover effect, still I don't find any simple solution.</p>
<p><strong>Wanted:</strong> I have a list of items and a corresponding list of slides (DIVs). After loading, the first list item should be selected (bold) and the first slide should be visible. When the user hovers over... | <p>Rather than displaying all slides when JS is off (which would likely break the page layout) I would place inside the switch LIs real A links to server-side code which returns the page with the "active" class pre-set on the proper switch/slide.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-consol... | <p>The only thing that's wrong with this code (at least to me) is that you're not using a loop to process all elements. Other than that, why not to it like that?</p>
<p>And with loop, I mean grabbing the container element via a JQuery and iterating over all child elements – basically a one-liner.</p>
| 5,484 |
<p>SqlDataReader is a faster way to process the stored procedure. What are some of the advantage/disadvantages of using SQLDataReader?</p>
| <p>I assume you mean "instead of loading the results into a DataTable"?</p>
<p>Advantages: you're in control of how the data is loaded. You can ask for specific data types, and you don't end up loading the whole set of data into memory all at the same time unless you want to. Basically, if you want the data but don't ... | <p>The data might not be concluesive and you are not in control of your actions that why the milk man down the road has always got to carry data with him or else they gona get cracked by the data and the policeman will not carry any data because they think that is wrong to keep other people's data and its wrong to do s... | 23,402 |
<p>I have the following solution project structure:</p>
<blockquote>
<p>Application.Core.Entities</p>
<p>Application.Xtend.CustomerName.Entities</p>
</blockquote>
<p>In the Core project I have an entity <strong>Customer</strong> defiend. In the XTend project, I have an entity defined that subclasses Customer named <str... | <p>I asked this same question on the NHibernate Users mailing list and the solution was so obvious that I am somewhat embarrassed that I couldn't see it. </p>
<p>The hibernate-mapping attributes assembly and namespace are convenient short cuts that allow you to not have to fully qualify your class names. This lets you... | <p>You need to map using the <code>extends</code> attribute of the <code><class></code> element (AFAIK, this is new in NHibernate 2.0). Then you can have your subclass mapping (<code>.hbm.xml</code>) in the XTend assembly. </p>
<p>You might have to use the AddAttribute/AddProperty (can't remember what it's calle... | 32,481 |
<p>From a <a href="http://www.joelonsoftware.com/items/2007/01/26.html" rel="nofollow noreferrer">Joel's post on Copilot</a>:</p>
<blockquote>
<p>Direct Connect! We’ve always done
everything we can to make sure that
Fog Creek Copilot can connect in any
networking situation, no matter what
firewalls or NATs... | <p>It's pretty tricky and interesting. I'm sure I have some details wrong, but the overview is this:</p>
<p>The programs can already talk to each other through Joel's server, so they can exchange information with each other and Joel's server. Further, Joel has their external IP addresses, and they give joel informat... | <p>There is a technique called "<a href="https://en.wikipedia.org/wiki/Hole_punching_(networking)" rel="nofollow noreferrer">Hole Punching</a>" that works well with "Cone" NAT (Cone is a technical familly of router). That's not an 100% sure technique, today, it works well with UDP on about 80% of the router.</p>
<p>Th... | 6,591 |
<p>How do I check to see if a column exists in a <code>SqlDataReader</code> object? In my data access layer, I have create a method that builds the same object for multiple stored procedures calls. One of the stored procedures has an additional column that is not used by the other stored procedures. I want to modifi... | <pre><code>public static class DataRecordExtensions
{
public static bool HasColumn(this IDataRecord dr, string columnName)
{
for (int i=0; i < dr.FieldCount; i++)
{
if (dr.GetName(i).Equals(columnName, StringComparison.InvariantCultureIgnoreCase))
return true;
... | <p>You can also call <a href="http://support.microsoft.com/kb/310107" rel="nofollow noreferrer">GetSchemaTable()</a> on your DataReader if you want the list of columns and you don't want to have to get an exception...</p>
| 48,805 |
<p>Does anyone have any suggestions (or a regular expression) for parsing the HTTP Accept header?</p>
<p>I am trying to do some content-type negotiation in ASP.NET MVC. There doesn't seem to be a built in way (which is fine, because there are a lot of schools of thought here), but the parsing is not entirely trivial a... | <p>Have you seen <a href="http://www.xml.com/pub/a/2005/06/08/restful.html" rel="noreferrer">this article</a>? It gives a pretty comprehensive implementation for parsing the Accept header and subsequently doing something useful with it.</p>
| <p>The <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html" rel="nofollow noreferrer">RFC</a> is quite complex. If the regex where to follow these rules to the letter, it would become several lines long.</p>
<p>If you already have the Accept-header, and ignore the quotes and the parameters, you could do somethin... | 31,870 |
<p>I have a couple of tables which are used to log user activity for an application. The tables looks something like this (pseudo code from memory, may not be syntactically correct):</p>
<pre><code>create table activity (
sessionid uniqueidentifier not null,
created smalldatetime not null default getutcdate()
);
... | <p>There's probably more efficient ways to do this as well, but this is closest to your original:</p>
<pre><code>truncate table activity_summary;
insert into activity_summary (sessionid, first_activity_desc, last_activity_summary)
select a.sessionid
,(select top 1 ad.activity_desc from activity_detail AS ad where ad.... | <p>Roughly,</p>
<p>INSERT etc.</p>
<pre><code>SELECT a.sessionid, d1.activity_description, d2.activity_description
FROM activity a
JOIN detail d1 ON a.sessionid = d1.sessionid
JOIN detail d2 ON a.sessionid = d2.sessionid
WHERE NOT EXISTS
(SELECT 1 FROM detail WHERE sessionid = a.sessionid AND created < d1.c... | 41,156 |
<p>Is tight looping in a program bad?</p>
<p>I have an application that has two threads for a game-physics simulator. An updateGame thread and a render thread. The render thread is throttled by causing the thread to sleep for some milliseconds (to achieve the frame-rate I want) and the updateGame thread (that updates... | <p>I read a really great post about efficiently and effectively executing physics calculations loop: <a href="http://gafferongames.com/game-physics/fix-your-timestep/" rel="nofollow noreferrer">Fix Your Timestep!</a></p>
<p>When a game is running that is usually the main application that the user cares about so tight ... | <p>For a game, probably not. Just make sure your game pauses when the switches tasks.</p>
| 47,216 |
<p>The situation is this. I have an asp.net webservice application...say a page called api.asmx</p>
<p>In the code behind I have several methods, for example:</p>
<pre><code>[WebMethod(Description="Method1")]
public int GetSomething(int num1, int num2){
try{
return SomeObject.DatabaseCall.DoSomething(num1, num... | <p>Any unhandled exceptions will be bubbled up to your Application_Error event in the Global.asax file. From there, you can call Server.GetLastError() to retrieve the Exception instance. </p>
<p>Once you have the exception, you can look at the stack trace. You will also have access to the Request object so you can ... | <p>Your LogError method could call <a href="http://msdn.microsoft.com/en-us/library/system.environment.stacktrace.aspx" rel="nofollow noreferrer">Environment.StackTrace</a>. Then it would "know" what method called it. </p>
| 34,060 |
<p>I currently don't know any thing about web services, except that they are used to allow an application to share its functions.</p>
<ul>
<li>Where & how to start? </li>
<li>Does any book on web services work with me if I use PHP as my programming language?</li>
<li>Does anyone know any IRC channel for help? </li... | <p>I've used two good books in the past that focus on web services and PHP. <a href="https://rads.stackoverflow.com/amzn/click/com/0764589547" rel="noreferrer" rel="nofollow noreferrer">Professional Web APIs with PHP</a> is good if you want to quickly get started <em>using</em> 3rd party APIs (like Amazon, Google, eBa... | <p>Web services are not hard to learn. If you already have PHP experience then you know most of what you need to do a web service. This <a href="http://webservices.xml.com/pub/a/ws/2004/03/24/phpws.html" rel="nofollow noreferrer">article</a> might start you off creating your first web service in php.</p>
| 32,048 |
<p>I've downloaded a tutorial that had fonts included in the source. When I try to build the project, I always get the following error message:</p>
<blockquote>
<p>Error 1 The font family "Joystick"
could not be found. Please ensure the
requested font is installed, and is a
TrueType or OpenType font.</p>
</... | <p>Do you see the Font in the Windows\Fonts directory? If the font is installed, it should be there. Have you try to use this font in Word or other program to see if it's really installed?</p>
<p>You might contact the person who is the source code is coming and ask him the question, or you could try to use his source ... | <p>Just Restart your editor once. It works. Because the editor loads the fonts only in the beginning.</p>
| 31,775 |
<p>My PHP/MS Sql Server 2005/win 2003 Application occasionally becomes very unresponsive, the memory/cpu usage does not spike. If i try to open any new connection from sql management studio, then the it just hangs at the open connection dialog box.
how to deterime the total number of active connections ms sql server ... | <p>This shows the number of connections per each DB:</p>
<pre><code>SELECT
DB_NAME(dbid) as DBName,
COUNT(dbid) as NumberOfConnections,
loginame as LoginName
FROM
sys.sysprocesses
WHERE
dbid > 0
GROUP BY
dbid, loginame
</code></pre>
<p>And this gives the total:</p>
<pre><code>SELECT
... | <p>see <a href="http://msdn.microsoft.com/en-us/library/ms174313.aspx" rel="nofollow">sp_who</a> it gives you more details than just seeing the number of connections </p>
<p>in your case i would do something like this </p>
<pre><code> DECLARE @temp TABLE(spid int , ecid int, status varchar(50),
l... | 26,552 |
<p>I know this is a longshot but I was wondering if anyone knows if this is possible.</p>
| <p>Most browsers set the <a href="http://en.wikipedia.org/wiki/Referer" rel="nofollow noreferrer">HTTP_REFERRER</a> header to the current URL when requesting a linked document. However, it can be spoofed so don't use it for security.</p>
| <p>I know nothing about air. </p>
<p>But if AIR has JavaScript access, and you can access the container document ( <a href="https://stackoverflow.com/questions/193130/how-do-i-share-a-javascript-object-between-different-pages-in-adobe-air">How do I share a javascript object between different pages in Adobe AIR?</a> ) ... | 42,595 |
<p>I've been trying to deal with some delimited text files that have non standard delimiters (not comma/quote or tab delimited). The delimiters are random ASCII characters that don't show up often between the delimiters. After searching around, I've seem to have only found no solutions in .NET will suit my needs and ... | <p>Use the <a href="http://filehelpers.sourceforge.net/" rel="nofollow noreferrer">File Helpers API</a>. It's .NET and open source. It's extremely high performance using compiled IL code to set fields on strongly typed objects, and supports streaming.</p>
<p>It supports all sorts of file types and custom delimiters;... | <p>While this doesn't help address the large input issue, a possible solution to the parsing issue might include a custom parser that users the strategy pattern to supply a delimiter.</p>
| 44,085 |
<p>I'm trying to reorder/group a set of results using SQL. I have a few fields (which for the example have been renamed to something a bit less specific), and each logical group of records has a field which remains constant - the address field. There are also fields which are present for each address, these are the sam... | <p>Assuming that the column headings "john", "lucy" etc are fixed, you can group by the address field and use if() functions combined with aggregate operators to get your results:</p>
<pre><code>select max(if(forename='john',surname,null)) as john,
max(if(forename='lucy',surname,null)) as lucy,
max(if(fo... | <p>I'm not certain, but I think what you're trying to do is GROUP BY.</p>
<pre><code>SELECT Address,Name FROM Table GROUP BY Name
</code></pre>
<p>if you want to select more columns, make sure they're included in the GROUP BY clause. Also, you can now do aggregate functions, like MAX() or COUNT().</p>
| 36,890 |
<p>I'm trying to scrape a price from a web page using PHP and Regexes. The price will be in the format £123.12 or $123.12 (i.e., pounds or dollars).</p>
<p>I'm loading up the contents using libcurl. The output of which is then going into <code>preg_match_all</code>. So it looks a bit like this:</p>
<pre><code>$conten... | <p>Have you try to use \ in front of £</p>
<pre><code>preg_match_all('/(\$|\£)[0-9]+(\.[0-9]{2})/', $contents, $matches);
</code></pre>
<p>I have try this expression with .Net with \£ and it works. I just edited it and removed some ":".
<a href="https://i.stack.imgur.com/DwYIJ.png" rel="nofollow noreferrer"><img src=... | <p>maybe pound has it's html entity replacement? i think you should try your regexp with some sort of couching program (i.e. match it against fixed text locally).</p>
<p>i'd change my regexp like this: <code>'/(?:\$|£)\d+(?:\.\d{2})?/'</code></p>
| 42,462 |
<p>We have two versions of a managed C++ assembly, one for x86 and one for x64. This assembly is called by a .net application complied for AnyCPU. We are deploying our code via a file copy install, and would like to continue to do so.</p>
<p>Is it possible to use a Side-by-Side assembly manifest to loading a x86 or ... | <p>I created a simple solution that is able to load platform-specific assembly from an executable compiled as AnyCPU. The technique used can be summarized as follows:</p>
<ol>
<li>Make sure default .NET assembly loading mechanism ("Fusion" engine) can't find either x86 or x64 version of the platform-specific assembly<... | <p>This solution can work for non managed assemblies as well. I have created a simple example similar to Milan Gardian's great example. The example I created dynamically loads a Managed C++ dll into a C# dll compiled for the Any CPU platform. The solution makes use of the InjectModuleInitializer nuget package to subscr... | 13,426 |
<p>How can I load an external JavaScript file using a bookmarklet? This would overcome the URL length limitations of IE and generally keep things cleaner.</p>
| <h3>2015 Update</h3>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/Security/CSP/Introducing_Content_Security_Policy" rel="noreferrer">Content security policy</a> will prevent this from working in many sites now. For example, the code below won't work on Facebook.</p>
<h3>2008 answer</h3>
<p>Use a bookmark... | <p>I always prefer to use a popular open source project <a href="https://github.com/muicss/loadjs/blob/master/dist/loadjs.min.js" rel="nofollow noreferrer">loadjs</a> </p>
<p>it is cross browser tested and has more functionality/comfort features.</p>
<p>So the code will look like this:</p>
<pre><code>loadjs=function... | 13,193 |
<p>In vs2008, is it possible to write an extension methods which would apply to any enumeration.</p>
<p>I know you can write extension methods against a specific enumeration, but I want to be able to every enumeration using a single extension method. Is this possible?</p>
| <p>Yes, just code against the base <code>Enum</code> type, e.g.</p>
<pre><code>public static void Something(this Enum e)
{
// code here
}
</code></pre>
<p>The down-side is you'll probably end up doing some quite nasty stuff like finding the real base type using <a href="http://msdn.microsoft.com/en-us/library/sys... | <p>Another example of making Enum extension - but this time it returns the input enum type.</p>
<pre><code>public static IEnumerable<T> toElementsCollection<T>(this T value) where T : struct, IConvertible
{
if (typeof(T).IsEnum == false) throw new Exception("typeof(T).IsEnum == false");
... | 34,878 |
<p>My goal is to make sure that in most scenarios objects are used via a "read-only interface" that is a subset of the full interface.</p>
<ul>
<li>As an example, if I were using C++, I would just return a <code>const</code> object.</li>
<li>In C#, if I could achieve this with interfaces, I would just implement a read... | <p>You could implement the readonly behaviour via state in the object, and throw an exception if a modifying method is called?</p>
| <p>If anyone is interested in what I did, I finally went for an abstract class instead of interface, and I did hide the method in the derived class to get the right accessors:</p>
<p>Like, in the base abstract class (readonly interface):</p>
<pre><code>protected double accuracy;
public double Accuracy { get { return ... | 48,779 |
<p>If I need to test out some of the components of a RAMPS 1.4 based 3D Printer, can I only plug some of them into the board (not all of them) and test them out?</p>
<p>I'd like to test out the NEMA 17 motors without testing the heated bed or extruder. Is this safe and why?</p>
| <p>If by components you mean motors, fans, or heated bed, then yes. This is even suggested in the <a href="http://reprap.org/wiki/RAMPS_1.4#Final_Setup" rel="noreferrer">Final Setup</a> instructions on the RAMPS wiki.</p>
<blockquote>
<p>If you think you may have mistakes (in your setup) you can install only one ste... | <p>Yes, you can. By leaving components unplugged you would simply have some pins powered that are not in use. But even with all your components plugged in, you would still have some unused, powered pins on your board, so I wouldn't think too hard about that. In some cases it might be needed to mount e.i. fans to cool y... | 169 |
<p>I often run into problems where I can't get something to connect to something else. I usually forget to check something obvious. Can you help with:</p>
<ul>
<li>A tip/technique for diagnosing a connection issue</li>
<li>The name of a tool or application that can help (and the situation in which it's useful)</li>
</... | <p>Simple checks to run when debugging network problems:</p>
<ol>
<li>Has each machine got an IP address, Go to command prompt and run ipconfig. Key things to check here are the interfaces and ensuring the appropriate ones have IP addresses.</li>
<li>Check both machines IP addresses are in the same range and subnet if... | <p>You need to be use the process of elimination, for example if you can ping the ip address but not the hostname then there's DNS issues. If you can ping the system but not connect to a share etc.</p>
| 27,425 |
<p>I have an SQLite table that contains a BLOB I need to do a size/length check on. How do I do that?</p>
<p>According to documentation <code>length(blob)</code> only works on texts and will stop counting after the first NULL. My tests confirmed this. I'm using SQLite 3.4.2.</p>
| <p>I haven't had this problem, but you could try <code>length(hex(glob))/2</code></p>
<p><strong>Update (Aug-2012):</strong>
For SQLite 3.7.6 (released April 12, 2011) and later, <code>length(blob_column)</code> works as expected with both text and binary data.</p>
| <p>Example of a <code>select</code> query that does this, getting the length of the blob in column <code>myblob</code>, in table <code>mytable</code>, in row 3:</p>
<pre><code>select length(myblob) from mytable where rowid=3;
</code></pre>
| 31,239 |
<p>I have done a bit of research into this and it seems that the only way to sort a data bound combo box is to sort the data source itself (a DataTable in a DataSet in this case). </p>
<p>If that is the case then the question becomes what is the best way to sort a DataTable?</p>
<p>The combo box bindings are set in ... | <p>If you're using a DataTable, you can use the (DataTable.DefaultView) <a href="http://msdn.microsoft.com/en-us/library/system.data.dataview.sort.aspx" rel="nofollow noreferrer">DataView.Sort</a> property. For greater flexibility you can use the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.bin... | <p>Does the data need to be in a DataTable?
Using a SortedList and binding that to a combo box would be a simpler way.</p>
<p>If you need to use a DataTable you can use the Select method to retrieve a DataView and pass in a sort parameter.</p>
<pre><code>DataView dv = myDataTable.Select("filter expression", "sort");
... | 4,947 |
<p>I've written (most of) an application in Flex and I am concerned with protecting the source code. I fired up a demo of <a href="http://www.flash-decompiler.com/" rel="noreferrer">Trillix swf decompiler</a> and opened up the swf file that was installed to my Program Files directory. I saw that all of the actionscript... | <p>Here's what I would do.</p>
<ul>
<li><p>Compile your application to a SWF file. Then encrypt the SWF using AES.</p></li>
<li><p>Make a "wrapper" application that loads the encrypted SWF into a ByteArray using URLLoader</p></li>
<li><p>Use the <a href="http://code.google.com/p/as3crypto/" rel="noreferrer">as3crypto<... | <p>I recently released an iOS and Android game using Flash. I looked around the internet for a good free program to protect the source code in my SWF and couldn't find anything so I wrote one. It's still in development and it's "use at your own risk" but it worked for me.</p>
<p>It's released on github. Check it out a... | 2,678 |
<p>I have 6 links on a page to an mp3.</p>
<p>The plugin I installed replaces those links with a swf and plays that mp3 inline.</p>
<p>The problem I <em>had</em> was that it was possible to activate all 6 links and have all audio playing at once. I <em>solved</em> that problem (I feel in a clumsy novice way though) b... | <p>Use event delegation - this means binding the click to some container and let that handle the event. You can then query the event.target to see if it was an anchor that was clicked then do you required behaviour. This is better for a number of reasons.</p>
<ol>
<li>Less events bound to elements (performance)</li>
<... | <p>Have a look at the <a href="http://brandonaaron.net/docs/livequery/" rel="nofollow noreferrer">livequery</a> plugin. With this plug-in you can bind event listeners even for elements that aren't available in DOM ready. </p>
<pre><code>$('a').livequery('click', function(){
});
</code></pre>
<p>The plug-in monit... | 42,105 |
<p>I'm using jQuery in conjunction with the <a href="http://malsup.com/jquery/form/" rel="nofollow noreferrer">form plugin</a> and I'd like to intercept the form data before submission and make changes. </p>
<p>The form plugin has a property called beforeSubmit that should do this, but I seem to be having trouble gett... | <p>I ran the following code through firebug and it appears to work as advertised, but the formData variable in the beforeSubmit callback is empty because you didn't set the name attribute on the text boxes.</p>
<pre><code><script type="text/javascript">
$(document).ready(function() {
var options = {
... | <p>For starters, according to <a href="http://malsup.com/jquery/form/#options-object" rel="nofollow noreferrer">this API</a>, your options object should use <code>type</code> and not <code>method</code>, or just specify the method attribute on the form in the HTML. </p>
<p>(now I'll throw in a couple minor stylistic ... | 44,804 |
<p>I would like to know how can i escape a # in velocity. Backslash seems to escape it but it prints itself as well</p>
<p>This: </p>
<pre><code>\#\#
</code></pre>
<p>prints: </p>
<pre><code>\#\#
</code></pre>
<p>I would like: </p>
<pre><code>##
</code></pre>
| <p>If you don't want to bother with the EscapeTool, you can do this:</p>
<pre><code>#set( $H = '#' )
$H$H
</code></pre>
| <p>The set technique is a good way to get around any characters you need escaping, like if you want to have $name followed by "_lastname" then you can do:</p>
<pre><code>set ($n = '_lastname)
</code></pre>
<p>and have this in your template: </p>
<pre><code>$name$n
</code></pre>
<p>and it's all good.</p>
| 7,729 |
<p>Simple question really - how do I use <code>text_field_with_auto_complete</code> inside a <code>form_for</code> block?</p>
<p>I've tried doing <code>f.text_field_with_auto_complete</code> but that gives an error, and just using <code>text_field_with_auto_complete</code> by itself doesn't seem to do anything.</p>
<... | <p>I personally use this:</p>
<pre><code><%= f.text_field :name, :autocomplete => "off" %><div class="auto_complete" id="customer_name_auto_complete"></div>
</code></pre>
<p>And add the auto-generated Javascript and CSS manually. Here's the Javascript:</p>
<pre><code>new Ajax.Autocompleter('cust... | <p>I had this problem too, but the solution I used might not apply to you.</p>
<p>Since the object I was querying in the autocomplete belonged to a different model, I used a fields_for like this, which solved the autocomplete problem.</p>
<pre><code><% fields_for :model, @formobject.model do %>
<p>
<%=... | 30,361 |
<p>I've got an Anycubic Predator (aka Anycubic D). I followed the official instructions and leveled my printer. </p>
<p>The first annoying problem I ran into is that after the auto-leveling, the level test printing shows that the printer wasn't leveled at all. I tried about 4-5 times, and finally leveled the printer (... | <p>A wide line works if there is something below it to squeeze the filament against, but if you don't have a full layer below it, it will stay thinner and it will droop. I would not use extreme ratios on overhangs. Still, do a parametric test: a overhang tower (a compact one) at different line widths and layer heights.... | <p>In terms of Cura's model for showing overhangs, I'm nearly sure it's just the ratio - rise over run, or rather run over rise. And indeed that's what makes sense mathematically:</p>
<p>At least some portion of the wall extrusion in layer N+1 needs to sit on top of the corresponding wall extrusion in layer N. For a g... | 1,664 |
<p>I have an XML definition that contains an element with child elements. For example:</p>
<pre><code><a>
<b>
<c>C</c>
<d>D</d>
</b>
</a>
</code></pre>
<p>I have an XSLT with an output of text. For example:</p>
<pre><code><xsl...>
<xsl:output method="t... | <p>Your SQL statement scares me. XML is case-sensitive, and your comparison there is likely to fail if the input XML and XSLT (including all elements, attributes, and values) aren't cased exactly like that used in the original database insert.</p>
<p>I believe both Oracle (certain) and SQL Server (think so) have mecha... | <p>Here is how it can be done:</p>
<pre><code><xsl:output method="xml" />
<xsl:template match="/"><xsl:apply-templates select="/a/b" mode="normalize-space" /></xsl:template>
<xsl:template match="text()" mode="normalize-space"><xsl:value-of select="normalize-space(.)" /></xsl:te... | 41,259 |
<p>I have a custom action in a workflow and would like to report an error to the user when something goes wrong. What's the best way of doing that?</p>
<p><strong>UPD:</strong> Ideally I would like to put the workflow in the error state and log a message to the workflow log. That doesn't seem possible. What's the c... | <p>when you throw the error your error handler can then email the user, or better if the list is massive, add the error state to the workflow item - i think this is default functionality though as the error would be mentioned there.</p>
<p><a href="http://www.sharepointsecurity.com/blog/sharepoint/sharepoint-2007-deve... | <p>Add the error to a hidden list with that users name. Set the visibility on the list (for users) to only read/write their own values. Then use a custom web part or FlexListViewer to view the contents of that list and display it to the user. Once they acknowledge that error, remove it from the list.</p>
<p>If necessa... | 3,688 |
<p>We have a page of search results which the user can hit in several ways. 90% of the ways will set up a 'Search Criteria' session object, which the results page will use to retrieve the search results.</p>
<p>When the session object isn't found, we will typically show the user an 'invalid search' message, and give ... | <p>This is an excellent <a href="http://www.eggheadcafe.com/articles/20051228.asp" rel="noreferrer">article</a> which is based off of <a href="http://aspalliance.com/520" rel="noreferrer">this one</a>. I think you will find your answers here (Page 2 of the second article specifically)</p>
| <p>All the browsers will return the expired session cookie. They'll do so until the browser is restarted or it's rewritten by a server response.</p>
<p>The answer from bnkdev uses this fact to detect new vs expired by seeing if the cookie is already set. It's simple and easy and will likely work for you, but it only... | 44,036 |
<p>I've created a seperate assembly with a class that is intended to be
published through wmi. Then I've created a windows forms app that
references that assembly and attempts to publish the class. When I try to
publish the class, I get an exception of type
System.Management.Instrumentation.WmiProviderInstallation... | <p>To summarize, this is the final code that works:</p>
<p>Provider class, in it's own assembly:</p>
<pre><code>// the namespace used for publishing the WMI classes and object instances
[assembly: Instrumented("root/mytest")]
using System;
using System.Collections.Generic;
using System.Text;
using System.Management... | <p>I used gacutil - installutil to to test your class (as a dll). The gacutil part worked, but installutil (actually mofcomp) complained about a syntax error:</p>
<p>...</p>
<p>error SYNTAX 0X80044014:
Unexpected character in class name (must be an identifier)</p>
<p>Compiler returned error 0x80044014</p>
<p>...</p... | 9,110 |
<p>I am using a service component through ASP.NET MVC.
I would like to send the email in a asynchronous way to let the user do other stuff without having to wait for the sending.</p>
<p>When I send a message without attachments it works fine.
When I send a message with at least one in-memory attachment it fails.</p>
... | <p>Don't use "using" here. You are destroying the memory stream immediately after calling SendAsync, e.g. probably before SMTP gets to read it (since it's async). Destroy your stream in the callback.</p>
| <p>I have tried your function and it works even for email with in memory attachments. But here are some remarks:</p>
<ul>
<li>What type of attachments did you try to send ? Exe ?</li>
<li>Are both sender and receiver on the same email server ?</li>
<li>You should “catch” exception and not just swallow it, than you wil... | 35,385 |
<p>In short: How do you specify a BIGINT in Django models?</p>
<p>In a current project I am doing using Django (0.97-svn release), I've all the integer fields in all the models defined as IntegerField. It was working immaculately during the development cycle where I was using SQLite for the DB backend. However, as so... | <p><a href="https://docs.djangoproject.com/en/dev/ref/models/fields/#bigintegerfield" rel="noreferrer">BigIntegerField</a> was added in changeset 11887, 2009-12-17 09:10:38 and is part of Django 1.2 and newer.</p>
| <p>Try a DecimalField.</p>
| 35,978 |
<p>We have are relatively simple Reporting Services report that our users commonly export to Excel. I've noticed that the files produced by the Excel export seem unusually large. If I open one of these files and just click save, without making any changes, the file size reduces to about half of it's previous size. Has ... | <p>You've mentioned that the report is relatively simple, but this is important to check. The export to Excel will go to extraordinary lengths to try and maintain how your report looks.</p>
<p>If you have lots of different borders or colours (particularly if different formatting is determined by the data in your repor... | <p>May be I am answering your question very late. Here's the solution for exporting to CSV.</p>
<p>You need to give the a name that you want to see as a column header for the field (not the column name) in the designer.</p>
<p>By default all the text headers are exported as a separate columns along with the table col... | 30,271 |
<p>I am looking for a program to make mockup screenshots with. I first found out I could do it with Visual Basic (uglier names I have yet to hear a programming language being called) from <a href="http://www.joelonsoftware.com/articles/fog0000000033.html" rel="nofollow noreferrer">joelonsoftware.com</a>. I don't want t... | <p><a href="http://www.balsamiq.com/" rel="nofollow noreferrer">Balsamiq</a></p>
| <p>wxGlade would work as well, plus it's free software.</p>
| 38,482 |
<p>I just want a quick way (and preferably not using a while loop)of createing a table of every date between date @x and date @y so I can left outer join to some stats tables, some of which will have no records for certain days in between, allowing me to mark missing days with a 0</p>
| <p>Strictly speaking this doesn't exactly answer your question, but its pretty neat.</p>
<p>Assuming you can live with specifying the number of days after the start date, then using a Common Table Expression gives you:</p>
<pre><code>WITH numbers ( n ) AS (
SELECT 1 UNION ALL
SELECT 1 + n FROM numbers... | <p>Just: WHERE col > start-date AND col < end-date</p>
| 12,087 |
<p>Linux 2.6.18-92.el5, ruby 1.8.7, Rails 2.2.2, mysql gem 2.7</p>
<p>I installed the MySQL binary distribution under /usr/local, then installed the mysql gem like this:</p>
<pre><code>gem install mysql --no-rdoc --no-ri \
-- --with-mysql-include=/usr/local/mysql/include \
--with-mysql-lib=/usr/local/mysql/lib \
... | <p>I had issues as well (on Mac OS X), and was just as frustrated that <code>gem install mysql</code> wasn't as simple as it used to be.</p>
<p>The short-sighted answer is that the mysql gem needs to build native extensions, and to do that, it needs some path information (specific to your system) about MySQL libraries... | <p>Possibly it had something to do with the prefix you used when installing mysql?
--with-mysql-lib=/usr/local/mysql/lib</p>
<p>Presumably, if that been /usr/local/lib (or somewhere ldconfig was already set to look) and/or if you had just used a top-level prefix of something like /usr/local, you may not have run into ... | 44,508 |
<p>In one of my applications I have a 1gb database table that is used for reference data. It has a huge amounts of reads coming off that table but there are no writes ever. I was wondering if there's any way that data could be loaded into RAM so that it doesn't have to be accessed from disk?</p>
<p>I'm using SQL Serve... | <p>If you have enough RAM, SQL will do an outstanding job determining what to load into RAM and what to seek on disk. </p>
<p>This question is asked a lot and it reminds me of people trying to manually set which "core" their process will run on -- let the OS (or in this case the DB) do what it was designed for.</p>
<... | <p><a href="http://msdn.microsoft.com/en-us/library/ms178015(SQL.90).aspx" rel="nofollow noreferrer">DBCC PINTABLE</a> will explicitly pin a table in core if you want to make sure it remains cached.</p>
| 6,454 |
<p>I have a java String that contains the unicode character U+9996 (that's what I get if I do codePointAt()). </p>
<p>If I look at it in the debugger expressions panel (in eclipse) then all is well and it looks like "<strong>首</strong>". However if I print it out to the console I get simply "<strong>?</strong>". It ... | <p>Have you verified that the value that gets stored in the database is actually U+003f (question mark)? There are all sorts of conventions for how to display characters that don't exist in the chosen font, and displaying them as ?' is fairly common.</p>
<p>So most likely, the character gets stored correctly, and for ... | <p>I don't know about the problems, but it's <a href="http://unicode.org/cgi-bin/GetUnihanData.pl?codepoint=9996" rel="nofollow noreferrer">definitely a valid Unicode character</a> (and has been since Unicode 1.1).</p>
| 44,512 |
<p>I'm trying to pull data from an ODBC app to SQL2005(dev ed) DB on an hourly basis. When I run SSIS the option to import all tables and views is grayed out and forces your to write a query. How would I go about setting up a SSIS integration service to update ALL 250 some tables on an hourly basis. </p>
| <p>What kind of database is your ODBC data source pointing to? SSIS might not give you a GUI for selecting tables/views for all DB types.</p>
| <p>perhaps you could rephrase your question a little, I am not 100% sure what you are asking here. Are you trying to get data into SQL Server from an application via SSIS with the Data Transform task using an ODBC connection to the Application? </p>
<p>Anyhoo, the simple answer to the MS Access part of your question i... | 35,736 |
<p>A few years ago I worked on a system where a numeric primary key was stored in a [SQL Server] varchar column, so I quickly came unstuck when querying with a BETWEEN operator:</p>
<pre><code>SELECT ID FROM MyTable WHERE ID BETWEEN 100 AND 110;
</code></pre>
<p>Results:</p>
<pre><code>100
102
103
109
110
11
</code>... | <p>If you're sure that the values in ID are numeric only, why not just CAST them</p>
<pre><code>WHERE CAST(ID as int) BETWEEN iStartValue AND iEndValue
</code></pre>
<p>EDIT 1:
An extension to the casting method which should work is to use a sub-query to pull out all numeric records. Please note - I do not think this... | <p>How about a cast instead.</p>
<pre><code>SELECT ID FROM MyTable
WHERE cast(ID as signed) BETWEEN cast(iStartValue as signed) AND cast(iEndValue as signed)
</code></pre>
<p>This syntax given is MySQL but there are similar CAST operators for T-SQl.</p>
| 46,457 |
<p>How can I write G-code for a triangle without sharp tips?</p>
<p><a href="https://i.stack.imgur.com/T0hpu.jpg" rel="nofollow noreferrer" title="Example of required triangle"><img src="https://i.stack.imgur.com/T0hpu.jpg" alt="Example of required triangle" title="Example of required triangle"></a></p>
<p>I want to ... | <p>First, convert the given measurements into a sketch...</p>
<p><a href="https://i.stack.imgur.com/ivxIW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ivxIW.png" alt="Sketched out dimensions" /></a></p>
<h2>G-code shenanigans</h2>
<p>we actually have the printer do circles.. let's plot that out...... | <p>Marlin has <code>G2</code> (clockwise arc) and <code>G3</code> (counterclockwise arc) commands that could be used to do this. <a href="http://marlinfw.org/docs/gcode/G002-G003.html" rel="nofollow noreferrer">You can find detailed documentation for the command here.</a></p>
<p>Basically, you can use</p>
<blockquote... | 1,393 |
<p>There are numerous libraries providing Linq capabilities to C# code interacting with a MySql database. Which one of them is the most stable and usable on Mono?</p>
<p>Background (mostly irrelevant): I have a simple C# (.Net 2.0) program updating values in a MySql database. It is executed nightly via a cron job and ... | <p>The only (free) linq provider for MySql is <a href="http://code2code.net/DB_Linq/" rel="nofollow noreferrer">DbLinq</a>, and I believe it is a long way from production-ready.</p>
<p>There is also <a href="http://www.devart.com/mysqlnet/" rel="nofollow noreferrer">MyDirect.Net</a> which is commercial, but I have hea... | <p>at this time you cannot use linq to sql, you might look into a third party linq mysql provider or linq to entities. linq to sql only works for sql server databases.</p>
| 6,364 |
<p>I have checked the whole site and googled on the net but was unable to find a simple solution to this problem.</p>
<p>I have a datatable which has about 20 columns and 10K rows. I need to remove the duplicate rows in this datatable based on 4 key columns. Doesn't .Net have a function which does this? The function c... | <p>You can use Linq to Datasets. Check <a href="http://msdn.microsoft.com/en-us/library/bb669119.aspx" rel="noreferrer">this</a>. Something like this:</p>
<pre><code>// Fill the DataSet.
DataSet ds = new DataSet();
ds.Locale = CultureInfo.InvariantCulture;
FillDataSet(ds);
List<DataRow> rows = new List<DataR... | <p>Use a query instead of functions:</p>
<pre><code>DELETE FROM table1 AS tb1 INNER JOIN
(SELECT id, COUNT(id) AS cntr FROM table1 GROUP BY id) AS tb2
ON tb1.id = tb2.id WHERE tb2.cntr > 1
</code></pre>
| 44,196 |
<p>I'm using MediaTemple's Grid Server (shared/grid hosting) to run some MySQL/PHP sites I'm writing and noticed that I wasn't closing one of my MySQL connections, which caused my site to error out: </p>
<pre><code>"Too Many Connections"
</code></pre>
<p>I can't log in anywhere to close the connections manually. </p>... | <p>If you can't log into MySQL at all, you will probably have to contact your hosting provider to kill the connections.</p>
<p>If you can use the MySQL shell, you can use the <a href="http://dev.mysql.com/doc/refman/5.0/en/show-processlist.html" rel="nofollow noreferrer">show processlist</a> command to view connection... | <p>Make sure that you're closing the connections with your PHP code. Also, you could increase the maximum connections allowed in /etc/my.cnf.</p>
<pre><code>max_connections=500
</code></pre>
<p>Finally, you can login to a mysql prompt and type <code>show status</code> or <code>show processlist</code> to view various... | 9,461 |
<p>One problem I have with a modern office is that people still tend to create physical copies of digital media (such as program manuals and specifications). I understand that for somethings it is prudent to create a physical copy but many of these physical copies go mostly unused, they just sit on a shelf to maybe one... | <p>It won't work for everybody, for sure, but I recently spent a year at a small web development company (under 25 employees) that had no printers and no copiers. Only the owner had one little printer in his locked office. Since they never had any printers or copiers, their work patterns had evolved to not use paper.</... | <p>This all depends on personal preference. Some people like to read on computer screen. But some people might do not prefer screen. They tend to take the print out of every possible thing.</p>
<p>IMO you can promote the use of duplex printing. Infact printing multiple pages on same A4 sheet. This should reduce the wa... | 34,336 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.