input
stringlengths
51
42.3k
output
stringlengths
18
55k
Counting rows in SQL stament using grouping by incremnental variables <p>Table I'm trying to get analytical result from is voice calls record. Each call (one row) has duration in seconds (just int value, not datetime). I'm trying to get number of records grouped by 15 seconds spans like this:</p> <pre><code>+--------...
<p>The following query fits your needs:</p> <pre><code>SELECT (duration - duration % 15), COUNT(*) FROM call GROUP BY (duration - duration % 15) ORDER BY 1; </code></pre> <p>You can also add some string formatting, in case you need the output exactly as you described it:</p> <pre><code>SELECT (duration -...
Entity Framework: Ignore Columns <p>I have a database that I wish to build an EF model from, however I do not want to include certain columns from the database as the columns concerned are maintained exclusively on the server and should not be manipulated by any application.</p> <p>Both of the columns are DateTime (if...
<p>Can you do this with the Entity Framework? Yes; it's easy. Can you do this with the Entity Framework designer? Unfortunately, that is much harder.</p> <p>The problem you're having is that the column exists in the storage schema (SSDL) in your EDMX. Removing the column with the GUI designer simply removes it from th...
Why is p2p web hosting not widely used? <p>We can see the growth of systems using peer to peer principles. But there is an area where peer to peer is not (yet) widely used: web hosting.</p> <p>Several projects are already launched, but there is no big solution which would permit users to use and to contribute to a pee...
<p>This is what <a href="http://freenetproject.org/">Freenet</a> basically is,</p> <blockquote> <p>Freenet is free software which lets you publish and obtain information on the Internet without fear of censorship. To achieve this freedom, the network is entirely decentralized and publishers and consumers of informat...
SQLSERVER Management Objects in c++ Programming <p>How to use SQLSERVER SMO in C++(CPP) to list all the servers availabel and find databases installed using VS2003/VS2005 IDE.</p> <p>And i need some clarification in</p> <p>1)Does Vs2003 Have support for SQLSMO?? 2)Is any additional files(reference) needed to work wit...
<p>SMO (SQL Server Management Objects) was released with SQL Server 2005, and requires .NET 2.0 at least. VS 2003 only supports .NET 1.x.</p> <p>In .NET 1.x, you'll have to revert to SQL-DMO - a COM based set of components for managing SQL Server database objects.</p> <p>Marc</p>
Is there a CEIL version of MySQL's DIV operator? <p>With MySQL </p> <p><code>a DIV b</code> </p> <p>is much faster than </p> <p><code>FLOOR(a / b)</code>. </p> <p>But I need to round up so I'm using,</p> <p><code>CEIL(a / b)</code></p> <p>It seems strange that there wouldn't be a ceiling version of DIV, but I can...
<p>Alternative:</p> <p>(a + b - 1) DIV b</p>
Is it possible to customize the DisplayMember of a DataBound ComboBox? <h1>Solution</h1> <p>This is what I came up with:</p> <pre><code>Public Class IndexedDropDownItem Private _KeyCode, _Display As String Public Property KeyCode() As String Get Return _KeyCode End Get Set(...
<p>Since you are using a datatable you would need to create a new column that computes the value.</p> <p>I personally have moved to using objects to do my databinding and with it in my class I simply add another public property "ListDisplayText" that does the formatting for me.</p>
C++ functions accepting both pointers and references <p>I am writing a library in C++ and have some functions that work with modules. An example would look like this:</p> <pre><code>void connect(Module *a, Module *b); </code></pre> <p>The problem is, that it would be sometimes handy if the function accepted also refe...
<p>Why not just call the function with</p> <pre><code>connect(&amp;a, &amp;b); </code></pre> <p>like in your inline function, whenever you have to call it with references? This makes it very clear that the function takes pointers, and that <code>a</code> and <code>b</code> are not pointers. You only have to type two ...
Can't perform Create, Update or Delete operations on Table because it has no primary key <p>I've been trying to insert row in the table having an identity column RequestID (which is primary key as well)</p> <pre><code> HelpdeskLog logEntry = new HelpdeskLog { RequestBody = message.Body }; if (attachment != null...
<p>I've also had this problem come up in my C# code, and realized I'd forgotten the IsPrimaryKey designation:</p> <pre><code> [Table (Name = "MySessionEntries" )] public class SessionEntry { [Column(IsPrimaryKey=true)] // &lt;---- like this public Guid SessionId { get; set; } [Column] public ...
How to Remove an Item from the Office Orb Menu in Outlook <p>Folks,</p> <p>I've been working on ribbon development in Office 2007, but I'm running into an issue that's driving me a bit nuts. I want to remove the "Permissions" option from the Orb menu of a new mail message in Outlook 2007. I am not having any luck. I'm...
<p>ahh, it turns out I was modifying the XML in the wrong part of the schema. The correct modification would look something like:</p> <pre><code>&lt;officeMenu&gt; &lt;splitButton idMso="PermissionRestrictMenu" visible="false"/&gt; &lt;/officeMenu&gt; &lt;tabs&gt; </code></pre>
ASP.NET MVC Views don't see any classes after massive refactoring <p>My project went through a name change, which led to using ReSharper to change the name of namespaces throughout the solution. Everything compiles just fine, but my ASP.NET MVC views are no longer seeing any inherited classes. I've changed the namespac...
<p>Try cleaning your bin directory and do a rebuild. Sometimes an older dll lingers in the bin folder and mess up your references/namespacing.</p>
How do I get the next item in a subset of an ordered table using linq? <p>I have two tables:</p> <pre><code>Topic ( TopicID: int, (primary key) TopicName: varchar ); Example ( ExampleID: int, (primary key) TopicID: int, (foreign key to Topic table) ExampleOrder: int, ExampleName: varchar ); </code></pre> ...
<pre><code>int exampleID = 5; //now to write a query var query = from ex in db.Examples let prior = db.Examples.Where(ex2 =&gt; ex2.ExampleID == exampleID).First() where ex.TopicID == prior.TopicID &amp;&amp; ex.ExampleOrder &gt; prior.ExampleOrder order ex by ex.ExampleOrder descending select ex /...
Restrict file access to authorized php users <p>I've inherited an application with a glaring security hole. </p> <p>It has session-based security, but file uploads (which are user specific) are not secured in any way and they are stored in the public file tree.</p> <p>Filenames do not follow any convention as such, m...
<p>Don't really understand why moving them isn't an option, since pushing requests for them to a handler means it no longer matters where they're stored. But you're the man on the scene.</p> <p>.htaccess looks like:</p> <pre><code>RewriteEngine on RewriteRule path/to/where/these/files/live/(.*) /handlerscript.php/$1...
Mutliple criteria for single field in symfony? <p>I'm trying to define multiple criteria for a single field in symfony, but every time I define a second criterion, it overwrites the previous one. Here is an example of my code:</p> <pre><code> # build query to fetch search results $c = new Criteria(); # set minim...
<p>For the case where you have both limits, you need to do something like this:</p> <pre><code>$c = new Criteria(); $c2 = $c-&gt;getNewCriterion(HomeModelPeer::PRICE, $request-&gt;getPostParameter('price_from'), Criteria::GREATER_EQUAL); $c2-&gt;addAnd($c-&gt;getNewCriterion(HomeModelPeer::PRICE, $request-...
Problem with partial method C# 3.0 <p>Do you know the answer to following question?</p> <blockquote> <p>Let us say, it MyMethod() is declared as partial method in MyPartialClass in MyPartialClass.cs. I have also provided body of MyMethod() in MyPartialClass in MyPartialClass2.cs. I use a problem without an...
<p>You should get error CS0759. Test case:</p> <pre><code>partial class MyClass { partial void MyMethod() { Console.WriteLine("Ow"); } } partial class MyClass { partial void MyMethod2(); } </code></pre> <p>Compilation results:</p> <pre><code>Test.cs(6,18): error CS0759: No defining declarati...
What is the Windows Forms equivalent of the WPF's Keyboard class? <p>Question says it all - is there a class somewhere in Windows Forms that has the same functionality as the WPF <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.keyboard.aspx" rel="nofollow"><code>System.Windows.Input.Keyboard</code...
<p>I don't believe there is an equivalent for WinForms. The best I know of is the static ModifierKeys property on Control but that is almost certainly not what you are looking for. </p> <p>I believe you are stuck with handling the events and keeping your own state :(</p>
Get ProgID from .NET Assembly <p>I want to write a program to find all the com visible .NET classes, and their ProgIDs from a .NET assembly. What's the best way to do this?</p>
<p>This will get the ProgId rather than the ClassId, and also work if the whole assembly is marked visible:</p> <pre><code> Assembly assembly = Assembly.LoadFile("someassembly.dll"); bool defaultVisibility; object[] assemblyAttributes = assembly.GetCustomAttributes(typeof(ComVisibleAttribute),f...
Querying the DNS service records to find the hostname and TCP/IP <p>In a paper about the <strong>Life Science Identifiers</strong> (see <a href="http://www.scfbm.org/content/3/1/2" rel="nofollow">LSID Tester, a tool for testing Life Science Identifier resolution services</a>), Dr Roderic DM Page wrote : </p> <p>Given ...
<p>The JNDI DNS provider can lookup SRV records. You need to do something like:</p> <pre><code>Hashtable env = new Hashtable(); env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory"); env.put("java.naming.provider.url", "dns:"); DirContext ctx = new InitialDirContext(env); Attributes attrs = ctx...
Is there an advantage of the operating system understanding the characteristics of how a thread may be used? <p>Is there an advantage of the operating system understanding the characteristics of how a thread may be used? For example, what if there were a way in Java when creating a new thread to indicate that it would ...
<p>That's what OS processes do. The OS has sophisticated scheduling for the processes. The OS tracks I/O use and CPU use and dynamically adjusts priorities so that CPU-intensive processing doesn't interfere with I/O.</p> <p>If you want those features, use a proper OS process.</p>
Can we implement Row Lost Focus event for GridView <p>I have a Hierarchical gridview and I need implement the following functionality in the child gridview:</p> <ol> <li>Show all the rows in editable mode (this can be done)</li> <li>Save all data of each row on it's lost focus</li> </ol> <p>We can capture the mouse e...
<p>You'd probably need to implement a postback / callback when the blur event fires for the row on the client-side. I'm not exactly sure which DOM elements support the blur event in every browser but you can do it. </p> <p>The GridEX control from Janus Systems can do it, but honestly, I'd really stay clear of doing th...
How can I write Perl that doesn't look like C? <p>My co-workers complain that my Perl looks too much like C, which is natural since I program in C most of the time, and Perl just a bit. Here's my latest effort. I'm interest in Perl that is easy to understand. I'm a bit of a Perl critic, and have little tolerance for c...
<p>From years of seeing Perl code written by C programmers, here's some generic advice:</p> <p>Use hashes. Use lists. USE HASHES! USE LISTS! Use list operations (map, grep, split, join), especially for small loops. Don't use fancy list algorithms; pop, splice, push, shift and unshift are cheaper. Don't use trees...
C# or Java: Prepend strings with StringBuilder? <p>I know we can append strings using <code>StringBuilder</code>. Is there a way we can prepend strings (i.e. add strings in front of a string) using <code>StringBuilder</code> so we can keep the performance benefits that <code>StringBuilder</code> offers?</p>
<p>Using the <a href="http://msdn.microsoft.com/en-us/library/0xzfkkwa.aspx">Insert method</a> with the position parameter set to 0 would be the same as preappending.</p> <p>This goes for C#, but I am sure Java StringBuilder has a similar method.</p>
How do you automate the launching/debugging of large scale projects? <p><strong>Scenario:</strong></p> <p>There is a complex piece of software that is annoying to launch by hand. What I've done is to create a python script to launch the executable and attach <em>gdb</em> for debugging.</p> <p>The process launching sc...
<p>Instead of forwarding the signal to the debuggee from Python, you could try just ignoring it. The following worked for me:</p> <pre><code>import signal signal.signal(signal.SIGINT, signal.SIG_IGN) import subprocess cat = subprocess.Popen(['cat']) subprocess.call(['gdb', '--pid=%d' % cat.pid]) </code></pre> <p>Wi...
Which actionscript / flash framework has the best tools for simple animation <p>I'm converting some Flex down to an Actionscript project and need to get up to speed as quickly as possible on a lightweight framwork for doing basic animation.</p> <p>The components may have some very simple data access - such as reading ...
<p>I like <code>caurina</code> which is easy to use but able to handle really complex things. It can be found <a href="http://code.google.com/p/tweener/" rel="nofollow">here</a>. But the best is just to grap a few and test them yourself.</p>
How can I check if a resource bundle key does not exist using JSTL tags? <p>I have a resource file that will have some optional keys. If the optional resource key is not present, I set a default instead. It appears that there is no easy way to determine if a key exists in the resource bundle. So this is what I'm doing ...
<p>You could write your own JSP tag that does this, so you can then just do:</p> <pre><code>&lt;my:message var="title" key="${form}.title" default="default.title"/&gt; </code></pre> <p>The tag implementation could either be your current JSP syntax, or a Java class.</p>
Does GQL support commonly available SQL Style aggregation? <p>What I'm looking for a simple Aggregate Functions that are widely available in versions of SQL. </p> <p>Simple things like <code>Select Count(*) from table1</code> to the more complex.</p> <p>If these are available, is there some documentation you could p...
<p>The SQL aggregate functions are not available. What you want to do is follow patterns like the sharded counters example: <a href="http://code.google.com/appengine/articles/sharding_counters.html">http://code.google.com/appengine/articles/sharding_counters.html</a> which explain that instead of aggregating the value...
Is there any cure for the preprocessor blues? <p>I know that I can kick the the preprocessor to spit out output with the <code>-E</code> option in my particular circumstance. For generated code this preprocessor output is murderous. For example I have a 4gl application and Informix converts this into <strong>C</stron...
<p>The Eclipse <a href="http://www.eclipse.org/cdt/" rel="nofollow">CDT</a> editor does a pretty good job highlighting code based on the macros you declare to be active. You may want to check it out.<img src="http://i.stack.imgur.com/Egekv.png" alt="alt text"></p>
Customize/remove Django select box blank option <p>I'm using Django 1.0.2. I've written a ModelForm backed by a Model. This model has a ForeignKey where blank=False. When Django generates HTML for this form it creates a select box with one option for each row in the table referenced by the ForeignKey. It also creat...
<p>Haven't tested this, but based on reading Django's code <a href="http://code.djangoproject.com/browser/django/trunk/django/forms/models.py#L680">here</a> and <a href="http://code.djangoproject.com/browser/django/trunk/django/forms/models.py#L710">here</a> I believe it should work:</p> <pre><code>class ThingForm(mod...
Cancel slow-loading external scripts <p>I am dynamically adding script tags to the DOM so I can download JSON data. Occasionally something goes wrong with a download, and the script fails to load properly.</p> <p>How do I tell the browser to give up on a script that has taken too long to load? I think this is importan...
<p>I'm not sure that you can control how the browser loads a script once you've inserted it into the DOM.</p> <p>However, if you use an XMLHttpRequest to download the JSON data, you can call the <a href="https://developer.mozilla.org/en/XMLHttpRequest#abort%28%29" rel="nofollow"><code>abort</code></a> method if the re...
Is there a realtime apache/php console similar to webrick or mongrel with ruby on rails? <p>Is there a realtime apache/php console similar to webrick or mongrel with ruby on rails?</p> <p>I want to be able to monitor what the heck my server is doing.</p> <h2>edit:</h2> <p>but I don't want to grep the log</p> <p>Tha...
<p>I believe <a href="http://www.firephp.org/" rel="nofollow">FirePHP</a> might be somewhat equivalent to what your looking for. </p> <p><strong>Simple Example:</strong></p> <pre><code> &lt;?php FB::log('Log message'); FB::info('Info message'); FB::warn('Warn message'); FB::error('Error message'); ?&gt; </code><...
Google App Engine: Intro to their Data Store API for people with SQL Background? <p>Does anyone have any good information aside from the Google App Engine docs provided by Google that gives a good overview for people with MS SQL background to porting their knowledge and using Google App Engine Data Store API effectivel...
<p>Here is a good link: One to Many Join using Google App Engine.</p> <p><a href="http://blog.arbingersys.com/2008/04/google-app-engine-one-to-many-join.html" rel="nofollow">http://blog.arbingersys.com/2008/04/google-app-engine-one-to-many-join.html</a></p> <p>Here is another good link: Many to Many Join using Google...
How to enter experience design work? <p>My main area of interest in the world of programming is enhancing the user experience. I’m currently enrolled in a Information Science and Technology degree program and intend to tackle the Human-Computer Interaction focus my university offers through this major.</p> <p>So to ...
<p>As a student, you can get lots of Microsoft software for free through their Bizspark program. You may want to checkout Expression Blend which is Microsoft's product for creating rich user interfaces in Silverlight.</p>
Rendering HTML inside a DataList <p>I have a formatted text that contains Bolded, italicsed, and other styles implemented inside the message. I have this message stored in a Database. Now I want to implement these tags into work inside the a field inside the DataList. How do I do it?</p> <p>&lt;%# Eval("message") %></...
<p>If you mean that your "message" contains formatted HTML, you should simply HTMLDecode it after the DataBinder has evaluated the value of the "message" property. For example:</p> <pre><code>' "message" contains the string "&lt;b&gt;Hello World!&lt;/b&gt;" ' Within the DataList: &lt;ItemTemplate&gt; &lt;asp:Label I...
Ext region property <p>I'm studying extjs now.</p> <pre><code>new Ext.Viewport({ layout: 'border', items: [{ region: 'north', html: '&lt;h1 class="x-panel-header"&gt;Page Title&lt;/h1&gt;', autoHeight: true, border: false, margins: '0 0 5 0' },... </code></pre> <p>i could not find 'region' propert...
<p>You are correct, the 'region' attribute is not a direct attribute of Viewport itself, but an attribute of the regions you are assigning to your Viewport.</p> <p>Each Viewport must contain at least two regions. These regions are defined as part of the Ext.layout.BorderLayout.Region class (<a href="http://extjs.com/d...
Is it possible to access the App Store Data for market analyzation? <p>I am wondering if the App Store provides an API that allows others to access the data like descriptions, prices, reviews, etc.?</p>
<p>The iTunes Store <em>is</em> the API.</p> <p>All pages in the iTunes Store are simply XML files rendered by iTunes. You can parse these files yourself and navigate around to your heart's content.</p> <p>Here's the URL for the front page:</p> <pre><code>http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStore.w...
library for server side (c/c++) xmlrpc <p>I want to implement support of the XMLRPC protocol for my server that is written in C and C++ and now looking for the most widely adopted xmlrpc library. License is not an issue, GPL would be fine. What would you suggest ? Is there any defacto standard xmlrpc C library for such...
<p>The de facto standard would imo be this one: <a href="http://xmlrpc-c.sourceforge.net/">http://xmlrpc-c.sourceforge.net/</a> and it supports both C and C++ and it even has its own embedded http daemon for servicing the http requests ...</p> <p>edit: and it's available under a BSD-style license, so it allows you to ...
How can I make external code 'safe' to run? Just ban eval()? <p>I'd like to be able to allow community members to supply their own javascript code for others to use, because the users' imaginations are collectively far greater than anything I could think of.</p> <p>But this raises the inherent question of security, pa...
<blockquote> <p>Or are there other ways to evaluate code</p> </blockquote> <p>You can't filter out calls to <code>eval()</code> at a script-parsing level because JavaScript is a Turing-complete language in which it is possible to obfuscate calls. eg. see svinto's workaround. You could hide <code>window.eval</code> b...
Extract cursor image in Java <p>I was wondering if there is a way to extract an Image object from a Cursor object in Java.</p> <p>A use for this would be for instance :</p> <pre><code>Image img = extractCursorImage(Cursor.getDefaultCursor()); </code></pre> <p>Which you then can draw on a toolbar button (that's the p...
<p>The <a href="http://java.sun.com/javase/6/docs/api/java/awt/Cursor.html">Cursor</a> class is pretty abstract - all the important stuff is delegated to native code, so you can't just draw one onto at <a href="http://java.sun.com/javase/6/docs/api/java/awt/Graphics2D.html">graphics</a> context. There isn't an immediat...
Read .NET configuration from database <p>The .NET 2.0 and up configuration system is quite powerful and extensible - as long as you don't want to change the fact it all comes from XML files in the filesystem.</p> <p>In my requirement, I cannot change files since my app runs in a managed environment outside my reach - ...
<p>There's an article here that talks about doing what you are talking about:</p> <blockquote> <p><a href="http://www.wrox.com/WileyCDA/Section/Redirecting-Configuration-with-a-Custom-Provider.id-291932.html" rel="nofollow">http://www.wrox.com/WileyCDA/Section/Redirecting-Configuration-with-a-Custom-Provider.id-2919...
How to model diffrent views (roles) on a resource? <p>How can I model roles views restfully?</p> <p>Lets say I have a resource that can be viewed by a buyer or a seller (some content is shared between them on the resource, and some is unique to each one of them)</p> <p>Should i make them a seperate resource: /resour...
<p>I wouldn't put it anywhere. Instead, I'd have the same URL display the applicable parts of the resource based on the authenticated user.</p> <p>User's roles are already decided upon when authenticating, makes no sense to require duplicating the data in the query. Imagine you have a complex user permission system. W...
detect browser font size <p>Is it possible to detect browser font size? Also is it possible to dedect new font size when user changes the font size from menu selection? Many thanks for everybody help. Best regards.</p>
<p>Well, it is possible, but my raven sitting on a crystal ball tells me not to tell you how, but to ask you what you want to achieve. Most likely, you want a webpage to look good no matter what the font-size is. For that, I recommend the <a href="http://www.w3.org/TR/CSS21/syndata.html#length-units">CSS units <code>em...
Why is it very slow for a Regex to finish a XML file of 3000 lines? <p>I noticed that it is very slow for a Regex to finish a XML file with 3000 lines [1]:</p> <pre><code>\(&lt;Annotation\(\s*\w\+="[^"]\{-}"\s\{-}\)*&gt;\)\@&lt;=\(\(&lt;\/Annotation\)\@!\_.\)\{-}"MATCH\_.\{-}\(&lt;\/Annotation&gt;\)\@= </code></pre> ...
<p>It depends on the regular expression itself if it is efficient or not. What it makes inefficient is backtracking. And to avoid this, the regular expression has to be as distinct as possible.</p> <p>Let’s take the regular expression <code>a.*b</code> as an example and apply it to the string <code>abcdef</code>. Th...
How to release the unused capacity of a string <p>I am dealing with a lot of strings in my program. These string data don't change through out the whole life time after they being read into my program.</p> <p>But since the C++ string reserves capacity, they waste a lot of space that won't be used for sure. I tried to ...
<p>When you call <code>reserve</code>, you're making a <em>request</em> to change the capacity. Implementations will only guarantee that a number equal to or greater than this amount is reserved. <strong>Therefore, a request to <em>shrink</em> capacity may be safely ignored by a particular implementation.</strong></p> ...
C++: Debugging memory leaks in reference counting system <p>I've got a number of reference counted classes in some of my applications, and also in dlls those applications use, all inheriting from and implementing a IRefCounted interface.</p> <p>In order to help with finding the source of these memory leaks I want each...
<p><del>I'm guessing you're using COM.</del> You'll probably need to find some way of having a <a href="http://www.ddj.com/cpp/184402026" rel="nofollow">weak pointer</a> so that the registry of instantiated objects doesn't prevent them from being destructed.</p> <p>If you can modify all the classes, you could inject ...
Variable Dumping in C++ <p>Is it possible to do a 'dump' on complex structures or even arrays in C++, in order to visually be able to check out what they've got inside them?</p> <p>I'm thinking of something similar to print_r() or var_dump() in PHP.</p> <p>Cheers, -Fin</p>
<p>The short answer is: no, unless you manually write such a routine yourself.</p> <p>Which is often not a bad idea, but it has the usual problems of getting out of sync with the class if you are adding/changing members often. This is unavoidable because C++ lacks any form of introspection into <code>struct</code>s.<...
How to create an active link in RSS? <p>In RSS, for example if I wanna add a link for the channel: Part of the RSS code:</p> <pre><code>&lt;link&gt; &lt;a href="http://www.nytimes.com/2009/04/10/technology/internet/10google.html?ref=technology"/&gt; &lt;/link&gt; </code></pre> <p>And now here is the XSL code:</p> <...
<p>I would use </p> <pre><code>&lt;link&gt;http://www.nytimes.com/2009/04/10/technology/internet/10google.html?ref=technology&lt;/link&gt; </code></pre> <p>Then in the XSLT, create an <code>a</code> tag and set the <code>href</code> attribute to that value. I don't know XSLT that well, but this might be possible or s...
Usage of ORMs like NHibernate when there are many associations - performance concerns <p>I have created an application (a web-based application) which now has a large number of associations. Simply put, an Account:</p> <ul> <li>has many Users</li> <li>has Settings</li> <li>has many Projects</li> </ul> <p>Similarly a ...
<p>It is generally good practise with NHibernate to enable lazy loading for most associations and objects by default unless you know you're always going to need the associated data. Then you can switch to eager loading selectively just for items where that is more efficient when you come to the optimisation stage.</p>
Random behavior differences between C# and Java: the seed <p>I have a Random into a class which aims to generate random sequences in different contexts: this is the result of a porting from Java code. In the Java version everything works fine since the java.lang.Random class has the method setSeed, which permits the ch...
<p>Typically I create a single instance of Random for my application and after setting the seed on instantiation can rely on each call to Next giving me a new random number. The trick is to make sure the seed is as random as possible. The use of Random in a C# app is a good example of where a Singleton is a good fit.</...
What is the difference between debug.write and Trace.write? <p>What is the difference between <strong>debug.write</strong> and <strong>Trace.write</strong>? When should each be used?</p>
<p>In the typical release build configuration, the <code>Debug</code> class is disabled and does nothing. <code>Trace</code>, however, can still be used in the release. You would typically use <code>Debug.Write</code> for stuff you only need when debugging and which is too verbose for production.</p> <p>Here's a good ...
Does anyone know how sites are generating the Apple App Store updated apps feeds? <p>A lot of sites have rss feeds for updated and new apps on the Apple iPhone App Store. However, Apple's rss feed generator only shows feeds for the top 100 free/paid apps. So how can I generate my own database of new/updated apps in the...
<p>Apple have an <a href="http://itunes.apple.com/rss/generator/" rel="nofollow">RSS generator for iTunes</a>.</p> <blockquote> <p>Provide the information requested below, then click Generate to view the feed URL. These feeds automatically update to reflect iTunes' top charts and new content, so you'll alway...
iPhone AdMob ad <p>I have the following two questions, I tried googling these, but didn't find any luck. Please help me.</p> <ol> <li><p>I have integrated AdMob ad to my iphone application. when the admob view is clicked, safari gets opened, and if there is any error in loading the ad, it displays an error message say...
<p>(1) Once control is transfered to safari, iPhone OS starts shutting your app down. Control will not transfer back to your app - the user will need to close safari and restart your application. </p> <p>The only way to display web content in an iPhone app without your app closing is by embedding the web browser insid...
questions related to DTD and schema: finding the missing words <p>This question are part of a quiz. I've finished already but some questions were answered incorrectly. However, the teacher don't upload the solution for those questions. Would you please help me for the solution of such questions? I need to know exactly...
<p>Was this multiple choice? What were the other choices?</p> <p>For 1 and 2 I can guess:</p> <p>1) NDATA (NDataDecl)</p> <p>2) attribute-list</p> <p>(What kind of exam needs you to know horrible old cruft like Notations, huh? Yuck!)</p>
How to hide datasource passwords in in Tomcat JMX Beans <p>Tomcat exposes a good wealth of information about its internals via JMX. You can see data source, connector usage, thread pools, you name it. </p> <p>However, it also exposes the password of the JDBC datasource (Catalina->DataSource->javax.sql.DataSource->...)...
<p>Just restrict access at JMX level to ones who are authorized.</p>
When to join name and when not to? <p>Most languages give guidelines to separate different words of a name by underscores (python, C etc.) or by camel-casing (Java). However the problem is when to consider the names as separate. The options are:</p> <p>1) Do it at every instance when separate words from the English di...
<p>I always do your option 1, and as far as I can tell, all modern frameworks do.</p> <p>One thing that comes to mind that just sticks names together is the standard C library. But its function names are often pretty cryptic anyway.</p>
Ensuring methods are only ever executed by the main thread <p>I have an objective-c class whose methods I only ever want to be called from the main thread.</p> <p>I could achieve this by adding something like this to each selector:</p> <pre><code>- (void) exampleSelector: (id) param { if (![NSThread isMainThread]...
<p>Hmm. I'm not sure if it's possible to do this; I can't think of a way to do so. What I would be inclined to do instead is to replace the object with a proxy. The proxy will be responsible for forwarding invocations to the object in the correct thread.</p> <pre><code>@interface Forwarder : NSObject { id recipien...
RegExp: How to extract usernames out of Tweets (twitter.com)? <p>I have the following example tweet:</p> <p>RT @user1: who are @thing and @user2?</p> <p>I only want to have <em>user1</em>, <em>thing</em> and <em>user2</em>.</p> <p>What regular expression can I use to extract those three names?</p> <p>PS: A username...
<p>Tested:</p> <pre><code>/@([a-z0-9_]+)/i </code></pre> <p><hr /></p> <p>In Ruby (irb):</p> <pre><code>&gt;&gt; "RT @user1: who are @thing and @user2?".scan(/@([a-z0-9_]+)/i) =&gt; [["user1"], ["thing"], ["user2"]] </code></pre> <p>In Python:</p> <pre><code>&gt;&gt;&gt; import re &gt;&gt;&gt; re.findall("@([a-z0...
What's the best way to enable/disable some controls amongst multiple controls under various different condition? <p>I am new to professional programming, I am writing C# but I think this isn't exactly C# specific. Anyway, I want to ask what's the best way to enable/disable some controls amongst multiple controls under ...
<p>I would bind the <code>Enabled</code> properties to <code>Can*</code> (<code>CanWalk</code>, <code>CanJump</code>, etc.) properties of the class, implement <code>INotifyPropertyChanged</code>, and check each potentially affected property when the object's state changes.</p> <p>The advantage of this method is the Pe...
SQLAlchemy many-to-many orphan deletion <p>I'm trying to use SQLAlchemy to implement a basic users-groups model where users can have multiple groups and groups can have multiple users.</p> <p>When a group becomes empty, I want the group to be deleted, (along with other things associated with the group. Fortunately, S...
<p>The way I've generally handled this is to have a function on your user or group called leave_group. When you want a user to leave a group, you call that function, and you can add any side effects you want into there. In the long term, this makes it easier to add more and more side effects. (For example when you w...
Why does the empty string not match as Seq.empty? <p><strong>EDIT: This was an old bug long since fixed in Scala 2.8 and later</strong></p> <p>During some experimentation around question <a href="http://stackoverflow.com/questions/740563/pattern-matching-a-string-as-seqchar">Pattern matching a String as Seq[Char]</a>,...
<p>This appears to be a bug in the library. Do you want to file the bug or shall I?</p> <pre><code>scala&gt; Seq.empty match {case Seq() =&gt; "yup"; case _ =&gt; "nope"} res0: java.lang.String = yup scala&gt; Seq() match {case Seq.empty =&gt; "yup"; case _ =&gt; "nope"} res1: java.lang.String = yup scala&gt; (""...
ABC Virtual OStream Insertion Operator <p>Consider the following snippet:</p> <pre><code>struct ObjectInterface { virtual ~ObjectInterface() {} virtual void Print(std::ostream&amp; target) const = 0; }; struct Foo : ObjectInterface { virtual void Print(std::ostream&amp; target) const { target ...
<p>You need a free function:</p> <pre><code>ostream &amp; operator &lt;&lt; ( ostream &amp; os, const ObjectInterface &amp; oi ) { oi.Print( os ); return os; } </code></pre>
Is it possible to delete both ends of a large file without copying? <p>I would like to know if it is possible, using Windows and c++, to take a large video file (several gigabytes in length) and delete the first and last few hundred megabytes of it “in-place”.</p> <p>The traditional approach of copying the useful ...
<p>Sure, it's possible in theory. But if your filesystem is NTFS, be prepared to spend <em>a few months</em> learning about all the data structures that you'll need to update. (All of which are officially undocumented BTW.)</p> <p>Also, you'll need to either</p> <ol> <li>Somehow unmount the volume and make your cha...
parse an XML with SimpleXML which has multiple namespaces <p>I have this ugly XML which has alot of namespaces on it, when I try to load it with simpleXML if i indicate the first namespace I'd get an xml object ,but following tags with other namespaces would not make it to the object. </p> <p>How can I parse this XML ...
<p>I think you need to register the namespacing and access with XPath. Something like the following should get you going (I haven't the facility to test this).</p> <pre><code>$xml = simplexml_load_string($res, NULL, NULL, "http://schemas.xmlsoap.org/soap/envelope/"); $xml-&gt;registerXPathNamespace('soap-env', 'http:...
help requires in winavr <p>i am trying to send ---.hex file to my siemens C55 throught serial port but while doing do i am getting an error </p> <blockquote> <p>"make.exe" program avrdude -p atmega8 -P com2 -c stk200 -U flash:w:gsm_remote.hex avrdude: port name "com2" is neither lpt1/2/3 nor valid number ...
<p>I'm not sure how to set the avrdude port on windows (it's described somewhere in the documentation), but I think you're making a bigger mistake here. Siemens C55 (mobile phone, right?) does not run on atmega. It uses Infineon C16X (most probably) like all the siemens phones from 5X/6X series. I don't think this code...
How do I set the ASP.NET version for a Virtual Directory using IIS Manager 7.0? <p>In the old version of IIS Manager, I could just right-click on a VD, hit properties, and then in the ASP.NET tab pick the version of ASP.NET I wanted to run. Does anyone know if that is still possible? I am running a localhost instance...
<p>You need to change the application pool - the ASP.NET version is set at the application pool level.</p> <p>Left click the virtual directory in IIS manager, then on the far right of the screen click on 'advanced settings' The application pool is at the top of the list there.</p> <p>If you need to, you can add a new...
python write string directly to tarfile <p>Is there a way to write a string directly to a tarfile? From <a href="http://docs.python.org/library/tarfile.html">http://docs.python.org/library/tarfile.html</a> it looks like only files already written to the file system can be added.</p>
<p>I would say it's possible, by playing with TarInfo e TarFile.addfile passing a StringIO as a fileobject. </p> <p>Very rough, but works</p> <pre><code>import tarfile import StringIO tar = tarfile.TarFile("test.tar","w") string = StringIO.StringIO() string.write("hello") string.seek(0) info = tarfile.TarInfo(name=...
Javascript - load events for embed elements <p>If I do an online onload event for embed objects, that seems to work but I can't seem to get the load event working through addEventListener. Is this expected?</p>
<p>Probably, but it may be browser dependent.</p> <p>windows and images and iframes define their load events with addEventListener and attachEvent, but other load events are browser specific.</p> <p>A script or link element's onload doesn't attach in IE, for instance.</p>
Why is \%(\) faster than \(\) in Vim? <p>I am confused by the docs:</p> <blockquote> <p><code>\%(\)</code> A pattern enclosed by escaped parentheses. <code>*/\%(\)* */\%(*</code> <code>*E53*</code> Just like <code>\(\)</code>, but without counting it as a sub-expression. This allows using more groups and it...
<p>The 'a little bit faster' comment is accurate in that there is a little less bookkeeping to be done, but the emphasis is on 'little bit' rather than 'faster'. Basically, normally, the material matched by <code>\(pattern\)</code> has to be kept so that you can use <code>\3</code> (for the appropriate number) to refe...
C#: How can i change the text of a label thats in form1 from another class? <p>im trying to change the text of a label from a class but have been unsuccessful.</p> <p>what i have is that im updating a variable in the class using get{} and set{}. i understand that i need to put or do something within set{} to get it to...
<p>You might want to consider using delegates or events and having your classes raise events back to the form, that way your classes will have no knowledge of your form.</p> <p><strong>EXAMPLE</strong></p> <pre><code>class SomeClass { public delegate void UpdateLabel(string value); public event UpdateLabel O...
Help storing an intrusive_ptr of a template class in a std::map <p>I have a small template class of type Locker contained within a boost::intrusive_ptr that I want to store inside a std::map:</p> <pre><code>template &lt;typename T&gt; bool LockerManager&lt;T&gt;:: AddData(const std::string&amp; id, T* pData) { bo...
<p>The compiler is doing its best to be helpful here. You need to define a method with the following signature:</p> <pre><code>boost::intrusive_ptr&lt;Locker&lt;Clayton&gt; &gt;::intrusive_ptr( boost::intrusive_ptr&lt;Locker&lt;Clayton&gt; &gt; (* const&amp;)(Locker&lt;Clayton&gt;) ): </code></pre> <p>You need to...
Writing effective XSLT <p><strong>What are the principles and patterns that go into writing effective XSLT?</strong></p> <p>When I say "effective" I mean that it is</p> <ol> <li>Well-structured and readable</li> <li>Simple, concise</li> <li>Efficient (i.e. has good performance)</li> </ol> <p>In short, I'm looking fo...
<h1>I. Elegant XSLT code</h1> <p><br /> <strong>One can often find examples of beautiful XSLT code, especially when XSLT is used as a functional programming language</strong>. </p> <p>For examples see <a href="http://www.idealliance.org/papers/extreme/proceedings/xslfo-pdf/2006/Novatchev01/EML2006Novatchev01.pdf"><st...
Assigning random colors per session, for chat <p>I have an AJAX chat system that I'm working on and so far I have it working. One thing I want to do is have it so when the user name is displayed on screen, it is a unique color (like in an AIM window). How would I generate a random color to assign to the user's name for...
<p>I think you're going to be better off randomly picking from a list of pregenerated colors that meet your requirements (dark enough, different enough from each other) than trying to generate colors on the fly.</p> <p><em>Edited to add:</em></p> <p>As far as keeping more than one user from having the same color, one...
Multi-Dimensional Array ( C++ ) <p>I'm trying to store a pointer in an array.</p> <p>My pointer to a pointer is class object is:</p> <pre><code>classType **ClassObject; </code></pre> <p>So i know i can allocate it by using the new operator like this:</p> <pre><code>ClassObject = new *classType[ 100 ] = {}; </code><...
<p>If you are using C++ use the <a href="http://www.boost.org/doc/libs/1%5F38%5F0/libs/multi%5Farray/doc/user.html" rel="nofollow">Boost Multidimensional Array Library</a></p>
NSApplicaton delegate - applicationDidFinishLaunching <p>I have declared a delegate for my cocoa application here :</p> <p>MyAppDelegate.h</p> <pre><code>@interface MyAppDelegate : NSApplication { } - (void) applicationDidFinishLaunching:(NSNotification*) notice ; @end </code></pre> <p>MyAppDelegate.m</p> <pre><cod...
<p>Your application delegate is not an application itself. It should inherit from NSObject, not NSApplication.</p> <h3>Why that matters</h3> <p>NSApplication is a singleton. Its <code>init</code> method always returns the first instance of NSApplication or any subclass, throwing away any subsequent objects you (or t...
Django: Adding additional properties to Model Class Object <p>This is using Google App Engine. I am not sure if this is applicable to just normal Django development or if Google App Engine will play a part. If it does, would you let me know so I can update the description of this problem.</p> <pre><code>class MessageM...
<p>You should still be able to send it messagesSQL to the template after you've added elements to it via the for loop. Python allows that sort of thing.</p> <p>Something else that might make sense in some cases would be to give your MessageModel methods. For instance, if you have a </p> <pre><code>def since_date_cr...
Unit testing Scala <p>I just recently started learning the Scala language and would like to do it in <a href="http://en.wikipedia.org/wiki/Test-driven%5Fdevelopment">TDD</a>-way. Could you share your experiences on the unit testing frameworks there are for Scala and the pros/cons of them.</p> <p>I'm using IntelliJ IDE...
<p>Have you looked at <a href="http://www.artima.com/scalatest/" rel="nofollow">ScalaTest</a> ?</p> <p>I've not used it, but it comes from Bill Venners and co at Artima, and consequently I suspect it'll do the job. It doesn't appear to have IDE integration, however.</p> <p><a href="http://www.theserverside.com/blogs/...
How does splint know my function isn't used in another file? <p>Splint gives me the following warning:</p> <pre><code>encrypt.c:4:8: Function exported but not used outside encrypt: flip A declaration is exported, but not used outside this module. Declaration can use static qualifier. (Use -exportlocal to inhibit w...
<p>You might find that if you included a header that declared <code>flip()</code> - as you should, of course - then <code>splint</code> would not complain. You should also declare <code>blah()</code> in the header as well.</p> <p>I'm not wholly convinced that this is the explanation because <code>blah()</code> is not...
What is the difference between Microsoft AJAX and AJAX Pro? <p>What is the difference between Microsoft AJAx and AJAX Pro?</p> <p>Also, for what should I use AJAX Pro?</p>
<p>Microsoft AJAX is Microsoft's Ajax library that contains ready to use server controls. </p> <p>AJAX Pro is a free AJAX library, that enables you to implement your Ajax calls manually. It's a little bit difficult to use then Microsoft's controls. But you have more control on the data and html elements with this libr...
Repository Pattern - POCOs or IQueryable? <p>I'm new to the Repository Pattern and after doing a lot of reading on the web I have a rough understanding of what is going on, but there seems to be a conflict of ideas.</p> <p>One is what the IRepository should return.</p> <p>I would like to deal in ONLY Pocos so I would...
<p>Yes, your version is the safest / most compatible one. You can still use it with about any resources, not only data access ones, but with web services, files, whatever.</p> <p>Note that with the IQueryable version you still get to work based on your POCOs classes, but you are tied to the IQueryable. Also consider t...
How to interrupt server Connection in C# <p>one my application features is tod download files from our ftp server. And of course this feature reqiures to cancel this operation (Cancel Downloading).</p> <p>Now, my Download Function is as follows:</p> <pre><code>try { reqFTP = (FtpWebRequest)FtpWebR...
<p>I'm assuming that you have a form of some sort, so your performing the download on a thread.</p> <p>What your probably better off doing is checking a "cancel" flag inside your while loop.</p> <p>eg.</p> <pre><code>while(readcount &gt; 0 &amp;&amp; !cancel) { ... } </code></pre> <p>Then let your method gracefu...
Need help converting VB.NET 08 code to PHP - Getting direct link from MediaFire.com <p>I was looking for a way to get a direct link from mediafire's file hosting service. By default, when a user visits a download link, he will be presented with a download page where he has to wait for the download to be processed and t...
<p>This VB.NET code relies on access to the client DOM through the WebBrowser .NET control. You could port this to PHP by:</p> <ul> <li>Using the cURL functions to get the HTML</li> <li>Loading them into an HTML parser to find the correct link</li> <li>Redirecting the user with <code>Header('Location: '.download_link)...
How to start creating a selection script , "inspect like what firebug do"? <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/742210/does-anyone-know-a-dom-inspector-javascript-library-or-plugin">Does anyone know a DOM inspector javascript library or plugin?</a> </...
<p>Could you do something like add a jquery function which does stuff on hovering and clicking on things you want to inspect?</p> <p>e.g</p> <pre><code>$('div, p, img').hover(function(){ // stuff to do on hover like highlight the object $(this).addClass('hover'); }, function(){ $(this).removeClass('hover'); ...
Why am I getting "Undefined index" from my PHP? <p>When I run this code:</p> <pre><code>&lt;?php if (preg_match('/^[a-z0-9]+$/', $_GET['p'])) { $page = realpath("includes/$_GET[p].php"); if ($page) { include $page; } } ?&gt; </code></pre> <p>I get this error:</p> <blockquote> <p>Notice: Undefined index: ...
<p>The error message says that there is no array item with the key <code>p</code>. If you cannot guarantee that a variable (or array item) does exist, you should first check it with the <a href="http://docs.php.net/isset" rel="nofollow"><code>isset</code> function</a>:</p> <pre><code>if (isset($_GET['p']) &amp;&amp; p...
Getting the time elapsed (Objective-c) <p>I need to get time that elapsed between two events: for example between appearance of UIView and between user's first reaction.</p>
<pre><code>NSDate *start = [NSDate date]; // do stuff... NSTimeInterval timeInterval = [start timeIntervalSinceNow]; </code></pre> <p><code>timeInterval</code> is the difference between start and now, in seconds, with sub-millisecond precision.</p>
How many ways there are to declare variables in facelets? <p>I noticed that c:set does not work well used inside "include of include of include", as important notice facelets documentation does't recommend it too.</p> <p>Now I am using ui:param inside ui:include, but it is a bit dispersive when no attached notes about...
<p>This is really a matter of trying to fit old JSP programming into the JSF framework. You should be using backing beans to hold your data.</p> <p>If you try to hard-code data directly into your xhtml file, you are defeating the purpose of JSF's MVC framework. If you have a specific example of what you are trying to ...
Binary Trees question. Checking for similar shape <p>Hi I'm stuck doing this, not sure how to go about it.</p> <p>If I have two binary trees, how would I check if the have the same shape? Data in the nodes doesn't matter, just if the tree structures are equal.</p> <p>Any ideas on how to solve this problem?</p>
<p>You can easily do that with recursion. This following code works because two non-empty trees have the same shape if and only if their respective subtrees have the same shape.</p> <pre><code>boolean equalTrees(Node lhs, Node rhs) { // Empty trees are equal if (lhs == null &amp;&amp; rhs == null) retu...
How can I make my PHP-based cron job execute more often? <p>I have a file "<code>update.php</code>" which does some MySQL operations. A cron job executes this file every 5 minutes. Unfortunately, I cannot execute the cron job more often.</p> <p>So I had the idea that I could add ...</p> <pre><code>&lt;html&gt; &lt;he...
<p>I'm afraid that won't work, because it's a browser feature to refresh the page.</p> <p>Question: Why can't you set the cron job to run more frequently that every 5 minutes?</p> <p>If there is no other option then you could create you're own daemon to do the job more frequently.</p> <p>e.g. Your php script could:...
Programatically determining amount of parameters a function requires - Python <p>I was creating a simple command line utility and using a dictionary as a sort of case statement with key words linking to their apropriate function. The functions all have different amount of arguments required so currently to check if t...
<p><a href="http://docs.python.org/library/inspect.html#inspect.getargspec">inspect.getargspec()</a>:</p> <blockquote> <p>Get the names and default values of a function’s arguments. A tuple of four things is returned: (args, varargs, varkw, defaults). args is a list of the argument names (it may contain nested lis...
TSQL make EXECUTE statement synchronous <p>I have two TSQL EXEC statements</p> <pre><code>EXECUTE (N'MyDynamicallyGeneratedStoredProcedure') -- return 0 on success SELECT @errCode = @@ERROR ; IF (@errCode = 0) BEGIN EXEC 'A Sql Statement using ##temptable created from first', @returnValue END </code></pre> <p>How ...
<p>EXECUTE is sychronous. The 2nd one runs after the 1st one. Always.</p> <p>Do you have multiple connections running the same code? You are using a global temp table that will be visible to all connections so it may look like asyncc execution...</p>
How to draw opengl graphics from different threads? <p>I want to make an opengl application that shows some 3d graphics and a command-line. I would like to make them separate threads, because they both are heavy processes. I thought that I could approach this with 2 different viewports, but I would like to know how to ...
<p>Its possible you can achieve what you want to do using Overlays.<br /> Overlays are a somewhat dated feature but it should still be supported in most setups. Basically an overlay is a separate GL Context which is rendered in the same window as another layer, drawing on top of whatever was drawn on the windows with i...
TreeViolationException problem <p>Hi Im having some trouble when inserting to the right of a node in a binary tree... I just dont see why the exception is happening. This is the method to inset:</p> <pre><code>public void attachRight(BinaryTree&lt;T&gt; tree) { if (right != null) { throw new TreeViolationException...
<p>From the information given, the exception should come from this line:</p> <pre><code>//insert 5 -&gt; right(16) root.right.attachRight(new BinaryTree&lt;Integer&gt;()); </code></pre> <p>because root.right.attachRight() has already been called on this line:</p> <pre><code>//insert 1 -&gt; right(12) root.right.atta...
Postgres functions <p>I need to make a select query with joins. This should be written in a function. My approach didn't work:</p> <pre><code>CREATE OR REPLACE FUNCTION test2() RETURNS SETOF record AS' DECLARE r record; BEGIN for r in SELECT * FROM messages_wall INNER JOIN location ON messages_wall.id...
<p><code>SELECT * FROM test2() AS tabletest2 (id integer, name text);</code> if you really wanna use a function, but a view is better in this case</p>
How to detect the point of a stack overflow <p>I have the following problem with my C program: Somewhere is a stack overflow. Despite compiling without optimization and with debugger symbols, the program exits with this output (within or outside of gdb on Linux):</p> <p> Program terminated with signal SIGSEGV, Segment...
<p>If you allow the system to dump core files you can analyze them with gdb:</p> <pre><code>$ ulimit -c unlimited # bash sentence to allow for infinite sized cores $ ./stack_overflow Segmentation fault (core dumped) $ gdb -c core stack_overflow gdb&gt; bt #0 0x0000000000400570 in f () #1 0x0000000000400570 in f () #...
Does anyone know a DOM inspector javascript library or plugin? <p>Does anyone know of a DOM inspector javascript library or plugin?</p> <p>I want to use this code inside a website I am creating, I searched a lot but didn't find what I wanted except this one: <a href="http://slayeroffice.com/tools/modi/v2.0/modi_help.h...
<p><a href="http://karmatics.com/aardvark/">Aardvark</a> is a firefox extension officially but you can use that as a javascript library, too. The inline demo in the said website is implemented using javascript. digg into the code &amp; you'll find <a href="http://karmatics.com/aardvark/loader.js">loader.js</a> which is...
Silverlight installed in Firefox 3, but not detected/activated <p>As the title says really. We are working on a Silverlight banner on a redesign of our site and the Silverlight content works fine in all browsers except Firefox 3 (PC v3.0.7,8 or Mac v3.0.8). The Add-in is marked as having been installed, however.</p> <...
<p>I checked your Silverlight.js file and it was version 1.0 of the .js file. I think that upgrading to the <a href="http://code.msdn.microsoft.com/silverlightjs" rel="nofollow">2.0 version of Silverlight.js file</a> (which was updated for FF3) may solve your issue. </p>
Determine the name of the variable used as a parameter to a method <p>How would you, in C#, determine the name of the variable that was used in calling a method?</p> <p>Example:</p> <pre><code>public void MyTestMethod1() { string myVar = "Hello World"; MyTestMethod2(myVar); } public void MyMethod2(string parm) {...
<p>There is a way, but it's pretty ugly.</p> <pre><code>public void MyTestMethod1() { string myVar = "Hello World"; MyTestMethod2(() =&gt; myVar); } public void MyMethod2(Expression&lt;Func&lt;string&gt;&gt; func) { var localVariable = (func.Body as MemberExpression).Member.Name; // localVariable == "myVar" }...
Unable to move between Screens in Emacs <p>I have two screens, one is empty and the other is Emacs' manual. My cursor is at the empty screen. </p> <p>All my commands affect the empty screen.</p> <p>A similar command in Vim is C-w.</p> <p><strong>How can you switch to the Emacs' manual</strong> such that I can roll d...
<p><strong>Control-x + o</strong> (C-x + o), google emacs cheat sheet for help</p> <ol> <li>hold Control</li> <li>press X</li> <li>release Control and X</li> <li>press O</li> </ol>
Copy files with double credentials (windows) <p>Assume we have c:\DirA that can be read by User1 only, and c:\DirB that can be written by User2 only. Both credentials are know. </p> <p>How can I copy files from DirA to DirB directly?</p>
<p>Assuming the process is run in the context of the first user, run <a href="http://msdn.microsoft.com/en-us/library/aa378184%28VS.85%29.aspx" rel="nofollow"><code>LogonUser</code></a> to obtain a security token for the second user. Spawn a thread and call <a href="http://msdn.microsoft.com/en-us/library/aa378612%28VS...
Tagging unit-tests <p>I'm working on a PHP project with solid unit-tests coverage.</p> <p>I've noticed, that last time, I'm making very tricky manipulations with unit-tests Command-Line Test Runner' <b>--filter</b> command.</p> <p>Here is this command's explanation from official documentation:</p> <blockquote> <bl...
<p>Good unit tests should: </p> <ul> <li>Have clear methods names and variable names to act as documentation</li> <li>Run fast. This will also be possible for test with complicated business logic. Test should run in an avarage time of something around 0.1 second.</li> <li>Test exactly one thing in one test method</li>...
TSQL: UPDATE with INSERT INTO SELECT FROM <p>so I have an old database that I'm migrating to a new one. The new one has a slightly different but mostly-compatible schema. Additionally, I want to renumber all tables from zero. </p> <p>Currently I have been using a tool I wrote that manually retrieves the old record, ...
<p>The key with migration is to do several things: First, do not do anything without a current backup. Second, if the keys will be changing, you need to store both the old and new in the new structure at least temporarily (Permanently if the key field is exposed to the users because they may be searching by it to get o...
How to access command line parameters outside of Main in C# <p>I am writing a .NET class that needs to parse the command line of the process. I don't want to have a dependency between the Main() method and that class. How can the class access the command line?</p>
<p>Call <code>Environment.GetCommandLineArgs()</code>.</p>
How do I parse text into lists in Java? <p>I have the following file saved as a <code>.txt</code>:</p> <pre><code>I Did It Your Way, 11.95 The History of Scotland, 14.50 Learn Calculus in One Day, 29.95 Feel the Stress, 18.50 Great Poems, 12.95 Europe on a Shoestring, 10.95 The Life of Mozart, 14.50 </code></pre> <p>...
<p>Seems simple enough that you don't need anything fancy.</p> <pre><code>BufferedReader r = new BufferedReader(new FileReader("file.txt")); List&lt;String&gt; titles = new ArrayList&lt;String&gt;(); List&lt;Double&gt; prices = new ArrayList&lt;Double&gt;(); while ((String line = r.readLine()) != null) { String[] t...