input stringlengths 51 42.3k | output stringlengths 18 55k |
|---|---|
When should I be concerned about transaction size? <p>I have a feature where we need to merge user records. The user chooses a user to keep and and a user to discard.</p>
<p>We have 59 relations to user records in our database so for each one I need to do:</p>
<p><code>
UPDATE (Table) set UserNo=(userToKeep) WHERE Us... | <p>Have you tested how long the process actually takes? How often are users merged?</p>
<p>If you have indexes on the user ID in each of this table (and I would think that would be the natural thing to do anyway) then even with 59 tables it shouldn't take too long to perform those updates and deletes. If you only actu... |
Delete Chars in Python <p>does anybody know how to delete all characters behind a specific character??</p>
<p>like this:</p>
<pre><code>http://google.com/translate_t
</code></pre>
<p>into </p>
<pre><code>http://google.com
</code></pre>
| <p>if you're asking about an abstract string and not url you could go with:</p>
<pre><code>>>> astring ="http://google.com/translate_t"
>>> astring.rpartition('/')[0]
http://google.com
</code></pre>
|
Write Dataset to SQL Table <p>I have converted a complex XML File to a Dataset that has 7 Tables and around 70 Columns I have created the tables in SQL Server to match the ones in the Dataset using the XML Schema. How can I easily write my Dataset to the SQL tables?</p>
| <p>Depending on how many rows you have in the DataSet, probably the best thing to do would be to use a SqlCommandBuilder, like so:</p>
<pre><code>var connection = new SqlConnection("my connection string");
connection.Open();
// repeat for each table in data set
var adapterForTable1 = new SqlDataAdapter("select * from... |
How to declare a variable/param of type "Control implementing interface ISomething"? <p>I wish to declare a variable in such a way as it can be assigned only values which derive from Control and also implement the ISomething interface.</p>
<p>I intend to add the ISomething interface to derivatives of controls. </p>
<... | <p>One way to do this is with generics - i.e. a generic method:</p>
<pre><code>void Foo<T>(T control) where T : Control, ISomething
{
// use "control"
// (you have access to all the Control and ISomething members)
}
</code></pre>
<p>Now you can call Foo <strong>only</strong> with other variables that ar... |
Should I add AJAX logic to my PHP classes/scripts? <p>I just started making a PHP/AJAX site and I was wondering where I should add the functionality to <strong>"only include the content"</strong>.</p>
<p>Should I have if statements in my header and footer scripts that check for a <strong>"ContentOnly"</strong> get par... | <p>Please don't use AJAX for the sake of using AJAX.</p>
<p>That said, most AJAX libraries pass a <code>X-Requested-With</code> HTTP header indicating that it's an AJAX request. You can use that header to decide whether to include your header/footer etc.</p>
|
In the windows python console, how to make Tab = four spaces? <p>Hello I would like that when I am in the python
console tabbing will give me four spaces. Any ideas? </p>
| <ol>
<li>Download and install <a href="http://www.autohotkey.com" rel="nofollow">AutoHotkey</a></li>
<li><p>Write this script:</p>
<pre><code>SetTitleMatchMode 2
#IfWinActive python
tab::
Send, {SPACE}
Send, {SPACE}
Send, {SPACE}
Send, {SPACE}
</code></pre></li>
</ol>
<p>Save it as tab-to-space.ahk, and doubleclick o... |
How do I make a reusable XIB with it's own UIViewController? <p>I am trying to create a reusable "picker". It is basically like a keypad of a phone. Since I will be using this a lot in my iPhone app, I have been frustrated with trying to make it appear.</p>
<p>It is in its own XIB file and has its own UIViewController... | <p>Are you pushing the view controller? </p>
<pre><code>[[self navigationController] pushViewController:mpvc animated:YES];
</code></pre>
<p>Or are you adding the view controller's view as a subView of your current view?</p>
|
Any resource/codes on how fiddler works? <p>I need to track http/url requests & redirects from a windows forms application using C#. It should handle both IE & firefox. Not sure if Fiddler is open-source but if i'm not mistaken, it's written using .NET. Sample codes or online articles on how to listen to http/u... | <p>Fiddler works as standard HTTP <a href="http://en.wikipedia.org/wiki/Proxy_server">proxy</a>. There is no magic here. See HTTP protocol for details. In both IE/Firefox, you need to set Fiddler (or your custom program) as proxy, and then browser will use it for all outgoing requests. Proxy is responsible for forwardi... |
Is there a fundamental difference between backups and version control? <p>How does version control differ from plain backups?</p>
<p>Let's forget about the feature decoration, and concentrate on the soul of version control. Is there a clear line that backups must cross before they can be called a VCS? Or are they, at ... | <p>The fundamental idea of version control is to manage <em>multiple revisions</em> of the same unit of information. The idea of backup is to copy the <em>latest version</em> of information to safe place - older versions can be overwritten.</p>
|
How to dynamically change shortcut key in Firefox? <p>I have a firefox extension which can be activated by a shortcut key. I want users to be able to change the key combo dynamically.</p>
<p>My XUL looks like this</p>
<pre><code><keyset id="ksMain">
<key id="keyDoMyThing" modifiers="control,shift" key="e... | <p>Turns out I need to delete the keyset as well and create an entirely new keyset. </p>
<pre><code>ksparent = keyset.parentNode
ksparent.removeChild(keyset);
keyset = document.createElement('keyset');
keyset.id = 'my-keyset';
keyelem = document.createElement('key');
keyelem.setAttribute('id', 'keyDoMyThing');
keyel... |
I get "Missing these required gems", but gems are installed <p>since I updated ruby using Mac Ports (on Leopard) I have got several problems and I also had to reinstall gems. Now when I run Mongrel I keep getting the error "Missing these required gems" followed by the list of gems that I required in environment.rb but ... | <p>You should use :</p>
<pre><code> config.gem 'rspec', :lib => 'spec'
config.gem 'rspec-rails', :lib => 'spec/rails'
</code></pre>
<p>because rspec libs are not named as it should ...</p>
|
Cygwin: Control-r reverse-i-search in bash: how do you "reset" the search? <p><strong>Question:</strong> How do you tell <kbd>Ctrl</kbd>+<kbd>r</kbd> reverse-i-search to "reset itself" and start searching from the bottom of your history every time?</p>
<p><strong>Background:</strong> When using reverse-i-search in bas... | <p>My bash works as you are expecting. Maybe hitting "ctrl+C" instead of "esc" can help.</p>
<p>Also, you can search forward using "ctrl+s" </p>
<p><em>edit</em>: ctrl+s works if it does not send a "stop" to your terminal, i.e. if "stty -a" gives you "-ixon". You can change it by "stty -ixon". Thanks to @Phil for rem... |
Is it possible to alias a branch in Git? <p>I am looking into using git on a massive scale. I was hoping to increase adoption and make things easier by calling the master branch trunk. </p>
<p>This can and will give SVN users some feelings of comfort. I know I can create a branch called trunk but that seems to devia... | <p>You can rename the master branch trunk as Greg has suggested, or you can also create a trunk that is a symbolic reference to the master branch so that both git and svn users have the 'main' branch that they are used to.</p>
<pre><code>git symbolic-ref refs/heads/trunk refs/heads/master
</code></pre>
<p>Note that t... |
Removing the TK icon on a Tkinter window <p>Does anybody know how to make the icon not show up? I'm looking for a way to have no icon at all.</p>
| <h3>On Windows</h3>
<p><strong>Step One:</strong></p>
<p>Create a transparent icon using either an icon editor, or a site like <a href="http://www.rw-designer.com/online_icon_maker.php" rel="nofollow">rw-designer</a>. Save it as <code>transparent.ico</code>.</p>
<p><strong>Step Two:</strong></p>
<pre><code>from tki... |
Cocoa Application Finished Launch <p>Is there any way to tell if a Cocoa application, such as Safari, has finished launching and able to respond?
I know it's easy to do using delegates within the actual code but that isn't possible for what I'm doing.</p>
<p>Thanks</p>
| <p>Check out NSWorkspace and NSWorkspaceDidLaunchApplicationNotification. Something like this:</p>
<pre><code>[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(appDidLaunch:) name:NSWorkspaceDidLaunchApplicationNotification object:nil]
</code></pre>
<p>The NSNotification object p... |
How can I allow a user to assign different site functions to different roles in an asp.net role provider? <p>I am debating on whether or not to write my own authentication class. It's almost done but I think it could be better to use a role provider (either custom or the default.) I know you can assign users to roles, ... | <p>The basic ASP.NET Role provider is flat structured - so a user needs to belong to all the roles they are a member of.</p>
<p>You would need to find/<a href="http://msdn.microsoft.com/en-us/library/8fw7xh74.aspx" rel="nofollow">write a role provider</a> that supports hierarchies - I'd recommend this route over somet... |
Uses for MachineKey in ASP.NET <p>What different ways are Machine Keys useful in asp.net?
I think the following are correct but thought there may be more.</p>
<ol>
<li>Multiple applications can use the same cookie</li>
<li>Multiple servers can work with the same viewstate</li>
</ol>
| <p>MachineKey is used for:</p>
<ul>
<li>ViewState encryption and validation</li>
<li>Forms Authentication (or Federated Authentication) uses this key for signing the authentication ticket</li>
</ul>
<p>Having a Web App installed on multiple servers requires same Machine Key configured on all of them in order for Load... |
Django Model API reverse lookup of many to many relationship through intermediary table <p>I have a Resident and can not seem to get the set of SSA's the resident belongs to. I've tried <code>res.ssa_set.all()</code> <code>.ssas_set.all()</code> and <code>.ssa_resident_set.all()</code>. Can't seem to manage it. What's ... | <p>I was trying to evaluate a query set object, not the object itself. Executing a get on the query set and then a lookup of the relation set worked fine. I'm changing to community wiki and leaving this here just incase someone else is as stupid as I was.</p>
<p>A working example:</p>
<pre><code>resident = Resident.o... |
How can I debug this line of code in Visual Studio? <p>I have the following line of code in VS2008.</p>
<pre><code> VirtualPathData virtualPathData =
RouteTable.Routes.GetVirtualPath(_viewContext.RequestContext,
"Home",
pageLinkValueDictionary);
</code></pre>
<p>I wish to debug this <cod... | <p>That the symbols file is downloaded doesn't mean that sources are available for it, the pdb needs to be source indexed as well.</p>
<p>From <a href="http://weblogs.asp.net/scottgu/archive/2007/10/03/releasing-the-source-code-for-the-net-framework-libraries.aspx" rel="nofollow">Scott Guthrie's announcement</a>:</p>
... |
Appropriate VS Project for Multiple .Net Sites <p>Here's what I'm working with:</p>
<ul>
<li>Several websites</li>
<li>Classes/data shared between them (registration systems on individual sites, and management on a central site)</li>
<li>A workflow application that runs nightly.</li>
</ul>
<p>I need to be able to cle... | <p>this is sort of a no brainer, unless I am missing something in your question.</p>
<p>You would have a website project for each website, and a class library project for your dll.</p>
<p>But what I THINK you meant is how to easily share the DLL(s) across all sites? In that case try coding some post build events for... |
jQuery: form returned on "success" needs re-binding <p>a quick question. I am using the jQuery.forms.js plug-in. </p>
<p>I have a form that posts to a php page and returns data with jSon. </p>
<p>The data that is returned is code for a new form (it replaces the form that was used to post the information). The new for... | <p>The easiest solution to this is not using jQuery's form plugin and doing it manually, which is really not very difficult:</p>
<pre><code>$(document).ready(function() {
jQuery('form[id*=postOnline]').live('submit', function() {
var formdata = $(this).serialize();
$.ajax({
type: $(thi... |
Is it a bad idea to use php in css documents? <p>I have created css page called style.php and included this the top: </p>
<p><code><?php header("Content-type: text/css"); ?></code></p>
<p>Does this make you cringe. Is it a terrible idea? I am doing this because I have created a CMS that allows the admin to con... | <p>It's not a bad idea (subject to the notes about caching + content-type), but think about the cost of firing up a PHP instance (mod_php) or passing the script to an already running php (fastcgi style). Do you really want that overhead?</p>
<p>You might be better off writing a "cached" version of your CSS page to a s... |
Quick primer on implementing a COM object that implement some custom IDLs in python? <p>Does anyone have experience using python to create a COM object that implements some custom IDLs? </p>
<p>Basically I'd like to know if it's extremely simple to do compared to c++, and if it is do you know of a good tutorial?</p>
| <p>The tutorial you are looking for is in the <a href="http://oreilly.com/catalog/9781565926219/" rel="nofollow">Python Programming On Win32</a> book, by Mark Hammond and Andy Robinson. A bit old, and the COM object creation info is distributed across some chapters.</p>
<p>A more recent example, <a href="http://techar... |
overload print python <p>Am i able to overload the print function? and call the normal function? What i want to do is after a specific line i want print to call my print which will call the normal print and write a copy to file.</p>
<p>Also i dont know how to overload print. I dont know how to do variable length argum... | <p>For those reviewing the previously dated answers, as of version release "Python 2.6" there is a new answer to the original poster's question.</p>
<p>In Python 2.6 and up, you can disable the print statement in favor of the print function, and then override the print function with your own print function:</p>
<pre>... |
How can I put $HOME/opt/git/bin to my PATH? <p>I tried to include the following unsuccessfully to my ~/.profile:</p>
<pre><code>export PATH='$HOME/opt/git/bin'
</code></pre>
<p>It seems not to work because $git gives me nothing.
I am trying to install Git.</p>
<p>I have also tried commands <a href="http://stackoverf... | <p>You'll want to be careful with that command. It will <strong>override</strong> your $PATH.</p>
<p>You might need to put it in <code>~/.bash_profile</code> and change it to this:</p>
<pre><code>export PATH="$HOME/opt/git/bin:$PATH"
</code></pre>
|
ASP.net: What type of application/website is more suitable to Webform or MVC? <p>I have read all the post regarding the pro and con of ASP.net webform vs mvc.</p>
<p>However, I'm wondering under what circumstance does one use webform or mvc? would it come down to what you or your team is more familiar with?</p>
| <p>Typical business application with lots of controls, their behavior rules, with enabling/disabling them in response to the events fired by other controls would be a lot more complicated task with MVC while with WebForms you can do it during a coffee-pause.</p>
<p>Also with MVC you get nice SEO-friendly urls out of t... |
Growing Amazon EBS Volume sizes <p>I'm quite impressed with Amazon's EC2 and EBS services. I wanted to know if it is possible to grow an EBS Volume.</p>
<p>For example: If I have a 50 GB volume and I start to run out of space, can I bump it up to 100 GB when required?</p>
| <p>You can grow the storage, but it can't be done on the fly. You'll need to take a snapshot of the current block, add a new, larger block and re-attach your snapshot.</p>
<p>There's a simple walkthrough <a href="http://blog.edoceo.com/2009/02/amazon-ebs-how-to-grow-storage.html">here</a> based on using <a href="http:... |
Printing window with GtkTreeView in C? <p>I have some reports in my application that are represented as window with GtkTreeView widget reading data from GtkListStore model. These reports are much like Excel tables with usual stuff: column names, some header and footer text, maybe small image, ...</p>
<p>What should I ... | <p>That should be possible with <a href="http://cairographics.org/" rel="nofollow">libCairo</a>, it supports many <a href="http://cairographics.org/backends/" rel="nofollow">backends</a> such as Windows GDI, PostScript and PDF.</p>
<p>Sure, that doesn't spawn a printing dialog but that should not be very complicated i... |
List of HTML Helpers you use <p>I have found Html Helpers extremely useful to simplify view pages code. </p>
<p>Apart from the ones included in the latest release of Asp.Net Mvc which one do you use? </p>
<p>How much you can reuse them in different projects and are they linked only to html
generation or did you ... | <p>Check out <a href="http://www.codeplex.com/MVCContrib" rel="nofollow">MvcContrib</a>.<a href="http://lunaverse.wordpress.com/2008/11/24/mvcfluenthtml-fluent-html-interface-for-ms-mvc/" rel="nofollow">FluentHtml</a>.</p>
|
Speed up Rails App on development env.? <p>I have <em>huge</em> Rails app on development right now, which run <em>VERY</em> slow on -e development. I use Mongrel as web server. Is there any way to speed up a little bit everything? Because i have to wait 3-10 sec. to reload a page. Thanks. </p>
| <p>This is the answer to all of your woes:</p>
<p><a href="https://github.com/thedarkone/rails-dev-boost">https://github.com/thedarkone/rails-dev-boost</a></p>
|
Making HTML content expand to fill the window <p>I have an HTML page divided vertically into</p>
<ul>
<li>Header</li>
<li>Body</li>
<li>Footer</li>
</ul>
<p>The body in turn is divided horizontally into</p>
<ul>
<li>A large DIV on the left surrounded by scrollbars, displaying a portion of a diagram</li>
<li>A form o... | <p>Using the height: 100% CSS attribute should make it work.</p>
<p>See if <a href="http://www.dave-woods.co.uk/?p=144">Dave Woods 100% Height Layout Using CSS</a> works for you.</p>
|
Microsoft Visual Studio (2008) - Filters in the Solution Explorer <p>In the Solution Explorer when working with C++ projects there is the standard filters of Header Files, Resource Files, and Source Files. What I'm wanting to accomplish is essentially Filters by folder.</p>
<p><hr /></p>
<p>Lets say the structure of ... | <p>You are free to manually create folders yourself and move the files around. I agree this is a much more convenient way to arrange files but AFAIK there is no way to make VS do this automatically.</p>
|
How to dynamically change the number of columns in an SSRS body <p>In SQL Server Reporting Services (SSRS), the number of columns on a page for a report is set in the Report Properties (this is not the same as the number of field columns which vary with the data).<br />
By default this is set one, but it could be two o... | <p>What you can do is to define several custom rendering options in rsreportserver.config:</p>
<pre><code><Render>
<Extension Name="PDF (1 column)"
Type="Microsoft.ReportingServices.Rendering.ImageRenderer.PdfReport,
Microsoft.ReportingServices.ImageRendering"/>
<Ov... |
Load an assembly in parent folder - probing? <p>I'm developing a class library that uses a very simple plugin structure - to simple to start creating new appdomains for each plugin. This is the folder structure:</p>
<pre><code>Bin
Modules
Plugins.dll
Main.dll
Library.dll
</code></pre>
<p>During r... | <p>When constructing you new app domains what are you setting as the ApplicationBase and the PrivateBinPath?
Simply keeping the application base as "Bin" and putting Modules as the PrivateBinPath should be sufficient but not knowing how you are doing it I can't give you a definite answer.</p>
<p>As an aside is there a... |
Where Is The Recommended Place To Store Instance Variables For Layouts <p>If you have a layout that has in a menu which gets its menu items from a database. Where is the recommended place in a Rails application to place that call and assigns it to the instance variable that the layout uses?</p>
<pre><code>1. @menuitem... | <p>Yes, you can define and set this as a <code>before_filter</code> in your application controller. All your controllers will call that before filter. It's not all that uncommon to set global instance variables this way.</p>
<p>An alternative is to use a memoization method in application controller and set is as a hel... |
Strange char* compile error? <p>Anything wrong with my code below? I got the compile error!</p>
<pre><code>typedef unsigned char BYTE;
void foo(char* & p)
{
return;
}
int main()
{
BYTE * buffer;
// error C2664: 'foo' : cannot convert parameter 1 from 'char *' to 'char *&'
foo ((char*)buffer);
retur... | <p>When you cast the <code>BYTE*</code> to <code>char*</code> a unnamed temporary entity is created with the type <code>char*</code>. The function you call takes a reference to a <code>char*</code> but you can't take a reference to such a temporary entity because it is not a real variable.</p>
|
Writing XSS Filter for (X)HTML Based on White List <p>I need to implement a simple and efficient XSS Filter in C++ for <a href="http://cppcms.sourceforge.net" rel="nofollow">CppCMS</a>. I can't use existing high quality filters
written in PHP because because it is high performance framework that uses C++.</p>
<p>The b... | <p>You can take a look at the Anti Samy project, trying to accomplish the same thing. It's Java and .NET though.</p>
<ul>
<li><a href="http://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project#.NET_version" rel="nofollow">http://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project#.NET_version</a></li>
<li><a ... |
Do people provide multiple mechanisms for doing the same thing in an API? <p>Is it confusing to design an API with multiple ways of achieving the same outcome? For example, I have my own <code>Date</code> library (which is a simple wrapper around the Java <code>Date</code>/<code>Calendar</code> classes to distinguish a... | <p>I've been doing academic research for the past 10 years on different issues that have to do with API usability in Java.</p>
<p>I can tell you that the statement about having one way to do things in Java is fairly incorrect. There are often <em>many</em> ways to do the same thing in Java. And unfortunately, they are... |
Customizing UIAlertView <p>Anyone have code to make this:</p>
<p><img src="http://booleanmagic.com/uploads/UIAlertViewHack.png" alt="UIAlertViewHack"></p>
<p>or better yet, a 3x2 grid of buttons with images using the UIAlertView object?</p>
<p>I don't care about the textfield, it's the buttons in a grid I want (pref... | <p>I think your best bet is to forget customizing UIAlert view and build a custom view yourself.</p>
<p>For one, what you're showing really isn't an "alert" so it's counter to what UIAlertView is designed to be for. This means that you're changing the UI paradigm on the user which is never a good idea.</p>
<p>Second,... |
Testing a sweeper with RSpec in Rails <p>I want to make sure my sweeper is being called as appropriate so I tried adding something like this:</p>
<pre><code>it "should clear the cache" do
@foo = Foo.new(@create_params)
Foo.should_receive(:new).with(@create_params).and_return(@foo)
FooSweeper.should_receive... | <p>As you already mentioned caching has to be enabled in the environment for this to work. If it's disabled then my example below will fail. It's probably a good idea to temporarily enable this at runtime for your caching specs.</p>
<p>'after_save' is an instance method. You setup an expectation for a class method, wh... |
Why will this function using CURL work for some URLs but not others? <p>I'm writing a website in PHP that aggregates data from various other websites. I have a function 'returnPageSource' that takes a URL and returns the html from that URL as a string.</p>
<pre><code>function returnPageSource($url){
$ch = curl_init()... | <p>You should use <a href="http://www.php.net/curl_error"><code>curl_error()</code></a> to check which error has occurred (if any)</p>
|
asp.net textbox onley remembers initial value <p>In my Page_Load I set the text equal to a value e.g. txtNote.text="note text ex"</p>
<p>If I change that text on my actual form to something else, then try to write my new value to a db ... the textNote.text is still "note text ex" what it was set to in the Page_Load...... | <p>Take your assignment into IsPostBack control like that : </p>
<pre><code>if (!IsPostBack)
{
txtNote.Text="note text ex";
}
</code></pre>
|
Help me implement Blackjack in Python (updated) <p>I am in the process of writing a blackjack code for python, and i was hoping someone would be able to tell me how to make it:</p>
<ol>
<li>Recognize what someone has typed i.e. "Hit" or "Stand" and react accordingly.</li>
<li>Calculate what the player's score is and w... | <p>This can get you started:</p>
<p><a href="http://docs.python.org/library/random.html">http://docs.python.org/library/random.html</a></p>
<p><a href="http://docs.python.org/library/strings.html">http://docs.python.org/library/strings.html</a></p>
<p><a href="http://docs.python.org/library/stdtypes.html">http://doc... |
What are your recommended Windows Server 2003 Backup Tools? <p>What tools do you guys recommend for backing up files and SQL Server databases on Windows 2003?</p>
<p>I'm looking for tools to run daily backups of both files and SQL Server databases. Compress them up and stick them on NAS drives.</p>
<p>I'm looking for... | <p>Here at my company I do the following.</p>
<p>At the end of the day I take a full back-up, using a SQL Server job. The syntax for this is well documented in BOL however here is an example:</p>
<pre><code> BACKUP DATABASE [DATABASE]
TO DISK = '[PATH]\[DATABASE].BAK'
WITH INIT;
</code></pre>
<p>I then ex... |
Which group messaging technology to use? <p>I feel a little bit kind of confused â for about 24 hours I have been thinking which group broadcasting technology to use in my project.</p>
<p>Basically, what I need is:</p>
<ul>
<li>create groups (by some backend process)</li>
<li>broadcast messages by any client (1:N, ... | <p>Yurii,</p>
<p>RabbitMQ, Haxe and as3: <a href="http://geekrelief.wordpress.com/2008/12/15/hxamqp-amqp-with-haxe/" rel="nofollow">http://geekrelief.wordpress.com/2008/12/15/hxamqp-amqp-with-haxe/</a></p>
<p>RabbitMQ, Ruby and ACLs: <a href="http://pastie.org/pastes/368315" rel="nofollow">http://pastie.org/pastes/36... |
Anybody written a tool for static analysis of an ASP.NET MVC application? <p>Has anyone written a tool to do static analysis of an ASP.NET MVC application?</p>
<p>Disclaimer: I'm not sure what I want really is <a href="http://en.wikipedia.org/wiki/Static_code_analysis" rel="nofollow">static analysis</a> - it just was ... | <p>In order to test routes you can use <a href="http://www.codeplex.com/MVCContrib" rel="nofollow">MvcContrib</a>. It contains many various cool features and route debugging handler is one of them. And at the moment this is all what I saw. It will be rather hard to create a good tool to show all information that you de... |
ASP.NET page events - Button click event comes after GridView bind <p>My understanding of the order of page events is this:</p>
<blockquote>
<p>Page : Load</p>
<p>Control : DataBind (for a GridView or whatever)</p>
<p>Control : Load</p>
<p>Control : Clicked (for a Button)</p>
<p>Page: PreRender</... | <p>The answer was in the Button Click event, after the data has been changed, call DataBind() on the page to cause the GridView (and anything else that needs it) to rebind. I didn't realise you could do that.</p>
<p>Thank you Ocdecio & Mufasa - I would mark your answers as helpful, but I got no rep yet.</p>
|
Android - How Do I Set A Preference In Code <p>I have an Android application in which I have my preferences in a xml file, which works fine. I've now want to set one of the preferences using code instead of displaying the entire preference screen, how would I go about doing this?</p>
| <p>I assume by preferences you are referring to your application's preferences and not Android phone settings.</p>
<p>To store preferences between runs of you application you need to do the following</p>
<ol>
<li><p>Create a SharedPreferences object</p>
<pre><code>SharedPreferences settings = getSharedPreferences(St... |
Using the context of the 'this' keyword with jQuery <p>As a jQuery neophyte I am somewhat confused by the different contexts in which the <strong><em>this</em></strong> keyword is used. Sometimes it refers to a DOM element e.g. <em>this.id</em> and sometimes it refers to a jQuery object e.g. <em>$(this).val()</em>.</p... | <p>Remy Sharp's post is confusing if you don't read it carefully, in my opinion. The meaning of <code>this</code> never changes. In the example you gave, there were 2 uses of <code>this</code>. As a DOM element in an event:</p>
<pre><code>$('a').click(function() {
alert(this.tagName);
});
</code></pre>
<p>and wra... |
What obscure syntax ruined your day? <p>When have you run into syntax that might be dated, never used or just plain obfuscated that you couldn't understand for the life of you.</p>
<p>For example, I never knew that comma is an actual operator in C. So when I saw the code</p>
<pre><code>if(Foo(), Bar())
</code></pre>... | <p>C++'s syntax for a default constructor on a local variable. At first I wrote the following. </p>
<pre><code>Student student(); // error
Student student("foo"); // compiles
</code></pre>
<p>This lead me to about an hour of reading through a cryptic C++ error message. Eventually a non-C++ newbie dropped by, lau... |
How to implement drag and drop in Flex Grid control? <p>I have a simple Grid control with some buttons that I want to be able to move around. The code below does work, but it takes a lot of effort to actually do the drag&drop and it is not clear where the drop will happen. I have to move the mouse around a lot to g... | <p>It looks like each empty grid item only exists on the border you've defined (I'm not sure why this is, possibly it's a known feature of containers). If you add a backgroundColor to each GridItem then dragEnter will be triggered over the whole area rather than just that border.</p>
|
ASP.Net MVC: "The given key was not present in the dictionary" <p>I have a set of websites built in MVC - each, essentially, is a clone of one original site). On one of the sites I'm getting the error from the title of this post ("The given key was not present in the dictionary") - it only occurs on a single page. The ... | <p>Ok, so the problem was not where I was expecting it to be. If I had a dollar for every time <em>that</em> happened...</p>
<p>Basically, the problem was located in the view that was throwing the error. There was a data item which was present in the other websites but not this one. I guess this type of problem is whe... |
In Java, Prevent a field from being changed after being returned by instance method <p>In a software development class at my university, the teacher kept mentioning that on a quiz we needed to make sure that a field returned by a getter needed to be "protected." I guess she meant that nothing outside the class should ... | <p>You either use a collection and wrap it in Collections.unmodifiable*() or you defensively copy your array, collection or object if its <strong>mutable</strong> (which arrays always are).</p>
<p>For example:</p>
<pre><code>class Foo {
private String[] bar = <some array contents>;
public String[] getB... |
Sending and receiving data over USB port <p>I'd like to send/receive data over a USB port to a device (from my vista pc). Is there a free/cheap library out there that can do this, and how involved would this project be (not taking into account what's being sent or received) ?</p>
| <p>You don't specify what's going on here. Does the device already exist? Is it already a USB device?</p>
<p>If you already have a USB device, then the manufacturer should be able to help.</p>
<p>If you are building the device, then you might want to look at something like a USB to serial adapter (which generally req... |
Git hook to send email notification on repo changes <p>How do I configure the appropriate Git hook to send a summary email whenever a set of changes is pushed to the upstream repository?</p>
| <p>Another, more modern way to do this is with <a href="http://git.kernel.org/cgit/git/git.git/tree/contrib/hooks/multimail/README?id=HEAD" rel="nofollow">git-multimail</a>, as suggested by <a href="http://stackoverflow.com/questions/552360/git-push-email-notification/552362?noredirect=1#comment29250514_552362">Chords<... |
Could not load file or assembly error <p>Can anyone help me figure out what the problem is. I am trying to start up a C# winformsa app in visual studio and i keep getting this error:</p>
<p><strong>Could not load file or assembly, Foo.dll version1.93343 or one of its dependencies
The system can't find the file specif... | <p>Typically it's about one of your references' reference, possibly deep down in the dependency tree. What I usually do is, fire up Sysinternals Process Monitor (<a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx">http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx</a>), filter by process ... |
Need to generate a image in ASP.Net through webservice <p>For my new asp.net application that I am developing I would like to generate an image at runtime using a webservice (return bytes), and show this as a image using Javascript (so that I can have ajax functionality.</p>
<p>Any ideas how to do this?</p>
<p>Or any... | <p>Instead of having the web service put an ASHX page with the querystring parameters handling the input params.
Make sure the Response.Content type is image/png </p>
<p>This ASHX page will generates the image stream on the fly and send it to the requesting image object. With this there is no image file saved on the ... |
Why are some programs written in C++ windows-only and others are not? <p>That's something I've been wondering for a while now.</p>
<p>Take Notepad++ for instace. Wikipedia tells me it was written in C++ and it's Windows-only.</p>
<p>Now take PHP. Wikipedia tells me this is also written in C++, but that runs on other ... | <p>It depends whether you are using platform specific libraries or not. Notepad++ is a desktop application and it needs a GUI toolkit. Although there are cross-platform C++ libraries like Qt and wxWidgets, Notepad++ is probably using a Microsoft's specific technology. Thus it can't be ported in other platforms.</p>
<p... |
winforms application guidelines <p>I want to start creating an application that has a menu on the left(some items in a tree) and I want to open different pages on the right on the form when I click these items. Could anybody guide me in doing this correctly pls? I dont want to have tons of data in memory and just displ... | <p>One approach is to have treeview <a href="https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-6165908.html" rel="nofollow">docked</a> on the left and a panel docked to fill. Then, on the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treeview.selectednodec... |
How best to work with the Expires header in ASP.NET MVC? <p>I want to be able to set a long expires time for certain items that a user downloads via GET request.</p>
<p>I want to say 'this is good for 10 minutes' (i.e. I want to set an Expires header for +10 minutes). The requests are fragments of HTML that are being ... | <ol>
<li><p>No, you don't <em>have</em> to use this method. However, I think it is probably the best method to choose, because it makes the controller more testable and less web-aware. The alternative would be to set the header manually in the Controller, like this:</p>
<p>Response.AddHeader("Expires", "Thu, 01 Dec 19... |
How to gain control over the construction of a WebService <p>I'd like to gain control over the construction of a WebService instance in ASP.NET.</p>
<p>This is what I did so far: I created a .ASMX file and pointed it to a Class with WebServiceBinding and WebMethod attributes attached to it as usual. At the time I brow... | <p>You could write a custom handler (.ashx) and do it manually that way.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms227675(VS.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms227675(VS.85).aspx</a></p>
|
Pushing a server by Git? <p>I have tried the following command unsuccessfully:</p>
<pre><code>git push 12.12.12.123:/proj.git master
</code></pre>
<p>It asks my password, but each time it rejects it.</p>
<p>I used the following commands to set up Git:</p>
<pre><code>git --bare update-server-info
chmod a+x hooks/pos... | <p>you need to do git init in your repo</p>
<p><a href="http://www.kernel.org/pub/software/scm/git/docs/git-init.html" rel="nofollow">http://www.kernel.org/pub/software/scm/git/docs/git-init.html</a></p>
<p>Here is nice and quick tuturial:
<a href="http://toolmantim.com/articles/setting_up_a_new_remote_git_repository... |
What do you think about the new Debian release cycle? <p>I was surprised to know that Lenny already promoted to "stable" - among some of my clients there is some fear that Debian would want to compete with Ubuntu for the desktop and forget its server devotion.</p>
<p>"Only" 2 years between 4.0 Etch and 5.0 Lenny is un... | <p>Where's the problem? Etch will be supported for one year from now, and upgrading it to Lenny is a matter of typing a few commands.</p>
<p>Debian seems still to be the most serious server distro. <a href="http://www.ubuntu.com/community/ubuntustory/debian" rel="nofollow">It's the rock that Ubuntu is built on</a>.</p... |
Can a perceptron be used to detect hand-written digits? <p>Let's say I have a small bitmap which contains a single digit (0..9) in hand writing.</p>
<p>Is it possible to detect the digit using a (two-layered) perceptron?</p>
<p>Are there other possibilities to detect single digits from bitmaps besides using neural ne... | <p>Here is a link to a huge database of handwritten digits. The front page also has relative performance data for many different methods including 2 layer Neural networks. This ought to give you a good start:
<a href="http://yann.lecun.com/exdb/mnist/" rel="nofollow">MNIST digits database and performance</a></p>
<p>Yo... |
Flex DateChooser: how to override the 'today' date? <p>By default, the Flex DateChooser highlights the 'today' date. I assume it gets this date from the OS. Is there a way to tell DateChooser what the 'today' date should be? </p>
| <p>By looking at the source code of <code>mx.controls.CalendarLayout</code> (which is used internally by <code>DateChooser</code>):</p>
<pre><code>// Determine whether this month contains today.
var today:Date = new Date();
var currentMonthContainsToday:Boolean = (today.getFullYear() == newYear && today.getMon... |
Disable IE script debugging via IE control <p>Bleh; Knowing how to ask the question is always the hardest so I explain a little more.</p>
<p>I'm using CAxWindow to create an IE window internally and passing in the URL via the string class argument:</p>
<pre><code>CAxWindow wnd;
m_hwndWebBrowser = wnd.Create(m_hWnd, r... | <p>Would it be possible to just wrap everything in a try / catch in the javascript code that is being displayed in the CAxWindow at that URL? That would allow you to squelch all the errors, hopefully.</p>
|
How do I build an object that stores pictures? <p>If you were building an object to store a photo (for a program like photoshop) how would you design it? What properties would you take into account?</p>
| <p>One of the major things I would consider is whether the photo actually needs to be stored in the object, or whether you just need a link to a file, URL or database. Photos tend to use a lot of memory, so keeping it out of memory until you actually need to display it is probably good design.</p>
<p>Apart from that, ... |
Is there any way to send a mail from within my iPhone application? <p>I want to send an email from within my iPhone application, primarily because i don't want to quit my application. Is there ANY way to do that? </p>
<p>Solution:</p>
<p>1) I found this open source API which does that:
<a href="http://code.google.com... | <ul>
<li>Install <a href="http://subversion.tigris.org/getting.html#osx" rel="nofollow">subversion</a> on your Mac, as well as the command line tools, there are a variety of GUI wrappers available with a a little Googling.</li>
<li>If you click the "source" tab on <a href="http://code.google.com/p/skpsmtpmessage/" rel=... |
Updating WPF list when item changes <p>I have a WPF ListBox, and I've added some 'FooBar' objects as items (by code).
FooBars aren't WPF objects, just dumb class with an overwritten ToString() function.</p>
<p>Now, when I change a property which influences the ToString, I'd like to get the ListBox to update.</p>
<ol>... | <p>Your type should implement <code>INotifyPropertyChanged</code> so that a collection can detect the changes. As Sam says, pass <code>string.Empty</code> as the argument.</p>
<p>You <em>also</em> need to have the <code>ListBox</code>'s data source be a collection that provides change notification. This is done via ... |
Directly query TFS Warehouse using T-sql <p>Hi I'm wondering if anybody has had any experience querying a Team Foundation Server store to retrieve current work item information. It is my understanding that the information I require is stored in the TFSWarehouse Database.</p>
<p>I'm well aware that there are APIs that ... | <p>If you have access to the SQL database that hosts TFS, you can write a query that pulls this information out.</p>
<p>The database you want to look at is TFSWarehouse.
Below is a query that gets Work Item general information.</p>
<pre><code>select System_Id as WorkItemId, System_Title as Title,
System_State as Stat... |
event is not defined in mozilla firefox for javascript function? <pre><code>function onlyNumeric() {
if (event.keyCode < 48 || event.keyCode > 57) {
event.returnValue = false;
}
}
onkeypress=onlyNumneric();
</code></pre>
<p>In IE, this code is working fine. However, in Mozilla Firefox, the ... | <p>In FF/Mozilla the event is passed to your event handler as a parameter. Use something like the following to get around the missing event argument in IE.</p>
<pre><code> function onlyNumeric(e)
{
if (!e) {
e = window.event;
}
...
}
</code></pre>
<p>You'll find that there are some other di... |
Delphi: How to calculate the SHA hash of a large file <p>Hi I need to generate a SHA over a 5 Gig file</p>
<p>Do you know of a non string based Delphi library that can do this ?</p>
| <p>You should use <a href="http://www.cityinthesky.co.uk/cryptography.html">DCPcrypt v2</a> and read your file buffered and feed the SHA hasher with the buffer until you've read the complete 5GB file.</p>
<p>If you want to know how to read a large file buffered, see my answer <a href="http://stackoverflow.com/question... |
How do I use Windsor to inject dependencies into ActionFilterAttributes <p>Having seen how <a href="http://codeclimber.net.nz/archive/2009/02/10/how-to-use-ninject-to-inject-dependencies-into-asp.net-mvc.aspx">NInject can do it</a> and <a href="http://www.jeremyskinner.co.uk/2008/11/08/dependency-injection-with-aspnet-... | <p>When I needed this, I built upon the work others have done with Ninject and Windsor to get <a href="http://weblogs.asp.net/psteele/archive/2009/11/04/using-windsor-to-inject-dependencies-into-asp-net-mvc-actionfilters.aspx">property injection dependencies on my ActionFilters</a>.</p>
|
Most efficient collection for this kind of LILO? <p>I am programming a list of recent network messages communicated to/from a client. Basically I just want a list that stores up to X number of my message objects. Once the list reaches the desired size, the oldest (first) item in the list should be removed. The colle... | <p>You want to use a <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Queue.html" rel="nofollow">Queue</a>.</p>
|
Mutual exclusion: is this safe? <p>Is this pattern for mutual exclusion as safe as I think it is? If so, what do you call it?</p>
<pre><code>lock (_lock) {
if (_flag) return;
else _flag = true;
}
try {
//critical code...
}
finally {
_flag = false;
}
</code></pre>
<p>I want to ensure the critical secti... | <p>No, that is not safe. If you want to ensure mutually exclusive without blocking, you can use Monitor.TryEnter:</p>
<pre><code>if (Monitor.TryEnter(lockObj, 0)) {
// got the lock !
try {
// code
}
finally { // release the lock
Monitor.Exit(lockObj);
}
}
</code></pre>
|
How to create duplicate allowed attributes <p>I'm using a custom attribute inherited from an attribute class. I'm using it like this:</p>
<pre><code> [MyCustomAttribute("CONTROL")]
[MyCustomAttribute("ALT")]
[MyCustomAttribute("SHIFT")]
[MyCustomAttribute("D")]
public void setColor()
{
}
</code></p... | <p>Stick a <code>AttributeUsage</code> attribute onto your Attribute class (yep, that's mouthful) and set <code>AllowMultiple</code> to <code>true</code>:</p>
<pre><code>[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public sealed class MyCustomAttribute: Attribute
</code></pre>
|
How can I securely destroy some data using sql server 2008 ? (using DoD secure wipe or an equivalent) <p>One of my clients wants me to perform a periodic "real" destruction of some of his old data, and I'm evaluating the best way to do it.</p>
<p>The data is in a table, and I want to destroy some of the rows contained... | <p>Use some form of encryption to store the data fields in the table.</p>
<p>When you decide to "delete", re-encrypt the data you will continue to use with a new key. Discard the old key, and delete the rows encrypted with the old key. Shrink.</p>
<p>Even if someone recovers the rows, w/o the old key no one will be a... |
Read Jena OntModel with Dependencies <p>I'm new to the concept of ontology and Jena, so I'm not sure I'm phrasing this correctly..</p>
<p>I need to read a series of connected owl files (by namespace dependencies?) into an in memory Jena model (OntModel?) so inference can be run. How do I do this? Does the order of t... | <p>This is what I did. It seems to work</p>
<pre><code> OntModel model = ModelFactory.createOntologyModel();
for (OwlFile referencedOntology: referencedOntologyList) {
model.getDocumentManager().addAltEntry( referencedOntology.getNamespace(), referencedOntology.getURI());
}
model.read(ontology.... |
intercepting keypresses even when the form does not have focus <p>I've built a winforms application which checks for CTR+ALT+S and CTRL+ALT+E keypresses, using by overriding the ProcessCmdKey method. This works great, but if the screensaver goes on and then goes off the form doesn't have focus and the keypresses aren... | <p>Alexander Werner has a "<a href="http://www.codeproject.com/KB/miscctrl/systemhotkey.aspx" rel="nofollow">System Hotkey Component</a>" project over at Code Project that wraps the RegisterHotkey() API into a user control that's really easy to implement.</p>
|
Debugging the Interwoven Worksite Web Services <p><strong><em>EDIT:</strong> Web Services being called from a windows console application at present, using VB.Net and Visual Studio 2008</em></p>
<p>We are using the Interwoven Worksite Web Services and are having issues debugging them. The web service is returning the... | <p>Yes - have used it and have had same issue. usually with that error you are not providing the full and/or correct moniker info, e.g. wrong dms name, wrong object id. I used fiddler to view the info being passed to/fro on the base worksite web product to see how they format those same IDs which helped alot. I hope th... |
MySql moving differences? <p>Suppose I have this code</p>
<pre><code>create temporary table somedata (a integer);
insert into somedata (a) values (11), (25), (62); --#these values are always increasing
select * from somedata;
</code></pre>
<p>giving this</p>
<pre><code>+--+
|a |
+--+
|11|
|25|
|62|
+--+
</code></pre... | <p>It would easier if you had an auto_increment column to give each row its own id - then you could join the table against itself on (alias2.id=alias1.id+1) and calculate the diff from alias2.a-alias1.a</p>
<p>As it is, I think the only way is with a subquery to obtain the largest value a less than the current row val... |
How do I declare a method using Func<T, TResult> as input argument? <p>Hy,</p>
<p>I'm writing a class which should help me in unit tests. The class offers methods to perform Assertions on Exceptions. </p>
<p>Until now I was able to write methods which take a function with no parameters and no return value as input. T... | <p>You should "declare" T and TResult as well, e.g.</p>
<pre><code>public static void Throws<T, TResult, TException>(Func<T, TResult> methodToExecute, T methodArgument) where TException : System.Exception
</code></pre>
<p>otherwise the compiler does not know what T and TResult are.</p>
|
uiwebview (mobilesafari) with static header <p>I've tried numerous methods to get a static header on a UIWebView so that it only scrolls the content below a html header. Has anyone successfully accomplished this?</p>
| <p>If this needs to work only on the phone, you could just place two UIWebViews, one above the other. Display the header in one, and the content in another.</p>
|
How to get the actual size-on-disk of a file from PowerShell? <p>I am writing an administrative script, and I need to calculate the size of files on disk. </p>
<p>These files are on a compressed NTFS volume.</p>
<p>I can't use <code>FileInfo.Length</code>, because that is file size and not size on disk. For example... | <p>(edit)</p>
<p>I figured out how to dynamically add a property (called a "script property") to the Fileobject, so now, I can use the syntax: $theFileObject.CompressedSize to read the size.</p>
<p>(end of edit)</p>
<p>Read Goyuix's response, and I thought "Cool, but isn't there some kind of type-extension capabilit... |
How to know what type is a var? <p>TypeInfo(Type) returns the info about the specified type, is there any way to know the typeinfo of a var?</p>
<pre><code>var
S: string;
Instance: IObjectType;
Obj: TDBGrid;
Info: PTypeInfo;
begin
Info:= TypeInfo(S);
Info:= TypeInfo(Instance);
Info:= TypeInfo(Obj);
end
<... | <p>No.</p>
<p>First, there's no such thing as a "non-instantiated variable." You instantiate it by the mere act of typing its name and type into your source file.</p>
<p>Second, you already know all there is to know about a variable by looking at it in your source code. The variable <em>ceases to exist</em> once your... |
Merge properties into a ResourceBundle from System.getProperties() <p>I'm building a ResourceBundle from a file, this bundle holds < String, String> values.</p>
<pre><code>InputStream in = getClass().getResourceAsStream("SQL.properties");
properties = new PropertyResourceBundle(in);
in.close();
</code></pre>
<p>I ... | <p>This does some of what you want (converts the System.properties to a ResourceBundle). Better error handling is left up to you :-)</p>
<pre>
public static ResourceBundle createBundle()
{
final ResourceBundle bundle;
final Properties properties;
final CharArrayWriter charWri... |
NHibernate - map same entity to different tables within the same database <p>Lets say we have an Employee entity composed of a few other entities, such as a one-to-many addresses and contacts, and a few fields (name, age, etc). We mapped this entity out and can use it just fine, saving each piece out into "Employee", "... | <p>The easiest way would be to have addresses and contacts mapped as composite elements. That way you could map your collection differently for <code>Employee</code> and for <code>EmployeeInput</code> since the mapping is owned by the container.</p>
<p>For example:</p>
<pre><code>public class Employee
{
public Li... |
Find PHP Orphan Page <p>I've inherited a PHP application that has "versions" of pages (viewacct.php, viewacct2.php, viewacct_rcw.php, etc). I want to discover which of these pages are called from other pages in the application and which are not. Is there a tool available that will help with that?</p>
| <p>Using whatever tools you would like (Find/Grep/Sed on Linux, I use Visual Studio on windows), it is just a matter of crawling your source tree for references of the filenames in each file.</p>
|
Any mnemonic tip for boolean? <p>I guess this is trivial for most of good<sup>1</sup> programmers, but I'm so used to programming using <code>true</code> and <code>false</code><sup>2</sup> that when I encounter 0 and 1, I can never remember which one means true and which one means false. </p>
<p>Any suggestions?</p>
... | <p>The mnemonic is "how much truth is in this?" Zero integer means zero truth. Anything else is nonzero truth. :)</p>
|
SQL Server 2005 - Blocked Process Report <p>I need to investigate a series of blocks and deadlocks that have been occurring randomly on our SQL 2008 server. I am the main developer on the site and do not have a DBA to lean on...</p>
<p>I am planning on using the Blocked Process Report in 2005 and enabling a trace.</p>... | <p>use <a href="http://weblogs.sqlteam.com/mladenp/archive/2008/07/18/Immediate-deadlock-notifications-without-changing-existing-code.aspx" rel="nofollow">Event Notification</a> method. it works in 2005 and 2008. it doesn't present any perf problem for detecting deadlocks</p>
|
Running Cocoa app under otest causes dyld_misaligned_stack_error in Release mode <p>I have a problem which I have been struggling with for a while.</p>
<p>I have a Cocoa library which acts as a wrapper for a C++ library. C++ library is tested using a set of BOOST unit tests. The tests run normally under both debug and... | <p>Try adding flag "-mstackrealign" in C flags in the release version.</p>
<blockquote>
<p>-mstackrealign</p>
<p>Realign the stack at entry. On the Intel x86, the -mstackrealign
option will generate an alternate prologue/epilogue that realigns
the runtime stack. This supports mixing legacy codes that keep... |
iPhone use of mutexes with asynchronous URL requests <p>My iPhone client has a lot of involvement with asynchronous requests, a lot of the time consistently modifying static collections of dictionaries or arrays. As a result, it's common for me to see larger data structures which take longer to retrieve from a server w... | <p>There are several ways to do this. The simplest in your case would probably be to use the @synchronized directive. This will allow you to create a mutex on the fly using an arbitrary object as the lock.</p>
<pre><code>@synchronized(sStaticData) {
// Do something with sStaticData
}
</code></pre>
<p>Another way ... |
How to detect which Space the user is on in Mac OS X Leopard? <p>Mac OS X Leopard has a virtual desktop implementation called <a href="http://www.apple.com/macosx/features/spaces.html" rel="nofollow">Spaces</a>. I want to <strong>programatically detect which space the user is currently on</strong>.</p>
<p><strong>Coc... | <p>Use HIWindowGetCGWindowID to get the CGWindowID for your WindowRef.</p>
<p>Use that ID with CGWindowListCreateDescriptionFromArray from CGWindow.h to get information on your window. </p>
<p>Look at the returned dictionary and extract the (optional) kCGWindowWorkspace key. That is your space ID for your window.</p>... |
Objective-C 2.0 and Fast Enumeration throwing exceptions <p>I have a block of code which is similar to the following:</p>
<pre><code>for (NSDictionary *tmp in aCollection) {
if ([[bar valueForKey:@"id"] isEqualToString:[tmp valueForKey:@"id"]])
{
break;
}
else
{
[aCollection addObject:bar];
... | <p>Well the way to solve it is not to mutate the array (e.g. add an object) while enumerating it :)</p>
<p>The problem here is that modifying the array by adding/removing elements could cause the enumeration values to become invalid, hence why it's a problem.</p>
<p>In your case The easiest way to solve this is fixin... |
Many-to-many relationship with surrogate key in Entity Framework <p>Entity Framework magically interprets the following table structure as a many-to-many relationship.</p>
<pre><code>table foo (int id)
table foo_bar (int foo_id, int bar_id)
table bar (int id)
</code></pre>
<p>But if the join table has any additional ... | <p>it's possible, but it requires quite a bit of manual work in the EDMX file, and I haven't been able to make EF use the surrogate key as actual primary key on the link table. You have to make EF use a combination key of both foo_id and bar_id as primary key.</p>
<p>in your storage model you have to change the Entit... |
XML compare tool that can "Tidy" the XML and ignore differences in attributes <p>I am looking at using <strong>Beyond Compare 3</strong> with <em>XML Tidy</em> compare comparison format. <em>XML Tidy</em> formats all the nodes with <strong>proper line breaks and indentation</strong> if an XML file is all slopped onto ... | <p>An XSLT identity transform that omits the attributes and sets the output to indent should work:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes" />
<xsl:template match="/">
<... |
Workaround for some WPF features that are missing in Silverlight <p>Iâm porting a WPF app to silverlight 2, and have come across several WPF features which are presently missing from SL. Could anyone help me with equivalents or suggest workarounds.</p>
<ol>
<li><p>I want to handle clicks and double clicks on a textb... | <p>I'm more familiar with Silverlight than the full WPF. Please considier my responses accordingly.</p>
<p>For number 2. For many keys, I check on KeyUp and KeyDown. I use KeyDown while trying to watch the entire time that the key is held down and KeyUp when it was used just once. You should know this was for a gam... |
jQueries equivalent to YAHOO.util.Event.addListener <p>Does jQuery have an equivalent method to YAHOO.util.Event.addListener ?</p>
| <p>Yes.</p>
<p>Check out <a href="http://docs.jquery.com/Events/bind#typedatafn" rel="nofollow">bind</a>. You can do something like</p>
<pre><code>$("#elementID").bind("click", function(e) {
// whatever you want
});
</code></pre>
<p>or you can call <a href="http://docs.jquery.com/Events/click#fn" rel="nofollow"... |
How do I secure my JsonResult GET calls? <p>I know how to use MVC's AntiForgeryToken attribute and it's associated HTML helper to help XSRF-secure my application's form POSTs.</p>
<p>Can something similar can be done for JsonResults that implement GET?</p>
<p>For instance, my View contains an onSubmit jQuery call lik... | <p>You may use the AntiForgeryToken combined with some custom logic. The creation of the AntiForgery token on the server is the same, but by default the value is not included in your XmlHttpRequest.</p>
<p>The value of this token is in the HTTP only cookie "__RequestVerificationToken" and should also be in the form da... |
How to search a git repository history to find a merge error? <p>At some point in our past branches of development in git were merged. However, the wrong merge decision was made and therefore some code didn't make it into master branch that we expected would be there. (There were multiple merges of different branche... | <p>Can <a href="http://www.kernel.org/pub/software/scm/git/docs/git-bisect.html" rel="nofollow">git-bisect</a> help in your case?</p>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.