instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Does WebSphere offer an HTTP input filter / firewall like mod_security?</p>
<p>I know that it's possible to have Apache be the HTTP server front-end to WebSphere, but that type of configuration is beyond my influence. We're stuck using just what WebSphere itself can do.</p>
<p>EDIT - To clarify, I am not looking ... | <p>J2EE has a <a href="http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Security.html" rel="nofollow noreferrer">standard</a> way of <a href="http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Security4.html#67530" rel="nofollow noreferrer">securing</a> it's apps. I recommend using this. If what you are trying to do is oddba... | <p>There are many attacks that target the web server in front of your application server, so you should get control of the configuration of that web server too.</p>
| 21,738 |
<p>I have a sproc that returns a single line and column with a text, I need to set this text to a variable, something like:</p>
<pre><code>declare @bla varchar(100)
select @bla = sp_Name 9999, 99989999, 'A', 'S', null
</code></pre>
<p>but of course, this code doesn't work...</p>
<p>thanks!</p>
| <p>If you are unable to change the stored procedure, another solution would be to define a temporary table, and insert the results into that</p>
<pre><code>DECLARE @Output VARCHAR(100)
CREATE TABLE #tmpTable
(
OutputValue VARCHAR(100)
)
INSERT INTO #tmpTable (OutputValue)
EXEC dbo.sp_name 9999, 99989999, 'A', 'S'... | <p>If the stored procedure is returning a single value you could define one of the parameters on the stored procedure to be an OUTPUT variable, and then the stored procedure would set the value of the parameter</p>
<pre><code>CREATE PROCEDURE dbo.sp_Name
@In INT,
@Out VARCHAR(100) OUTPUT
AS
BEGIN
SELECT @... | 26,029 |
<p>Data: a dependency list, already verified to be acyclic. So here, 'a' depends on 'b','c' (c depends on d), etc... </p>
<pre><code>A = { 'a' : dict(b=1, c=1),
'c' : dict(d=1),
'd' : dict(e=1,f=1,g=1),
'h' : dict(j=1)
}
</code></pre>
<p>I'd like to have a top-down, recursive solution to let's say... | <p>Try this:</p>
<pre><code>#!/usr/bin/env python
def get_all(D, k):
yield k
for ii in D.get(k, []):
for jj in get_all(D, ii):
yield jj
A = { 'a' : dict(b=1, c=1),
'c' : dict(d=1),
'd' : dict(e=1,f=1,g=1),
'h' : dict(j=1)
}
for ii in get_all(A,'a'):
print ii
</code></... | <p>Try this:</p>
<pre><code>#!/usr/bin/env python
def get_all(D, k):
yield k
for ii in D.get(k, []):
for jj in get_all(D, ii):
yield jj
A = { 'a' : dict(b=1, c=1),
'c' : dict(d=1),
'd' : dict(e=1,f=1,g=1),
'h' : dict(j=1)
}
for ii in get_all(A,'a'):
print ii
</code></... | 13,397 |
<p>Something like this one on the Stackoverflow site would be nice! </p>
<p>Or something non-jQuery that doesn't conflict with jQuery $() tags would be great.</p>
| <p>I'm surprised nobody has mentioned <strong><a href="http://markitup.jaysalvat.com/home/" rel="nofollow noreferrer">markitup</a></strong>:</p>
<p><em>markItUp! is a JavaScript plugin built on the jQuery library. It allows you to turn any textarea into a markup editor. Html, Textile, Wiki Syntax, Markdown, BBcode or ... | <p>Tiny MCE is the best IMHO - I have tired a ton of them and Tiny has the best over features, easy to create content templates, easy to set which CSS is shown in the editor and used to display it, very large API, great skins, ect...</p>
| 25,462 |
<p>I unpacked a zip-file delivery into a clearcase view. Now I want to add the complete file tree to the repository. The GUI only provides an "Add to source control ..." for individual files/directories. Do you know how to recursively add the whole tree?</p>
<p>(I'm on a Windows system, but have Cygwin installed.)</p>... | <p>I would rather go with the clearfsimport script, better equipped to import multiple times the same set of files, and automatically:</p>
<ul>
<li>add new files,</li>
<li>make new version of existing files previously imported (but modified in the source set of files re-imported)</li>
<li>remove files already imported... | <p>You can also add this command to your context menu with a small script...</p>
<p><a href="http://www.ibm.com/developerworks/rational/library/4687.html" rel="nofollow noreferrer">Ten best Triggers</a></p>
<p><strong>edit</strong>: oh, sorry. didn't saw that this was already suggested...</p>
| 16,744 |
<p>Does anyone have battle stories to share trying to use Visual Studio to develop applications for Unix? And I'm not talking using .NET with a Mono or Wine virtual platform running beneath.</p>
<p>Our company has about 20 developers all running Windows XP/Vista and developing primarily for Linux & Solaris. Unti... | <p><em>VS chugs to catch up with me.</em> <br>
Hmmm ... you machine needs more memory & grunt. Never had performance problems with mine.</p>
<p>I've about a decade's experience doing exactly what you're proposing, most of it in the finance industry, developing real-time systems for customers in the banking, stock ... | <p>We are using a similar solution to what you described.</p>
<p>We have our code stored on the Windows side of the world and UNIX (QNX 4.25 to be exact) has access though an NFS mount (thanks to UNIX services for Windows). We have an ssh into UNIX to run make and the pipe to output into VS. Accessing the code is fast... | 3,640 |
<p>When using TempData, my understanding is that it will keep whatever you put in it around for only one request. So when using TempData to retain data across a redirect (in order to use the Post-Request-Get pattern), isn't it possible that some other request from the user could come into the server in between the resp... | <p>Well, browsing the ASP.NET MVC code shows that the while TempData is stored in the session, it is removed from the session when it is loaded. And it gets loaded in the Controller's ExecuteCore() method.</p>
<p>So I think that would mean that yes, you entirely could run into a race condition where a request from a d... | <p>TempData makes use of the Session object, which does not suffer this problem, AFAIK. Have you run into a specific problem with this?</p>
| 29,171 |
<p>Ok I followed the steps for setting up ruby and rails on my Vista machine and I am having a problem connecting to the database.</p>
<h2>Contents of <code>database.yml</code></h2>
<pre><code>development:
adapter: sqlserver
database: APPS_SETUP
Host: WindowsVT06\SQLEXPRESS
Username: se
Password: paswd
</co... | <p>I ran into the same problem yesterday. Apparently 'deprecated' is a gem, so you want to run "gem install deprecated" to grab and install the latest version. Good luck.</p>
| <p>I too had faced this problem. There is another work around.
You can create a DSN for the app db from control panel->admin tools->Odbc.
Database.yml file should look like below:</p>
<pre><code>adapter: sqlserver
mode: odbc
dsn: DSN_NAME
host: localhost
database: App_development
username: uname
password: password
</c... | 15,850 |
<p>I need a well tested Regular Expression (.net style preferred), or some other simple bit of code that will parse a USA/CA phone number into component parts, so:</p>
<ul>
<li>3035551234122</li>
<li>1-303-555-1234x122</li>
<li>(303)555-1234-122</li>
<li>1 (303) 555 -1234-122</li>
</ul>
<p>etc...</p>
<p>all parse in... | <p>None of the answers given so far was robust enough for me, so I continued looking for something better, and I found it:</p>
<p><a href="https://github.com/googlei18n/libphonenumber" rel="nofollow noreferrer">Google's library for dealing with phone numbers</a></p>
<p>I hope it is also useful for you.</p>
| <p>here's a method easier on the eyes provided by the Z Directory (vettrasoft.com),
geared towards American phone numbers:</p>
<pre><code>string_o s2, s1 = "888/872.7676";
z_fix_phone_number (s1, s2);
cout << s2.print(); // prints "+1 (888) 872-7676"
phone_number_o pho = s2;
pho.store_save();
</code></pre>
... | 28,150 |
<p>How do I convert a hex string to an integer?</p>
<pre><code>"0xffff" ⟶ 65535
"ffff" ⟶ 65535
</code></pre>
| <p><strong>Without</strong> the <code>0x</code> prefix, you need to specify the base explicitly, otherwise there's no way to tell:</p>
<pre><code>x = int("deadbeef", 16)
</code></pre>
<p><strong>With</strong> the <code>0x</code> prefix, Python can distinguish hex and decimal automatically:</p>
<pre><code>>... | <p>The formatter option '%x' % seems to work in assignment statements as well for me. (Assuming Python 3.0 and later)</p>
<p><strong>Example</strong> </p>
<pre><code>a = int('0x100', 16)
print(a) #256
print('%x' % a) #100
b = a
print(b) #256
c = '%x' % a
print(c) #100
</code></pre>
| 25,714 |
<p>I want to test some PHP on my local machine running Windows XP Professional. I'm familiar with coding PHP for upload, but not with running a web server.</p>
<p><strong>What is the easiest way to set up a test environment?</strong> Step-by-step instructions would be great if you can give them.</p>
<p>(I see WAMP reco... | <p><a href="https://i.stack.imgur.com/8PuYL.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8PuYL.gif" alt="alt text"></a><br>
<sub>(source: <a href="http://www.apachefriends.org/images/1240.jpg" rel="nofollow noreferrer">apachefriends.org</a>)</sub> </p>
<p><a href="http://www.apachefriends.org/en... | <p><a href="http://www.apachefriends.org/en/xampp.html" rel="nofollow noreferrer">XAMPP from ApacheFriends</a> is pretty simple to set up and use.</p>
<p><strong>note</strong> the site appears to be down as at 15:02 UTC on 3rd Dec 2008<br>
<strong>note again</strong> and it is back!</p>
| 43,780 |
<p>I have a custom UILabel subclass for displaying currency values. I only want the user to be able to enter digits and let the view format those digits into a currency value -- like a cash register. This makes UITextField an inappropriate choice for this kind of input.</p>
<p>I've already overridden hitTest: so that ... | <p>Just recently I had the same issue. Here is what I did:</p>
<p>I created a class to hold just an id and the text for each object (in my case I called it a sku (item number) and a description). This creates a smaller object that uses less memory since it is only used for searching. I'll still grab the full-blown obj... | <p>You could try Lucene.Net. I'm not sure how well it's suited to mobile devices, but it is billed as a "high-performance, full-featured text search engine library".</p>
<p><a href="http://incubator.apache.org/lucene.net/" rel="nofollow noreferrer">http://incubator.apache.org/lucene.net/</a>
<a href="http://lucene.apa... | 34,865 |
<p>I'm making another app's window topmost to ensure that a click in my app brings the other's dialog into views. The problem I'm having is that I don't get focus back to my app after the call. If the other app has more windows one of them ends up with focus, and otherwise no window (looking at the taskbar only) gets f... | <p>Related: <a href="https://stackoverflow.com/questions/48288/unexpected-behaviour-of-processmainwindowhandle">Unexpected behaviour of Process.MainWindowHandle</a></p>
<p>Basically MainWindowHandle gives you the current top-most window of the process despite what the documentation says.</p>
<p>That explains why the ... | <p>[Actual solution used]</p>
<p>So far I'm going with sending the window handle of the calling window to the target app, and getting it to push it back on top when finished. It is a real pain as I will have ~50 windows to deal with, but it seems stable. The next approach, if this turns out to have problems, will be t... | 28,515 |
<p>I have a situation where I might have multiple instances of a program running at once, and it's important that just one specific function not be executing in more than one of these instances at once.</p>
<p>Is this the proper way to use a mutex to prevent this from happening?</p>
<pre><code>lock (this.GetType()) {... | <p>You said multiple instances of one application, so we're talking about two program.exe's running, right? The lock statement won't lock across multiple programs, just within the program. If you want a true Mutex, look at the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.threading.mutex" rel="nofollow n... | <p>TheSeeker is correct.</p>
<p>Jeff Richter's advice in <a href="http://books.google.com/books?id=C-V_AAAACAAJ&dq=clr+via+c%23&ei=k6TBSPjYOomUzATIs8WIDg" rel="nofollow noreferrer">Clr Via C#</a> (p638-9) on locking is to create a private object specifically for the purpose of being locked.</p>
<pre><code>pri... | 6,908 |
<p>I currently use a DataTable to get results from a database which I can use in my code.</p>
<p>However, many example on the web show using a DataSet instead and accessing the table(s) through the collections method.</p>
<p>Is there any advantage, performance wise or otherwise, of using DataSets or DataTables as a s... | <p>It really depends on the sort of data you're bringing back. Since a DataSet is (in effect) just a collection of DataTable objects, you can return multiple distinct sets of data into a single, and therefore more manageable, object. </p>
<p>Performance-wise, you're more likely to get inefficiency from unoptimized q... | <p>A DataTable object represents tabular data as an in-memory, tabular cache of rows, columns, and constraints.
The DataSet consists of a collection of DataTable objects that you can relate to each other with DataRelation objects.</p>
| 2,442 |
<p>I am developing a cocoa application that will be making heavy use of both web services and a standard dbms (most likely MySQL) and I am wondering if anyone has a good option for a database library or ORM solution they have used. CoreData is not an option due to the need to support a standard DBMS and to be able to ... | <p>We faced a similar question when we first started work on <a href="http://checkoutapp.com" rel="noreferrer">Checkout</a>, our solution was to code the entire app in Python, using PyObjC. Checkout 1 had an sqlite backend, Checkout 2 has a postgres backend.</p>
<p>There are a couple of really mature and powerful ORM... | <p>I've also implemented a simple object persistence framework based on sqlite, but it certainly wasn't trivial to do. I agree with eJames' conclusion- don't implement one yourself if you don't have to.</p>
<p>If you aren't committed to programming in Objective-C you might want to take a look at PyObjC which would al... | 40,004 |
<p>I'd like to know if it's possible to compile an .swf file at runtime via C# (would be called via a Flex Application). I've read some articles about using fsch.exe, but nothing that gave any concrete examples.</p>
<p>I'm fairly certain this is possible, so a secondary question is whether it's feasible on a medium sc... | <p>That's not a problem. The order of rows returned by a SQL SELECT is undefined unless it has an <code>ORDER BY</code>. The order you get them is usually influenced by the order they are stored in the table and/or the indices that are used by the statement.</p>
<p>So depending on that order without using <code>ORDER ... | <p>The rows are returned in whatever their physical order on disk is; you can reorder them physically using the <code>CLUSTER</code> SQL command, but due to the way Postgres works they'll become unordered as soon as you start modifying rows.</p>
<p>For what you're doing an <code>ORDER BY</code> is the right answer.</p... | 48,240 |
<p>I have a mapping application that needs to draw a path, and then display icons on top of the path. I can't find a way to control the order of virtual earth layers, other than the order in which they are added. </p>
<p>Does anyone know how to change the z index of Virtual Earth shape layers, or force a layer to the ... | <p>I'll add my voice to the noise and take a stab at making things clear:</p>
<h2>C# Generics allow you to declare something like this.</h2>
<pre><code>List<Person> foo = new List<Person>();
</code></pre>
<p>and then the compiler will prevent you from putting things that aren't <code>Person</code> into the ... | <p>NB: I don't have enough point to comment, so feel free to move this as a comment to appropriate answer.</p>
<p>Contrary to popular believe, which I never understand where it came from, .net implemented true generics without breaking backward compatibility, and they spent explicit effort for that.
You don't have to ... | 5,163 |
<p>I work on a Webproject using <a href="http://jquery.com/" rel="nofollow noreferrer">jQuery</a> and CakePHP. I use <a href="http://www.appelsiini.net/projects/jeditable" rel="nofollow noreferrer">jeditable</a> as an inplace edit plugin. For textareas I extend it using the <a href="http://www.appelsiini.net/2008/4/aut... | <p>I didn't see any problems using Autogrow with jeditable in any browsers but here is an implementation of Growfield with jeditable. It works much in the same way that the Autogrow plugin for jeditable does. You create a special input type for jeditable and just apply .growfield() to it. The necessary javascript is... | <p><strong>Thank you Alex!</strong> Your growfield-Plugin works.
In meantime I managed to solve the other problem. I took another <a href="http://flesler.blogspot.com/2007/10/jqueryscrollto.html" rel="nofollow noreferrer">Scroll-Library</a> and hacked a callback event into the jeditable-plugin. It was not that hard as ... | 18,345 |
<p>Can you suggest some good MVC framework for perl -- one I am aware of is <a href="http://www.catalystframework.org/" rel="noreferrer">catalyst</a></p>
<p>The need is to be able to expose services on the perl infrastructure which can be called by Java/.Net applications seamlessly.</p>
| <p>I'll tell you right now that Catalyst has by far the best reputation amongst Perl developers in terms of a rapid application development MVC framework. </p>
<p>In terms of "pure" MVC I'm not sure there are even that many "mature" or at least production-ready alternatives.</p>
<p>If Catalyst doesn't seem right to y... | <p>I have built some applications with <a href="https://metacpan.org/pod/Kelp" rel="nofollow">Kelp</a>, it's easy to learn and very helpful.</p>
| 6,734 |
<p>Given the code from the <a href="http://railscasts.com/episodes/75" rel="nofollow noreferrer">Complex Form part III</a> how would you go about testing the virtual attribute?</p>
<pre><code> def new_task_attributes=(task_attributes)
task_attributes.each do |attributes|
tasks.build(attributes)
end
end... | <p>It looks as if new_task_attributes= is expecting an array of hashes, but you're passing it a hash. Try this:</p>
<pre><code>def test_adding_task_to_project
p = Project.new
new_tasks_attributes = [{ "name" => "paint fence"}]
p.new_tasks_attributes = (new_tasks_attributes)
p.save
assert p.tasks.length ==... | <p>Can we see the whole stack trace? Where does it think String#stringify_keys! is being called?</p>
<p>Also, params looks odd to me. Is tasks.build() expecting input like this: <code>["new_tasks_attribute", {"name" => "paint fence"}]</code> ?</p>
<p>If not, maybe you actually want Hash#each_key() instead of Hash#... | 11,872 |
<p>I have a undirected graph with about 100 nodes and about 200 edges. One node is labelled 'start', one is 'end', and there's about a dozen labelled 'mustpass'.</p>
<p>I need to find the shortest path through this graph that starts at 'start', ends at 'end', <strong>and passes through all of the 'mustpass' nodes (in... | <p>Everyone else comparing this to the Travelling Salesman Problem probably hasn't read your question carefully. In TSP, the objective is to find the shortest cycle that visits <em>all</em> the vertices (a Hamiltonian cycle) -- it corresponds to having <em>every</em> node labelled 'mustpass'.</p>
<p>In your case, give... | <p>How about using brute force on the dozen 'must visit' nodes. You can cover all the possible combinations of 12 nodes easily enough, and this leaves you with an optimal circuit you can follow to cover them.</p>
<p>Now your problem is simplified to one of finding optimal routes from the start node to the circuit, whi... | 27,438 |
<p>JPEG, GIF and PNG can be displayed with the img tag and will work in all browsers, the object element can be use for displaying images specifying its MIME type, but what other graphic formats are supported by img or object tag in most browsers without installing plugins? (TIF, SVG, PCX, PICT, etc..) </p>
| <p>There's an excellent <a href="http://en.wikipedia.org/wiki/Comparison_of_web_browsers#Image_format_support" rel="noreferrer">chart on wikipedia</a> that lists common image types and their support by browser.</p>
<p>The file types you listed (jpg, gif and png) seem to be the main formats supported by nearly every br... | <p>Until 2006, IE didn't deal properly with PNGs that used the alpha channel, while Firefox and other (nearly) standards conforming browsers did. There is still a lot of IE 6 out there, judging by my apache logs.</p>
| 22,226 |
<p>ActiveReports seems like a powerful flexible tool, but if you make a mistake anywhere, you get an exception "data member not found. please check your datasource and datamember properties". </p>
<p>There is no indication as to which datasource/datamember is at fault or what subreport the problem lies in, but Active ... | <p>I was getting the same error while trying to pass a raw dataset to a report as below:
<p>
...
<p>
<code>Dim rpt as New ActiveReport</code>
<p>
<code>With rpt</code>
<p>
<code>.DataSource = _data</code>
<p>
<code>.Run()</code>
<p>
<code>End With</code>
<p>
...
<p>
I specified a table in the dataset and the error went... | <p>Unfortunately I don't know a way to immediately tell which subreport that error is coming from. Indeed, that error message should be improved when you're using subreports. I will report it to the ActiveReports development team. </p>
| 19,276 |
<p>As I continue my quest of learning functional programming, I've come
to wonder if there may be alternatives to my default "procedural" way
of thinking. To be more specific, I'm looking at a function I
wrote. Here is what it does:</p>
<pre><code>Swap two elements of an unordered list of numbers, such that one of the... | <p>If your software is open source you can use <a href="http://launchpad.net" rel="nofollow noreferrer">Launchpad</a> for translating.</p>
| <p>I don't have any experience crowd-sourcing translations, but my advice would be to find some dependable freelance translators in your target languages (check out Proz.com), and keep going back to them every time you have new content. Application UIs are notoriously difficult to localize because of lack of context in... | 41,102 |
<p>My Tomcat instance is listening to multiple IP addresses, but I want to control which source IP address is used when opening a <code>URLConnection</code>. </p>
<p>How can I specify this?</p>
| <p>This should do the trick:</p>
<pre><code>URL url = new URL(yourUrlHere);
Proxy proxy = new Proxy(Proxy.Type.DIRECT,
new InetSocketAddress(
InetAddress.getByAddress(
new byte[]{your, ip, interface, here}), yourTcpPortHere));
URLConnection conn = url.openConnection(proxy);
</code></pre>
<p>... | <p>Setting manually socket work fine ...</p>
<pre><code>private HttpsURLConnection openConnection(URL src, URL dest, SSLContext sslContext)
throws IOException, ProtocolException {
HttpsURLConnection connection = (HttpsURLConnection) dest.openConnection();
HttpsHostNameVerifier httpsHostNameVerifier = n... | 11,707 |
<p>I have a database with a table Customers that have some data<br><br>
I have another database in the office that everything is the same, but my table Customers is empty<br><br>
How can I create a sql file in SQL Server 2005 (T-SQL) that takes everything on the table Customers from the first database, creates a, let's... | <p>This functionality is already built in to Sql Server Management Studio 2008. </p>
<p>Just download <a href="http://www.microsoft.com/sqlserver/2008/en/us/trial-software.aspx" rel="noreferrer">the trial</a> and only install the client tools (which shouldn't expire). Use Management Studio 2008 to connect to your 2005... | <p>If both databases resides in the same instance of SQL Server, ie use same connection, this SQL might be helpful:</p>
<pre><code>INSERT INTO [DestinationDB].[schema].[table] ([column])
SELECT [column] FROM [OriginDB].[schema].[table]
GO
</code></pre>
| 4,073 |
<p>I have a fingerprint image taken from a sliding scanner. However the output does not have clean background. It looks like this:</p>
<p><a href="http://img208.imageshack.us/img208/2622/dirtyie0.png">dirty http://img208.imageshack.us/img208/2622/dirtyie0.png</a></p>
<p>I want to remove the background so that further... | <p>You might try an edge detection filter. That would help remove the background noise, and might sharpen up the fingerprint features for the rest of the processing.</p>
<p><a href="http://en.wikipedia.org/wiki/Canny_edge_detector" rel="noreferrer">Canny edge detector</a> might be a good one to try first. There's ev... | <p>To start, I'd increase the contrast to 100% to get a pure black and white image (not greyscale).</p>
| 27,750 |
<p>Is there a built in way to determine if a component is fully visible in a Flex application (i.e. not offscreen one way or the other). If not how would I go about figurin it out?</p>
<p>I want to show or hide additional 'next' and 'previous' buttons if my primary 'next' and 'previous' buttons are off screen.</p>
<p... | <p>here is a method for calculating if the component is within the bounds of the stage, it will not however tell you if the component is being hidden by another component, or if the component is being hidden because it is outside the bounds of another container.</p>
<pre><code>public function isComponentWithinStage(c:... | <p>Could you give the specifics of the visible item and the container(s) it's in? Is it a matter of having to scroll some container to get to the buttons? Or is it a matter of someone has dragged a child window of a flexlib:MDICanvas partially off screen? </p>
<p>I think it's going to come down to if the x,y positi... | 34,993 |
<p>I have form with 2 DDL named</p>
<p>State and City</p>
<p>State:</p>
<pre><code><asp:UpdatePanel ID="States" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="States"EventName="SelectedIndexChanged" />
</Triggers>
&... | <p>I recommend creating a private property in the ViewState that holds the collection of physical objects. Then add the object to that list then databind the list of objects to the drop down.</p>
<p>Page Behind</p>
<pre><code><asp:DropDownList runat="server" ID="ddlCity" DataValueField="Key" DataTextField="Value"&... | <p>If at all possible, I would suggest using the <a href="http://www.asp.net/ajax/ajaxcontroltoolkit/samples/CascadingDropDown/CascadingDropDown.aspx" rel="nofollow noreferrer">CascadingDropDown Extender</a> instead of the UpdatePanel. There's no use reinventing that wheel, and the Toolkit control uses web services in... | 38,446 |
<p>If tan(x) = y and atan(y) = x why Math.Atan(Math.Tan(x)) != x?</p>
<p>I´m trying to calculate x in something like: </p>
<pre><code>tan(2/x +3) = 5
</code></pre>
<p>so </p>
<pre><code>atan(tan(2/x + 3) = atan(5)
</code></pre>
<p>and so on... but I´ve tried this: </p>
<pre><code>double d = Math.Atan(Math.Tan(10... | <ol>
<li>The tangent function is periodic with period pi, and is invertible <em>only</em> if you restrict it to a subset of its domain over which it is injective. Usually the choice of such set is the open interval ]-pi/2, pi/2[, hence the arctan function will always return a point in that interval. In your case, 10 = ... | <p>In general, when you are dealing with floating point numbers, you are dealing with approximations. There are numbers that cannot be represented exactly, and the tan and arctan operations are themselves only approximate.</p>
<p>If you want to compare floating point numbers, you need to ask if they are nearly equal, ... | 40,142 |
<p>I like to study languages outside my comfort zone, but I've had a hard time finding a place to start for functional languages. I heard a lot of good things about <a href="https://rads.stackoverflow.com/amzn/click/com/0070004846" rel="noreferrer" rel="nofollow noreferrer">Structure and Interpretations of Computer Pr... | <p><a href="http://www.ccs.neu.edu/home/matthias/BTLS/" rel="noreferrer">The Little Schemer</a> teaches recursion really well, and it's fun and simple to read. </p>
<p>I also liked <a href="http://www.scheme.com/tspl3/" rel="noreferrer">The Scheme Programming Language</a> for a broader introduction into the language. ... | <p>I have heard good things about <a href="https://rads.stackoverflow.com/amzn/click/com/0201342758" rel="nofollow noreferrer" rel="nofollow noreferrer">Haskell Functional Programming</a>, but I also found this <a href="http://www.amazon.com/LISP-Functional-Programming-Books/lm/36GEU8N3B2JPW" rel="nofollow noreferrer">... | 4,313 |
<p>I have a MySQL table LOGIN_LOG with fields ID, PLAYER, TIMESTAMP and ACTION. ACTION can be either 'login' or 'logout'. Only around 20% of the logins have an accompanying logout row. For those that do, I want to calculate the average duration.</p>
<p>I'm thinking of something like</p>
<pre><code>select avg(LL2.TIME... | <p>Given the data you have, there probably isn't anything much faster you can do because you have to look at a LOGIN and a LOGOUT record, and ensure there is no other LOGIN (or LOGOUT?) record for the same user between the two.</p>
<p>Alternatively, find a way to ensure that a disconnect records a logout, so that the ... | <p>Do you have a SessionManager type object that can timeout sessions? Because a timeout could be logged there, and you could get the last activity time from that and the timeout period.</p>
<p>Or you log all activity on the website/service, and thus you can query website/service visit duration directly, and see what ... | 45,660 |
<p>We are moving our database server to a bigger box. I have several databases with full text indexes. What is the best way to move the full text indexes?</p>
| <p>I find backup and restore is the only reliable way to move databases. The FTS should move with it when you do that. Detaching and reattaching databases never really sits well with me. </p>
| <p>If you are moving the databases, move the folders that contain the FTS information and you should be fine.</p>
<p>If you're doing a restore, you should be fine as is.</p>
| 25,262 |
<p>I think I've declared a Vector with an object correctly. But, I don't know how to access it's members when looping with Iterator.</p>
<p>In my code, the line --->> cout << " " << *Iter;</p>
<p>How do I print the contents of the members? Like *Iter.m_PackLine ???</p>
<p>Not sure if I used the correc... | <pre><code>cout << " " << *Iter;
</code></pre>
<p>will only work if <code>CFileInfo</code> has an overloaded <code>operator<<</code> that can output your struct. You can output individual members of the struct instead like this:</p>
<pre><code>cout << " " << Iter->m_PackLine;
</code><... | <p>Thanks all, wish I could grant multiple points for the answers :)</p>
<p>litb also pointed out a problem I was having in my declaration of the vector. I removed the second argument in the vector declaration and it worked.</p>
<p>Stackoverflow parsed out some of my code, I'll be more careful in posting next time.<... | 41,700 |
<p>I have multiple projects in a couple of different workspaces. However, it seems like I can never figure out how to change my current workspace. The result is that files that I have checked out on my machine are shown to be checked out by somebody else and are not accessible.</p>
| <p>I'm going to assume you mean "workspace", not "workstation", as your question doesn't quite make sense to me otherwise.</p>
<p>In Visual Studio, go to the Source Control Explorer (View->Other Windows->Source Control Explorer). At the top of the source control explorer window you should have a toolbar with a few bu... | <p>I don't entirely understand your question.</p>
<p>Are you saying that files you check out on one machine seems to be unaccessible on another of your machines? I'd say that would be entirely by design, as now you have a file that has local modifications done on one machine, which may or may not be available on your ... | 4,223 |
<p>I have log4net running on my AsP.NET site. I'm able to log messages to my DB Table, but it isn't logging the ThreadContext properties. For example:</p>
<pre><code>ThreadContext.Properties["Url"] = HttpContext.Current.Request.Url.ToString();
ThreadContext.Properties["HttpReferer"] = HttpContext.Current.Request.Serve... | <p>So, it turns out the config was to blame. It was slightly wrong:</p>
<p>Original:</p>
<pre><code><conversionPattern value="%property{log4net:HttpReferer}"/>
</code></pre>
<p>Changed:</p>
<pre><code><conversionPattern value="%property{HttpReferer}"/>
</code></pre>
<p>I had to take out the "log4net:" ... | <p>Can you turn on log4net verbose/debug/show sql to see what its doing at that level? Is there perhaps another bit of config thats needed to tie it all together?</p>
| 22,681 |
<p>What's a quick-and-dirty way to make sure that only one instance of a shell script is running at a given time?</p>
| <p>Use <a href="http://linux.die.net/man/1/flock" rel="noreferrer"><code>flock(1)</code></a> to make an exclusive scoped lock a on file descriptor. This way you can even synchronize different parts of the script.</p>
<pre><code>#!/bin/bash
(
# Wait for lock on /var/lock/.myscript.exclusivelock (fd 200) for 10 secon... | <p>Try something like the below,</p>
<pre><code>ab=`ps -ef | grep -v grep | grep -wc processname`
</code></pre>
<p>Then match the variable with 1 using an if loop.</p>
| 22,428 |
<p>I've read a lot of comments mention in passing that the BlackBerry threading model deviates from the Java standard and can cause issues, but no amount of googling has enlightened me on what this means exactly.</p>
<p>I've been developing a fairly large business application for the BlackBerry and, although I don't r... | <p>1.UI
User interface operations <strong>always</strong> need to run in the UI thread. To execute such functions like <code>LabelField.setText("foo");</code> you need to do:</p>
<pre><code>UiApplication.getUiApplication().invokeLater(new Runnable(){
public void run(){
myLabelField.setText("foo");
myLabelFie... | <p>The only issue I can think of is discussed in the answer to <a href="https://stackoverflow.com/questions/292587/interacting-with-ui-threads-in-javaj2me">another stackoverflow question</a>.</p>
| 46,451 |
<p>Warning: this is the actual code generated from my system:</p>
<pre><code>;WITH RESULTS AS (
SELECT 1174 AS BatchRunID, 'STATINV' AS Program, m.APPL_CD, m.ALBASE, 'CountFocusRecords' AS Measure, COUNT(*) AS Value
FROM [MISWork].[SX_FOCUS_NATIVE_200806] AS m WITH(NOLOCK)
INNER JOIN MISProcess.SXProcessCatalog AS cat... | <p>Change to UNION ALL, since you'll never have dupes (the Measure column is hard coded to be different). UNION must first sort the rows, and then find dupes and eliminate.</p>
<p>My real guess is it's a parallelization issue. Try adding OPTION (MAXDOP 1) at the end.</p>
| <p>If you can post the query execution plan in XML format, that'll help us determine what parts of the query are causing problems. In SSMS, click Query, Display Estimated Execution Plan, and when it comes up, right-click on it and save as XML.</p>
| 19,846 |
<p>Here's the situation:</p>
<p>I have one VS2005 solution with two projects: MyDll (DLL), MyDllUnitTest (console EXE).</p>
<p>In MyDll I have a class called MyClass which is internal to the DLL and should not be exported. I want to test it in MyDllUnitTest, so I added a test suite class called MyClassTest, where I c... | <p>I don't understand why you don't want to build it in your dll project. As long as both projects are using the same source file, they will both generate the same object file (assuming compiler options are set the same way).</p>
<p>If you want to test the dll without exporting the class itself (I presume this is beca... | <p>I think you also need to explicitly add the .obj file to your list of additional dependencies in your project linker settings.</p>
| 32,699 |
<p>I am running my <code>HTTPServer</code> in a separate thread (using the threading module which has no way to stop threads...) and want to stop serving requests when the main thread also shuts down.</p>
<p>The Python documentation states that <code>BaseHTTPServer.HTTPServer</code> is a subclass of <code>SocketServer... | <p>I should start by saying that "I probably wouldn't do this myself, but I have in the past". The serve_forever (from SocketServer.py) method looks like this:</p>
<pre><code>def serve_forever(self):
"""Handle one request at a time until doomsday."""
while 1:
self.handle_request()
</code></pre>
<p>You... | <p>Here's a context-flavored version for Python 3.7+ which I prefer because it cleans up automatically <em>and</em> you can specify the directory to serve:</p>
<pre><code>from contextlib import contextmanager
from functools import partial
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
from thread... | 33,718 |
<p>In another question on SO I answered with code like the one below and got a comment that the LINQ-query probably was evaluated in every iteration of the for/each. Is that true?</p>
<p>I know that LINQ-querys does not executes before its items is evaluated so it seems possible that this way to iterate the result can... | <p>NO... in a foreach, the "GetEnumerator" is called only once (ever), and that is used going forward.</p>
<p>EDIT: I put a statement here about the result set being stored temporarily... that's only true for some cases... not this one, so I took it out.</p>
<p>EDIT: Please forgive this for being overly verbose... bu... | <p>I looked up the FOR EACH...NEXT statement and it seems like Visual Basic evaluates the collection only once, before the loop begins, so it should not run the query on every iteration.</p>
<blockquote>
<p>Number of Iterations. Visual Basic
evaluates the collection only once,
before the loop begins. If your
s... | 43,142 |
<p>I am trying to create a Task Scheduler task to start my SQL Server 2005 instance every morning, because something stops it every night. This is a temporary solution until I can diagnose the stoppage.</p>
<p>I created a task to run under my admin user, and to start the program, <em>cmd</em> with the arguments <em>/... | <p>Use an enum:</p>
<pre><code>public enum Foo {
INSTANCE;
}
</code></pre>
<p>Joshua Bloch explained this approach in his <a href="http://sites.google.com/site/io/effective-java-reloaded" rel="noreferrer">Effective Java Reloaded</a> talk at Google I/O 2008: <a href="http://www.youtube.com/watch?v=pi_I7oD_uGI#t=28... | <p>Sometimes a simple "<strong><code>static Foo foo = new Foo();</code></strong>" is not enough. Just think of some basic data insertion you want to do.</p>
<p>On the other hand you would have to synchronize any method that instantiates the singleton variable as such. Synchronisation is not bad as such, but it can lea... | 9,613 |
<p>Using groovy, would you expect better performance in terms of speed and memory overhead to read and query JSON vs XML? </p>
| <p>JSON is smaller and simpler than XML. I'd bet that JSON is faster to parse.</p>
<p>YAML would be faster still.</p>
| <p>XML has a bit more overhead than JSON because of the angle brackets and extra information and what not. Any good parser should be able to parse JSON faster than XML for this reason.</p>
| 21,721 |
<p>The <a href="http://msdn.microsoft.com/en-us/vcsharp/aa336809.aspx" rel="nofollow noreferrer">C# 3.0 spec</a> has the following code example in section 10.6.1.3 "Output parameters":</p>
<pre><code>using System;
class Test
{
static void SplitPath(string path, out string dir, out string name) {
int i = pa... | <p>It is an invalid character '–'. Change '–' to '-'</p>
| <p>According MSDN ( <a href="http://msdn.microsoft.com/en-us/library/362314fe(VS.71).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/362314fe(VS.71).aspx</a> ) this was even possible in .net 1.1 you can of course have a</p>
<p>string myString = "Filip Ekberg";</p>
<p>And then access the first ... | 43,885 |
<p>Are there any open source algorithms in c# that solve the problem of creating a difference between two text files?</p>
<p>It would be super cool if it had some way of highlighting what exact areas where changed in the text document also.</p>
| <p>There is <a href="http://www.menees.com/Diff.Net.htm" rel="nofollow noreferrer">Menees Diff</a> which will provide you with a C# diff implementation. The source code is included. I've used it in the past with good success wrapping it in my own implemenation.</p>
| <p>Check out <a href="http://en.wikipedia.org/wiki/Diff" rel="noreferrer">diff</a>. Here it is <a href="http://www.gnu.org/software/diffutils/diffutils.html" rel="noreferrer">in the gnu project</a> (open source, of course), and many more links to implementations are found in the wikipedia article. A comparison of diffe... | 9,096 |
<p>How do you handle database exceptions in your application?<br>
Are you trying to validate data prior passing it to DB or just relying on DB schema validation logic?<br>
Do you try to recover from some kind of DB errors (e.g. timeouts)?</p>
<p>Here are some approaches:</p>
<ol>
<li>Validate data prior passing it to... | <p>@aku: DRY is nice, but its not always possible. Validation is one of those places, as you will have three completely different and unrelated places where validation is not only possible but absolutely needed: Within the UI, within the business logic, and within the database.</p>
<p>Think of a web application. Y... | <p>The sorts of apps that I was writing (I've since moved jobs) were in-house fat-client apps.<br>
I would try to keep the business logic in the client, and do more mechanical validation on the db (ie validation that only related to the procedure's ability to run, as opposed to higher level validation).<br>
In short, v... | 6,039 |
<p>I want something like an <a href="http://en.wikipedia.org/wiki/Map_%28C++%29" rel="nofollow noreferrer">std::map</a>, but I only want to see if the item exists or not, I don't actually need a key AND a value. What should I use?</p>
| <p>Looks like you need a <a href="http://en.cppreference.com/w/cpp/container/set" rel="nofollow noreferrer">std::set</a>.</p>
| <p>You can keep using std::map for the desired purpose.</p>
<p>To check if a particular item (of key type) exists in the map or not, you can use following code:</p>
<pre><code>if (mapObj.count(item) != 0)
{
// item exists
}
</code></pre>
<p>As answered earlier, std::set will do the job as well. Interestingly both... | 15,193 |
<p>I have Swing java application with network communications to several "Players" that are represented as player objects, each with their own communication thread. The app has a "Team" object managing all player objects. Several UI components listen to events passed from the players through the Team object. </p>
<p>In... | <p>Maybe you can use easymock to isolate the classes you want to test, and have the mock objects receive the events and check that they're fired.</p>
<p>I'd recommend EasyMock: <a href="http://www.easymock.org/" rel="nofollow noreferrer">http://www.easymock.org/</a></p>
<p>From your story it feels that your unittests... | <p>Maybe you can use easymock to isolate the classes you want to test, and have the mock objects receive the events and check that they're fired.</p>
<p>I'd recommend EasyMock: <a href="http://www.easymock.org/" rel="nofollow noreferrer">http://www.easymock.org/</a></p>
<p>From your story it feels that your unittests... | 42,670 |
<p>Can any one explain why the output of this code is only 'hello' and what this code means?</p>
<pre><code>( 0, characterArray, 0, characterArray.Length );
</code></pre>
<p>The output is showing:</p>
<p><PRE>The character array is: hello</PRE></p>
<p>The code follows:</p>
<pre><code>string string1 = "hello there"... | <p>It's because your array is only set for 5 characters. Expand it to 11 and it will work.</p>
<p>Here is what the Copyto is:</p>
<pre><code>public void CopyTo(
int sourceIndex,
char[] destination,
int destinationIndex,
int count
)
</code></pre>
<pre>
Parameters
sourceIndex
Type: System..::.Int32
A c... | <p>That's because your character array size is only 5. if you want the whole string as an array, you can you string.ToCharArray instead</p>
| 46,051 |
<p>One of the nice feature of the Image control is that we can specified an Uri as the ImageSource and the image is automatically downloaded for us. This is great! <strong>However, the control doesn't seem to have a property indicating if the image loading is in progress or not.</strong></p>
<p>Is there a property tel... | <p>As long as your ImageSource is a BitmapImage you could use the BitmapImage.DownloadCompleted event. The only problem I have found so far is that it only works from C#, so you would lose some flexibility. I'm guessing you could access that event from XAML, but I'm not sure how. The following sample starts loading the... | <p>Hmm - that's a good question. I looked at the ImageSource class's documentation on MSDN, and it doesn't look like there is anything on there to get that information.</p>
<p>That being said, could you start the download manually and set the Image control's Source property once that download finishes? You'd know for ... | 42,713 |
<p>What is a good free library for editing MP3s/FLACs. </p>
<p>By editing I mean:</p>
<ul>
<li>Cutting audio file into multiple parts</li>
<li>Joining multiple audio files together</li>
<li>Increase playback speed of file without affecting the pitch (eg. podcasts up to 1.3x)</li>
<li>Re-encoding audio file from Flac ... | <p>Just about every language has bindings to C, so you'll probably want to get the applicable C libraries for encoding/decoding mp3's and FLAC files. This list might include</p>
<p>libFLAC <a href="http://flac.sourceforge.net/api/index.html" rel="nofollow noreferrer">http://flac.sourceforge.net/api/index.html</a> FLA... | <p>I use <a href="http://audacity.sourceforge.net/" rel="nofollow noreferrer">Audacity</a> for all my editing needs</p>
<blockquote>
<p>Audacity is a free, easy-to-use audio
editor and recorder for Windows, Mac
OS X, GNU/Linux and other operating
systems. You can use Audacity to:</p>
<pre><code>* Record live ... | 3,986 |
<p>If you create an ASP.NET web file project you have direct access to the Profile information in the web.config file. If you convert that to a Web App and have been using ProfileCommon etc. then you have to jump through a whole bunch of hoops to get your web app to work.</p>
<p>Why wasn't the Profile provider built i... | <p>The profile provider uses the ASP.NET Build Provider system, which doesn't work with Web Application Projects.</p>
<blockquote>
<p>Adding a customized BuildProvider
class to the Web.config file works in
an ASP.NET Web site but does not work
in an ASP.NET Web application project.
In a Web application proje... | <p>Actually, Microsoft does have a solution for this known issue.
It's the "Web Profiler Builder". I used it for my Web App and it works great.
<a href="http://code.msdn.microsoft.com/WebProfileBuilder/Release/ProjectReleases.aspx?ReleaseId=980" rel="nofollow noreferrer">http://code.msdn.microsoft.com/WebProfileBuilder... | 3,366 |
<p>The following is a question I asked on my blog a few months back but I still haven't got a proper answer to. Then a couple of days ago I was asked if I had the answer so I decided to copy the question in here where it will get a much more exposure by willing-and-able developers. Anyways, here goes...</p>
<hr>
<p>I... | <p>On the server side you can detect that the session is expired and return a strong typed exception. On the browser side, you can specifically detect for that error and simply have the page refresh. This assumes that when your page posts back for the refresh that your application detects expired sessions and has the... | <p>What's wrong with redirecting the user to the login page after his session actually expired? From a user point of view I do really prefer this over not noticing an expired session, filling out some way too long form and actually notice the expiration on submit.
It's at least a very user friendly solution to the prob... | 32,101 |
<p>Thanks for reading this.</p>
<p>I am dynamically generating some data which includes a select drop-down with a text box next to it. If the user clicks the select, I am dynamically populating it (code below). I have a class on the select and I was hoping the following code would work. I tested it with an ID on the s... | <p><code>$(this)</code> is only relevant within the scope of the function. outside of the function though, it loses that reference:</p>
<pre><code>$('.classSelect').one("click", function() {
$(this); // refers to $('.classSelect')
$.ajax({
// content
$(this); // does not refer to $('.classSelect')
}... | <p>That is matching one select. You need to match multiple elements so you want</p>
<pre><code>$("select[class='classSelect']") ...
</code></pre>
| 37,161 |
<p>I'm looking for a good ssh console plugin for Eclipse, and can't find much at all. Would anyone have some good leads on one?</p>
| <p>In Eclipse 3.4.1, there is the Remote Systems Explorer perspective that allows you to create and connect to SSH terminals (<a href="http://www.eclipse.org/dsdp/tm/tutorial/" rel="noreferrer">here</a>)</p>
| <p>You can also try the <a href="https://code.google.com/p/elt/" rel="nofollow">Terminal plug-in for Eclipse</a></p>
<blockquote>
<p>This plug-in provides a fully-working, command-line terminal to
Eclipse 3.7 or later (yes, even 4.2!) It works on Linux and MacOS
only.</p>
</blockquote>
<p>More info at: <a href=... | 43,348 |
<p>Heavy emphasis on simple. I've never made an installer and I'd rather not have to learn much. A system that I could hand a pile of files to and it would make some smart guesses about where to put them would be ideal.</p>
<p>Go ahead and answer the general question.</p>
<p>However In my cases I'm stuck with some ex... | <p><a href="http://www.jrsoftware.org/" rel="noreferrer">InnoSetup</a> or <a href="http://nsis.sourceforge.net/" rel="noreferrer">NSIS</a>, whichever seems easier to you. <a href="http://www.istool.org" rel="noreferrer">ISTool</a> is a nice GUI tool for InnoSetup which makes creating setup scripts even easier.</p>
| <p>My advice is this. Try to keep the installer as simple as possible. Windows Installer is a very complicated piece of software and when things don't work right it can be hard to figure out what's going on. I'm sure we have all experienced the endless loop of Windows Installer trying to repair a file that you no longe... | 4,366 |
<p>I am in need of a way to mute a specific application in Vista.</p>
<p>Example: Mute just Firefox, but not all of the other application. Much similar to muting a specific program from within the volume mixer in vista. </p>
<p>If there is a program that will do this, i would appreciate that. Otherwise if there is ... | <p>I suggest using the built in Mixer in Vista...</p>
<p>Why do you want to use an 3rd party program?</p>
| <p>Using AutoHotkey, this works even better than expected! Just a fast window flash and BOOM, done.
Src: <a href="http://feebdack.com/knob/how_to_mute_a_single_application" rel="nofollow">http://feebdack.com/knob/how_to_mute_a_single_application</a></p>
<pre><code>#NoEnv ;// Recommended for new scripts
#Persistent ;/... | 6,297 |
<p>Is this possible? I had troubles with SVN clients not being able to access the repository with the following error message:</p>
<blockquote>
<p>Repository moved permanently to '<a href="http://svn.example.com/test/" rel="noreferrer">http://svn.example.com/test/</a>'; please relocate</p>
</blockquote>
<p>If I add... | <p>The problem is that you are using the document root also as the repository root (I'm not blaming you, this should just work, but it doesn't).</p>
<p>Try pointing the <code>DocumentRoot</code> and <code>SVNParentPath</code> directives to different physical locations, so the resulting config file should look like thi... | <pre><code>This is working for me:
<Location />
DAV svn
SVNPath /repository
AuthType Basic
AuthName "Repository authentication"
AuthUserFile /repository/.svn-auth
AuthzSVNAccessFile /repository/.svn-access
Satisfy All
Require valid-user
</Location>
</code></pre>
<p>Pointing... | 33,158 |
<p>I want to set a breakpoint on the <code>__DoPostBack</code> method, but it's a pain to find the correct file to set the breakpoint in.</p>
<p>The method <code>__DoPostBack</code> is contained in an auto-generated js file called something like: </p>
<pre><code>ScriptResource.axd?d=P_lo2...
</code></pre>
<p>After ... | <p>How about this one <a href="http://sourceforge.net/projects/sqlitebrowser/" rel="nofollow noreferrer">http://sourceforge.net/projects/sqlitebrowser/</a>:</p>
<blockquote>
<p>SQLite Database browser is a light GUI editor for SQLite databases, built on top of QT. The main goal of the project is to allow non-technic... | <p>Sourceforge has a help wanted page: <a href="http://sourceforge.net/people/" rel="nofollow noreferrer">http://sourceforge.net/people/</a></p>
<p>browse the postings to see if a project is in your expertise or find one that sound interesting...</p>
<p>And let me be the first to say thank you for being willing to co... | 10,265 |
<p>I'm looking for a good, clean way to go around the fact that PHP5 still doesn't support multiple inheritance. Here's the class hierarchy:</p>
<p>Message<br>
-- TextMessage<br>
-------- InvitationTextMessage<br>
-- EmailMessage<br>
-------- InvitationEmailMessage </p>
<p>The two types of Invitation* cl... | <p>Alex, most of the times you need multiple inheritance is a signal your object structure is somewhat incorrect. In situation you outlined I see you have class responsibility simply too broad. If Message is part of application business model, it should not take care about rendering output. Instead, you could split res... | <p>How about an Invitation class right below the Message class?</p>
<p>so the hierarchy goes:</p>
<p>Message<br>
--- Invitation<br>
------ TextMessage<br>
------ EmailMessage </p>
<p>And in Invitation class, add the functionality that was in InvitationTextMessage and InvitationEmailMessage. </p>
<p>I know that In... | 11,631 |
<p>It's been suggested that this might be a reasonable approach, in order to minimize changes to an existing server configurations, but is it actually valid/supported? I've not been able to find anything specific either way.</p>
<p>In practice, with a JBoss Portal V2.4.2 server, there appears to be some class-loading ... | <p><a href="http://jcp.org/en/jsr/detail?id=286" rel="nofollow noreferrer">JSR 286 (Portlet 2.0) spec</a>:</p>
<blockquote>
<p>PLT.2.7</p>
<p>Relationship with Java 2
Platform, Standard and Enterprise
Edition</p>
<p>The Portlet API v2.0 is based on the
Java Platform, Standard Edition 5.0
and Enterp... | <p>I assume that the question has to do whether a standard web application can be rendered as a portlet from a Portlet container. This is not possible. The portlets need to be based on the GenericPortlet class and have special deployment descriptors. There is the JSR-168 standard, which specifies the requirements for t... | 47,327 |
<p>Has anyone used <a href="http://www.oracle.com/technetwork/middleware/coherence/overview/index.html" rel="nofollow noreferrer">Oracle Coherence</a>? It looks very promising at the roadshows.</p>
<p>My concern is whether it's a stable and robust enough to implement mission-critical financial solutions.</p>
<p>I'd b... | <p>I've had first hand experience with Oracle Coherence at two big investment banks and can say it's definitely stable. However, as with any complex piece of software it's not without it's quirks.</p>
<p><b>EDIT:</b> Doh, just realised the question is over a year old. Oh well...</p>
| <p>Oracle Coherence is a mature product, but you need to make sure that you have the latest patches from Oracle. The point releases that are downloadable from the Oracle website have many bugs that are fixed in the patch releases.</p>
<p>As for development and maintenance, the learning curve is a little steeper than ... | 15,379 |
<p>Here's my code (note that this was given by a friend):</p>
<pre><code>Private Sub Browse_Click()
Dim textfile As String
textfile = Space(255)
GetFileNameFromBrowseW Me.hWnd, StrPtr(sSave), 255, StrPtr("c:\"),
StrPtr("txt"), StrPtr("Apps (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) +
"All files (*.*)... | <p>As shahkalpesh mentioned, you can access this functionality simply using a standard COM library.</p>
<p>In VB6, add the component:</p>
<ul>
<li>Project > Components</li>
<li>On the Controls tab, choose Microsoft Common Dialog Control 6.0 (SP6)</li>
</ul>
<p>Now on your form, add the new Common Dialog control from... | <p>Maybe sSave contains a pathname, but textfile contains 255 spaces.</p>
| 36,832 |
<p>I'm currently using the module <code>URI::URL</code> to generate a full URL from a relative URL; however, it isn't running as fast as I'd like it to be. Does anyone know another way to do this that may be faster?</p>
| <p>The following code should work.</p>
<pre><code>$uri = URI->new_abs( $str, $base_uri )
</code></pre>
<p>You should also take a look at <a href="http://search.cpan.org/dist/URI/URI.pm" rel="nofollow noreferrer">the URI page on search.cpan.org</a>.</p>
| <p>Perhaps I got the wrong end of the stick but wouldn't,</p>
<pre><code>$full_url = $base_url . $relative_url</code></pre>
<p>work? IIRC Perl text processing is pretty quick.</p>
<p><i>@lennysan</i> Ah sure yes of course. Sorry I can't help, my Perl is pretty rusty.</p>
| 4,649 |
<p>I need to store phone numbers in a table. Please suggest which datatype should I use?
<strong>Wait. Please read on before you hit reply..</strong></p>
<p>This field needs to be indexed heavily as Sales Reps can use this field for searching (including wild character search).</p>
<p>As of now, we are expecting phon... | <p>Does this include:</p>
<ul>
<li>International numbers?</li>
<li>Extensions?</li>
<li>Other information besides the actual number (like "ask for bobby")?</li>
</ul>
<p>If all of these are no, I would use a 10 char field and strip out all non-numeric data. If the first is a yes and the other two are no, I'd use two ... | <p>Use data type long instead.. dont use int because it only allows whole numbers between -32,768 and 32,767 but if you use long data type you can insert numbers between -2,147,483,648 and 2,147,483,647.</p>
| 10,069 |
<p>I am working on an ASP.NET (3/5) web application. In the application, we assemble lists of classes from a variety of data sources. I would like to create a report in SQL Server SSRS that renders a report from the contents of one of those lists, without pushing the list to the database (in fact, it would be a viola... | <p>Reporting services offer something called as DataSet extensions. You may use that to render the report from your custom data source. You do not need to load them back into database. However, certain editions of SQL like SQL Express reporting services does not support dataset extension.</p>
| <p>You might want to use the ReportViewer control which ship with Visual Studio 2005 and Visual Studio 2008.</p>
<p>It can run in a "local mode", which doesn't require a Report Server backend. You simply drop it from the VS toolbox onto an ASPX form, then wire it up in code with any IEnumerable collection as its data... | 36,724 |
<p>Is there any way that I can find the container pointed to by an iterator? Specifically, I want to be able to find the <code>std::vector</code> pointed to by a particular <code>std::vector::iterator</code> so that I can check the range, without having to actually pass references to that vector around.</p>
<p>If (as ... | <p>I don't believe so. If iterators had to keep a reference/pointer to their owning container, then it would be impossible for them to be optimized down to a lightweight pointer (which can be done with containers guaranteeing contiguous storage like vectors and such).</p>
| <p>I don't believe there's an exposed method to do that. The reason being, that's not the purpose of the iterator. There is, of course, no technical reason that an iterator could not hold a pointer to its parent container. Even if it is implemented in such a way that does not require that pointer, it could still hold i... | 49,159 |
<p>For the past few weeks, I've been trying to learn about just how email works. I understand the process of a client receiving mail from a server using POP pretty well. I also understand how a client computer can use SMTP to ask an SMTP server to send a message. However, I'm still missing something...</p>
<p>The w... | <p>The SMTP server at Gmail (which accepted the message from Thunderbird) will route the message to the final recipient.</p>
<p>It does this by using DNS to find the MX (mail exchanger) record for the domain name part of the destination email address (hotmail.com in this example). The DNS server will return an IP addr... | <p>Step 2 to 3 (i.e. Gmail to Hotmail) would normally happen through SMTP (or ESMTP - extended SMTP).</p>
<p>Hotmail doesn't send anything to a client via POP3. It's important to understand some of the nuances here. The client contacts Hotmail via POP3 and requests its mail. (i.e. the client initiates the discussion).... | 5,274 |
<p>How to allow <code>TextBlock</code>'s text to be selectable?</p>
<p>I tried to get it to work by displaying the text using a read-only TextBox styled to look like a textblock but this will not work in my case because a TextBox does not have inlines. In other words, how to make it selectable?</p>
| <p>Use a <code>TextBox</code> with these settings instead to make it read only and to look like a <code>TextBlock</code> control.</p>
<pre><code><TextBox Background="Transparent"
BorderThickness="0"
Text="{Binding Text, Mode=OneWay}"
IsReadOnly="True"... | <p>I've implemented <a href="http://blog.angeloflogic.com/2014/07/selectabletextblock-in-junglecontrols.html" rel="nofollow">SelectableTextBlock</a> in my opensource controls library. You can use it like this:</p>
<pre class="lang-xml prettyprint-override"><code><jc:SelectableTextBlock Text="Some text" />
</code... | 16,509 |
<p>I have the following JavaScript code:
<a href="http://www.nomorepasting.com/getpaste.php?pasteid=22561" rel="nofollow noreferrer">Link</a></p>
<p>In which the function makewindows does not seem to be working.</p>
<p>It does actual create a window, however the html either contains what is quotes, or if I change it ... | <blockquote>
<p>$row2["ARTICLE_DESC"] is PHP variable.</p>
</blockquote>
<p>It is indeed a php variable, but <strong>it is not being rendered as php because it is not enclosed in <code><?php ?></code> tags</strong></p>
<p>So, the correct way to do it is: </p>
<pre><code>child1.document.write(<?php echo js... | <p>I suspect that it is including the javascript after it has been parsed by the PHP interpreter. Try adding a parameter to makewindows and pass the value you intend to use in via the parameter when you construct the HTML.</p>
<pre><code> ...
<p><a href='#' onclick='makewindows('"
. json_encode($row2["ART... | 45,456 |
<p>I'm creating some big files (DB exports) with Java and I need to put them somewhere on our SharePoint server. Right now, I'm doing this with IE but I'd like to automate this step, too.</p>
<p>I searched the web and I found some hints to use SOAP but I don't really see to the ground of all this, yet. Can someone pro... | <p>Okay ... after several hours of work and biting myself through the "documentation" MicroSoft provides and all the hints randomly spread over the 'net, I've managed to write some sample code to browse the content of a SharePoint server: <a href="http://blog.pdark.de/2008/11/navigating-sharepoint-folders-with.html" re... | <p>I can think of different options:</p>
<ul>
<li>Mapping the Document library to a file drive and just save the file like any other file in the file system.</li>
<li>Using HTTP WebDAV protocol.</li>
</ul>
<p>...and for the NTLM authentication part:</p>
<p><a href="http://www.luigidragone.com/networking/ntlm.html" r... | 40,537 |
<pre><code>EmployeeNumber =
string.IsNullOrEmpty(employeeNumberTextBox.Text)
? null
: Convert.ToInt32(employeeNumberTextBox.Text),
</code></pre>
<p>I often find myself wanting to do things like this (<code>EmployeeNumber</code> is a <code>Nullable<int></code> as it's a property on a LINQ-to-SQL dbml objec... | <p>The problem occurs because the conditional operator doesn't look at how the value is used (assigned in this case) to determine the type of the expression -- just the true/false values. In this case, you have a <code>null</code> and an <code>Int32</code>, and the type can not be determined (there are real reasons it... | <p>As of <a href="https://devblogs.microsoft.com/dotnet/welcome-to-c-9-0/#target-typed--and-" rel="nofollow noreferrer">C# 9.0</a>, this will finally be possible:</p>
<blockquote>
<h3>Target typed ?? and ?:</h3>
<p>Sometimes conditional ?? and ?: expressions don’t have an obvious shared type between the branches. Such ... | 10,138 |
<p>Which one should I use?</p>
<pre><code>catch (_com_error e)
</code></pre>
<p>or </p>
<pre><code>catch (_com_error& e)
</code></pre>
| <p>The second. Here is my attempt at quoting Sutter</p>
<p>"Throw by value, catch by reference"</p>
<blockquote>
<p>Learn to <code>catch</code> properly: Throw exceptions by value (not pointer) and
catch them by reference (usually to <code>const</code>). This is the combination
that meshes best with exception ... | <p>Definitely the second. If you had the following:</p>
<pre><code>class my_exception : public exception
{
int my_exception_data;
};
void foo()
{
throw my_exception;
}
void bar()
{
try
{
foo();
}
catch (exception e)
{
// e is "sliced off" - you lose the "my_exception-ness" of the exception obje... | 18,219 |
<p>I have written a CGI script that creates an image dynamically using GET data. To include this image in my webpage, I am using the following code:</p>
<pre><code><img src="image.py?text=xxxxxxxxxxxxxx">
</code></pre>
<p>The problem is that I expect in the future the "text" field will get very long and the URL... | <p>Store the text somewhere (e.g. a database) and then pass through the primary key.</p>
| <p>img's use GET. You'll have to come up with another mechanism. How about calling the same functionality in image.py and saving the file as a temp file which you ref in the img tag? Or how about saving the value of text in a db row during the rendering of this img tag and using the row_id as what you pass into the ... | 30,152 |
<p>I have some questions about basic CSS that I was unable to understand or find an answer for.</p>
<p>First, I tried placing 3 div tags within another div tag. The first main div tag containing the 3 other tags had nothing set for it except a size, which was <code>400px</code> by <code>400px</code>. Of the other 3 di... | <blockquote>
<p>My problem is that out of the 2 divs,
the one that came last in the code,
would appear first in a browser, and I
did not understand the reasoning for
this.</p>
</blockquote>
<p>I think that You misunderstood a "appear first". You set Your divs to be floating right. So a "2" div, which is FIRS... | <pre><code><html>
<head>
<style>
#main {
border: 4px dashed red;
display: block;
overflow: hidden;
}
#left {
float: left;
width: 20px;
height: 20px,
}
#right {
float: right;
width: 20px;
height: 20px,
}
</style>
</head>
<body>
<div id="main">... | 37,783 |
<p>The file upload control in asp.net does not allow me to select a folder and enables me to select only the files. Is there any way in which I can select a folder (obviously without using the file upload control).</p>
<p>Why I want to select the folder is basically to store its entire path in a database table. </p>
| <p>The HTML <code><input type=file></code> element only supports single file uploads. If you to have multiple file upload, you would have to use a 3rd party component - usually written in Flash.</p>
<p>Here an example: <a href="http://www.codeproject.com/KB/aspnet/FlashUpload.aspx" rel="nofollow noreferrer">http... | <p>No, browsing for files are the client-side feature, and the only information about file path is their name. It's cause security.</p>
| 16,064 |
<pre><code> public sealed class UserLoginSingleton
{
UserLoginCollection _userLoginCol = new UserLoginCollection();
UserLoginSingleton()
{
}
public static UserLoginSingleton Instance
{
get
{
IDictionary items = HttpContext.Current.Items;
if (!items.Con... | <p>The <code>HttpContext.Items</code> collection is per-request. So in your case when the user gets redirected to page2.aspx, the instance you created on page 1 is gone. For the same instance to be available across requests, you need to be using <code>HttpContext.Session</code> to store your instance.</p>
| <p>static fields are shared between requests. Watch out for the standard multi-threaded issues!</p>
<p>HttpContext instances are not shared between requests.</p>
| 47,483 |
<p>In Visual Studio, two files are created when you create a new Windows Form in your solution (e.g. if you create MyForm.cs, MyForm.Designer.cs and MyForm.resx are also created). These second two files are displayed as a subtree in the Solution Explorer.</p>
<p><strong>Is there any way to add files to the sub-tree or... | <p>Open .csproj in edit mode, look for the file you want to be under another one, and add the DependentUpon element, like this:</p>
<pre><code><Compile Include="AlertDialog.xaml.cs">
<DependentUpon>AlertDialog.xaml</DependentUpon>
</Compile>
</code></pre>
| <p>You need to edit the csproj directly. There is a DependentUpon tag that you have to add as a child tag of the file you want to place under MyForm.cs.</p>
<p>Example:</p>
<pre><code><Compile Include="MyForm.MyCoolSubFile.cs">
<DependentUpon>MyForm.cs</DependentUpon>
</Compile>
</code></pre... | 27,556 |
<p>I've recently updated an application to the 3.5 framework (from 2.0). The app links to Reporting Services (2005) remotely via an URL. This all works fine locally but when deployed to the dev server (win 2003) I'm getting a 403 error when attempting to call the report server.</p>
<p>"You are not authorized to view t... | <p>Not sure if I should answer myself or just comment but anyway.</p>
<p>Found the (or at least a) solution from another post. Apparently the reporting services root directory can get corrupted - how is not clear - but I deleted the ReportServer virtual directory and recreated it with the Reporting Services Configurat... | <p>When you say call the report server, what do you mean specifically? Access the Report Manager using this url: www.myserver.com/reports ?</p>
<p>The main reason is, that locally you are authenticated implicitly as the user you're logged on to the server. Accessing the server remotely in the browser, does not neces... | 42,991 |
<p>I'm wanting to use jQuery to wrap a mailto: anchor around an email address, but it's also grabbing the whitepace that the CMS is generating.</p>
<p>Here's the HTML I have to work with, the script as I have it and a copy of the output.</p>
<p>HTML</p>
<pre><code><div class="field field-type-text field-field-ema... | <p>Use the <code>replace</code> function in js:</p>
<pre><code>var emailAdd = $(this).text().replace(/ /g,'');
</code></pre>
<p>That will remove all the spaces</p>
<p>If you want to remove the leading and trailing whitespace <strong>only</strong>, use the jQuery $.trim method :</p>
<pre><code>var emailAdd = $.trim(... | <p><code>str=str.replace(/^\s+|\s+$/g,'');</code></p>
| 47,051 |
<p>I am using java language,I have a method that is supposed to return an object if it is found.</p>
<p>If it is not found, should I:</p>
<ol>
<li>return null</li>
<li>throw an exception</li>
<li>other</li>
</ol>
<p>Which is the best practise or idiom?</p>
| <p>If you are always expecting to find a value then throw the exception if it is missing. The exception would mean that there was a problem.</p>
<p>If the value can be missing or present and both are valid for the application logic then return a null.</p>
<p>More important: What do you do other places in the code? ... | <p>That really depends on if you expect to find the object, or not. If you follow the school of thought that exceptions should be used for indicating something, well, err, exceptional has occured then:</p>
<ul>
<li>Object found; return object</li>
<li>Object not-found; throw exception</li>
</ul>
<p>Otherwise, return ... | 21,155 |
<p>When a script is saved as a bundle, it can use the <code>localized string</code> command to find the appropriate string, e.g. in <code>Contents/Resources/English.lproj/Localizable.strings</code>. If this is a format string, what is the best way to fill in the placeholders? In other words, what is the AppleScript equ... | <p><a href="https://developer.apple.com/library/content/releasenotes/AppleScript/RN-AppleScript/RN-10_10/RN-10_10.html" rel="nofollow noreferrer">Since OS X 10.10</a>, it’s been possible for any AppleScript script to use Objective-C. There are a few ways to call Objective-C methods from within AppleScript, as detailed ... | <p>As ugly as it is, calling out to <code>printf(1)</code> is the common solution.</p>
<p>A cleaner, though somewhat more complex, solution is to use AppleScript Studio, which allows you to call into Objective-C objects/classes from your AppleScript code with the <code>call method</code> syntax documented <a href="htt... | 8,963 |
<p>How do I make my application always use English when displaying win32/.net exceptions messages?</p>
<p>I got this message, it looks like someone used babelfish to translate it (it's Swedish):
"System.ComponentModel.Win32Exception: Programmet kunde inte starta eftersom programmets sida-vid-sidakonfiguration är felak... | <p>You can try setting <code>Thread.CurrentThread.CurrentUICulture</code> and/or <code>.CurrentCulture</code> to <code>CultureInfo("en-US")</code>.</p>
| <blockquote>
<p>How do I make my application always
use English when displaying win32/.net
exceptions messages?</p>
</blockquote>
<p>First of all, <em>don't show win32/.net exception messages to users</em>. You should handle exceptions rather than showing them to user.</p>
<p>By default exception messages will ... | 23,971 |
<p>I have a products table...</p>
<p><a href="http://img357.imageshack.us/img357/6393/productscx5.gif" rel="nofollow noreferrer">alt text http://img357.imageshack.us/img357/6393/productscx5.gif</a></p>
<p>and a revisions table, which is supposed to track changes to product info</p>
<p><a href="http://img124.imagesha... | <p>Here's how I'd do it:</p>
<pre><code>SELECT p.*, r.*
FROM products AS p
JOIN revisions AS r USING (product_id)
LEFT OUTER JOIN revisions AS r2
ON (r.product_id = r2.product_id AND r.modified < r2.modified)
WHERE r2.revision_id IS NULL;
</code></pre>
<p>In other words: find the revision for which no oth... | <p>That same query is parsable in MySQL.</p>
<p>Why are you using a Left JOIN instead of an INNER join or a RIGHT join? </p>
<p>Also if you want to go about this in a different way, you have the MAX function at your disposal.</p>
| 19,046 |
<p>Other than <a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wall" rel="nofollow noreferrer">-Wall</a>, what other warnings have people found useful?</p>
<p><em><a href="http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Warning-Options.html" rel="nofollow noreferrer">Options to Request or Suppress War... | <p>I routinely use:</p>
<pre class="lang-none prettyprint-override"><code>gcc -m64 -std=c99 -pedantic -Wall -Wshadow -Wpointer-arith -Wcast-qual \
-Wstrict-prototypes -Wmissing-prototypes
</code></pre>
<p>This set catches a lot for people unused to it (people whose code I get to compile with those flags for the fir... | <p>I use this option:</p>
<p><a href="https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wfatal-errors" rel="nofollow noreferrer">-Wfatal-errors</a></p>
| 18,694 |
<p>I have been slowly learning SQL the last few weeks. I've picked up all of the relational algebra and the basics of how relational databases work. What I'm trying to do now is learn how it's implemented.</p>
<p>A stumbling block I've come across in this, is foreign keys in MySQL. I can't seem to find much about the ... | <p>Assuming your categories and users table already exist and contain cID and uID respectively as primary keys, this should work:</p>
<pre><code>CREATE TABLE `posts` (
`pID` bigint(20) NOT NULL auto_increment,
`content` text NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`uID` bigint(20) NOT NULL,
`wik... | <p>I agree with Robert. You are missing the name of the column in the references clause (and you should be getting the error 150). I'll add that you can check how the tables got created in reality with:</p>
<pre><code>SHOW CREATE TABLE posts;
</code></pre>
| 29,287 |
<p>I'm looking for suggestions on possible IPC mechanisms that are:</p>
<ul>
<li><strong>Cross platform</strong> (Win32 and Linux at least)</li>
<li>Simple to implement in <strong>C++</strong> as well as the <strong>most common scripting languages</strong> (perl, ruby, python, etc).</li>
<li>Finally, <strong>simple to... | <p>In terms of speed, the best cross-platform IPC mechanism will be pipes. That assumes, however, that you want cross-platform IPC on the same machine. If you want to be able to talk to processes on remote machines, you'll want to look at using sockets instead. Luckily, if you're talking about TCP at least, sockets ... | <p>Python has a pretty good IPC library: see <a href="https://docs.python.org/2/library/ipc.html" rel="nofollow noreferrer"><a href="https://docs.python.org/2/library/ipc.html" rel="nofollow noreferrer">https://docs.python.org/2/library/ipc.html</a></a></p>
| 8,558 |
<p>I have a IBAction such as:</p>
<pre><code>- (IBAction)showPicker:(id)sender;
</code></pre>
<p>How can I get the name of the control from the sender variable?</p>
<p>I am typically a c# coder so have tried the following to no avail</p>
<pre><code>senderName = ((UIButton *)sender).name;
</code></pre>
<p>I need so... | <p>You might want to look at using the <em>tag</em> property. It's an integer rather than a name, but can be used to differentiate between two controls. It's inherited from UIView so any control that's sending an event should have it.</p>
<p>It's editable in Interface Builder under View attributes.</p>
<p>It's a prop... | <p>If the control has a name attribute, then:</p>
<pre><code>NSString *senderName = [sender name];
</code></pre>
<p>This isn't something most controls have. You might want:</p>
<pre><code>NSString *senderName = [sender title];
</code></pre>
<p>If it was an NSButton, for instance. Or as Marc says, for a UIButton, ... | 46,862 |
<p>I'm trying to set up a basic test of HMAC-SHA-256 hashing but I'm having problems with the engine setup. Ideally I would like to set up only the HMAC-SHA-algorithm but so far I haven't even gotten the general case where load all the algorithms to work. Currently I'm getting segfaults on the row where I try to set th... | <p>The problem with your original suggestion is, as Martin said, that you need to initialise the ENGINE. The problem with your edited code was that you were doing ENGINE_new, which is getting you a completely new ENGINE of your own, which you then need to provide with cipher methods, digest methods, etc. In fact, for... | <p>It looks as though nothing is allocating an engine, so the first use of <code>e</code> is segfaulting. I think you need to call <code>ENGINE *ENGINE_new(void)</code> first.</p>
<p>(Note that I've used OpenSSL, but I haven't used the <code>ENGINE</code> functions before.)</p>
<p><strong>Update</strong>: I'm not rea... | 30,049 |
<p>I have been working on a childish little program: there are a bunch of little circles on the screen, of different colors and sizes. When a larger circle encounters a smaller circle it eats the smaller circle, and when a circle has eaten enough other circles it reproduces. It's kind of neat!</p>
<p>However, the way ... | <p>Computers are usually single tasked, this means they can usually execute one instruction at a time per CPU or core.</p>
<p>However, as you have noticed, your operation system (and other programs) appear to run many tasks at the same time.</p>
<p>This is accomplished by splitting the work into processes, and each p... | <p>IF your computer has multiple processors or multiple cores, then you could easily run multiple threads and run smaller parts of the loops in each thread. Many PCs these days do have multiple cores -- so have it so that each thread gets 1/nth of the loop count and then create n threads.</p>
| 34,574 |
<p>I want to delete <strong>all</strong> the previously created indices. I am using <code>Lucene.net</code>.</p>
<p>I tried the following:</p>
<pre><code>Term term = new Term(); //empty because I want to delete all the indices
IndexReader rdr = IndexReader.Open(_directory);
rdr.DeleteDocuments(term);
rdr.Close();
</... | <p>The best way to delete an index is to wipe the filesystem directory. However, if you wan't to regenerate the index, the easiest way is to open a new indexwriter with the create parameter as true. It will start a new index deleting the contents of the existing one. </p>
| <p>As Jokin said, the easiest was is to delete all of the files within the directory. i.e.;</p>
<pre><code>DirectoryInfo directoryInfo = new DirectoryInfo(@"IndexLocation");
Parallel.ForEach(directoryInfo.GetFiles(), file => {
file.Delete();
});
</code></pre>
| 23,873 |
<p>I'm moving DB from MySQL (used ODBC) to MS SQL and I want to "translate" SQL queries to LINQ. Can someone help me with this (it should SUM Charge column for every location and group result by months):</p>
<pre><code>SELECT
sum(case when Location="Location1" then Charge else 0 end) as Location1,
sum(case when Locati... | <p>This might help.</p>
<pre><code>context.log_sales
.GroupBy(s => new {Year = OrderTime.Year, Month = OrderTime.Month})
.Select
( g => new {
Date = new DateTime(g.Key.Year, g.Key.Month, 1),
Location1 = g.Where(s => s.Location == "Location1").Sum(s => s.Charge),
Location2 = g.Where(s => s.Location... | <p>.. do You know maybe how to make adding Locations to Select dynamically? For example from List/Array.</p>
<p>EDIT: .. or maybe making Locations to load dynamically and setting which Locations should be loaded in Where statement before Select. Is this possible?</p>
| 22,199 |
<p>I have this simple regex,</p>
<pre><code>[\d]{1,5}
</code></pre>
<p>that matches any integer between 0 and 99999.</p>
<p>How would I modify it so that it didn't match 0, but matches 01 and 10, etc?</p>
<p>I know there is a way to do an OR like so...</p>
<pre><code>[\d]{1,5}|[^0]{1}
</code></pre>
<p>(doesn't ma... | <p>probably better off with something like:</p>
<p>0*[1-9]+[\d]{0,4}</p>
<p>If I'm right that translates to "zero or more zeros followed by at least one of the characters included in '1-9' and then up to 4 trailing decimal characters"</p>
<p>Mike</p>
| <pre><code>^([1-9][0-9]{0,4}|[0-9]{,1}[1-9][0-9]{,3}|[0-9]{,2}[1-9][0-9]{,2}|[0-9]{,3}[1-9][0-9]|[0-9]{,4}[1-9])$
</code></pre>
<p>Not pretty, but it should work. This is more of a brute force approach. There's a better way to do it via grouping as well, but I'm drawing a blank on the actual implementation at the mo... | 27,469 |
<p>Does anyone have recommendations/experience of how to find people willing to do usability testing of web based apps? I suspect I may need people who might actually be potential users, because mine is a commercial/vertical app which contains some processes and terminology which may not mean much to the average joe/j... | <p>I've used this service a couple times and have been impressed with the quality of the feedback they provide.</p>
<p><a href="http://www.usertesting.com/" rel="noreferrer">usertesting.com</a></p>
| <p>I read this a few days ago and it might help: </p>
<p><a href="http://www.joelonsoftware.com/uibook/fog0000000249.html" rel="nofollow noreferrer">http://www.joelonsoftware.com/uibook/fog0000000249.html</a></p>
| 36,978 |
<p>I work at a small company and our production system uses a hand-rolled RESTful API, implemented in Java with JAXB. We now find that we're taking on customers who use Ruby on Rails, and I have to come up with a reference implementation to show customers how to use our API in Ruby. I'd love to be able to just tell th... | <p>"Best" obviously depends on your needs.</p>
<p>The <em>fastest</em> way to generate any XML in ruby is to use <a href="http://libxml.rubyforge.org/" rel="nofollow noreferrer">libxml-ruby</a> - <a href="http://libxml.rubyforge.org/rdoc/" rel="nofollow noreferrer">link to rdoc</a>.
If your server gets any kind of loa... | <p>I find myself in almost an identical situation as yours (RESTful API done with JAXB w/ namespaces). </p>
<p>I think the most promising project for working with XML in Ruby is HappyMapper. It is a kind of XML binding library (along the lines of an early JAXB-type implementation). It has been gaining a lot of tractio... | 30,843 |
<p>I am designing a class that stores (caches) a set of data. I want to lookup a value, if the class contains the value then use it and modify a property of the class. I am concerned about the design of the public interface.<br>
Here is how the class is going to be used:</p>
<pre>
ClassItem *pClassItem = myClass.Loo... | <p>Two things.</p>
<p>The first solution is close.</p>
<p>Don't however, return <code>ClassItem *</code>. Return an "opaque object". An integer index or other hash code that's opaque (meaningless) to the client, but usable by the myClass instance.</p>
<p>Then lookup returns an index, which modify can subsequently ... | <p>This assumes that you're setting value to the same "something" in both the Modify and Add cases:</p>
<pre><code>if (!myClass.AddIfNotExists(value, something)) {
// use myClass
}
</code></pre>
<p>Otherwise:</p>
<pre><code>if (myClass.TryModify(value, something)) {
// use myClass
} else {
myClass.Add(value... | 15,436 |
<p>I work on Linux all the time and I'm clueless about Windows, not even having a Windows box. Is Git nowadays working on Windows? Or am I making problems for my Windows pals by using it?</p>
| <p>As far as I can tell <a href="http://code.google.com/p/msysgit/" rel="nofollow noreferrer">msysgit</a> works perfectly well under Windows Vista.</p>
<p>This after a whole 2-month experience checking out plugins and applications for Ruby on Rails :-)</p>
<p>Anyway, it was a breeze to install, no problem.</p>
| <p>It works, but not well. If you Google around a bit, you'll find <a href="http://code.google.com/p/msysgit" rel="nofollow noreferrer">the port which uses MinGW</a>. The main problems are instability and some very Linux-like tools (gittk). If you really need it though, you should be able to get by.</p>
| 15,110 |
<p>I'm implementing a <strong>email newsletter sender service</strong> using .NET and Windows Server technologies. Are there comprehensive guidelines which could help <strong>avoiding emails being trapped by spam filters</strong> and other mechanisms?</p>
<p>They should cover all aspects of (legal) bulk mail sending: ... | <p>Although I don't have a definitive answer, I think this is a very important question.
Here are few tidbits I know about it</p>
<ol>
<li>Choose a clean hosting/smtp server. IP addresses of spamming SMTP servers are often black-listed by other ISPs.</li>
<li>Send a simple introductory email to every subscriber, aski... | <p>Unless you have a very specific reason to host the newsletter yourself, I think you'd be much better off using a third party service. There are lots out there, and some are very cheaply priced.</p>
<ol>
<li><p>It'll save you on development work
(no point in re-inventing the
wheel).</p></li>
<li><p>Their system wil... | 14,610 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.