input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
Get the SQL that would be executed from a certain method or named_scope <p>Given an ActiveRecord method or <code>named_scope</code> chain, is there a way to return the SQL that will get executed, without actually running it?</p>
<p>e.g.</p>
<pre><code>Vote.positive.count.sql #=> "SELECT COUNT(*) FROM votes WHERE v... | <p>You can get information out of a named scope like so:</p>
<pre><code>Vote.positive.proxy_options
</code></pre>
<p>As for getting the full SQL statement, ActiveRecord puts this together using a protected method called <code>construct_finder_sql</code>.</p>
<p>So you could try this:</p>
<pre><code>Vote.positive.se... |
Error while adding a dropdown in website <p>I am getting the following error while i submit a form after i added a dropdown box in my designer</p>
<p>System.NullReferenceException: Object reference not set to an instance of an object. at WebApplication1._Default.collectEmailBodyText() in C:\v1.5_production_05June09\De... | <p>I would guess the most likely issue there is that form1.FindControl is not finding the control. I would recommend performing the find control first, then checking it's not null before attempting to access any values from it.</p>
|
rails models <p>i have a model named test.rb and when i use @tests=Test.new in my controller i get the following error. Can someone temme how can i resolve this?
"undefined method `new' for Test:Module"</p>
| <p>Looks like test is already the name of a module called Test if would seem that you have naming conflict. Try placing your own model in a module ie</p>
<pre><code>module MyModule
class Test < ActiveRecord::Base
end
end
</code></pre>
<p>and then calling it like so</p>
<pre><code>@test = MyModule::Test.new
... |
Rolling forward the archivelog and online redo logs to the restored database <p>I'm currently using Oracle db11g on Red Hat Enterprise Linux 5.0.
I make an incremental level 0 one time a week and incremental level 1 everyday.
I can restore this backup on my new Linux server without any problems because I have all archi... | <ol>
<li>Restore your backed up files.</li>
<li>Copy your current online redo log files (from the "damaged" production instance) to the new server.</li>
<li>RECOVER DATABASE;</li>
</ol>
<p>This scenario assumes you have total continuity with archived logs and online logs. In doing the recovery, Oracle will apply neces... |
UITableView, having problems changing accessory when selected <p>I'm using a UITableView to allow selection of one (of many) items. Similar to the UI when selecting a ringtone, I want the selected item to be checked, and the others not. I would like to have the cell selected when touched, then animated back to the no... | <p>I solved it like hatfinch suggested in his edit. My code sample make sure there's only one row checked but I'm sure you can tweak it if thats not what you need.</p>
<pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
int newRow = [indexPath row];
int oldRow = [l... |
Windows Mobile/Pocket PC: How do I change the border color of focused/unfocused CEdit, CListCntl, CButton in MFC or Win32 <p>How do I change the border color of focused/unfocused CEdit, CListCntl, CButton in WinCE/Windows Mobile 5/6 with MFC or Win32 API?</p>
| <p>You can achieve such an effect by deriving your own CEdit class and override WM_NCPAINT message, this allows you to paint the non-client area yourself and draw you own border when focus is changed:</p>
<pre><code>void CMyEdit::OnNcPaint()
{
CWindowDC dc(this);
CRect rect;
GetWindowRect(&rect);
... |
.NET MVC - The system cannot find the path specified <p>yesterday I deployed my website from c:\development\project\ to c:\inetpub\wwwroot\virtualdir\ (same pc). It worked for some time, I could reach the website by going to <a href="http://computername/virtualdir/" rel="nofollow">http://computername/virtualdir/</a>.</... | <p>It's finding a System.Web.Mvc just fine, as you can see in the stacktrace:</p>
<pre><code>System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +128
</code></pre>
<p>What it appears is happening is the ControllerTypeCache, while attempting to enumerate all the assmeblies that are referenced in orde... |
HTTP Post headers, received differently from what's being sent <p>HI I'm tring to send some headers in my PHP script such as </p>
<pre><code>$headers[] = "BATCH_TYPE: XML_SINGLE";
$headers[] = "VENDOR_ID: 56309";
</code></pre>
<p>But they are being received as:</p>
<p>Batch-Type
Vendor-ID</p>
<p>..not as they were... | <p>How are you checking these headers ? I've just tried myself with the following code:-</p>
<pre><code><?php
header("BATCH_TYPE: XML_SINGLE");
</code></pre>
<p>And got back the following:-</p>
<pre><code>HTTP/1.1 200 OK
Date: Wed, 10 Jun 2009 08:56:54 GMT
Server: Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.1 with... |
Maillog file in linux <p>I accidently delelte /var/log/maillog, after I recreate it, but postfix wouldn't write any mail log into it anymore, I restart postfix, no help, anyone know why?</p>
| <p>maillog is usually managed by syslog, not postfix directly.</p>
<p>Restarting syslog should be enough, as to permissions just ensure they're similar to other files in /var/log and that should be enough.</p>
<p>On my debian system all logs are owned either root:adm or root:root, are usually mode 644 or 640 (u+rw, g... |
adding html with jquery <p>is there a neat way to add html with jQuery instead of </p>
<pre><code>$("#elm").html($("#elm").html() + "some text");
</code></pre>
<p>It'd be great to just do <code>$("#elm").html(+= "some text")</code> or something similar...</p>
| <pre><code>$('#elm').append('some text');
</code></pre>
<p><a href="http://docs.jquery.com/Manipulation/append" rel="nofollow">http://docs.jquery.com/Manipulation/append</a> for more information on using append</p>
|
WPF Binding: Where a property contains the path to the value <p>I've got an expander with a couple of TextBlocks in the top bar which i'm using to give a title and a piece of key information.</p>
<p>Ideally i want to set the path to key piece of information, but i can't work out how to bind the path of the binding to ... | <p>I don't think it can be done in pure XAML... Path is not a DependencyProperty (and anyway Binding is not a DependencyObject), so it can't be the target of a binding</p>
<p>You could modify the binding in code-behind instead</p>
|
Lucene: How to do wildcard search inside a Term? <p>I've the following lucene index:</p>
<pre><code>Document A
item = level:(1)
item = level:(2)
item = level:(3)
Document B
item = level:(1)
item = level:(4)
</code></pre>
<p>Suppose I want to search for all documents which contain level:(1) AND level:(2) ?</p>
<p>Th... | <p>The simplest solution would be to make <code>level</code> your query parser's default field, allowing your query to be reduced to:</p>
<pre><code>(1 OR 2)
</code></pre>
<p>However, I suspect that this isn't exactly what you're looking for...</p>
<p>According to the <a href="http://lucene.apache.org/java/2%5F3%5F2... |
ActiveX cannot create object vb6 application with crystal report8.5 <p>I inherited a program from my late dad its developed with vb6 and has sql server 2000 as the back end. when i try to print a report from the application it gives the error message "ActiveX cannot create object" but when i view the report from crytal... | <p>There is not really much to go on, but it looks like your program is missing some unspecified dependancy. Maybe you should check the installation was correct? It might be an idea to reinstall the program.</p>
|
programmatically create a spring context <p>Does anyone know if there any way that I can programmatically create a bean context?</p>
<p>I want to be able to do something like:</p>
<pre><code>ConfigurableApplicationContext c = new ConfigurableApplicationContext();
BeanDefinition bd = new BeanDefinition();
bd.setId("id... | <p>Try either:</p>
<ul>
<li><a href="http://static.springframework.org/spring-javaconfig/docs/1.0.0.M4/reference/html/">Spring JavaConfig</a></li>
<li><a href="http://grails.org/Spring%2BBean%2BBuilder">Grails BeanBuilder</a></li>
<li><strong>new</strong> <a href="http://atunit.googlecode.com/">AtUnit</a></li>
</ul>
... |
onKeyDown() issue <p>I would like to create a photo/video capture application. </p>
<p>I have created a <code>CaptureView</code> class which extends <code>SurfaceView</code> and placed it in the main form.</p>
<p>The main form's activity has <code>onCreateOptionsMenu()</code> method which creates a menu. The menu wor... | <p>I had a similar problem and solved it by adding </p>
<pre><code>this.requestFocus();
this.setFocusableInTouchMode(true);
</code></pre>
<p>in the constructor of my SurfaceView subclass.</p>
|
Adobe flex maximum size of uploaded file <p>Is there a maximum size limit for files being uploaded in Adobe Flex?
I am testing it on localhost and can't upload a file of roughly 300MB.
Even though I receive the complete event, after I upload the file....
I was able to upload a file of roughly 10MB.
I am using PHP on th... | <p>It could be that PHP is not accepting the file because it is too big. You need to make sure the PHP configuration values <a href="http://php.net/manual/en/ini.core.php#ini.upload-max-filesize" rel="nofollow"><code>upload_max_file_size</code></a> and <a href="http://php.net/manual/en/ini.core.php#ini.post-max-size" r... |
Size of a dictionary <p>I am currently designing a website in C#, which uses some very complex code to generate a search list, which I am currently designing as a Tree-like structure.</p>
<p>The main reason I am using a tree is the fact that this website is high-traffic and has a very complex search filter, which mean... | <p>best bet is to run load on the site under different models and check <a href="http://msdn.microsoft.com/en-us/library/x2tyfybc.aspx" rel="nofollow">the relevant performance counters</a>. </p>
<p>As a simplification you could extract just the code that creates and stores data structures, and embed that into a consol... |
Is there a parameter for MSDOS commands (e.g. ipconfig) that cause them to wait for input before disappearing? <p>When I run e.g. <code>ipconfig</code> using the Run command (windows key+R), once the program has executed it immediately closes the instance of the command line interface, is there any universal parameter ... | <p>Use <code>cmd</code> with the <code>/k</code> switch:</p>
<pre><code>cmd /k ipconfig
</code></pre>
|
Vista & Cookies <p>Does anybody know where are cookies stored in Windows Vista?
I'm looking at C:\Users\MyUser\AppData\Roaming\Microsoft\Windows\Cookies but the cookies I see there don't match the one I see through Firefox.</p>
<p>I'm creating a cookie in ASP.NET, localhost, Firefox shows me the cookie but I cannot lo... | <p>I think FireFox stores cookies in its own storage, not under the Cookies folder in the profile. This is where IE stores its cookies.</p>
<p>On my system (XP Pro with FireFox 3.0.10), cookies seem to be stored unter C:\Documents And Settings\USERNAME\Application Data\Mozilla\FireFox\Profiles... in a SQLite database.... |
How to display image in mail after deleted in app server? <p>I have code which creates an image in an application server and that image has been referred in mail html. After sending mail, image will be deleted in application server. When I open the mail, the image is not getting displayed in the mail. </p>
<p>I think ... | <p>If you can't attach the image then you have to ensure than whatever external img src is being referred to (e.g. <code><img src="http://foo.com/bar.jpg"/></code>) remains accessible as long as people could reasonably view the message.</p>
|
reset multiple css styles for one single div element <p>my question is if it is possible to reset css styles (a lot off them) for a single div
and all elements that are contained in that div.</p>
<p>I am asking, because I found this tutorial for a jquery shoutbox that has it's own
css file.
I can not just copy the sty... | <p>Try this:</p>
<pre><code>div.foo, div.foo *
{
// your styles
}
</code></pre>
<p>which will apply the styles to the <code>div</code> with class "foo" and all its descendants. The star (<code>*</code>) is known as the <a href="http://www.w3.org/TR/CSS2/selector.html#universal-selector" rel="nofollow"><em>univers... |
Passing Javascript variable to <a href > <pre><code><script language="javascript" type="text/javascript">
var scrt_var = 10;
</script>
</code></pre>
<p>HTML Part:</p>
<pre><code><html>
this is a <a href ="2.html & Key= scrt_var">Link </a>
</html>
</code></pre>
<p>I just wan... | <p>If you want it to be dynamic, so that the value of the variable at the time of the click is used, do the following:</p>
<pre><code><script language="javascript" type="text/javascript">
var scrt_var = 10;
</script>
<a href="2.html" onclick="location.href=this.href+'?key='+scrt_var;return false;">L... |
How to use rails to find this result across 3 tables? <p>A project has 3 tables : client, invoices, deliveries</p>
<p>The relations are: </p>
<pre><code> client has_many invoices
client has_many deliveries
invoices belongs_to client
deliveries belongs_to client... | <p>I would define a method on the client that checks if
date is in month x for deliveries and invoices</p>
<pre><code>def has_invoice_in_month(year, month)
start_date = Date.new(year, month, 1)
end_date = Date.new(year, month, -1)
invoices.each do |invoice|
return true if start_date < invoice.date and... |
Log4j for Message Driven Beans <p>So, here's my problem:
<br>
I have a message driven bean X and would like to make use of Logger in X's onMessage() method. Lets presume that I have a single instance of the bean running in my app server, hence, I would initialize log4j in ejbCreate(). This would mean I would have to d... | <p>If you're getting this from inside a JAR file, then you're missing an iniitial <code>/</code>:</p>
<pre><code>Classloader.getResourceAsStream("/xyz_log4j.properties")
</code></pre>
<p>And depending on what directory contains the properties file, you have to specify a path to that directory relative to the top of t... |
String Comparison <p>Scenario</p>
<p>Consider the following code snippet. </p>
<pre><code> string s = "S";
string s1 = "S";
string s2 = string.Empty;
switch (s)
{
case "S":
s1 = "StringComparison";
break;
default:
... | <p>Because on the second switch you're are not doing a String comparison, you're doing a Char comparison.</p>
|
How do I convert an NSString into something I can use with FSCreateDirectoryUnicode? <p>I'm new to Mac and Objective-C, so I may be barking up the wrong tree here and quite possibly there are better ways of doing this.</p>
<p>I have tried the code below and it doesn't seem right. It seems I don't get the correct lengt... | <p>There are a couple of issues with your raw string data. But the easiest way to do it in Cocoa is:</p>
<pre><code>NSString *theString = @"MyFolderName";
NSString* path = [NSHomeDirectory() stringByAppendingPathComponent:theString];
[[NSFileManager defaultManager] createDirectoryAtPath:path
... |
asp.net Garbage Collection Notifications <p>Has anyone implement this new feature in .net 3.5 SP1 in an asp.net environment? The only thing I can find the web is <a href="http://www.codeproject.com/KB/aspnet/asp%5Fnet%5Fgc%5Fnotifications2.aspx" rel="nofollow">this</a>, which is not an actual implementation.</p>
| <p>in 3.5sp1, we have introduced 2 new APIs that tells you when a new Gen2 notification is approaching
Check out <a href="http://msdn.microsoft.com/en-us/library/cc647167.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/cc647167.aspx</a> for more details.</p>
|
Using SEO-friendly links <p>I'm developing a PHP website, and currently my links are in a facebook-ish style, like so</p>
<pre><code>me.com/profile.php?id=123
</code></pre>
<p>I'm thinking of moving to something more friendly to crawling search engines
(like here at stackoverflow), something like:</p>
<p><code>me.c... | <p>Stackoverflow does something similar to your <code>me.com/john-adams-123</code> option, except more like <code>me.com/123/john-adams</code> where the john-adams part actually has no programmatic meaning. The way you're proposing is slightly better because the semantic-content-free numeric ID is farther to the right... |
Reliably detecting that another of my applications is running <p>I have two applications, a WinForms app and a Windows Service that will both run on the same machine. I want the WinForms app to reliably detect when the service is running. I have complete control over the design and implementation of both applications.... | <p>K. Scott Allen has <a href="http://odetocode.com/Blogs/scott/archive/2004/08/20/401.aspx" rel="nofollow">a good write up</a> on using a Mutex for this purpose and issues you'll run into with the GC.</p>
<blockquote>
<p>If I want to have only one instance of the application running across all sessions on the machi... |
order of parsed elements is lost in XMLBeans <p>I have a XML structure somewhat like this:</p>
<pre><code><root>
<a/>
<b/>
<b/>
<a/>
<a/>
</root>
</code></pre>
<p>My XSD looks like this:</p>
<pre><code><xs:element name="root">
<xs:complexType... | <p>Try </p>
<p><code>xml.selectPath("./*")</code> </p>
|
iPhone custom cells - transparent label background <p>Picture is worth more than a thousand words :)</p>
<p><img src="http://i239.photobucket.com/albums/ff175/mlakilud/Labels.jpg" alt="alt text" /></p>
<p>Here is the code:</p>
<pre><code>
// Initialization code
UIView *myContentView = self.contentView;
UII... | <p>Or alternatively:</p>
<pre><code>self.label.backgroundColor = [UIColor clearColor];
</code></pre>
|
Quality Assurance Code of Conduct <p>I haven't been able to find any good resources about QA code of conduct and would like to start documenting this. The main issue I have is really basic stuff like:</p>
<ul>
<li>Someone reports "the design is broken" when the real issue is they are using IE6 and haven't updated the... | <p>This sounds more like an interpersonal problem, rather than a technical one (except maybe the last point).</p>
<p>If you feel people are not polite and respectful to each other, there are many solutions (consulting, coaching etc.), but that should be considered and treated as a social problem, not a technical one.<... |
To close or not to close: a dialog application when "Escape" is pressed <p>For dialog applications traditional behavior has been to close the application when "Escape" is pressed. However some users complain about this as they often press the key by mistake. </p>
<p>What's your approach?<br />
1) Close the application... | <p>That depends on the dialog - if the user's likely to have put any effort into the dialog, then (3) sounds like a good approach:</p>
<blockquote>
<p>Pop an "Are you sure you want to
quit?" message (possibly with a "Don't
show this again" check box").</p>
</blockquote>
<p>Otherwise, closing the dialog (not the... |
How do I keep multiple similar 'view/layout' files DRY without using using 'if()' statements everywhere in CakePHP? <p>I'm developing a application with CakePHP, and I have two layouts: one for the home page, and another for the rest of the application. Except for some coding on the header, they're almost exactly the s... | <p>I'd suggest using a ton of elements. This way, you can still keep all of the code in one place. For example, if this is your home page layout (boilerplate excluded):</p>
<pre><code><body>
<?php echo $this->renderElement('pageHeader'); ?>
<?php echo $this->renderElement('frontPageNot... |
What is a Fishbone Diagram? <p>Why are "cause and effect" diagrams also called "fishbone diagrams" ?</p>
<p>What is a Fishbone Diagram?</p>
| <p>A <a href="http://en.wikipedia.org/wiki/Fishbone%5Fdiagram">Fishbone diagram</a> is also known as a Ishikawa diagram. It is so named because it looks like a fish's backbone.</p>
<p><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Ishikawa%5FFishbone%5FDiagram.svg/280px-Ishikawa%5FFishbone%5FDiagr... |
ColdFusion COM object manipulation of MS Word 2000 dies after 100 seconds <p>I'm using ColdFusion 7 on a Windows 2003 server to talk to a default installation of Microsoft Word 2000 using COM objects. The goal is to generate a document with some tables in it.</p>
<p>That much I'm able to do. The CPU spikes to 100% for... | <p>Ok, answer number 2. Since the .Net weiners say it works you might have more luck building the document via an external vb.net script and passing any special requirements via a configuration file and/or command-line arguments. Alternatively if you'd prefer a real language you could do it in python with the win32com ... |
Asp.Net MVC Actions - Separation of Concerns/Single Responsibility Principle <p>In computer science we've been taught that each method should do one thing and one thing only. I'm a little confused then that we see MVC actions like the following <a href="http://www.nerddinner.com/">given as examples of good practice</a>... | <p>To me, this method does only one thing: update the model with the edited values received from the web form.</p>
<p>It's clear that doing this requires a couple of things to happen, but they are atomic and well defined. If you ever need to modify how this part of the model needs to be updated, this is the controller... |
how to code drivers? <p>I want to code drivers in C in linux os, though I think its very tough. Can I get some hints as to how to start or books to follow? Drivers can be from my USB port to graphics card!! </p>
<p>I know as to where I can search for books, I would like to know as to what the basic knowledge I shoul... | <p>Start with <em><a href="http://books.google.co.uk/books?id=97eyKSX0oCYC&dq=linux%2Bdevice%2Bdrives&printsec=frontcover&source=bl&ots=TFy-cN2dMU&sig=4LgLimN9xuVxX4nBstA9utHlBws&hl=en&ei=GLwvSqeUEM-rjAepzdWTCw&sa=X&oi=book%5Fresult&ct=result&resnum=2">Linux Device Drivers</a... |
Duplicate columns values within a table <p>My scenario is I have a table with columnxs A, B, C and D. A is the PK and B and C are both foreign keys.</p>
<p>I intend to add an exta column to this table E, the side effect of this within the application is it will cause a row to be inserted after which there will be dupl... | <p>If the relation is one to many, you're not breaking a referential rule by having multiple rows referring to a single foreign row.</p>
<p>Adding an extra column in this way might break existing applications. A query like this, that used to return one row, might now return many rows:</p>
<pre><code> select *
from ... |
How to calculate a relative date based on a date string <p>I'd like to find the date <em>after</em> a date provided by the user</p>
<p>This is not working:</p>
<pre><code>$start_date = '2009-06-10';
$next_day = date( $start_date, strtotime('+1 day') );
echo $next_day; // 2009-06-10
</code></pre>
| <p>Try date_modify:</p>
<pre><code>$d = new DateTime("2009-01-01");
date_modify($d, "+1 day");
echo $d->format("Y-m-d");
</code></pre>
<p>Documentation at <a href="http://us3.php.net/manual/en/datetime.modify.php" rel="nofollow">http://us3.php.net/manual/en/datetime.modify.php</a>.</p>
|
i want to develop an add-on for mozilla <p>i want to develop an add-on for mozilla which will browse and give every detail of the song that you're playing on your system now !!.. is it possible?.. how to know which song i am playin ? . which ebooks to follow to develop an extension</p>
| <p>Have a look at <a href="https://jetpack.mozillalabs.com/" rel="nofollow">Jetpack</a>, the new, easy way to create Firefox add-ons. </p>
|
How can I use the eclipse indenter from my code? <p>I noticed the eclipse indenter has support for the latest version of java, and it would be nice if I could use that class to indent generated java source code. Is there a way of integrating it ?</p>
<p>EDIT: I need to be able to include the code formatter in my code.... | <p>You can try running the formatter as a <a href="http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.jdt.doc.user/tasks/tasks-231.htm" rel="nofollow">standalone application</a> (also <a href="http://blogs.operationaldynamics.com/andrew/software/java-gnome/eclipse-code-format-from-command-line.html" rel="nof... |
Is there any good tutorial (example) for unit testing kohana base project? <p>I am looking for the best practices with PHPUnit testing a project on KohanaPHP framework.</p>
| <p>Kohana has a phpUnit module which is maintained by Ben Rogers, Chris Bandy, Isaiah DeRose-Wilson, Jeremy Bush, Kiall Mac Innes and Sam Clark.</p>
<p>You can find the module below and the documentation can be found <a href="http://dev.kohanaphp.com/wiki/phpunit" rel="nofollow">here</a> and <a href="http://www.phpuni... |
Automating WebTrends analysis <p>Every week I access server logs processed by WebTrends (for about 7 profiles) and copy ad clickthrough and visitor information into Excel spreadsheets. A lot of it is just accessing certain sections and finding the right title and then copying the unique visitor information. </p>
<p>I ... | <p>I use ODBC for querying metrics and numbers out of webtrends. We even fill a scorecard with all key performance metrics..</p>
<p>Its in German, but maybe the idea helps you: <a href="http://www.web-scorecard.net/" rel="nofollow">http://www.web-scorecard.net/</a></p>
<p>Michael</p>
|
Website security question with PHP? (Probably applies to ASP/Rails/etc.. too) <p>Say, I have "index.htm" and "routines.php".</p>
<p>"index.htm" will call eventually call "routines.php" using JS (AJAX).</p>
<p>So, my question is, how can "routines.php" verify that the request came from the same local server and not ou... | <p>You may forget about the Ajax part as it's not really part of the problem. You should read about Cross Site Request Forgeries (CSRF) and CSRF tokens. Some links:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery" rel="nofollow">http://en.wikipedia.org/wiki/Cross-site_request_forgery</a><... |
How do I access a file's icon server-side via PHP? <p>I have a PHP script running that lists files in a certain directory on the server. Is there any way to access the file's icon metadata? Lots of issues with this I suppose (eg: depends on the OS hosting the script. depends on whether the file is using a custom icon. ... | <p>You might be able to plug into the /icons folder that most apache installations have setup for their default directory listings. </p>
<p>It's not OS dependent at least.</p>
<p>You should be able to craft a url that displays an icon for a particular extension.</p>
|
SQL division <p>I have three tables; Apartment (apartmentnr, floor, apartmenttype), Floor (floornr, house), House(housenr, adress)</p>
<p>Now, I want to show housenr and adresses of houses that have apartments of all apartmenttypes (1-4), using 'NOT EXISTS'.</p>
<p>Please help me with suggestions on how to do this!</... | <p>As @onedaywhen hints, <code>not exists</code> is pretty ponderous for this task, and <code>count distinct</code> offers leaner syntax (performance issues are mentioned in the article he points to):</p>
<pre><code>SELECT House.adress
FROM House
JOIN Floor ON (House.housenr=Floor.house)
JOIN Apartment ON (Floor.floor... |
Hadoop cluster. 2 Fast, 4 Medium, 8 slower machines? <p>We're going to purchase some new hardware to use just for a Hadoop cluster and we're stuck on what we should purchase. Say we have a budget of $5k should we buy two super nice machines at $2500/each, four at around $1200/each or eight at around $600 each? Will ha... | <p>You're generally better off with Hadoop getting a few extra machines that are less beefy. You almost never see datanodes with more than 16GB ram and dual quad-core CPUs, and often they are smaller than that. </p>
<p>You always have to run one as the namenode (master), and generally you don't also run a datanode (w... |
Need help on choosing locks for thread synchronization <p>I have several modifying threads and some reading threads, which all access the global variable X. I want to make my synchronization policy like this:</p>
<p>When a thread try to modify X, it will require a lock first, and several modifying threads can have sev... | <p>You are looking for a read/write lock (or reader-writer lock). I believe <a href="http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/apis/users%5F86.htm" rel="nofollow">there is one</a> in pthreads (pthread_rwlock_*).</p>
|
Does SWT distribute a JAR that works on any supported operating system? <p>The <a href="http://www.eclipse.org/swt/" rel="nofollow">SWT</a> project currently maintains one distributable for each supported operating system. For example:</p>
<ul>
<li><code>swt-3.4.2-win32-win32-x86.zip</code></li>
<li><code>swt-3.4.2-gt... | <p>No, there isn't, and you can't make one either out of the standalone SWT distributions. That's because each os/windowing system/architecture combination has its own implementation of each of the SWT classes. For example, if your code refers to org.eclipse.swt.widgets.Button, the JVM has no way of knowing if you want... |
Trouble creating new Entity Data Model <p>I'm trying to add a new ADO.Net Entity Data Model to an MVC project I am working on.</p>
<p>When I complete the wizard, choosing my db and tables (just a single table for now) I get an error ""Exception has been thrown by the target of an invocation." and it throws me back the... | <p>You could try creating the Entity Data Model manually using the <a href="http://msdn.microsoft.com/en-us/library/bb387165.aspx" rel="nofollow">EdmGen.exe tool</a>. Hopefully that will give a bit more information about the error.</p>
|
Filter out the Users logging in time <p>I am new to Sharepoint 2007. I am trying to configure MOSS 2007. My question is: Can we know when a user has logged in and uploaded any document to a particular site in the central database?</p>
<p>I know these information can get from the logs but I want any application that gi... | <p>If you know what library you're interested in, you could consider either:</p>
<ul>
<li>setting an alert on the library</li>
<li>writing an event handler that would run your code when items are added/updated</li>
</ul>
|
How can I trigger a server-side event from a client-side event? <h3>Short version</h3>
<p>All I need is that, in a <code>ModalPopUp</code>, when the <code>DoubleClick</code> event of a <code>ListItem</code> fires, the click event of my OK button should be executed.</p>
<h3>Detail</h3>
<p>I have a <code>ModalPopUpExt... | <p>Have a look at this way using __doPostback</p>
<p><a href="http://stackoverflow.com/questions/905387/calling-a-vb-net-function-from-javascript/905404#905404">http://stackoverflow.com/questions/905387/calling-a-vb-net-function-from-javascript/905404#905404</a></p>
|
jQuery.attr function <p>i am using</p>
<pre><code>$('<div/>').attr('font-weight','bold');
</code></pre>
<p>It is not applying font-weight to bold with above function. Is there something wrong in there?</p>
| <p>Yea, something's wrong, the $() function is used to select an element, class or id, not a mal-formed tag. Also, you should use the css() function to change css properties so you need something like this:</p>
<pre><code>$("#mydiv").css('font-weight', 'bold');
</code></pre>
<p>If you want to select <em>all</em> divs... |
Which Java blocking queue is most efficient for single-producer single-consumer scenarios <p>I'm working on a standard Java system with critical timing requirements for my producers (1/100s of ms matters). </p>
<p>I have a producer placing stuff in a blocking queue, and a single consumer later picking up that stuff an... | <p>Well, there really aren't too many options. Let me go through the <a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/BlockingQueue.html">listed subclasses</a>:</p>
<p><a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/DelayQueue.html"><code>DelayQueue</code></a>, <a href="http://ja... |
Change text of "Return" keyboard button <p>How can I change the standard text of the "Return" button to something else?</p>
<p>I want it to be "Add".</p>
| <p>Unfortunately, you can change "Return" into only one of these predefined labels with the <code>returnKeyType</code> property:</p>
<ul>
<li>Return (default)</li>
<li>Go</li>
<li>Google</li>
<li>Join</li>
<li>Next</li>
<li>Route</li>
<li>Search</li>
<li>Send</li>
<li>Yahoo</li>
<li>Done</li>
<li>Emergency Call</li>
<... |
log-out is not working in php for a login System <p>i am implementing a log-in system, i am sure a lot of you know what it is, i use sessions to store the user's ID, and check it if he access a page that needs the user to be logged in.<br />
But my problem is when the user clicks the log-out anchor, nothing happens i s... | <p>You need to do a <code>session_start()</code> before <code>session_destroy()</code>.</p>
<p>If you don't, PHP has no idea which session you're trying to destroy.</p>
|
Fading in a background image <p>I have a web page that uses a large image for its background. I was hoping to use jQuery to load the image once it is downloaded (basically the way that bing.com loads its background image). Is this possible with jQuery? If so, is there a plugin that you would recommend? </p>
| <p>You could first load the image, and then, when it has finished loading, set it as background-image. That way the browser will (hopefully) load the background image from the cache instead of redownloading it. As you requested it as a plugin:</p>
<pre><code> $.fn.smartBackgroundImage = function(url){
var t = this;
... |
Key handling routines <p>Is there anyway to modify the key handling routine that the Windows Login Screen uses to allow a barcode with the username, 2key tab character ($I), and a password to log in a user. I cannot get the login screen to recognize the TAB character to tab to the password text field. Any help would be... | <p>You can <a href="http://technet.microsoft.com/en-us/library/bb742447.aspx" rel="nofollow">write your own gina.dll</a>, and create your own login dialog. By replacing the login dialog you can take care of the input in whatever way you want. I've never done this and it doesn't seem to be a straightforward chore, but y... |
Method Signature Problem <p>I am getting the Error/Warning about a part of my code saying 'Messages Without A Matching Method Signature will be assumed to return 'id' and accept 'â¦' as arguments.)'
I do not understand why I am getting this error, so i am looking for some help, below is a link to that part of code in ... | <p>This warning usually means your signature may be different or you haven't declared a prototype for your method.</p>
<p>For instance, you may have done something like this:</p>
<pre><code>// Prototype
-(void) foo:(float)bar;
// Calling the function
int blargh = 3;
[myClass bar:blargh];
</code></pre>
<p>You see ho... |
How can I know if a string represents a valid MIME type? <p>I have a whole bunch of string that are supposed to represent MIME types. However, some of these string have bad/invalid MIME types. Is there a way in the .NET framework to get a list of valid MIME types?</p>
| <p>IANA have a list <a href="http://www.iana.org/assignments/media-types/" rel="nofollow">here</a>. I would think that is more of an authority than most lists you can find.</p>
|
Validating Dates in Javascript with Unusual Form Field Ids - Salesforce.com Web-To-Case Integration <p>Ok, I need help. This is my first question here. </p>
<p>Background:
I am working on a charity project, and my portion of the project is to build the Web-To-Case functionality with Salesforce.com. Salesforce.com, ... | <p>Your checkDate function is correct. The problem is in your checkDates function. Javascript doesn't like variables that begin with numbers. Change it to:</p>
<pre><code>function checkDates(form)
{
checkDate(form.elements['00N80000003LGJ5']);
checkDate(form.elements['00N80000003LGNt']);
}
</code></pre>
<p>an... |
Scoring / rating engines - advice and examples? <p>I need to create a flexible (and preferably dynamic) scoring engine, much like a credit scoring or premium calculating system. Does anyone with practical experience of creating a scoring engine have any advice, examples or suggested patterns?</p>
<p>I already know abo... | <p>A scoring engine has to actually score something - with your FICO score, it's the risk that you'll default on new credit. Essentially, there are a handful of steps:</p>
<ol>
<li>Collect mountains of data</li>
<li>Decide what you want to know about the data - what do you want to predict?</li>
<li>Mine the data for a... |
Undocumented System Procedure 'sp_MSforeachtable' and the @whereand parameter <p>I'm attempting to use <a href="http://www.databasejournal.com/features/mssql/article.php/3441031/SQL-Server-Undocumented-Stored-Procedures-spMSforeachtable-and-spMSforeachdb.htm" rel="nofollow">the undocumented system procedure <code>sp_MS... | <p>Update for SQL2000:</p>
<pre><code>declare @s nvarchar(1000)
set @s = ' and uid = ' + convert(nvarchar, user_id('my_schema'))
exec sp_msforeachtable @command1='print ''?''', @whereand = @s
</code></pre>
|
How to load a Google Static Maps Image using Javascript <p>Right now I can use this URL to request a Google Static Maps image successfully:</p>
<pre><code>http://maps.google.com/staticmap?center=37.687,-122.407&zoom=8&size=450x300&maptype=terrain&key=[my key here]&sensor=false
</code></pre>
<p>How... | <p>Does this code work for you (it works for me -- be sure to insert your key)?</p>
<pre><code><html>
<head>
<script language="javascript">
function swap() {
document.getElementById('my-image-id').src = "http://maps.google.com/staticmap?center=37.687,-122.407&zoom=8&size=450x300&... |
.NET template files <p>I have a application that generates a couple of different mails. These mails are currently build up using a string builder that generates a HTML based string that is the mail content.</p>
<p>This approach is getting messy. The code is objects mixed with HTML, etc, etc. <em>What I'd like is to ha... | <p>It can be done with T4. It would work exactly the way it does in MVC.</p>
<p>You should consider getting the <a href="http://www.visualt4.com/" rel="nofollow">Clarius T4 Editor</a>, as Visual Studio does not come with intellisense for T4 out of the box, and the Clarius T4 editor can provide that.</p>
|
Return value of function might be undefined <p>Ok, I have the following function:</p>
<pre><code>function TfPackagedItemEdit.GetRTFDescription: TStringList;
begin
Result.Text := richDescription.Lines.Text; //stringlist
end;
</code></pre>
<p>The compiler generates the following warning about this line:</p>
<p>[DCC ... | <p>The <code>Result</code> variable is not initialized by default. It doesn't automatically refer to some compiler-generated <code>TStringList</code> instance. You need to assign a value to <code>Result</code>. That means having a line like this somewhere in your code:</p>
<pre><code>Result := ...;
</code></pre>
<p>A... |
Why does adding count(*) to a select statement force a row to exist in a subquery? <p>On Oracle 9i, why does the following produce the result 'abc'</p>
<pre><code>select 'abc ' || (select txt from
(select 'xyz' as txt from dual where 1=2))
from dual
</code></pre>
<p>while this produces 'abc xyz':</p>
<pre><co... | <pre><code>select count(*) from dual where 1=2
</code></pre>
<p>returns 0. That is, a row with the value zero.</p>
|
Convert a PDF to a Transparent PNG with GhostScript <p>I am attempting, unsuccessfully, to use Ghostscript to rasterize PDF files with a
transparent background to PNG files with a transparent background. I've
searched high and low for questions from others attempting the same thing
and none of the posted solutions, whi... | <p>I share your experience with the <code>-dTextAlphaBits=4</code> and <code>-dGraphicsAlphaBits=4</code> flags. They appear not to work on all texts. The "fix" I came up with was to just render the image at 4 times the desired size, and then scale the image down. Luckily ghostscript has no problems rendering gigapixel... |
how to search all / wildcard in lucern solr <p>I'm using RoR + acts_as_solr to query a Solr database. </p>
<p>I'm used to using "*" to select all, thanks to MySQL, but that command fires an exception in Solr. Are they other wildcards I can use? Suggestions? Thanks!</p>
| <p>In Solr you can get all documents by querying <code>*:*</code> (except for pagination, that's <a href="http://stackoverflow.com/questions/1315434/how-to-get-all-docs-with-actsassolr/1316394#1316394">another topic</a>)</p>
|
Get a UITableView to not scroll and grow within a UIScrollView <p>I need to create a screen that is similar to the one below. The only way I can come up with is to have a UIScrollView be the parent view. Then have a UIImageView and UILabels for the thumbnail and main text ("All3Sports").</p>
<p>For the sections like... | <p>I did something like this with a UITableView and set the table view style to UITableViewStyleGrouped but put the image & title, in your case "All3Sports", in the Header of the grouped table view and the 3 bottom buttons in the Footer. </p>
|
Swing: Can't get JButton to update - repaint() not working <p>I'm using Swing for the first time to create a simple GUI. It consists of a <code>JFrame</code> upon which I have placed a single <code>JButton</code> which, when clicked, calls some other code which takes approx. 3 seconds to return.</p>
<p>Just before the... | <p>What's happening is that the 3-second code is executing in the GUI thread, so the button doesn't have a chance to update until it's done.</p>
<p>To solve this, start a <a href="http://java.sun.com/javase/6/docs/api/javax/swing/SwingWorker.html" rel="nofollow"><code>SwingWorker</code></a> to do the long-running oper... |
Redirecting FORTRAN (called via F2PY) output in Python <p>I'm trying to figure out how to redirect output from some FORTRAN code for which I've generated a Python interface by using F2PY. I've tried:</p>
<pre><code>from fortran_code import fortran_function
stdout_holder = sys.stdout
stderr_holder = sys.stderr
sys.stdo... | <p>The stdin and stdout fds are being inherited by the C shared library.</p>
<pre><code>from fortran_code import fortran_function
import os
print "will run fortran function!"
# open 2 fds
null_fds = [os.open(os.devnull, os.O_RDWR) for x in xrange(2)]
# save the current file descriptors to a tuple
save = os.dup(1), o... |
my rails ApplicationController is having a RoutingError <p>I am by no means a Ruby developer, but I code HAML for a ruby framework on my localhost. </p>
<p>I had originally put a file called vidgirlBox2.flv file and called to it within the HAML, but converted the file to a swf called vidGirl_home.swf . </p>
<p>This s... | <p>I'm not super Flash-savvy, but it looks like when you converted the file to a swf, it basically embedded your prior vidgirlBox2.flv file as a resource. My guess is that resource used to live on your desktop, so when you edited your fla file the local path got saved into the resource somehow. The error you are seei... |
How to force Delphi compiler to display all hints and warnings <p>Is there a way to force the Delphi compiler to display all hints and warnings all the time?</p>
<p>Here is the behavior that I am currently seeing in Delphi 6:</p>
<ol>
<li>Check out fresh copy of my application from source control</li>
<li>Open projec... | <p>Hints and Warnings are generated by the compiler. It will only report on units that it has compiled. The "compile" command will only compile files that have <em>changed</em>. To force a recompilation of all units used by your project, use the <strong>Build</strong> command instead.</p>
<p>Later versions assign a... |
Why does XML:Simple complain that "No element found"? <p>I'm trying to execute a simple Perl program that uses <a href="http://search.cpan.org/dist/XML-Simple" rel="nofollow">XML::Simple</a> to print out the data from an XML file.
However, the error I'm getting is :</p>
<pre>
no element found at line 15, column 0, byt... | <p>Need a closing customer-data tag at the end of the document to make it well formed. That's why the parser barfs at the end of the file.</p>
|
How do I hook in to a double-press of the Ctrl key? <p>What I'm looking for is functionality similar to Google desktop. When you hit <kbd>Ctrl</kbd> twice rapidly, a little search box pops up.</p>
<p>I've tried using a fairly heavy keyboard hook class that I found somewhere, but that kept giving meunpredictable result... | <p>You'll probably want to use <a href="http://msdn.microsoft.com/en-us/library/ms644990%28VS.85%29.aspx" rel="nofollow">SetWindowsHookEx</a> to hook into the keyboard events at a low level.</p>
<p>Here is some <a href="http://www.codeguru.com/columns/vb/article.php/c4829" rel="nofollow">sample code in C++</a>, and he... |
How do I get a keyIterator for a LinkedHashMap? <p>By looking at the source code for LinkedHashMaps from Sun, I see that there is a private class called KeyIterator, I would like to use this. How can I gain access?</p>
| <p>You get it by calling</p>
<pre><code>myMap.keySet().iterator();
</code></pre>
<p>You shouldn't even need to know it exists; it's just an artifact of the implementation. For all you know, they could be using flying monkeys to iterate the keys; as long as they're iterated according to the spec, it doesn't matter how... |
Reverse engineering a statistics data file from my insulin pump controller <p>This may or may not be a grey area subject, though my intentions are certainly not, so my intention is not to stir up an ethical debate on the topic of reverse engineering. </p>
<p>I'm a type 1 diabetic currently undergoing pump therapy. I... | <p>What I would do next is try and find some numbers. There's a bunch of ways the numbers could be encoded:</p>
<ul>
<li>Ints (1, 2, 4 bytes, various endianness)</li>
<li>Floating-point (of various sizes)</li>
<li>Fixed point or some other strange format</li>
</ul>
<p>You have the advantage of knowing some numbers th... |
How do I use SecureString securely? <p>All of the examples I have seen end up converting a SecureString back to a standard string before using it, defeating the object. What's a good way of using a secure string without this problem?</p>
<p>I know I can marshall the SecureString to a BSTR but what can I do with this B... | <p>This link includes a lot of helpful information, including how to get an unmanaged memory block for passing the string to native code (that is presumably also secure), a BCL class that uses it, and links to a couple examples:</p>
<p><a href="http://bartdesmet.net/blogs/bart/archive/2006/03/31/3851.aspx" rel="nofoll... |
hibernate query issue, so close and stumped <p>The schema:
(psuedocode)</p>
<p>I have a bean, called BaseEntity...</p>
<pre><code>@Entity
class BaseEntity {
@OneToMany @CascadeType.ALL
List [Property] properties;
//the use angled braces ommited for the stackoverflow editor to show up properly
}
</code></pre>... | <p>The performance problem looks like it is in your sub selects. </p>
<p>What about breaking it up a bit</p>
<pre><code>select entity from BaseEntity as entity join entity.properties as property where
property.category.name in ( 'FOO','BAR' )
</code></pre>
<p>This would get you the list of Base Entities with a prop... |
Is the Decorator Pattern too much for implementing a coffee ordering system? <p><strong>Update:</strong> Since we usually say, "the situation will determine if any Design Pattern is a good fit for the job"... will a coffee ordering system in real life be solved using the Decorator Pattern?</p>
<p>Is the Decorator Pat... | <p>This is a typical problem with examples for higher-level abstractions. The example has to be simple enough to be easily understood and demonstrate the concepts, which also means for a lot of Design Patterns that it's also more easily implemented in another way.</p>
<p>That said, the way I've normally seen Decorator... |
Check if date is this date or bigger <p>I trying to check if a date is this date or bigger inside my linq query with boolean. But it's not working like i want.</p>
<p>This my code</p>
<pre><code> public bool CheckMonth(int month)
{
if (month > System.DateTime.Now.Month)
{
... | <p>What is it that you want to do? According to your text you want to find out whether a given date is today or later, but the code sample compares only the month (which means that June this year is the same as June last year). If you want to compare the date (including year and day), this comparison will do the job fo... |
Update dynamic html attribute <p>What im trying to do is when the p inherits the class "active" that div.test will print the link rel correctly. </p>
<p>Currently if the page loads without the class assigned to the p tag, it will not. How can I make it happen when the p tag inherits the class "active" the link printed... | <p>I am not sure what you asking. Are you saying that you would like this code:</p>
<pre><code>var relvar = $('p.active').attr('rel');
$("div.test").html("<a rel='"+ relvar +"'>hello</a>");
</code></pre>
<p>To be run whenever the <code><p></code> element changes classes? If so, there is no "onchange... |
Exporting and importing subscriptions to SharePoint-hosted reports that were created in SQL Server Reporting Services <p>I came across <a href="http://stackoverflow.com/questions/202295/any-way-to-export-import-sql-server-reporting-services-subscriptions">this</a> question in related questions which basically asks the ... | <p>Something to try...</p>
<p>When a SSRS subscription is create a job gets created under SQL Server Agent\Jobs. The job name looks like a guid so it's not easy to tell one subscription from another. But you can right click on the job and the "Script Job as" options are available. </p>
<p>I'm sure someone with more T... |
Code Access Security real time implementation in .net? <p>I am a C# .net devoloper.</p>
<p>I have read a lot about Code Access Security(CAS) in .net.</p>
<p>I haven't seen the implementation of this featue on any of the project i have worked on?</p>
<p>Has anyone implemented it? </p>
<p>I read that ALL managed code... | <p>CAS simply prevents untrusted code from doing something you don't want it to do to a resource you might want to protect.</p>
<p>I think the classic example of where it's required is an untrusted program attempting to access resources on your local PC. In such a case, you can use CAS to grant permissions to this pr... |
Making a calendar editable to anyone? <p>I am trying to make a webpage that looks like the Google Calendar and allows anyone to add/edit/delete any event, working like a notice board.</p>
<p>For now I am using a customized UI to show all the events in my Google Calendar and it works perfectly. But I can't find out how... | <p>If you're not completely tied to Google Calendar, you could have a look at <a href="http://code.google.com/p/calagator/" rel="nofollow">Calagator</a>. Originally written specifically for the Portland tech community, it can be adapted fairly easily - my friend did up <a href="http://vancal.org/" rel="nofollow">VanCal... |
xml flash gallery / joomla help needed <p>I've bought the "virtual gallery" from flashden but I'm having problems implementing it.. I'm not used to using flash galleries or xml files, so hopefully someone can help me out a bit.</p>
<p>Here's the call to the flash (js):</p>
<pre><code> var so = new SWFObject("gallery... | <p>I apolagize if my answer is retardedly simple, but your xml option paths and your file structures don't match. This would make it so that the proper files can't be loaded.</p>
|
Is it worth wrapping a logging framework in an additional layer? <p>I'm currently looking at upgrading the logging mechanism in a medium-to-large-sized Java codebase. Messages are currently logged using static methods on a <code>Debug</code> class, and I have recommended switching from this to something like SLF4J or c... | <p>I entirely agree with you: wrappers of wrappers of wrappers are getting out of hand. I suspect that architect doesn't realize how SLF4J in particular can easily wrap any other logging system, so that "changing implementation" is perfectly feasible without yet another layer of wrappage.</p>
|
Apple Automater URL selection, <p>I want to search a website, say google, and open the search result weblinks. In Automator you just start by opining the search site witch the parameter in the url. Than you get all the links from this site and then you sort them.
BUT i never could find out HOW you stop after say the fi... | <p>It's a variant of the question you asked, but does this help you?</p>
<p><a href="http://homepage.mac.com/cjrtools/automator-apps/files/url-links-textedit.html" rel="nofollow">http://homepage.mac.com/cjrtools/automator-apps/files/url-links-textedit.html</a></p>
<p>Specifically "only return the URLs in the same dom... |
Javascript - How to detect if document has loaded (IE 7/Firefox 3) <p>I want to call a function after a document loads, but the document may or may not have finished loading yet. If it did load, then I can just call the function. If it did NOT load, then I can attach an event listener. I can't add an eventlistener aft... | <p>There's no need for all the code mentioned by galambalazs. The cross-browser way to do it in pure JavaScript is simply to test <code>document.readyState</code>:</p>
<pre><code>if (document.readyState === "complete") { init(); }
</code></pre>
<p>This is also how jQuery does it.</p>
<p>Depending on where the JavaSc... |
Showing Datetime using C# <p>I need to show timestamp as shown below in my .Net application:</p>
<p>13/12/2007 5:04 PM EST</p>
<p>or</p>
<p>13/12/2007 5:04 PM CST</p>
<p>depending upon the US timezone. </p>
<p>How do i achieve this functionality using C#??</p>
<p>Thanks for reading.</p>
| <pre><code>Console.WriteLine(DateTime.Now + " " + TimeZone.CurrentTimeZone.StandardName);
</code></pre>
<p>returns</p>
<p>6/10/2009 7:45:14 PM Central Standard Time</p>
<p>TimeZone.CurrentTimeZone.StandardName will return the long name and I believe you will have to modify your code a bit to get the abr. for each zo... |
How to strip whitespace-only text nodes from a DOM before serialization? <p>I have some Java (5.0) code that constructs a DOM from various (cached) data sources, then removes certain element nodes that are not required, then serializes the result into an XML string using:</p>
<pre><code>// Serialize DOM back into a st... | <p>You can find empty text nodes using XPath, then remove them programmatically like so:</p>
<pre><code>XPathFactory xpathFactory = XPathFactory.newInstance();
// XPath to find empty text nodes.
XPathExpression xpathExp = xpathFactory.newXPath().compile(
"//text()[normalize-space(.) = '']");
NodeList emptyTextN... |
Are there any 'rules of thumb' regarding the dynamic creation of form controls? <p>For example, suppose a new Windows From application were being developed with lets say 25 different screens each of which had say 5-10 controls on them.....</p>
<p>Obviously all of the necessary listboxes, dialog boxes, listviews, datas... | <p><a href="http://www.4guysfromrolla.com/articles/081402-1.aspx" rel="nofollow">Here</a> is a really good article explaining using dynamic controls in the context of ASP.NET and when it would be applicable. The same examples are applicable I believe. Generally insert controls at run-time gives you the flexibility to... |
Union and struct packing problem <p>I'm writing some software where each bit must be exact(it's for the CPU) so __packed is very important. </p>
<pre><code>typedef union{
uint32_t raw;
struct{
unsigned int present:1;
unsigned int rw:1;
unsigned int user:1;
unsigned int dirty:1;
unsigned int free:7;
unsigned int ... | <p>Your struct has only 31 bits</p>
|
db2 stored procedure. locking / releasing table <p>I use a stored procedure to read/update/return certain fields in a journaled as400 table.
I want to lock the table first and then release it after the record is updated. I
tried tons of stuff, but releasing table is a problem. SP defines and opens cursor,
selects re... | <p>The locks will not be released until a COMMIT or ROLLBACK is issued, either within the procedure itself, or from the application that called the procedure.</p>
|
Any reason NOT to slap the 'synchronized' keyword everywhere? <p>In my java project, almost every non-static method I've written is <code>synchronized</code>. I've decided to fix up some code today, by removing most of the <code>synchronized</code> keywords. Right there I created several threading issues that took quit... | <p>If you indiscriminately synchronize, you also run the risk of creating a <a href="http://en.wikipedia.org/wiki/Dining_philosophers_problem">deadlock</a>. </p>
<p>Suppose I have two classes, <code>Foo</code> and <code>Bar</code>, both having a synchronized method <code>doSomething()</code>. Suppose further that eac... |
Hibernate polymorphism <p>This is a Hibnerate polymorphism question and a data model design
question; they are intertwingled. I've used Hibernate in the past,
and have enjoyed it, but sometimes I find it difficult to think
about anything but trivial designs. Not a knock on Hibernate; just
an observation that ORM in g... | <p>This is absolutely possible. You could associate the notes with the abstract <code>Fruit</code> class instead of repeating them in each of the implementations:</p>
<pre><code>@Entity
@Inheritance
public abstract class Fruit {
private Set<Note> notes;
...
@OneToMany(cascade = CascadeType.ALL, mappedB... |
Finding malformed XHTML with Javascript <p>Does anyone have a good way of finding if a string contains malformed XHTML using Javascript?</p>
<p>Since my page allows 'user' generated XHTML returns (the users <em>can</em> be trusted) and injects it into the DOM, I want a way to check if there are unclosed or overly clos... | <p>I do this on the server with HTMLTidy</p>
<pre><code>htmltidy -asxhtml
</code></pre>
|
Difference in declaring structures <p>I was using my structure like this. I don't like to typedef as I have told it can hide errors.
However, I was looking at some sample code and I have seen structures declared like this. And this is the normal way I declare them.</p>
<pre><code>struct person
{
int age;
cha... | <p>This:</p>
<pre><code>struct
{
int age;
char name[32];
}person;
</code></pre>
<p>declares a variable <code>person</code> that is a <code>struct</code>. The <code>struct</code> has no name, but you still use the <code>person</code> variable the same way.</p>
<pre><code>struct _person
{
int age;
cha... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.