input
stringlengths
51
42.3k
output
stringlengths
18
55k
Setting Midlet Icon using J2ME-Polish <p>I'm using J2ME Polish version 2.0.7 together with ant to build my Midlet application. In order to specifcy the main-class, name and icon of the application, the J2ME Polish <a href="http://www.j2mepolish.org/cms/leftsection/documentation/building/build.xml/build-section.html#mid...
<p>No it must be in the info section of the j2mepolish target:</p> <pre><code>&lt;project ...&gt; &lt;target name="j2mepolish" ...&gt; &lt;j2mepolish&gt; &lt;info ... icon="xxx.png"&gt; </code></pre>
How can I determine if a date is between two dates in Java? <p>How can I check if a date is between two other dates, in the case where all three dates are represented by instances of <code>java.util.Date</code>?</p>
<p>This might be a bit more readable:</p> <pre><code>Date min, max; // assume these are set to something Date d; // the date in question return d.after(min) &amp;&amp; d.before(max); </code></pre>
How to dynamically add a style for text-align using jQuery <p>I'm trying to correct the usual IE bugs around CSS 2.1 and need a way to alter an elements style properties to add a custom text-align style.</p> <p>Currently in jQuery you can do something like</p> <pre><code>$(this).width( or $(this).height( </code></pre...
<p>You have the right idea, as documentation shows:</p> <p><a href="http://docs.jquery.com/CSS/css#namevalue">http://docs.jquery.com/CSS/css#namevalue</a></p> <p>Are you sure you're correctly identify this with class or id? </p> <p>For example, if your class is myElementClass</p> <pre><code>$('.myElementClass').cs...
Is there a hook to monitor activity on a bluetooth serial port <p>Is there any way of monitoring activity over a bluetooth connection either using a software hook or an external bluetooth monitor, where the bluetooth is emulating a RS232 serial port.</p> <p>When I'm using a cabled connection, I could use an in-line da...
<p>Sysinternals's Portmon can monitor serial ports, see <a href="http://technet.microsoft.com/en-us/sysinternals/bb896644.aspx" rel="nofollow">http://technet.microsoft.com/en-us/sysinternals/bb896644.aspx</a> Presumably it can monitor Bluetooth virtual serial ports...</p>
Isolating triggers from WPF THemes <p>HI,</p> <p>I am using the WPF themes libary which is relaesed in Codeplex.com. All works fine. The theme used is applied. But there is a problem when I need to create a style for a button control(With triggers especially) and associate it with a button. What happens is the theme d...
<p>This problem was "beaten to death" <a href="http://stackoverflow.com/questions/16096/how-to-apply-multiple-styles-in-wpf">here</a>.</p>
Integrating swf in c++ <p>Is there any way of making c++ gui applications that include .swf?</p> <p>The swf file are pretty small and easier to make than gif or other kind of animations so it would be nice to be able to include them.</p> <p>Some recommendations of a library, free or even open source...</p>
<p>You can host the Flash player itself in your app. You just have to implement the webbrowser side of the plugin architecture you choose. You have two choices, Netscape style plugins and ActiveX. If you only want to run on Windows, hosting it as an ActiveX control is very straightforward. If you want to run cross ...
Problems with DeploymentItem attribute <p>I'm currently maintaining an "old" system written in C#.net, removing some obsolete features and doing some refactoring. Thanks god, the previous guy wrote some unit tests (MSTests). I quite comfortable with JUnit tests, but didn't do yet much with MSTests.</p> <p>The test met...
<p><code>DeploymentItem</code> is a bit of a mess. </p> <p>Each file in your solution will have a "Copy To Output Folder" setting in VS.NET. You need this to be "Copy Always" (or similar) in order to get the files into the output folder.</p> <p>Check that you've got this set for the new files. If you don't have this ...
Subsonic 3 T4 Templates - Output half of a View to a UserControl <p>I am using the Subsonic MVC Template and in the List.tt template it loops through all the properties and puts them into an HTML table. </p> <p>I would like that table written to a usercontrol but after a few hours I cannot get it to work properly. <...
<p>I have done it so don't worry about it...</p>
Python Multiprocessing atexit Error "Error in atexit._run_exitfuncs" <p>I am trying to run a simple multiple processes application in Python. The main thread spawns 1 to N processes and waits until they all done processing. The processes each run an infinite loop, so they can potentially run forever without some user i...
<p>Rather then just forcing <code>sys.exit()</code>, you want to send a signal to your threads to tell them to stop. Look into using <a href="http://docs.python.org/library/signal.html" rel="nofollow">signal handlers</a> and threads in Python.</p> <p>You could potentially do this by changing your <code>while True:</c...
.net framework 4.0 documentation <p>Is the actual API documentation for .net 4.0 already live on MSDN?</p> <p>I read a blog post from someone in the vs2010 team saying that, but I've not been able to find it.</p>
<p>Yes. The beta documentation is available.</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/w0x726c2%28VS.100%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/w0x726c2(VS.100).aspx</a></li> </ul>
geo location and blocking access to my app on iPhone <p>I am working on a radio player for iPhone. What I need is to provide my position before playing stream. I am thinking of using CoreLocation, it's ok, but how to determine geo position if user does not allow CoreLocation when asked ?</p> <p>What would be the best ...
<p>I would just use core location. If for whatever reason the user declines the core location popup, then just prompt them to enter their location manually (e.g. choose country and city).</p> <p>You could use the IP address, but then you run into other problems as well (for instance if they are using WiFi on their iP...
Loading UINavigationController from another nib automatically by UITabBarController <p>I think I've found the cause: Document Info window in IB has a warning: <em>"'Selected Navigation Controller (Second)' has nib name property set to 'SecondView.nib', but this view controller is not intended to have its view set in th...
<p>I haven't tried setting up UINavigationController via IB. I have multiple screens, each is stored in separate xib and there's a corresponding class that extends UIViewController. In applicationDidFinishLaunching I initialize UIViewControllers using xib's but then manually create UINavigationController, add navigatio...
Regex for finding date in Apache access log <p>I'm writing a python script to extract data out of our 2GB Apache access log. Here's one line from the log.</p> <pre><code>81.52.143.15 - - [01/Apr/2008:00:07:20 -0600] "GET /robots.txt HTTP/1.1" 200 29 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1) VoilaBot...
<p>match() looks for a match at the beginning of the string. Use search() to look for a match anywhere in the string. More info here: <a href="http://docs.python.org/library/re.html#matching-vs-searching" rel="nofollow">http://docs.python.org/library/re.html#matching-vs-searching</a></p>
jQuery UI Tabs with $(document).ready equivalent <p>I'm trying to use jQuery UI tabs much like a Master Page in ASP.Net. I have specific javascript that needs to run once each tab is loaded. I've tried to have a $(document).ready function in each page, but I've read that's bad practice and only seems to work in IE.</...
<p><code>$(document).ready()</code> is not bad practice, and it works in every browser that jQuery works in. If your events are only firing in IE, you've got a bug somewhere in your own code.</p> <p>I have dozens of ready functions in my applications and no problems.</p>
externalinterface - calling javascript from SWF <p>HI,</p> <p>im trying to call a javascript function from my actionscript code but its not working;</p> <p>as3:</p> <pre><code>if (ExternalInterface.available) { try { ExternalInterface.addCallback("changeDocumentTitle",null); } catch(error:Error) </cod...
<p>If you are trying to invoke a JS function from within your Flex app, you want to use ExternalInterface.call(...) and not ExternalInterface.addCallback(...). From the docs:</p> <blockquote> <p>public static function call(functionName:String, ... arguments):*</p> <p>Calls a function exposed by the Flash Playe...
Security Reinforcement: How to collect visitors' IP addresses in Grails Framework? <p>How to make a logging list of Users' IP addresses, should this be done via tomcat or grails or a combination of both</p>
<pre><code>ServletRequest.getRemoteAddr() </code></pre>
How to identify that a Windows Mobile 2005 device has connected to the cradle? <p>How to identify that Terminal (Windows Mobile 2005 ) connect to cradle ?</p> <p>I need to identical in the Terminal</p> <p>thank's in advance</p>
<p>If you need to do it from the device:</p> <pre><code>static public bool IsConnectedToCradle { get { return SystemState.CradlePresent; } } </code></pre> <p>PS: FWIW, in Windows Mobile terminology, the 'terminal' is usually called the 'device'.</p>
WPF Border DesiredHeight <p>The following <a href="http://msdn.microsoft.com/en-us/library/ms753296.aspx#example">Microsoft example code</a> contains the following:</p> <pre><code>&lt;Grid&gt; ... &lt;Border Name="Content" ... &gt; ... &lt;/Border&gt; &lt;/Grid&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigge...
<p>You can see that property in the code part of your application</p> <p>Edit:</p> <pre><code>Border content = new Border(); int desiredHeight = content.DesiredSize.Height; int desiredWidth = content.DesiredSize.Width; </code></pre> <p>To solve the problem try binding it to the Height attribute, since DesiredHeight ...
Why does my asp.net membership login page not work with a redirect? <p>I have this membership site setup on my local machine using the ASP.NET membership provider. When I go to:</p> <p><a href="http://localhost/admin/" rel="nofollow">http://localhost/admin/</a></p> <p>It redirects me to </p> <p><a href="http://loca...
<p>Can you show us some code? If you are using <code>FormsAuthentication.RedirectFromLoginPage</code> method, you should get what you want. Are you using <code>FormsAuthentication.SetAuthCookie</code> instead?</p> <h3>Update</h3> <p>Change <code>path="/Admin"</code> in <code>web.config</code> to <code>path=/</code></...
Ignoring PHP error, while still printing a custom error message <p>So:</p> <pre><code>@fopen($file); </code></pre> <p>Ignores any errors and continues</p> <pre><code>fopen($file) or die("Unable to retrieve file"); </code></pre> <p>Ignores error, kills program and prints a custom message</p> <p>Is there an easy way...
<p>Typically:</p> <pre><code>if (!($fp = @fopen($file))) echo "Unable to retrieve file"; </code></pre> <p>or using your way (which discards file handle):</p> <pre><code>@fopen($file) or printf("Unable to retrieve file"); </code></pre>
Calling Snarl from java code <p>Does anyone know how to call <a href="http://www.fullphat.net/index.php" rel="nofollow">snarl</a> api from java code?</p> <p>Thanks</p>
<p>I have successfully called snarl with <a href="http://code.google.com/p/jweatherwatch/wiki/SnarlNetworkBridge" rel="nofollow">http://code.google.com/p/jweatherwatch/wiki/SnarlNetworkBridge</a>, indicated in the official <a href="https://sites.google.com/site/snarlapp/developers/developer-guide" rel="nofollow">https:...
Best way to sanitise POST/GET variables from a form/URL? <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/60174/best-way-to-stop-sql-injection-in-php">Best way to stop SQL Injection in PHP</a> </p> </blockquote> <p>I am creating a website using PHP that makes ...
<p>Might be worth reading <a href="http://stackoverflow.com/questions/60174/best-way-to-stop-sql-injection-in-php">this post</a>.</p>
How do you model custom attributes of entities? <p>Let's say we're having an application which should be able to store all kind of products. Each product has at least an <code>ID</code> and a <code>Name</code> but all other attributes can be defined by the user himself.</p> <ol> <li>E.g. He could create a productgroup...
<p>I'd recommend either the <a href="http://martinfowler.com/eaaCatalog/concreteTableInheritance.html" rel="nofollow">Concrete Table Inheritance</a> or the <a href="http://martinfowler.com/eaaCatalog/classTableInheritance.html" rel="nofollow">Class Table Inheritance</a> designs. Both designs satisfy all four of your c...
Recursively parsing XML in Actionscript 2 <p>I'm looking for an efficient and reusable way to parse xml into an object in actionscript2. The xml structure itself might change so it's important that im able to parse the xml with out 'hard coding' specific nodes, etc.</p> <p>I normally use As3 and wouldn't need somethin...
<p>i did not fully understand your pseudo code ... what happens to the Array <code>values</code>? seems to be simply discarded ... also, it seems not to be recursive ...</p> <p>the problem is, that the semantics of XML and ECMA-objects is different ...</p> <p>what would you map this to?</p> <pre><code>&lt;cart&gt;&l...
JavaScript to add HTML tags around content <p>I was wondering if it is possible to use JavaScript to add a &lt;div&gt; tag around a word in an HTML page.</p> <p>I have a JS search that searches a set of HTML files and returns a list of files that contain the keyword. I'd like to be able to dynamically add a &lt;div cl...
<p>In general you will need to parse the html code in order to ensure that you are only highlighting keywords and not invisible text or code (such as alt text attributes for images or actual markup). <a href="http://stackoverflow.com/questions/884140/javascript-to-add-html-tags-around-content/884282#884282">If you do ...
Showing a hidden process on Windows? <p>I got a bit of a problem.</p> <p>Related to my earlier questions about <a href="http://serverfault.com/questions/9943/sp3-installed-vs-sp3-slipstreamed-difference-in-default-security-settings">Slipstreamed SP3 vs. patched SP3</a>, we've come to the conclusion that there is an In...
<p>I do not believe there is any way to force an IE window which does not have a window handle to allocate a window handle for itself (or use a previously allocated one) and display itself.</p> <p>As to your backup method: I <em>think</em> this would work, but you're working in dangerous territory there. I'd actually...
How can I watch the user.config file and reload the settings when it changes? <p>I have a situation where I am running multiple instances of my WPF application. I want the instances to share the same user.config file. Currently, whichever instance writes to the user.config file last wins. I'd prefer for all the inst...
<p>I found it. The following code will return the path to the user.config file. You need to add a reference to System.Configuration.dll</p> <pre><code>Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal); string path = config.FilePath; </code></pre> <p>Now ...
WPF resources in an assembly <p>Is there to browse the WPF resources in a WPF assembly in .NET with Lutz's reflector?</p>
<p>There is a BAML addin for Reflector. <a href="http://reflectoraddins.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=1805#DownloadId=9088" rel="nofollow">http://reflectoraddins.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=1805#DownloadId=9088</a></p>
Message forwarding in Smalltalk <p>So I'm writing an application where one object has a bunch of delegate objects that it forwards messages to. The idea is that I can say</p> <pre><code>someObject sendMessage:aMessage </code></pre> <p>and aMessage will be sent to all of someObject's delegates (for any value of aMessa...
<p>Since you want to pass objects in as arguments, you'll have to pass them in as a separate list of using a message pattern like the following:</p> <blockquote> <p>someObject sendMessage: aSelector withArguments: argumentList</p> </blockquote> <p>Then you'd implement #sendMessage:withArguments: as:</p> <blockquot...
How to return a function value with decorator and thread <p>have this code</p> <pre><code>import threading def Thread(f): def decorator(*args,**kargs): print(args) thread = threading.Thread(target=f, args=args) thread.start() thread.join() decorator.__name__ = f.__name__ re...
<p>The reason <code>None</code> is returned, is because there is nothing to return (besides the fact that <code>decorator</code> doesn't have a return statement). <code>join()</code> always returns <code>None</code>, as per the <a href="http://docs.python.org/3.0/library/threading.html#threading.Thread.join" rel="nofol...
Documentation on Apple Mail's .emlx data structure(s) (for conversion purposes)? <p>This appears to be a rare gem: where to find documentation on the structure of Apple Mail's .emlx files (and their partial variants, and the meaning of the directory structures). The docs do not appear to exist on Apple's site, nor can...
<p>Here is an emlx2mbox converter in ruby: <a href="http://vengefulcow.com/emlx2mbox/" rel="nofollow">Mailbox Converter</a>.</p> <p>I don't think it was written from any documentation of the spec, but it has undergone multiple updates, so hopefully evolved to handle at least some of the quirks of the format. The sour...
How to post a Google Calendar in a web page without using <iframe>? <p>Google Calendar provides a way to insert your Google Calendar into a web page using an &lt;iframe>. Is there a way to insert this data into a web page without having to use the &lt;iframe>?</p> <p>I know that there are ways to do this using the Goo...
<p>Actually you can just make it an object and it will validate. For the Google calendar in particular, all you have to do is change "iframe" to "object" (don't for get to change the iframe break too), change "src" to "data", and remove the frameborder and scrolling tags and all is good. The only drawback is that obj...
Sifr browser issues <p>www.johncowle.co.uk/</p> <p>I have employed Sifr on my site index. It works fine in Safari but nothing appears in Firefox.</p> <p>Why?</p>
<p>I would recommend you look at cufon (google it) if you want cross-browser based font replacement that doesn't require users to have flash</p>
How to spawn parallel child processes on a multi-processor system? <p>I have a Python script that I want to use as a controller to another Python script. I have a server with 64 processors, so want to spawn up to 64 child processes of this second Python script. The child script is called:</p> <pre><code>$ python creat...
<p>What you are looking for is the <a href="http://docs.python.org/library/multiprocessing.html#module-multiprocessing.pool">process pool</a> class in multiprocessing.</p> <pre><code>import multiprocessing import subprocess def work(cmd): return subprocess.call(cmd, shell=False) if __name__ == '__main__': co...
how to create google sitemap for mvc site? <p>I was wondering if anyone has done this yet or has any examples on how to create a Google Sitemap for an MVC website.</p> <p>Any help or example would be appreciated.</p> <p>Im talking about this: https://www.google.com/webmasters/tools/docs/en/protocol.html</p>
<p>I used <a href="http://www.mikesdotnetting.com/Article/111/RSS-Feeds-and-Google-Sitemaps-for-ASP.NET-MVC-with-LINQ-To-XML">Mike Brind's Sitemap code</a>, with a small change. </p> <p>You need to add the XNamespace to every XElement, otherwise Google spits the dummy.</p> <p>Here's my version:</p> <pre><code>public...
Indexed view in Sql Server 2005 Error <p>I tried to add an index on a view in Sql Server 2005 an I got this error: "Cannot create index on view 'AllAssignmentNotes' because the view is not schema bound."</p> <p>I didn't want to put too much information here as it might be overload. Just wondering if anyone could give ...
<p>Just as the error says, you can't have an index on a view that isn't schema bound. To schemabind the view use </p> <pre><code>create view with schemabinding. </code></pre> <p>all tables referenced int the view must be fully quallified with the schemaname, i.e. dbo.table, not just table</p>
Setting up ehcache replication - what multicast settings do I need? <p>I am trying to set up ehcache replication as documented here: <a href="http://ehcache.sourceforge.net/EhcacheUserGuide.html#id.s22.2">http://ehcache.sourceforge.net/EhcacheUserGuide.html#id.s22.2</a><br /> This is on a Windows machine but will ultim...
<blockquote> <p>I want to test it locally so am running two separate tomcat instances with the above config.</p> </blockquote> <p>As I have just submitted an answer regarding cherouvims <a href="http://stackoverflow.com/questions/1313410/ehcache-auto-discovery-via-multicast-between-2-instances-on-the-same-host">...
OnClientClick and Calling Custom JavaScript Function <p>I am using the following code to call a javascript function but the OnClientClick expression is never evaluated. </p> <pre><code>&lt;asp:Button ID="btn1" UseSubmitBehavior="false" OnClientClick='moveComment(txtComment_&lt;%# Eval("Container.DataItemIndex") %&gt;...
<p>Here is the answer: </p> <pre><code>&lt;asp:Button ID="btn1" UseSubmitBehavior="false" OnClientClick='&lt;%# GetId(Container.DataItemIndex.ToString()) %&gt;' runat="server" Text="add comment"/&gt; </code></pre> <p>And GetId method on the server side: </p> <p>protected string GetId(string index) { ...
Visual Studio Add-in QueryStatus() calls <p>I wonder if anyone can tell me why does <code>QueryStatus()</code> method get called so many times when command is being evaluated for execution? In my case it gets called several times (at least 9) with at least one <code>vsCommandStatusTextWantedName</code> and many more <c...
<p>The one Exec() part is easy: that only gets called when a command is actually invoked. QueryStatus() will get called at different times to update UI elements like menu items, toolbar buttons. Since status can be different depending on state like: is text selected, is a project open, is a file open, etc, it needs t...
Why is the MemoryStream data not released from memory <p>Is there something that needs to be done with the following code to release the memory it uses?</p> <pre><code> Dim objImage As MemoryStream Dim objwebClient As WebClient Dim sURL As String = Trim(m_StationInterface.PicLocation) objwebClient = New WebCli...
<p><a href="http://msdn.microsoft.com/en-us/library/system.drawing.image%5Fmethods.aspx" rel="nofollow">Image</a> implements IDisposable, so you should Dispose the old image before replacing it with a new one.</p> <p>Something like (bear with me, I haven't used VB in a while):</p> <pre><code>Dim objImage As MemoryStr...
mysqlimport and double-quotes <p>We have a large tab-delimited text file (approximately 120,000 records, 50MB) that we're trying to shove into MySQL using mysqlimport. Some fields are enclosed in double-quotes, some not. We're using the <code>fields-optionally-enclosed-by='\"'</code> switch, but the problem is some o...
<p>You could import it with the quotes (fields-optionally-enclosed-by switch removed) and then run a check where if the value has double quotes at the beginning and end (assuming none of the values have inches at the beginning) then truncate by 1 character from the beginning and end to remove the extra quotes you got f...
ActiveMerchant/Spree - Is there a per-transaction/per-account commission to the creators? <p>This is probably a silly question but if you use ActiveMerchant (or spree), do the creators of ActiveMerchant (or spree) take a commission? Since it's open source I wouldn't expect them to. But at the same time, because it's su...
<p>They don't take a commission.</p>
What is the specifications for Motion JPEG? <p>I've been googling like mad and can't find any file format specifications for mjpeg. </p> <p>What should the header look like? Do i just append a series of jpegs after the header? </p> <p>I know it's the usually in the .avi container, does that have a standardized forma...
<p>Apparently there is no single specifiaction. From <a href="http://en.wikipedia.org/wiki/Motion%5FJPEG">wikipedia</a>:</p> <blockquote> <p>Criticisms</p> <p>Unlike the video formats specified in international standards such as MPEG-2 and the format specified in the JPEG still-picture coding standard, th...
Can System.Web.MVC.UpdateModel update EF Navigation Properties? <p>If I have 2 tables in my database: <em>Foo</em> and <em>bar</em>. <strong>Foo</strong> is identified by <em>FooId</em> and <strong>Bar</strong> is identifier by <em>BarId</em>. A <em>Bar</em> can have 0 to many <em>Foos</em> therefore Foo has <em>BarId<...
<p>No, the default model binder isn't going to be able to do this. You would be hard-pressed to write a custom model binder to do it, also. The HTML SELECT element will only store an ID value in the description, not enough to materialize most entity instances. So we just have to do with the fact that we will be getting...
How to synchronize lifetime of forms authentication cookie and Asp.Net Session? <p>I am building an ASP.NET web site that uses <code>FormsAuthentication</code> and a standard Session mechanism with configuration like:</p> <pre><code>&lt;authentication mode="Forms"&gt; &lt;forms cookieless="UseCookies" name=".MyApp...
<p>I've heard this question many times, my answer is usually "why would you want this?". One does not require the other and their expiration times should be determined using different criteria.</p> <p>Session state does not require a user to be logged in. An app doesn't even need to use authentication to use session s...
We treat interfaces and implementations like we treat content and styling, so why not handle it similarly? <p>I've used Spring, and I've looked into Guice, and I think that these are both rather obtrusive extensions to languages. I firmly believe that programming languages themselves need to adapt to patterns more cohe...
<p>This is a very old idea, first implemented in the early 1980s. Then it was known by the terms "configuration programming", "software integrated circuits" or "architecture description languages". "Dependency Injection" is a neologism coined when enterprise developers recently rediscovered the ideas.</p> <p>For exa...
Fermat's Little Theorem <p>How do you compute the following using <a href="http://en.wikipedia.org/wiki/Fermat%27s_little_theorem" rel="nofollow">Fermat's Little Theorem</a>?</p> <pre><code>2^1,000,006 mod 101 2^-1,000,005 mod 11 </code></pre>
<p>You know that a^(p-1) === 1 mod p, so...</p> <p>2^10 === 1 mod 11<br /> 2^(-1,000,005) = 2^(-1,000,000)*2^(-5) = 1 * 2^(-5) = 2^(-5)*2^(10) = 32 mod 11 = -1 = 10</p> <p>From this, can you see how to work the larger number? The process is the same.</p> <p>It's FLT all the way. I messed up.</p>
In bash, how can I print the first n elements of a list? <p>In <code>bash</code>, how can I print the first <code>n</code> elements of a list?</p> <p>For example, the first 10 files in this list:</p> <pre><code>FILES=$(ls) </code></pre> <p><strong>UPDATE:</strong> I forgot to say that I want to print the elements on...
<pre><code>FILES=(*) echo "${FILES[@]:0:10}" </code></pre> <p>Should work correctly even if there are spaces in filenames.</p> <p><code>FILES=$(ls)</code> creates a string variable. <code>FILES=(*)</code> creates an array. See this page for more <a href="http://mywiki.wooledge.org/BashGuide/Arrays">examples on using ...
Delphi text offsets in edits and memos <p>I have noticed that in Delphi 2009, the text in a multi-line memo has different padding on the left from that in a single-line edit, though both are based on TCustomEdit. The exact offset depends on the font size:</p> <p><img src="http://img188.imageshack.us/img188/7668/editm...
<p>There is <a href="http://msdn.microsoft.com/en-us/library/bb761590%28VS.85%29.aspx" rel="nofollow">EM_GETMARGINS</a>. I'm not sure if that counts as "simple". :-)</p> <p>EDIT: Try this:</p> <pre><code>type tSynMargins = record left, right: Word; end; function GetLeftMargin(hEdit: HWND): Word; var margin...
C# winforms: Is my separation of GUI and logic done correctly? <p><strong>Edit</strong></p> <p>Based on suggestions below to send the logic code GUI delegates, I came up with code like this:</p> <pre><code>Action ClearFunction = new Action(()=&gt;Invoke(new Action(delegate() { ResultsBox.Clear(); } ) )); </code></pre...
<p>I wouldn't have a circular reference between the form and searchCore. why don't you make the search logic talk back to form through a callback? that way the search doesn't need to know about the form and is easier to test.</p>
Map technologies for the web (such as Google Maps) <p>Ok so basically I am talking with someone about building a way for users to post locations to a map and have a pin over the location.</p> <p>I know Google Maps can do this and probably has the best documentation/support. I was just wondering if/what other options ...
<p>So to answer your question. I <a href="http://www.cannonade.net/map.php" rel="nofollow">use</a> the Google Maps API.</p> <p>Why?</p> <p>I think there are a whole lot of good reasons that make Google Maps an extremely valuable mapping solution for web developers. I realise I will probably sound like a hand waving...
SFTP task for msbuild? <p><br/> <br/> <br/> Does anyone know of an SFTP task for msbuild? We'd like to automate our deployments to production, but for security reasons we don't allow SMB file-share access from our dev/test/build environment to production.</p> <p>Right now, developers deploy code by manually uploading ...
<p>Could install WinSCP and just use the MsBuild <a href="http://msdn.microsoft.com/en-us/library/x8zx72cd.aspx">Exec Task</a></p> <p>I used something like the following to upload an ISO file to a server after a build.</p> <pre><code>winscp.exe sftp://root:password;@192.168.0.200:22/uploaddir/ "c:\myfile.iso" </code>...
Narrowing problem with Spring MVC annotation-based controller and @RequestMapping <p>Consider this Spring MVC Controller:</p> <pre><code>@Controller @RequestMapping("/test*") public class TestController { @RequestMapping(method = RequestMethod.GET) public void doStuff(Model model){ ... } @RequestMapping(...
<p>This smells like a bug. If you add method=GET to the second handler, it works as expected, so that's the workaround.</p> <p>I've filed a bug report on this, hopefully it'll be addressed.</p> <p><a href="http://jira.springframework.org/browse/SPR-5772">http://jira.springframework.org/browse/SPR-5772</a></p>
How to Integrate LinqToSql with Metadata Annotations <p>I'm just getting started on a new MVC project, and like a good boy I am trying to defer going to the DB for as long as possible. Here's the scoop:</p> <ol> <li>I'm planning on using the ComponentModel.DataAnnotations decorations.</li> <li>I'm also planning on usi...
<p>Brad Wilson wrote a great blog post about using DataAnnotations and unit testing them; <a href="http://bradwilson.typepad.com/blog/2009/04/index.html" rel="nofollow">http://bradwilson.typepad.com/blog/2009/04/index.html</a></p> <p>The gist of the testing strategy is this:</p> <ol> <li>Write a test to check to make...
How to ignore hostname in SSH tunnel <p>Here is a trivia question for any ssh/ssl experts. In our corporate office we have a JMS app (Tibco EMS) running on a server behind a firewall which blocks most ports.</p> <p>I can ssh into this server but can not send messages to the JMS app because the port isn't open. So usin...
<p>I'm pretty sure that name does not come from the certificate. As far as I understand Tibco, you should have a daemon process <code>rvd</code> or <code>rvrd</code> (or some sort of an agent process) somewhere - either on the server, or on both client and the server. Look for configuration files for these. The chances...
Why is swallowing InterruptedException ok for subclasses of Thread? <p>In Brian Goetz's <a href="http://www.ibm.com/developerworks/java/library/j-jtp05236.html" rel="nofollow">article on how to handle InterruptedException</a>, one paragraph stands out:</p> <blockquote> <p>The one time it's acceptable to swallow an i...
<p>Basically. The concern expressed in the article is that if you swallow the interupt exception then calling code higher in the stack won't know about the interuption, possibly causing undesirable behavior. If you start the thread, then you know there is nothing higher in the call stack that cares about being interupt...
C# Regular Expression to match letters, numbers and underscore <p>I am trying to create a regular expression pattern in C#. The pattern can only allow for:</p> <ul> <li>letters</li> <li>numbers</li> <li>underscores</li> </ul> <p>So far I am having little luck (i'm not good at RegEx). Here is what I have tried thus fa...
<p><strong>EDIT :</strong></p> <pre><code>@"^[a-zA-Z0-9\_]+$" </code></pre> <p>or</p> <pre><code>@"^\w+$" </code></pre>
How Can I Automate Tasks in Xcode? <p>I'm building an app in Obj-C / Xcode and I'm running into some repetitive tasks. For example if I want to add an image resource to my project I just go through the same identical steps... only difference is the path to the resource. </p> <p>How can I automate these tasks?</p> <...
<p>There's definitely no macro recorder, but there are some tools you can use. First, there's Applescript, which is the most likely to be of use for this particular problem. I'm not promising it'll be easy, however. There isn't a rich collection of Applescripts for Xcode that I know of, so you'd need to dig through the...
Mathematica GraphPlot with images <p>I am trying to use <code>GraphPlot</code> function to build a <code>Graph</code>, where each node is an image. I wanted to display the image as my vertex. Does anybody know how to do this?</p> <p>I tried something like this:</p> <pre><code>GraphPlot[ Map[If[# &gt; 2.0 , 0, 1] &am...
<pre><code> imgs = ExampleData /@ ExampleData["TestImage"]; GraphPlot[{1 -&gt; 4, 1 -&gt; 5, 2 -&gt; 3, 2 -&gt; 4, 2 -&gt; 5, 3 -&gt; 4, 3 -&gt; 5}, VertexRenderingFunction -&gt; (Inset[Image[imgs[[#2]], ImageSize -&gt; 100], #1] &amp;)] </code></pre> <p><img src="http://i.stack.imgur.com/nGJ1o.png" alt="enter im...
Linking JavaScript Libraries in User Controls <p>I have been using ASP.NET MVC for six months or so and have been checking out the Nerd Dinner example created by those Microsoft guys. One thing I noticed they did when enabling AJAX to RSVP for a dinner, is put the JavaScript references in the User Control being used f...
<p>I would definitely advise against putting them inside partials for exactly the reason you mention. There is a high chance that one view could pull in two partials that both have references to the same js file. You've also got the performance hit of loading js before loading the rest of the html.</p> <p>I don't know...
What is the type signature of this Haskell function? <p>I wrote a function to check whether a number is prime or not:</p> <pre><code>prime n = prime' n 2 (floor (sqrt n)) where prime' n c u | n `mod` c == 0 = False | c &gt; u = True | otherwise = prime' n (c+1) u </...
<p>The problem is that you use <code>sqrt</code> on <code>n</code>, which forces <code>n</code> to be a floating-point number; and you also use <code>mod</code> on <code>n</code>, which forces n to be an integer. Intuitively, from looking at your code, <code>n</code> <em>should</em> be an integer, so you can't directly...
Creating an index on a table variable <p>Can you create a index on a table variable in SQL Server 2000?</p> <p>i.e. </p> <pre><code>DECLARE @TEMPTABLE TABLE ( [ID] [int] NOT NULL PRIMARY KEY ,[Name] [nvarchar] (255) COLLATE DATABASE_DEFAULT NULL ) </code></pre> <p>Can I create a index on Name?</p>
<p>The question is tagged SQL Server 2000 but for the benefit of people developing on the latest version I'll address that first.</p> <p><strong>SQL Server 2014</strong></p> <p>In addition to the methods of adding constraint based indexes discussed below SQL Server 2014 also allows non unique indexes to be specified ...
How do I make the code in lib/ automatically reload when the file changes? <p>This is a follow up to this <a href="http://stackoverflow.com/questions/285148/where-should-my-non-model-non-controller-code-live">question</a>. During development I have to restart the rails app everytime I change the code in lib/ in order f...
<p>Witold Rugowski's got some great information <a href="http://nhw.pl/wp/2009/01/07/reloading-your-plugin-in-development-mode" rel="nofollow">on this link.</a></p>
activate MCC, MNC API in Nokia Pys60 <p>I can not get location info from pyS60. It seems the featured API is not activated.</p> <p>How can I activate this API? Is there any free licensing system? </p> <p>Or anything so that I can use restricted (or non-free for general developers) APIs at least in my phone to test th...
<p>You need to sign you application. The process depends on the phone and kind of developement model you want to follow.</p> <p>If you just want to test some apps on your phone, use <a href="http://www.symbiansigned.com/app/page/public/openSignedOnline.do" rel="nofollow">Open Signed Online</a>. If you want to test man...
TFS and keyword expansion <p>We've just moved some projects from Microsoft Visual SourceSafe (VSS) to Microsoft Team Foundation Server (TFS) and have now noticed that keyword expansion no longer works.</p> <p>For instance, keywords like <code>$Log$</code> or <code>$Header$</code> are no longer expanded to the correct ...
<p>TFS does not support keyword expansion. See the following post for more information:</p> <ul> <li><a href="http://blogs.msdn.com/buckh/archive/2007/07/07/keyword-expansion-in-tfs.aspx" rel="nofollow">Keyword expansion in TFS</a></li> </ul>
NSIS patching (multiple patches in one file) <p>I'm able to generate patch files from one version to another using NSIS' Vpatch. Let's say I have mydll.dll version 1, and I have a patch to update it to version 2. Then I have a new version again, thus I generate another patch to update it to version 3. </p> <p>What bo...
<p>VPatch is an open source project in itself so you could ask in their forum. The guy wrote it says you can ask him questions. There is a link from his page to the email form: <a href="http://www.tibed.net/vpatch/" rel="nofollow">http://www.tibed.net/vpatch/</a></p>
How might I determine the XPath of a DOM element? <p>In JavaScript, supposing I have a reference to an element, how do I retrieve an XPath expression that would select it?</p> <p>Is there something like <code>objElement.xpath</code>?</p>
<p>Since Annibigi doesn't want to post the solution, I'll do it: See <a href="http://snippets.dzone.com/posts/show/4349" rel="nofollow">this snippet</a>.</p>
HTML input type = file in Adobe AIR does not present file browser <p>So the good old HTML file uploader tag only presents a browse button (without associated text input) when rendered in a HTML based Adobe AIR application. Upon clicking the browse button, nothing seems to happen. I would expect a popup window so I c...
<p>Actually, this does work. I somehow managed to stop this from working, probably through a combination of cloning that part of the DOM elsewhere.</p>
Is log10f() not a part of standard math library? <p>I am having issues with usage of log10f(). I am compiling the program on Linux (2.6.28-11-generic) and using gcc (3.4.6). </p> <p>The following source compiles and prints 1.000000 on execution. </p> <pre><code>#include &lt;stdio.h&gt; #include &lt;math.h&gt; int ma...
<p>That's because the required <strong><code>libm.a</code></strong> library is not linked into the executable automatically.</p> <p>You have to add the <strong><code>-lm</code></strong> parameter to gcc. Then the linker will also link <code>libm.a</code> into your executable. </p>
Block replacement in sed <p>I am trying to replace a block in a file using sed, but with no success.</p> <p>E.g. I want to replace this:</p> <pre><code>for(int i = 0; i &lt; MAX_LOOPS; ++i) { printf("Hello World!"); } </code></pre> <p>With this:</p> <pre><code>int i = 0; while(i &lt; MAX_LOOPS) { printf("He...
<p>The following will do the trick but in a very basic way, i.e. it's not robust nor does it worry with formatting.</p> <p>s/for(int i = 0; i &lt; MAX_LOOPS; ++i)/int i = 0;\nwhile(i &lt; MAX_LOOPS)/g /printf("Hello World!");/{ a++i; }</p> <p>This is just a quick hack but it ought to be enough to get you going....
Blogger help with labels <p>Just wondering whether anyone knows how to get blogger labels into "alt" tags in an image. I have tried <code>alt="data:post.labels"</code> to no available at all ? </p> <p>Doesnt anyone know how to assist with this on blogger?</p> <p>P.S - I know about the ‘rel=tag’ - but for the spec...
<p>Looks like you may be using the XML version of templating Blogger. If that's the case, then you'll need to use something like the below if you want to have the ALT attribute show up with the name of the tag:</p> <pre><code>expr:alt='data:label.name' </code></pre> <p>You can use the same principle to display the la...
prime numbers c# <p>And I would like to program something like, displaying the prime numbers in a listbox if user will input any integer in the textbox. (that means, if they write 10, it will display the prime numbers from 0-10, or 20 from 0-20, etc).</p> <p>What should I consider first, before I do the programming? I...
<p>Well, first of all I'd think about how to find prime numbers, and write that in a console app that reads a line, does the math, and writes the results (purely because that is the simplest thing you can do, and covers the same parsing etc logic you'll need later).</p> <p>When you are happy with the prime number gene...
Creating unordered list in a DIV <p>I have a DIV. I want to dynamically generate a bulleted list inside the DIV using jQuery with a items list I have with me</p> <pre><code>for (cnt = 0; cnt &lt; someList.length; cnt++) { someList[cnt].FirstName + ":" + someList[cnt].LastName + "&lt;br/&gt;" // what to write here?...
<p>Keeping things as simple as possible. Using your existing javascript, You would just need to add this:</p> <pre><code>$('#myDiv').append("&lt;ul id='newList'&gt;&lt;/ul&gt;"); for (cnt = 0; cnt &lt; someList.length; cnt++) { $("#newList").append("&lt;li&gt;"+someList[cnt].FirstName + ":" + someList[cnt].LastName+...
How can I tell if a network cable has been unplugged? <p>I have a C# application that should only be used when the network is down, but am afraid users will just unplug the network cable in order to use it.</p> <p>Is there a way to detect if the network cable has been unplugged?</p> <p>Thanks</p>
<p>In my humble opinion, there is no certain way to distinguish between a network down and an unplugged cable. And even if there is a way, there is also a way to work around it.</p> <p>Let's assume that you have a solution and let's look at some situations:</p> <ul> <li>There is no network traffic, the cable is not u...
What HTML rendering differences exist between other browsers and Firefox? <p>I would like to know about the basic compatibility issues in the major browsers (Internet Explorer, Chrome) when compared to Mozilla Firefox, such as:</p> <ol> <li>Text Alignment</li> <li>Color</li> <li>Font Size</li> <li>Tool Tips</li> <li>P...
<p>This is a really vague question, but I find <a href="http://www.quirksmode.org/" rel="nofollow">Quirks Mode</a> extremely helpful with all aspects of browser compatibility. Also look at <a href="http://www.alistapart.com/" rel="nofollow">A List Apart</a>.</p>
dual screen programming issue <p>I am using VSTS 2008 + C#. Is there any way to get the informaiton like, whether we are currently in dual monitor mode, how much is the current resolution of each desktop?</p> <p>BTW: there are two modes of dual screen, duplicate screen or extended screen. I need a solution as well to ...
<p><a href="http://msdn.microsoft.com/de-de/library/system.windows.forms.screen.allscreens.aspx" rel="nofollow">System.Windows.Forms.Screen.AllScreens</a></p> <blockquote> <p>Gets an array of all displays on the system.</p> </blockquote> <p>The property <a href="http://msdn.microsoft.com/en-us/library/system.wind...
URL rewrite using mod_rewrite in .htaccess <p>I am trying to rewrite the URL using the mod_rewrite apache module. I am trying to use it as below : </p> <pre><code>Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^wants/testing.htm wants.php?wantid=$1 [L] </code></pre> <p>I have created a .htaccess f...
<p>As per OP's comment:</p> <blockquote> <p>The URL shows mydomain.com/wants.php?wantid=123. I need to make it look like mydomain.com/wants/123</p> </blockquote> <p>This should work for your case:</p> <pre><code>RewriteEngine on RewriteBase / RewriteRule ^wants/([0-9]+)$ /wants.php?wantid=$1 [L] </code></pre...
NSURLConnection is run many times <p>I connect asynchronously with server each 5 seconds. The URL is the same, but POST-body is changed each time. Now I create NSURL, NSURLRequest and NSURLConnection from the scratch each time.</p> <p>I think it'd be more effective to set connection once and just use that one further....
<p>I assume what you're concerned about is the overhead of creating the HTTP connection. NSURLConnection is smart enough to handle this for you using HTTP/1.1 and reusing existing connections. It does not use pipelining last time I checked, but for your purpose, connection reuse should be sufficient. I do encourage you...
What are Android application update issues and best practices? <p>I've published an Android applications on the Android market and now have an update to do.</p> <p>I want to know if any of you have already done that, and what experience can you share about it :</p> <ul> <li>How to manage version conflicts ?</li> <li>...
<p>I'll comment only on what I've experienced: Android market will not let you have package version conflicts. It examines the package and if the new version is less than or equal to the old version it will refuse the upload (it did with me).</p> <p>All updates appear as a patch to the user, although I believe they a...
Select datetime prints wrong date <p>When I select some data rows from mssql2005 database and bind them to datagrid, dates selected from db are invalid. For example in db I have date in form: </p> <p>2009-05-10 00:00:00.000</p> <p>but when it is displayed in data grid it looks like this:</p> <p>5/9/2009 10:00:00 PM<...
<p>Looks like a timezone issue to me. Are you selecting the rows directly from the database into your application, or are you possibly retrieving them via a webservice from another machine?</p> <p>As a basic test, try setting your windows timezone +2 hours ahead then see whether the issue still occurs.</p>
iphone application icon was blur when show on the itunes store <p>my icon was blur when show on the itunes Store but fine in iphone's locally appstore,my large icon format is:</p> <p>pixel:512X512 format:png dpi:72</p> <p>can anybody point to me what is the reason of icon getting blur in itunes store since i have fol...
<p><strong>Your 512x512 icon should be a jpeg</strong> though I can't imagine it being uploaded as iTunes Connect rejects other formats.</p> <p>Resubmitting is an option.</p>
ServerSide Sessions safe? <p>I'm using (server side, not cookie) sessions in an application that I writing, if the users has not obtained access to the server can I trust the $_SESSION variable or should I verify it's content on every page load?<br /> <br /> <br /> <strong>Note:</strong><br /> I'm trying to limit the n...
<p>Yes you can store it in the session safely. You should make sure that the Validation method is safe. (the method you use before storing in the session).</p>
db2 referential integrity problem <p>Situation is pretty serious, we have a table in DB2 on AS400 which has defined foreign key to another table, so we are entering record which have regular ID of referenced table so when we enter SQL insert through front end tool everything went fine. </p> <p>Problem arises when this...
<p>Maybe you are inside a transaction and the data you are going to put is inconsistent, and then a rollback is performed, so you should not see anytinh wrong.</p>
C# CF2.0 - System.Activator and Internal classes <p>I've got a data provider that contains a collection of entities. I only want to be able to create a new entity through the data provider.</p> <p>I.e, to create a new record I need to use:</p> <pre><code>Entity entity = Provider.AddNew(); enity.set_Properties... etc ...
<p>Don't use the Activator, which relies on a public constructor. Instead use reflection to find the parameterless constructor and then call it. Something along these lines:</p> <pre><code>Type t = typeof(MyType); var parameterlessCtor = (from c in t.GetConstructors( BindingFlags.Public | BindingFlags.NonPublic | ...
Is it possible to get document of iframe with iframe_id? <p>AFAIK,I can achieve this goal by window.frames['frame_name']</p> <p>but if I only know frame_id,is it possible to get the content too?</p> <p>You can try it out here:</p> <p><a href="http://maishudi.com/rte-light-read-only/index.html" rel="nofollow">http://...
<p>I think this should do it. It works on (the latest) firefox, safari, camino and opera (mac). <br />You should still do some testing though (especially in IE)</p> <pre><code>var iframeObj = document.getElementById("theIframeId"); var documentObj = iframeObj.contentWindow || iframeObj.contentDocument; var location = ...
Maintaining ViewState for FileUpload Control <p>I am creating <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx" rel="nofollow"><code>FileUpload</code></a> controls at run time. When I click a <code>LinkButton</code> a new <code>FileUpload</code> control is generated.</p> <p>N...
<p><strong>Steps</strong> </p> <ol> <li>user selects a file</li> <li>user click LinkButton (issues a postback that adds additional file uploading control)</li> <li>server side should get the file on postback and store it somewhere (anywhere)</li> <li>replace first <code>&lt;input type=file&gt;</code> with something l...
How does your organisation setup testing data? <p>I work as a tester for an organisation that has a web service as it's critical application. Currently we load massive amounts of test data through the web front end, as this is how it would be done in the real world.</p> <p>This gives the data an amount of legitimacy a...
<p>This comes from a developer's perspective rather than a tester's, so it may or may not apply.</p> <p>I can't speak for the organization as a whole, but in our project we have spent some time creating "real-world-like" data that we load into the test database using SQL scripts. This data is a combination of real dat...
What's the most optimal way to get a random floatingpoint number between floatA and floatB? <p>I have an interval consisting of two float numbers, and need to generate 20 random numbers in a look that are somewhere inbetween this interval defined by the two floats.</p> <p>Lets say, for example:</p> <pre><code>float a...
<p>try this</p> <pre><code>float a = 12.49953f; float b = 39.11234f; int startVal = a*10000; int endVal = b*10000; srandom((unsigned)(mach_absolute_time() &amp; 0xFFFFFFFF)); int randomValue = startVal+ (random() % (endVal - startVal)); float r = (float)randomValue / 10000.0f; </code></pre>
Performing an inner join <p>I've trying to do an inner join select statement where I select two fields from a table, and than all the records of a field in a second table that have the same id as the first table.</p> <p>The code looks as follow:</p> <pre><code> Dim conn As OleDbConnection Dim cmd As OleDbComma...
<p>Use <code>[Vegetables Descriptions].[DescID]</code> instead of <code>[Vegetables Descriptions.DescID]</code>. Since "Vegetable Descriptions" contains a space, it has to be the only name within <code>[]</code>.</p>
Can you add parameters inside a print() function in javascript <p>Hi guys i am looking for a way to add parameters on a print function, cause i have to print only the table and when i alert the table it shows me the correct value but when i am printing it prints the entire page.</p> <p>my code is </p> <p><code>aa = d...
<p>Print stylesheets are nice, but you can still accomplish this in Javascript. Just pass your value to be printed to the following function...</p> <pre><code>function printIt(printThis) { var win = window.open(); self.focus(); win.document.open(); win.document.write('&lt;'+'html'+'&gt;&lt;'+'body'+'&gt;'); ...
SQL Server: Extract Table Meta-Data (description, fields and their data types) <p>I am trying to find a way to extract information about my tables in SQL Server (2008).<br /> The data I need needs to include the <strong>description of the table</strong> (filled from the Description property in the Properties Window), a...
<p>To get the description data, you unfortunately have to use sysobjects/syscolumns to get the ids:</p> <pre><code>SELECT u.name + '.' + t.name AS [table], td.value AS [table_desc], c.name AS [column], cd.value AS [column_desc] FROM sysobjects t INNER JOIN sysusers u ON u.uid = t.ui...
iPhone MoviePlayer example, where did the button and label come from <p>I had working with the iPhone example named "MoviePlayer" where it show you how to add an overlay over a MPMoviePlayer.</p> <p>This works great, but I can't find where did they set the button and label? how can I add some controls of my own?</p>
<p>Asked too soon.</p> <p>Yet, if someone needs it: <br/> 1. open the MainWindow.xib with Interface builder (double-click should work) <br/> 2. in the xib window, there is a view named "My overlay view".</p> <p>this is it.</p>
How to stop a service within the OnStart method? <p>I'm writing a windows service in .net 2.0.</p> <p>What should I do within the <code>OnStart()</code> method if for some reason I don't want my service to start? Can I simply call the <code>Stop()</code> method of the base class (<code>ServiceBase</code>)? I've tried ...
<p>Why do you want to do that? If there's an error, log it in event log and throw an exception. Your service won't be started and the user will be informed that something bad happened.</p>
Does dropping a table in MySQL also drop the indexes? <p>It's not explicitly mentioned in the documentation (<a href="http://dev.mysql.com/doc/refman/6.0/en/drop-table.html">http://dev.mysql.com/doc/refman/6.0/en/drop-table.html</a>). I ask because I just saw a curious database migration in a Rails project where the d...
<p>Yes, it does.</p> <p>However, if you have foreign key constraints such as RESTRICT that ensure referential integrity with other tables, you'll want to drop those keys prior to dropping or truncating a table.</p>
How to create Bitmap from System.Window.media.PixelFormats.Gray16 <p>I am successfully drawn images from their raw pixel data.(only 8 bit images). here is the code for doing the same thing.</p> <pre><code> PixelFormat format = PixelFormat.Format8bppIndexed; Bitmap bmp = new Bitmap(Img_Width, Img_Height, forma...
<p>Try this:</p> <pre><code>private static Bitmap changePixelFormat(Bitmap input, PixelFormat format) { Bitmap retval=new Bitmap(input.Width, input.Height, format); retval.SetResolution(input.HorizontalResolution, input.VerticalResolution); Graphics g = Graphics.FromImage(retval); g.DrawImage(input, 0,...
Is there a list of which OpenID Providers use which schema Attributes? <p>I'm using OpenId in my website. Love it. Currently, I'm testing my code with my own openId account, which i have with <a href="https://www.myopenid.com/" rel="nofollow">MyOpenId</a>. Whenever I tried to retrieve any data handed to me from MyOpenI...
<p>IMO, maintaining a list of OPs and their odd behaviors presents a nightmare task and would defeat the purpose of the spec that's supposed to determine behavior. Of course from your perspective you just want the thing to work. :) So here goes...</p> <p>Part of resolving <a href="http://dotnetopenauth.net:8000/tick...
XSLT: Breaking CSV from one source XML node into multiple target XML nodes <p>Thanks to help of fellow SO users that helped me out in <a href="http://stackoverflow.com/questions/886316/">this question</a> I am half way through my XML transformation.</p> <p>The problem that I hit a wall with transforming comma seperate...
<p>I've updated the solution I provided to your other question:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output indent="yes"/&gt; &lt;xsl:template match="/"&gt; &lt;records&gt; &lt;!-- Just process the first field's children, to get ...
Convert Func<T, string>[] into Func<T, string[]>? <p>Consider this class:</p> <pre><code>public class Column&lt;T&gt; { public string Header { get; set; } public Func&lt;T, string&gt; ValueExpression { get; set; } } </code></pre> <p>used like this:</p> <pre><code>var columns = new List&lt;Column&lt;Employee&...
<pre><code>public static Func&lt;T, U[]&gt; Combine&lt;T, U&gt;(this Func&lt;T, U&gt;[] functions) { return t =&gt; functions.Select(fun =&gt; fun(t)).ToArray(); } </code></pre> <p>I'd declare that for generic <code>IEnumerable&lt;Func&lt;T, U&gt;&gt;</code> instead of array:</p> <pre><code>public static Func&lt;...
Single SQL SELECT Returning multiple rows from one table row <p>We have a table which is of the form:</p> <pre><code>ID,Value1,Value2,Value3 1,2,3,4 </code></pre> <p>We need to transform this into.</p> <pre><code>ID,Name,Value 1,'Value1',2 1,'Value2',3 1,'Value3',4 </code></pre> <p>Is there a clever way of doing th...
<p>Give a <code>union</code> a shot.</p> <pre><code>select ID, 'Value1' as Name, Value1 as Value from table_name union all select ID, 'Value2', Value2 as Value from table_name union all select ID, 'Value3', Value3 as Value from table_name order by ID, Name </code></pre> <p>using <code>union all</code> means that the...
ASP.Net Datalist with linked DataSourceId does not reload <p>I have a MultiView control which has a View in which a DataList is filled like this:</p> <pre><code>&lt;asp:DataList ID="DataList6" runat="server" DataSourceID="SqlDataSource11" Width="100%"&gt; &lt;ItemTemplate&gt; &lt;!-- rendering is left out to keep t...
<p>Try <code>DataList6.DataBind</code></p>