instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>I'm trying to use <code>SQLBindParameter</code> to prepare my driver for input via <code>SQLPutData</code>. The field in the database is a <code>TEXT</code> field. My function is crafted based on MS's example here:
<a href="http://msdn.microsoft.com/en-us/library/ms713824(VS.85).aspx" rel="nofollow noreferrer">http... | <p>you're passing NULL as the buffer length, this is an in/out param that shoudl be the size of the col_num parameter. Also, you should pass a value for the ColumnSize or DecimalDigits parameters. </p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms710963(VS.85).aspx" rel="nofollow noreferrer">http://msdn.micro... | <p>you're passing NULL as the buffer length, this is an in/out param that shoudl be the size of the col_num parameter. Also, you should pass a value for the ColumnSize or DecimalDigits parameters. </p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms710963(VS.85).aspx" rel="nofollow noreferrer">http://msdn.micro... | 10,960 |
<p>Considering "private" is the default access modifier for class Members, why is the keyword even needed?</p>
| <p>It's for you (and future maintainers), not the compiler.</p>
| <p>Actually, if the class or struct is not declared with an access modifier it defaults to internal. </p>
<p>So if you want to make it private, use private.</p>
| 16,629 |
<p>What I have is a collection of classes that all implement the same interface but can be pretty wildly different under the hood. I want to have a config file control which of the classes go into the collection upon starting the program, taking something that looks like :</p>
<pre><code><class1 prop1="foo" prop2="... | <p>It may be easier to serialise the classes to/from xml, you can then simply pass the XmlReader (which is reading your config file) to the deserializer and it will do the rest for you..</p>
<p><a href="http://www.diranieh.com/NETSerialization/XMLSerialization.htm" rel="noreferrer">This is a pretty good article on seri... | <p>Reflection is what you want. Reflection + TypeConverter. Don't have much more time to explain, but just google those, and you should be well on your way. Or you could just use the xml serializer, but then you have to adhere to a format, but works great.</p>
| 5,114 |
<p>I have a multi dimensional OLAP cube with a number of dimensions. Some of these dimensions have hierarchies. The users would like to perform 'what-if' analysis on the measures in the cube by changing the hierarchies in the dimensions. </p>
<p>For example, they want to know the impact on departmental resource budget... | <p>have you taken a look here? <a href="http://office.microsoft.com/en-us/excel/HA011265551033.aspx" rel="nofollow noreferrer">http://office.microsoft.com/en-us/excel/HA011265551033.aspx</a> if you are using sql server and excel, you want the "Excel Add-in for SQL Server Analysis Services" and you can perform writeback... | <p>There may be tools that allow this sort of analysis, but I only have experience of writing MDX, which ought to be able to help you.</p>
<p>Typical 'what if' analysis is more about changing values in the OLAP cube (e.g. change net sales from 845.45 to 700.00 and see what happens to gross profit). Your case is a bit ... | 5,457 |
<p>I am trying to write a formula in ActionScript 3 that will give me var "z" (please see image below) in degrees, which I will then convert to radians.</p>
<p>I will already know the value of vars "x" and "y". Using trigonometry, how can I calculate the length of the hypotenuse and therefore the variable angle of var... | <p>What you need is this:</p>
<pre><code>var h:Number = Math.sqrt(x*x + y*y);
var z:Number = Math.atan2(y, x);
</code></pre>
<p>That should give you the angle in radians, you might need to swap x/y and possibly add or remove 90 degrees but it should do the trick! (Note that you don't even need <strong>h</strong> to g... | <p>What @Patrick said, also the hypotenuse is <code>sqrt(x^2 + y^2)</code>.</p>
| 8,002 |
<p>I'm coming from the open source world, and interested in giving ASP.NET a spin. But I'm having a little trouble separating the tools from the platform itself in regards to the licensing. I've downloaded Visual Web Developer 2008 Express, but not sure how different this is from one of the full-featured Visual Studio ... | <p>All of .net is available in the .net SDK, so in theory you will not need Visual Studio at all.</p>
<p>Now, there are some things that Express will not do. For example, the Database Designer is not very comprehensive and adding different remote databases is not or only very hardly possible. Still, in code you can con... | <p>Visual Studio is just the IDE. You could theoretically create every file in Notepad and compile manually with just the .net framework.</p>
<p>IIS is an operating system feature, and SQL Server has different flavors with different capabilites.</p>
| 7,572 |
<p>For a long time, I thought that to start a new project we only need 3 basic tools.
1) A Build System (e.g. Maven & CruiseControl)
2) A Version Control System (e.g. CVS & SVN & GIT)
3) A Bug Tracking System (e.g. Bugzilla)</p>
<p>Yesterday, a senior guy told me that we need at least one thing mo... | <p>A project management tool for team members, customers or users.</p>
<p>One of the most important parts is interacting with people, a project management tool allows you show the progress/milstone and organized the feature request, defect and resources along with other features like forum, nofications and document u... | <p>We've found a wiki to be invaluable for recording specs, designs, thoughts, questions, and just about any other "living" information we need to remember.</p>
<p>Atlassian offers Confluence, a very inexpensive ($1200) web-based wiki that just <em>worked</em> for us out of the box. It's very customizable but took al... | 31,878 |
<p>We are trying to look at optimizing our localization testing. </p>
<p>Our QA group had a suggestion of a special mode to force all strings from the resources to be entirely contained of X. We already API hijack LoadString, and the MFC implementation of it, so doing it should not be a major hurdle. </p>
<p>My quest... | <p>If this approach is to highlight formatted strings (or format sequences) in the application (i.e. all text appearing other than XXXX), you could locate the escape sequence (using regex perhaps) and insert block quotes around the formatted (substituted) values, <br>e.g. Some\ntext -> Some[\n]text</p>
<p>You get read... | <p>You can apply compiler theory here and generate your scanner and parser using <a href="http://dinosaur.compilertools.net/" rel="nofollow noreferrer">flex/bison</a> (lex/yacc, or whatever tools). You can define \w+ as word, which can match both "Hello" and "World" etc..</p>
| 23,089 |
<p>When creating a web application, and lets say you have a User object denoting a single user, what do you think is the best way to store that the user has logged in?</p>
<p>Two ways I've thought about have been:</p>
<ul>
<li>Stored the user database id in a session variable</li>
<li>Stored the entire user object in... | <p>I recommend storing the id rather than the object. The downside is that you have to hit the database every time you want to get that user's information. However, unless every millisecond counts in your page, the performance shouldn't be an issue. Here are two advantages:</p>
<ol>
<li><p>If the user's information... | <p>I store the user in the session, usually. The can't-change-until login problem can be solved by replacing the object in the session with a new copy after you've made changes.</p>
| 4,135 |
<p>Can you mix .net languages within a single project? So pre-compiled, I would like to call classes and methods of other source files.</p>
<p>For both web and apps? </p>
<p>In particular I'd be interested in F# and C#.</p>
| <p>You can mix languages in a single assembly with <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=22914587-B4AD-4EAE-87CF-B14AE6A939B0&displaylang=en" rel="noreferrer">ILMerge</a> and <a href="http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx" rel="noreferrer">MSBuild</a>.</p>
<p><a href="ht... | <p>you can specify the language in each assembly project (library DLL) and use several of these in the same solution, but i don't think you can mix languages within the same assembly</p>
| 23,895 |
<p>Here's my problem - I have some code like this:</p>
<pre><code><mx:Canvas width="300" height="300">
<mx:Button x="800" />
</mx:Canvas>
</code></pre>
<p>So the problem is that the Button inside the canvas has an x property way in excess of the Canvas's width - since it's a child of the Canvas... | <p>I figured it out - apparently the Container has a property called clipContent - here's the description from Adobe:</p>
<p><em>Whether to apply a clip mask if the positions and/or sizes of this container's children extend outside the borders of this container. If false, the children of this container remain visible ... | <p>You should be able to use the <strong>includeInLayout</strong> property also, which would allow you to apply it to each child component independently.</p>
| 18,835 |
<p>Is there any way to display scrollabletext in loose xaml? The equivalent in HTML would be </p>
<pre><code><div style="overflow:scroll">some long bit of text here</div>
</code></pre>
<p>Can you do this in loose xaml? </p>
<p>From my experiments so far it seems that in loose xaml:</p>
<ol>
<li>You ca... | <p>Typically, if you see an issue with authentication where it works in IE 6 but not IE 7, I'd check to make sure Kerberos is configured correctly.</p>
<p>Running as Network Service, your Kerberos SPNs should attached to the machine account. As a domain account, the SPN's need to be on that account.</p>
<p>As to why... | <p>You can try to disable "Enable integrated authentication" in Options, Advanced Settings.
But I don't know if there isn't some side effects.</p>
| 27,874 |
<p>I have a module that sends an email to a specified email address but I want to default the email recipient to the portal administrator. How can I retrieve this information?</p>
| <p>If you are in the context of a control inheriting from <code>PortalModuleBase</code>, <code>PortalSettings</code> is available as a property, so it would just look like</p>
<pre><code>PortalSettings.Email
</code></pre>
| <pre><code>' get the current portal
Dim portSettings As PortalSettings = PortalController.GetCurrentPortalSettings
' get email address
Dim email as string = portSettings.Email
</code></pre>
| 36,994 |
<p>I'm attempting to determine the row length in bytes of a table by executing the following stored procedure:</p>
<pre><code>CREATE TABLE #tmp
(
[ID] int,
Column_name varchar(640),
Type varchar(640),
Computed varchar(640),
Length int,
Prec int,
Scale int,
Nullable varchar(640),
TrimTrailing... | <p>How doing it this way instead? </p>
<pre><code>CREATE TABLE tblShowContig
(
ObjectName CHAR (255),
ObjectId INT,
IndexName CHAR (255),
IndexId INT,
Lvl INT,
CountPages INT,
CountRows INT,
MinRecSize INT,
MaxRecSize INT,
AvgRecSize INT,
ForRecCount INT,
Extents INT,
... | <p>I can't help you with creating a temp table to store sp_help information, but I can help you with calculating row lengths. Check out this <a href="http://msdn.microsoft.com/en-us/library/aa933068.aspx" rel="nofollow noreferrer">MSDN article</a>; it helps you calculate such based on the field lengths, type, etc. Prob... | 28,141 |
<p>I have this CheckBoxList on a page:</p>
<pre><code><asp:checkboxlist runat="server" id="Locations" datasourceid="LocationsDatasource"
datatextfield="CountryName" datavaluefield="CountryCode" />
</code></pre>
<p>I'd like to loop through the checkbox elements on the client using Javascript and grab the valu... | <p>I finally have the answer I've been looking for!</p>
<p>The asp.net CheckboxList control <em>does</em> in fact render the value attribute to HTML - it has been working for me in a Production site for over a year now! (We ALWAYS have EnableViewState turned off for all our sites and it still works, without any tweaks... | <p>Swapna, Your answer absolutely works. So in order to check if the check box in the ASP.Net Checkboxlist is checked and then accumulate the list as a comma-delimited string, you can do as</p>
<p>C# Code-behind</p>
<pre><code>ChkboxList1.DataSource = dsData;
ChkboxList1.DataTextField = "your-display-column-name";
Ch... | 21,740 |
<p>Yeah, its a bit on this side of pointless, but I was wondering... I've got all these codebehind files cluttering my MVC app. The only reason why I need these files, as far as I can tell, is to tell ASP.NET that my page extends from ViewPage rather than Page. </p>
<p>I've tried a couple different Page directives c... | <p>Delete the codebehind and use a page directive like this:</p>
<pre><code><%@ Page Title="Title" Inherits="System.Web.Mvc.ViewPage" Language="C#" MasterPageFile="~/Views/Layouts/Site.Master" %>
</code></pre>
<p>Or, if you want to get rid of the codebehind but still want to use strongly typed view, then read t... | <p>Straight out of the box you should be able to delete the .designer.cs and nothing will break. The other code behind can be useful, for instance if you'd like to strongly type your viewdata.</p>
| 24,223 |
<p>Where can I download a PyLucene+JCC Windows build compiled for python 2.6?</p>
<p>Jose</p>
| <p>Not tested but there appears to be an egg here:</p>
<p><a href="http://code.google.com/p/pylucene-win32-binary/" rel="nofollow noreferrer">http://code.google.com/p/pylucene-win32-binary/</a></p>
| <p>you might want to see <a href="http://mail-archives.apache.org/mod_mbox/lucene-pylucene-dev/200902.mbox/%3Calpine.OSX.2.00.0902181122530.1109@yuzu.local%3E" rel="nofollow noreferrer">this recent mailing list post</a> and the related thread. There's also a <a href="http://markmail.org/message/d6tfni5sdqywwfoy" rel="... | 43,867 |
<p>Just a simple question about my FEP sheet getting dented after print.
I just bought an Elegoo Mars 2 Pro and had trouble getting it to stick to the bed, after some painful bed leveling and realizing my exposure times were too low for maroon resin, I finally got it to stick to the bed by the 4th print.</p>
<p>Now bef... | <p>The rook is normally difficult to remove, it's designed this way.</p>
<p>Have you tried resetting the height of you build Plate?
If it makes a grinding sound when doing the first 2 or three layers your build plate might be traveling too low.</p>
<p>Also try re-leveling your build plate, e.g. I pushed so hard when I ... | <p>You have not done anything wrong!</p>
<p>Usually, each resin type is suitable for a specific VAT floor. For example, for PDMS floor you should use very specific types of resins.</p>
<p>FEP is known to be very strong and difficult to ruin. But still a couple of things you need to consider:</p>
<ul>
<li>When the resin... | 2,011 |
<p>I have a (derived) Menu control, that displays a rather large list of items from a custom data source. I need to disable ViewState on the menu to avoid the very annoying "Can't select a disabled or unselectable menu item" when some other control causes the current selection to change on a postback.</p>
<p>Unfortuna... | <p>I've figured out the essence of the problem. Using Reflector we can see the important part(s) of the low level method that handles the actual postback and then raises the event:</p>
<pre><code>string str = HttpUtility.HtmlDecode(eventArgument);
...
MenuItem item = this.Items.FindItem(str.Split(new char[] { '\\' }),... | <p>In Page_Load rebind the control to the sitemapdata and check if IsPostBack.</p>
<pre><code>if (IsPostBack) {
Menu.DataBind();
}
</code></pre>
<p>this work for me and reduce the viewstate.</p>
| 29,200 |
<p>I'd like to display a repeating event on a date/time display in an app. This date time display can take the form of a calendar, but it could also just be a list of upcoming events. </p>
<p><strong>What is the best way to handle tracking this event that can repeat?</strong> </p>
<p><em>For example: Should the e... | <p>I did something like this before and I based my schema off of SQL Servers sysschedules table.</p>
<p><a href="http://technet.microsoft.com/en-us/library/ms178644.aspx" rel="nofollow noreferrer">http://technet.microsoft.com/en-us/library/ms178644.aspx</a></p>
<p>The schema linked above will allow you to store the s... | <p>I think it depends on type of event it is. Is it like Christmas where once it comes along and happens you really aren't interested in it until the next occurrence? Or is it a task like, "Make sure I call my mom every month", where if it happens and you missed it you wouldn't want it to go away?</p>
<p>One way I r... | 46,645 |
<p>I'm more of a programmer than a designer, and I'm trying to embrace <code><div></code>s rather than using tables but am getting stuck.</p>
<p>Here's what I'm trying to do. I am setting up a survey page. I want each question's text to sit at the top of the blue div, and wrap if it's too long. I want all of ... | <p>Here is what I would do:</p>
<pre><code><div class="greencontainer">
<div class="redcontainer">
<input type="checkbox" />
</div>
<div class="bluecontainer">
<label>Text about this checkbox...</label>
</div>
</div>
</code></pre>
<p>with css:</p>
... | <p>Very little testing here, but I <em>think</em> you'll want "clear: both;" on .greencontainer instead of "float: left". Also remove "clear: both" from .bluecontainer</p>
<p>See more info at: <a href="http://www.quirksmode.org/css/clearing.html" rel="nofollow noreferrer">http://www.quirksmode.org/css/clearing.html</a... | 33,354 |
<p>I would like to be able to say things like</p>
<p><strong>cd [.fred]</strong> and have my default directory go there,
and my prompt change to indicate the full path to my current location.</p>
| <p>Just type</p>
<p><code>cd:==set default</code> </p>
<p>at the command prompt. You can also put this in your LOGIN.COM file, but be sure to put a $ in front, i.e.</p>
<p><code>$ cd:==set default</code></p>
<p>To change your prompt to show your default, something like this may work up to a point</p>
<p><code>$ se... | <p>Use HGSD which implements an SD (short for SET DEFAULT) command. Just google it. It is an improved version by Hunter Goatley of an older implementation.</p>
<p>The only thing it cannot handle (yet), are logicals with multiple translations. Other than that, It works like a charm, and you do not need to type in compl... | 15,869 |
<p>I'm currently modifying a Java script in Rational Functional Tester and I'm trying to tell RFT to wait for an object with a specified set of properties to appear. Specifically, I want to wait until a table with X number of rows appear. The only way I have been able to do it so far is to add a verification point that... | <p>No, there is not a built-in waitForProperty() type of method, so you cannot do something simple like tableObject.waitForProperty("rowCount", x);</p>
<p>Your options are to use a verification point as you already are doing (if it ain't broke...) or to roll your own synchronization point using a do/while loop and the... | <p>You can do one thing.... you can try getting the particular property and check that you are getting the desired value of that. If not then iterate in a IF loop.</p>
<pre><code>while (!flag) {
if (obj.getproperty(".text").equals("Desired Text")) {
flag = true
}
}
</code></pre>
| 12,168 |
<p>A good friend of mine works for a large asp.net shop, with a web farm with many web servers (dozens). The application logs exceptions and messages to the event log on each box (not to a centralized location).</p>
<p>Does anyone know of a convenient way to perform unified reporting on event logs on a number of diff... | <p>I would use <a href="http://logging.apache.org/log4net/index.html" rel="nofollow noreferrer">Log4Net</a> (or something similar) for the logging, saving the files to disk, and rotating log file periodically. (I'm not a big fan of the Windows event log, personally.) Then have a background service on each box which upl... | <p>Members of my ASP.Net development team are enthusiastic users of the free software from BareMetal called <a href="http://www.baremetalsoft.com/baretail/index.php" rel="nofollow noreferrer">Bare Tail</a> to read plain text log files when they need to quickly determine the source of a production issue. I believe that ... | 42,661 |
<p>I have a script which uses pexpect to start a CLI program. It works a bit like a shell where you get a prompt where you can enter some commands.</p>
<p>The problem I have, I think, is that this program uses a coloured prompt.</p>
<p>This is what I do </p>
<pre><code>import pprint
import pexpect
1 a = pexpect.spa... | <p>Ok, I found the answer. csl's answer set me on the right path.</p>
<p>pexpect has a "env" option which I thought I could use. like this:</p>
<pre><code>a = pexpect.spawn('program', env = {"TERM": "dumb"})
</code></pre>
<p>But this spawns a new shell which does not work for me, our development environment
depends... | <p>Couldn't find anything in <a href="http://pexpect.sourceforge.net/pexpect.html" rel="nofollow noreferrer">the pexpect documentation</a> for setting terminals, but you could probably start your program explicitly with a shell, and then set the terminal type there:</p>
<pre><code>shell_cmd = 'ls -l | grep LOG > lo... | 46,784 |
<p>I've upgraded my stepper drivers.</p>
<p>I'm looking to understand why my stepper motors made noise in the first place.</p>
| <p>Stepper motors contain two distinct sets of coils. The current in these coils is governed by your stepper motor driver.</p>
<p><a href="https://i.stack.imgur.com/RaDxb.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RaDxb.gif" alt="Stepper motor diagram (WikiForU.com)"></a></p>
<p>To move the mo... | <p>To make a stepper perform a step, block signals are send to energize the coils to position the rotor. Such a block signal causes abrupt motion and triggers harmonic frequencies. This is audible as stepper noise. If the block signal is smoothed, the motion is more fluent and less noise will be observed. A similar eff... | 1,388 |
<p>Suppose to have a code like this:</p>
<pre><code><div class="notSelected">
<label>Name
<input type="text" name="name" id="name" />
</label>
<div class="description">
Tell us what's your name to make us able to fake to be your friend
whe... | <p>I would recommend a look at jQuery for your task. It is quite easy to learn and produces nice effects quickly. But your described effect alone, pure JavaScript would also be enough.</p>
<p>Make your DIVs always have a class called "selectable". You can toggle other CSS classes later on. Create a CSS class named "se... | <p>Yet another unrelated-to-the-original-question answer but... jQuery also has an alternative syntax for doing mouseover/mouseout stuff called hover.</p>
<pre><code>$(element).hover(function(){ /* mouseover */ }, function(){ /* mouseout */ });
</code></pre>
<p>Example,</p>
<pre><code>$('ul#nav li').hover(function()... | 26,580 |
<p>I have many requires and includes and i was wondering if there's something that can help me look at the whole of php code when a webpage is loaded. the reason i'm asking is that after fiddling with some code i cannot put any php code anymore as it will not be "sensed" by the compiler. like if i put anything inside t... | <p>Not entirely sure what you are after...</p>
<p>The get_included_files function can allow you to view a list of all of the files php has loaded at that point.</p>
<p>You may also find using grep or the "find in files" function in your editor (if it has one) can help you track down something in the code that you kno... | <p>You can't look at PHP code that's not running on your computer. The idea is that the code inside the PHP tags (<code><?php ?></code>) is popped out, run, and then whatever the output is is snuck back in where the tags were before the final version is sent to your computer. Thus, you can't see the code on your ... | 44,520 |
<p>What are the C++ coding and file organization guidelines you suggest for people who have to deal with lots of interdependent classes spread over several source and header files?</p>
<p>I have this situation in my project and solving class definition related errors crossing over several header files has become quite... | <p>Some general guidelines:</p>
<ul>
<li>Pair up your interfaces with implementations. If you have <code>foo.cxx</code>, everything defined in there had better be declared in <code>foo.h</code>.</li>
<li>Ensure that every header file #includes all other necessary headers or forward-declarations necessary for independ... | <p>One more point in addition to the others here:</p>
<blockquote>
<p>Don't include any private definitions
in an include file. E.g. any
definition that is only used in
xxx.cpp should be in xxx.cpp, not
xxx.h. </p>
</blockquote>
<p>Seems obvious, but I see it
frequently.</p>
| 45,031 |
<p>I have 3 divs where only one is visible by default, they each contain information about a product. Below this divs is a list of 3 images which are images of the products. By default of course the 1st list item is selected and has <code>class="selected"</code>. When a different product image is clicks then <code>clas... | <p>Consider the following code:</p>
<pre><code><img id="img1" src="1.jpg" desc="d1" class="selected prodImg" />
<img id="img2" src="2.jpg" desc="d2" class="prodImg" />
<img id="img3" src="3.jpg" desc="d3" class="prodImg"/>
<div id="d1">description 1</div>
<div id="d2" class="hidden"&g... | <pre><code><script>
$(".prodImg").click(function() {
if ($(this).hasClass("selected")) return;
$('.prodImg').removeClass('selected');
$(this).addClass('selected');
var name = $(this).attr('desc');
$('.'+name).removeClass();
$('.'+name).addClass(''); ... | 28,870 |
<p>I need to get existing web pages into an existing ASP.NET web site project in Visual Studio 2008. I simply tried to drag and drop the whole file folder content into the Visual Studio Solution Explorer or even to copy them into the web site folder.</p>
<p>Both ways, Visual Studio seems unable to map the .designer.cs... | <p>It sounds like you are trying to bring web application files into a web site. <em>IIf that is the case</em>, The designer files are not even needed. Just dont include them. They are generated and compiled in at runtime when the website runs.</p>
| <p>try copying the files through the filesystem and then right clicking on the project and selecting to add an existing item at which point you can choose all at once and this usually puts them in the proper places.</p>
| 21,505 |
<p>I'm teaching/helping a student to program.</p>
<p>I remember the following process always helped me when I started; It looks pretty intuitive and I wonder if someone else have had a similar approach.</p>
<ol>
<li>Read the problem and understand it ( of course ) .</li>
<li>Identify possible "functions" and variable... | <p>I go via the test-driven approach.</p>
<h3>1. I write down (on paper or plain text editor) a list of tests or specification that would satisfy the needs of the problem.</h3>
<pre><code>- simple calculations (no discounts and concessions) with:
- single item
- two items
- maximum number of items that does... | <p>Keep in mind, if you get 5% off then another 5% off, you don't get 10% off. Rather, you pay 95% of 95%, which is 90.25%, or 9.75% off. So, you shouldn't add the percentage.</p>
| 16,614 |
<p>I want to insert a new row into an Access database. I'm looking at doing something like: </p>
<pre><code>oConnection = new Connection("connectionstring")
oTable = oCennection.table("Orders")
oRow = oTable.NewRow
oRow.field("OrderNo")=21
oRow.field("Customer") = "ABC001"
oTable.insert
</code></pre>
<p>Which seems t... | <p>This is one way: </p>
<pre><code>cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\emp.mdb;")
cn.Open()
str = "insert into table1 values(21,'ABC001')"
cmd = New OleDbCommand(str, cn)
cmd.ExecuteNonQuery
</code></pre>
<p>I would make a dataset, add a tableadapter connected to the Access dat... | <p>Unfortunately, the world doesn't re-arrange itself to suit how you think it should work. If you want to work with a database, it's a good idea to get at least somewhat comfortable with SQL, as that is generally how it's done.</p>
<p>On the bright side, there is a whole category of products that do kind of what you... | 43,770 |
<p>How often does Akamai refresh cache?</p>
<p>We use Akamai to cache frequently accessed files. When uploading and overwriting files to the Akamai FTP, I can't see the new file reflected live.</p>
<p>Anybody have any experience with this?</p>
| <p>It is configurable. You will need to talk to whoever in your organisation manages your Akamai account. They will have access to change how and what things are cached. If necessary, they can put you in touch with a technical contact at Akamai.</p>
| <p>Files on the Akamai network can be tuned with whatever cache configuration the end customer requires. Typically the two most common approaches to cache design I see are:</p>
<ol>
<li>Configuring based on file extension. (e.g. *.css, *.js, etc)</li>
<li>Configuring based on path. (/product/test /checkout, etc)</li>
... | 45,769 |
<p>I have just edited a new post, <a href="https://3dprinting.stackexchange.com/questions/4153/help-understanding-bridge-settings">Help understanding bridge settings</a>, so that the video would be "inlined" and playable in the post itself<sup>1</sup>.</p>
<p>However, the video does not show up, and only the ... | <p>Per answer to <a href="https://meta.stackexchange.com/questions/296832/what-are-the-limitations-in-beta">What are the limitations in Beta</a></p>
<p>"Inline videos is a feature that is off by default on all sites and only turned on if the community thinks it's necessary to improve the quality of a good portion of t... | <p>A note of caution, <a href="https://stackoverflow.com/c/moderators/questions/257#answer-261">this post</a> on the Stack Moderators site, Pᴀᴜʟsᴛᴇʀ2's post, <a href="https://stackoverflow.com/c/moderators/questions/257">How do you request embedded video for your site?</a> - As mods can only follow these links I've inc... | 41 |
<p>I have long tables generated by datagrid control that go beyond the page width. I would like to convert that into separate table for each row or definition list where each field name is followed by field value.</p>
<p>How would I do that. </p>
| <p>Uses jquery. If you have more than one table you'll need to change it to accommodate that. Also, just appends to the end of the document. If you want it elsewhere, find the element you want to place it after and insert it into the DOM at that point.</p>
<pre><code>$(document).ready(
function() {
var... | <p>Here's a reference:</p>
<p><a href="http://www.mail-archive.com/flexcoders@yahoogroups.com/msg15534.html" rel="nofollow noreferrer">http://www.mail-archive.com/flexcoders@yahoogroups.com/msg15534.html</a></p>
<p>The google terms I think you want are "invert datagrid". You'll get lots of hits.</p>
| 37,584 |
<p>I've been asked to help out on an XNA project with the AI. I'm not totally new to the concepts (pathfinding, flocking, etc.) but this would be the first "real" code. I'd be very thankful for any resources (links or books); I want to make sure I do this right.</p>
| <p>The standard textbook and a great place to start is Russel and Norvig's <a href="https://rads.stackoverflow.com/amzn/click/com/0137903952" rel="noreferrer" rel="nofollow noreferrer"><em>Artificial Intelligence: A Modern Approach</em></a>. You can also get <a href="http://ocw.mit.edu/OcwWeb/Electrical-Engineering-an... | <p>I would second: Programming Game AI by example (Matt Buckland) </p>
<p>This book gives great algorithms that should easly port to XNA.</p>
| 4,443 |
<p>I'm wondering if this is a good design. I have a number of tables that require address information (e.g. street, post code/zip, country, fax, email). Sometimes the same address will be repeated multiple times. For example, an address may be stored against a supplier, and then on each purchase order sent to them. ... | <p>I actually use this as one of my interview questions. The following is a good place to start:</p>
<pre><code>Addresses
---------
AddressId (PK)
Street1
... (etc)
</code></pre>
<p>and</p>
<pre><code>AddressTypes
------------
AddressTypeId
AddressTypeName
</code></pre>
<p>and</p>
<pre><code>UserAddresses (substi... | <p>In the case of orders, you would never want to update the address as the person (or company) address changed if the order has been sent. You meed the record of where the order was actually sent if there is an issue with the order.</p>
<p>The address table is a good idea. Make a unique constraint on it so that the s... | 39,506 |
<p>Where X is any programming language (C#, Javascript, Lisp, Perl, Ruby, Scheme, etc) which supports some flavour of closures. </p>
<p>Some limitations are mentioned in the <a href="http://ivan.truemesh.com/archives/000411.html" rel="noreferrer">Closures in Python</a> (compared to Ruby's closures), but the article i... | <p>The most important limitation, currently, is that you cannot assign to an outer-scope variable. In other words, closures are read-only:</p>
<pre><code>>>> def outer(x):
... def inner_reads():
... # Will return outer's 'x'.
... return x
... def inner_writes(y):
... # Will as... | <p>The better workaround until 3.0 is to include the variable as a defaulted parameter in the enclosed function definition:</p>
<pre>
def f()
x = 5
def g(y, z, x=x):
x = x + 1
</pre>
| 17,121 |
<p>We are about to get a canned package in that has been modified to our needs. I'm part of the team setup to prepare tests for it. It has an Oracle back end and I believe it's written in C++ .NET.</p>
<p>My question is what free or open source testing tools would you recommend.</p>
<p>Thanks</p>
<p>Ken</p>
| <p>For regression testing of our applications I use a free tool called AutoHotKey <a href="http://www.autohotkey.com/" rel="nofollow noreferrer">http://www.autohotkey.com/</a>. It is simple, batch configurable, and can work for virtually any application you have. Not exactly designed for black box testing, but a good f... | <p>What do you expect from such a tool? I don't know of any tool that can arbitrarily test any piece of software.</p>
| 6,323 |
<p>If I have an object implementing the <code>Map</code> interface in Java and I wish to iterate over every pair contained within it, what is the most efficient way of going through the map?</p>
<p>Will the ordering of elements depend on the specific map implementation that I have for the interface?</p>
| <pre class="lang-java prettyprint-override"><code>Map<String, String> map = ...
for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println(entry.getKey() + "/" + entry.getValue());
}
</code></pre>
<p>On Java 10+:</p>
<pre class="lang-java prettyprint-override"><code>for (var e... | <p>I copied the data of a map to another with this code:</p>
<pre><code>HashMap product =(HashMap)shopping_truck.get(i);
HashMap tmp = new HashMap();
for (Iterator it = product.entrySet().iterator(); it.hasNext();) {
Map.Entry thisEntry = (Map.Entry) it.next();
tmp.put(thisEntry.getKey(), thisEntry.getValue())... | 6,906 |
<p>I have been learning about the basics of C# but haven't come across a good explanation of what this is:</p>
<pre><code>var l = new List<string>();
</code></pre>
<p>I don't know what the <code><string></code> is doing or if it's the <code>List</code> that is doing the magic. I have also seen objects bee... | <p>That is the generic syntax for C#.</p>
<p>The basic concept is that it allows you to use a Type placeholder and substitute the actual real type in at compile time.</p>
<p>For example, the old way:</p>
<pre><code>ArrayList foos = new Arraylist();
foos.Add("Test");
</code></pre>
<p>worked by making ArrayList store... | <p>< > is for generics. In your specific example, it means that the List is a List of strings, not say a list of ints.</p>
<p>Generics are used to allow a type to be, well, generic. It's used ALOT in Collections to allow them to take different types so that they can function much like a normal array and still catch... | 18,774 |
<p>Is there a way to detect if the user is holding down the shift key (or other modifier keys) when executing a javascript bookmarklet?</p>
<p>In my tests of Safari 3.1 and Firefox 3, <code>window.event</code> is always undefined.</p>
| <p>If you're looking for a way to detect the mouse position while the bookmarklet is being physically clicked, no, there is no way. Since the bookmarklet is positioned outside of any page (this area is generally called the browser "chrome" - which is confusing since there's now a browser with that name) it's not possib... | <p>window.event is an IE only. Event objects are passed to an event listener as an argument in firefox and safari. So you can tell in IE, but not in any other popular browser.</p>
| 17,052 |
<p>I'm putting together a script to find remove duplicates in a large library of images. At the moment I'm doing a two pass filter of first finding files of the same size and then doing a sha256 on a 10240 byte piece of the file to get a fingerprint of the files with the same size (code <a href="http://parand.com/say/i... | <p>I don't think the JPEG specification includes any kind of checksum in the way you're describing.</p>
<p>A JPEG can contain a thumbnail as part of its EXIF metadata, though. It's not a perfect indicator, since it's possible for two different images to have the same thumbnail. There's at least one documented case o... | <p>In JPEG standard(ITU-T.81) i believe there isn't any field/syntax element which has a checksum or such, for the whole compressed jpeg image file. Unless a customised application puts such filed in the Application segment, or as meta data for which segments are provided in the standard.
So to serve your purpose, what... | 26,734 |
<p>I'm programming an application for a <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2591" rel="nofollow noreferrer">32 bit processor with limited memory</a> (512k flash, 32k RAM).</p>
<p>The <a href="http://www.newhavendisplay.com/index.cfm/page/ptype=product/product_id=524/cate... | <p>In a way, you are in pretty much the same situation game developers where at the time of the Tandys, Spectrums and early PCs. So, here's my recommendation:</p>
<p>You should read Michael Abrash writings on computer graphics. They were written in a time where a floating point co-processor was an optional piece of ha... | <p>Some ideas that would combine nice graphics and low memory:</p>
<ul>
<li>Store backgrounds and sprites in flash.</li>
<li>Store dynamically generated graphics in RAM using a palette to half the bytes.</li>
<li>Use the windowing feature of the LCD driver to only update the part of the screen you need to.</li>
</ul>
| 20,998 |
<p>I'm using this database where the date colomn is a numeric value instead of a Date value. </p>
<p>Yes, I know I can change that with a mouseclick, but all the applications using that database were made by one of my predecessors (and everyone after him just ignored it and built on). So if I'd change it to Date a lot... | <p>Access will convert to a number for you, as was mentioned, the dates are stored as numbers.</p>
<pre><code>Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("TestTable")
rs.AddNew
rs!NumberDate = Now() 'Value stored, eg, 39791.4749074074 '
rs.Update
rs.MoveLast
'To show that it converts back to the corre... | <p>Access stores date internally as a floating point number (number of days since 31.12.1899 or something), have you tried using CDate() to convert the number back to a date? You should be able to query using BETWEEN then.</p>
<p>Another possibility is that the date is stored numerically but not converted (i.e 3112189... | 45,869 |
<p>Has anyone implemented Lightbox style background dimming on a modal dialog box in a MFC/non .net app.<br>
I think the procedure would have to be something like:</p>
<p>steps:</p>
<ol>
<li><p>Get dialog parent HWND or CWnd* </p></li>
<li><p>Get the rect of the parent window and draw an overlay with a translucen... | <p>Here's what I did* based on Brian's links<br>
First create a dialog resource with the properties:</p>
<ul>
<li>border <strong>FALSE</strong></li>
<li>3D look <strong>FALSE</strong></li>
<li>client edge <strong>FALSE</strong></li>
<li>Popup style</li>
<li>static edge <strong>FALSE</strong></li>
<li>Transparent <stro... | <p>I think you just need to create a window and set the transparency. There is an MFC <a href="http://www.codeproject.com/KB/dialog/CGlassDialog.aspx" rel="nofollow noreferrer">CGlassDialog sample on CodeProject</a> that might help you. There is also an <a href="http://www.codeproject.com/KB/winsdk/quaker1.aspx" rel="n... | 7,490 |
<p>What is the correct way to do this? For example, how would I change a stored procedure with this signature:</p>
<pre><code>CREATE PROCEDURE dbo.MyProcedure
@Param BIT = NULL
AS
SELECT *
FROM dbo.SomeTable T
WHERE T.SomeColumn = @Param
</code></pre>
<p>So that giving @Param with a value of 1 or 0 performs t... | <p>Assuming that NULL means "don't care" then use</p>
<pre><code>CREATE PROCEDURE dbo.MyProcedure
@Param BIT = NULL
AS
SELECT *
FROM dbo.SomeTable T
WHERE T.SomeColumn = @Param OR @Param IS NULL
</code></pre>
| <p>I happen to think that the cleanest way of doing this is (in T-SQL) is:</p>
<pre><code>SELECT * FROM TABLE WHERE column = ISNULL(@param, column)
</code></pre>
<p>Other RDBMS would prefer COALESCE instead of ISNULL.</p>
<p>I think it's more obvious what the intent is here, especially as you start to add other OR c... | 23,322 |
<p>I want to create a class that takes string array as a constructor argument and has command line option values as members vals. Something like below, but I don't understand how the Bistate works.</p>
<pre><code>import scalax.data._
import scalax.io.CommandLineParser
class TestCLI(arguments: Array[String]) extends C... | <p>Here are shorter alternatives to that pattern matching to get a boolean:</p>
<pre><code>val opt1 = result(opt1Option).isInstanceOf[Positive[_]]
val opt2 = result(opt2Option).posValue.isDefined
</code></pre>
<p>The second one is probably better. The field <strong>posValue</strong> is an Option (there's <strong>negV... | <p>So if I want to assign to variable boolean value of whether flag is found I have to do like below?</p>
<pre><code>val opt1 = result(opt1Option) match {
case Positive(_) => true
case Negative(_) => false
}
</code></pre>
<p>Isn't there a way to write this common case with less code than that?</p>
| 31,364 |
<p>Which browsers other than Firefox support Array.forEach()? <a href="http://developer.mozilla.org/En/Core_JavaScript_1.5_Reference:Objects:Array:forEach#Compatibility" rel="noreferrer">Mozilla say it's an extension to the standard</a> and I realise it's trivial to add to the array prototype, I'm just wondering what ... | <p>The <a href="http://en.wikipedia.org/wiki/JavaScript" rel="noreferrer" title="JavaScript - Wikipedia, the free encyclopedia">JavaScript</a> article of Wikipedia lists the JS versions by browser. forEach is <a href="http://developer.mozilla.org/en/New_in_JavaScript_1.6" rel="noreferrer" title="New in JavaScript 1.6">... | <p>If you need all browsers to support this and other JavaScript 1.6 to 1.8 functions, I would suggest using the customizable <a href="http://jpaq.org/" rel="nofollow" title="jPaq">jPaq</a> library. The functions are implemented in the way that was suggested by Mozilla.</p>
| 18,958 |
<p>I'm trying to debug a rather complicated formula evaluator written in T-SQL UDFs (don't ask) that <strong>recursively</strong> (but indirectly through an intermediate function) calls itself, blah, blah.</p>
<p>And, of course, we have a bug.</p>
<p>Now, using PRINT statements (that can then be read from ADO.NET by ... | <p>Why not use SQL Profiler with statement level events added?</p>
<p><strong>Edit</strong>: Add events for Stored Procedures : SP:Stmt Starting or SP:Stmt Completed
Use variables to debug if needed, i.e. set @debug='i am here'; UDF's, while not technically stored procedures, will get traced with the statement level e... | <p>I second the SQL Profiler suggestion. Take some time to set it up so that only the events you are interested in are logged to cut output size. You can output the trace to a file - I have frequently then loaded that file back into a table to enable analysis. (extremely handy for performance analysis, though no doubt ... | 45,920 |
<p>I seem to make this mistake every time I set up a new development box. Is there a way to make sure you don't have to manually assign rights for the ASPNET user? I usually install .Net then IIS, then Visual Studio but it seems I still have to manually assign rights to the ASPNET user to get everything running correct... | <p>Install IIS, then .NET. The .NET installation will automatically register the needed things with IIS.</p>
<p>If you install .NET first, run this:</p>
<pre><code>%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i
</code></pre>
<p>to run the registration parts, and </p>
<pre><code>%windir%\Microsoft... | <p>If you install first IIS and then .Net, it'll be OK.</p>
<p>In your scenario - use <a href="http://msdn.microsoft.com/en-us/library/k6h9cz8h(VS.80).aspx" rel="nofollow noreferrer">Aspnet_regiis.exe -qa <em>user</em></a> (not available for .Net < 2.0)</p>
| 11,373 |
<p>Visual Studio Solution files contain two GUID's per project entry. I figure one of them is from the AssemblyInfo.cs</p>
<p>Does anyone know for sure where these come from, and what they are used for?</p>
| <p>Neither GUID is the same GUID as from AssemblyInfo.cs (that is the GUID for the assembly itself, not tied to Visual Studio but the end product of the build).</p>
<p>So, for a typical line in the sln file (open the .sln in notepad or editor-of-choice if you wish to see this):</p>
<pre><code>Project("{FAE04EC0-301F-... | <p><a href="http://msdn.microsoft.com/en-us/library/bb165951(VS.80).aspx" rel="noreferrer">According to MSDN</a>: </p>
<blockquote>
<p>[The <code>Project</code>] statement contains the
unique project GUID and the project
type GUID. This information is used by
the environment to find the project
file or files... | 7,642 |
<p>This is a follow on to this <a href="https://stackoverflow.com/questions/232500/how-to-configure-security-when-calling-wcf-service-from-net-20-client">question</a>. I am trying to avoid using the x509 certificate method as that makes my client installs more complex. If basicHttpBinding is not the only option, wher... | <p>The problem isn't a mismatch between .Net 2.0 services and WCF and the various bindings - they are (with a few notable exceptions that shouldn't be a problem in your case) very compatible protocols.</p>
<p>WSE 3.0 (which runs on the 2.0 .Net framework) is particularly close. You can use this with either basicHttpBi... | <p>You could require SSL + Username/Password with basicHttp.</p>
<p>First the below is what your client would use in .NET 2.0 to auth w/ your WCF service.</p>
<pre><code>Dim client As WebServiceClient = New WebServiceClient("basicHttpWebService")
client.ClientCredentials.UserName.UserName = "username"
client.ClientCr... | 29,070 |
<p>I'm writing an article about editing pages in order to hand pick what you really want to print. There are many tools (like "Print What you like") but I also found this script. Anyone knows anything about it? I haven't found any kind of documentation or references.</p>
<pre><code>javascript:document.body.contentEdit... | <p>The contentEditable property is what you want -- It's supported by IE, Safari (and by chrome as a byproduct), and I <em>think</em> firefox 3 (alas not FFX2). And hey, it's also part of HTML5 :D</p>
<p>Firefox 2 supports designMode, but that is restricted to individual frames, whereas the contentEditable property a... | <p>It enables the browser's in-built editing functionality where available. As is mentioned above, designMode is Gecko and contentEditable is everyone else (and added to Gecko 1.9). These features are used as the basis of (nearly?) every WYSIWYG editor built with HTML/Javascript. If you're simply typing/deleting, nothi... | 21,274 |
<p>I'm interested in using an Object-Relational Mapping package for an upcoming project. This project will begin as an ASP.NET application but will have lots of functionality that will eventually be shared with WinForms applications. Can anyone suggest some good, free ORM packages that work well in both ASP.NET and W... | <p>SubSonic is not as extensive as nHibernate; rather, it is a straight forward Active Record 1 class per table Data Access Layer. </p>
<p>Some of the features are a query tool, ability to execute stored procedures and a scaffolding app in ASP.net. You can be up and running within 30 minutes or less, with a tiny lear... | <p>I've been using SubSonic for about a year now for a handful of ASP.NET apps as well as a WinForms app. It is extremely easy to get started with and I have not yet been "painted into a corner" by choosing it -- there is almost always some way to do what you need, usually easily. I estimate it has shaved 30% off of ou... | 25,263 |
<p>Is there a simple attribute or data contract that I can assign to a function parameter that prevents <code>null</code> from being passed in C#/.NET? Ideally this would also check at compile time to make sure the literal <code>null</code> isn't being used anywhere for it and at run-time throw <code>ArgumentNullExcep... | <p>There's nothing available at compile-time, unfortunately.</p>
<p>I have a bit of a <a href="https://web.archive.org/web/20081231232311/http://msmvps.com/blogs/jon_skeet/archive/2008/10/06/non-nullable-reference-types.aspx" rel="noreferrer">hacky solution</a> which I posted on my blog recently, which uses a new stru... | <p>Ok this reply is a bit late, but here is how I am solving it:</p>
<pre><code>public static string Default(this string x)
{
return x ?? "";
}
</code></pre>
<p>Use this exension method then you can treat null and empty string as the same thing.</p>
<p>E.g. </p>
<pre><code>if (model.Day.Default() == "")
{
/... | 37,155 |
<p>I have created a timeclock application in C# that connects to a web service on our server in order to clock employees in/out. The application resides in the system tray and clocks users out if they shut down/suspend their machines or if they are idle for more than three hours to which it clocks them out at the time ... | <p>The best way is going to be to actually try to make the connection and catch the errors. You can ping the machine, but that will only tell you if the machine is running and on the network, which doesn't necessarily reflect on whether the webservice is running and available.</p>
| <p>When handling the event, put your connection code into a method that will loop through until success, catching errors and retrying. </p>
<p>Even a delay wouldn't be perfect as depending on the individual systems and other applications running it can take varying times for the network connection to be re-established... | 16,352 |
<p>The Alt+Space command doesn't work on Putty (at least for me). So, if I've to minimize or maximize my PuTTY windows, I'll have to use the mouse which is very uncomfortable. Did anyone get around this problem?</p>
<p>Thanks for your time!</p>
| <p>Never mind, there's a setting for that.</p>
<p>Window -> Behavior -> (System Menu Appears on Alt+SPACE checkbox)</p>
| <p>You should go to Window/Behavior and check Full screen on Alt-Enter. Save the session, so you'll be able to use this shortcut to convert into full screen mode.</p>
| 33,260 |
<p>I have this .NET web app that draws a table in Page_Load.</p>
<p>Then after that it handles the events, which should change the table drawn in Page_Load.
This is very inefficient.</p>
<p>Is there a way to execute the code (which draws the table) after it finishes handling all events? (instead of doing it in Page_L... | <p>You need to handle an event that occurs after the control events, but before the page is rendered, such as <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.page.loadcomplete.aspx" rel="nofollow noreferrer">LoadComplete</a> or <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.control.preren... | <p>Check out the OnPreRender event in the page lifecycle.</p>
<p>-Oisin</p>
| 39,592 |
<p>Given an array like {"one two", "three four five"}, how'd you calculate the total number of words contained in it using LINQ?</p>
| <p>You can do it with SelectMany:</p>
<pre><code>var stringArray = new[] {"one two", "three four five"};
var numWords = stringArray.SelectMany(segment => segment.Split(' ')).Count();
</code></pre>
<p><a href="http://msdn.microsoft.com/en-us/library/system.linq.enumerable.selectmany.aspx" rel="nofollow noreferrer">... | <p>Not an answer to the question (that was to use LINQ to get the combined word count in the array), but to add related information, you can use strings.split and strings.join to do the same:</p>
<p>C#:</p>
<pre><code>string[] StringArray = { "one two", "three four five" };
int NumWords = Strings.Split(Strings.Join(... | 48,810 |
<p>Is it possible for the .NET CLR to support Objective-C? Are there any reasons (either from a legal or implementational) standpoint why this wouldn't be possible?</p>
<p>In the spirit of cross-platform application development, it would be nice to be able to write and run Objective-C applications on Windows machines. ... | <p>Objective-C is a strict superset of C. As such, it's got a lot of features, like pointers, that translate poorly onto .NET. Of course, it may be that -- in practice -- most Objective-C programs are written in such a way that they would also compile against a more tightly-defined version of the language specificatio... | <p>What about <a href="https://en.wikipedia.org/wiki/Objective-J" rel="nofollow noreferrer">Objective-J</a> and <a href="https://en.wikipedia.org/wiki/Cappuccino_(software)" rel="nofollow noreferrer">Cappuccino</a> for .Net, rather than Objective-C and <a href="https://en.wikipedia.org/wiki/Cocoa_%28API%29" rel="nofoll... | 30,479 |
<p>How would you handle cross database queries in different environments. For example, db1-development and db2-development, db1-production and db2-production. </p>
<p>If I want to do a cross-database query in development from db2 to db1 I could use the fully qualified name, [db1-development].[schema].[table]. But ho... | <p>Why are the database names different between dev and prod? It'd, obviously, be easiest if they were the same.</p>
<p>If it's a single table shared, then you could create a view over it - which only requires that you change that view when moving to production.</p>
<p>Otherwise, you'll want to <a href="http://msdn.m... | <p>For this reason, it's not practical to use different names for development and production databases. Using the same db name on development, production, and optionally, acceptance/Q&A environments, makes your SQL code much easier to maintain.</p>
<p>However, if you really have to, you could get creative with vie... | 40,615 |
<p>So I have xml that looks like this:
</p>
<pre class="lang-html prettyprint-override"><code><todo-list>
<id type="integer">#{id}</id>
<name>#{name}</name>
<description>#{description}</description>
<project-id type="integer">#{project_id}</project-id>
&l... | <p>Create a class for each element that has a property for each element and a List or Array of objects (use the created one) for each child element. Then call System.Xml.Serialization.XmlSerializer.Deserialize on the string and cast the result as your object. Use the System.Xml.Serialization attributes to make adjustme... | <p>i had the same questions few years back that how abt mapping xml to C# classes or creating C# classes which are mapped to our XMLs, jst like we do in entity Framework (we map tables to C# classes). I created a framework finally, which can create C# classes out of your XML and these classes can be used to read/write ... | 28,026 |
<p>I have an array of characters that are Points and I want to take any character and be able to loop through that array and find the top 3 closest (using Point.distance) neighbors. Could anyone give me an idea of how to do this?</p>
| <p>This is a new and improved version of the code I posted last night. It's composed of two classes, the PointTester and the TestCase. This time around I was able to test it too!</p>
<p><strong>We start with the TestCase.as</strong></p>
<pre><code>package {
import flash.geom.Point;
import flash.display.Spri... | <p>It might be worth mentioning that, if the number of points is large enough for performance to be important, then the goal could be achieved more quickly by keeping two lists of points, one sorted by X and the other by Y. One could then find the closest 3 points in O(logn) time rather than O(n) time by looping throug... | 19,226 |
<p>How can we get information regarding poorly performing sqls(taking too much time for execution)</p>
<p>Does MS SQL server maintains tables/views (Similar to v$sql in Oracle) for storing sql queries.</p>
| <p>I Use the SQL Profiler to collect statistic data wich I then can use to nail down where there are need to do some work, tweak indexes and so on.</p>
<p>Here are some tips about monitoring with Profiler:
<a href="http://www.developer.com/db/article.php/3490086" rel="nofollow noreferrer">http://www.developer.com/db/a... | <p>take a look at sys.dm_exec_query_stats and <a href="http://glennberrysqlperformance.spaces.live.com/blog/cns!45041418ECCAA960!828.entry" rel="nofollow noreferrer">this page</a>. SQL Server 2005+ only.</p>
| 40,973 |
<p>On occasion, I get the following error in design mode of some user controls in Visual Studio 2008:</p>
<blockquote>
<p>The file 'UserControl.vb' does not
support code parsing or generation
because it is not contained within a
project that supports code.</p>
</blockquote>
<p>It doesn't happen on a consisten... | <p>It is a bug in VS. It happens in VS2005 as well. </p>
<p>Don't waste your time: close VS, open it again and everything should work fine.</p>
| <p>I had reverted (through source control) changes to my project file, which removed the file from my solution (specifically the .Designer file). However, I still had the file open in Visual Studio and attempting to show the designer for it caused this error.</p>
<p>I clicked the "Show All Files" button at the top of ... | 48,245 |
<p>I am playing with Microsoft's TreeView control and I am trying to force a data update of some sorts while editing a node's label, similar to UpdateData for a grid.</p>
<p>Basically, in my editor, I have a Save button and this TreeView control: what I want is when I am editing a node's label in the TreeView, if I cl... | <p><code>volatile</code> is needed if you are reading from a spot in memory that, say, a completely separate process/device/whatever may write to.</p>
<p>I used to work with dual-port ram in a multiprocessor system in straight C. We used a hardware managed 16 bit value as a semaphore to know when the other guy was don... | <p>One use I should remind you is, in the signal handler function, if you want to access/modify a global variable (for example, mark it as exit = true) you have to declare that variable as 'volatile'.</p>
| 9,816 |
<p>How do you go about checking that an IIS website is successfully using Kerberos and not falling back on NTLM?</p>
| <p>One way I found to test in code that you are using Kerberos is that that the HTTP_AUTHORIZATION header for NTLM always starts with the following:</p>
<pre><code>Negotiate TlRMTVNTUA
</code></pre>
<p>If the header doesn't start with text then the browser is authenticating using Kerberos.</p>
| <p>Well, Negotiate can also be Kerberos, because it is a wrapper over Kerberos and NTLM. Like other guys said, Wireshark (or Network Monitor) and Security event log will not cheat you.</p>
| 40,849 |
<p>This web page <a href="http://www.w3schools.com/ASP/prop_sessionid.asp" rel="noreferrer">http://www.w3schools.com/ASP/prop_sessionid.asp</a> states that a session ID is generated on the ServerSide.</p>
<p>If this is the case, then how does a server know it's still the same client on the 2nd request response cycle? ... | <p>The SessionID is generated Server Side, but is stored on the Client within a Cookie. Then everytime the client makes a request to the server the SessionID is used to authenticate the existing session for the client.</p>
| <p>The server will generate a session id if none exists. But once it has been generated, the client can pass that id back to the server. If the client modifies that id, you would likely get an error from the server, and a new id generated.</p>
| 28,946 |
<p>How to print line numbers to the log. Say when outputting some information to the log, I also want to print the line number where that output is in the source code. As we can see in the stack trace, it displays the line number where the exception has occurred. Stack trace is available on the exception object.</p>
<... | <p>From <a href="https://web.archive.org/web/20100818065334/http://blog.taragana.com:80/index.php/archive/core-java-how-to-get-java-source-code-line-number-file-name-in-code/" rel="noreferrer">Angsuman Chakraborty</a> (archived) :</p>
<pre><code>/** Get the current line number.
* @return int - Current line number.
*/... | <p>My way it works for me</p>
<pre><code>String str = "select os.name from os where os.idos="+nameid; try {
PreparedStatement stmt = conn.prepareStatement(str);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
a = rs.getString("os.n1ame");//<<<----Here is the ERROR ... | 14,031 |
<p>What happen when SQL Server 2005 happen to reach the maximum for an IDENTITY column? Does it start from the beginning and start refilling the gap? </p>
<p>What is the behavior of SQL Server 2005 when it happen?</p>
| <p><strong>You will get an overflow error when the maximum value is reached</strong>. If you use the bigint datatype with a maximum value of <code>9,223,372,036,854,775,807</code> this will most likely never be the case. </p>
<p>The error message you will get, will look like this:</p>
<pre><code>Msg 220, Level 16, St... | <p>If the identity column is an Integer, then your max is 2,147,483,647. You will get an overflow error if you exceed it. </p>
<p>If you think this is a risk, just use the BIGINT datatype, which gives you up to 9,223,372,036,854,775,807. Can't imagine a database table with that many rows.</p>
<p>Further discussion <a... | 32,787 |
<p>I'm confused by the discussion and advancement both of a new version of HTML and a new version of XHTML. Are they competitors? If so, what is likeliest to be the adopted future of the web? If not, what is the differing non-competing purpose for each?</p>
<p>Are we due to have a BluRay/HDVD battle here? Is there ult... | <p>HTML 5 is meant for web applications whereas XHTML2 is meant for documents. From the <a href="http://www.w3.org/TR/html5/introduction.html#relationship0" rel="nofollow noreferrer">HTML 5 working draft</a>:</p>
<blockquote>
<p>XHTML2 defines a new HTML vocabulary with better features for hyperlinks, multimedia conten... | <p>From what I was able to find in a quick google search, I would suggest that these are indeed competing standards. Both are attempting to advance web technology but are following different paths to do so. </p>
<p>For a pretty thorough treatment of the matter you might look at these two links:</p>
<p><a href="http:/... | 17,484 |
<p>I have some data of the form</p>
<pre><code>Key ID Link
1 MASTER 123
2 AA 123
3 AA 123
4 BB 123
5 MASTER 456
6 CC 456
</code></pre>
<p>I would like to be able to select in the same select all linked items matching the selection criteria, plus the l... | <p>Here's one method.</p>
<pre><code>SELECT DISTINCT key, id, link
FROM the_table
START WITH id = 'AA'
CONNECT BY id = 'MASTER' and link = PRIOR link and 'AA' = PRIOR ID
</code></pre>
| <p>SELECT * FROM table_name WHERE ID=your_id UNION ALL SELECT * FROM table_name WHERE ID='MASTER' AND link = (SELECT link FROM table_name WHERE ID=your_id)</p>
<p>That should answer to the question I understood ;)</p>
| 38,739 |
<p><a href="https://rads.stackoverflow.com/amzn/click/com/020161622X" rel="noreferrer" rel="nofollow noreferrer">The Pragmatic Programmer</a> advocates the use of code generators.
Do you create code generators on your projects? If yes, what do you use them for?</p>
| <p>Code generators if used widely without correct argumentation make code less understandable and decrease maintainability (the same with dynamic SQL by the way). Personally I'm using it with some of ORM tools, because their usage here mostly obvious and sometimes for things like searcher-parser algorithms and grammat... | <p>Yes I've had to maintain a few. CORBA or some other object communication style of interface is probably the general thing that I think of first. You have object definitions that are provided to you by the interface you are going to talk over but you still have to build those objects up in code. Building and runni... | 13,837 |
<p>I want to have a text box that the user can type in that shows an Ajax-populated list of my model's names, and then when the user selects one I want the HTML to save the model's ID, and use that when the form is submitted.</p>
<p>I've been poking at the auto_complete plugin that got excised in Rails 2, but it seems... | <p>I rolled my own. The process is a little convoluted, but...</p>
<p>I just made a text_field on the form with an observer. When you start typing into the text field, the observer sends the search string and the controller returns a list of objects (maximum of 10).</p>
<p>The objects are then sent to render via a ... | <p>I rolled my own. The process is a little convoluted, but...</p>
<p>I just made a text_field on the form with an observer. When you start typing into the text field, the observer sends the search string and the controller returns a list of objects (maximum of 10).</p>
<p>The objects are then sent to render via a ... | 10,674 |
<p>I've got what I think is a simple question. I've seen examples both ways. The question is - "why can't I place my annotations on the field?". Let me give you an example....</p>
<pre><code>@Entity
@Table(name="widget")
public class Widget {
private Integer id;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)... | <p>From a performance and design perspective, using annotations on getters is a better idea than member variables, because the getter setters are called using reflection if placed on the field, than a method. Also if you plan to use validation and other features of hibernate, you'll have all the annotations at one plac... | <p>Does it work if you do the following:</p>
<pre><code>@Entity
@Table(name="widget")
public class Widget {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Integer id;
public Integer getId() { return this.id; }
public Integer setId(Integer Id) { this.id = id;}
}
</code></pre>
| 39,352 |
<p>For the last couple of months I have been writing an intranet site for my college with lots of reports for staff about students. It is all going well but once a week (ish) I am having to go to IT get them to log into IIS stop the application pool, clear out the website folder, clear out the temporary asp.NET cache a... | <p>Why are you stopping the app pool and clearing the temp files? It works just fine of you overwrite the files in the website itself.</p>
<p>The only thing I do is go into the bin directory and clear out all the randomly named .dll files.</p>
<p>Visual Studio also has it's own deployment option, which you can just ... | <p>I always update my website during scheduled maintenance, usually outside work hours. So, evening or weekend are the best time to shutdown for a short laps of time the services, and update the website. Schedule that maintenance so everyone know their will be a downtime.</p>
| 19,400 |
<p>Is there a way that I can get a full crash dump when my application crashes suddenly? </p>
<p>The problem is that I suspect that it's due to unmanaged code that kills the .net framework itself, and because of that, unless there's a debugger attached to the application at the moment of the crash, the application doe... | <p>You can use <a href="http://support.microsoft.com/default.aspx/kb/286350" rel="nofollow noreferrer">adplus -crash</a> or <a href="http://support.microsoft.com/kb/241215" rel="nofollow noreferrer">userdump.exe</a>.</p>
| <p>debugdiag is fully <a href="http://blogs.iis.net/sukesh/archive/2006/06/02/ddintro.aspx" rel="nofollow noreferrer">scriptable</a>. When I was having problems like this, we would have it scan for certain process names, and attach automatically. </p>
| 33,229 |
<p>I am having problems submitting forms which contain UTF-8 strings with Ajax. I am developing a <a href="http://en.wikipedia.org/wiki/Apache_Struts" rel="noreferrer">Struts</a> web application which runs in a <a href="http://en.wikipedia.org/wiki/Apache_Tomcat" rel="noreferrer">Tomcat</a> server. This is the environm... | <p>have you tried adding the following before the call :</p>
<pre><code>$.ajaxSetup({
scriptCharset: "utf-8" ,
contentType: "application/json; charset=utf-8"
});
</code></pre>
<p>The options are explained <a href="http://docs.jquery.com/Ajax/jQuery.ajax#toptions" rel="noreferrer">here</a>.</p>
<p>contentTy... | <p>I see this problem a lot.
The meta doesn't work always in your PHP data operations, so just type this at the beginning:</p>
<pre><code><?php header('Content-type: text/html; charset=utf-8'); ?>
</code></pre>
| 4,952 |
<p>I find the .Net FileSystemWatcher class really handy for writing utilities that automatically come to life when files show up in their watched folders. Is there any equivalent to this functionality in the *nix world that would allow me to watch a folder (and possibly all of its subdirectories)?</p>
<p><strong>Edit:... | <p>That would be <a href="http://www.gnome.org/%7Eveillard/gamin/" rel="noreferrer">Gamin the File Alteration Monitor</a> or <a href="http://en.wikipedia.org/wiki/Inotify" rel="noreferrer">Inotify</a>.</p>
<p>Edit: Mono does have Gamin bindings - in fact, its implementation of FileSystemWatcher uses Gamin. <a href="htt... | <p>Yes, dnotify and <a href="http://www-128.ibm.com/developerworks/linux/library/l-inotify.html" rel="nofollow noreferrer">inotify</a>.</p>
<p>I don't know if Mono has these wrapped, but it would be worth checking.</p>
| 41,991 |
<p><a href="https://i.stack.imgur.com/WwWuN.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/WwWuN.jpg" alt="3D printing problem stringing"></a></p>
<p>So these past few days I have been 3D printing again with my Ender 3 with PETG and 0.4 mm nozzle and while I have been using the same setting as usual I ... | <p>The travel speed of 160 mm/s is a big red flag. PETG is not tolerant of a hot nozzle moving over it at high speeds, especially unretracted (combing). The nozzle will drag material in a stuttering pattern, every so often, marring the surface and pulling what it dug up into strings.</p>
<p>Lower the travel speed to t... | <p>Petg it stringy material, all I can do is keep it dry to prevent blob. but I live in hot country with high moisture so I decide to keep filament in heat dryer box while print. It help a lot. </p>
| 1,615 |
<p>About two days ago, I started seeing that my hotend was heating up erratically. I first noticed this while printing a part in PETG and the temp jumped to 260 °C. I shut down the printer at that time and first started checking the hardware. I noticed that the E3D V6 thermistor had been tightened too much. I disa... | <p>One of the thermistor wires had come loose from the crimp ferrules. I re-crimped it and it works fine now. </p>
| <p>This can come from several sources:</p>
<h1>Hardware</h1>
<p>The thermistor or its connections might be damaged, and the fault is only observable when the hotend is hot or moved to a certain area. Start by checking the wiring! You may be able to repair a bad connection easily, but depending what was broken, you may ... | 844 |
<p>I have a framework that loads a lot of child collections from a non-database source. I recently got a use case where the resource is on network drives, and it is taking forever to get the collections loaded. I still need to support the eager loading scenario, but I now need to add lazy loading.</p>
<p>I had the sol... | <p>The solution turned out to be simpler than I thought. I just mixed the modes at different levels. By this I mean that I used eager loading at the topmost horizontal collections, and converted anything else below this to lazy loading.</p>
<p>It works really well. Now the UI, that uses this framework, is very respons... | <p>Yes, a boolean in your constructor would definitely be a bad code smell. However, I would also say that changing your class to support lazy loading is a code smell as well because it violates some of the basic principles of encapsulation (i.e. should your class know or care whether resources are located on network d... | 40,856 |
<p>I am building a small wpf app in C#. When a button gets clicked a third
party dll function constructs a tree like object. This object is bound
to a treeview. This works fine but takes a bit of time to load. As the
dll function constructs the object it prints progress info to the
console. I want to redirect this ... | <p>You haven't included the code that is loading the data for the <code>TreeView</code>, but I'm guessing it's being done on the UI thread. If so, this will block any UI updates (including changes to the <code>TextBlock</code>) until it has completed.</p>
| <p>I believe the problem is in the constructor of your StringRedir class. You're passing in ProgessTextBlock, and you're doing this to it:</p>
<pre><code>local.Text = "";
</code></pre>
<p>This is effectively <em>overwriting</em> the previously set value for ProgressTextBlock.Text, which was this:</p>
<pre><code>{Bin... | 49,827 |
<p><strong>What mechanisms do you know that prevent your site from being abused by anonymous spammers.</strong></p>
<p>For example, let's say that I have a site where people can vote something. But I <em>don't</em> want someone to spam something all the way to the top. So I found (a) creating an account and only allow... | <p>The big thing I've noticed is that whatever you do, you want your system to be unique. You want an attacker to have to tailor their automation program for your specific site, rather than just throw a pre-existing script at it that will work almost anywhere. It doesn't even have to be cryptographically secure; it j... | <p>stackoverflow has a few features that help with this; I think the single most useful step you can take is disabling the ability of anonymous users and new accounts to vote. This way, no one can sign up for hundreds of accounts and use their one vote to overpower other users. I'd say requiring a few posts or member... | 6,347 |
<p>I have a pretty standard django app, and am wondering how to set the url routing so that I don't have to explicitly map each url to a view. </p>
<p>For example, let's say that I have the following views: <code>Project, Links, Profile, Contact</code>. I'd rather not have my <code>urlpatterns</code> look like this:</... | <p>In answer to your first question, hopefully, you'll see something in the sys.transmission_queue system view. See
<a href="http://msdn.microsoft.com/en-us/library/ms190336.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms190336.aspx</a> for documentation on that.</p>
<p>If you Google that, y... | <p>John,</p>
<p>I've only recently begun looking into the service broker in order to implement asynch messaging between DB instances. I found the following to be quite useful in getting my head around it.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/bb839489(SQL.90).aspx" rel="nofollow noreferrer">http://m... | 20,300 |
<p>Typically I use <code>E_ALL</code> to see anything that PHP might say about my code to try and improve it.</p>
<p>I just noticed a error constant <code>E_STRICT</code>, but have never used or heard about it, is this a good setting to use for development? The manual says:</p>
<blockquote>
<p>Run-time notices. Ena... | <p>In PHP 5, the things covered by <code>E_STRICT</code> are not covered by <code>E_ALL</code>, so to get the most information, you need to combine them:</p>
<pre><code> error_reporting(E_ALL | E_STRICT);
</code></pre>
<p>In PHP 5.4, <code>E_STRICT</code> will be included in <code>E_ALL</code>, so you can use just <c... | <p>ini_set("display_errors","2");
ERROR_REPORTING(E_ALL);</p>
| 10,047 |
<p>When you execute a SQL query, you have to clean your strings or users can execute malicious SQL on your website.</p>
<p>I usually just have a function escape_string(blah), which:</p>
<ul>
<li>Replaces escapes (<code>\</code>) with double escapes (<code>\\</code>).</li>
<li>Replaces single quotes (<code>'</code>) w... | <p>For maximum security, performance, and correctness use prepared statements.
Here's how to do this with lots of examples in different languages, including PHP:</p>
<p><a href="https://stackoverflow.com/questions/1973/what-is-the-best-way-to-avoid-sql-injection-attacks">https://stackoverflow.com/questions/1973/what-i... | <p>I am not sure if MySQL supports parameterized queries, if so, you should make an effort to go this route. This will ensure the users input can't do anything malicious.</p>
<p>Otherwise some "bad" characters in addition to what you mentioned would be semicolon (;) and comments (-- and /* */).</p>
| 2,478 |
<p>My project is currently using a svn repository which gains several hundred new revisions per day.
The repository resides on a Win2k3-server and is served through Apache/mod_dav_svn. </p>
<p>I now fear that over time the performance will degrade due to too many revisions.<br>
Is this fear reasonable?<br>
We are alr... | <p>What type of repo do you have? FSFS or BDB?</p>
<p>(Let's assume FSFS for now, since that's the default.)</p>
<p>In the case of FSFS, each revision is stored as a diff against the previous. So, you would think that yes, after many revisions, it would be very slow.</p>
<p>However, this isn't the case. FSFS uses... | <p>I am not sure..... I am using SVN with apache on Centos 5.2. Works ok. Revision number was 8230 something like that... And on all client machines Commit was so slow that we had to wait at least 2min for a file that is 1kb. I am talking about 1 file that has no big filesize. </p>
<p>Then I made a new repository. Sta... | 15,541 |
<p>I have a layout similar to this:</p>
<pre><code><div id="..."><img src="..."></div>
</code></pre>
<p>and would like to use a jQuery selector to select the child <code>img</code> inside the <code>div</code> on click.</p>
<p>To get the <code>div</code>, I've got this selector:</p>
<pre><code>$(th... | <p>The jQuery constructor accepts a 2nd parameter called <a href="http://api.jquery.com/jQuery/#jQuery-selector-context" rel="noreferrer"><code>context</code></a> which can be used to override the context of the selection. </p>
<pre><code>jQuery("img", this);
</code></pre>
<p>Which is the same as using <a href="http:... | <p>You could use</p>
<pre><code> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
$(this).find('img');
</script>
</code></pre>
| 39,439 |
<p>What logging solutions exist for j2me? </p>
<p>I'm specifically interested in easily excluding logging for "release" version, to have a smaller package & memory footprint. </p>
| <p>If you are using preprocessing and obfuscation with Proguard, then you can have a simple logging class.</p>
<pre><code>public class Log {
public static void debug(final String message) {
//#if !release.build
System.out.println(message);
//#endif
}
}
</code></pre>
<p>Or do logging where ever you nee... | <p>I wrote a bytecode optimizer, and because of the format of class files you can point to the UTF encoding of classname & function which allows you to output logs with MyClass.someFunc() (you can process the signature if you want to get the types) which allows you to do something like the C style debug using <stro... | 14,665 |
<p>I'm comparing the results produced when i use the 'Make .exe' compared to when i run the exact same process using the exact same variables though the IDE vb 6 debugger.</p>
<p>I've tried an array of different compiler options but to no avail.</p>
<p>So my question is why would i get a difference between the debugg... | <p><code>Debug.Assert</code> and <code>Debug.Print</code> Statement are not compiled into the binary. I sometimes use this to detect whether I am in the IDE or a compiled binary:</p>
<pre>
On Error Resume Next
Debug.Print 1/0
If Err=0 then
'Compiled Binary
else
'in the IDE
End if
</pre>
<p>Be careful with stateme... | <p>I've found that in some (very rare) cases, there can be differences in compiled and debug code for VB6.</p>
<p>It might be worth trying the 'Compile to P-Code' option - sometimes this gives slightly different results from native code. You'll find it in Project Properties/Compile tab.</p>
<p>It's possible that if y... | 27,304 |
<p>Say I have two tables, a master list of students containing personal info, and a list of student enrollments in classes. The two tables share a common column, which is a string uniquely identifying the student, but it is not the primary key. </p>
<p>Say I want to display all the enrollments on a page, along with so... | <p>Yes ActiveRecord will manage the relationships for you, but you can also specify the join when searching for a condition in the relationship. For example:</p>
<pre><code>User.find(:all, :joins => :phone_numbers, :conditions => { :phone_numbers => {:name => 'business'} })
</code></pre>
<p>Note though us... | <p>What mwilliams says plus make sure you want a many to many association when you follow the guide.</p>
| 43,873 |
<p>I'm using grep to generate a list of files I need to move:</p>
<pre><code>grep -L -r 'Subject: \[SPAM\]' .
</code></pre>
<p>How can I pass this list to the mv command and move the files somewhere else?</p>
| <p>If you want to find and move files that do not match your pattern (move files that don't contain <code>'Subject \[SPAM\]'</code> in this example) use:</p>
<pre><code>grep -L -Z -r 'Subject: \[SPAM\]' . | xargs -0 -I{} mv {} DIR
</code></pre>
<p>The -Z means output with zeros (\0) after the filenames (so spaces are n... | <p>You can pass the result to the next command by using
grep ... | xargs mv {} destination</p>
<p>Check man xargs for more info.</p>
| 11,737 |
<p>One of our partners recently reported that our software could not contact a remote instance of SQL Express until they started the RPC Locator and SQL Server Browser services. Where would I find a list of services that must be running, on both server and client, to enable remote access to SQL Express and/or SQL Serve... | <p>SQL Express always installs as a named instance (servername\sqlexpress) and hence has a dynamic port assigned to it. The SQL Browser service is required for clients to locate the instance. Without the SQL browser, a client won't know what port the service is listening on.</p>
| <p>Looking at my current installation of SQL Server, I have remote connections enabled and working and both RPC Locator and SQL Server Browser services are disabled on the machine.</p>
<p>The key is that you have to enable remote connections properly in the Surface Area Configuration Wizard.</p>
| 25,593 |
<p>I am developing an iOS application, and trying to zip the file I have created in the application, is there any built in function able to do this?</p>
| <p>As Alex pointed out, I responded to <a href="https://stackoverflow.com/questions/230984/compression-api-on-the-iphone">this question</a> by pointing out the <a href="http://www.cocoadev.com/index.pl?NSDataCategory" rel="nofollow noreferrer">NSData category</a> contributed by users of the Cocoadev wiki. That categor... | <p>first you download Objective-zip example from <a href="http://code.google.com/p/objective-zip/downloads/list" rel="nofollow">http://code.google.com/p/objective-zip/downloads/list</a></p>
<blockquote>
<p>in this example Find and copy three folder Objective-Zip, MiniZip and ZLib drag in to your project</p>
<p>... | 36,409 |
<p>Is there a CSS editor which automatically expands one-line declarations as multi-line declarations on focus ? To clarify my thought, see example below:</p>
<p>Original CSS:</p>
<pre><code>div#main { color: orange; margin: 1em 0; border: 1px solid black; }
</code></pre>
<p>But when focusing on it, editor automatic... | <p>If you are using Visual Studio you should be able to do a close approximation of this:</p>
<ol>
<li>You can change how CSS is formatted
via the Tools -> Options menu.</li>
<li>Check 'Show all settings' if it is unchecked.</li>
<li>Go to Text Editor -> CSS -> Format and pick the semi-expanded option</li>
<li>Ok you ... | <p>Sorry. I don't know of any IDEs that explicitly do that.</p>
<p>But, there are quite a few external options:</p>
<ul>
<li><a href="http://csstidy.sourceforge.net/" rel="nofollow noreferrer">CSSTidy</a> (download)</li>
<li><a href="http://www.cleancss.com/" rel="nofollow noreferrer">Clean CSS</a> (in-browser)</li>
... | 19,465 |
<p>How do you think, is it a good idea to have such an enum:</p>
<pre><code>enum AvailableSpace {
Percent10,
Percent20,
SqF500,
SqF600
}
</code></pre>
<p>The question is about the semantics of the values names, i.e. both percentage and square feet. I really believe that it's not a good idea, but I could n... | <p><strong>The answer</strong>: No, it is not a good idea to use enums for representing values. Especially values in two semantically distinct scales. You should not use enums for values.</p>
<p><strong>The reason</strong>: What's the relation between the enum values from the two scales, like Percent10 and SqF600? How... | <p>If at all possible, I'd rather break your example into two values, where your enum is "Percent" and "SquareFeet" and the second value is the quantifier. Tie these together in a struct.</p>
<p>If the context allows for it, it may be even better to create two wrapper types "Percent" and "SquareFeet" and then create s... | 21,742 |
<p>How do I suspend a whole process (like the Process Explorer does when I click Suspend) in C#.</p>
<p>I'm starting the Process with Process.Start, and on a certain event, I want to suspend the process to be able to do some investigation on a "snapshot" of it.</p>
| <p>Here's my suggestion:</p>
<pre><code> [Flags]
public enum ThreadAccess : int
{
TERMINATE = (0x0001),
SUSPEND_RESUME = (0x0002),
GET_CONTEXT = (0x0008),
SET_CONTEXT = (0x0010),
SET_INFORMATION = (0x0020),
QUERY_INFORMATION = (0x0040),
SET_THREAD_TOKEN = (0x0080),
... | <p>See this CodeProject article for the win32 basics : <a href="http://www.codeproject.com/KB/threads/pausep.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/threads/pausep.aspx</a>. This sample code makes use of the ToolHelp32 library from the SDK, so I would recommend turning this sample code into an un... | 9,674 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.