input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
How to pass a method as parameter without declaring a delegate in .NET <p>No matter how I try, I cannot mimic the clean syntax of Rhino Mocks, without declaring a delegate.</p>
<p>Example:</p>
<pre><code>Expect.Call(service.HelloWorld("Thanks"))
</code></pre>
<p>Do you have any idea on how to do this?</p>
<p>Thanks... | <p>You could use the Action delegate provided in newer versions of .NET</p>
<pre><code>void Execute(Action action) {
action();
}
void Test() {
Execute(() => Console.WriteLine("Hello World!"));
}
</code></pre>
|
sql userid + name + profile optimize question <p>Chances are i will need to do a lot of userid->username lookups. So i was thinking, instead of having a table like the below</p>
<pre><code>userid int PK
username text
userpass_salthash int
user_someopt1 int
user_sig text
</code></pre>
<p>to have it broken up as the be... | <p>You should do the first option (single table) for both normalization and performance. </p>
<p>Performance:</p>
<ul>
<li>If you put an index on <code>(UserId, Username)</code>, you'll have a covering index - so you won't ever need to go to the table to get the Username anyway. </li>
<li>If you put your clustered in... |
CGAL inheritance <p>How can I use an inherited class of a triangulation in the context of a triangulation in CGAL?</p>
<p>Basically I have the following code:</p>
<pre><code>typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_with_info_2<int,K> Vb;
typedef CGA... | <p>I checked your program, you would need to reformat it a bit, so that it fits the generic programming model. Let me recall what your code does (the one available at <a href="http://github.com/gjorquera/triangle-mesh/blob/6eb7e304a486a1a3de47ac9264a322b5cf7bc4c1/main.cpp" rel="nofollow">github</a>):</p>
<ol>
<li>read... |
Installing ASP.Net Framework 3.5 on Server (From 2.0) <p>I want to upgrade the Windows 2003 x86 server which is running ASP.NET 2.0, to support ASP.NET 3.5</p>
<p>Which file / files do I need? </p>
<p>Do I need to install 3.0 first, then 3.5, then 3.5 SP1, or will the full download of 3.5 SP1 (dotnetfx35.exe 3.5.3072... | <p>Installing 3.5 SP1 by itself will add everything you need. I don't think live applications will be interrupted, but performance might be impacted while the installer is running. Be sure to run Microsoft Update after as well for any post SP1 updates that might be needed.</p>
|
Automatically detect the server's proxy settings in PHP <p>I have a PHP script which is running on a windows server. The script creates a soapclient object which can be given proxy_host and a proxy_port. Rather than hardcoding these values or making them a config option, I'd like the PHP script to automatically detec... | <p>I don't believe this is currently possible, given the wide range of possible proxy configurations. Typically, components (such as payment gateways) provide configuration settings for proxy information (usually in the php.ini file) where you could set these. Otherwise, if you're running on a *Nix based environment,... |
CodeSmith v.s. T4: .netTiers level suite <p>Has someone ported the netTiers template set to Visual Studio's T4 templates? Or is there a system of similar scope? Does anyone use T4 in a work environment? What (if any) major differences are there between Codesmith and T4? </p>
| <p>I dabbled in T4 for a bit - hey, if it's free and included in VS2008, use it, right?</p>
<p>My basic idea was to create a set of templates to read a database table, and create our own "roll-your-own" ORM classes from it. </p>
<p>I gave up on T4, frustrated and unable to get even the most basic things to work that ... |
C++ Not Installed In Cygwin <p>I just installed Cygwin. And I can launch a bash shell from windows, do "ls", "emacs", "vi" , etc. However, when I do "g++" it says command not found.</p>
<p>I thought g++ was installed by default in Cygwin? If that's not the case, what is the exactly categories under which I can add g++... | <p>Did you install the <code>Devel</code> packages?</p>
<p>I would suggest you read <a href="http://www.horstmann.com/ccc/help/cygwin/install.html">this tutorial</a> to get up and running.</p>
|
Without using trace, how to tell if flash application is in a container? <p>I'm trying to determine if my flash content is inside a container. I have no idea what this means, but apparently it's bad for making ExternalInterface.calls. I'm developing the site on a linux machine I'm running the server on and I'm working ... | <p>You should really spend an afternoon with the docs for flash player's security and javascript stuff. I think it would really help you in understanding how this all works.</p>
<p>Some clarification is needed for your q:</p>
<p>You say you are running a server on your linux box, but your swf is on a windows machine?... |
Interface design using C# Generics <p>I am currently designing a class library that will provide data to a web application graph rendering engine in C#. I am currently defining the interfaces of this library. </p>
<p>I have a IGraphData interface which I would like to cache using a service that accesses the cache, th... | <p>Why don't you just make the interface generic instead?</p>
<pre><code>interface ICacheService<T> {
T Get(string identifier);
void Set(T graphData);
}
</code></pre>
<p>if you wanted, you could type-constrain T to be of type IGraphData, or you could write it as:</p>
<pre><code>interface IGraphDataCach... |
WPF ListBox Selection Problem when changing an item <p>When changing the selected item in a ListBox, I'm getting a weird error where the changed item appears selected but I cannot deselect it or reselect it.</p>
<p>Is there a way to fix this?</p>
<p>Here's a sample app that demonstrates the problem.</p>
<pre><code>p... | <p>After searching a bit more I found the solution. Adding an IsSynchronizedWithCurrentItem to the ListBox solved the problem.</p>
<pre><code><ListBox
x:Name="lst"
ItemsSource="{Binding Items}"
IsSynchronizedWithCurrentItem="True"
/>
</code></pre>
|
Avoiding a nested subquery in SQL <p>I have a SQL table that contains data of the form:</p>
<p>Id int
EventTime dateTime
CurrentValue int</p>
<p>The table may have multiple rows for a given id that represent changes to the value over time (the EventTime identifying the time at which the value changed).</p>
<p>Given ... | <p>Here is my first go:</p>
<pre><code>select ids.Id, count( distinct currentvalue)
from ids
join valuehistory vh on ids.id = vh.id
where vh.eventtime < @StartTime
group by ids.id
</code></pre>
<p>However, I am not sure I understand your table model very clearly, or the specific question you are trying to solve.</... |
Is there a PHP script that can convert HTML table data to various formats? <p>Using PHP, I can convert MySQL data or static table data to csv, Excel, JSON, MySQL etc but is there a useful conversion script or tool that can convert table data into other formatted/styled formats such as PDF and/or JPG/PNG using the PHP G... | <p>I've used <a href="http://www.digitaljunkies.ca/dompdf/" rel="nofollow">this</a> before to turn a HTML table into a PDF. I generated the table from a MySQL query.</p>
|
Mixing ASP.NET Webforms and ASP.NET MVC <p>I am having trouble with forms authentication. The root web.config is setup to deny access to all non authenticated users with a structure like:</p>
<p>Controllers<br />
Folder - Webforms<br />
Folder1 - Webforms<br />
Model<br />
Public Folder - Webforms with web.config to a... | <p>I'm having trouble seeing what the config sections actually look like. Can you edit the post and drop those sections into a Code Sample block (the button with binary in the text editor toolbar). </p>
<p>Is the goal to lock down everything that's WebForms and make the MVC driven bits public? </p>
<p>(Would have ... |
LINQ2SQL performance with transactions <p>I'm having a major performance issue with LINQ2SQL and transactions. My code does the following using IDE generated LINQ2SQL code:</p>
<p>Run a stored proc checking for an existing record
Create the record if it doesn't exist
Run a stored proc that wraps its own code in a tran... | <p>One big thing that changes as soon as you get a transaction - the <a href="http://msdn.microsoft.com/en-us/library/system.transactions.isolationlevel.aspx" rel="nofollow">isolation level</a>. Is your database under heavy contention? If so: by default a <code>TransactionScope</code> is at the highest "serializable" i... |
How to load kernel into memory from CD-ROM using Assembly (NASM) <p>I'm writing a bootstrap and kernel for myself and both bootstrap and kernel will be burn on a CD-R and will function as a CD-live. It is not a linux CD-Live or something else,is totally my own bootloader and kernel. I do not want to use other booloader... | <p>For the BIOS to load your boot sector from CD, you'll need to make the CD bootable by using the <a href="http://en.wikipedia.org/wiki/El_torito" rel="nofollow">"El Torito"</a> standard. </p>
<p>Once you use that, you have two options<br>
a. Emulation - the BIOS emulates either a floppy or hard drive, and you can r... |
Adding a new row (with a templated column) to an Infragistics UltraWebGrid <p>I am using the Infragistics UltraWebGrid to capture some data. I don't have this grid bound to a datasource, I simply access the values I need when the user clicks a save button.</p>
<p>I need to add autocomplete functionality to one of the ... | <p>Well, first time I ask a question and doesn't get an inmediate answer. I am going to describe what I am going to do just for anyone with the same problem or just in case anyone with a better solution gets to read this.</p>
<p>I am simply going to wrap the WebGrid in a UpdatePanel, and call the igtbl_doPostBack() at... |
Is there a simple preprocessor/code-generator like GNU M4 that can be called from Ant? <p>I need to maintain some old XSL code and I've discovered that there's a lot of duplication in the XSL files. It looks like there isn't an easy include/import function for XSL which would allow me to move the code to a different fi... | <p>There is an include mechanism for XSL. See <a href="http://www.w3.org/TR/xslt#section-Combining-Stylesheets" rel="nofollow">http://www.w3.org/TR/xslt#section-Combining-Stylesheets</a> for details.</p>
<p>If you can't achieve what you want with that, you can preprocess your XSL with another XSL transform: XSL is ju... |
MVP pattern, how many views to a presenter? <p>We are trying to get the Model-View-Presenter pattern used on (virtually) all new dev work that we undertake.</p>
<p>I'm a strong believer in having a framework to help people meet a design requirement, we have a few in-house frameworks for various different components (l... | <p>I don't see a problem with your approach. You don't strictly need to have a one-to-many relationships between a presenter and views - usually you only have one view per presenter. The idea behind MVP is <strong>decoupling</strong> presenters from views, so that you can switch the view more easily if you need to (for... |
C++: First element of vector "corrupting" <p>I have a class (foo) that contains a vector.</p>
<p>If i try iterating over the elements in the vector like so:</p>
<pre><code>for(vector<random>::iterator it = foo.getVector().begin();
it != foo.getVector().end(); ++it) {
cout << (*it) << endl;... | <pre><code>for(vector<random>::iterator it = foo.getVector().begin();
</code></pre>
<p>The temporary vector is returned when you do <code>foo.getVector()</code> and it gets destroyed the moment <code>;</code> is encountered after <code>foo.getVector().begin();</code> Hence iterator becomes invalid inside the loo... |
Jquery accordion and thickbox clash <p>I am having a problem using thickbox and accordion on the same page ie none of them work. I have checked that they both use the latest version of jquery. Below are my includes. There are no other jscript files included. I am using this on a wordpress template if this can cause an ... | <p>Your coded included references to two versions of jquery library. The first one (jquery-1.3.2.min.js) was extended with the accordion plugin but then it was overwritten by the second library (jquery.js). </p>
<p>This broke your <code>$('#sidebar ul').accordion();</code> code because the second jquery library did no... |
Error regarding AjaxControlToolKit <p>When I run a page I get the following parse error.</p>
<blockquote>
<p>Parser Error</p>
<p>Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file ... | <p>Are you using version 1.0 or 3.0 of the AjaxControlToolkit? You may have accidentally referenced the 1.0 version when you shouldn't have.</p>
|
Shrink image using javascript <p>I need to shrink the image that was kept in div background-image using javascript.for that image four's side having rounded corner.</p>
<p>Is it possible in javascript?</p>
<p>any suggestions ?</p>
| <p>You <em>can't</em> resize backgrounds with JS.</p>
<p>You <em>can</em> split the image up into 4 corner images and nest divs to show them all:</p>
<pre><code><div style="background:url(tl.jpg) top left no-repeat">
<div style="background:url(tr.jpg) top right no-repeat">
<div style="backg... |
Optimize NHibernate Query <p>In my system I do a centralized calculation on an aggregate with a lot of collections. I need ALL of the collections to be loaded before the calculation, and therefore I use a multicriteria that joins the collections on the root. </p>
<p>The criteria i listed here below. It takes approx 50... | <p>After a while I have finally realized, that for this exact scenario it might make a lot more sense to use a document-oriented database like MongoDB or an object database. </p>
<p>That way I can load the entire aggregate in one go and forget about joins. </p>
<p>So for anyone who runs into scenarios like the above,... |
GData Java Client not working because Google redirects to localized site <p>I'm following the documentation at <a href="http://code.google.com/apis/analytics/docs/gdata/1.0/gdataJava.html" rel="nofollow">Google Analytics Data API - Java</a>
and am getting the <code>RedirectRequiredException</code> exception, because G... | <p>The URL was incorrect. I copied it from the example, which was incorrect.</p>
|
problem with laoding image at run time in asp.net <p>I'm having an image that i have added to the image folder in app_data folder
of my application. now problem is that it's showing the image at design time
but at runtime it don't show.now if page is postback now it shows the image.</p>
<p>what's the prob with thi... | <p>You should verify in the html code pre-postback that the image has a valid url. Aren't you setting the url only on the postback event handler?</p>
<p>Post the code for more help</p>
|
Ways to reduce MS SQL database backup file sizes <p>This question might make one smile, really, HDD space is as cheap as dirt today. But nevertheless, with extremely slow internet connections (which is still the case in the major part of the world) transferring backups from different branches might be real pain in the ... | <ol>
<li>Zip the backup.</li>
<li>Divide into multiple filegroups so you can backup files separately.</li>
<li>Drop indexes before backup. You might want to copy the DB locally before doing this.</li>
<li>Have indexes on a separate filegroup so you don't have to back them up.</li>
<li>Put text/binary/image data on a se... |
Converting pdf to images using Ruby/JRuby <p>I'm looking for an easy way to generate previews for labels generated as pdfs. It would be great if I could convert these pdfs to images and show them to the user before the actual print/download.</p>
<p>The application is currently running in a Jruby on rails environment, ... | <p>Are you on Linux?</p>
<pre><code>sudo apt-get install imagemagick
</code></pre>
<p>In your ruby code do</p>
<pre><code>system "convert -colorspace rgb -density 150 ../path/whatever.pdf ../path/whatever.jpg"
</code></pre>
<p>-density is the DPI of the final image</p>
<p>-colorspace fixes issues I had with the co... |
What does the "on error goto 0" and "error resume next" in old ASP mean? <p>I am working with old ASP code and I am not sure about semantics of <code>on error goto 0</code> and <code>error resume next</code> construction. </p>
<p>Can you recommend me some useful resources or enlight me directly?</p>
| <p>Have a look here:
<a href="http://www.powerasp.com/content/new/on-error-resume-next.asp" rel="nofollow">http://www.powerasp.com/content/new/on-error-resume-next.asp</a></p>
|
Resharper Ruleset, can we share them? <p>I work in a small dev team and we've recently acquired Resharper. Is it possible to configure Resharper's ruleset (e.g. Disabling resharper from wanting to rename everything to "var" ) on one machine and distribute that ruleset amongst all the developers?</p>
<p>Thanks</p>
| <p>I believe you can find this in Resharper -> Options -> Languages -> Common -> Code Style Sharing.</p>
<p><strong>UPDATE</strong>: In Resharper 6, settings management can be found in Resharper -> Manage Options... From there you can import/export settings files and apply a layered configuration.</p>
|
How can I get permutations of items from two subqueries in T-SQL? <p>Lets say I have two subqueries:</p>
<pre><code>SELECT Id AS Id0 FROM Table0
=>
Id0
---
1
2
3
and
SELECT Id AS Id1 FROM Table1
=>
Id1
---
4
5
6
</code></pre>
<p>How do I combine these to get the query result:</p>
<pre><code>Id0 Id1
----... | <p>Cartesian join, a join with no join condition</p>
<pre><code>select id0.id as id0, id1.id as id1
from id0, id1
</code></pre>
<p>alternatively you can use the CROSS JOIN syntax if you prefer</p>
<pre><code>select id0.id as id0, id1.id as id1
from id0 cross join id1
</code></pre>
<p>you can order your query if y... |
In C# 3.0 we use "var" what is its alternative in C# 2.0? <p>I am learning plug able architecture in .Net using Managed Extensibility Framework (MEF.)
I saw sample code on the net, but when I tried to implement it I got stuck at one point.</p>
<p>The code was using:</p>
<pre><code> var catalog = new AttributedAssembl... | <p>Basically, <code>var</code> forces the compiler to determine (infer) the <em>compile-time</em> type of a variable based on it's "initializer" -- effectively, an expression to the right from <code>=</code> sign. Here the types are obvious:</p>
<pre><code>AttributedAssemblyPartCatalog catalog =
new AttributedAss... |
Implementing Licencing mechanism for a Software <p>I am thinking of implementing a good licensing mechanism that has a good resistance against piracy. The required mechanism should not use an internet connection at each and every time the software is used. I am thinking of a mechanism based on hardware IDs etc. Do you ... | <p>Ideally you need something that is OS independent.</p>
<p>I would recommend that you embed the license protection within your code or wrap your application within it in such a way that it cannot be run without the copy protection code having run first.</p>
<p>It would be best if your application needs a license ke... |
How to change nvarchar to datetime format? <p>My code generates some dataset per 10 minutes-log or per 30 minutes-log, but the DateTime Format is <code>'1900-01-01 14:20:00'</code>. I need <code>'2009-05-13 14:20:00'</code>, so I want to change it. </p>
<p>See Table1 and Table2 below.</p>
<pre><code>declare @date1 nv... | <p>Why don't you declare your date variables as datetime?</p>
<pre><code> declare @date1 datetime
declare @date2 datetime
set dateformat ymd
set @date1 = '2009-05-12'
set @date1 = '2009-05-13'
...
</code></pre>
<p>This way, you don't have to do any conversions from nvarchar to datetime.</p>
<p>Or, if d... |
Why does the .NET Framework StreamReader / Writer default to UTF8 encoding? <p>I'm just looking at the constructors for StreamReader / Writer and I note it uses UTF8 as default. Anyone know why this is? I would have presumed it would have been a safer bet to default to Unicode.</p>
| <p>UTF-8 will work with any ASCII document, and is typically more compact than UTF-16 - but it still covers the whole of Unicode. I'd say that UTF-8 is <em>far</em> more common than UTF-16. It's also the default for XML (when there's no BOM and no explicit encoding specified).</p>
<p>Why do you think it would be bette... |
XSL: Avoid exporting namespace defintions to resulting XML documents <p>I'd like to take data from some XML files and transform them into a new XML document. However, I do not want the definition of a namespace in the XSLT to occur in the result document. </p>
<p>In other words:</p>
<p>source:</p>
<pre><code><Nam... | <p>You can use the <code>exclude-result-prefixes</code> attribute of the <code>xsl:stylesheet</code> element to suppress namespaces from the output document:</p>
<pre><code><?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
... |
How to convert an arbitrary large integer from base 10 to base 16? <p>The program requires an input of an arbitrary large unsigned integer which is expressed as one string in base 10. The outputs is another string that expresses the integer in base 16.</p>
<p>For example, the input is "12345678909876543212345678909876... | <ol>
<li><p>Allocate an array of integers, number of elements is equal to the length of the input string. Initialize the array to all 0s.</p>
<p>This array of integers will store values in base 16.</p></li>
<li><p>Add the decimal digits from the input string to the end of the array. Mulitply existing values by 10 ad... |
Asynchronous procedure call with DB2 .NET Data Provider <p>Is there any way to asychronously call a DB2 stored procedure using DB2 .NET Data Provider?</p>
| <p>There are a number of ways- which one is appropriate will depend on your scenario.</p>
<p>What I was doing in Oracle was getting back 1000s of items of XML from a DB based on a queue of work item IDs. Getting them out in one go with a datareader didn't work, so I got them out 1 at a time on several different thread... |
Retreving Client Username by using Windows authentication <p>I'm attempting to retrieve the user name and client machine name of the person logged on to a computer on our intranet in ASP.NET. This is just for logging purposes. I retrieve the user name "System.Security.Principal.WindowsIdentity.GetCurrent().Name", probl... | <p>The code you are using will get the <code>WindowsIdentity</code> associated with the current thread (which is the identity ASP.NET is running on). Unless you are impersonating based on client user identity that won't work. You need to use this:</p>
<pre><code>HttpContext.Current.User.Identity.Name
</code></pre>
|
Red5 + Java + Windows installation + ant compilation : it works, but why? <p>I'm totally new to both java <strong>and</strong> java Server worlds...
But I've a good knowledge (17 years) of object-oriented programming.
My question is : </p>
<p>Why do I have to call ant to make it work (see later, if you're not interes... | <p>Ant will both compile the code (compile target) and build the jar file (target jar), which will be placed in lib folder. When you simply compile the code with javac, the jar file isn't generated.</p>
|
Selecting only one row from child model based upon the parent model <p>Following is the association between 2 models:</p>
<pre><code>class FotoGossip < ActiveRecord::Base
has_many :uploads
end
class Upload < ActiveRecord::Base
belongs_to :foto_gossip
end
@latest_uploads = Upload.all(:include => :foto_... | <p>I think you can use <a href="http://api.rubyonrails.org/classes/ActiveRecord/Calculations/ClassMethods.html#M002135" rel="nofollow">ActiveRecord::Base#calculate</a> like in</p>
<pre><code>@latest = Update.maximun(:creted_at,:distinct=>:foto_gossip_id)
</code></pre>
|
good way to represent a excel sheet value in Java <p>Consider that I've a excel sheet in below format:</p>
<b>person</b>
<b>age</b>
<br/>
Foo
29
<br/>
Bar
27
<p>Now I want to read these values (using POI HSSF) and have to process them. What's the best way to do that?</p>
<p>Note that I do not have a Object P... | <pre><code>public class Grid {
private Row headerColumns;
private List<Row> dataRows;
public Grid() {
dataRows = new LinkedList<Row>();
}
public Grid(int rowCount) {
dataRows = new ArrayList<Row>(rowCount);
}
public void addHeaderRow(List<String> headers)... |
What are the reasons why Map.get(Object key) is not (fully) generic <p>What are the reasons behind the decision to not have a fully generic get method
in the interface of <a href="http://java.sun.com/javase/6/docs/api/java/util/Map.html#get(java.lang.Object)"><code>java.util.Map<K, V></code></a>.</p>
<p>To clar... | <p>As mentioned by others, the reason why <code>get()</code>, etc. is not generic because the key of the entry you are retrieving does not have to be the same type as the object that you pass in to <code>get()</code>; the specification of the method only requires that they be equal. This follows from how the <code>equa... |
reusing TableCellEditor objects <p>So I have lots of tables and lots of cell editors, with lots of stuff in them. I figured I should be reusing them, not doing new() every time since the whole thing is set getTableCellEditorComponent() but still, nearly every time I try to do it, I get "leftovers" in old cells, and ot... | <p><code>JTable</code>s are huge. While the <code>JComponent</code> subclass in a <code>TableCellEditor</code> may also be quite large, it isn't really worth worrying about. Further, it is a good idea to avoid sharing mutable objects, particularly ones as complicated as Swing components. Having one parent per component... |
Char(4) versus int as StatusID/StatusCode column in a table <p>I need a status column that will have about a dozen possible values.
Is there any reason why I should choose int (StatusID) over char(4) (StatusCode)?
Since sql server doesn't support named constants, char is far more descriptive than int when used in store... | <p>Database purists will say a key should have no meaning in the business domain, and that you should create a status table where you look up the description and other meanings of the status.</p>
<p>But for operators and end users, having a descriptive status code can be a blessing. And it doesn't even have to be cha... |
Injecting Maven project information into Swing Application Framework resources? <p>I have a Maven project using the Swing Application Framework and would like to inject project information from the pom.xml into my application's global resources to avoid duplication. </p>
<p>The base application (provided via netbeans... | <p>You could try using <a href="http://www.sonatype.com/books/maven-book/reference/resource-filtering-sect-description.html" rel="nofollow">filtered resources</a>. If you create a property file, say <code>src/main/resources/com/myapp/app.properties</code> that looks like this:</p>
<pre><code>version=${project.version... |
Infinite recursion trying to check all elements of a TreeCtrl <p>I have a TreeCtrl in which more than one Item can be assigned the same object as PyData. When the object is updated, I want to update all of the items in the tree which have that object as their PyData.</p>
<p>I thought the following code would solve the... | <p>How is the "next" item ever going to be the first item? </p>
<p>This appears to be a tautology. The next is never the first.</p>
<pre><code> current = self.GetNextVisible(current)
current != self.GetFirstVisibleItem()
</code></pre>
<p>It doesn't appear that next wraps around to the beginning. It appear... |
Some changes to SQLite database are not persisting after app close and relaunch <p>I've got an iPhone app I'm developing and when the app launches I open an SQLite database connection, and I close it when the application terminates. The database is in the application documents folder.</p>
<p>During the lifetime of the... | <p>Ah... I figured it out! One of my obscure finalize statements never actually got reached! As it was only a SELECT statement I didn't check it over because it has nothing to do with any data manipulation or transactions! That's a day's worth of development out of the window! But I won't make that mistake again!</p>
... |
Query about shared library performance <p>I have a question about performance difference (from the perspective of Cycles consumed) between a static library and shared library(windows - dll).</p>
<p>I have a static library for some code. I also have a dynamic library for the same code.
I have linked these two librarie... | <p>Once the routines in the DLL have been thunked in, there is no performance difference other than an additional CALL/RET when calling them.</p>
|
How to connect to SQL Server database from JavaScript in the browser? <p>Can anybody give me some sample source code showing how to connect to a SQL Server 2005 database from JavaScript locally? I am learning web programming on my desktop.</p>
<p>Or do I need to use any other scripting language? Suggest some alternati... | <p>You shouldn´t use client javascript to access databases for several reasons (bad practice, security issues, etc) but if you really want to do this, here is an example:</p>
<pre><code>var connection = new ActiveXObject("ADODB.Connection") ;
var connectionstring="Data Source=<server>;Initial Catalog=<catal... |
How do I alter enterd text before matching <p>I have an jQuery.autocomplete field presenting a limited range of decimal numbers. Ex:</p>
<pre><code>var the_list = ['+2.23', '+1.10', '-1.10', '-2.00', '-3.00',]
</code></pre>
<p>But I allow the user to enter data like '2.3' and '-5'. At least I can get partial matches ... | <p>Assuming that you're using the autocomplete plugin for jquery found here:
<a href="http://www.pengoworks.com/workshop/jquery/autocomplete.htm" rel="nofollow">http://www.pengoworks.com/workshop/jquery/autocomplete.htm</a></p>
<p>Then modify the plugin file to change this:</p>
<pre><code> function onChange() {
/... |
Big smart ViewModels, dumb Views, and any model, the best MVVM approach? <p>The following code is a refactoring of my previous MVVM approach (<a href="http://stackoverflow.com/questions/852441/fat-models-skinny-viewmodels-and-dumb-views-the-best-mvvm-approach">Fat Models, skinny ViewModels and dumb Views, the best MVVM... | <p>I like your sample above, I think it implements the spirit of MVVM. Just for clarification, though, the ViewModel code and the Model code should not be in the same source file as the actual Code Behind. In fact, I would argue that they should not be in the same project.</p>
<p>Here is MVVM as I understand it: </p... |
Xpath and XmlNameSpace <p>I have the following XML</p>
<pre><code><?xml version="1.0"?>
<FileHeader
xmlns="urn:schemas-ncr-com:ECPIX:CXF:FileStructure:020001"
VersionNumber="020001"
TestFileIndicator="P"
CreationDate="13012009"
CreationTime="172852"
FileID="0000000001"
>
<Item
I... | <p>With an <code>XmlNamespaceManager</code> and an alias in the xpath:</p>
<pre><code> XmlNamespaceManager mgr = new XmlNamespaceManager(doc.NameTable);
mgr.AddNamespace("x", doc.DocumentElement.NamespaceURI);
foreach (XmlNode node in doc.SelectNodes(
"//x:Item/x:AddendA/x:ImageViewDetail", mgr))
... |
Application level checksumming as the tcp checksumming might be too weak? <p>This Paper (<a href="http://portal.acm.org/citation.cfm?doid=347059.347561" rel="nofollow">When the CRC and TCP checksum disagree</a>) suggests that since the TCP checksumming algorithm is rather weak, there would occur an undetected error eve... | <p>I've worked on trading systems for IBs, and I can assure you there is no extra checksumming going on - most apps use naked sockets. Given the current problems in the financial sector, I think bad TCP/IP checksums should be the least of your worries.</p>
|
Any quick way to find out if a ASP.NET control property is backed by viewstate or ordinary fields? <p>In all my Page_Load() events I have to do a </p>
<pre><code>if(!IsPostBack)
{
//code runs on initial get
//Set properties backed by viewstate
}
else
{
//Code runs on each get and post
//Set properties backed b... | <p>This seems to be more of a design question - When to use ViewState. Since you have the source you obviously know which controls uses ViewState, so no guesswork or discovery is needed. </p>
<p>IsPostback is the usual way to determine GET or POST. You can also examine Request.HttpMethod. For deciding when to use View... |
Nullable types and the ternary operator: why is `? 10 : null` forbidden? <p>I just came across a weird error:</p>
<pre><code>private bool GetBoolValue()
{
//Do some logic and return true or false
}
</code></pre>
<p>Then, in another method, something like this:</p>
<pre><code>int? x = GetBoolValue() ? 10 : null;
... | <p>The compiler first tries to evaluate the right-hand expression:</p>
<pre><code>GetBoolValue() ? 10 : null
</code></pre>
<p>The <code>10</code> is an <code>int</code> literal (not <code>int?</code>) and <code>null</code> is, well, <code>null</code>. There's no implicit conversion between those two hence the error m... |
How do I call a method in a custom ActiveX dll using java/vb script <p>I have created an ActiveX dll using VB6 and packaged it using the Package & Deployment Wizard which has resulted in a cab file and a demo HTML page. </p>
<p>This ActiveX dll contains a simgle method that returns a string and accepts no argument... | <p>Javascript knows nothing about Class1. You have to get the object into javascript.</p>
<p>Try:</p>
<pre><code> function displaymessage()
{
try
{
var filename;
var class1 = document.getElementById("Class1");
filename = class1.Sa... |
is SSIS insert bulk the same as a BULK Insert <p>I'm doing a bulk insert of a CSV file into SQL Server 2005, using an SSIS package (not built by me)</p>
<p>I'm running SQL Profiler and see the insert statement as:</p>
<pre><code>insert bulk [dbo].[stage_dht]( ..... )
</code></pre>
<p>but there's no FROM clause in th... | <p>Yes, the SSIS Bulk Insert task uses the same underlining functionality that the BULK INSERT command uses.</p>
<p>You will most likely see differences in SQL Profiler because the the Bulk Insert task will use the underlining COM object directly (which powers bulk insert), rather than simply being a GUI wrapper on th... |
IronPython and instantiating COM objects <p>I'm using IronPython 2.0 in a SharpDevelop 3.1 console window. I'm trying to reference and use the Redemption CDO replacement library.</p>
<p>The standard usage for the library is to instantiate an RDOSession object, then use the methods on that object to navigate through t... | <p>You need to use:</p>
<pre><code>session = Redemption.RDOSessionClass()
</code></pre>
|
Java Memory explained (SUN JVM) <p>I tried to find an interpretation of the memory segments of the sun java vm, which would also be <strong>understandable by an administrator</strong>. It should explain what heap / non-heap memory is and the significance of the different memory pools. </p>
<p>If it would somehow relat... | <p>Here's a list of resources I had noted down. Some of these explain how the heap/garbage collection works and some have details on how to configure everything.</p>
<p>IBM</p>
<ul>
<li><a href="http://publib.boulder.ibm.com/infocenter/javasdk/v1r4m2/index.jsp?topic=%2Fcom.ibm.java.doc.diagnostics.142%2Fhtml%2Fhowdoe... |
Datetime issue in Django <p>I am trying to add the datetime object of a person. Whenever the birth year is less than year 1942, I get a strange error <code>DataError: unable to parse time</code> when reading the data back from the DB.</p>
<pre><code>class Person(models.Model):
"""A simple class to hold the person ... | <p>The only thing I could come up with here can be found in the <a href="http://www.postgresql.org/docs/6.3/static/c0804.htm">PostgreSQL docs</a>. My guess is that Django is storing your date in a "reltime" field, which can only go back 68 years. My calculator verifies that 2009-68 == 1941, which seems very close to wh... |
Get table Id in code in .Net <p>I have two tables on a webform. On a button click I want to hide one and show the other. I gave them both an Id and I want to set the tables' style="display:" </p>
<p>I tried this in javaScript using a function and document.getelementbyid(id).style.display='none' but it did not work.</p... | <p>I am assuming your tables are .net controls? If so, passing 'id' is not enough as .net does not assign the same server id as client-side id.</p>
<p>You need to access the ClientID property of the .net control server-side to get it's real client-side id:</p>
<pre><code>MyButton.OnClientClick = string.Format("{0}.st... |
XML indenting when injecting an XML string into an XmlWriter <p>I have an XmlTextWriter writing to a file and an XmlWriter using that text writer. This text writer is set to output tab-indented XML:</p>
<pre><code>XmlTextWriter xtw = new XmlTextWriter("foo.xml", Encoding.UTF8);
xtw.Formatting = Formatting.Indented;
x... | <p>How about using a XmlReader to read the xml as xml nodes?</p>
<pre><code>string xml = ExternalMethod();
XmlReader reader = XmlReader.Create(new StringReader(xml));
xw.WriteNode(reader, true);
</code></pre>
|
How to attach logged in user to Django exception error messages? <p>When I get an error exception email from my Django site it would be useful to see the User and/or UserProfile information for the currently logged in user. How do I add this to the Django site exception error emails?</p>
| <p>Django appends repr(request) at the end of the e-mail. Using the default wsgi development server you can find the logged in user as</p>
<p>'LOGNAME': 'myuser', </p>
<p>This may be hidden in some e-mail clients as it is wrapped in angle brackets.</p>
<pre><code><WSGIRequest
GET:<QueryDict: {}>,
POST:<... |
Compiling Android Qemu image <p>I want to start playing around with Android. Downloaded the sources and followed the instructions from the <a href="http://source.android.com/download" rel="nofollow">download page</a> </p>
<p>Made a plain generic build:</p>
<pre><code>============================================
TARGE... | <p>Are you trying to build for the emulator?
if so follow these steps:</p>
<ol>
<li>from your android root folder run the following command: "source build/envsetup.sh" that will setup the build environment.</li>
<li>to select the build for emulator option use the following command "lunch 1"</li>
<li>build, from your r... |
Hibernate L2 Caching and Many-To-Many relationships <p>I've got a pair of Hibernate entities, A and B, that are related via a bidirectional many-to-many relationship, as described <a href="http://docs.jboss.org/hibernate/stable/core/reference/en/html/collections-advancedmappings.html#collections-bidirectional" rel="nof... | <p>By definition you need to remove from both sides. It makes sense from
a technical perspective as basically both collections are cached
independently.</p>
<p>Of course it's nonsense from a practical perspective and
many people will trip over it.</p>
|
How to setup TeamCity under IIS? <p>Any ideas?</p>
| <p>With IIS 7.5 you can use Application Request Routing to route requests at <code>teamcity.server.domain.com:80</code> to Tomcat at <code>server.domain.com:81</code>. I would consider this approach superior since the Tomcat Connector seems a bit flaky under WS2008 x64.</p>
<p>Jon Alb has a good writeup on how to conf... |
Deleting data from a large table <p>I have a table with about 10 fields to store gps info for customers. Over time as we have added more customers that table has grown to about 14 million rows. As the gps data comes in a service constantly inserts a row into the table. 90% of the data is not revelent i.e. the customer ... | <p>My 2 cents:</p>
<p>If you are using SQL 2005 and above, you can consider to partition your table based on the date field, so the table doesn't get locked when deleting old records.</p>
<p>Maybe, if you are in position of making dba decisions, you can temporarily change your log model to Simple, so it won't grow up... |
File extention of zlib zipped html page? <p>What does a zipped html file using zlib (deflate) look like sitting on the server? Does it have a different extension than .html?</p>
| <p>It has the extension you uploaded it with.</p>
<p>Note that if you ask the web server to serve deflated html pages, it will do so on-the-fly, and any caching it does will be somewhere other than your web site directory, so you won't actually see those files, if they are files at all.</p>
<p>In other words, if you'... |
What are the table and column limits in SQL? <p>What is the maximum number of tables that can be created in sql and what is the maximum number of columns for a single table?</p>
| <p>As seen here: <a href="http://msdn.microsoft.com/en-us/library/ms143432.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms143432.aspx</a></p>
<p>MS SQL Server can contain 2,147,483,647 objects. Objects include tables, views, stored procedures, user-defined functions, triggers, rules, defaults, constra... |
How to get a stopwatch program running? <p>I borrowed some code from a site, but I don't know how to get it to display.</p>
<pre><code>class Stopwatch
def start
@accumulated = 0 unless @accumulated
@elapsed = 0
@start = Time.now
@mybutton.configure('text' => 'Stop')
@mybutton.command { stop }
... | <p>Based upon the additional code rkneufeld posted, this class requires a timer that is specific to Tk. To do it on the console, you could just create a loop that calls tick over and over. Of course, you have to remove all the code that was related to the GUI:</p>
<pre><code>class Stopwatch
def start
@accumula... |
File to byte[] in Java <p>How do I convert a <code>java.io.File</code> to a <code>byte[]</code>?</p>
| <p>From <strong>JDK 7</strong> you can use <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#readAllBytes(java.nio.file.Path)" rel="nofollow"><code>Files.readAllBytes(Path)</code></a>.</p>
<p>Example:</p>
<pre><code>import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.... |
How can I target CSS to a particular sharepoint Page Layout file? <p>Is it possible to create a .CSS file for each SharePoint Page Layout I develop, or does the CSS for each possible layout in a master page need to be referenced in the master page?</p>
<p>IE is it possible to affect the <code><head></code> of th... | <p>Michal's solution can be further enhanced by including any links etc in the PlaceHolderAdditionalPageHead content placeholder tag on your layout page. This way it will be included properly in the head of the generated page.</p>
<p>e.g. </p>
<pre><code><asp:Content ContentPlaceholderID="PlaceHolderAdditionalPage... |
Opacity in web pages? <p>I keep seeing 60-80% opacity on tables on websites. They look really cool, but I'm not sure why they are doing it. Is it Javascript, or is it an image?
How do I change the opacity of a table?</p>
| <p>You can do it in CSS, but it requires a little hacking to get it to work cross-browser. </p>
<pre><code>selector {
filter: alpha(opacity=50); /* internet explorer */
opacity: 0.5; /* fx, safari, opera, chrome */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=50)"; /*IE8*/
}
</code... |
Setting value of paramter containing " ' " (apostrophe) used in LIKE query <p>I have the following query in ASP.NET/C# code which is failing to return any values using a parameter...</p>
<pre><code>select * from MyTable where MyTable.name LIKE @search
</code></pre>
<p>I have tried the following query alternatives to ... | <p>I think the issue is that you're escaping the quotes in your <code>search</code> parameter, when the SQL parameter does that for you.</p>
<p>The percent signs should be <em>inside</em> the SQL Parameter value; your query just references the parameter plainly. The SQL should look like this:</p>
<pre><code>select *... |
Submit button disapears on hover and then reapears <p>So I'm using CSS :hover to replace a submit button background. When I mouse over the button the old background image disappears (so it looks like nothing is there) for a moment and then reappears with the new background. I thought that perhaps the button image fil... | <p>Is this only on the initial page display / hover?</p>
<p>This will be because the image file is only loaded on request - i.e. the hover action.</p>
<p>To avoid this, both button states should be stored in a single file. You then just need to adjust the background-position property to display the correct half of th... |
mysql syntax <p>In response to another question here on stackoverflow (<a href="http://stackoverflow.com/questions/858746/how-do-you-select-every-n-th-row-from-mysql">How do you select every n-th row from mysql</a>), someone supplied this answer:</p>
<pre><code>SELECT * FROM ( SELECT @row := @row +1 AS rownum, [column... | <p><code>a = b</code> in MySQL compares <code>a</code> to <code>b</code> and returns <code>true</code> if they're equal, or <code>false</code> otherwise. <code>@a := b</code>, on the other hand, <em>sets</em> the value of <code>@a</code> to <code>b</code>.</p>
<p>Basically, <code>=</code> is the comparison operator ("... |
TSQL - Best way to select data where a leave date falls in range of an invoice <p>Background: I have a payroll system where leave is paid only if it falls in range of the invoice being paid. So if the invoice covers the last 2 weeks then only leave in the last 2 weeks is to paid.</p>
<p>I want to write a sql query to ... | <p>So LeaveDate should be between (WeekEnding-NoOfWeeksCovered) and (WeekEnding) for some Invoice?</p>
<p>If I've understood it right, you might be able to use an EXISTS() subquery, something like this:</p>
<pre><code>SELECT *
FROM DailyLeaveLedger dl
WHERE Paid = 0 AND
EXISTS (SELECT *
FROM Invo... |
Algorithm for base-10 numeric display - minimum changes per refresh <p><strong>Quick Summary:</strong></p>
<p>I'm looking for an algorithm to display a four-digit speed signal in such a way that the minimum number of (decimal) digits are changed each time the display is updated.</p>
<p>For example:</p>
<pre><code>Fi... | <p>If you do not need the data expressed by the 4th digit, and are strictly bound to a 4 digit display, have you considered using the 4th digit as an increase/decrease indicator? Flash some portion of the top or bottom of the zero at 2Hz* to indicate that the next change of the gauge will be an increase or decrease.</... |
Getting pdb-style caller information in python <p>Let's say I have the following method (in a class or a module, I don't think it matters):</p>
<pre><code>def someMethod():
pass
</code></pre>
<p>I'd like to access the caller's state at the time this method is called.</p>
<p><code>traceback.extract_stack</code> j... | <p>I figured it out:</p>
<pre><code>import inspect
def callMe():
tag = ''
frame = inspect.currentframe()
try:
tag = frame.f_back.f_locals['self']._tag
finally:
del frame
return tag
</code></pre>
|
Table size using JPA query language <p>Using JPA query language, how do I determine the size (number of rows) in an entity (table)?</p>
| <p>Use the count aggregate function:</p>
<pre><code>EntityManager em = ...
Query q = em.createQuery ("SELECT count(x) FROM Magazine x");
Number result = (Number) q.getSingleResult ();
</code></pre>
|
Alternative to Application.LoadFromText for MS Access Queries <p>I am attempting to load from text files, queries into an MS Access Queries Collection using VBScript. I am using something like this:
The code originated from <a href="http://stackoverflow.com/questions/187506/how-do-you-use-version-control-with-access-d... | <p>This saves the query defs</p>
<pre><code>For i = 0 To db.QueryDefs.Count - 1
Application.SaveAsText acQuery, db.QueryDefs(i).Name, sExportpath & "\" & db.QueryDefs(i).Name & ".sql"
Next i
</code></pre>
<p>Then the LoadFromText should work</p>
|
issue commands to window/process started from batch file <p>I want to pass commands to a process started in a batch file, specifically Cygwin. For instance, if I start Cygwin with something like the following:</p>
<pre><code>start "window1" cmd.exe /c cygwin
</code></pre>
<p>How might I execute 'ls' in "window1", in... | <p>I have to ask why you want to run the commands from a batch file? Do you want to take different actions based on the results/output of the commands?</p>
<p>In either case, what you are asking is bordering on impossible. Why don't you simply write your logic in a bash script and run</p>
<p><code>start "window1" cmd... |
Do I need a lock when only a single thread writes to a shared variable? <p>I have 2 threads and a shared <code>float</code> global. One thread only writes to the variable while the other only reads from it, do I need to lock access to this variable? In other words:</p>
<pre><code>volatile float x;
void reader_threa... | <p>Different architectures have different rules, but in general, memory loads and stores of aligned, <code>int</code>-sized objects are atomic. Smaller and larger may be problematic. So if <code>sizeof(float) == sizeof(int)</code> you might be safe, but I still wouldn't depend on it in a portable program.</p>
<p>Als... |
Does the System.Data.DataTable have a size limit? <p>I'm adding data rows to my data table but the row count in the data table does not increase. Seems to be a limit of either size of the table or number of data rows.</p>
<p>FYI, .net 2.0</p>
| <p><a href="http://msdn.microsoft.com/en-us/library/system.data.datatable%28VS.80%29.aspx" rel="nofollow">Click here</a> to see the limitations of the datatable type. 16,777,216 is the maximum number of records.</p>
|
High performance Ruby listbox <p>I need to make a small application in Ruby that will display log lines received over TCP in different colors.
What is a recommended GUI framework to use for this type of app?</p>
<p>I should work on Windows and Linux.</p>
| <p><a href="http://shoooes.net/" rel="nofollow">Shoes</a> is a great lightweight GUI framework with mac, linux, and windows support.</p>
|
++ on a dereferenced pointer in C? <p>Trying to understand the behaviour of pointers in C, I was a little surprised by the following (example code below):</p>
<pre><code>#include <stdio.h>
void add_one_v1(int *our_var_ptr)
{
*our_var_ptr = *our_var_ptr +1;
}
void add_one_v2(int *our_var_ptr)
{
*our_var... | <p>This is one of those little gotcha's that make C and C++ so much fun. If you want to bend your brain, figure out this one:</p>
<pre><code>while (*dst++ = *src++) ;
</code></pre>
<p>It's a string copy. The pointers keep getting incremented until a character with a value of zero is copied. Once you know why this tri... |
What's the best way to store app settings? (MVC) <p>I'm developing a swing app which suits the MVC pattern and I'm wondering about the best place to store settings such as width/height, xml files location... Should those settings be avaiable also only through the Model? Should I use a global static class? A singleton?<... | <p>I'd suggest <a href="http://java.sun.com/javase/6/docs/api/java/util/prefs/package-summary.html" rel="nofollow"><code>java.util.prefs</code></a><code>.</code><a href="http://java.sun.com/javase/6/docs/api/java/util/prefs/Preferences.html" rel="nofollow"><code>Preferences</code></a>.</p>
<p>Then you don't have to in... |
Jquery - Get the text of multiple spans with the same class? <p>I'm relatively new to jquery, so I have what I hope will be a simple question.
I need to append multiple spans to the line items in an unordered list.<br />
Essentially, each line item contains a and I need to grab the content of that span and append it t... | <p>Try this</p>
<pre><code>$("ul > li").each(function() {
var Name = $(".name", this) .text();
var Content = $(".content", this) .text();
$(this).append("<span class=\"additional\"><a href=\"/addinfo.php\">"+ Name +"'s additional info</a></span>");
});
</code></pre>
<p>This will... |
inserting extra data in linq to sql partial class <p>I have a L2S generated class called Accounts, I have a L2S class called UsersInAccounts I need to add a function call AddUserToAccount(accountid, userid) should/could this function be added to the partial Accounts class I have created or are partial classes used for ... | <p>I don't think that what you are doing is a problem. In your code, you'd probably have an Account instance that you want to do things with so being able to do this:</p>
<pre><code>Account theAccountIWant = GetTheAccount();
theAccountIWant.addUser(myUsersGUID);
</code></pre>
<p>...seems pretty intuitive. It might be... |
Crystal Reports if-then-else selection based on parameter <p>I have this crystal report, and I want to be able to use it to display every person in the table or display only those who owe money.</p>
<p>The parameter is called displayAll and is a boolean.
Basically I want this</p>
<pre><code>if displayAll Then
Show... | <p>In your Record Selection Formula, say something like:</p>
<pre><code>If {?DisplayAll} Then
True
Else
{Data.Balance} < 0;
</code></pre>
|
Perforce Issue in Visual Studios 2008 <p>My team uses Visual Studios 2008 to develop SSIS packages and we use Perforce as our source control system. When a user adds a file to a project, the project is automatically checked out WITHOUT checking to see if it is the current version. <strong>Is there a way to force Visu... | <p>This could be an issue with a "shared" workspace client being used with P4SCC and Visual Studio. Workspace clients should be unique to each user and machine -- Perforce uses the workspace client to track the contents of a specific machine's workspace.</p>
<p>Here's how it happens when both users are using the same ... |
Implementing shuffle on the celestial jukebox <p>How would one implement shuffle for the "Celestial Jukebox"? </p>
<p>More precisely, at each time t, return an uniform random number between 0..n(t), such that there are no repeats in the entire sequence, with n() increasing over time.</p>
<p>For the concrete example,... | <p>The way that I like to do that kind of non-repeating random selection is to have a list, and each time I select an item at random between <code>[0-N)</code>, I remove it from that list. In your case, as new items get added to the catalog, it would also be added to the not-yet-selected list. Once you get to the end... |
whoami in python <p>What is the best way to find out the user that a python process is running under?</p>
<p>I could do this:</p>
<pre><code>name = os.popen('whoami').read()
</code></pre>
<p>But that has to start a whole new process.</p>
<pre><code>os.environ["USER"]
</code></pre>
<p>works sometimes, but sometime... | <pre><code>import getpass
print getpass.getuser()
</code></pre>
<p>See the documentation of the <a href="http://docs.python.org/library/getpass.html">getpass</a> module.</p>
<blockquote>
<p>getpass.getuser()</p>
<p>Return the âlogin nameâ of the user. Availability: Unix, Windows.</p>
<p>This function ... |
searching for pages explaining codes <p>Google does not allow searching for !</p>
<p>!-f becomes -f</p>
<p>What search engines find pages with !-f?</p>
| <p><strike>It seems to work if you put it in quotes, like "!-f", did you try that?</strike>
from <a href="http://knol.google.com/k/barry-welford/the-humble-exclamation-mark/3fhotx4fqh463/2#" rel="nofollow">http://knol.google.com/k/barry-welford/the-humble-exclamation-mark/3fhotx4fqh463/2#</a> :</p>
<blockquote>
<p>G... |
DDD: Primary keys (Ids) and ORMs (for example, NHibernate) <p>Why is it considered OK to have an Id field in the domain entities?
I have seen several solutions that provide base class with Id and Id-based GetHashCode/Equals.</p>
<p>My understanding of domain model is that it should contain only things related to the d... | <p>I just can talk about NHibernate. There you need a field for the primary key, it's up to you if you take business data (not recommended) or a surrogate key with no business meaning.</p>
<p>Typical scenarios are:</p>
<ul>
<li>auto-incrementing value generated by the database</li>
<li>guid generated by NHibernate</l... |
Asp.net Routing, WebServices, and IIS7 Classic <p>I have a web forms app running on IIS7 Classic. It utilizes .asmx style web services for a client side heavy portion of the site.</p>
<p>We have been tasked with layering in "friendly urls" and decided to use the new Asp.net routing. We have a rule in IIS to map <em>... | <p>You need to add <code>requireAccess="None"</code> to the handler in web.config, ie:</p>
<pre><code><add name="aspnet_isapi 32-bit" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition=... |
An object reference is required for the non-static field, method, or property? <p>I know this is probably a very newbish question, so I apologize.</p>
<p>I am trying to access the Text property of a label on Form1 from another form, MaxScore.</p>
<p>When I click the Ok button on MaxScore, I want to set Form1's myGame... | <p>Is by any chance Form1 the name of the class?</p>
<p>You need to have a reference to an instance of the form class.</p>
<p>Since <code>okBtn</code> is not on the same form, you need to give the <code>MaxScore</code> form a reference to the <code>Form1</code> instance.</p>
<p>For instance, you can add this to your... |
LINQ To XML Syntax for XML Element with Attributes <p>I'm a bit of a LINQ newbie and I was having some trouble with the following. I'm trying to perform a query using LINQ on an XML file and store the results in a list of DataClass objects that match the XML.</p>
<p>I've got an XML file that is defined like this:</p>
... | <p>Here is the code for a Console application with the LINQ query you need. I had to fill in the getters and setters of your class and containing structure, but this is tested working code. To get a List(Of ASNData) just call DataTables.ToList</p>
<p>Of course this will work with any number of Order elements.</p>
<... |
Understanding the results of Execute Explain Plan in Oracle SQL Developer <p>I'm trying to optimize a query but don't quite understand some of the information returned from <strong>Explain Plan</strong>. Can anyone tell me the significance of the OPTIONS and COST columns? In the OPTIONS column, I only see the word FULL... | <p>The output of EXPLAIN PLAN is a debug output from Oracle's query optimiser. The COST is the final output of the Cost-based optimiser (CBO), the purpose of which is to select which of the many different possible plans should be used to run the query. The CBO calculates a relative Cost for each plan, then picks the pl... |
STL map doesn't add a pair after removing the first pairs <p>In this chunk of code I add a pair on a map and everything is fine but when I delete a pair that isn't the last one the map doesn't add any more pairs. What I'm Doing wrong??</p>
<pre><code>SomeClass::add(Object object)
if (!object.empty())
{
ObjectList:... | <p>Well you are keying on the size of the map, this seems like it may cause your problems.</p>
<p>So if you have 3 things in the map you will have</p>
<pre><code> 1 => Obj1
2 => Obj2
3 => Obj3
</code></pre>
<p>if you remove one of these elements, say at 1, you will have</p>
<pre><code> 2 => Obj2
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.