instruction stringlengths 21 27.8k | chosen stringlengths 18 28.2k | rejected stringlengths 18 33.6k | __index_level_0__ int64 0 50k |
|---|---|---|---|
<p>Is there an easy way to return data to web service clients in JSON using Rails?</p>
| <p>Rails resource gives a RESTful interface for your model. Let's see.</p>
<h1>Model</h1>
<pre><code>class Contact < ActiveRecord::Base
...
end
</code></pre>
<h1>Routes</h1>
<pre><code>map.resources :contacts
</code></pre>
<h1>Controller</h1>
<pre><code>class ContactsController < ApplicationController
.... | <p>ActiveRecord also provides methods to interact with JSON. To create JSON out of an AR object, just call object.to_json. TO create an AR object out of JSON you should be able to create a new AR object and then call object.from_json.. as far as I understood, but this did not work for me.</p>
| 8,200 |
<p>I just did a merge using something like:</p>
<pre><code>svn merge -r 67212:67213 https://my.svn.repository/trunk .
</code></pre>
<p>I only had 2 files, one of which is a simple <code>ChangeLog</code>. Rather than just merging my <code>ChangeLog</code> changes, it actually pulled mine plus some previous ones that ... | <p>This only happens with conflicts - basically svn tried to merge the change in, but (roughly speaking) saw the change as:</p>
<p>Add</p>
<pre><code>2008-08-06 Mike Stone <myemail>
* changed_file: Details.
</code></pre>
<p>before</p>
<pre><code>2008-08-06 Someone Else <their_email>
</code></pre>
... | <p>There's not really enough information to go on here.</p>
<pre><code>svn merge -r 67212:67213 https://my.svn.repository/trunk .
</code></pre>
<p>will merge any files changed in the revision 67212 in the folder /trunk on the repository and merge them into your current working directory. If you do:</p>
<pre><code>sv... | 2,609 |
<p>Do you often see in API documentation (as in 'javadoc of public functions' for example) the description of "value limits" as well as the classic documentation ?</p>
<p><strong>Note:</strong> I am not talking about <a href="https://stackoverflow.com/questions/20922/do-you-comment-your-code">comments within the code<... | <p>I think they <strong>can</strong> belong together but don't necessarily <strong>have</strong> to belong together. In your scenario, it seems like it makes sense that the limits are documented in such a way that they appear in the generated API documentation and intellisense (if the language/IDE support it).</p>
<p>... | <p>I think they do, and have always placed comments in the header files (c++) arcordingly.</p>
<p>In addition to valid input/output/return comments, I also note which exceptions are likly to be thrown by the function (since I often want to use the return value for...well returning a value, I prefer exceptions over err... | 8,681 |
<p>My company (a large organization) is developing a "road-map" for evolving their rather old, tangled confederation of systems to an SOA model. A few people are pushing hard for using Websphere Integration Developer and Websphere Process Server as the defacto platform for developing future applications...because they... | <p>My experience with the IBM Java tool set is pure pain. Days to install lots of different versions of different components all incompatible with each other, discover a bug in component A get told to update to see if it fixes, updating component A breaks component B and C, get told to update these etc. </p>
<p>I find... | <blockquote>
<p>Do the GUI tools help eliminate monotonous/redundant coding...or just obscure things and make things harder to maintain? Basically, do the benefits justify the complexity?</p>
</blockquote>
<p>As a Developer, I find the tools at varying levels of being bug free. 6.0.1 was a pain, 6.2 is so much bette... | 49,693 |
<p>I'm not asking about general syntactic rules for file names. I mean gotchas that jump out of nowhere and bite you. For example, trying to name a file "COM<n>" on Windows?</p>
| <p>From: <a href="http://www.grouplogic.com/knowledge/index.cfm/fuseaction/view_Info/docID/111" rel="nofollow noreferrer">http://www.grouplogic.com/knowledge/index.cfm/fuseaction/view_Info/docID/111</a>.</p>
<blockquote>
<p>The following characters are invalid as file or folder names on Windows using NTFS: <code>/<... | <p>Unless you're touching special directories, the only illegal names on Linux are '<code>.</code>' and '<code>..</code>'. Any other name is possible, although accessing some of them from the shell requires using escape sequences.</p>
<p>EDIT: As Vinko Vrsalovic said, files starting with '<code>-</code>' and '<code>--... | 14,888 |
<p>I am working on integrating geolocation services into a website and the best source of data I've found so far is MaxMind's GeoIP API with GeoLite City data. Even this data seems to often be questionable though. For example, I am located in downtown Palo Alto, but it locates my IP as being in Portola Valley, which ... | <p>Where an IP comes up at the wrong end of the country, you probably won't find a better match elsewhere because it's probably an ISP that uses one group of IPs for customers in a wide area. My favourite example is trains here in the UK where the on-board wifi is identified as being in Sweden because they use a satell... | <p>I am not sure if this will help, but here is a site that has done a pretty good job of IP mapping. Maybe you could ask them for help :) <a href="http://www.seomoz.org/ip2loc" rel="nofollow noreferrer">seomoz.org</a></p>
| 21,324 |
<p>I'm looking for a strategy in as far as stopping the repetitive problem of branching out tables. For example as a fictitious use case, say I have a table with users that contains their name, login, password and other meta data. In this particular scenario, say the user is restricted to login per a specific subset of... | <p><em>Opportunity</em> to denormalize? I think you may have misunderstood conventional wisdom - denormalization is an <em>optimization</em> technique. Not something you go out looking for.</p>
| <p>You may want to consider an user-attribute table and attribute-type table where you can define what type of attributes a user can have. Each new use use case would become an attribute type, and the data would simply be added user-attribute table.</p>
<p>With your example of the IP addresses, you would have an attr... | 26,310 |
<p>What is the regex for a alpha numeric word, at least 6 characters long (but at most 50).</p>
| <pre><code>/[a-zA-Z0-9]{6,50}/
</code></pre>
<p>You can use word boundaries at the beginning/end (\b) if you want to actually match a word within text.</p>
<pre><code>/\b[a-zA-Z0-9]{6,50}\b/
</code></pre>
| <p>With PCRE regex you could do this:</p>
<pre><code>/[a-zA-Z0-9]{6,50}/
</code></pre>
<p>It would be very hard to do in regex without the min/max quantifiers so hopefully your language supports them.</p>
| 37,216 |
<p>Attempting to deploy a MOSS solution to a UAT server from dev server <em>for the first time</em>. On executing this command </p>
<pre><code>stsadm -o addsolution -filename xxx
</code></pre>
<p>I get a "Object reference not set to an instance of an object"
Based on these links: (and others):</p>
<p>[<a href="http:... | <p>I think the obvious thing you are missing is that the user account doesn't have the required permission to use the sharepoint database - just as it says in your post ;)</p>
| <p>The issue seems to not be with your solution, but with the SSP. Try deleting the UAT SSP and re-creating it and associate with your site(s).</p>
<p>If that works, you will need to find out why the issue occured.</p>
| 31,333 |
<p>Bought a new printer. When this problem has happened anywhere from the third to the twentieth layer up. An excess of filament suddenly exits the nozzle, often pulling the print from the bed when the nozzle moves away. The only advice I've found so far is that the nozzle or hotend may have damage, but I didn't find a... | <p>For casings I use a combination of TPU and PETG or PLA. PETG shell gives it rigidity and TPU gives it a bit of impact protection. So corners and inside layers of TPU within a hard PETG or PLA shell (shell has no corners).</p>
<p>I haven't had a problem with either but obviously PLA won't withstand heat very well, so... | <p>If you just cared about impact resistance of the housing itself, the clear choice would be TPU, which would be basically indestructible. However, the housing is there to protect what's inside - not only from impact, but from stresses (e.g. bending) that could break it. This means you need a material that both provid... | 2,140 |
<p>The people on this website seem to know everything so I figured I would ask this just in case:</p>
<p>Is there a method/function in prototype that converts a JSON object to a string that you can store in a cookie?</p>
<p>If not,..i'll just use another external library.</p>
<p>Thanks,
Andrww</p>
| <p>Sure there is: <a href="http://www.prototypejs.org/learn/json" rel="noreferrer">Prototype JSON</a></p>
<pre><code>var data = {name: 'Violet', occupation: 'character', age: 25 };
var myString = Object.toJSON(data);
// myString = '{"name": "Violet", "occupation": "character", "age": 25}'
</code></pre>
<p>Then shove ... | <p>Assuming you're speaking of <a href="http://www.prototypejs.org/" rel="nofollow noreferrer">Prototype JavaScript framework</a>, why not just use JavaScript's own JSON functionality? JSON does after all stand for JavaScript Object Notation.</p>
| 45,123 |
<p>How do I create class (i.e. <a href="https://en.wikipedia.org/wiki/Method_(computer_programming)#Static_methods" rel="nofollow noreferrer">static</a>) variables or methods in Python?</p>
| <p>Variables declared inside the class definition, but not inside a method are class or static variables:</p>
<pre><code>>>> class MyClass:
... i = 3
...
>>> MyClass.i
3
</code></pre>
<p>As @<a href="https://stackoverflow.com/questions/68645/static-class-variables-in-python#answer-69067">millerde... | <p>Not like the <code>@staticmethod</code> but class variables are static method of class and are shared with all the instances.</p>
<p>Now you can access it like</p>
<pre><code>instance = MyClass()
print(instance.i)
</code></pre>
<p>or</p>
<pre><code>print(MyClass.i)
</code></pre>
<p>you have to assign the value to th... | 9,420 |
<p>There are a million and one CMS' that do a good job but the interface and usability of it let the entire system down (like a lot of websites out there).</p>
<p>Whenever I need to develop a bespoke system for content management I always try and draw on my past experiences and those of my clients to work out what wor... | <p>I personally think inline-editing is a massive speed boost for clients and developers.</p>
| <p>I agree with jchrista, drag-and-drop is very nice. This is the feature that initially drew me to Sitefinity. There is an online demo of this <a href="http://demo.sitefinity.com/" rel="nofollow noreferrer">here</a>.</p>
| 40,358 |
<p>I want to examine the contents of a std::vector in gdb but I don't have access to _M_impl because I'm using icc, not gcc, how do I do it? Let's say it's a std::vector for the sake of simplicity.</p>
<p>There is a very nice answer <a href="https://stackoverflow.com/questions/253099/how-do-i-print-the-elements-of-a-c... | <p>Not sure this will work with your vector, but it worked for me.</p>
<pre><code>#include <string>
#include <vector>
int main() {
std::vector<std::string> vec;
vec.push_back("Hello");
vec.push_back("world");
vec.push_back("!");
return 0;
}
</code></pre>
<p>gdb:</p>
<pre><code>... | <p>The <code>std::vector</code> template <a href="http://herbsutter.wordpress.com/2008/04/07/cringe-not-vectors-are-guaranteed-to-be-contiguous/" rel="nofollow noreferrer">guarantees the data is stored contiguously</a>. If you take the address of the front element (say, <code>&v[0]</code>, for instance), you can a... | 41,731 |
<p>I'm preferably looking for a SQL query to accomplish this, but other options might be useful too.</p>
| <pre><code>SELECT LAST_DDL_TIME, TIMESTAMP
FROM USER_OBJECTS
WHERE OBJECT_TYPE = 'PROCEDURE'
AND OBJECT_NAME = 'MY_PROC';
</code></pre>
<p><strong><code>LAST_DDL_TIME</code></strong> is the last time it was compiled.
<strong><code>TIMESTAMP</code></strong> is the last time it was changed.</p>
<p>Procedures may need t... | <pre><code>SELECT name, create_date, modify_date
FROM sys.procedures order by modify_date desc
</code></pre>
| 38,049 |
<p>While creating classes in Java I often find myself creating instance-level collections that I know ahead of time will be very small - less than 10 items in the collection. But I don't know the number of items ahead of time so I typically opt for a dynamic collection (ArrayList, Vector, etc).</p>
<pre><code>class Fo... | <p>The <code>ArrayList</code> class in Java has only two data members, a reference to an <code>Object[]</code> array and a size—which you need anyway if you don't use an <code>ArrayList</code>. So the only advantage to not using an <code>ArrayList</code> is saving one object allocation, which is unlikely ever to be a b... | <p>The overhead is very small. It is possible to write a hybrid array list that has fields for the first few items, and then falls back to using an array for longer list.</p>
<p>You can avoid the overhead of the list object entirely by using an array. To go even further hardcore, you can declare the field as Object, a... | 8,134 |
<p>Certain <a href="http://www.avg.com/special-toolbar-404-dns-error-tlbrc.tpl-mcr1" rel="nofollow noreferrer">malware such as AVG</a> hijack 404 pages in order to display a page in the browser riddled with their own ads.
The only work around I've found is to abandon 404 http status codes for custom error pages in my w... | <p>It’s not your fault and it’s certainly not your responsibility. Keep the HTTP status codes, they are useful. If some of your users decide to install a browser plugin which handles 404 status codes, don't try to work around it.</p>
<p><a href="http://googlewebmastercentral.blogspot.com/2008/08/farewell-to-soft-404s.... | <p>When you describe AVG as "malware" are you refering to the antivirus software?</p>
<p>I do not think malware means what you think it means.</p>
<p>Aside from abandoning the 404 code I doubt there is much you can do, as the client is free to do whatever it wan't with your 404.</p>
<p>I had a firefox plugin that ch... | 38,730 |
<p>Background: We develop win32 applications, and use the "Thompson Toolkit" on windows to give us a unix-like shell that we use as our command-line.</p>
<p>We have a GUI program (with a WinMain and message loop) that we want to write to the console, but printf and so on don't work, even when we launch the program fro... | <p>In short, you need to attach a console. For details and ready to use code, see <a href="http://www.codeproject.com/KB/dialog/ConsoleAdapter.aspx" rel="noreferrer">http://www.codeproject.com/KB/dialog/ConsoleAdapter.aspx</a>.</p>
| <p>somewhere in the Visual Studio Project Settings you can switch on having a console, assuming you are using VS. (Can't say where because I currently don't have it)</p>
| 23,372 |
<p>Ok, so I demo'd Refactor Pro and Resharper, I'm more comfortable with Resharper so that's what I bought. When I uninstalled Refactor Pro I thought everything was breezy. However, now when I open Visual Studio I get </p>
<p>The Add-in 'DevExpress Tools' failed to load or caused and exception, woudl you like to remov... | <p>I had the same issue with the VS.NET 2005 version and I'm not sure it is related. It was a registry problem and when i contacted the people from devexpress they send me a clean up tool. </p>
<p>You can try to see if there is another clean up tool for 2008 or search in the registry for the file name and remove it ma... | <p>This page has instructions on how to manually remove a Visual Studio add-in:</p>
<p><a href="http://www.mztools.com/articles/2006/mz2006018.aspx" rel="nofollow noreferrer">http://www.mztools.com/articles/2006/mz2006018.aspx</a></p>
| 6,768 |
<p>I've been teaching myself Objective-C over the past month or so (I'm a Java head) and I've got my brain wrapped around most of it now. One thing that's confusing me at the moment: What's the difference between importing a class via @class vs doing a #import? </p>
<p>Is one better than another one, or do I need to u... | <p><code>#import</code> brings the entire header file in question into the current file; any files that THAT file <code>#import</code>s are also included. @class, on the other hand (when used on a line by itself with some class names), just tells the compiler "Hey, you're going to see a new token soon; it's a class, so... | <p>The other thing you want to keep in mind is that #imports slow down your compile times, since it means the the compiler needs to pull and work through a lot more header files. This is mostly masked by the use of precompiled headers, but I have occasionally been handed projects that corss imported every header instea... | 31,539 |
<p>When using a filament based printer, what operator behaviors increase the frequency at which a bed must be relevelled between prints?</p>
| <h1>Mechanical interaction</h1>
<h2>Operator induced regular actions</h2>
<p>When an operator reaches into the machine and operates something on the bed, this can induce errors that slowly accumulate. The most typical operation would be to remove something from the printbed, cleaning the printbed or swapping the printb... | <p>The only ones I have found are.</p>
<p>Manually putting pressure on the bed when removing prints.</p>
<p>Removing the bed covering, eg a glass plate</p>
<p>Damaging the bed in some way. For example my bed has high spots on it (always has). This means that if I remove the glass plate I use and put it back, it sits sl... | 2,148 |
<p>I'm attempting to create a custom calendar control that inherits from ASP.Net's built in calendar user control. </p>
<p>the code-behind file for my control looks like this:</p>
<pre><code>public partial class WeeklyEventsCalendar : Calendar
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
... | <p>I think the problem is that you're attempting to inherit the Calendar control (which is a server control) from a user control (based on your ASCX extension). You can't do this. If you want to inherit from the Calendar control then you need to create a server control.</p>
<p>Let me know if you need some sample code.... | <p>I think the problem is that you're attempting to inherit the Calendar control (which is a server control) from a user control (based on your ASCX extension). You can't do this. If you want to inherit from the Calendar control then you need to create a server control.</p>
<p>Let me know if you need some sample code.... | 22,832 |
<p>I'm looking to create a "Countries You've Visited" map - just like the ones you've probably seen on Facebook, TravelAdvisor and whatnot.</p>
<p>I've tried different flash kits, but they're not quite as advanced as I'd like them to be. The main problem I've encountered with all the different kits is changing the bac... | <blockquote>
<p>just seems like a huge pain and very error-prone</p>
</blockquote>
<p>I overcame the pain and fixed errors (ok, most of them). Here is the result: <a href="http://jvectormap.owl-hollow.net" rel="nofollow">jVectorMap</a></p>
| <p>If it will work for what you're building, Virtual Earth is in 6.1 these days and has a lot of excellent and easy-to-use javascript calls in the API to load polygons. If you have the point data that defines the countries (which should be freely available), you can easily define a VEShape polygon with an array of VEL... | 10,005 |
<h2>I'm looking to add some lookup lists in the database, but I want them to be easy localizable (SQL 2005, ADO.NET)</h2>
<p>This would include:</p>
<ul>
<li>Easy Management of multiple languages at the same time</li>
<li>Easy Retrieval of values from the database</li>
<li>Fallback language (in case the selected lang... | <p>If you structure your data like this:</p>
<pre><code>MessageToken DisplayText LangCode
firewood Fire wood en
firewood Bois de chauffage fr
</code></pre>
<p>When you make your query, just supply the default languageId (if blank) or the supplied languageId. Use a standard list of token... | <p>After studying the problem in detail I have found the following:</p>
<ol>
<li><p>I could use the <code>SET CONTEXT_INFO</code>, but I would have to inject some SQL to solve the problem.</p></li>
<li><p>The best option would be not to store localized data in the look-up tables. Instead, store some identification str... | 27,054 |
<p>Would the following SQL remove also the index - or does it have to be removed separately?</p>
<pre><code>CREATE TABLE #Tbl (field int)
CREATE NONCLUSTERED INDEX idx ON #Tbl (field)
DROP TABLE #Tbl
</code></pre>
| <p>Yes they are. You can search in MSSQL help for CREATE INDEX article it is said there:</p>
<blockquote>
<p>"Indexes can be created on a temporary
table. When the table is dropped or
the session ends, all indexes and
triggers are dropped."</p>
</blockquote>
| <p>The drop table will remove the index. Drop Index takes the index name and the table name. </p>
<p>In this case would be DROP INDEX idc ON #tbl</p>
<p>which can be called if you want to drop the index but leave the table.</p>
| 11,734 |
<p>I have a Customer class.</p>
<pre><code>public class Customer
{
private string _id;
private string _name;
// some more properties follow
</code></pre>
<p>I am inheriting the EqualityComparer form MyEqualityComparer(of Customer).<br>
This I am intending to use in LINQ queries.<br>
MyEqualityComparer is... | <p>See <a href="https://stackoverflow.com/questions/263400">this question on hashcodes</a> for a pretty simple way to return one hashcode based on multiple fields.</p>
<p>Having said that, I wouldn't derive from <code>EqualityComparer<T></code> myself - I'd just implement <code>IEqualityComparer<T></code> ... | <p>Resharper (fantastic refactoring plugin from JetBrains) thinks it should be:</p>
<pre><code>public override int GetHashCode(Customer obj)
{
unchecked
{
return ((obj.Id != null ? obj.Id.GetHashCode() : 0) * 397)
^ (obj.Name != null ? obj.Name.GetHashCode() : 0);
}
}
</code></pre>
<p... | 44,241 |
<p>Given a class instance, is it possible to determine if it implements a particular interface? As far as I know, there isn't a built-in function to do this directly. What options do I have (if any)?</p>
| <pre><code>interface IInterface
{
}
class TheClass implements IInterface
{
}
$cls = new TheClass();
if ($cls instanceof IInterface) {
echo "yes";
}
</code></pre>
<p>You can use the "instanceof" operator. To use it, the left operand is a class instance and the right operand is an interface. It returns true if the... | <p>You can also do the following</p>
<pre><code>public function yourMethod(YourInterface $objectSupposedToBeImplementing) {
//.....
}
</code></pre>
<p>It will throw an recoverable error if the <code>$objectSupposedToBeImplementing</code> does not implement <code>YourInterface</code> Interface.</p>
| 34,562 |
<p>Context:
So, I am attempting to build a ridiculously complex domain model. Talking with the users, there are multiple ways the system will be used (For example: one way is from the perspective of the employee; another way is from the perspective of the employer). In actuality, they are multiple applications reus... | <p>No, this is absolutely appropriate. Evan's calls these 'perspectives' Bounded Contexts in his book.</p>
<p>Instead of having a really complex domain model, try building a simple one that addresses the domain in a specific way really well. Bounded Contexts can be linked together to form a web of smaller, simpler, ... | <p>I don't think you should try and predefine the 'core domain' up front. Let it emerge over the development process. Additionally, anything that is not common to the 2 (or more) perspectives should not be in the 'core'.</p>
<p>For instance, build a portion of the system from the employeer perspective. This might prom... | 24,542 |
<p>Does anyone have any information about getting the current versions of ASP.NET MVC (Preview 5) working on Mono 2.0? There was info on the old versions (Preview 2, maybe Preview 3), but I've seen no details about making Preview 5 actually work.</p>
<p>The <a href="http://www.mono-project.com/Roadmap" rel="nofollow n... | <p>Well a potential is that RewritePath to / has some sort of bug, so just avoid that. Changing the RewritePath(Request.ApplicationPath) to:</p>
<pre><code>HttpContext.Current.RewritePath("/Home/Index");
</code></pre>
<p>Seems to fix the problem, and at least the demo works so far. </p>
| <p>Are you using Mono from svn or stable?
What kind of webserver are you using?
What kind of Operating system?
Do you have rewrite rules in your web server?</p>
<p>I can run preview 4 in Linux with this in the page_load method in default.aspx.cs</p>
<pre><code>HttpContext.Current.RewritePath(Request.ApplicationPath);... | 24,750 |
<p>I am trying to use the Event Log to write some debug information and I can't make it works. It complains about not being able to find the Event Source. Do I have to install something on the OS?</p>
| <p>Here a code that I modified from one of our application. This might help you to start with the creation. </p>
<pre><code>System.Diagnostics.EventLog eventLog1 = new System.Diagnostics.EventLog();
string eventLogName = "StackOverFlowEventName";
string eventLogSource = "StackOverFlowWebsite";
//This code HERE wil... | <p>What code are you using currently in your project? I'm currently using this line to write to the event log. </p>
<pre><code>System.Diagnostics.EventLog.WriteEntry(assemblyName, "Error stuff", System.Diagnostics.EventLogEntryType.Error);
</code></pre>
<p>Watch out though, this will throw an exception if the log fil... | 37,135 |
<ol>
<li>In the application we have something about 30 types of objects that are created repeatedly. </li>
<li>Some of them have long life (hours) some have short (milliseconds). </li>
<li>Objects could be created in one thread and destroyed in another.</li>
</ol>
<p>Does anybody have any clue what could be good pooli... | <p>To minimize construct/destruct latency, you need fully constructed objects at hand, so you will eliminate the new/ctor/dtor/delete time. These "free" objects can be kept in a list so you just pop/push the element at the end.</p>
<p>You may lock the object pools (one for each type) one by one. It is a bit more effic... | <p>If you have some guess of the preferred size of the pool you can create fixed size pool using stack structure using array (the fastest possible solution). Then you need to implement four phases of object life time hard initialization (and memory allocation), soft initialization, soft cleanup and hard cleanup (and me... | 12,511 |
<p>Having briefly looked at Haskell recently, what would be a <em>brief, succinct, practical</em> explanation as to what a monad essentially is?</p>
<p>I have found most explanations I've come across to be fairly inaccessible and lacking in practical detail.</p>
| <p>First: The term <strong>monad</strong> is a bit vacuous if you are not a mathematician. An alternative term is <strong>computation builder</strong> which is a bit more descriptive of what they are actually useful for.</p>
<p>They are a pattern for chaining operations. It looks a bit like method chaining in object-or... | <h2>Explanation</h2>
<p>It's quite simple, when explained in C#/Java terms:</p>
<ol>
<li><p>A monad is a function that takes arguments and returns a special type. </p></li>
<li><p>The special type that this monad returns is <strong>also</strong> called monad. (A monad is a combination of #1 and #2)</p></li>
<li><p>Th... | 6,675 |
<p>I am playing with the new stuff of C#3.0 and I have this code (mostly taken from <a href="http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx" rel="noreferrer">MSDN</a>) but I can only get true,false,true... and not the real value :</p>
<pre><code> int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
... | <p>Change your "Select" to a "Where"</p>
<pre><code> int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 };
var oddNumbers = numbers.Where(n => n % 2 == 1);
Console.WriteLine("Odd Number:");
foreach (var x in oddNumbers)
{
Console.WriteLine(x);
}
</code></pre>
<p>The "Select" method is ... | <blockquote>
<pre><code>numbers.Select(n => n % 2 == 1);
</code></pre>
</blockquote>
<p>Change this to</p>
<pre><code>numbers.Where(n => n % 2 == 1);
</code></pre>
<p>What select does is "convert" one thing to another. So in this case, it's "Converting" n to "n % 2 == 1" (which is a boolean) - hence you get al... | 29,954 |
<p>I have a little game written in C#. It uses a database as back-end. It's
a <a href="http://en.wikipedia.org/wiki/Collectible_card_game" rel="noreferrer">trading card game</a>, and I wanted to implement the function of the cards as a script.</p>
<p>What I mean is that I essentially have an interface, <code>ICard</c... | <p><a href="https://www.codeproject.com/Articles/8656/C-Script-The-Missing-Puzzle-Piece" rel="nofollow noreferrer">Oleg Shilo's C# Script solution (at The Code Project</a>) really is a great introduction to providing script abilities in your application.</p>
<p>A different approach would be to consider a language that... | <p>Yes, I thought about that, but I soon figured out that another Domain-Specific-Language (DSL) would be a bit too much.</p>
<p>Essentially, they need to interact with my gamestate in possibly unpredictable ways. For example, a card could have a rule "When this cards enter play, all your undead minions gain +3 attack... | 2,275 |
<p>How do I achieve authorization with MVC asp.net?</p>
| <p>Use the Authorize attribute</p>
<pre><code>[Authorize]
public ActionResult MyAction()
{
//stuff
}
</code></pre>
<p>You can also use this on the controller. Can pass in users or roles too.</p>
<p>If you want something with a little more control, you could try something like <a href="http://schotime.net/blog/ind... | <p>This is how you can have authentication by default:
<a href="http://mycodepad.wordpress.com/2014/03/17/mvc-secure-your-web-app/" rel="nofollow">http://mycodepad.wordpress.com/2014/03/17/mvc-secure-your-web-app/</a></p>
| 42,710 |
<p>In C# some of default name space such as System.Collections are listed without typing in using blah. In visual basic, they are not imports for you. Is there a way to force vb to auto imports some of default name space or VB work differently than C#?</p>
| <p>I think the first item posted by John Rudy is what you're looking for- add them in the project properties.</p>
<p>However, VB.Net does also work differently than C#, in that it means a different thing in VB to import a namespace than it does in C#. When you import a namespace in VB, it also brings child namespaces... | <p>I don't believe Visual Studio does this by default for C#or VB.</p>
<p>However, the Jetbrains Resharper plugin will auto import namespaces for you, in the same that Eclipse does when you use CTRL+SHIFT+O.</p>
| 32,864 |
<p>The point of this question is to create the shortest <b>not abusively slow</b> Sudoku solver. This is defined as: <b>don't recurse when there are spots on the board which can only possibly be one digit</b>.</p>
<p>Here is the shortest I have so far in python:</p>
<pre><code>r=range(81)
s=range(1,10)
def R(A):
... | <p>I haven't really made much of a change - the algorithm is identical, but here are a few further micro-optimisations you can make to your python code.</p>
<ul>
<li><p>No need for !=0, 0 is false in a boolean context.</p></li>
<li><p>a if c else b is more expensive than using [a,b][c] if you don't need short-circuiti... | <p>I've just trimmed the python a bit here:</p>
<pre><code>r=range(81);s=range(1,10)
def R(A):
z={}
for i in r:
if A[i]!=0:continue
h={}
for j in r:h[A[j]if j/9==i/9 or j%9==i%9 or j/27==i/27 and j%9/3==i%9/3 else 0]=1
z[9-len(h)]=h,i
for l,(h,i)in sorted(z.items(),cmp,lambd... | 26,574 |
<p>what is the preferred method of deploying a web project? Just copy the dll's after compiling in release mode and registering them? or using NSIS to build an installer or the MS set up project.</p>
| <p>I usually use a <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=0AA30AE8-C73B-4BDD-BB1B-FE697256C459&displaylang=en" rel="noreferrer">Web Deployment Project</a> per WebSite or WebApplication, it allows me to manage build configurations, merging, and define pre-post build MSBuild tasks. </p>
<p... | <p>I would recommend investing in setting up a continuous integration process (CruiseControl.Net or TeamCity etc...) As you are probably not only going to deploy it to your customer only once.</p>
<p>Having an automatic deploy at the push of a button is a Godsend. If you invest a few days you can have automatic deplo... | 48,307 |
<p>I want to start working with TDD but I don't know really where to start. We coding with .NET (C#/ASP.NET).</p>
| <p>See the questions <a href="https://stackoverflow.com/questions/4303/why-should-i-practice-test-driven-development-and-how-should-i-start">Why should I practice Test Driven Development and how should I start?</a>, <a href="https://stackoverflow.com/questions/167079/moving-existing-code-to-test-driven-development">Mov... | <p>I would start by reading up on TDD and why it's a good practice. As you read that, try to think about how the concepts apply to your own projects.</p>
<p>When I was learning TDD, it seemed simple at first, but it's such a paradigm shift that it forced me to change the way I thought about how my program would work. ... | 20,359 |
<p>Is it possible to find out who called a stored procedure?</p>
<p>For example, say I get an error in <code>proc3</code>. From within that proc I want to know if it was called by <code>proc1</code> or <code>proc2</code>.</p>
| <p>I would use an extra input parameter, to specify the source, if this is important for your logic.</p>
<p>This will also make it easier to port your database to another platform, since you don't depend on some obscure platform dependent function.</p>
| <p>Do you need to know in proc3 at runtime which caused the error, or do you just need to know while debugging?</p>
<p>You can use <a href="http://msdn.microsoft.com/en-us/library/ms187929.aspx" rel="nofollow noreferrer">SQL Server profiler</a> if you only need to do it during debugging/monitoring.</p>
<p>Otherwise i... | 17,830 |
<p>A question regarding a DB development project. The database already exist and is rather large (several TBs).</p>
<ol>
<li>What do you use for version control in DB development?</li>
<li>How do you control concurrent changes to the data model by different teams</li>
<li>What is your approach to the Unit Testing in t... | <p>A few months ago, I searched and found nothing (satisfactory). I had to implement my own control library. Lack of good existing "touch-aware" libraries makes me think I should commercialize mine, but it's very incomplete.</p>
| <p>mirabyte, it seems good, but you can't try in some test application their touch controls component, the are only provide a sample application. Otherwise, you can't see how to look inside of your application. </p>
<p>In my opinion, you should choice resco, they are working in PocketPC platform many year and they kno... | 23,205 |
<p>Is there a mechanism to inject dependencies into Linq to Sql or entity framework entities? If so would it be a sensible approach?</p>
| <p>Sorry I was not clear.
I want to be able to inject sevices eg. IEmailer into linq to sql entities using one of the many dependancy injection frameworks eg. windsor spring, unity etc.</p>
| <p>What exactly are you after? Note that you can use LINQ-to-SQL without the attributes, if you want to use existing classes... you need to use an <a href="http://msdn.microsoft.com/en-us/library/bb386907.aspx" rel="nofollow noreferrer">external xml file</a> to hold the mappings, and an <a href="http://msdn.microsoft.c... | 29,521 |
<p>I am a PHP developer who is kind of in a pickle. I'm trying to locate and/or build an API capable of speaking to Hotmail, Yahoo and GMAIL in order to retrieve contact lists (with the user's consent, of course). The one I'm having the most trouble finding is a Hotmail API.</p>
<p>Where would I start to look as far a... | <p>Some pointers:</p>
<ul>
<li>Gmail: <a href="http://code.google.com/apis/contacts/" rel="nofollow noreferrer">Google Contacts Data API</a></li>
<li>Yahoo:
<ul>
<li><a href="http://developer.yahoo.com/addressbook/" rel="nofollow noreferrer">Address Book API</a> <strong>(deprecated)</strong> </li>
<li><a href="http:... | <p>Rapleaf might have something for you:</p>
<p><a href="http://www.phpclasses.org/browse/package/4436.html" rel="nofollow noreferrer">http://www.phpclasses.org/browse/package/4436.html</a></p>
<p>It appears that this service plays cat and mouse with some providers, as not all e-mail providers offer a stable API for ... | 42,287 |
<p>I have a rails app that uses heavily js (over 1MB total). I'd like to compress them in order to reduce the overall load time of the site.</p>
<p>I did a fast search and found that most browsers accept compressed content.</p>
<p>I'd like to know what can I do to make my rails app send compressed content and thus ma... | <p>You should always have the web server proxying to your mongrels handle the serving of static content and it's compression. Requests for static content should never be passed to the mongrels.</p>
<p>e.g. with nginx it's simply a matter of adding gzip directives to your config file.</p>
<p><a href="http://topfunky.n... | <p>Two similar questions have been asked and answered. Hopefully the content there will be helpful, too.</p>
<p><a href="https://stackoverflow.com/questions/75482/how-can-i-pre-compress-files-with-moddeflate-in-apache-2x">How can I pre-compress files with mod_deflate in Apache 2.x?</a></p>
<p><a href="https://stacko... | 38,237 |
<p>in "CSS: The missing manual" the author says that font-size: medium (or other size keywords) sets the font relative to the <em>browser's</em> base font size.</p>
<p>But what I'm seeing in FF2 and IE6 is that it sets the font size to what I specified in the .CSS HTML or BODY style (which is much preferred).</p>
<p... | <p>From <a href="http://www.w3.org/TR/CSS21/fonts.html#font-size-props" rel="noreferrer">the CSS 2.1 specification</a>:</p>
<blockquote>
<p>The 'medium' value is the user's preferred font size and is used as the reference middle value.</p>
</blockquote>
<p>If a browser doesn't do this, then the browser is buggy.</p... | <p>I think if you set a default size to a element like a container or the body, then any relative font-sizes in the children are based on the parent elements. Only if you don't specify a font-size anywhere does it just default to the browser (which they all have different sizes at that).</p>
| 11,990 |
<p>Which is Best way to send data to aspx page, and <strong>why</strong>?</p>
<ul>
<li>using query string</li>
<li>using session</li>
<li>using cross page postback </li>
<li>Something else</li>
</ul>
<p>Thanks.</p>
<hr>
<blockquote>
<p>What are you trying to achieve? More
info. please</p>
</blockquote>
<p>For ... | <p>It really depends greatly on your uses.</p>
<ul>
<li>using query string</li>
</ul>
<p>Query string data is a good way of sending data which is not important to keep secure. It is probably the best and easiest way of passing data which users should be able to see and it isn't a problem if they try to change the que... | <p>Depends what kind of data, and what kind of action is taken when the data is received. A query string is the simplest and most standard and most used way of sending data to the server. Next question is what method do you use POST or GET. As a general rule of thumb you can take the following: use POST when the reques... | 20,993 |
<p>I have a need to convert images from CMYK to RGB - not necessarily back again, but hey, if it can be done...</p>
<p>With the release of ColdFusion 8, we got the <a href="http://cfquickdocs.com/cf8/?getDoc=cfimage" rel="nofollow noreferrer">CFImage</a> tag, but it doesn't support this conversion; and nor does <a hre... | <p>A very simple formula for converting from CMYK to RGB ignoring all color profiles is:</p>
<pre>
R = ( (255-C)*(255-K) ) / 255;
G = ( (255-M)*(255-K) ) / 255;
B = ( (255-Y)*(255-K) ) / 255;
</pre>
<p>This code requires CMYK values to be in rage of 0-255. If you have 0 to 100 or 0.0 to 1.0 you'll have to... | <p>I know that this question is old, but I still encounter problems with CMYK images & ColdFusion. However, I just read a CMYK JPEG image using ColdFusion 10 and resaved it. The saved image was able to to be read using ColdFusion 9 (which is only capable of reading RGB JPEGs.) I'm not sure if this conversion is ... | 4,242 |
<p>if i have :</p>
<pre><code><div class="carBig"></div>
</code></pre>
<p>and</p>
<pre><code><div class="car"></div>
</code></pre>
<p>and $(".car").size();</p>
<p>i get 2 items ..</p>
| <p>What version of jquery are you using?</p>
<p>Using this code:</p>
<pre><code><html><head><title>Testing</title>
<script type="text/javascript" src="/js/jquery/jquery-1.2.6.min.js">
</script>
<script type="text/javascript">
$(document).ready(function() {
$(".car").each(... | <p>What version of jquery are you using?</p>
<p>Using this code:</p>
<pre><code><html><head><title>Testing</title>
<script type="text/javascript" src="/js/jquery/jquery-1.2.6.min.js">
</script>
<script type="text/javascript">
$(document).ready(function() {
$(".car").each(... | 41,483 |
<p>On Linux, the "top" command shows a detailed but high level overview of your memory usage, showing:</p>
<p>Total Memory, Used Memory, Free Memory, Buffer Usage, Cache Usage, Swap size and Swap Usage.</p>
<p>My question is, what commands are available to show these memory usage figures in a clear and simple way? Bo... | <p>Here are the basics. I'm not sure that any of these count as "clear and simple" though.</p>
<p><strong><code>ps(1)</code></strong></p>
<p>For process-level view:</p>
<pre><code>$ ps -opid,vsz,rss,osz,args
PID VSZ RSS SZ COMMAND
1831 1776 1008 222 ps -opid,vsz,rss,osz,args
1782 3464 2504 433 -bash
$
</co... | <p>The command <code>free</code> is nice. Takes a short while to understand the "+/- buffers/cache", but the idea is that cache and buffers doesn't really count when evaluating "free", as it can be dumped right away. Therefore, to see how much free (and used) memory you have, you need to remove the cache/buffer usage -... | 40,992 |
<p>I'm not sure how to search for this answer, so I'll go ahead and ask it.</p>
<p>In my rails project I have a User model and a foo model. A user can have one or more foo models assigned to it. I have accomplished this by adding </p>
<pre><code>has_many :foo, :through => :user_foo
</code></pre>
<p>in my user mod... | <p>I assume that you have <code>belongs_to :user</code> in your Foo class?</p>
<p>What does your controller code look like? To show all foos it should have something like this:</p>
<pre><code>def index
@foos = Foo.all
end
</code></pre>
| <p>The error suggests you foo object is empty.</p>
<p>If you want all Foo's connected with the current user object, you use </p>
<pre><code>my_user = User.find(1) # finds user with id no. 1
list_of_foos = my_user.foos # finds all foos associated with my_user
</code></pre>
<p>should work</p>
<p>If you are looking fo... | 37,362 |
<p>Is it possible to unlisten on a socket after you have called listen(fd, backlog)? </p>
<p>Edit: My mistake for not making myself clear. I'd like to be able to temporarily unlisten on the socket. Calling close() will leave the socket in the M2LS state and prevent me from reopening it (or worse, some nefarious progra... | <p>Some socket libraries allow you to specifically reject incoming connections. For example: <a href="ftp://ftp.tu-clausthal.de/pub/mirror/gnu/www/software/commoncpp/docs/refman/html/class_t_c_p_socket.html" rel="nofollow noreferrer">GNU's CommonC++: TCPsocket Class</a> has a <a href="ftp://ftp.tu-clausthal.de/pub/mir... | <p>At a basic level, sockets are either open or closed (we'll ignore the niceties of the TCP/IP state diagram here). </p>
<p>If your socket is closed, then nothing can send data to it. If it's open, then incoming data will be accepted and acknowledged by the TCP/IP stack until it's buffering algorithm cries "enough!".... | 19,570 |
<p>Notepad++ has a neat feature that combines search and highlighting. When you select a word, it is highlighted wherever else it shows up on the page, so it is an implicit search, which I find very very useful. </p>
<p>Is there a way to get that into VS?</p>
<p>I would also be interested in having these highlighting... | <p>Check out this <a href="https://stackoverflow.com/questions/256931/how-to-highlight-occurrences-of-a-search-term-in-text-in-visual-studio">question</a> and the related answers:
<a href="https://stackoverflow.com/questions/256931/how-to-highlight-occurrences-of-a-search-term-in-text-in-visual-studio">How to highligh... | <p>The same feature is also available in Eclipse. Very useful.</p>
| 38,430 |
<p>I am using C# and Windows Forms. I have a normal progress bar working fine in the program, but now I have another operation where the duration cannot be easily calculated. I would like to display a progress bar but don't know the best way to start/stop the scrolling marquee. I was hoping for something as simple as s... | <p>Use a progress bar with the style set to <code>Marquee</code>. This represents an indeterminate progress bar.</p>
<pre><code>myProgressBar.Style = ProgressBarStyle.Marquee;
</code></pre>
<p>You can also use the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.progressbar.marqueeanimationspeed.... | <p>you can use a <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.aspx" rel="nofollow noreferrer">Timer</a> (System.Windows.Forms.Timer).</p>
<p>Hook it's Tick event, advance then progress bar until it reaches the max value. when it does (hit the max) and you didn't finish the job, reset the... | 40,334 |
<p>Im currently writing my bachelor thesis with latex and using TexnicCenter. I want to be able to send my generated pdf file to people and they should be able to write comments.
It seems like commenting is not allowed by default, how do I change this?</p>
<p>I am using straight to PDF with pdflatex and acrobat reader... | <p>I think your problem is that acrobat reader doesn't allow commenting on documents not produced by abode approved products, which I don't think pdflatex would be. </p>
<p>You should look at the free <a href="http://www.docu-track.com/home/prod_user/PDF-XChange_Tools/pdfx_viewer" rel="noreferrer">PDF-XChange Viewer</... | <p>I would definitely have a look at the <a href="https://rads.stackoverflow.com/amzn/click/com/0201433117" rel="nofollow noreferrer" rel="nofollow noreferrer">LaTeX Web Companion</a>. There is a whole section about generating PDF from LaTeX, including esoterica such as forms.</p>
| 4,708 |
<h2>Seeking a method to:</h2>
<h2>Take whitespace separated tokens in a String; return a suggested Word</h2>
<p><br>
<strong>ie:</strong><br>
Google Search can take <em>"fonetic wrd nterpreterr"</em>,<br>
and atop of the result page it shows <em>"Did you mean: phonetic word interpreter"</em></p>
<p><em>A solution in... | <p>In his article <a href="http://norvig.com/spell-correct.html" rel="nofollow noreferrer">How to Write a Spelling Corrector</a>, Peter Norvig discusses how a Google-like spellchecker could be implemented. The article contains a 20-line implementation in Python, as well as links to several reimplementations in C, C++, ... | <p>If you have a dictionary stored as a trie, there is a fairly straightforward way to find best-matching entries, where characters can be inserted, deleted, or replaced.</p>
<pre><code>void match(trie t, char* w, string s, int budget){
if (budget < 0) return;
if (*w=='\0') print s;
foreach (char c, subtrie t... | 16,439 |
<p>Are there any open source (or I guess commercial) packages that you can plug into your site for monitoring purposes? I'd like something that we can hook up to our ASP.NET site and use to provide reporting on things like:</p>
<ul>
<li>performance over time</li>
<li>current load</li>
<li>page traffic</li>
<li>SQL per... | <p>It should be noted that google analytics is not an accurate representation of web site usage. This is because the web beacon (web bug) used on the page does not always load for these reasons:</p>
<ol>
<li>Google analytics servers are called by millions of pages every second and can not always process the requests i... | <p><a href="http://google.com/analytics" rel="nofollow noreferrer">Google Analytics</a> is free (up to 50,000 hits per month I think) and is easy to setup with just a little javascript snippet to insert into your header or footer and has great detailed reports, with some very nice graphs.</p>
| 3,869 |
<p>I have an s-expression bound to a variable in Common Lisp:</p>
<pre><code>(defvar x '(+ a 2))
</code></pre>
<p>Now I want to create a function that when called, evaluates the expression in the scope in which it was defined. I've tried this:</p>
<pre><code>(let ((a 4))
(lambda () (eval x)))
</code></pre>
<p>an... | <p>You need to create code that has the necessary bindings. Wrap a LET around your code and bind every variable you want to make available in your code:</p>
<pre><code>(defvar *x* '(+ a 2))
(let ((a 4))
(eval `(let ((a ,a))
,*x*)))
</code></pre>
| <p>In Common Lisp you can define <a href="http://www.cvc.uab.es/~javier/CrossVisions/Help/FrameTopic487.html" rel="nofollow noreferrer">*evalhook*</a> Which allows you to pass an environment to <code>(eval ...)</code>. <code>*evalhook*</code> is platform independent.</p>
| 26,534 |
<p>I am trying to run a macro when I double click on Visio shapes. </p>
<p>I want to pass the shape object to the VBA macro so that I could do something in the macro depending on the id of the Shape object.</p>
<p>Is it possible to pass the parameter to VBA macro. If yes, please let me know how?</p>
<p>Thanks.</p>
| <p>Quality is the measure of completeness of the requirements or the completeness of features in a product scenario.</p>
<p>User-friendliness is one of the features, right? So yes, it's part of the quality. So, one can say the Quality of User-friendliness of MS Excel is great but the quality of its memory management i... | <p>User-friendlyness is definitely an important aspect of software quality, but it is often more elusive than maintaining stability (i.e. absence of software errors). A program can have a hideous and unusable user-interface but be perfectly stable. Such a program would grade very high on the quality scale, IMO.</p>
| 35,420 |
<p>I have a web service that is protected by requiring the consuming third party application to pass a client certificate. I have installed the certificate on the providing web service in production and on the client as well. This process is currently working fine for other clients with a similar setup. The current ... | <p>I had this kind of problem a couple of weeks ago. The solution in my case was to use impersonation in order to gain appropriate access to the certificate store. By default, the IIS worker thread was running as a system user, and as such had no access to the appropriate store. Adding the certificate to a specific ... | <p>You could just slap this sticker on your program and call it a day:</p>
<p><img src="https://i.stack.imgur.com/AZidp.png" alt="alt text"></p>
| 29,702 |
<p>How can I generate a (pseudo)random alpha-numeric string, something like: 'd79jd8c' in PHP?</p>
| <p>First make a string with all your possible characters:</p>
<pre><code> $characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
</code></pre>
<p>You could also use <a href="http://php.net/range" rel="noreferrer">range()</a> to do this more quickly.</p>
<p>Then, in a loop, choose a random number and use it as the ind... | <p>Jeremy's answer is great. If, like me, you're unsure of how to implement range(), you can see my version using range().</p>
<pre><code><?php
$character_array = array_merge(range('a', 'z'), range(0, 9));
$string = "";
for($i = 0; $i < 6; $i++) {
$string .= $character_array[rand(0, (count($character... | 7,049 |
<p>Here's a perfect example of the problem: <a href="http://blog.teksol.info/2009/03/27/argumenterror-on-number-sum-when-using-classifier-bayes.html" rel="nofollow noreferrer">Classifier gem breaks Rails</a>.</p>
<p>** Original question: **</p>
<p>One thing that concerns me as a security professional is that Ruby doe... | <p>I don't think this is a concern.</p>
<p>Yes, the mythical "somebody" can replace the implementation of MD5 with something insecure. But in order to do that, the mythical somebody must actually be able to get his code into the Ruby process. And if he can do that, then he presumably could also inject his code into a ... | <p>If someone monkeypatched an object or a module, then you need to look at 2 cases: He added a new method. If he is the only one adding this meyhod (which is very likely), then no problems arise. If he is not the only one, you need to see if both methods do the same and tell the library developer about this severe pr... | 5,223 |
<p>For ActionScript 2, I've used <a href="http://www.naturaldocs.org/" rel="noreferrer">NaturalDocs</a>. However it has pretty poor support for PHP. I've looked so far at <a href="http://www.doxygen.nl/" rel="noreferrer">doxygen</a> and <a href="http://www.phpdoc.org/" rel="noreferrer">phpDocumentor</a>, but their outp... | <h2>ApiGen</h2>
<p><a href="http://apigen.org/">http://apigen.org/</a></p>
<p>ApiGen has support for PHP 5.3 namespaces, packages, linking between documentation, cross referencing to PHP standard classes and general documentation, creation of highlighted source code and experimental support for PHP 5.4 traits.</p>
<... | <p>You could edit the template file to add your own stylesheet to override the existing one.</p>
| 22,987 |
<p>I am new to FDM RP. I've done a lot of work on ZCorp and Connex. </p>
<p>The question is can vectors curve drive an extrusion nozzle? Within a 3D volume I can generate curves that I want the print nozzle to follow. Is this possible or has it been done? If so, what software or is there a hack? </p>
<p>Another q... | <p>Just for the fun of it and perhaps to contribute to this question, I opened my recent task in Simplify3d slicing software. Setting the perimeter walls and top/bottom surfaces to zero did not generate an error as I expected.</p>
<p>The print preview, essentially a g-code viewer, presented the model as only the honey... | <p>Vectors do not drive the extrusion nozzles in current software. There are methods to take vectors and create a solid model with them which can be used. The standard workflow is to take a solid model, save it in the STL format, and then import the STL file into the slicing software and outputs Gcode with contain coor... | 409 |
<p>I am developing some client side Javascript that is using some JSON web services on a different domain. I have read that some browsers do not allow cross-domain scripting and that I should create a proxy on my local server to serve the data.</p>
<p>Can someone please point me to a simple example of how to do this ... | <p>You may be able to avoid a proxy by using a technique like <a href="http://remysharp.com/2007/10/08/what-is-jsonp/" rel="nofollow noreferrer">JSONP</a>. Assuming the web service you're talking to supports JSONP (for example, Flickr or Twitter both offer a JSONP API) or you have control over the data the web service ... | <p><strong>No</strong> browsers allow cross-domain scripting, and although w3c has left space for this in its recommendation on the xmlHTTPRequest-object, we still have to wait for some time to see it implemented in a secure way ...</p>
| 29,559 |
<p>What is the difference between old style and new style classes in Python? When should I use one or the other?</p>
| <p>From <em><a href="http://docs.python.org/2/reference/datamodel.html#new-style-and-classic-classes" rel="noreferrer">New-style and classic classes</a></em>:</p>
<blockquote>
<p><strong>Up to Python 2.1, old-style classes were the only flavour available to the user.</strong></p>
<p>The concept of (old-style) c... | <p>New-style classes inherit from <code>object</code> and must be written as such in Python 2.2 onwards (i.e. <code>class Classname(object):</code> instead of <code>class Classname:</code>). The core change is to unify types and classes, and the nice side-effect of this is that it allows you to inherit from built-in ty... | 7,852 |
<p>Just wondering if anybody had working code example (in c#) for exporting a crystal report to Excel from a .NET application without the report's page headers and footer's.</p>
<p>I am using crystal reports v9 runtime.</p>
| <p>Have you looked <a href="http://articles.slicehost.com/search?q=email" rel="nofollow noreferrer">here</a>, seems to me that there is plenty of information to get started. I found <a href="http://articles.slicehost.com/2008/9/2/mail-server-slice-setup" rel="nofollow noreferrer">mail-server-slice-setup</a> to be quite... | <p>Just install something like postfix as "internet site" and you'll be able to send mails directly from your VPS</p>
<p>it should work with default settings but it would be recommended to also read a few docs/how-to's to secure it properly </p>
| 23,914 |
<p>Is there a way to trigger a beep/alarm/sound when my breakpoint is hit? I'm using Visual Studio 2005/2008.</p>
| <h3>Windows XP</h3>
<p>Control Panel -> Sounds and Audio... -> Program Events - Microsoft Developer -> Breakpoint Hit</p>
<h3>Windows 7</h3>
<p>Control Panel -> All Control Panel Items -> Sounds -> Sounds (tab) - Microsoft Visual Studio -> Breakpoint Hit</p>
| <p>You can create a macro that runs in response to a breakpoint firing. In your macro, you could do whatever it takes to make a beeping noise.</p>
| 10,603 |
<p>On the other end of the spectrum, I would be happy if I could install a wiki and share the login credentials between <a href="http://en.wikipedia.org/wiki/WordPress" rel="nofollow noreferrer">WordPress</a> and the wiki. I hacked <a href="http://en.wikipedia.org/wiki/MediaWiki" rel="nofollow noreferrer">MediaWiki</a>... | <p>The tutorial <em><a href="https://bbpress.org/forums/topic/mediawiki-bbpress-and-wordpress-integration/" rel="nofollow noreferrer">WordPress, bbPress & MediaWiki</a></em> should get you on the right track to integrating MediaWiki into your WordPress install. It's certainly going to be a <em>lot</em> easier than ... | <p>My company uses WordPress and MediaWiki internally and we use HTTP_AUTH access control to create a "single sign on". As we add more applications, we simply integrate them into the HTTP_AUTH system where practical. For security, you can run HTTP_AUTH over SSL. The basic steps are:</p>
<p>Configure the .htaccess t... | 5,382 |
<p>Is there some means of querying the system tables to establish which tables are using what locking schemes? I took a look at the columns in <strong>sysobjects</strong> but nothing jumped out.</p>
| <p>aargh, just being an idiot:</p>
<pre><code>SELECT name, lockscheme(name)
FROM sysobjects
WHERE type="U"
ORDER BY name
</code></pre>
| <p>take a look at the syslockinfo and syslocks system tables
you can also run the sp_lock proc</p>
| 2,948 |
<p>I have to read a COM port and the data should be displayed inside the TextArea dynamically (data will come every minute), which I have created inside JPanel.</p>
<p>Advance Thanks for reply.</p>
| <p>Some leads:</p>
<ul>
<li><a href="http://www.java2s.com/Code/Java/Development-Class/COM-Port.htm" rel="nofollow noreferrer">java2s has some examples</a>.</li>
<li>this <a href="http://www.java2s.com/Code/Java/Development-Class/OpenaserialportusingJavaCommunications.htm" rel="nofollow noreferrer"><strong>CommPortOpe... | <p>For a multi-platform application, look into <a href="http://www.rxtx.org/" rel="nofollow noreferrer">rxtx</a>.</p>
<p><code>javax.comm</code> has not had active development for a number of years. The <a href="http://www.rxtx.org/" rel="nofollow noreferrer">rxtx</a> project has a compatible api as well as a more f... | 45,381 |
<p>I writing a report in Visual Studio that takes a user input parameter and runs against an ODBC datasource. I would like to write the query manually and have reporting services replace part of the where clause with the parameter value before sending it to the database. What seems to be happening is that the <code>@pa... | <p>It sounds like you'll need to treat the SQL Statement as an expression. For example:</p>
<pre><code>="Select col1, col2 from table 1 Where col3 = " & Parameters!Param1.Value
</code></pre>
<p>If the where clause is a string you would need to do the following:</p>
<pre><code>="Select col1, col2 from table 1 Wh... | <p>I am a bit confused about this question, if you are looking for simple parameter usage then the notation is :<code>*paramName*</code> , however if you want to structurally change the <code>WHERE</code> clause (as you might in sql+ using ?) then you should really be using custom code within the report to define a fun... | 3,068 |
<p>I am writing a photo gallery/sharing website and want to (1) write EXIF data to the JPEGs stored on server, and (2) strip that EXIF data prior to writing to the output stream for display.</p>
<p>Is anyone aware of a dotNet library -- preferably open source -- that allows the editing (the key here is that I need to ... | <p>Check this libraries:</p>
<ul>
<li><a href="http://www.codeproject.com/KB/graphics/exifextractor.aspx" rel="noreferrer">EXIFextractor</a></li>
<li><a href="http://www.codeproject.com/KB/graphics/photoproperties.aspx" rel="noreferrer">Photo Properties</a></li>
<li><a href="http://www.codeproject.com/KB/GDI-plus/Imag... | <p>If you're searching for a .net Standard compatible library, I highly recommend <a href="https://github.com/SixLabors/ImageSharp" rel="nofollow noreferrer">ImageSharp</a>.</p>
| 28,077 |
<p>Following this <a href="https://3dprinting.stackexchange.com/questions/2617/decent-cnc-control-software-for-osx">issue</a> I would like to propose to allow general CNC related questions here as well. 3D Printers are CNC machines, they only add instead of subtract. 3D printers use G-Code, just like CNC milling machin... | <p>There are tens of SE sites that deal with programming in some way, shape or form. SO is obviously the most general one of these, but there are many more specialized ones (CodeReview,TeX,Programmers,Drupal/Wordpress/Joomla/Server Fault/Ubuntu/...). If this site had been "Makers StackExchange" or "Digital Fabrication"... | <p>As has been discussed previously <a href="https://3dprinting.meta.stackexchange.com/questions/147/hobbyist-machine-questions-on-topic">here</a>, the relevance of CNC questions on this site depend on the questions closeness to 3D printing. So, for instance, if the software you are asking about is the same as a 3D pri... | 34 |
<p>I found a lot of questions asking for the best tool, but none asking for the <strong>features, you really need</strong>? And what features you <em>never</em> really needed?</p>
<p>(I caught myself to be comparing tools on feature matrices. Something I hate, because in the end I will be using only the 3-4 most impor... | <p>It need to:</p>
<ol>
<li>collect bugs</li>
<li>order bugs on priority/severity/due date etc</li>
<li>assign bugs to developers</li>
<li>track a bug history</li>
<li>link similar bugs together</li>
<li>link bugs to customers</li>
<li>link solved bugs to releases</li>
<li>provide enough information or a reference to ... | <p>Need:</p>
<p><li>Email notification.
<li>Status
<li>Group notify
<li>Group rights
<li>Web interface
<li>Easy / fast interface</p>
| 41,241 |
<p>I know Googling I can find an appropriate answer, but I prefer listening to your personal (and maybe technical) opinions.<br/>
<strong>What is the main reason of the difference between Java and C# in throwing exceptions?</strong><br/>
In Java the signature of a method that throws an exception has to use the "throws"... | <p>In the article <a href="http://www.artima.com/intv/handcuffs.html" rel="nofollow noreferrer">The Trouble with Checked Exceptions</a> and in Anders Hejlsberg's (designer of the C# language) own voice, there are three main reasons for C# not supporting checked exceptions as they are found and verified in Java:</p>
<ul... | <p>I went from Java to C# because of a job change. At first, I was a little concerned about the difference, but in practice, it hasn't made a difference.</p>
<p>Maybe, it's because I come from C++, which has the exception declaration, but it's not commonly used. I write every single line of code as if it could throw... | 15,099 |
<p>Say I have a list of all <code>Projects</code>, and that I group them by <code>Category</code> like this:</p>
<pre><code>var projectsByCat = from p in Projects
group p by p.Category into g
orderby g.Count() descending
select new { Category = g.Key, Projects... | <p>If you're using LINQ to SQL or LINQ to Entities you should first fully materialize the results into memory:</p>
<pre><code>var oddCategories = projectsByCat.ToList().Where((c,i) => i % 2 != 0);
var evenCategories = projectsByCat.ToList().Where((c,i) => i % 2 == 0);
</code></pre>
<p>It isn't possible to iter... | <pre><code>var text = "this is a test <string> to extract odd <index> values after split";
var parts = text.Split(new char[] { '<', '>' });
IEnumerable words = parts.Where(x => parts.ToList().IndexOf(x) % 2 == 1)
</code></pre>
<p><em>words</em> would contain "string" and "index"</p>
| 33,485 |
<p>What Direct3D render states should be used to implement Java's Porter-Duff compositing rules (CLEAR, SRC, SRCOVER, etc.)?</p>
| <p>I'm haven't used Java too much, but based on the <a href="http://keithp.com/~keithp/porterduff/p253-porter.pdf" rel="nofollow noreferrer">white paper from 1984</a>, it should be a fairly straightforward mapping of render state blend modes.</p>
<p>There are of course more that you can do than just these, like normal... | <p>When I implement the render states for "A" (that is paint the source pixel color/alpha and ignore the destination pixel color/alpha), Direct3D doesn't seem to perform the operation correctly if the source has an alpha value of zero. Instead of filling the target area with transparency, I'm seeing the target area re... | 8,816 |
<p>I have two printers, one is an Anet A8 and the other one is a CreatBot DX plus. On both of them I installed a BLTouch, firstly on the DX and today on the A8. I have never had a problem with the probe, but today I am experiencing some problems. I just set the offset, by doing the procedure, and I found to that the Z0... | <p>I've tried that item as well. In fact, other than the heart, I built a <a href="https://www.thingiverse.com/thing:3825323" rel="nofollow noreferrer">remix</a> which works better but is still difficult to free up after printing. Those tabs you're concerned about will print better at a very low (thin) layer setting... | <p>It's not uncommon that different slicers have different effects on different models.
The techniques used to slice the models differs. If the model you slice works fine in one and not in the other it's sometimes a setting but sometimes just the slicer.
Just use the slicer that works :)</p>
| 1,575 |
<p>I was wondering if there is a better way to cope with MS-Access' inability to handle NULL for boolean-values other than change the column-data-type to integer.</p>
| <p>I think you must use a number, and so, it seems does <a href="http://allenbrowne.com/tips.html" rel="nofollow noreferrer">Allen Browne, Access MVP</a>.</p>
| <p>Not that I've found :( I haven't programmed Access in awhile, but what I remember involves quite a lot of isNull checks.</p>
| 11,327 |
<p>I need to implement a Diff algorithm in VB.NET to find the changes between two different versions of a piece of text. I've had a scout around the web and have found a couple of different algorithms.</p>
<p>Does anybody here know of a 'best' algorithm that I could implement?</p>
| <p>Well I've used the c# version on codeproject and its really good for what I wanted...</p>
<p><a href="http://www.codeproject.com/KB/recipes/diffengine.aspx" rel="noreferrer">http://www.codeproject.com/KB/recipes/diffengine.aspx</a></p>
<p>You can probably get this translated into VB.net via an <a href="http://labs... | <p>I don't know for sure if it's the best diff algorithms but you might want to check out those links that talks about SOCT4 and SOCT6</p>
<p><a href="http://dev.libresource.org/home/doc/so6-user-manual/concepts" rel="nofollow noreferrer">http://dev.libresource.org/home/doc/so6-user-manual/concepts</a></p>
<p>and als... | 2,530 |
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/13537/bootstrapping-a-language">Bootstrapping a language</a> </p>
</blockquote>
<p>What's the importance of having an interpreter for a given language written in the target language (for example, <a href="http:... | <p>It's not so much about writing the interpreter in itself - more about writing the interpreter in a high-level language, not in C. Ideally, doing so allows to change details of the implementation, and making the interpreter more modular.</p>
<p>For the specific case of PyPy, writing the interpreter and the core obje... | <p>An added benefit is that if you implement good debugers and IDEs for your target language, they also work for your source language.</p>
| 34,856 |
<p>I'd like to try out Eclipse, but I'm a bit baffled with all the different distributions of it. I mainly program in Python doing web development, but I also need to maintain PHP and Perl apps. It looks like EasyEclipse is a bit behind. Should I just grab the base Eclipse and start loading plug-ins?</p>
| <p>Maybe try Aptana (<a href="http://www.aptana.com/" rel="nofollow noreferrer">http://www.aptana.com/</a>) - you can then plug in as many extra modules as you require.</p>
| <p>PyDev is pretty decent as I'm sure you know. It can fit on top of all the Eclipse distributions (provided they meet the minimum version requirements). If you're doing webdev stuff, you'll probably find the closest fit with Aptana. </p>
<p>That said, I find Aptana hideously clunky when compared to a decent text edit... | 47,583 |
<p>I have a VB6.0 project and I want to convert it in VB.Net.</p>
<p>In my VB6.0 application some of the MDI Child form’s height is 17000 and width is 13000. Now I want to set the same form size in VB.Net forms, but it allows maximum form width = 1036, height = 780 for resolution 1024x768.</p>
<p>How can I increase f... | <p>Your classic VB units are in what are called "twips". You will most likely be able to divide those numbers by 12 or 15 (depending on if you are using large or small fonts) and you will get a certain number of pixels.</p>
| <p>I think the VB6 units are not the same with the VB.Net one. So you have to do a conversion.</p>
| 5,643 |
<p>Web applications that want to force a resource to be <em>downloaded</em> rather than directly <em>rendered</em> in a Web browser issue a <code>Content-Disposition</code> header in the HTTP response of the form:</p>
<p><code>Content-Disposition: attachment; filename=<em>FILENAME</em></code></p>
<p>The <code>filename<... | <p>I know this is an old post but it is still very relevant. I have found that modern browsers support rfc5987, which allows utf-8 encoding, percentage encoded (url-encoded). Then Naïve file.txt becomes:</p>
<pre><code>Content-Disposition: attachment; filename*=UTF-8''Na%C3%AFve%20file.txt
</code></pre>
<p>Safari (5)... | <p>I normally URL-encode (with %xx) the filenames, and it seems to work in all browsers. You might want to do some tests anyway.</p>
| 11,908 |
<p>Is there a way in Oracle to select the date on which daylight savings will switch over for my locale?</p>
<p>Something vaguely equivalent to this would be nice:</p>
<pre><code>SELECT CHANGEOVER_DATE
FROM SOME_SYSTEM_TABLE
WHERE DATE_TYPE = 'DAYLIGHT_SAVINGS_CHANGEOVER'
AND TO_CHAR(CHANGEOVER_DATE,'YYYY') = TO_CH... | <p>We use the following two functions to calculate the start and end dates for any given year (post 2007, US).</p>
<pre><code>Function DaylightSavingTimeStart (p_Date IN Date)
Return Date Is
v_Date Date;
v_LoopIndex Integer;
Begin
--Set the date to the 8th day of March which will effectively skip the f... | <p>Here's my version of the above. It's advantage is that it does not need a second 'alter session set time zone', and can be used more easily from an application.
You create the stored function, and then you simply use:
ALTER SESSION SET time_zone='Asia/Jerusalem';
select GetDSTDates(2012,1) DSTStart,GetDSTDates(2012,... | 36,585 |
<p>In implementing my first significant script using jquery I needed to find a specific web-control on the page. Since I work with DotNetNuke, there is no guaranteeing the controls ClientID since the container control may change from site to site. I ended up using an attribute selector that looks for an ID that ends ... | <pre><code>$("#<%= cboPanes.ClientID %>")
</code></pre>
<p>This will dynamically inject the DOM ID of the control. Of course, this means your JS has to be in an ASPX file, not in an external JS file.</p>
| <p>Use a marker class on the control, and select that via jQuery.</p>
| 19,768 |
<p>I'm trying to figure the best strategy about how to organize DataContexts. The typical DB we work has between 50 and 100 tables usually in third-normal form and with many relations between them. I think we have two options:</p>
<ol>
<li>Put all tables in a single context. This will ensure that anything we do will b... | <p>LINQ-to-SQL mappings are like typed DataSets, in that when you use one, you're dealing with a session containing data. You can have the same tables in several different DataContexts. They're only classes, after all; they don't mean anything until you start interacting with the database, by filling them with existi... | <p>You should create contexts that allow you to perform <em>units of work</em>. This may involve overlapping table mappings.</p>
<p>Context1 : Customer has many Invoices</p>
<p>Context2 : Customer has many Orders</p>
<p>Context3 : Invoice has many Orders</p>
| 28,932 |
<p>Does anyone know (like in tried and succeeded) if I can have D2009 both in English and in French?<br>
It's not so much to generate French or English applications but to have the IDE available in either language to take screen shots and make demos in French or in English. </p>
<p>What would be involved: complementa... | <p>Install one version in a virtual machine. I hear VMWare works really good.</p>
| <p>Why would you want that? If you need internationalized versions of your program, you should better use at tool for that purpose (e.g. dxGetText) rather than recompile it with a different Delphi version. In that case I definitely suggest using the English IDE, so you can translate the RTL errors from English to the t... | 21,748 |
<p>I'm researching SVN repository browsers, and it's a tiresome task given how many are out there (I started <a href="http://subversion.tigris.org/links.html#browsers" rel="nofollow noreferrer">here</a>)</p>
<p>The "ideal" system would</p>
<ul>
<li>Run on Linux</li>
<li>Be easy to use, even for non-developer types</l... | <p>Trac.( <a href="http://trac.edgewall.org/" rel="noreferrer">http://trac.edgewall.org/</a> ) Its not wonderful, but from what I've seen, for SVN its the best. </p>
<p>With Access control to boot.</p>
<p>I managed to set up a rig with even per-directory permissions for various trac users ( they just didn't appear ... | <p>You should have a look at <a href="http://www.groowiki.com" rel="nofollow noreferrer">http://www.groowiki.com</a></p>
<p>We plan to have the access control features you miss, it is on the roadmap. We also target search, workflow support and right now you can add description to the file and directories
using radeox ... | 12,142 |
<p>I'm sure this is a newbie question, but every time I've compiled/dl'ed a new version of vim for os x, running vim on the command-line opens up the gvim app. I just want to upgrade the console version (so I can, for example, have python compiled in to use omnicomplete).</p>
| <p>You can also use MacPorts to handle the installation for you. Once you've installed it, run the <code>/opt/local/bin/vim</code> binary. I place this in my <code>PATH</code> before the system binary dirs (although be aware that this may cause problems for cmdline tools that rely on the versions of tools shipped with... | <p>Can also symlink your new binary to /usr/local/bin/</p>
| 18,207 |
<p>I think there are several newsletters which are very good in content. </p>
<p>EDIT: Such as <a href="http://www.javaspecialists.eu/archive/archive.jsp" rel="nofollow noreferrer">http://www.javaspecialists.eu/archive/archive.jsp</a></p>
| <p>In flagrant self-promotion, I recommend my Java tips, <a href="http://solidsimplesafe.com/" rel="nofollow noreferrer">http://solidsimplesafe.com/</a>. You can subscribe via newsletter or RSS.</p>
<p>I've been distracted from this by another project recently. But I've got plenty of new material waiting to be whipped... | <p>For .NET i would subscribe to Scott Guthrie's <a href="http://weblogs.asp.net/scottgu/" rel="nofollow noreferrer">blog,</a></p>
<p>Especially if its ASP.NET!</p>
| 44,226 |
<p>I have this query in sql server 2000:</p>
<pre><code>select pwdencrypt('AAAA')
</code></pre>
<p>which outputs an encrypted string of 'AAAA':</p>
<pre>
0x0100CF465B7B12625EF019E157120D58DD46569AC7BF4118455D12625EF019E157120D58DD46569AC7BF4118455D
</pre>
<p><strong>How can I convert (decrypt) the output from its o... | <p>I believe pwdencrypt is using a hash so you cannot really reverse the hashed string - the algorithm is designed so it's impossible. </p>
<p>If you are verifying the password that a user entered the usual technique is to hash it and then compare it to the hashed version in the database.</p>
<p>This is how you could... | <p>You cannot decrypt this password again but there is another method named "pwdcompare". Here is a example how to use it with SQL syntax:</p>
<pre><code>USE TEMPDB
GO
declare @hash varbinary (255)
CREATE TABLE tempdb..h (id_num int, hash varbinary (255))
SET @hash = pwdencrypt('123') -- encryption
INSERT INTO tempdb.... | 20,885 |
<p>I've got a very small standalone vb.net app that gets run automatically. Every now and then it hits an error condition that I want to log and then keep processing. But, this is far too minor a thing to store in the system's main log - I really just want to append a line to a text file.</p>
<p>What's the least str... | <p><a href="http://msdn.microsoft.com/en-us/library/ms143356.aspx" rel="noreferrer">IO.File.AppendAllText</a>(@"Y:\our\File\Name.here", "your log message here")</p>
| <p>This MSDN article, <a href="http://msdn.microsoft.com/en-us/library/6ka1wd3w.aspx" rel="nofollow noreferrer">How to: Write Text to a File</a> should do it.</p>
| 34,429 |
<p>I've got an ms-access application that's accessing and ms-sql db through an ODBC connection. I'm trying to force my users to update the data <em>only</em> through the application portion, but I don't care if they read the data directly or through their own custom ms-access db (they use it for creating ad hoc reports... | <p>There is a way to do this that is effective with internal users, but can be hacked. You create two IDs for each user. One is a reporting ID that has read-only access. This is they ID that the user knows about: Fred / mypassword</p>
<p>The second is an ID that can do updates. That id is Fred_app / mypassword_mang... | <p>Does you app allow for linked table updates or does it go through forms? Sounds like your idea of using a centralized user with distinct roles is the way to go. Yes, you could change users but I that may introduce more coding and once you start adding more and more code other solutions (stored procedures, etc) may s... | 7,287 |
<p>I maintain several client sites that have no dynamic data whatsoever, everything is static asp.net with c#.<br>
Are there any pitfalls to caching the entire page for extreme periods of time, like a week?</p>
<p>Kibbee, We use a couple controls on the sites (ad rotator, some of the ajax extensions) on the sites. Th... | <p>The only significant pitfall to long cache times occurs when you want to update that data. To be safe, you have to assume that it will take up to a week for the new version to become available. Intermediate hosts such as a ISP level proxy servers often do cache aggressively so this delay will happen.</p>
<p>If ther... | <p>When you say that you have no data, how are you even using asp.net or c#. What functionality does that provide you over plain HTML? Also, if you do plan on caching, it's probably best to cache to a file, and then when a request is made, stream out the file. The OS will take care of keeping the file in memory so th... | 5,707 |
<p>Is there a single shortcut to start inserting in the new line at end of the file?</p>
<p>I'm aware of <kbd>G</kbd> + <kbd>o</kbd> combo.</p>
| <p>There's also the command line option "+":</p>
<pre>
vim + myfile.txt
</pre>
<p>Will open myfile.txt and do an automatic G for you.</p>
| <p>You could stick the map definition in your .vimrc and then invoke it when the you open the file.</p>
<p>Or, if you only want to do this for a particular file, you could create an autocmd for that file type that does it automatically. See <a href="http://vimdoc.sourceforge.net/htmldoc/autocmd.html#autocommand" rel="... | 33,647 |
<p>I have this simple controller:</p>
<pre><code>public class OneController : Controller
{
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Create()
{
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(IList<TestModel> m)
{
return View(m);
}... | <p>I was already looking at that article, and found the bug I was having (subtle, yet critical).
If you render the hidden field with the index using Html.Hidden, the helper will "accumulate" the previous values, so you'll end up with a hidden saying index=1, and the next saying index=1,2.</p>
<p>Changing the helper ca... | <p>Not sure I can answer without seeing more of the code and how your form is setup.
But, you could take a look at <a href="http://www.haacked.com" rel="nofollow noreferrer">Phil Haack's</a> blog entry about <a href="http://www.haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx" rel="nofollow noreferrer">Model... | 33,821 |
<p>I'm a .NET developer, and worked with VB6 before that. I've become very familiar with those environments, and working in the context of garbage collected languages. However, I now wish to bolster my skillset with native C++ and find myself a bit overwhelmed. Ironically, it's not what I'd imagine is the usual stum... | <p>I know you say you've got a good grasp of pointers and memory management, but I'd still like to explain an important trick.
As a general rule of thumb, <em>never</em> have new/delete in your user code.</p>
<p>Every resource acquisition (whether it's a synchronization lock, a database connection or a chunk of memory... | <p>I <a href="http://khason.net/blog/pinvoke-cheat-sheet/" rel="nofollow noreferrer">wrote small cheat sheet</a> for such programmers. You also might be interested with more complicated cases, such <a href="http://khason.net/blog/how-to-pinvoke-varargs-variable-arguments-in-c-or-hidden-junk-in-clr/" rel="nofollow noref... | 36,291 |
<p>What's the best way to perform a deep copy in the constructor of an object that is part of multi-threaded C++ code?</p>
| <p>Depends on your data structures.</p>
<p>I'd guess the problem you're facing (although you don't say so) is potential locking inversion. If you're deep copying, then you will presumably take one or more locks for the various objects you need to copy. </p>
<p>If you can define a DAG (that is, a partial order) where ... | <p>My first impulse (I'm not an expert):</p>
<p>Have a lock on that object that the code uses for writing to it. When you're deep copying, lock the object, perform your deep copy, and then unlock it.</p>
<p>Or, am I missing something here?</p>
| 21,279 |
<p>I'm working with JIntegra java com bridge.
I have an object of type Object which true coclass is unknown.
I need to check if that object can be casted to specific COM interface (which has a proxy class generated by JIntegra).</p>
| <p>Call <code>queryInterface()</code> on the proxy. It should throw an exception if the underlying COM object does not implement the proxy interface.</p>
| <p>If the proxy class implements a (generated) interface, can you check if the object is an instanceof that?</p>
| 21,912 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.