input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
C#, SQL: Storing arbitrary user data in a database as serialized binary <p>Would you consider it bad practice to store various user data in a database as serialized binary? Is it a good, bad or really ugly idea?</p>
<p>I'm talking about pretty much arbitrary things, like the last splitter distance on a form, the last ... | <p>Since you are not searching, it would not be a bad idea - it is a opaque container for miscelaneous user data, and as you said it doesn't contain any critical information. And you are correct, you don't need to change the database to support a new configuration of settings.</p>
|
.msi downloading as text <p>I'm using tomcat 6.0 and struts2.</p>
<p>When I try to click on a link to download a .msi file on IE, the page loads up text from the .msi file instead.</p>
<p>Has anyone encountered this before? What can be done?</p>
<p>Thanks...</p>
| <p>Another guru told me to add this to tomcat/conf/web.xml:</p>
<pre><code><mime-mapping>
<extension>msi</extension>
<mime-type>application/x-msi</mime-type>
</mime-mapping>
</code></pre>
<p>And that works :)</p>
|
Preventing invoking C types from Python <p>What's the correct way to prevent invoking (creating an instance of) a C type from Python?</p>
<p>I've considered providing a <code>tp_init</code> that raises an exception, but as I understand it that would still allow <code>__new__</code> to be called directly on the type.</... | <p>Simple: leave the tp_new slot of the type empty.</p>
<pre><code>>>> Foo()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot create 'foo.Foo' instances
>>> Foo.__new__(Foo)
Traceback (most recent call last):
File "<stdin>", line 1, in <... |
How to test enum types? <p>I'm currently trying to build a more or less complete set of unit tests for a small library. Since we want to allow different implementations to exist we want this set of tests to be (a) generic, so that we can re-use it to test the different implementations and (b) as complete as possible. F... | <p>For enums, I test them only when they actually have methods in them. If it's a pure value-only enum like your example, I'd say don't bother.</p>
<p>But since you're keen on testing it, going with your second option is much better than the first. The problem with the first is that if you use an IDE, any renaming on ... |
how to impersonate client side of wcf call <p>I need some help about WCF and authorization.
Currently I have a client which calls as .NET remoting object hosted in a windows service and which is calling a WCF service (with wshttpbinding).
The WCF service is using windows authentication with message based security.</p>
... | <p>The user that your windows service is running as, must be allowed to impersonate a user.</p>
<p>There is a right called "Impersonate a client after authentication"</p>
<p><a href="http://blogs.technet.com/askperf/archive/2007/10/16/wmi-troubleshooting-impersonation-rights.aspx" rel="nofollow">http://blogs.technet.... |
Problem with retrieving XML via HTTP and writing to file <p>I've written a small scraper that is meant to open up a connection to a PHP script on a remote server via HTTP and pump some XML it finds there into a local file. </p>
<p>Not exactly rocket science, I know.</p>
<p>The code below is the scraper in its entiret... | <p>Try:</p>
<pre><code>XmlDocument doc = new XmlDocument();
doc.Load(url);
doc.Save(filename);
</code></pre>
<p>It really is that easy (with some error handling obviously). The .Net framework should do everything for you. I jumped through hoops a month or so ago trying to do the same thing and kicked myself when I re... |
Send HTML email asp <p>I want to add some html in an email. I've tried the following.</p>
<pre><code>vFromName = "someone"
vFromAddress = "someemail"
vTo = "recipient"
vSubject="someSubject"
vBodyofemail = "<html><table><tr><td><b>SomeText</b></td></tr></table><... | <p>According to <a href="http://www.aspemail.com/manual%5F02.html" rel="nofollow">this page</a> you need to set the <strong>IsHTML</strong> flag to true.</p>
<pre><code>strHTML = "Hello world"
Mail.IsHTML = True
Mail.Body = "<HTML><BODY><CENTER>" & strHTML & "</CENTER></BODY><... |
Rotate Hue using ImageAttributes in C# <p>How can I rotate the hue of an image using GDI+'s <code>ImageAttributes</code> (and presumably <code>ColorMatrix</code>)?</p>
<p>Note that I want to rotate the hue, not tint the image.</p>
<p><B>EDIT</B>: By rotating the hue, I mean that each color in the image should be shif... | <p><a href="http://rexmorgan.net/journal/rotate%5Fimage%5Fhue%5Fin%5Fcnet" rel="nofollow">I threw this together</a> for this question (ZIP file with c# project linked at the bottom of the post). It does not use <code>ImageAttributes</code> or <code>ColorMatrix</code>, but it rotates the hue as you've described:</p>
<p... |
Adding MPI support to a C++ program <p>I have a program that is been implemented in C++ which I now want to add MPI support. There is an MPI binding for C++, with namespace MPI and everything.</p>
<p>In my case I have a specific object that is suitable to be the parallelized process into the cluster.</p>
<p>My questi... | <p>MPI doesn't parallelize anything automatically, it only gives you an interface for sending data between nodes. Your code is written and runs as usual sequential code independently on each node and every once in a while you send data to some other node or try to receive data from some other node.</p>
|
Error in if condition - MS SQL server <p>I am trying to create Update trigger which should be invoked only if the ReturnedOn column is clicked.</p>
<p>I have used the following code-snippet but it generates the error:</p>
<p>CODING:</p>
<pre><code>CREATE TRIGGER trg_ForUpdateOnBookIssuedDetails
on BOOKISSUEDDETAILS
... | <pre><code>...
declare @Rows1 int,@Rows2 int
if update(ReturnedOn)
begin
...
</code></pre>
<p>An extra "(" perhaps...?</p>
|
Can I re-write my URLs like this and is it a good idea? <p>Is it possible to re-write (Apache Mod-Rewrite) a URL from this:</p>
<p><strong><code>http://www.example.com/view.php?t=h5k6</code></strong> to this <strong><code>http://www.example.com/h5k6</code></strong></p>
<p>The reason for this re-write is that the URL ... | <p>The terminology of <a href="http://httpd.apache.org/docs/1.3/mod/mod%5Frewrite.html" rel="nofollow">mod-rewrite</a> works the other way. Requests would come in like this <code>http://www.example.com/h5k6</code> and would be rewritten to <code>http://www.example.com/view.php?t=h5k6</code> internally. That way your PH... |
Embedding webpage in Flash <p>I know very little about Flash, and so is not programming in it. I have a website in PHP, and obviously, HTML, CSS, JS, etc.</p>
<p>What I want to do is to allow users to full-screen certain pieces of the DOM. So my question is, is there any way to wrap flash around certain portions of th... | <p>The standard Flash player does not have the concept of iFrame. With AIR you can embed a browser (WebKit based) within a Flash application, but this is only for desktop applications.</p>
<p>The only real way to do exactly what you want would be to have Flash read out to the DOM via ExternalInterface, pull in the str... |
Calling Console.WriteLine from multiple threads <p>Why does Console.WriteLine work from multiple threads?</p>
| <p>The console class handles the thread synchronization for you.</p>
<p>From the documentation of <a href="http://msdn.microsoft.com/en-us/library/system.console.aspx">Console</a>:</p>
<blockquote>
<p>I/O operations using these streams are
synchronized, which means multiple
threads can read from, or write to,
... |
Sorting a List of LIst by the Value of the sublist <pre><code>private List<String> subList;
private List<List<String>> records = new ArrayList<List<String>>();
for(....){
subList = new ArrayList<String>();
...populate..
records.add(subList);
}
</code></pre>
<p>For exam... | <p>This is just like sorting a string of characters: given two strings, start at the beginning and compare each character; if there's a difference, the string with the lower value comes first, otherwise, look at the next characters from each string. If the strings are of different lengths, treat the shorter string as i... |
Windows console logging to file loses tail end if application crashes; how to see tail end? <p>We build complicated console-based tools that produce a lot of commentary on the console. These tools process a lot of data and so runs are expensive and we don't like to do them more often than necessary, especially during ... | <p>You can flush the console's buffer at any point:</p>
<pre><code>Console.Out.Flush();
</code></pre>
<p>This uses <a href="http://msdn.microsoft.com/en-us/library/system.io.textwriter.flush.aspx" rel="nofollow">TextWriter.Flush()</a>.</p>
<p>If you need to make sure this always happens, it'd be fairly easy to write... |
How does the industry refer to storing mulitple boolean value state in one integer? <p>Here is an easy question.</p>
<p>How does the industry refer to storing mulitple boolean value state in one integer?</p>
<p>The SetWindowPos api is an example.</p>
<pre>
SWP_NOSIZE DEFINE 1
SWP_NOMOVE DEFINE 2
SWP_... | <p>a <a href="http://en.wikipedia.org/wiki/Bit%5Ffield" rel="nofollow">bit field</a></p>
|
Correctly Unit Test Service / Repository Interaction <p>I have a method CreateAccount(...) that I want to unit test. Basically it creates an Account Entity and saves it to the DB, then returns the newly created Account. I am mocking the Repository and expecting an Insert(...) call. But the Insert method expects an Ac... | <pre><code>[Test]
public void can_create_account()
{
const string email = "test@asdf.com";
const string password = "password";
Account newAcc = new Account();
var accounts = MockRepository.GenerateMock<IAccountRepository>();
var service = new AccountService(accounts);
var account = servi... |
getting the bottom 16 bits of a Java int as a signed 16-bit value <p>Hmmm. Consider this program, whose goal is to figure out the best way to get the bottom 16 bits of an integer, as a signed integer.</p>
<pre><code>public class SignExtend16 {
public static int get16Bits(int x)
{
return (x & 0xffff) - ((x &am... | <p>Since numeric casts are implicit-friendly, I think the only reason you're getting the warning is that the compiler will always make the cast to int upon return, making your explicit cast redundant.</p>
|
jquery ui custom tab with ajax tabs <p>I am using jquery UI tabs </p>
<p>I have three ajax tabs like so:</p>
<pre><code><div id="tabs">
<ul>
<li><a href="linktopage1.jsp">Failed EIV Pre-Screening</a></li>
<li><a href="linktopage2.jsp">Failed SSA Screening</a><... | <p>From the <a href="http://docs.jquery.com/UI/Tabs" rel="nofollow">doc</a>, use 'selected' property.</p>
<pre><code>$('#tabs').tabs({ selected: 2 });
</code></pre>
|
Hibernate not fetching public member <p>Consider the following code:</p>
<pre><code>@Entity
@Table(name = "a")
public class A implements Serializable
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id")
public int id;
@Transient
public B b;
public B getB()
{
... | <p>Sounds like a lazy fetching issue. The public reference is null when you try to access it directly, but when you do it with "get", Hibernate knows to call out to the database and hydrate that instance for you.</p>
|
Creating the links of a chain in OpenGL <p>I am working on a project where I have to create a chain with 12 links in it. I want to create the chain out of two curved segments for the top and bottom of the link ad two cylinders for the straight segments, I intend to use a display list to create one link and then displa... | <p>Assuming you want to use display lists, <code>gluPartialDisk()</code> is probably efficient enough (and it's not worth the effort to implement it yourself).</p>
<p>However, there are methods that are even faster than using display lists themselves. I would highly suggest using vertex arrays or vertex buffer objects... |
How to convert this asp.net MVC code from c# to vb.net <p>I need a quick hand figuring out what this code is doing, and how to make it work in vb.net </p>
<pre><code><%=Html.PageLinks((int(ViewData["CurrentPage"], (int)ViewData["Totalpages"], x=> Url.Action("List", new {page = x})) %>
</code></pre>
<p>i've f... | <p>I believe the correct conversion of C#:</p>
<pre><code>x=> Url.Action("List", new {page = x})
</code></pre>
<p>would be in VB.Net:</p>
<pre><code>Function(x) Url.Action("List", New With {.page = x})
</code></pre>
|
What to use to process JSON responses on a command line? <p>I have a nightly executable that will run on a windows or linux server that will be downloading information from various web sources and one of those sources contains a JSON response. This executable will download the information and connect to a SQL server d... | <p>The eval() technique only works within JavaScript, as JSON is valid JavaScript syntax. You might be able to use something like Rhino (Java), but otherwise every language you choose will require using a JSON library. Since you are most familiar with C# and .NET, it seems like the most logical choice if the target mac... |
Migrate SQL Server Tables to Sharepoint Lists <p>I have some tables (aprox 200) i want migrate and include in Sharepoint lists. I need a automatic process, anyone have a tool or code to generate sharepoint list based on tables?</p>
<p>Or please give some links for can help me in my demand.</p>
| <p>I don't think that you will find a tool that will do the whole job.</p>
<p>What you could do is to import each table in to excel, then export it from excel to a sharepoint list.</p>
<p><a href="http://www.sharepointcustomization.com/wss/articles/lists-excel.htm" rel="nofollow">http://www.sharepointcustomization.co... |
ListBox Focused Item <p>this is a WinForms question.</p>
<p>In a ListBox with SelectionMode = MultiSimple, how can I get the currently focused item?</p>
<p>Note, I don't want to get the SelectedItem or SelectedItems, but the item which currently have the dash lines around, something like ListView.FocusedItem.</p>
| <p>This is kinda hacky, but i haven't found a better solution.</p>
<ol>
<li>Put ListBox.DrawMode on OwnerDrawFixed</li>
<li><p>Capture the DrawItem Event and save the focus index on a field</p>
<pre><code> if (e.State == DrawItemState.Focus) {
myfocus = e.Index;
}
// Draw the background of the ListBox control for... |
How to execute php file into variable? <p>Does it possible to execute php file and store its output into some variable?</p>
<p>For example i have one global template, then i need to process subtemplates, and afterall i need to insert that subtemplate output into global template block. </p>
<p>How can i do it ?</p>
| <p>You can use the <a href="http://docs.php.net/manual/en/ref.outcontrol.php">output control functions</a>, buffer the output with <a href="http://docs.php.net/ob%5Fstart"><code>ob_start</code></a> and retrieve it with <a href="http://docs.php.net/ob%5Fget%5Fcontents"><code>ob_get_contents</code></a>:</p>
<pre><code>o... |
How do I run a terminal command within PHP? <p>I'm writing an in-house module to generate a small LaTeX PDF. Within the module, how do I use PHP to utilize the command line?</p>
| <p>I think what you are looking for is the function: <a href="http://mx.php.net/manual/en/function.exec.php" rel="nofollow">passthru()</a>
if you want to directly send the output of your command.</p>
<p>Or if you run your command that command creates a file in the sever and then you send that file to the user use the ... |
Cross-platform fonts in WxWidgets GLCanvas <p>I'm developing a cross-platform app w/ wxWidgets and opengl... </p>
<p>I'm not sure what the best way is to have fonts work in the glcanvas. I've tried using FTGL but I think the version included in Fedora 11 must be broken or something since I can't get the example code o... | <p>Transliterate <a href="http://dmedia.dprogramming.com/?n=Tutorials.TextRendering1" rel="nofollow">this tutorial</a> to C++ and <a href="http://wiki.wxwidgets.org/Embedding%5FPNG%5FImages#bin2c" rel="nofollow">array-embed</a> a gzipped copy of the <a href="http://unifoundry.com/unifont.html" rel="nofollow">GNU Unifon... |
Removing the Label From Django's TextArea Widget <p>How do I remove the label that comes attached to the TextArea I am trying to use with Django? I'm trying to find ANY information about this issue but I cannot seem to find anything relating to my problem. This is what I'm doing in my code:</p>
<pre><code>class Commen... | <p>This should work with the latest version (trunk) of django:</p>
<pre><code>comment = forms.CharField(label="", help_text="", widget=forms.Textarea())
</code></pre>
<p>Hope that helps!</p>
|
how to handle change event in jquery? <p>What could be wrong with below function? Theres a <P> tag in error and it gets filled when error occurs, the error is thus shown for a sec and then disappers.</p>
<pre><code>$('#error').hide();
$('#error').find('p').change(function(){
if($(this).contents().length > 0){
$... | <p>AFAIK, the change event works only for the input elements, it wouldn't fire for your paragraph element. </p>
<p><strong>EDIT:</strong>
If your problem is that the paragraphs become invisible again, then there must be some other code which does that. Check for setInternal or setTimeout method calls in your code. </p... |
Including Objective C++ Type in C++ Class Definition <p>I've got a project that is primarily in C++, but I'm trying to link in a Objective-C++ library. I have a header that looks something like:</p>
<p>CPlus.h:</p>
<pre><code>#import "OBJCObject.h"
class CPlus {
OBJCObject *someObj;
};
</code></pre>
<p>CPlus.mm:... | <p>Are you <code>#import</code>ing CPlus.h from an Objective-C (.m) file? If so, it will not understand the C++ class since it is being compiled with C semantics, and is not Objective-C++ aware. The .m compiler will see <code>class</code> and not know what to do.</p>
<p>You can include Objective-C objects in C++ class... |
Nested routing <p>How do I write a route that maps a path like this?</p>
<p>/powerusers/bob/article-title</p>
<p>This is what I got so far:</p>
<pre><code>map.resources :users, :as => "powerusers" do |users|
users.resources :articles, :as => ''
end
</code></pre>
<p>This gives me the following route:</p>
<p... | <p>Ok, if you don't want the intermediate nested resource (/articles) I wouldn't use the map.resources at all.</p>
<p>Try:</p>
<pre><code>map.connect '/powerusers/:user_id/:article_title', :controller => 'articles', :action => 'view_by_title'
</code></pre>
|
Implementing a custom Python authentication handler <p>The answer to a <a href="http://stackoverflow.com/questions/1080179/handling-authentication-and-proxy-servers-with-httplib2">previous question</a> showed that Nexus implement a <a href="http://svn.sonatype.org/nexus/tags/nexus-1.3.4/nexus-clients/nexus-rest-client-... | <p>If, as described, name and description are the only differences between this "NxBasic" and good old "Basic", then you could essentially copy-paste-edit some code from urllib2.py (which unfortunately doesn't expose the scheme name as easily overridable in itself), as follows (see <a href="http://svn.python.org/view/p... |
Holding onto object references <p>Given the below setup and code snippets, what reasons can you come up with for using one over the other? I have a couple arguments using either of them, but I am curious about what others think.</p>
<p>Setup</p>
<pre><code>public class Foo
{
public void Bar()
{
}
}
</code... | <p>The first version means you can examine <code>foo</code> in a debugger more easily before calling <code>Bar()</code>.</p>
<p>The first version also means you associate a name with the object (it's actually the name of variable of course, but there's clearly a mental association) which can be useful at times:</p>
<... |
Would "endless scroll" work with things that are editable? <p>I'm working on this application that's sort of like a blog. I'm thinking about doing a thing where the user can scroll through all their posts using an "endless scroll" functionality like Google Reader has.</p>
<p>Here's the problem I'm anticipating... if t... | <p>Beware: I find 'endless scroll' annoying. It messes up the scroll-thumb as an indicator of position, with surprise changes and pauses. At some point it will become unwieldy -- the 'hundreds of posts' scenario you mention -- unless there's even more complexity (discarding items off the top when you're deep, offering ... |
Linked List: Is this solution good? <p>I was looking for a way to avoid starting from the head of the list each time I want to find a node, so I thought of assigning indexes to nodes, keeping a pointer to a random (not exactly random; see below) node and then finding the pointer that's closest to the index I want to fi... | <p>It sounds to me like you're trying to invent <a href="http://en.wikipedia.org/wiki/Skip%5Flist" rel="nofollow">Skip Lists</a>, which is a sort of balanced, sorted tree. </p>
<p>Probably what you really want is to use something like boost::multi_index, which will allow you to use a combination of indices to get goo... |
NSSortDescriptor for comparing CLLocation objects in Cocoa/iPhone <p>I have an array of CLLocation objects and I'd like to be able to compare them to get distance from a starting CLLocation object. The math is straight forward but I'm curious if there is a convenience sort descriptor to go about doing this? Should I av... | <p>You can write a simple compareToLocation: category for CLLocation that returns either NSOrderedAscending, NSOrderedDescending, or NSOrderedSame depending on the distances between self and the other CLLocation object. Then simply do something like this:</p>
<pre><code>NSArray * mySortedDistances = [myDistancesArray... |
Why is this a floating point exception? <p>Today I was tracking down a floating point exception in some code I had just written. It took a little while to find because it was actually caused by taking an integer mod zero. Obviously doing anything mod zero is not going to be defined but I thought it was strange that the... | <p>The operation triggers <a href="http://en.wikipedia.org/wiki/SIGFPE">SIGFPE</a>:</p>
<blockquote>
<p>SIG is a common prefix for signal
names; FPE is an acronym for
floating-point exception. Although
SIGFPE does not necessarily involve
floating-point arithmetic, there is no
way to change its name without... |
jqmodal and nyromodal will not work w/ Jquery 1.3.2 and Firefox toolbar extension <p>I've been trying to create my own firefox toolbar with commands that will open and close a modal dialog using either jqModal or nyroModal. In both cases the act of opening the dialog causes errors and I can't find anything out there as... | <p>Looks like the only way to handle this is through the Toolbar Panel object instead of modal windows.</p>
|
How do you do something after you render the view? (Django) <p>I want to do something after I have rendered the view using </p>
<pre><code>return render_to_response()
</code></pre>
<p>Are signals the only way to do this? Do I need to write a custom signal or does request_finished give me enough information? Basically... | <p>You spawn a separate thread and have it do the action.</p>
<pre><code>t = threading.Thread(target=do_my_action, args=[my_argument])
# We want the program to wait on this thread before shutting down.
t.setDaemon(False)
t.start()
</code></pre>
<p>This will cause 'do_my_action(my_argument)' to be executed in a second... |
Table layout problem - Firefox versus Chrome and IE7 <p>I'm trying to layout an HTML table (it's tabular data) and it is rendering differently in Firefox 3.5 and Chrome 2.0.172 (EDIT and IE7 - which renders the table like Chrome does).</p>
<p>I have the table inside a div:</p>
<pre><code><div id="listcontainer">... | <p>I don't know about chrome, but I believe that IE7 requires an explicit "width: auto;" on elements for it to properly handle "min-width". This does not appear to be documented on msdn, however it seems to come up on google.</p>
<p><a href="http://blog.throbs.net/2006/11/17/IE7+And+MinWidth+.aspx" rel="nofollow">http... |
Audio recording error kAudioQueueErr_CannotStart on iPhone OS 3.0 <p>I'm working on a couple different iphone apps that both record and play sounds concurrently. Think multitrack mixing... play one sound a save it then listen to that sound while recording the next sound to another file. My mechanism for this has been... | <p>It's kind of a cliche answer, but did you use the audio session API to set your audio category to "play and record"? You have to do this in order to reserve the microphone for your app's use. There were a bunch of changes to audio session in 3.0 (to create the obj-c convenience class AVAudioSession, and to define ... |
Is it ok to use GET urls in confirmation or verification emails for user accounts? <p>I read that some webmail services prefetch url links in emails. The GET request would then trigger my server to verify the account, regardless of whether the user did anything. </p>
<p>Is this true and if so, how can I work around ... | <p>Never heard of a webmail service who'd pre-fetch GET links with query parameters -- that could turn out to be costly in many ways, after all. I think you'll be fine with the one-click solution you're thinking of!</p>
|
Datacontext and Nhibernate Session <p>I am a newbie to Object Oriented Programming. I am working with Windows Application and Model View Presenter Pattern and I want to have the Change tracking available. My question is as follows</p>
<p>Do I need the presenter to hold a Nhibernate Session or Linq to Sql Datacontext f... | <p>Yes. The best approach I've found for Windows Form projects using NHibernate is to use the ISession as a unit-of-work. Therefore the scope and lifetime of the ISession is the same as your UOW. You may want to consider if your form has multiple UOWs or multiple transactions within a single UOW.</p>
<p>See also: <a h... |
Optimizing Oracle CONNECT BY when used with WHERE clause <p>Oracle <code>START WITH ... CONNECT BY</code> clause is applied <strong>before</strong> applying <code>WHERE</code> condition in the same query. Thus, WHERE constraints won't help optimize <code>CONNECT BY</code>. </p>
<p>For example, the following query will... | <p>Query A says start with managers in the Sales department and then get all their employees. Oracle doesn't "know" that <strong>all</strong> the employees returned be the query will be in the Sales department, so it can't use that information to reduce the set of data to work with before performing the CONNECT BY. </... |
How to set WPF window's startup ClientSize? <p>I want to set my WPF window's initial <em>client</em> size. I'm not seeing a straightforward way to do this.</p>
<p>Specifically, when my window opens, I want it to be sized just big enough for its contents to fit without needing scrollbars. But after it's shown, I want t... | <p>You can do it in code-behind on the Load event handler in one of two ways:</p>
<p>NOTE: The content of the LayoutRoot Grid is the same in both examples, but the Width and Height on the LayoutRoot are only specified in example A.</p>
<p>A) ClearValue on the the Window's SizeToContent and on the content's Width and ... |
How to ease the transition from WinForms to WPF <p>I'm working on a large Winforms application dealing with large amounts of data exposed through grids. I see us eventually moving completely to an M-V-VM & WPF implementation but now we're still closer to a ball-of-mud than anything resembling loose coupling.</p>
<... | <p>Recommending you to install Prism, and have a look at the samples.</p>
<p><a href="http://www.codeplex.com/CompositeWPF" rel="nofollow">http://www.codeplex.com/CompositeWPF</a></p>
<p>I suggest you to go ahead with a complete WPF approach. Few suggestions if you've a winforms background, when you come to WPF</p>
... |
Cannot use Html.ActionLink in asp.net mvc spark files <p>I'm using the spark view engine with my asp.net mvc application.
In my aspx pages, I can succesfully use Html.Actionlink, but when I attempt it in spark files, it doesnt show up in intellisense, and when i try to run it anyway, i get:</p>
<p>Dynamic view compila... | <p>(Copied from Rei Roldán's answer in <a href="http://groups.google.com/group/spark-dev/browse%5Fthread/thread/5276b265a3880aeb">Spark discussion group</a>)</p>
<p>This is where the helpers live.</p>
<pre><code><use namespace="System.Web.Mvc.Html" />
</code></pre>
|
Disable Account due to Login 3 times failed <p>Recently i read an article is about prevent brute-force attack. It said that automatically disabling user accounts is a poor security mechanism to fight a dictionary attack. In the first place, If an attacker can disable an account by incorrectly guessing its password thre... | <p>A few ideas:</p>
<ol>
<li><p>You can keep a history of the IP address(es) that have historically been used to login to a given account. The lockout mechanism can be helpful, but be a little more lenient on those recognized addresses to avoid making a user's bad day worse.</p></li>
<li><p>For the other situation wit... |
play audiofile <p>i done a code for playing a .wav through my appln.now i want to play a mp3 file through
can anyone help to come around that.
herer i have .net framework 1.1 only</p>
| <p>if you have .NET framework 1.1. only, probably your best approach is to use a P/Invoke wrapper for mciSendCommand</p>
<pre><code>[DllImport("winmm.dll")]
private static extern long mciSendString(
string strCommand, StringBuilder returnString,
int returnBufferLength, IntPtr callback);
void PlayFile... |
PYTHON: Update MULTIPLE COLUMNS with python variables <p>I'm trying to write a valid mysql statement that would allow me to update multiple columns in one record with values provided as python variables.</p>
<p>My statement would look like this:</p>
<pre><code>db = MySQLdb.connect(host="localhost", user="user", passw... | <p>You are using string formatting, while what you SHOULD be doing is using a parametrized query. Do it like this:</p>
<pre><code>cursor.execute("UPDATE table_name SET field1=%s ... field10=%s WHERE id=%s", (var1,... var10, id))
</code></pre>
<p>Did you really need to post it with 10 variables? It was so frustrating ... |
Handling COR dump issue with purify <p><br>
I an instrumenting a C++application using IBM purify and I get the issue COR dump and my program aborts although when run from terminal it runs fine. Can anyone tell me what is this COR dump and how to handle with it?<br>
Platform: <code>RHEL 64bit</code></p>
<p>Thanx,</p>
| <p>If the software you are using is licensed, please contact IBM.</p>
|
Reading data from an open HTTP stream <p>I am trying to use the .NET WebRequest/WebResponse classes to access the Twitter streaming API here <code>"http://stream.twitter.com/spritzer.json"</code>.</p>
<p>I need to be able to open the connection and read data incrementally from the open connection.</p>
<p>Currently, w... | <p>I ended up using a TcpClient, which works fine. Would still be interested to know if this is possible with WebRequest/WebResponse though. Here is my code in case anybody is interested:</p>
<pre><code>using (TcpClient client = new TcpClient())
{
string requestString = "GET /spritzer.json HTTP/1.1\r\n";
requestStrin... |
Is there a token for capture line breaks in multiline regex? <p>I've run into this problems several times before when trying to do some html scraping with php and the preg* functions.</p>
<p>Most of the time I've to capture structures like that:</p>
<pre><code><!-- comment -->
<tag1>lorem ipsum</tag>... | <p>I think you could replace the <code>\n\n</code> with <code>(\r?\n){2}</code> this way you capture the <code>CRLF</code> pair instead of just the <code>LF</code> char.</p>
|
Best practices for writing open source Java <p>Where can I find some best practices for writing open source Java code?
I'm not looking for directions on how to write the code proper, but rather on distribution, packaging, documentation, and all the other aspects besides .java files.</p>
<p>My goal is to take a module ... | <p>I'm not sure if there will be universal agreement on "best practices", but the items you mention might have easy answers:</p>
<ol>
<li>Distribution is easy with java.net or Sourceforge. You'll publish your code using their standards,</li>
<li>Packaging will be ZIP files. It's a good idea to create an MD5 hash to ... |
How to access system time finer than 1 second on the iPhone <p>The system time function time(0) gives me a resolution of 1 second, right?</p>
<p>Is there a finer-grained function?</p>
<p><strong>I'm using it to determine the time interval between two events.</strong></p>
<p>A line of code would help me greatly. It m... | <p>See <a href="http://developer.apple.com/documentation/CoreFoundation/Reference/CFTimeUtils/index.html">CFAbsoluteTimeGetCurrent</a>:</p>
<pre><code>CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
// do something you want to measure
CFAbsoluteTime end = CFAbsoluteTimeGetCurrent();
NSLog(@"operation took %2.5f sec... |
Linking to an external URL in Javadoc? <p>Something like:</p>
<pre><code>/**
* See {@linktourl http://google.com}
*/
</code></pre>
| <p>This creates a "See Also" heading containing the link, i.e.:</p>
<pre><code>/**
* @see <a href="http://google.com">http://google.com</a>
*/
</code></pre>
<p>will render as:</p>
<blockquote>
<p><strong>See Also:</strong><br/>
<a hr... |
How do I remove a MySQL database? <p>You may notice from my last question that a problem caused some more problems, <em><a href="http://stackoverflow.com/questions/1081399">Reading MySQL manuals in MySQL monitor?</a></em></p>
<p>My database is now unusable partly due to my interest to break things and my inability to ... | <p>From the MySQL prompt:</p>
<pre><code>mysql> drop database <db_name>;
</code></pre>
|
MS Access 2003 - Simple value input into a text box from clicking label boxes <p>Ok so could anyone please help me out with the VB for auto entering information into a text box, by clicking certian label boxes on a form in access 2003.</p>
<p>I built this thing using label boxes as "sort of links" instead of button fo... | <p>I would recommend using a transparent button instead of a label. </p>
<p>The main reason is that you can set the mouse cursor to become a small hand when you hover over the button, so it gives back information to the user that this can be clicked.<br />
With a label, the user cannot make the difference between a n... |
Css position in ie7 <p>I have a file uploading site and my template works fine in every browser except ie7</p>
<p>the google ads are not showing correctly in ie7, i tried applying css properties <strong>display: block</strong> and also tried with <strong>inline</strong>, specified <strong>width</strong> and <strong>he... | <p>Set your doctype to fixed and it should sort it out.</p>
<pre><code><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
</code></pre>
|
Is it better to keep libraries in the application lib or in common/lib? <p>I'm doing some Spring development and I'm trying to decide if libraries should always be kept in the application lib, even if they end up being common to more than one app. Doesn't Tomcat startup slowdown if a bunch of jar files end up in the co... | <p>Unless there is very good reason to make them common, then keep individual copies for each application.</p>
<p>You may run into VERY nasty classloader problems if you make them common.</p>
|
Populating a DropDownlist From a Strongly Typed List <p>I"m populating a <code>DropDownList</code> from a strongly typed list, and that is working fine. The issue is I want to concatenate two of the fields within the list first and then put them in the dropdown. i.e., FirstName + LastName. I've tried a few things that... | <p>Try using an enumeration of an anonymous object created on the fly.</p>
<pre><code>var _CustomerList = customers.Select( c => new {
Name = c.FirstName + " " + c.LastName,
Key = c.CustomerKey
});
... |
What JEditorPane event should I create a listener for? <p>Suppose I have a JEditorPane in a JPanel. I want to be able to execute a callback each time the user enters/pastes text in the JEditorPane component. What type of listener should I create?</p>
| <p>You can use a DocumentListener to be notified of any changes to the Document.</p>
<p>Since I can't yet leave comments, I would just like to say that it is better to use listeners when possible than it is to override a class, like the example given above that overrides the PlainDocument.</p>
<p>The listener approac... |
jQuery Image Slideshow: captions not transparent in IE <p>I have created a slideshow of images using jQuery. The images fade between each other. There are captions for each image, each inside its own div. As the image is faded in the related caption slides up. The caption is meant to be transparent and this works in al... | <p>IE doesn't implement the filter CSS property. You will need to use something like filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0); for transparency in IE. Alternatively you can use a PNG background image and use JS to apply transparency. Lots of options out there.</p>
|
What order should I use GzipOutputStream and BufferedOutputStream <p>Can anyone recommend whether I should do something like:</p>
<pre><code>os = new GzipOutputStream(new BufferedOutputStream(...));
</code></pre>
<p>or</p>
<pre><code>os = new BufferedOutputStream(new GzipOutputStream(...));
</code></pre>
<p>Which i... | <blockquote>
<p>What order should I use <code>GzipOutputStream</code> and <code>BufferedOutputStream</code></p>
</blockquote>
<p>For object streams, I found that wrapping the buffered stream around the gzip stream for both input and output was almost always <em>significantly</em> faster. The smaller the objects, th... |
How to create a constant static array of strings in c#? <p>I'd like to offer a list of constants within my DLL.</p>
<p>Example usage:</p>
<pre><code>MyDLL.AddHouse( HouseName, MyDll.HOUSETYPES.Big)
MyDLL.AddHouse( HouseName, MyDll.HOUSETYPES.Small)
</code></pre>
<p>Tried:</p>
<pre><code>public static readonly strin... | <p>Try using an enumeration. In C# this is the best option.</p>
<p>As the enumerations are strongly typed, instead of having an API that takes a string, your api will take a value of the type of your enumeration.</p>
<pre><code>public enum HouseTypes
{
Big,
Small
}
MyDll.Function(HouseTypes Option)
{
}
</code>... |
Sending progress message from Server to Client using Ajax <p>I am using UpdatePanel to trigger a button click event, which saves some 100+ files on a designated folder.
I want the server to update the client about the status and count of files being saved.</p>
<pre><code>protected void btnSave_Click(...){
var fi... | <p>It's not that easy... You can't actively send something from the server to the client. Only the client can make a request to query the status.</p>
<p>Now you already have a request running (the click on the button). But that will only finish once the 100 files have been saved. In theory, you could send a small bit ... |
DOM when not an actual document <p>Ok, lets say I go to <a href="http://www.google.com/intl/en_ALL/images/logo.gif" rel="nofollow">http://www.google.com/intl/en_ALL/images/logo.gif</a> , which is not really a document, but an image, iin my browser. Does it still have a document object? Can I use <code>javascript:</co... | <p>A quick look with Firebug reveals that yes indeed, there is a DOM and a document object. For example, <code>javascript:alert(document.title)</code> in the location bar gives "logo.gif (GIF Image, 276x110 pixels)". This results from the construction of the following document by the browser:</p>
<pre><code><html&g... |
Native code execution by JVM/CLR <p>How does JVM/CLR execute JIT compiled native code? Is it by some code injection or by copying code to executable memory? What are the system calls that allows dynamic code execution?</p>
| <p>I can explain how we do it in <a href="http://cacaojvm.org/" rel="nofollow">CACAO VM</a> (a research JIT-only JVM). First, the machine code for a method is generated into some heap-allocated memory block. After compilation, the final code length is known, and a chunk of executable memory is allocated using <code>mma... |
How to build jars from IntelliJ properly? <p>I have a project that contains a single module, and some dependencies.
I'd like to create a jar, in a separate directory, that contains the compiled module. In addition, I'd like to have the dependencies present beside my module.</p>
<p>No matter how I twist IntelliJ's "bui... | <p>Here's how to build a jar with IntelliJ 10 <a href="http://blogs.jetbrains.com/idea/2010/08/quickly-create-jar-artifact/">http://blogs.jetbrains.com/idea/2010/08/quickly-create-jar-artifact/</a></p>
<p>File -> Project Structure -> Project Settings -> Artifacts -> Jar -> From modules with dependencies...</p>
<p>Ext... |
How to create temporary file (0x100) to accelerate application <p>I have seen that Windows system use temporary files to increase the performance of some tasks. Those files are marked with the 0x100 attribute when i look at them. I have got the following text from Microsoft: "</p>
<blockquote>
<p>By using CreateFile... | <p>Well, how about using the CreateFile() method?</p>
<pre><code>var
FileName : PChar;
hMyFile : THandle;
...
hMyFile := CreateFile(FileName,
GENERIC_WRITE,
0,
nil,
CREATE_ALWAYS,
FILE_ATTRIBUTE_TEMPORAR... |
Algorithms for Updating Relational Data <p>What algorithms are known to perform the task of updating a database by inserting, updating, and deleting rows in the presence of database constraints?</p>
<p>More specifically, say that before images of rows to be deleted, after images of rows to be inserted, and both images... | <p>Why are you even trying to do this? The correct way to do it is to get the database engine to defer the checking of the constraints until the transaction is committed.</p>
<p>The problem that you pose is intractable in the general case. If you consider just a transitive closure of the foreign keys in the rows you w... |
String substring function <p>How can i get the string within a parenthesis with a custom function?</p>
<p>e.x. the string "GREECE (+30)" should return "+30" only</p>
| <p>There are some different ways.</p>
<p>Plain string methods:</p>
<pre><code>Dim left As Integer = str.IndexOf('(')
Dim right As Integer= str.IndexOf(')')
Dim content As String = str.Substring(left + 1, right - left - 1)
</code></pre>
<p>Regular expression:</p>
<pre><code>Dim content As String = Regex.Match(str, "... |
In very simple gtk2 c app, problem setting up gnu build tools <p><strong>UPDATE:</strong> First problem solved, second one described at the bottom of this post.</p>
<p><strong>UPDATE2:</strong> Second problem solved as well.</p>
<p>I'm trying to learn about setting up GNU build tools (autoconf/automake) for a very si... | <p>Two issues in your <code>configure.ac</code> file. First, the syntax of your <code>AM_INIT_AUTOMAKE</code> invocation is 10 year old, I suspect you copied it from a very old tutorial (hint: the Automake manual has a <a href="http://sources.redhat.com/automake/automake.html#Autotools-Introduction" rel="nofollow">tut... |
How to configure Felix OBR repositories list? <p>Is there any way to specify a number of OBR repositories in Felix's <code>config.properties</code> file? I do can add a repository at runtime, but I have to do it after restart.</p>
<p>"Prefrences Service" does not help, it seems "Bundle Repository" does not use it.</p>... | <p>conf/config.properties</p>
<p>obr.repository.url=(space delimited list of urls)</p>
|
Intranet system <p>This isn't exactly code-related, but you guys know the best!</p>
<p>What's the best intranet/project management system?</p>
<p>I'm thinking about using Expression Engine to manage my own custom one.</p>
<p><em>Edit</em></p>
<p>PHP platform.</p>
<p>I need to set up projects, colaborate with partn... | <p>I would try checking out the ones over at opensourcecms.</p>
<p><a href="http://php.opensourcecms.com/scripts/show.php?catid=4&cat=Groupware" rel="nofollow">http://php.opensourcecms.com/scripts/show.php?catid=4&cat=Groupware</a></p>
<p>See if that doesn't help you with your decision.</p>
|
Should I use mb_* or iconv_* functions for multibyte strings? <p>As we all now, handling multibyte strings is not that easy in PHP. For example I want to get the length of the following string: <code>ä</code></p>
<pre><code>strlen('ä'); // 2, because ä equals 2 bytes
mb_strlen('ä', 'UTF-8'); // 1
iconv_strlen('ä'... | <p>Have a look at this Powerpoint presentation:</p>
<p><a href="http://www.nyphp.org/content/presentations/smallworld/April2006-nyphp-Presentation.ppt" rel="nofollow">http://www.nyphp.org/content/presentations/smallworld/April2006-nyphp-Presentation.ppt</a></p>
<p>In a nutshell:
Iconv supports more encodings, but is... |
Database Results in Cocoa <p>I am creating an application that has to interact with server data and then display the results from a database accordingly. I am writing the client side app in Cocoa.</p>
<p>Example: A user logs on to a web application. They have some options for filing a web report. Choices: single li... | <p>I'm not sure I understand what you're asking for. Isn't it pretty trivial to figure out how many NSTextFields the user wants and then have a little for() loop to create them? You'll probably want to keep track of the textfields, so I would probably do it like this:</p>
<pre><code>NSMutableDictionary * interfaceEl... |
Java Reflection: Create an implementing class <pre><code>Class someInterface = Class.fromName("some.package.SomeInterface");
</code></pre>
<p>How do I now create a new class that implements <code>someInterface</code>?</p>
<p>I need to create a new class, and pass it to a function that needs a <code>SomeInterface</cod... | <p>Easily, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Proxy.html"><code>java.lang.reflect.Proxy</code></a> to the rescue!</p>
<p><strong>Full working example</strong>:</p>
<pre><code>interface IRobot {
String Name();
String Name(String title);
void Talk();
void Talk(String... |
How to Display Total number of Orders on a Certain Day in MySQL <p>I would like to know how to display orders placed on a certain day.</p>
<p>For example:</p>
<p>I would like to display orders placed today.</p>
<p>My MySQL database contains the following tables: </p>
<p>1) orders<br>
2) orders_statuses</p>
<p>Und... | <p>Assuming you have a foreign key in <code>ORDERS_STATUSES</code> called <code>ORDERS_ID</code>:</p>
<pre><code>select o.orders_id
, o.orders_placed_date
from orders o
inner join orders_statuses os
os.orders_id = o.orders_id
and
os.status_id = 3
where date(o.orders_placed_date) = cu... |
What are the Java equivalents to Linq and Entity Framework <p>Having played with Linq (to SQL and Objects) as well as the Entity Framework from Microsoft recently, I was wondering what the non-.Net (specifically Java) equivalents are?</p>
| <p>Consider using Querydsl : <a href="http://www.querydsl.com" rel="nofollow">http://www.querydsl.com</a></p>
<p>It supports JPA/Hibernate, JDO, SQL and Collections.</p>
<p>Querydsl is fully type-safe, supports autocomplete in IDEs and provides a common querying syntax on top multiple backends.</p>
<p>I am the maint... |
How do I execute a command contained within a variable in PHP? <p>Currently, I'm passing a command into a user-defined function in PHP. How do I have PHP execute this when I ask it to?</p>
| <p>You'll want to either use <a href="http://us2.php.net/manual/en/function.eval.php" rel="nofollow"><code>eva</code>l</a> or <a href="http://nz.php.net/manual/en/function.call-user-func.php" rel="nofollow"><code>call_user_func</code></a>, depending on whether it's a set of expressions or simply a function call.</p>
|
Static initializer in Objective-C upon Class Loading <p>I am trying to build something to dynamically instantiate an object from class-name similar to how Java's Class.forName method works, e.g.</p>
<pre><code>Class klass = Class.forName("MyClass");
Object obj = klass.instantiate(...
</code></pre>
<p>I didn't see any... | <p>You want to use NSClassFromString, like this:</p>
<pre><code>Class klass = NSClassFromString(@"MyClass");
id obj = [[klass alloc] init];
</code></pre>
|
How would you adblock using Python? <p>I'm slowly building a <a href="http://github.com/regomodo/qtBrowser/tree/master" rel="nofollow">web browser</a> in PyQt4 and like the speed i'm getting out of it. However, I want to combine easylist.txt with it. I believe adblock uses this to block http requests by the browser.</p... | <p>I know this is an old question, but I thought I'd try giving an answer for anyone who happens to stumble upon it. You could create a subclass of QNetworkAccessManager and combine it with <a href="https://github.com/atereshkin/abpy" rel="nofollow">https://github.com/atereshkin/abpy</a>. Something kind of like this:</... |
Help with designing a schema for a lyrics database <p>I'd like to work on a project, but it's a little odd. I want to create a site that shows lyrics and their translations, but they are shown simultaneously side-by-side (so this isn't just a normal i18n of the site).</p>
<p>I have normalized the tables like this (for... | <p>Just a note. I'm not really sure that 7 tables is that big a join. I seem to remember that Postgres has a special query optimiser (based on a genetic algorithm, no less) that only kicks in once you join 12 tables or more.</p>
|
Running JSON through Python's eval()? <p>Best practices aside, is there a compelling reason <strong>not</strong> to do this?</p>
<p>I'm writing a post-commit hook for use with a Google Code project, which provides commit data via a JSON object. GC provides an HMAC authentication token along with the request (outside ... | <p>If you're comfortable with your script working fine for a while, and then randomly failing on some obscure edge case, I would go with eval.</p>
<p>If it's important that your code be robust, I would take the time to add simplejson. You don't need the C portion for speedups, so it really shouldn't be hard to dump a ... |
Problem with "this.function" and Scope in my code <p>Hey I have this code right here:
<a href="http://pastie.org/534470" rel="nofollow">http://pastie.org/534470</a></p>
<p>And on line 109 I get an error saying "TypeError: Result of expression 'this.allVarsDefined' [undefined] is not a function."</p>
<p>Scope in javas... | <p>This looks prototype-based. You probably need to set up your notification callback like this:</p>
<pre><code>setTimeout(this.notify.bind(this), 5000, track);
</code></pre>
<p>so that the notify function is bound to the Scrobbler object and gets <code>this</code> set to the Scrobbler object instead of the event tr... |
Non-Windows RAD Web development <p>I have spent most of my web-development career in the Microsoft camp, but for different reasons I am trying to look at options. </p>
<p>Some years back I did a bit of Java/Struts development in eclipse, which was nice for its time but my memories of it are not close to what Visual St... | <p>We have a pretty heavy investment in the Microsoft framework at the office and so I'm mostly doing ASP.NET MVC stuff now. If I were to pick an alternative at this point, I'd probably go with RubyOnRails. It has a very clean MVC implementation -- playing around with it made it pretty easy to get started with ASP.NE... |
SQL Server - standard pattern for doing row by row operations on a table/view <p>I want to iterate through a table/view and then kick off some process (e.g. run a job, send an email) based on some criteria. </p>
<p>My arbitrary constraint here is that I want to do this inside the database itself, using T-SQL on a sto... | <p>Your best bet is a cursor. SQL being declarative and set based, any 'workaround you may find that tries to force SQL to do imperative row oriented operations is unreliable and may break. Eg. the optimizer may cut out your 'operation' from the execution, or do it in strange order or for an unexpected number of times.... |
Scheduled execution of code to conduct database operations in SQL Server <p>If I want to conduct some database operations on a scheduled basis, I could:</p>
<ul>
<li><p>Use SQL Server Agent (if SQL Server) to periodically call the stored procedure and/or execute the T-SQL</p></li>
<li><p>Run some external process (sch... | <p>Another possibility is to have a queue of tasks somewhere, and when applications that otherwise use the database perform some operation, they also do some tasks out of the queue. Wikipedia does something like this with its job queue. The scheduling isn't as certain as with the other methods, but you can e.g. put off... |
Multi-variable complicated singletons <p>I have a pair of static fields with a complicated one-time initialization. I want this initialization to happen lazily, <em>a la</em> the standard <a href="http://www.yoda.arachsys.com/csharp/singleton.html" rel="nofollow">singleton pattern</a>.</p>
<p>However, the initializat... | <p>Create a wrapper class that contains the references to both your 'singletons' and make that class the singleton?</p>
<p><strong>Addendum:</strong><br />
If you really want to avoid the second level of indirection with this approach, you can always do it in two stages:</p>
<ul>
<li>create a new singleton that encap... |
.htaccess conditional rewrite <p>I'm trying to create an conditional Rewrite Rule using an .htaccess file and Apache.</p>
<p>Basically what I need is that the Apache would check if the requested file exists in a sub folder, case in which Apache would serve this existing file, or, if the file does not exist, Apache wou... | <p>Try these rules:</p>
<pre><code>RewriteCond %{REQUEST_URI} ^/(([^/]+/)*)gallery/
RewriteCond %{DOCUMENT_ROOT}%1gallery/cache/$0 -f
RewriteRule ^.+ cache/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.* index.php/$0 [L]
</code></pre>
<p>The first rule checks if the requested path is a path to an existing... |
How to make iPhone app look right when user is on a phone call or Internet tethering? <p>The status bar has grown, so parts of my interface get cut off. Any pointers on how to fix this (e.g. using autoresize masks, etc.)?</p>
<p>I use Interface Builder for the UI, so everything is .xib's.</p>
| <p>You generally handle it with autoresize masks, or if you have custom views you can deal with it in the layoutSubviews method.</p>
<p>The simulator has an option "Toggle In-Call Status" you can use for testing it out without having to load it on the phone calling yourself.</p>
|
how to implement strlen() in c#? <p>I was thinking to a solution to calculate length of string in c# without using <code>Length</code> property. </p>
<p>I thing which I can think of is getting this done is </p>
<p>Program is in C# </p>
<pre><code>public static int strlen (string s)
{
string temp = s + '... | <p>The issue is the way strings are stored in C#. While in some languages it takes computation to figure out how long a string is, in C#, the <em>only</em> way to figure out the length of a string is through its Length property. If you thing about how strings are stored, there is an array of character, and a Length. ... |
How resource intensive are Listeners in java? <p>I'm new to Java Programming but an experienced C++ programmer. I was learning how to program GUIs using swing. I was wondering how resource intensive (runtime as well as memory) are ActionListeners? Is there a general guideline to the total number of listeners that one... | <p>CPU usage: close to none. Listeners are only called when the state of the object they listen to is changed. They don't really "listen". The object to which they are listening calls them when needed. (Note: this is a simplification)</p>
<p>Memory usage: Mostly an ActionListener has no state. So the total enduring me... |
Unable to inject smalldatetime into D-SQL statement <p>when i try to execute this sql statement i am getting the error.. Conversion failed when converting character string to smalldatetime data type.</p>
<p>Does anyone know what i am doing wrong?</p>
<pre><code>declare @modality varchar(50)
declare @datefrom smalldat... | <p>You are trying to concatenate the smalldatetime with a varchar.
Change </p>
<p><strong>Solution 1</strong></p>
<pre><code>declare @datefrom smalldatetime
</code></pre>
<p>to</p>
<pre><code>declare @datefrom varchar(8)
</code></pre>
<p>and</p>
<pre><code>select @var1 = 'select sum('+ @modality +') as ' + dbo.fn... |
DI object graph building - separating logic and construction graph <p>Sorry if this is a really basic question but it's been really getting to me. I really like the idea of DI, it really helps me with my testing but I have hit a bit of a brick wall I think. So I have two types:</p>
<pre><code> Table
TableManager
</c... | <p>One option is to configure a <code>TableFactory</code> which <em>does</em> know the query provider and reader, and only needs to know the table name. You can then pass the factory to the <code>TableManager</code>. On the other hand, a <code>TableManager</code> sounds like it probably needs to be the factory itself -... |
How to attach source code of libraries downloaded with ivy <p>I use ivy with the ivy eclipse plugin to download dependencies. Works great. But how can I attach the source code for those libraries, in order to step into these libraries?</p>
| <p>Have you tried attaching the source configurations?</p>
<pre><code><dependencies defaultconfmapping="*->default,sources">
</code></pre>
|
Jquery, Links <p>I need to select with jQuery <code><a href=""></code> , but only 'href' with extentions '.JPG' or '.jpg'</p>
<p>for example :</p>
<p>to find only this 'links'</p>
<pre><code><a target="_blank" href="images/test.jpg" class="highslide ">
<img src="images/test.jpg" alt='img'/>
<... | <pre><code>$("a[href$=.jpg], a[href$=.JPG]")...
</code></pre>
|
Exceptions and Abstractions <p>When should you throw a custom exception?</p>
<p>e.g. I have some code that connects to a server. The code that connects to the server throws an IOException when it fails to connect. In the context of the method it's called, this is fine. It's also fine in the network code.</p>
<p>But a... | <p>I would expect exceptions to talk in terms of what I've asked the originating method to do. e.g.</p>
<pre><code>read -> ReadException
connect -> ConnectException
buildPortfolio -> FailedToBuildPortfolioException
</code></pre>
<p>etc. This abstracts away what's going on under the covers (i.e. are you conne... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.