input
stringlengths
51
42.3k
output
stringlengths
18
55k
How to rollback a transaction in Entity Framework <pre><code>string[] usersToAdd = new string[] { "asd", "asdert", "gasdff6" }; using (Entities context = new Entities()) { foreach (string user in usersToAdd) { context.AddToUsers(new User { Name = user }); } try { context.SaveChanges(...
<p>OK</p> <p>I created a sample a application like the example from the the question and afterwords I checked in the DB and no users were added.</p> <p><strong>Conclusion: ObjectContext.SaveChange it's automatically a transaction.</strong></p> <p><strong>Note:</strong> I believe transactions will be needed if execut...
Powershell in SSIS <p>What would I need to do in order to run a PowerShell script in an SSIS package? </p> <p>Does PowerShell need to be installed on the SQL server? How do I actually call the script in SSIS?</p> <p>Thanks</p>
<p>Yes, PowerShell needs to be installed. Then, you can use an <a href="http://msdn.microsoft.com/en-us/library/ms141166.aspx">Execute Process Task</a> to point to the PowerShell executable and give the script as an argument.</p> <p>Like so:</p> <pre><code>Executable: %windir%\system32\WindowsPowerShell\v1.0\powershe...
Assign array of pointers to array <p>If I have an array of char pointers and another static array of characters, how do I assign each element of the array of pointers to each element of a static array? </p> <p>(Trying to break down a problem into a smaller problem.)</p> <p>Thanks.</p> <pre><code> array of pointer...
<p>I am improvising Tomi's answer here.<br /> The others are too long for such a question.</p> <pre><code>char chrArr[] = "asd"; char* ptrArr[sizeof(chrArr)]; int i; // A simple assignment loop over 'i' pointers and chars for (i=0; i&lt; sizeof(chrArr); i++) ptrArr[i] = &amp;chrArr[i]; --------- ----------...
Implementing NHibernate Unit Test to Generate Schema with VB.NET/MBUnit <p>I'm trying to implement unit tests for my NHibernate data access layer. The first test, which I drew from an example I found on the web (http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/04/01/your-first-nhibernate-based-application.as...
<p>The section declares the name of an assembly containing class declarations and mapping files. The mapping files contain the metadata for the mapping of the POCO class to a database table (or multiple tables).</p> <p>On the other hand you've got</p> <pre><code>cfg.AddAssembly(GetType(Todd.Core.Product).Assembly) <...
Close popup window if it exists <p>With some javascript I openup a popup no prob using:</p> <pre><code>function myPopup2(x){ if (x==1) { myWindow = window.open( "timer.html", "", "height = 150, width = 300" ); }else { myWindow.close(); } } </code></pre> <p>I then run some PHP scrip...
<p>If you give your window a name when you open it, it is possible to get a handle to the window later. </p> <pre><code>function myPopup2(x){ if (x==1) { myWindow = window.open( "timer.html", "windowName", "height = 150, width = 300" ); }else { if (!myWindow) { myWindow = w...
Optimizing a Cocoa/Objective-C search <p>I'm performing a search of a large plist file which contains dictionaries, tens of thousands of them, each with 2 key/string pairs. My search algorithms goes through the dictionaries, and when it finds a text match in either of the strings in the dictionary, the contents of the ...
<p>Without looking at the data set I can't be sure, but if you profile it you are spending the vast percentage of your time in -rangeOfString:options:. If that is the case you will not be able to improve performance without fundamentally changing the data structure you are using to store your data.</p> <p>You might wa...
Silverstripe on souceforge project web <p>how do I install silverstripe on sourceforge for a project. I know I need a synlink...but I don't know how to? </p> <p>I have a htdocs folder that is read only (once on the server) that I can access via sftp <br> it is accsesable via url</p> <p>I have a persistent folder...
<p>So you're trying to install SilverStripe on sourceforge? Well, okay.</p> <p>I guess you need to check that the MySQL user you're using has write access to the database. Also, that you got the database name right in the installation process: if you didn't, the installer will try to create that database, and if you d...
Simulate Photoshop's saturation changes in Imagemagick <p>In Photoshop you can adjust the hue, saturation and lightness of an image with three sliders. ImageMagick you can <a href="http://www.imagemagick.org/Usage/color/#modulate" rel="nofollow">modulate</a> the brightness, saturation, and hue.</p> <p>Minimizing the s...
<p>Could it be that they each use slightly different RGB colour models? From the names of the attributes they use (lightness and brightness), it certainly seems that;</p> <ul> <li>Photoshop = HSL (hue, saturation, luminence) </li> <li>ImageMagik = HSV (hue, saturation, value)</li> </ul> <p>Check out this Wikiepedia ...
J @ not working as expected <p>I'm just starting to try to pick up the J language, and am confused by the following:</p> <pre><code> 1 2 +/@{ i.4 1 2 +/ 1 2 { i.4 3 </code></pre> <p>when in the documentation for @ it says: "x u@v y ↔ u x v y"</p> <p>I assume I'm just mistaking one part of speech for another, ...
<pre> NB. <strong>u</strong> b. 0 <em>returns the rank of</em> <strong>u</strong> NB. <em>the rank of a verb determines the arguments it applies to at a time</em> NB. <em>monadic</em> <strong>+</strong> y <em>applies to atoms; dyadic</em> x <strong>+</strong> y <em>applies to pairs of atoms</em> + b. 0 0 0 ...
Does my development environment mirror user's environment? <p>I am trying to get a better idea on this as so far I have had mixed answers in person.</p> <p>I am a solo dev in a 5 man IT dept for a Health Care related business. My developer machine is running Win 7 RC1 (x64) but my users are all running Win XP Pro (x8...
<p>Your development environment doesn't need to mirror your user's environment, but your testing environment certainly should!</p> <p>Having a VM of the users image for testing would probably be good enough.</p>
Is referencing and calling methods via strings in PHP a bad idea? <p>I've always worry about calling methods by referencing them via strings.</p> <p>Basically in my current scenario, I use static data mapper methods to create and return an array of data model objects (eg. SomeDataMapper::getAll(1234)). Models follow t...
<p>This is essentially a version of the factory pattern - Using strings to create a object instance.</p> <p>However, I question the design idea of using an iterator to control the paging of data - that's not really the purpose of an iterator. Unless we just have name confusion, but I'd probably prefer to see somethin...
.NET Compiler Output <p>I'm attempting to resolve source problems and I'm attempting to figure out which version is which. The other problem I'm running into is the output the .NET compiler generates is very unintelligible and a little frustrating. In my bin folder i have the following assemblies:</p> <pre><code>Aja...
<p>Your best bet is to do a few things.</p> <ol> <li>Make sure that the project is a web application, the compiling is much cleaner that way.</li> <li>When you PUBLISH the site, delete all existing files, and re-publish the whole thing. This way you can ensure that the most current DLL's are the only ones out there.<...
Can I have multiple security contexts with spring security? <p>I have one security context definition that uses PreAuthenticatedProcessingFilterEntryPoint for the flex part of my application. How can I have another definition that will use standard form login with html forms for another part of my application? Here's w...
<p>It has been tricky to do until recently, but now it is easy!</p> <p>Spring Security has added support for the scenario in version 3.1. It is currently available as a Release Candidate, implemented by <a href="https://jira.springsource.org/browse/SEC-1171">SEC-1171</a>. Details of the syntax are in the manual includ...
How to query for map element in hibernate? <p>I have a hibernate mapping which looks like this:</p> <pre><code>&lt;hibernate-mapping&gt; &lt;class name="MutableEvent" table="events" mutable="true" dynamic-insert="true" dynamic-update="true"&gt; &lt;id name="id"&gt; &lt;generator class=...
<p>Try creating alias for the criteria. </p> <pre><code>criteria.createAlias( "attributes", "as" ); criteria.add( Restrictions.ilike( "as.other", new Variant("aValue") ); </code></pre>
Create a transparent div over a td or tr element <p>I have a table and I would like to be able to set up a transparent div over the entire row to show that it is inaccessible at the moment.</p> <p>Here is my a row from my table:</p> <pre><code>&lt;tr id="post_1998"&gt; &lt;td id="post_1998_image"&gt; ...content......
<p>You want to use the z-index value in CSS. Make the transparent divs using appropriate CCSS code which you will find easily with a Google search, and then set the z-index on that div to a higher value (say 20 - a random choice). This places the div over the other content.</p> <p>You need two different settings for d...
Quickly determining if a set of files are identical in C#? <p>I have the need to relatively quickly be able to determine if a set of files on a user's machine has been processed before by my application. The app in question uploads the files for the user to a server, and if the files have been uploaded before, it skips...
<p>I probably wouldn't put the dictionary into the app.config file, although I guess you could, depending on the server information. I'd probably just put it in a text file on its own unless you found that to be more of a problem for some reason. It feels like it's more data <em>for</em> the application than configurat...
How can I write custom Exceptions? <p>How can I create a new <code>Exception</code> different from the pre-made types?</p> <pre><code>public class InvalidBankFeeAmountException extends Exception{ public InvalidBankFeeAmountException(String message){ super(message); } } </code></pre> <p>It will show t...
<p>All you need to do is create a new <code>class</code> and have it <code>extend Exception</code>.</p> <p>If you want an <code>Exception</code> that is unchecked, you need to <code>extend RuntimeException</code>.</p> <p><strong>Note</strong>: A checked <code>Exception</code> is one that requires you to either surrou...
Getting the data in Flex pop up window at run time <p>I am creating a project in Flex. </p> <p>I have a main page from which i open a popup window on button click. i this pop up window to display my data which i am getting from my Http request in my response() as rawdata. I did broke this data into array. </p> <p>I c...
<p>You might want to use a framework like PureMVC or Cairngorm for separation of model and view. You want some non-UI actionscript code to be managing the requests and (if necessary) caching of the data. This way you can display the data in any view you like. Difficult to illustrate in a simple response, but check out ...
Application startup flags in Windows Forms? <p>Is there a way for a Windows Forms application to detect if any flags have been added to the command/shortcut used to launch it? Like if I wanted to go "app.exe /flag", can I get the "/flag" somewhere programatically?</p>
<p>You can use <a href="http://msdn.microsoft.com/en-us/library/system.environment.getcommandlineargs.aspx" rel="nofollow">Environment.GetCommandLineArgs()</a> to get an array of the arguments passed into your program.</p>
Version Control for Local Website (XAMPP) <p>I am working on a shopping cart which is installed locally via xampp.</p> <p>The files are stored in:</p> <p>D:/xampp/htdocs/cart</p> <p>Now I would like to start making coding changes and design changes, but I need to keep a track of what changes i make so that I can go ...
<p>Depends on your needs, but for a single user project you probably will be happy with <a href="http://tortoisesvn.net/downloads">TortoiseSVN</a> for Windows. It comes with shell integration and is relatively easy to use.</p>
ASP.NET MVC Routing with a controller named "PropertiesController" <p>I'm having a tricky issue (bear with me as I'm new to MVC) with trying to use a controller (and a route subsequently) with the name PropertiesController.</p> <p>I believe this is because there is a directory (which I can't really remove) called "Pro...
<p>Since someone else is having the same problem, I'm guessing that you're running into a reserved keyword here (I imagine ClassControllers are out as well).</p> <p>It's not the first time it's happened either - digging deeper into the internals of the environment, <a href="http://stackoverflow.com/questions/987105/as...
JavaScript function in href vs. onclick <p>I want to run a simple JavaScript function on a click without any redirection.</p> <p>Is there any difference or benefit between putting the JavaScript call in the <code>href</code> attribute (like this: </p> <pre><code>&lt;a href="javascript:my_function();window.print();"&...
<p><strong>bad:</strong> </p> <pre><code>&lt;a id="myLink" href="javascript:MyFunction();"&gt;link text&lt;/a&gt; </code></pre> <p><strong>good:</strong> </p> <pre><code>&lt;a id="myLink" href="#" onclick="MyFunction();"&gt;link text&lt;/a&gt; </code></pre> <p><strong>better:</strong> </p> <pre><code>&lt;a id="myL...
How does HTTP Adaptive Bitrate Streaming work on the iPhone? <p>Apple has included HTTP Adaptive Bitrate Streaming in the iPhone OS 3.0, in particular Safari handles this automatically.</p> <p>I'd like to play with this in a low cost manner, but I expect it'll require a custom HTTP server in the worst case, and intere...
<h3>Update</h3> <p>Looks like Apple made an IETF draft proposal, and some people are already working on segmenters:</p> <p>HTTP Live Streaming - draft-pantos-http-live-streaming-01<br> <a href="http://tools.ietf.org/id/draft-pantos-http-live-streaming-01.txt">http://tools.ietf.org/id/draft-pantos-http-live-streaming-...
Are there any methods in .NET BCL which take `ref` parameters? <p><code>TryParse</code> family of methods uses <code>out</code> parameters; I could give <code>Swap</code> as an example of <code>ref</code> parameters being useful, but are there good examples in the .NET Base Class Library?</p>
<p>There are quite a few just in mscorlib. Run this to find them, and give it types in different assemblies to show others.</p> <pre><code>using System; using System.Linq; class Test { static void Main() { ShowRefsInAssemblyContaining(typeof(string)); } static void ShowRefsInAssemblyConta...
.Net XML Serialization and Escaped or Encoded characters <p>I'm using XML Serialization heavily in a web service (the contracts pass complex types as params). Recently I noticed that the .Net XML Serialization engine is escaping some of the well known 5 reserved characters that must be escaped when included within an e...
<p>According to the <a href="http://www.w3.org/TR/2008/REC-xml-20081126/#syntax" rel="nofollow">XML spec</a>, for regular content and markup:</p> <ul> <li><code>&amp;</code> always needs to be escaped as <code>&amp;amp;</code> because it's the escape character</li> <li><code>&lt;</code> always needs to be escaped as <...
Reload django wsgi scripts without root <p>I have an install of django on apache using embedded wsgi. I DON'T have root on the machine. </p> <p>How can I tell apache to reload the python instance when I deploy new source code?</p> <p>I tried removing all the .pyc files and it still is running the old code.</p>
<p>If you are running mod_wsgi in daemon mode with apache, you may not have to restart apache to get it to reload.</p> <p>I just touch my wsgi file (unix: touch updates the 'saved date' of a file) and apache reloads it on next access/web-hit.</p> <p>See <a href="http://code.google.com/p/modwsgi/wiki/QuickConfiguratio...
Set a CSS class on an ASP.NET RadioButtonList ListItem <p>Is there any way to set a CSS class on an input item in a radio button list? I'd like to reference these form values by class in jQuery.</p> <p>Given an ASP.NET RadioButtonList with classes set on the ListItems:</p> <pre><code> &lt;asp:RadioButtonList ID="Radi...
<p>Yes, RadioButtonList renders horrible HTML.</p> <p>Anyway, it's still easy to get them from jQuery. </p> <p>Try</p> <pre><code>$('span.myclass input:radio') </code></pre> <p>Above will get all the radio buttons inside the span with class 'myclass'. </p>
Why do multiple threads eat my memory <p>I have a Windows C++ application that holds a <code>std::hash_set</code> containing abount 5 Million entries each with 32 Bytes. If i create the hash_set in a separate (of many) threads it uses > 1 GB according to ProcessExplorer. I see this when i free the list. If i create it ...
<p>The data structure ultimately allocates from the heap, and it's the same heap regardless of the thread. Making heap calls from a different thread is not going to affect the amount of memory allocated. Either your tools are lying to you, or you're allocating the <code>hash_set</code> on several other threads by accid...
How to save current state of OFFSET in SQL <p>I have 1000 rows of data but need to only display 100 rows at a time. I would like navigation buttons (like on google next, prev) to go thought the groups of 100 </p> <p>My C cgi application runs and exits every new query, so it can't save states.</p> <p>Question is: Wha...
<p>Very confusing way to ask this, but... </p> <p>Your 'page' has 100 items, so simply pass a GET variable to the next page ?page=1 Then you use OFFSET = page * 100</p>
Single Autonumber Instead of Multiple Key <p>Is there a reason to use a single incrementing field for a primary key instead of multiple fields that actually represent the unique record? </p> <p>I'm working on an existing php application, and the tables all seem to have a single 'id' key instead of using the 2 or more ...
<p>It depends on the definition of "Unique". Yes, names, email addresses, and SSN values are supposed to be "unique". However, stranger things have happened. Having a separate ID value, in a lot of cases, can make life a lot easier...</p> <p><strong>Update</strong></p> <p>Based on the edit to the question, I don't...
Call Google Translate from Python <p>I want to execute <a href="http://code.google.com/apis/ajaxlanguage/documentation/translate.html" rel="nofollow">this script (view source)</a> that uses Google Translate AJAX API from python, and be able to pass arguments and get the answer back. I don't care about the HTML.</p> <...
<p>You can use the RESTful API instead. It's designed for environments that are not Javascript.</p> <p><a href="http://code.google.com/apis/ajaxlanguage/documentation/reference.html#_intro_fonje" rel="nofollow">http://code.google.com/apis/ajaxlanguage/documentation/reference.html#_intro_fonje</a></p> <p>That should b...
How do I use MySQL C++ Connector for storing binary data? <p>I have a block of binary data defined as:</p> <p>void* address, size_t binarySize;</p> <p>that I want to store to a MySQL database using MySQL C++ Connector.</p> <p>The function setBlob() takes istream.</p> <p><strong>The question:</strong></p> <p>How ca...
<p>You have to subclass streambuf e.g. like this:</p> <pre><code>class DataBuf : public streambuf { public: DataBuf(char * d, size_t s) { setg(d, d, d + s); } }; </code></pre> <p>Then you can instantiate an istream object which uses a DataBuf as buffer, which itself uses your block of binary data. Supposi...
Position of Google Analytics code <p>The Google Analytics setup instructions state:</p> <blockquote> <p>This tracking code snippet should be included in your site's pages so that it appears at the bottom of the page's HTML (or generated-HTML) structure, before the closing &lt;body&gt; tag.</p> </blockquote> ...
<p>It's just to improve page load performance. If this code were at the beginning, then if for some reason the analytics code ran slowly, the rest of the page would wait for it to finish or timeout before loading.</p> <p>The analytics code likely makes queries to Google's servers, so they have to wait for the servers...
Is the primary key automatically indexed in MySQL? <p>Do you need to explicitly create an index, or is it implicit when defining the primary key? Is the answer the same for MyISAM and InnoDB?</p>
<p>The primary key is always indexed. This is the same for MyISAM and InnoDB, and is generally true for all storage engines that at all supports indices.</p>
Calling aspnet Membership ResetPassword stored procedure <p>I would like to call the aspnet Membership ResetPassword stored procedure called: <code>aspnet_Membership_ResetPassword</code> within the <code>aspnetdb</code> database.</p> <p>When I look at the <code>SqlMembershipProvider</code> class there is a ResetPasswo...
<p>If you are using Encryption mode to store the password it will be better to use ChangePassword Method like the following:</p> <pre><code>_MembershipUser.ChangePassword(_MembershipUser.GetPassword(),"NewP@ssw0rd"); </code></pre>
What is the easiest way to turn a mysql result variable into a multidimensional array in php? <p>What is the easiest way to turn a mysql result variable into a multidimensional array in php?</p> <p>Thanks</p>
<p>Run <a href="http://us3.php.net/mysql_fetch_assoc" rel="nofollow"> mysql_fetch_assoc </a> in a loop. </p> <pre><code>while ($row = mysql_fetch_assoc($result)) { $table[] = $row; } print_r($table); </code></pre>
JQuery Copy text & paste into textarea <p>I've created a javascript function that will take a hidden span, copy the text within that span and insert it into a single textarea tag on a website. I've written a function in JavaScript that does this (well, kinda, only after a few clicks), but I know there's a better way - ...
<p>Based on the comment in your question, I am assuming you have something like this in your HTML:</p> <pre><code>&lt;a href="#" onclick="repost_submit(5);"&gt;copy post&lt;/a&gt; </code></pre> <p>And I am also assuming that because you are passing a post ID there can be more than one per page.</p> <p>Part of the be...
Retrying an operation after an exception: Please criticize my code <p>My Perl application uses resources that become temporarily unavailable at times, causing exceptions using <code>die</code>. Most notably, it accesses SQLite databases that are shared by multiple threads and with other applications using through <code...
<p>I'd probably be inclined to write retry like this:</p> <pre><code>sub _retry { my ( $retrys, $func ) = @_; attempt: { my $result; # if it works, return the result return $result if eval { $result = $func-&gt;(); 1 }; # nah, it failed, if failure reason is not a lock, croak cr...
Is it possible in Google Earth to embed HTTP text/HTML output into a Placemark's balloon description area? <p>I'm displaying KML placemark data in Google Earth via a NetworkLink, and would like to keep the size of the KML down by not including the description text in the Placemarks' KML definitions. Instead, I would li...
<p>you could try putting iframe there:</p> <pre><code> &lt;iframe src="...."&gt;&lt;/iframe&gt; </code></pre> <p>i am not sure if google earth allows remote sources to be included via iframe as this could be a possible security problem, though.</p>
What's a good way to handle development/production libs paths with Perl? <p>With Perl, what is an easy way to handle different development versus production libs paths? I want to use my local box path for testing, but when I launch I want it to automatically point to the production lib path.</p>
<p>Take a look at the <a href="http://perldoc.perl.org/perlrun.html#PERL5LIB" rel="nofollow">PERL5LIB environment variable</a>, or for an even easier time, look at <a href="http://search.cpan.org/dist/local-lib/lib/local/lib.pm" rel="nofollow">local::lib</a>.</p>
FireFox 3.5 Fetches Image Sprite Repetitively - how to prevent? <p><strong>EDIT: Mozilla fixed the bug. This thread is dead.</strong></p> <p><strong>EDIT: This is a Mozilla bug. See this thread: <a href="https://bugzilla.mozilla.org/show%5Fbug.cgi?id=501853" rel="nofollow">https://bugzilla.mozilla.org/show%5Fbug.cgi?i...
<p>There seems to be a problem with FireFox 3.5 loading images from the server and not using the cache properly. Google "firefox 3.5 not caching images" and you will notice a lot of people noticing this problem.</p>
SQL-Like Selects in Imperative Languages <p>I'm doing some coding at work in C++, and a lot of the things that I work on involve analyzing sets of data. Very often I need to select some elements from a STL container, and very frequently I wrote code like this:</p> <pre><code>using std::vector; vector&lt; int &gt; numb...
<p>You've almost exactly described <a href="http://en.wikipedia.org/wiki/Language%5FIntegrated%5FQuery" rel="nofollow">LINQ</a>. It's a .NET 3.5 feature so you should be able to use it from C++.</p>
How to use Joda-Time with java.sql.Timestamp <p>I Have a <a href="http://docs.oracle.com/javase/tutorial/jdbc/basics/prepared.html">prepared statement</a></p> <pre><code>INSERT INTO mst(time) VALUES (?); </code></pre> <p>where time is of type <a href="http://www.postgresql.org/docs/current/static/datatype-datetime.ht...
<p>You can convert a Joda DateTime to a long (millis since the epoch) first, and then create a Timestamp from that.</p> <pre><code>DateTime dateTime = new DateTime(); Timestamp timeStamp = new Timestamp(dateTime.getMillis()); </code></pre>
How can I make system calls invoke my SIGSEGV handler when given protected memory? <p>I'm working on a memory tracking library where we use <code>mprotect</code> to remove access to most of a program's memory and a SIGSEGV handler to restore access to individual pages as the program touches them. This works great most ...
<p>You can use <a href="http://linux.die.net/man/2/ptrace" rel="nofollow"><code>ptrace(2)</code></a> to achieve this. It allows you to monitor a process and get told whenever certain events occur. For your purposes, look at <code>PTRACE_SYSCALL</code> which allows you to stop the process upon syscall entry and exit.</p...
Set Property Value on Master Page from Content Page <p>I need to pass data to a variable in my master page each time a page is loaded.</p> <p>I have a string[] of RequiredRoles that I set on each content page defining what roles are required to access that page.</p> <p>On my master page, I have a method that takes th...
<p>Add page directive to your child page:</p> <pre><code>&lt;%@ MasterType VirtualPath="~/MasterPage.master" %&gt; </code></pre> <p>Then add property to your master page:</p> <pre><code>protected static string _section = "home"; public string Section { get { return _section; } set { _section = value; } } </c...
How do I use JPQL to delete entries from a join table? <p>I have a JPA object which has a many-to-many relationship like this:</p> <pre><code>@Entity public class Role { //... @ManyToMany(fetch=FetchType.EAGER) @JoinTable( name="RolePrivilege", joinColumns= @JoinColumn(name="role", referen...
<p>The JPQL update and delete statements need to refer to an Entity name, not a table name, so I think you're out of luck with the approach you've suggested.</p> <p>Depending on your JPA provider, you could delete the entries from the JoinTable using a simple raw SQL statement (should be 100% portable) and then progra...
how to create a singleton asmx service <p>how can i create an singleton asmx webservice ? (please don't say use WCF and WWF :D )</p>
<p>Short Answer: You don't want to.</p> <p>Long Answer: A request to an .ASMX is going to non deterministically use a new worker thread, so even if you used the singleton pattern, the life of the singleton will not be known.</p> <p>Perhaps elaborate on what you want to do, and I can guide you towards the best pattern...
Persistent UIBarButtonItem in UIToolbar? <p>I've been developing an iPhone app that uses a UIToolbar (in the context of a UINavigationController) to display a small status icon at the bottom of the screen. The toolbar will eventually also have action icons associated with it (think Mail application).</p> <p>I'm runnin...
<p>Instead of using the navigation controller's toolbar, add one directly to the window and resize the navigation controller's view's frame to avoid it. That single global toolbar will then always be visible.</p> <p>If you're using the Navigation-based Application template, and are using Interface Builder, the follow...
Exception using CopyToDataTable with "new {..}" LINQ query <p>From this code I can call bmwCars.CopyToDataTable() as I expected.</p> <pre><code>var bmwCars = from car in dataTable.AsEnumerable() where car.Field&lt;string&gt;("Make").ToLower().Equals("bmw") select car...
<p>You could build your own <a href="http://msdn.microsoft.com/en-us/library/bb396189.aspx">CopyToDataTable</a> that takes any kind of IEnumerable(not only <code>DataRow</code>)and returns a new <code>DataTable</code>:</p> <pre><code>// following would not compile by default // because input is not an IEnumerable&lt;D...
Using Facebook Connect with Authlogic <p>I am trying to make Authlogic and Facebook Connect (using Facebook) play nice so that you can create an account either the normal registration way or with Facebook connect. I have been able to get the connect to work one way but logging out only loggs out on facebook and not on ...
<p>Here's an example app I made using the Facebook Connect extension, authlogic and Open ID. It still needs some work, but it does function.</p> <p><a href="http://big-glow-mama.heroku.com/" rel="nofollow">http://big-glow-mama.heroku.com/</a></p> <p><a href="http://github.com/holden/authlogic%5Fopenid%5Fselector%5Fe...
How do I get more warnings from javac? <p>I want the Java compiler to give me the highest level of warnings possible. Currently I compile with -Xlint. Is there anyway for me to get more warnings? The warnings provided by Xlint seem paltry.</p> <p>I just compiled this code with -Xlint and got no warnings:</p> <pre><co...
<p>There are no way to get this warning in <code>javac</code>. Alternatively, use <a href="http://findbugs.sourceforge.net/" rel="nofollow">FindBug</a> -- it can check this type of pattern.</p>
convert code snippet to C# <p>VS 2008 </p> <p>I have this code snippet I found on a VB website.</p> <p>But for some reason I am having trouble converting it to C#.</p> <pre><code>My.Computer.Network.IsAvailable </code></pre> <p>Many thanks,</p>
<pre><code>using System.Net.NetworkInformation; internal class Program { private static void Main() { NetworkInterface.GetIsNetworkAvailable(); } } </code></pre>
Saving profile with registration in Django-Registration <p>In Django-Registration it says you can save a custom profile when you save a user.<br> But I have no idea what the documentation is asking me to do. Here is what they say:</p> <blockquote> <p>To enable creation of a custom user profile along with the <code>...
<p>You can pass the callback function in your urls.py file. </p> <pre><code>from mysite.profile.models import UserProfile url( r'^accounts/register/$', 'registration.views.register', { 'profile_callback': UserProfile.objects.create }, name = 'registration_register' ), </code></pre> <p>Substitute your o...
Is there a .Net analog of the functionality provided by java.lang.instrument? <p>I have looked at a few of the well-known AOP-oriented frameworks for .Net such as PostSharp, bltoolkit, Castle, Cecil, and Policy Injection Block from Microsoft. Perhaps I am ignorant, but it appears that these frameworks do not provide t...
<p>You are correct that most of the AOP frameworks for .NET requires you to create objects using a special kind of factory or the like. The reason for this is that (custom) attributes in .NET are passive, so you need some kind of framework that can inspect those attributes in a timely fashion.</p> <p>There are a few A...
Converting XSLT 1.0 to XSLT 2.0 <p>I have a XSLT 1.0 file to transform a XML file using XSLT 1.0. It works fine with IE 6.0, Firefox 3.0.11. However, PHP 5.2.6 XSL XSLTProcessor (providing XSLT 1.0) and Qt C++ QXmlQuery (providing only XSLT 2.0) give blank output.</p> <p>I'm thinking of 2 ways:</p> <ol> <li><p>Conver...
<p>XSLT should be pretty much backward compatibly, although obviously there are things you can use in XSLT 2.0 that make life much easier.</p> <p>It sounds like you have something wrong in your XSLT, but as you don't provide anything for us to look at it is hard to say.</p> <p>I would recommend getting hold of Kernow...
How should I use transparent pngs in IE 6 over a background-repeat? <p>The code below has a repeating background image "thinline.png". On top of that are 4 layered transparent PNGs: cardshadow.png, steel.png, startjobapplicationshadow.png and startapplication.png</p> <p>My goal is to make this code look good in IE6 wi...
<p>Take a look at <a href="http://dean.edwards.name/IE7/" rel="nofollow">IE7</a> by Dean Edwards. It's a javascript library for Internet Explorer 6 that makes transparent pngs work correctly, as well as fixing css bugs and adding support for additional css features. I've used this library in the past with some success ...
COM MFC ATL worth studying? <p>Is it worth studying COM MFC ATL WTL now?</p>
<p>Everything is worth studying:</p> <p><em>Those who forget history are doomed to repeat it</em></p> <p><em>You must understand the past to understand the present</em></p> <p>Should you spend a majority of your time on it? Only if you expect that you will have to work with it. Otherwise, focus on the future.</p>
The Microsoft.VisualStudio.Data.Interop.IVsDataProviderManager service could not be found <p>I'm using VS2008 to develop an app. Now, whenever I connect to database in Server Explorer, it shows me the report </p> <blockquote> <p>The Microsoft.VisualStudio.Data.Interop.IVsDataProviderManager service could not be ...
<p>Just goto start -> Run -> type devenv /ResetSkipPkgs</p> <p>This solved my problem.</p> <p>Happy Programming....................</p> <p>Mohan</p>
Delphi TClientSocket replacement using winsock2 and IOCP? <p>Is there such a thing? It needs to be asynchronous (no Indy).</p>
<p>Try HPScktSrvr - <a href="http://www.torry.net/pages.php?id=220#939383" rel="nofollow">http://www.torry.net/pages.php?id=220#939383</a></p>
Learning Python for a .NET developer <p>I have been doing active development in C# for several years now. I primarily build enterprise application and in house frameworks on the .NET stack.</p> <p>I've never had the need to use any other mainstream high level languages besides C# for my tasks, since .NET is the stand...
<p>Foord and Muirhead's <a href="http://www.manning.com/foord/">IronPython in Action</a> is an amazingly good book, perfectly suitable for teaching Python to .NET folks as well as teaching .NET to Python folks. I may be biased, as I was a tech reviewer and Foord is a friend, but I've had other cases in the past where a...
WinVerifyTrust to check for a specific signature? <p>I'm implementing a process elevation helper for Windows. It's a program that will run in elevated mode and launch other programs with administrator privileges without displaying additional UAC prompts. For security reasons, I want to make sure only binaries that are ...
<p>I believe what you're looking for is <a href="http://msdn.microsoft.com/en-us/library/aa380264%28VS.85%29.aspx">CryptQueryObject</a>.</p> <p>With it you should be able to pull the involved certificate out of a PE, and do any additional checks you want.</p> <p><hr /></p> <p>By way of example, this will get you to ...
iPhone build lite and full versions - adMob problem <p>I'm traing to build a lite version for my app the way it is described in this post: <a href="http://stackoverflow.com/questions/549462/how-do-i-manage-building-a-lite-vs-paid-version-of-an-iphone-app">http://stackoverflow.com/questions/549462/how-do-i-manage-buildi...
<p>have you checked that the AdMob library is marked as belonging to both the Lite and Full versions?</p> <p>(click on library, get info, look on "targets" tab)</p>
WCF for REST <p>Is wcf a viable REST solution? It prevents you from using some special characters like # so requesting tag/c# does not work. is there a work around, is this by design?</p>
<p>It is -- check out the <a href="http://msdn.microsoft.com/en-us/netframework/cc950529.aspx" rel="nofollow">REST starter kit</a>.</p>
iPhone - Why does the documentation say UIImageView is NSCoding compliant? <p>Ideally an NSCoding compliant class will work as expected using encodeWithCoder: and initWithCoder: (at least I thought so till recently) without the developer having to bother about what goes on inside the routines (unless my idea of an NSCo...
<p>The documentation is misleading -- <code>UIImage</code> does not conform to <code>NSCoding</code> as you've stated. You can work around it (in a primitive way) by doing the work yourself:</p> <pre><code>@interface UIImage (NSCoding) - (id)initWithCoder:(NSCoder *)decoder; - (void)encodeWithCoder:(NSCoder *)encoder;...
Refresh problem when treeview node changed <p>I have a Treeview in a masterpage and a products page in child page.</p> <p>When i click treeview node i want to bind data to a gridview on the product page.</p> <pre><code>protected void trvCategoryTab_SelectedNodeChanged(object sender, EventArgs e) { if (trvC...
<p>It sounds like you want to use AJAX.</p>
Screen-to-World coordinate conversion in OpenGLES an easy task? <p><strong>The Screen-to-world problem on the iPhon</strong>e<br></p> <p>I have a 3D model (CUBE) rendered in an EAGLView and I want to be able to detect when I am touching the center of a given face (From any orientation angle) of the cube. Sounds pretty...
<p>You can now find <strong>gluUnProject</strong> in <a href="http://code.google.com/p/iphone-glu/">http://code.google.com/p/iphone-glu/</a>. I've no association with the iphone-glu project and haven't tried it yet myself, just wanted to share the link.</p> <p>How would you use such a function? <a href="http://www.lor...
Synchronizing COM Threads with .NET <p>In our C# application we are making use of a thirdparty (<a href="http://www.thesycon.com/eng/home.shtml" rel="nofollow">Thesycon</a>) COM object which runs threads to write data to a scanning device from 7 files. </p> <p>I start the writing method by calling</p> <pre><code>COM....
<p>If the COM object provides no means to monitor its process, then the answer is going to be NO.</p> <p>If the COM object does provide a mechanism, then you need to use that to determine when you can perform the <code>StopWriting</code>.</p>
How can I close my file with the special condition? <p>just think that when I opened my file then when I want to write something in it ,one Exception will be thrown,and if I used file.close() in the try block ,So because of that Exception will not work, where should I close my file???</p>
<p>The proper way to do so is:</p> <pre><code>FileOutputStream out = null; try { out = ... ... out.write(...); ... out.flush(); } catch (IOException ioe) { ... } finally { if(out!=null) { try { out.close(); } catch (IOException ioe) { ... } } } </code></pre>
Should I list PDFs in my sitemap file? <p>Should I add PDFs to my XML sitemap? </p> <p>I want to know if Google will crawl the PDFs.</p>
<p>Yes, Google crawls PDFs.</p> <p>See the <a href="https://support.google.com/webmasters/answer/35287" rel="nofollow">Search Console Help article</a> for a list of file types indexed.</p>
How can I determine whether a Java class is abstract by reflection <p>I am interating through classes in a Jar file and wish to find those which are not abstract. I can solve this by instantiating the classes and trapping InstantiationException but that has a performance hit as some classes have heavy startup. I can't ...
<p>It'll have abstract as one of its modifiers when you call getModifiers() on the class object.</p> <p>This <a href="http://java.sun.com/docs/books/tutorial/reflect/class/classModifiers.html" title="link">link</a> should help.</p> <pre><code> Modifier.isAbstract( someClass.getModifiers() ); </code></pre> <p>Also:</...
user friendly framework for personal website? <p>Which are the user friendly frameworks for building personal sites? Specially if that comes with little programming knowledge. And integrated jquery will be great. python or php based framework will do better.</p> <p>I tried wordpress and joomla! But those are far more ...
<p>"a simple personal site with personal blogging, live commenting, twitting, keeping personal projects and resume etc."</p> <p>In my opinion, a personal site means a single author. You don't have a lot of really "dynamic" content. How many times a day will you update a person site? Once? Twice?</p> <p>A blog, c...
Why does unserialize in PHP keep returning false? <p>I've just written the easiest script in the world, but still I can't get it to work, and it's mighty strange. </p> <p>I want to use jQuery to catch some input field values and serialize them with jQuery's <code>serialize()</code>. I then send the serialized string t...
<p>You're using the wrong PHP function. You should use <a href="http://php.net/parse%5Fstr"><code>parse_str</code></a> instead.</p> <pre><code> parse_str($str, $unserialized); </code></pre>
"Invalid token ',' in class, struct, or interface" after checkout <p>I am having problems compiling an EPiServer Web Application after checking it out of Subversion.</p> <p>I get this error</p> <blockquote> <p>Compiler Error Message: CS1519: Invalid token ',' in class, struct, or interface member declaration</p> </...
<p>I encountered this problem as I was restructuring the dll references in a project. </p> <p>I had moved the external/third part dlls from the bin folder to a library folder outside the web project root.</p> <p>My problem was that some of the dll references did not have copy local set to true, so they were never cop...
What's the current state of ORMs? <p>Historically I've been completely against using ORMS for all but the most basics applications.</p> <p>My reasoning has and always has been that it's a very leaky abstraction ... mostly because SQL provides a very powerful way to retreive data from a relational source which usually ...
<p>Please read: <a href="http://www.codinghorror.com/blog/archives/001281.html" rel="nofollow">All Abstractions Are Failed Abstractions</a> It should put a lot of your questions in perspective.</p> <p>Performance is usually not an issue with ORM - and if you really find yourself in a situation where it is, then there ...
Window Position of a CHM file <p>I just compiled and viewed a CHM file used in my project. I noticed that the viewer remembers the window size and position across sessions.</p> <p>Where does the HTML help viewer save the window position for each CHM file? </p>
<p>These settings are stored in a file called HH.DAT. On Windows XP, this file can be found in</p> <pre><code>C:\Documents and Settings\%username%\Application Data\Microsoft\HTML Help\hh.dat </code></pre> <p>Other OS versions put it in different places. There is one such file per user profile.</p> <p>Looking at the ...
redirect 301 question <p>We just switched to our new website redesign.</p> <p>We have a copy of the previous one in a folder "v1" and the new one is in "v2". I play with 2 .htaccess files. The file are organised as such:</p> <pre><code>root L .htaccess (1) L v1 L v2 L .htaccess (2) </code></pre> <p>.htaccess ...
<p>You can just state the absolute URL path for the substitute:</p> <pre><code>RewriteRule ^pixflow/$ /projects/pixflow1/ [L,R=301] </code></pre> <p>But yours should work too.</p>
I want to use javascript to insert an attribute to an element <p>Any ideas how I would go about writing a javascript method to insert an attribute to a tag</p> <p>eg. I have</p> <pre><code>&lt;input id='in1' value='Submit' type='submit'/&gt; </code></pre> <p>and I want to insert an attribute name</p> <pre><code>&lt...
<p>Try this:</p> <pre><code>document.getElementById("in1").setAttribute("name", "submit_content"); </code></pre>
Today button in jQuery Datepicker doesn't work <p>I'm using jQueryUI Datepicker and show "Today" button. But it doesn't work. It also doesn't work in demo: <a href="http://www.jqueryui.com/demos/datepicker/#buttonbar">http://www.jqueryui.com/demos/datepicker/#buttonbar</a></p> <p>I'w want to fill input with today when...
<p>I don't like the solution of modifying the jQuery source code because it removes the ability to use a CDN. Instead, you can reassign the _gotoToday function by including this code (based on @meesterjeeves answer) somewhere in your page's JavaScript scope file:</p> <pre><code>$.datepicker._gotoToday = function(id) {...
assembly.GetExportedTypes() doesn't include WCF service <p>I use a WsdlImporter and ServiceContractGenerator to set up CodeDomProvider to get an assembly which (I thought) should allow me to create an instance of my HelloWorldService. </p> <pre><code>MetadataExchangeClient mexClient = new MetadataExchangeClient(metad...
<p>These techniques are used to create client-side classes. When you create an instance of HelloWorldServiceClient, you'll be creating an instance of the proxy class that can be used to communicate with the service.</p>
Does RandomAccessFile.close() internally call FileChannel.force()? <p>I am using RandomAccessFile to perform some writes to a file as part of a transaction. Before I commit my transaction, I want to be absolutely sure that the data is written to disk. Calling <code>force(boolean) </code> on the RAF's <code>FileChannel...
<p>This is completely FS-dependent. But if you do not get an (IO)Exception, you should trust the JVM and commit your transaction. Whether you can trust your FS is the other question. For example, if you use ext4 having delayed allocation activated, you might lose data on a instant power loss even after RandomAccessFile...
C#: Custom casting to a value type <p>Is it possible to cast a custom class to a value type?</p> <p>Here's an example:</p> <pre><code>var x = new Foo(); var y = (int) x; //Does not compile </code></pre> <p>Is it possible to make the above happen? Do I need to overload something in <code>Foo</code> ?</p>
<p>You will have to overload the cast operator.</p> <pre><code> public class Foo { public Foo( double d ) { this.X = d; } public double X { get; private set; } public static implicit operator Foo( double d ) {...
How to use Stored Procedure in Inner Joins? <p>How to use stored procedure in inner joins?</p>
<p>you can't. what you can do is rewrite your scprocs into table valued user definde functions and then join to them.</p> <p>you'll have to expand a bit on your question though.</p>
jQuery javascript array handling <p>Noobie muddling his way through an Ajax autosuggest form:</p> <p>I've got most of it working, but need to break things down a bit, so I can understand how jQuery refers to things. <strong>EDIT</strong>: This is my working code, thanks guys. Some problems with delay on the ajaxdiv, n...
<p>I think your are trying to iterate through the selection with a for loop instead of using the jQuery Core function <a href="http://docs.jquery.com/Core/each#callback" rel="nofollow">$.each()</a></p> <pre><code>$(".resultlist").children().each(function(i){ if ($(this).hasClass("selected")){ listindex = i; } ...
PyQt clipboard doesn't copy to system clipboard <p>The following snippet of code doesn't seem to affect the system clipboard at all:</p> <pre><code>clipboard = QtGui.QApplication.clipboard() clipboard.setText(text) </code></pre> <p>According to the Qt documentation, this is how you copy text to clipboard, </p> <p>Wh...
<p>I know you are not using Windows, but maybe this will give you some ideas... I used this in a PyQt program to copy URLs to the clipboard:</p> <pre><code>import win32clipboard s = 'copy this to the clipboard' try: win32clipboard.OpenClipboard() win32clipboard.EmptyClipboard() win32clipboard.SetClipboard...
ruby Open URL and rescue <p>I would like to check if a few URL's exst on my old website and collect URLS that returns 404.</p> <pre><code>@paintings = Painting.find(:all) @paintings.each do |painting| open("http://www.mydomain.com/" + painting.user.username.downcase + "/" + painting.permalink) rescue OpenURI::HTT...
<p>Looks like you've forgotten the <code>begin</code> prior to the open:</p> <pre><code> begin open("http://www.mydomain.com/" + painting.user.username.downcase + "/" + painting.permalink) rescue OpenURI::HTTPError @failure += painting.permalink else @success += painting.permalink end </code></pre>
How to make eclipse aware of OSGI bundles within a maven repository (local &| remote) <p>I have a project which is build through maven. Each module is built as an osgi bundle. </p> <p>Within Eclipse the modules have also the plugin nature. Some modules require external dependencies (log4j, apache commons, ...), which ...
<p>I didn't find anything, so I convinced my colleague to write an eclipse plugin which does exactly this. It is a provisioner which analyzes a m2 repository and pulls in the found osgi plugins from there. It is a alpha version, but you may try it and we are happy to get a response. Just write to info [at] inavare [dot...
Does anybody have any feedback on SeeBeyond / Sun's JCAPS product <p>I have a client currently thinking about using SeeBeyond / Sun's <a href="http://www.sun.com/software/javaenterprisesystem/javacaps/index.jsp" rel="nofollow">JCAPS</a> product, does anyone on SO have any positive or negative experiences using / develo...
<p>SeeBeyond/JCAPS might not have a future now that Oracle has bought Sun.</p>
Let WPF Tabcontrol height assume height of largest item? <p>Is there any way to have to tabcontrol take the size of the largest tab item (well, actually, the tabitem's content)?</p> <p>Since the tabcontrol has no specific size assigned it should autosize: it does that correctly, but when you switch tabs it automatical...
<p>Yes it can be done: <a href="http://stackoverflow.com/questions/8416674/reuse-grid-rowdefinitions-for-each-tabitem">reuse-grid-rowdefinitions-for-each-tabitem</a></p> <p>Example:</p> <pre><code> &lt;TabControl Grid.IsSharedSizeScope="True"&gt; &lt;TabItem Header="Tab 1"&gt; ...
Transformation using MovieClip.transform.matrix problem <p>I have problem when dealing with transform in Flash cs4 ....</p> <p>When I rotate my movieclip and trace the output, my movieclip's width also changed.... </p>
<p>This is a bug in flash player. There are a few things you can do:</p> <p><hr /></p> <p>Option 1 (probably the best way):</p> <p>Create a subclass of MovieClip and override the get and set methods for width and height. Have the setters call super, and store the values as private variables (eg _width/_height) When ...
How to show/hide selected object like div? <p>So i'm trying out MVC after only playing with it some time ago.</p> <p>Need to find the best way to selectively show and hide sections (divs, etc) on clicking or changing a value of a control, but not having to post back, i.e. javascript?</p> <p>Any suggestions.</p>
<p>Use <a href="http://jquery.com/" rel="nofollow">jQuery</a>. You can use a jQuery Event to detect a click and then <a href="http://docs.jquery.com/Effects/hide" rel="nofollow">hide</a> or <a href="http://docs.jquery.com/Effects/show" rel="nofollow">show</a> divs. </p> <p>So, You have a button called "HideDiv" and "D...
Is IE8 backwards compatible? <p>Hopefully some has some knowledge of this.</p> <p>I'm fast realising that IE8 certainly can't be ignored anymore. I had previously put it down to either a) just a buggy piece of software, or b) still to small a piece of the market share. Now, however, I'm seeing more and more require...
<blockquote> <p>My question is can I switch over to testing on IE8 only and safely 'believe' that the resulting code will still work on IE7?</p> </blockquote> <p>No.</p>
SetForegroundWindow problems when a modal child exists <p>I am using the Win32 API call <code>SetForegroundWindow</code> to set focus to another application's window. I am then using <code>SendKeys</code> to send keystrokes to that window.</p> <p>This works well apart from when a modal window (such as a File Open dial...
<p>See the <a href="http://msdn.microsoft.com/en-us/library/ms633507%28VS.85%29.aspx" rel="nofollow">GetLastActivePopup</a> API.</p>
How to force qmake not to create symbolic links to target when TEMPLATE=lib? <p>I have a (partial) qmake project file like this:</p> <pre><code>TEMPLATE=lib TARGET=whatever SOURCES=whatever.cpp HEADERS=whatever.h </code></pre> <p>This will - atleast by default - create a library and few symbolic links like this:</p> ...
<p>If you override the QMAKE_LN_SHLIB variable with a no-op, it will not make the symbolic links.</p> <pre><code>QMAKE_LN_SHLIB = : </code></pre>
How do I avoid compiler warnings when converting enum values to integer ones? <p>I created a class <code>CMyClass</code> whose CTor takes a <code>UCHAR</code> as argument. That argument can have the values of various enums (all guaranteed to fit into a <code>UCHAR</code>). I need to convert these values to <code>UCHAR<...
<p>I wouldn't be emabarrassed by static_cast here, but if you are:</p> <pre><code>template &lt;class T&gt; inline UCHAR ToUchar(T t) { return static_cast&lt;UCHAR&gt;(t); } </code></pre> <p>saves writing a function for every enum.</p>
Validation are dissapearing while deployment in asp.net <p>I have a asp.net validation in test box when i debug and run in vs2008 web developer edition is working fine.</p> <p>But when i display the code in the production server by copy pasting the code in web root folder its not working.</p> <p>I am developing the a...
<p>Please check the CauseValidation property of surrounding controls. Is any of them set to False by mistake.</p>
Quick way to detect if a DataContext table or view exists <p>Currently, I'm developing an application that depends on (and thus connects to) various databases via LINQ-to-SQL. For one of the databases, the connection string may vary and is thus configurable - however, the schema of this database is identical for all co...
<p>Here is an (untested) idea:</p> <p>Grab the name of your table. You can hard code it in, or you can grab it programmatically via</p> <pre><code>TableAttribute attribute = (TableAttribute)typeof(MyTableObject) .GetCustomAttributes(typeof(TableAttribute), true) ....
Serve a dynamically generated image with Django <p>How do I serve a dynamically generated image in Django? </p> <p>I have an html tag</p> <pre><code>&lt;html&gt; ... &lt;img src="images/dynamic_chart.png" /&gt; ... &lt;/html&gt; </code></pre> <p>linked up to this request handler, which creates an in-memory image...
<p>I assume you're using PIL (Python Imaging Library). You need to replace your last line with (for example, if you want to serve a PNG image):</p> <pre><code>response = HttpResponse(mimetype="image/png") img.save(response, "PNG") return response </code></pre> <p>See <a href="http://effbot.org/zone/django-pil.htm">he...
System.Text.StringBuilder limit <p>I've read that the StringBuilder type has a limit (the default is 16 characters), and when you append some text to it, beyond its limit, a new instance is created with a higher limit and the data is copied to it. I tried that using the following code :</p> <pre><code>StringBuilder te...
<p>All the fun stuff happens in this line:</p> <pre><code>IL_0014: callvirt instance class [mscorlib]System.Text.StringBuilder [mscorlib]System.Text.StringBuilder::Append(string) </code></pre> <p>This is where you make the call to the <code>Append()</code> method, but the IL you have posted does not contain the bo...
Calculate the difference between date/times in PHP <p>I have a Date object ( from Pear) and want to subtract another Date object to get the time difference in seconds.</p> <p>I have tried a few things but the first just gave me the difference in days, and the second would allow me to convert one fixed time to unix ti...
<p>Still gave somewhat wrong values but considering I have an old version of PEAR Date around, maybe it works for you or gives you an hint on how to fix :)</p> <pre><code>&lt;pre&gt; &lt;?php require "Date.php"; $now = new Date(); $target = new Date("2009-07-02 15:00:00"); //Bring target to current timezone ...
Remove UIWebView Shadow? <p>Does anyone know if its possible to remove the shadow that is placed on the UIWebView window? </p> <p>Example: <a href="http://uploadingit.com/files/1173105_olub5/shadow.png">http://uploadingit.com/files/1173105_olub5/shadow.png</a></p> <p>If its possible how do you do it?</p> <p>Thanks</...
<p>This is a cleaner alternative to "Nikolai Krill" solution. This only hides UIImageViews within the UIWebView and not the UIWebBrowserView. </p> <pre><code>for (UIView *view in [[[webView subviews] objectAtIndex:0] subviews]) { if ([view isKindOfClass:[UIImageView class]]) view.hidden = YES; } </code></pre> <...