input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
opengl set texture color with vertex color <p>Because I need to display a <a href="http://codeflow.org/ubuntu.png" rel="nofollow">huge number of labels</a> that <a href="http://www.youtube.com/watch?v=A_ah-SE-cNY" rel="nofollow">move independently</a>, I need to render a label in <a href="http://pyglet.org" rel="nofoll... | <p>You want to set <code>glEnable(GL_COLOR_MATERIAL)</code>. This makes the texture color mix with the current OpenGL color. You can also use the <code>glColorMaterial</code> function to specify whether the front/back/both of each polygon should be affected. Docs <a href="http://www.glprogramming.com/blue/ch05.html#id3... |
AJAX console window with ANSI/VT100 support? <p>I'm planning to write gateway web application, which would need "terminal window" with VT100/ANSI escape code support. Are there any AJAX based alternatives for such a task?</p>
<p>I'm thinking something like this: <a href="http://tryruby.hobix.com/">http://tryruby.hobix... | <p>Try</p>
<p><a href="http://wiki.kartbuilding.net/index.php/Anyterm">AnyTerm</a></p>
<p><a href="http://wiki.kartbuilding.net/index.php/Ajaxterm">AjaxTerm</a></p>
<p><a href="http://www-personal.umich.edu/~mressl/webshell/">WebShell</a></p>
|
Autocomplete on SQL Management Studio? <p>Does anyone know if there's an add-in that does autocomplete for queries on SQL Management Studio?</p>
| <p>You can also try Devart's free SQL Complete. </p>
<p><a href="http://www.devart.com/dbforge/sql/sqlcomplete/">http://www.devart.com/dbforge/sql/sqlcomplete/</a></p>
|
Can you modify CPU registers from within VS2008 IDE? <p>Was just wondering if there was a way to edit the CPU registers (i.e. EAX, EBX, ECX, etc) or flags (OV, UP, erc) from within the Visual Studio IDE. I know you can <strong>view</strong> them using the Registers pane (ctrl-shift-G) and you can cycle through them wi... | <p>yes, you can....</p>
<p>from the help (you know...the f1 key)</p>
<p>To change the value of a register </p>
<ul>
<li>In the Registers window, use the TAB key or the mouse to move the insertion point to the value you want to change. When you start to type, the cursor must be located in front of the value you want... |
Strategic Advice: Upgrading the Design of a Web App <p>I have an ASP.NET web site dedicated to reporting on PBX extension stats. It comprises many report pages, with HTML generated almost purely by code-behind (setting a Label control's Text property instead of using Response.Write), using un-parameterised string lite... | <p>For your back-end design, I suggest having a class to represent each main table of your database (i.e. a Report class and a User class, for example). Anything that's not an event handler should go in the back-end class files / namespace.</p>
<p>For your GUI, looks like you're on the right track using ASP.NET contro... |
Variable LIMIT Clause in MySQL <p>I am writing a stored procedure where I have an input parameter called my_size that is an int, I want to be able to use in a limit clause in a select statement. Apparently this is not supported, is there a way to work around this?</p>
<pre><code># I want something like:
SELECT * FROM ... | <p>For those, who cannot use MySQL 5.5.6+ and don't want to write a stored procedure, there is another variant. We can add where clause on a subselect with ROWNUM.</p>
<pre><code>SET @limit = 10;
SELECT * FROM (
SELECT instances.*,
@rownum := @rownum + 1 AS rank
FROM instances,
(SELECT @rownu... |
Subversion vs CVS <p>I've used both SVN and CVS a little bit, but will need to choose one for a new project I will be starting.</p>
<p>Can anyone who has used both extensively please offer some pros and cons and which they think is better? Best learning resources would be appreciated too.</p>
<p>This will be for a s... | <p>I've used both. There is no comparison; you want svn. The only reason to use CVS is because you are entering or taking over a legacy system with management that does not want to change the status quo. If you are starting on a new project, it is virtually a logical impossibility to argue that CVS is better than Su... |
NSApplication and -applicationDidFinishLaunching: <p>I have an application where I have a <code>main.m</code> that returns <code>NSApplicationMain(argc, (const char **) argv);</code>.</p>
<p>I want to run code on <code>-applicationDidFinishLaunching:</code>, but I just dont see how to do it. </p>
<p>Can anyone help ... | <p>The applicationDidFinishLaunching: method of the NSApplication delegate will be called when the app has finished loading. Many of the project templates setup a delegate. If you are using one just add the appropriate method to it.</p>
<p>If your project does not have an app delegate set up you will need to do that y... |
dimensions of loaded swf's stage <p>Here's the situation - I've got a shell that loads an external .swf. Now, that .swf is 800x600, but it's an animation piece, and there are elements that extends off the stage. When I load the .swf into the shell and call its width attribute, it returns 1200 - because it's including t... | <p>The width and height of the loaded SWF as defined by the FLA it was created with can be found in the <code>Loader</code> object in which you've loaded the SWF into.</p>
<pre><code>swfLoader.contentLoaderInfo.width
swfLoader.contentLoaderInfo.height
</code></pre>
<p>This will always show you the dimensions as defin... |
Using a Single system() Call to Execute Multiple Commands in C <p>In an information security lab I'm working on, I've been tasked with executing multiple commands with a single call to "system()" (written in C, running on Fedora). What is the syntax that will allow me to execute more than command through system()? (T... | <p>That depends on the shell being invoked to execute the commands, but in general most shells use <code>;</code> to separate commands so something like this should work:</p>
<pre><code>command1; command2; command3
</code></pre>
<p>[EDIT]</p>
<p>As @dicroce mentioned, you can use <code>&&</code> instead of <... |
Which variables should I typecast when doing math operations in C/C++? <p>For example, when I'm dividing two ints and want a float returned, I superstitiously write something like this:</p>
<pre><code>int a = 2, b = 3;
float c = (float)a / (float)b;
</code></pre>
<p>If I do not cast <code>a</code> and <code>b</code> ... | <h3>Question 1: Float division</h3>
<pre><code>int a = 2, b = 3;
float c = static_cast<float>(a) / b; // need to convert 1 operand to a float
</code></pre>
<h3>Question 2: How the compiler works</h3>
<p>Five rules of thumb to remember:</p>
<ul>
<li>Arithmetic operations are always performed on values of the ... |
OOP Problems to use for Coding Tests during interviews <p>As a second interview I get people to sit down and write code...I try to make the problem really technology independent.</p>
<p>My programming problems that I have don't really exercise peoples OO abilities. I tend to try and keep the coding problem solvable w... | <p>This is a problem that I use with some trainings, looks simple but is tricky OOP-wise:</p>
<p>Create model classes that will properly represent the following constructs:</p>
<ol>
<li>Define a Shape object, where the object is any two dimensional figure, and has the following characteristics: a name, a perimeter, a... |
Rename files in sub directories <p>Is there any way of batch renaming files in sub directories?</p>
<p>Example: </p>
<p>Rename *.html to *.htm in a folder which has directories and sub directories.</p>
| <p>Windows command prompt: (If inside a batch file, change %x to %%x)</p>
<pre><code>for /r %x in (*.html) do ren "%x" *.htm
</code></pre>
<p>This also works for renaming the middle of the files</p>
<pre><code>for /r %x in (website*.html) do ren "%x" site*.htm
</code></pre>
|
send key for right arrow <p>what is the syntax for the sendkey for rightarrow in .net?</p>
| <p>{RIGHT} </p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx</a></p>
|
Button text in JTable renderer not visible. Why? <p>I have a custom cell renderer set in JTable and it works but instead an "x" visible on buttons being table cells I see "..." (three dots). What did I miss ??</p>
<pre><code> /***************************************************************************
* Listener rea... | <p>The size of the button isn't large enough to contain the rendered "x" plus the padding around it. </p>
<p>A solution would be to enlarge the table cell or reduce the padding (always assuming that the button has the same size as the table cell).</p>
|
EBNF to fluent interface <p>I have recently had the need to write a fluent interface for C# that will essentially mirror SQL. Yes, I am aware of LINQ to SQL, but I'm interesting in getting "closer to the metal"--having something that essentially provides nothing more than an Intellisensified SQL shim <em>within</em> C... | <p>I like it, but you have to make sure to return types like HasFromAndSelect or something like that so you don't end up with <code>fq.SELECT(Foo.ID).SELECT(Foo.Age).WHERE(Foo.Age > 22)</code> or <code>fq.WHERE(Foo.Age > 22).SELECT(Foo.ID)</code>, etc.</p>
<p>There's much more thought that needs to go into this,... |
How do I set up a test project for a Eclipse plugin project <p>I'm working on a eclipse plug-in and I've tried to create another test project seperate from the plug-in. The reason I do this is to not let the plug-in depend on jUnit when it is exported. However, I can't access the Eclipse Plug-in API when I do the testi... | <p>The recomended way of ding this seems to be with Plug-in fragments:</p>
<p><a href="http://rcpquickstart.com/2007/06/20/unit-testing-plug-ins-with-fragments/">http://rcpquickstart.com/2007/06/20/unit-testing-plug-ins-with-fragments/</a></p>
<p>The fragment gets a high-degree of access to your plugin's code and sep... |
What is the worst abuse you've seen of LINQ syntax? <p>On a recent <a href="http://www.dotnetrocks.com/default.aspx?showNum=383">Dot Net Rocks podcast</a>, Jon Skeet mentioned possible abuses of LINQ syntax. What examples have people seen where crazy things are being done with LINQ?</p>
| <p>It has to be a <a href="http://blogs.msdn.com/lukeh/archive/2007/10/01/taking-linq-to-objects-to-extremes-a-fully-linqified-raytracer.aspx">ray-tracer implemented in a single LINQ expression</a>. Clever, beautiful, and scary all at the same time!</p>
|
Is void** an acceptable type in ANSI-C? <p>I have seen a function whose prototype is:</p>
<pre><code>int myfunc(void** ppt)
</code></pre>
<p>This function is called in a C file as
a = myfunc(mystruct **var1);</p>
<p>where mystruct is typedef for one of structure we have. </p>
<p>This works without any compilat... | <p>The <a href="http://c-faq.com/">comp.lang.c FAQ</a> addresses this issue in detail in <a href="http://c-faq.com/ptrs/genericpp.html">Question 4.9</a>. In short, they say <strong>it's not strictly portable</strong> to cast an arbitrary pointer-to-pointer to a <code>void **</code>; they go on to explain that "code lik... |
Looking for a Report Designer that allows connection to a RESTful webservice <p>I'm looking for a Report Designer that will allow me to connect to a RESTful webservice. Ideally I would like one that has a royalty-free End-User Report Designer. WE will be hosting it in an ASP.NET web site. So something compatable with t... | <p>I'm not sure what you mean by asking for a report generator that can connect to a web service. </p>
<p>Web services aren't something you can report on. They're just a source of data. What do you want to connect to and what data are you expecting to get back?</p>
<p>The problem with RESTful web services is you don'... |
Symfony app - how to add calculated fields to Propel objects? <p>What is the best way of working with calculated fields of Propel objects?</p>
<p>Say I have an object "Customer" that has a corresponding table "customers" and each column corresponds to an attribute of my object. What I would like to do is: add a calcul... | <p>There are several choices. First, is to create a view in your DB that will do the counts for you, similar to my answer <a href="http://stackoverflow.com/questions/234785/#235267">here</a>. I do this for a current Symfony project I work on where the read-only attributes for a given table are actually much, much wid... |
How do I convert big numbers to decimal? <p>0x34363932353433373538323038353135353439</p>
| <p>From the Unix / cygwin command line, you can use bc.</p>
<pre><code>$ bc
ibase=16
34363932353433373538323038353135353439
1164362276596472215941024063897591129839055929
</code></pre>
<p>There is also <a href="http://sciencesoft.at/bc/?lang=en" rel="nofollow">an online version</a>. If you want to do it in code you ... |
Is there an equivalent of ComboBoxRenderer for NumericUpDown? <p>I want to draw spinner controls, such as those found on a NumericUpDown, on a custom component. If I want to draw a drop-down button, I can use ComboBoxRenderer. Is there an equivalent of ComboBoxRenderer for NumericUpDown?</p>
| <p>Turns out there is. See the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.visualstyles.visualstyleelement.spin.aspx" rel="nofollow">VisualStyleElement.Spin class</a>.</p>
|
Is SPRING.Net the best framework for Aspect Oriented Programming(AOP)? <p>Please give me the advantages and disadvantages of using the particular framework.</p>
<p>Can give me examples of successes where you have used AOP in you .net applications?</p>
| <p>An older post, but might help you see some of the pro/cons of products and AOP implementations.</p>
<p><a href="http://ayende.com/Blog/archive/2007/07/02/7-Approaches-for-AOP-in-.Net.aspx" rel="nofollow">http://ayende.com/Blog/archive/2007/07/02/7-Approaches-for-AOP-in-.Net.aspx</a></p>
|
Detect when JavaScript is disabled in ASP.NET <p>In the Render method of an ASP.NET web-control, I need to alter the output of the Html based on whether JavaScript is enabled or disabled on the clients browser,</p>
<p>Does anyone know the right incantation to figure that out?</p>
| <p>The problem with using script to check whether javascript is enabled is that you only find that out after the script hasn't run.</p>
<p>Some solutions try the opposite - they use javascript to set a value and then supply Javascript enabled controls if that value is later detected. However, this fails with javascri... |
How do I find a user's Active Directory display name in a C# web application? <p>I'm writing a web application which uses windows authentication and I can happily get the user's login name using something like:</p>
<pre><code> string login = User.Identity.Name.ToString();
</code></pre>
<p>But I don't need their login... | <p>How about this:</p>
<pre><code>private static string GetFullName()
{
try
{
DirectoryEntry de = new DirectoryEntry("WinNT://" + Environment.UserDomainName + "/" + Environment.UserName);
return de.Properties["fullName"].Value.ToString();
}
catch { return nul... |
Apache/Tomcat error - wrong pages being delivered <p>This error has been driving me nuts. We have a server running Apache and Tomcat, serving multiple different sites. Normally the server runs fine, but sometimes an error happens where people are served the wrong page - <strong>the page that <em>somebody else</em> req... | <p>Could it be the thread-safety of your servlets?</p>
<p>Do your servlets store any information in instance members.</p>
<p>For example, something as simple as the following may cause thread-related issues:</p>
<pre><code>public class MyServlet ... {
private String action;
public void doGet(...) {
... |
How to implement a singleton in C#? <p>How do I implement the singleton pattern in C#? I want to put my constants and some basic functions in it as I use those everywhere in my project. I want to have them 'Global' and not need to manually bind them every object I create.</p>
| <p>If you are just storing some global values and have some methods that don't need state, you don't need singleton. Just make the class and its properties/methods static.</p>
<pre><code>public static class GlobalSomething
{
public static int NumberOfSomething { get; set; }
public static string MangleString( s... |
How do I tag a database component in UML? <p>In an UML component diagram, how does one tag or identify a component as a database, so that it's easily recognizable? In the old days there was the cylinder symbol for showing database but that's not part of the UML. Same goes for an application server for instance, how wou... | <p>Just use the <code><<database>></code> for the component diagram.</p>
<p>For a more detailed information check out this article: <a href="http://www.sparxsystems.com.au/resources/uml_datamodel.html" rel="nofollow">http://www.sparxsystems.com.au/resources/uml_datamodel.html</a></p>
|
Team foundation and 64-bit windows, can't install? <p>So is it a certified answer that you can't install Team foundation on windows 2008 64-bit?</p>
<p><b>Update</b></p>
<p>Is it better just do install it on windows 2003 or 2008?</p>
| <p>short answer is <a href="http://blogs.msdn.com/granth/archive/2008/09/15/can-i-run-tfs-on-a-64-bit-os.aspx" rel="nofollow">no</a></p>
<p>Rereading I need to make clear for double negative, read link, official is that you can't but there is a workaround if desired.</p>
|
ASP.NET Menu Parent Menu Item Highlighting on Hover when Flyouts are enabled <p>I have a ASP.Net Menu Control with three levels and flyouts enabled.
I want to highlight the parent items (right upto the top level parent) whenever a user hovers over the menu items.</p>
<p>I do not want to use a client side solution as d... | <p>The only server side solution I can think of would be to set the client side solution on page load. </p>
<p>Is there a reason that you would want to build this server side rather than client side? Because forcing an event like this to occur server side is, by definition, rather inelegant. </p>
|
VS2008 Express: How to save as UTF-8 all files by default? <p>Is there any way to make Visual Studio 2008 Express store all the files as UTF-8 by default?</p>
<p>Thanks for your time.
Best regards.</p>
| <p>If you create a new file inside VS it will be UTF8 by default, but if the file is already created by other enconding you have to "Save as", and then change the enconding by pressing the down arrow in the "Save" button, and then selecting "Save with enconding..."</p>
|
"Simple" SQL Query <p>Each of my clients can have many todo items and every todo item has a due date.</p>
<p>What would be the query for discovering the next undone todo item by due date for each file? In the event that a client has more than one todo, the one with the lowest id is the correct one.</p>
<p>Assuming t... | <p>This question is the classic <strong><em>pick-a-winner for each group</em></strong>. It gets posted about twice a day.</p>
<pre><code>SELECT *
FROM todos t
WHERE t.timestamp_completed is null
and
(
SELECT top 1 t2.id
FROM todos t2
WHERE t.client_id = t2.client_id
and t2.timestamp_completed is null
... |
Bookmarked page redirect <p>I recently converted a site from asp to CF. Unfortunately, alot of the old users had the "homepage" bookmarked. www.example.com/homepage.asp</p>
<p>Is there a sort of catch all way I could redirect any traffic from that page to the current index.cfm?</p>
<p>I would normally just delete t... | <p>Put this in the old homepage.asp</p>
<pre><code><%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "/index.cfm"
%>
</code></pre>
|
Is there any difference between a GUID and a UUID? <p>I see these 2 acronyms thrown around, and I was wondering if there are any differences between a GUID and a UUID?</p>
| <p>The <strong>simple answer</strong> is: <strong>no difference</strong>, they are the same thing. Treat them as a 16 byte (128 bits) value that is used as a unique value. In Microsoft-speak they are called GUIDs, but call them UUIDs when not using Microsoft-speak.</p>
<p>Even the authors of the UUID specification a... |
How to debug ORA-01775: looping chain of synonyms? <p>I'm familiar with the issue behind ORA-01775: looping chain of synonyms, but is there any trick to debugging it, or do I just have to "create or replace" my way out of it? </p>
<p>Is there a way to query the schema or whatever to find out what the current definiti... | <p>As it turns out, the problem wasn't actually a looping chain of synonyms, but the fact that the synonym was pointing to a view that did not exist.</p>
<p>Oracle apparently errors out as a looping chain in this condition.</p>
|
Looking for suggestions for building a secure REST API within Ruby on Rails <p>I'm getting started on building a REST API for a project I'm working on, and it led me to do a little research as to the best way to build an API using RoR. I find out pretty quickly that by default, models are open to the world and can be c... | <p>There are several schemes for authenticating API requests, and they're different than normal authentication provided by plugins like restful_authentication or acts_as_authenticated. Most importantly, clients will not be maintaining sessions, so there's no concept of a login.</p>
<p><strong>HTTP Authentication</str... |
Load multiple external websites into one webpage via re-using ONE IFrame + Ajax <p>I am trying to embed multiple external websites into one web page. Using an IFRAME works ok, but once you get past 10 embedded iframes, the memory fottprint starts to get too big.</p>
<p>So I was thinking, is it possible via ajax/javas... | <p>You are trying to use a hammer to put screws in the wall. Maybe some will go, but it won't be pretty. Your best option would be either a screen scraper or web services in order to retrieve the data from the external sites. Perhaps include more details about the situation such as, are the external sites your own. Do ... |
When using keytool to generate a CSR file, does it have to be generated on the hosting server? <p>I was under the impression that I could run it on any machine, but a guy from our hosting company is saying that the csr has to be generated on the server hosting the site.</p>
<p>Can anyone clear this one up for me?</p>
... | <p>The bottom line is you do not need to generate CSRs on the server hosting an SSL certificate. A CSR is a CSR and you could actually generate it using something like OpenSSL and then import both the key and certificate once it is created into the keystore. The problem is that they probably don't understand now to get... |
How to (de)serialise JSON data in Silverlight using a different name to member variable <p>I have the following members defined in a class that I'm trying to deserialise:</p>
<pre><code>[DataMemberAttribute(Name = "cust_title")]
public String Title { get; set; }
[DataMemberAttribute(Name = "cust_description"... | <p>I've just found the answer out by a bit of trial and error. In order to use the <code>[DataMemberAttribute]</code> you must also put <code>[DataContractAttribute]</code> above your class definition:</p>
<pre><code>[DataContractAttribute]
public class MyClass
{
[DataMemberAttribute(Name="test_test")]
public Stri... |
Available Build Tools (make, etc)? <p>There's a lot of questions on here regarding various niche build needs (.NET, continuous integration, etc) but, of course, my niche need is different.</p>
<p>Rather than asking a very specific question right now, I'd like a survey of available build tools (such as make, ant, etc) ... | <p><a href="http://www.scons.org/" rel="nofollow">SCons</a></p>
<p>Build scripts are Python scripts. Supposed to work on Linux, Windows, Mac OS X.</p>
|
Matlab copy constructor <p>Is there a better way to implement copy construcor for matlab for a handle derived class other than adding a constructor with one input and explicitly copying its properties?</p>
<pre><code>obj.property1 = from.property1;
obj.property2 = from.property2;
</code></pre>
<p>etc.</p>
<p>Thank... | <p>If you want a quick-and-dirty solution that assumes all properties can be copied, take a look at the PROPERTIES function. Here's an example of a class that automatically copies all properties:</p>
<pre><code>classdef Foo < handle
properties
a = 1;
end
methods
function F=Foo(rhs)
if nargin==0... |
Images & Hyperlink Borders - Ghost 1px x 1px Border <p>I've an image that is wrapped in an anchor tag that, through jQuery, triggers an action somewhere else on the page. When I click on the image, two tiny 1px by 1px boxes show up in the upper and lower left corners of the image.</p>
<p>My CSS styles explicitly stat... | <p>Is your anchor tag under or overlining?</p>
<p>Set the a and a:hover in that situation to text-decoration: none.</p>
<p>Happened to me, and the reason it was two tiny boxes is because the width of the element didn't quite extend, or something.</p>
<p>Good luck!</p>
<p>D'oh: I see it's upper- and lower- LEFT boxe... |
ASP.NET aspx page code runs impersonated though impersonation is disabled <p>I have a blank test app created in VS 2005 as ASP.NET application. <a href="http://msdn.microsoft.com/en-us/library/ms998351.aspx" rel="nofollow">MSDN says</a> that </p>
<blockquote>
<p>By default, ASP.NET does not use impersonation, and yo... | <p>Seems odd, A few things to try:</p>
<ul>
<li>While in on a breakpoint in Debug type $user in a watch window, that will show you the process and thread identities.</li>
<li><p>Your use of impersonate is incorrect, try this code:</p>
<pre><code>// Declare the logon types as constants
const long LOGON32_LOGON_INTERAC... |
Retrieving python module path <p>I want to detect whether module has changed. Now, using inotify is simple, you just need to know the directory you want to get notifications from.</p>
<p>How do I retrieve a module's path in python?</p>
| <pre><code>import a_module
print a_module.__file__
</code></pre>
<p>Will actually give you the path to the .pyc file that was loaded, at least on Mac OS X. So I guess you can do</p>
<pre><code>import os
path = os.path.dirname(amodule.__file__)
</code></pre>
<p>You can also try</p>
<pre><code>path = os.path.abspath(... |
Override Default Constructor of Partial Class with Another Partial Class <p>I don't think this is possible, but if is then I need it :)</p>
<p>I have a auto-generated proxy file from the wsdl.exe command line tool by Visual Studio 2008.</p>
<p>The proxy output is partial classes. I want to override the default constr... | <p>I had a similar prolem, with my generated code being created by a dbml file (I'm usng Linq-to-SQL classes).</p>
<p>In the generated class it calls a partial void called OnCreated() at the end of the constructor.</p>
<p>Long story short, if you want to keep the important constructor stuff the generated class does f... |
Is there a free Visual Studio addin for Nunit? <p>I'm cheap and don't want to pay for ReSharper or TestDriven.NET, is there a free visual Studio addin for NUnit?</p>
| <p>You can create a blank project (Choose console application for example) and in the property of the project you can select DEBUG tag and select "Start External Program". Put the path of Nunit. Than, in the start option, the command line arguments select the DLL that contain all your test (mine is always in the nunit\... |
Lisp DO variable syntax reasoning <p>In Peter Seibel's <em>Practical Common Lisp</em>, he gives this example:</p>
<pre><code>(do ((nums nil) (i 1 (1+ i)))
((> i 10) (nreverse nums))
(push i nums))
</code></pre>
<p>I can see how it works, using nums inside the loop but not giving it a step-form. Why would yo... | <p>Because it's convenient and saves indentation. Furthermore, the accumulator conceptually belongs to the loop, so why not put it there?</p>
|
Using "this" with jQuery Selectors <p>I have some HTML that looks like this:</p>
<pre><code><ul class="faq">
<li class="open">
<a class="question" href="">This is my question?</a>
<p>Of course you can, it will be awesome. </p>
</li>
</ul>
</code><... | <p>Try using: </p>
<pre><code>$(this).siblings('p').css()
</code></pre>
|
Config values in DB or File? <p>I have some configuration values for an asp.net web app. They will be maintained by a system admin once the system goes live. Should I store these values in the database or in a config file? Is there a best practice for this sort of thing?</p>
| <p>It's easy and convenient to create a robust interface to edit the values in the database.</p>
<p>It's less easy to create a good one for the config file.</p>
<p>So I would usually you want to store everything which you would like your users/administrators to be able to edit later in the database. Everything which ... |
How do I change the locale that JasperReports uses? <p>The windows installed on my machine has the locale <code>en_AU</code> and that's what JasperReports uses. I already tried changing the locale of all users, including the Administrator but it still uses <code>en_AU</code>.</p>
<p>How can I change that locale? Is it... | <p>The locale is set during execution, not in the JRXML.</p>
<p>Using Java, set the <code>REPORT_LOCALE</code> parameter for the report's parameter map. For example:</p>
<pre><code>InputStream reportTemplate = getReportTemplate();
JRDataSource dataSource = getDataSource();
java.util.Map parameters = getParameters();... |
Finding composite numbers <p>I have a range of random numbers. The range is actually determined by the user but it will be up to 1000 integers. They are placed in this:</p>
<pre><code>vector<int> n
</code></pre>
<p>and the values are inserted like this:</p>
<pre><code>srand(1);
for (i = 0; i < n; i++)
... | <p>In this code:</p>
<pre><code>if(i % v[j] == 0)
cout << v[j] << endl;
</code></pre>
<p>You are testing your index to see if it is divisible by v[j]. I think you meant to do it the other way around, i.e.:</p>
<pre><code>if(v[j] % i == 0)
</code></pre>
<p>Right now, you are printing random divisors o... |
What are good ways to design or diagram state? <p>The issue that prompted me to ask this is a web form that was not persisting data the way I expected it to. That's vague, but the point is, what do you like to do to model state, flow of data, and so forth?</p>
| <p>I'll second the whiteboard answer and add that explaining what is <em>supposed</em> to be happening, following by verbalizing what the the code is <em>actually</em> doing, along with a basic graphic is hugely helpful for any project.</p>
|
Bash script, match on dates like? <p>I'm writing a script to remove some build artifacts older than 1 week. </p>
<p>The files have names in the form <em>artifact-1.1-200810391018.exe</em>.</p>
<p>How do I go about removing only the files that are greater than 1 week old, excluding the time in hours and minutes at the... | <p>You mean, something along the line of:</p>
<pre><code>find /path/to/files -name "artifact*" -type f -mtime +7 -exec rm {} \;
</code></pre>
<p>?</p>
|
Netbeans GUI Designer & Fixed-Size Application Panels <p>I'm having a problem, creating a fixed-size overall panel for a touchscreen GUI application that has to take up the entire screen. In a nutshell, the touchscreen is 800 x 600 pixels, and therefore I want the main GUI panel to be that size.</p>
<p>When I start a... | <p>Have you tried <a href="http://java.sun.com/docs/books/tutorial/extra/fullscreen/index.html" rel="nofollow">java full screen mode</a>?</p>
|
Does the concept of shared sessions exist in ASP.NET? <p>I am working on a web application (ASP.NET) game that would consist of a single page, and on that page, there would be a game board akin to Monopoly. I am trying to determine what the best architectural approach would be. The main requirements I have identified... | <p>You could use the ASP.Net Cache or the Application state to store the game object since these are shared between users. The cache would probably be the best place since objects can be removed from it to save memory. </p>
<p>If you store the game object in cache using a unique key you can then store the key in each ... |
Is there something between a normal user account and root? <p>I'm developing an application that manages network interfaces on behalf of the user and it calls out to several external programs (such as ifconfig) that requires root to make changes. (Specifically, changing the IP address of a local interface, etc.) During... | <p>Your idea about the daemon has much merit, despite the complexity it introduces. As long as the actions don't require some user interface interaction <em>as root</em>, a daemon allows you to control what operations are allowed and disallowed.</p>
<p>However, you can use SUDO to create a controlled compromise betwee... |
VB6 Editor changing case of variable names! <p>I'm not much of a Visual Basic person, but I am tasked with maintaining an old VB6 app. Whenever I check out a file, the editor will replace a bunch of the uppercase variable names with lowercase automatically. How can I make this stop!? I don't want to have to change t... | <p>Continuing from <a href="http://stackoverflow.com/questions/248760/vb6-editor-changing-case-of-variable-names#248773">DJ's answer</a>...</p>
<p>And it won't only change the case of variables in the same scope either.</p>
<p>It will change the case of all variables with the same name in your entire project. So even... |
How can I enable set the timeout on file uploads in SWF to greater than 3 min? <p>I'm using SWFUpload to handle file uploads and have run into a problem where any file upload >= 3 min will time out. As far as I can tell, Apache and PHP are configured properly to handle large files. Are there any settings with Flash tha... | <p>If the PHP script is timing out, then you can adjust the php time_limit by calling set_time_limit(int seconds). If you set it equal to -1 then the script will execute indefinitely, if that's what you want / need.</p>
<p>If the Flash is timing out, you might want to take a look at the following:</p>
<p><a href="htt... |
Python: using a recursive algorithm as a generator <p>Recently I wrote a function to generate certain sequences with nontrivial constraints. The problem came with a natural recursive solution. Now it happens that, even for relatively small input, the sequences are several thousands, thus I would prefer to use my algori... | <pre><code>def getPermutations(string, prefix=""):
if len(string) == 1:
yield prefix + string
else:
for i in xrange(len(string)):
for perm in getPermutations(string[:i] + string[i+1:], prefix+string[i]):
yield perm
</code></pre>
<p>Or without an accumulator:</p>
<pr... |
Shortcut for commenting CSS in VS 2008 <p>When I press the standard Ctrl + E, C (an other variants) in VS2008 whilst editing a CSS file, it says that command is not available. How do I setup a shortcut to apply a plain old /* */ comment to selected text in VS? Thanks</p>
| <p>Within Visual Studio, hit Alt-F11 to open the Macro IDE and add a new module by right-clicking on MyMacros and selecting Add|Add Module...</p>
<p>Paste the following in the source editor:</p>
<pre><code>Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module Commen... |
Summarize aggregated data <p>I have a table like as follows:</p>
<pre>
SoftwareName Count Country
Project 15 Canada
Visio 12 Canada
Project 10 USA
Visio 5 USA
</pre>
<p>How do I query it to give me a summary like...</p>
<pre>
SoftwareName Canada ... | <pre><code>SELECT SoftwareName,
SUM( CASE Country WHEN 'Canada' THEN [Count] ELSE 0 END ) AS Canada,
SUM( CASE Country WHEN 'USA' THEN [Count] ELSE 0 END ) AS USA,
SUM( [Count] ) AS Total
FROM [Table]
GROUP BY SoftwareName;
</code></pre>
|
How do I make UITableViewCellAccessoryDisclosureIndicator visible in black background? <pre><code>cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
</code></pre>
<p>in this method</p>
<pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
</c... | <p>I ran into this same issue, and just create a UIImageView out of a UIViewâs imageWithName @"AccDisclosure.png" using the following hastily mocked-up graphic which you're free to copy: <a href="http://thinkingman.com/db/downloads/AccDisclosure.png">http://thinkingman.com/db/downloads/AccDisclosure.png</a> (if you j... |
Django: Arbitrary number of unnamed urls.py parameters <p>I have a Django model with a large number of fields and 20000+ table rows. To facilitate human readable URLs and the ability to break down the large list into arbitrary sublists, I would like to have a URL that looks like this:</p>
<pre><code>/browse/<name1... | <p>A possibility that you might consider is matching the entire string of possible values within the url pattern portion and pull out the specific pieces within your view. As an example:</p>
<pre><code>urlpatterns = patterns('',
url(r'^browse/(?P<match>.+)/$', 'app.views.view', name='model_browse'),
)
def ... |
What is the fastest webserver solution with the lowest memory footprint? <p>I need a webserver to serve up very simple POST/GET requests as JSON. I don't need MVC, Rails, Django. I need something that takes up very little memory, preferrably around 5K per reqeust. The webserver will talk to backend services like Scr... | <p>I've had a good experience with nginx (<a href="http://nginx.net/" rel="nofollow">http://nginx.net/</a>), that said, when choosing a webserver, you should look closely at your requirements and make an informed decision as these things can be very application specific.</p>
<p>You'll notice that in this question that... |
What is the best .net Micro Framework dev board, for under $300? <p>I'm looking for a relativity cheap .net Micro Framework development board for use on a personal robotics project. I'd don't need much for I/O, but I want at least one serial port and one Ethernet port. </p>
<p>I would prefer not to have to spend more ... | <p>This looks very cool. And only 30$.</p>
<p><a href="http://www.netduino.com/">http://www.netduino.com/</a></p>
<p>And this Plus version with ethernet.</p>
<p><a href="http://www.netduino.com/netduinoplus/specs.htm">http://www.netduino.com/netduinoplus/</a></p>
|
Translate SVN path to local file system path in Python <p>I'm writing a utility in Python that will attach changed files in Subversion to an email and send it when a subset of folders that are under source control in SVN have been changed. I am using the pysvn library to access the repository.</p>
<p>I have a copy of... | <p>Stay with the slice operator, but do not change the loop variable inside the loop. for fun, try the generator expression (or keep the listcomp).</p>
<pre><code>baselen = len(self.basePath)
return (path[baselen:].replace("/", "\\") for path in paths)
</code></pre>
<p>Edit: `lstrip()' is not relevant here. From the ... |
unions declaration C code <p>I have seen some declaration of a union inside a struct as follows. Example code given below.</p>
<p>My questions is does it help in any memory savings(typical use for which a union is used for)? I do not see the benefit. </p>
<pre><code>typedef struct
{
int x1;
unsigned int x2;
... | <p>This is not a typical use for a union at all. Unions are variant types - you can put many different kind of types into them and retrieve them. <strong>Putting only one type into a union gives you nothing</strong>, except weird looking code.</p>
|
Debugging a Direct3D Model <p>I am trying to render a model in Direct3D using <code>DrawIndexedPrimitives</code>. However, I am not able to see it on screen. What are the usual methods used to debug a Direct3D model?</p>
<p>I've tried the following:</p>
<ul>
<li>Switched off back face culling</li>
<li>Used <code>Prim... | <p>Use PIX tool from DX SDK. It's <em>absolutely awesome</em>.</p>
<p>Probably you'll want to use single frame capture mode. Then on the draw call PIX will show the model before vertex processing takes place, after vertex processing takes place, complete state of your device, resulting pixels rendered, etc.</p>
|
Prevent long word to add horizontal scroll to html view <p>On Windows Mobile, I am displaying my output in HTML. This includes lots of user-generated strings. Occasionally there are situations where a really large string is part of the output that has no whitespaces or punctuation. </p>
<p>Unfortunately the Windows Mo... | <p>Besides the shy hypen as mentioned by nickf, you can always use CSS to hide overshooting words by settings the box's style to <code>overflow: hidden</code>. Good news: no scrollbar, ma. Bad news: word is cut. For the shy hypen, I wouldn't go with the entity, though. Instead, use the character directly in your text: ... |
JavaME: Convert String to camelCase <p>What would be a simple implementation of a method to convert a String like "Hello there everyone" to "helloThereEveryone". In JavaME support for String and StringBuffer utility operations are quite limited.</p>
| <p>Quick primitive implementation. I have no idea of restrictions of J2ME, so I hope it fits or it gives some ideas...</p>
<pre><code>String str = "Hello, there, everyone?";
StringBuffer result = new StringBuffer(str.length());
String strl = str.toLowerCase();
boolean bMustCapitalize = false;
for (int i = 0; i < s... |
Looking for a better way than virtual inheritance in C++ <p>OK, I have a somewhat complicated system in C++. In a nutshell, I need to add a method to a third party abstract base class. The third party also provides a ton of derived classes that also need the new functionality.</p>
<p>I'm using a library that provides ... | <p>Why does this class need to derive from shape?</p>
<pre><code>class ImprovedShape : public virtual Shape
{
virtual double GetArea() const = 0;
};
</code></pre>
<p>Why not just have</p>
<pre><code>class ThingWithArea
{
virtual double GetArea() const = 0;
};
</code></pre>
<p>ImprovedSquare is a Shape and ... |
How to present credentials in order to open file? <p>How do I specify the username and password in order for my program to open
a file for reading?
The program that needs to access the file is running from an account that
does not have read access to the folder the file is in.
Program is written in C# and .NET 2, runni... | <p>You want to impersonate a user who does have the rights to access the file.</p>
<p>I recommend using a class like this - <a href="http://www.codeproject.com/KB/cs/zetaimpersonator.aspx">http://www.codeproject.com/KB/cs/zetaimpersonator.aspx</a>. It hides all the nasty implementation of doing impersonation.</p>
<pr... |
How can I record what process or kernel activity is using the disk in GNU/Linux? <p>On a particular Debian server, iostat (and similar) report an unexpectedly high volume (in bytes) of disk writes going on. I am having trouble working out which process is doing these writes.</p>
<p>Two interesting points:</p>
<ol>
<... | <p>iotop is good (great, actually). </p>
<p>If you have a kernel from before 2.6.20, you can't use most of these tools.</p>
<p>Instead, you can try the following (which should work for almost any 2.6 kernel IIRC):</p>
<pre>
sudo -s
dmesg -c
/etc/init.d/klogd stop
echo 1 > /proc/sys/vm/block_dump
rm /tmp/disklog
... |
How do I add fitnesse pages to version-control? <p>What is the recommended practice? Should I add the my sub-folder under the fitnesse folder to version control? </p>
<p><em>Context: working on a single developer rails pet project. I've my rails project under version-control (Subversion) however my fitnesse wiki pa... | <p>Use the <code>-d</code> switch (<em>which is surprisingly low profile on a google search</em>)</p>
<pre><code>Fitnesse20081201>run -p 8080 -d c:/projects/MyProjectNeedsAcceptanceTests
</code></pre>
<p>This will create a subfolder in the specified folder called FitnesseRoot if it doesn't already exist, with all ... |
Efficient way to recursively calculate dominator tree? <p>I'm using the Lengauer and Tarjan algorithm with path compression to calculate the dominator tree for a graph where there are millions of nodes. The algorithm is quite complex and I have to admit I haven't taken the time to fully understand it, I'm just using it... | <p><a href="http://www.boost.org/doc/libs/1_36_0/libs/graph/doc/lengauer_tarjan_dominator.htm"><code>boost::lengauer_tarjan_dominator_tree_without_dfs</code></a> might help.</p>
|
How to convert a Unix timestamp to DateTime and vice versa? <p>There is this example code, but then it starts talking about millisecond / nanosecond problems.</p>
<p>The same question is on MSDN, <em><a href="http://blogs.msdn.com/brada/archive/2004/03/20/93332.aspx">Seconds since the Unix epoch in C#</a></em>.</p>
<... | <p>Here's what you need:</p>
<pre><code>public static DateTime UnixTimeStampToDateTime( double unixTimeStamp )
{
// Unix timestamp is seconds past epoch
System.DateTime dtDateTime = new DateTime(1970,1,1,0,0,0,0,System.DateTimeKind.Utc);
dtDateTime = dtDateTime.AddSeconds( unixTimeStamp ).ToLocalTime();
... |
Align element under other element through css <p>I have a really simple search form with the following</p>
<ul>
<li>Label ("Search")</li>
<li>Textbox (fixed width)</li>
<li>Submit button</li>
<li>"Advanced" link</li>
</ul>
<p>Label, textbox and submit are all on one horizontal line and centered.
Now I would like my a... | <p>If I understand the question you want:</p>
<pre><code> Search [xxxxxxxxxxxxxxxx] [Submit]
Advanced
</code></pre>
<p>You'll have to add some more elements in to do that:</p>
<pre><code><div style="width: 300px; margin: auto; text-align: center;">
Searc... |
Restrict adding control on Panel <p>How can i restrict adding controls in Panel in C# window controls? I have to restrict user to add controls in a panel at design time.</p>
| <p>If you want to limit the types of controls or number of controls one can add to the panel you can make your own subclass of the panel and check the Control type or Control count in an overload of the Controls.Add method. </p>
<p>Edit: Overloading the Controls.Add method was not as easy as I thought, but you can mak... |
An alternative to alert/confirm/error dialogs? <p>We all know that alerts are bad. If you didn't know it read <a href="http://www.codinghorror.com/blog/archives/000114.html" rel="nofollow">this</a></p>
<p>Alerts are used to communicate with the user. So if we don't use them what is a good alternative? </p>
<p>I'd lik... | <p>Hereâs the hierarchy for dealing with user errors or warnings, applied to validating user input to a field.</p>
<ol>
<li><p>Remove the element that may result in an error. Do you really need the userâs birth date? Can you get by just as well with something else that wonât require validation, such as option bu... |
Best programming methodology for very fast timeline and little requirements? <p>What is a good programming methodology for custom applications that need to be coded very fast and very customized? I realize the lack of requirements is a problem no matter what. Also how do you convince management to change their practi... | <p>run... like hell</p>
|
Is asp.net session information stored in a cookie? <p>If I write <code>Session["asdf"] = 234;</code></p>
<p>In my asp.net web app, does this mean the client will have a cookie stored on their browser?</p>
| <p>Yes, but 234 won't be stored in the cookie. The cookie will only contain a unique ID (for example, <code>lit3py55t21z5v55vlm25s55</code>). Every time ASP.NET sees that unique ID, it will look up the corresponding session information.</p>
<p>If you don't want to use cookies, you can put the session ID in the URL. Re... |
ASP.NET Ajax: close window after Ajax call? <p>I'm using ASP.NET Ajax. How can I <strong>tell the browser to close the current window</strong> after the server call finishes (server-side code)?</p>
<p>I managed to do this using the ASP.NET Ajax's ScriptManager method "RegisterDataItem" in the server method (inside a b... | <p>If I understood you right, registering <code>window.close()</code> with <code>ScriptManagers</code> <code>RegisterStartupScript</code> method on event handler should work. For details on using <code>ScriptManager.RegisterStartupScript</code> see <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.scriptma... |
Single instance Amazon EC2 <p>We're running a lightweight web app on a single EC2 server instance, which is fine for our needs, but we're wondering about monitoring and restarting it if it goes down.</p>
<p>We have a separate non-Amazon server we'd like to use to monitor the EC2 and start a fresh instance if necessary... | <p>You should have a look at <a href="http://reductivelabs.com/trac/puppet/wiki/PuppetIntroduction">puppet</a> and its support for <a href="http://reductivelabs.com/trac/puppet/wiki/Recipes/AmazonWebService">AWS</a>. I would also look at the <a href="http://rightaws.rubyforge.org/">RightScale AWS library</a> as well as... |
Capistrano: How to Include common settings in multiple project deploy.rb files <p>this is probably a newbie ruby question. I have several libraries and apps that I need to deploy to several different hosts. All of the apps and libs will share some common settings for those hosts-- e.g. host name, database server/user/p... | <p>I just experimented with it a little more and what I discovered is that you have to:</p>
<pre><code>load 'config/my_module'
</code></pre>
<p>I can put all of my common definitions here and just load it into my deploy.rb.</p>
<p>It appears from the docs that load loads and executes the file. Alternatively, require... |
Correct approach to Properties <p>I am working in Java on a fairly large project. My question is about how to best structure the set of Properties for my application.</p>
<p>Approach 1: Have some static Properties object that's accessible by every class. (Disadvantages: then, some classes lose their generality shou... | <p>I like using Spring dependency injection for many of the properties. You can treat your application like building blocks and inject the properties directly into the component that needs them. This preserves (encourages) encapsulation. Then, you assemble your components together and create the "main class". </p... |
JS Regex For Human Names <p>I'm looking for a good JavaScript RegEx to convert names to proper cases. For example:</p>
<pre><code>John SMITH = John Smith
Mary O'SMITH = Mary O'Smith
E.t MCHYPHEN-SMITH = E.T McHyphen-Smith
John Middlename SMITH = John Middlename SMITH
</code></pre>
<p>Well you get the idea.</p>
... | <p>Something like this?</p>
<pre><code>function fix_name(name) {
var replacer = function (whole,prefix,word) {
ret = [];
if (prefix) {
ret.push(prefix.charAt(0).toUpperCase());
ret.push(prefix.substr(1).toLowerCase());
}
ret.push(word.charAt(0).toUpperCase())... |
Is it possible to communicate with a sub subprocess with subprocess.Popen? <p>I'm trying to write a python script that packages our software. This script needs to build our product, and package it. Currently we have other scripts that do each piece individually which include csh, and perl scripts. One such script is ru... | <p>I would choose to go with Pexpect. </p>
<pre><code>import pexpect
child = pexpect.spawn ('sudo mod -p -c noresource -u dtt -Q')
child.expect ('First question:')
child.sendline ('Y')
child.expect ('Second question:')
child.sendline ('Yup')
</code></pre>
|
Lean Software (Webapplication) Release Engineering <p>I'm looking to re-organize the way we release our internal software. All of the code (PHP webapps, some Java apps and Perl scripts) is checked into Subversion repositories but there are no branches or tags, everything is checked into trunk (only around 1-3 devs per ... | <p>Use tags and branches; make it a part of the development cycle. When you update that "stable-1.0" branch, have tested the change(s) and tagged it "release-1.0.5", you simply do "svn switch" on the server to the new tag. Didn't work, despite having tested it? Switch back, and figure out what's wrong.</p>
<p>But ... |
Weird IE & Javascript issue <p>So I'm creating some HTML using javascript based on where the user clicks on the page. On page load the script replaces an empty div with a ul and some data. The user clicks on that data to receive more and so on. Now when the user navigates off the page and then hits the back button to g... | <p>It sounds like you need to manage the history and state of your page. Check our Brad Neuberg's <a href="http://code.google.com/p/reallysimplehistory/" rel="nofollow">Really Simple History</a>.</p>
|
How do you bind the TextWrapping property of a TextBox to the IsChecked value of a MenuItem? <p>The TextWrapping property of the TextBox has three possible values:</p>
<ul>
<li>Wrap</li>
<li>NoWrap</li>
<li>WrapWithOverflow</li>
</ul>
<p>I would like to bind to the IsChecked property of a MenuItem. If the MenuItem i... | <p>If you want to do this all in xaml you need to use a <a href="http://msdn.microsoft.com/en-us/library/system.windows.style.aspx">Style</a> and a <a href="http://msdn.microsoft.com/en-us/library/system.windows.datatrigger.aspx">DataTrigger</a>.</p>
<pre><code><StackPanel>
<CheckBox x:Name="WordWrap">... |
right approach to handling bad xml data <p>I've got a little c# windows service that periodically pulls xml from a web service and stores the data in a database table.</p>
<p>Unfortunately it's failing because the web service has occasional bad data in it - strings instead of decimals. I don't have any control over t... | <blockquote>
<p>Pre-process the XML provided by the
web service before loading into the
validating XML reader, removing any
bad nodes entirely.</p>
</blockquote>
<p>This is the option I would choose, it would allow you to grab the bad input before the exception and store it somewhere so it can be looked at lat... |
Using QSortFilterProxyModel with a tree model <p>I have a QDirModel whose current directory is set. Then I have a QListView which is supposed to show the files in that directory. This works fine. Now I want to limit the files shown, so it only shows png files (the filename ends with .png). The problem is that using a Q... | <p>We ran into something similar where I work, and ended up making our own proxy model to do our filtering. However, looking through the documentation for what you want (which seems like it would be a more common case), I came across two possibilities.</p>
<ol>
<li>You might be able to set a name filter on the QDirMo... |
How do I find the length (size) of a binary blob in sqlite <p>I have an sqlite table that contains a BLOB file, but need to do a size/length check on the blob, how do I do that?</p>
<p>According to some documentation I did find, using length(blob) won't work, because length() only works on texts and will stop counting... | <p>haven't had this problem, but you could try <code>length(hex(glob))/2</code></p>
<p><strong>Update (Aug-2012):</strong>
For SQLite 3.7.6 (released April 12, 2011) and later, <code>length(blob_column)</code> works as expected both both text and binary data.</p>
|
Detect a âError: Object doesn't support this property or methodâ <p>The object Iâm working on is instantiated in JavaScript, but used in VBScript. In one code path, the variable <code>M.DOM.IPt</code> is defined and has a value, in the other however it is not. I need to detect if it has been defined or not. I che... | <pre><code>On Error Resume Next
Err.Clear
MyVariable=M.DOM.Ipt
If Err.Number<> 0 Then
'error occured - Ipt not defined
'do your processing here
Else
'no error - Ipt is defined
'do your processing here
End If
</code></pre>
|
How can one open a PNG (image) file with VB6 into an RGB array, or R, G, B arrays <p>How can one open a PNG formatted image file with VB6? Ideally, I (that is my customer) would like to have the PNG file open and placed into seperate R(ed), G(reen) and B(lue) arrays.</p>
<p>VB6 is not my tool of choice (for lack of k... | <p>Thanks for the link, although not being a fluent VB guy (more C & ASM flavours), the code appears to be very BMP centric; not PNG. </p>
<p>If that's the case, I have to believe you suggested the link because it would be a simple matter to make the code PNG'able, but I wouldn't know how to approach that.</p>
|
Share Styling Between CSS Classes <p>In <a href="http://stackoverflow.com/questions/226206/alternating-item-style">this question</a>, I was given a really cool answer to alternating an image and its description between left and right, respectively. Now I want to apply styling to both, e.g. padding-top, padding-bottom ... | <p>Here's how you do it:</p>
<pre><code>.ProductAltItemStyle, .ProductItemStyle {
// CSS Rules that apply to both go here
}</code></pre>
|
Is it possible to execute SQL commands and send MSMQ messages in a TransactionScope? <p>I'm investigating using MSMQ for my team's new project but I need to know if I can send MSMQ messages and execute SQL commands within a System.Transactions.TransactionScope and have them commit or rollback together. I can't find a r... | <p>From personal experience I know the TransactionScope works great with SQL. I'm not too familiar with MSMQ but a quick <a href="http://www.google.com/search?q=msmq+transactionscope" rel="nofollow">Google search</a> shows some examples (normally forum discussions) where it looks like it's working successfully. The Sys... |
An example for using DBMS_AQ.POST and explanation of its utility <p>The DBMS_AQ package has a method called POST. </p>
<p>The documentation says,</p>
<blockquote>
<p>This procedure posts to a list of
anonymous subscriptions, allowing all
clients who are registered for the
subscriptions to get notifications of... | <p>The first that springs to mind is that you may have a large number of client applications interested in the DB information. Some system triggers an event that updates the database with useful, but not so important information (e.g. total count of rows in a table that is shown to the user).</p>
<p>It then wants to b... |
VIM visual mode: highlight last 2 chars in each line? <p>I like Vim's visual mode. <kbd>v</kbd> for highlight/select chars or lines, <kbd>Ctrl</kbd><kbd>v</kbd> for rectangle highlighting, as far as I know (I am a beginner). Is there any way to use visual mode to highlight last two chars, for example, on each line for ... | <p>My approach to this sort of problem is to use line selection (shift-V, cursor movement) to select the lines-of-interest, then type:</p>
<pre><code> :s/..$//
</code></pre>
<p>That's a substitution, using the regex <code>..$</code> which will match the last two characters at the end of the line. Then substitute 'not... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.