instruction
stringlengths
0
30k
Make methods static when they are not part of the instance. Don't sweat the micro-optimisations. You might find you have lots of private methods that could be static but you always call from instance methods (or each other). In that case it doesn't really matter that much. However, if you want to actually be able to...
Whether or not a method is static is more of a design consideration than one of efficiency. A static method belongs to a class, where a non-static method belongs to an object. If you had a Math class, you might have a few static methods to deal with addition and subtraction because these are concepts associated with Ma...
In the end it all boils down to the protocol you'd want to use. Shoutcast IMHO is plain HTTP, so to *make* your own stream, you just output the streams content. To make an ogg based webradio work with my Sonos system, I have created a little transcoding wrapper around sox which is is actually written in PHP, so it m...
I found this book by keith Brown The .NET Developer's Guide to Windows Security. It has some good samples covering all kinds of security scenarios. [Online version][1] is also available. [1]: http://alt.pluralsight.com/wiki/default.aspx/Keith.GuideBook.HomePage
The best strategy is always to give your users options. Why don't you start the stream at a low bitrate that will work for everyone and provide a "High Quality" link for those of us with FTTH connections? I believe YouTube has started doing this.
p1.py: <pre><code> execfile("p2.py") </code></pre> p2.py: <pre><code> import inspect print inspect.getfile( inspect.currentframe() ) </code></pre>
I don't think it will become mainstream. I think Ted Dziuba gets it right when he says it solves a "problem" that most people don't consider to be worth solving. http://teddziuba.com/2008/09/openid-is-why-i-hate-the-inter.html
If it were me, I'd reverse the question and ask why *I should* use a GridView, If you need a bunch of built-in features like paging and sorting, then the GridView might be a good fit. If you just want tabular data, I'd reconsider. Why? Because with GridView you're getting a whole bunch of stuff you won't use, your ...
Try attacking it from the other angle. Look at streaming services that cater to the customer you want, and have significant volume (maybe youtube) and see what they're pushing. You'll find there'a pretty direct correlation between alexa rating (popularity) and quality(minimum bitrate required). Vimeo will always hav...
In your above scenario, you'd be better off doing a master-detail style GridView, which will save you the overhead of all those GridView objects that get created. There are various implementation of it ([using a drop down for the master][1], using a [modal popup for the detail][2], etc.), but the main point is that ...
Search by hash?
|search|hash|utilities|
I had the idea of a search engine that would index web items like other search engines do now but would only store the file's title, url and a hash of the contents. This way it would be easy to find items on the web if you already had them and didn't know where they came from or wanted to know all the places that so...
|apache-flex|drag-and-drop|
YUI drag&drop proxy drag
|yui|dragdrop|
Question for YUI experts... I have a table and I've made each cell of the first row draggable by [proxy][1]. In IE, when the drag proxy is released, the original table cell actually jumps to wherever the release point was. How can I prevent this from happening? Essentially, I want to know where the proxy was dropped...
|javascript|dragdrop|yui|
|javascript|drag-and-drop|yui|
MAPI and managed code experiences?
|.net|mapi|pinvoke|e-mail|
Using MAPI functions from within managed code is officially unsupported. Apparently, MAPI uses its own memory management and it crashes and burns within managed code (see [here](http://blogs.msdn.com/pcreehan/archive/2007/05/04/what-does-unsupported-mean.aspx) and [here](http://blogs.msdn.com/mstehle/archive/2007/10/03...
Using MAPI functions from within managed code is officially unsupported. Apparently, MAPI uses its own memory management and it crashes and burns within managed code (see [here](http://blogs.msdn.com/pcreehan/archive/2007/05/04/what-does-unsupported-mean.aspx) and [here](http://blogs.msdn.com/mstehle/archive/2007/10/03...
|.net|e-mail|pinvoke|mapi|
|.net|email|mapi|pinvoke|
|.net|pinvoke|e-mail|mapi|
|.net|mapi|pinvoke|e-mail|
|.net|email|pinvoke|mapi|
I am using a wxGenericDirCtrl, and I would like to know if there is a way to hide directories, I'd especially like to hide siblings of parent nodes. For example if my directory structure looks like this: +-a | +-b | | | +-whatever | +-c | | | +-d ...
I am using a wxGenericDirCtrl, and I would like to know if there is a way to hide directories, I'd especially like to hide siblings of parent nodes. For example if my directory structure looks like this: +-a | +-b | | | +-whatever | +-c | | | +-d ...
Yes, as Kevin says, HTTP/1.1 specifications say "A single-user client should not maintain more than 2 connections with any server or proxy."
What do you use to create a website architecture?
|html|architecture|project-planning|
Sure, we can use a simple bulleted list or a mindmap. But, there must be a better, more interactive way. What do you use when starting your website architecture?
|architecture|project-planning|
By "architecture", do you mean the initial site map? If not, please post a clarification and I'll edit my response. Our tech team starts development after our creative department has done their stuff. Part of what we get is output from the information architect. He passes off a graphical sitemap, a detailed sitemap ...
CakePHP ACL Database Setup: ARO / ACO structure?
|cakephp|acl|
I'm struggling to implement ACL in CakePHP. After reading the documentation in the [cake manual][1] as well as several other tutorials, blog posts etc, I found Aran Johnson's excellent tutorial which has helped fill in many of the gaps. His examples seem to conflict with others I've seen though in a few places - spec...
The cause of your problem is **NOT** the Win console not willing to accept Unicode (as it does this since I guess Win2k by default). It is the default system encoding. Try this code and see what it gives you: import sys sys.getdefaultencoding() if it says ascii, there's your cause ;-) You have to create...
You will generate a key on the users machine via whatever ssh client they are using. pUTTY for example has a utility to do this exact thing. It will generate both a private and public key. The contents of the public key file generated will be placed in the authorized_keys file. Next you need to make sure that t...
You don't actually have to use the generated class that the WSDL gives you. If you take a look at the code that it generates, it's just making calls into some .NET framework classes to submit SOAP requests. In the past I have copied that code into a normal .cs file and edited it. Although I haven't tried this specifica...
GateKiller, In simple terms (and not a copy-paste out of the SQLBOL) so you can understand the concepts: RESTORE WITH RECOVERY uses the backup media file (eg. fulldata.bak) to restore the database to back to the time that backup file was created. This is great if you want to go back in time to restore the data...
Call ASP.NET Function From Javascript?
[According to CWA][1], the average US resident has a 1.9Mbps download speed. They have data by state, so if you have money then you can probably get a more specific report for your intended audience. Keep in mind, however, that more and more people are sharing this with multiple computers, using VOIP devices, and run...
I've used the following in a header file occasionally to produce clickable items in the VC6 and recent VS(2003+) compiler ouptut window. Basically, this exploits the fact that items output in the compiler output are essentially being parsed for "PATH(LINENUM): message". This presumes on the Microsoft compiler's...
I should had used google. \\\ #If DEBUG Then Console.WriteLine("Debug mode.") #Else Console.WriteLine("Release mode.") #End If /// Make sure that the option "Configuration settings" -> "Build" "Define DEBUG constant" in the project properties is checked.
Compiler constants. I don't remember the C# syntax, but this is how I do it in VB: #If CONFIG = "Debug" Then 'do somtehing #Else 'do something else #EndIf
Well, for images, there's [http://tineye.com/][1], which will one-up that, and find you similar images too. [1]: http://tineye.com/ tin eye
>>> import weakref >>> class Object: ... pass ... >>> o = Object() >>> r = weakref.ref(o) >>> # if the reference is still active, r() will be o, otherwise None >>> do_something_with_o(r()) See the [wearkref module docs][1] for more details. You can also use `weakref.proxy...
Redirecting non-www URL to www
|.htaccess|isapi-rewrite|
I'm using [Helicon's ISAPI Rewrite 3][1], which basically enables .htaccess in IIS. I need to redirect a non-www URL to the www version, i.e. example.com should redirect to www.example.com. I used the following rule from the examples but it affects subdomains: RewriteCond %{HTTPS} (on)? RewriteCond %{HTTP...
I found this book by keith Brown The .NET Developer's Guide to Windows Security. It has some good samples covering all kinds of security scenarios. Free [Online version][1] is also available. [1]: http://alt.pluralsight.com/wiki/default.aspx/Keith.GuideBook.HomePage
Adding extra information to a custom exception
|c#|.net|exception|elmah|
I've created a custom exception for a very specific problem that can go wrong. I receive data from another system, and I raise the exception if it bombs while trying to parse that data. In my custom exception, I added a field called "ResponseData", so I can track exactly what my code couldn't handle. In custom excep...
Boolean Expressions in Shell Scripts
|bash|shell|expression|
What's the "right" way to do the following as a boolean expression? for i in `ls $1/resources`; do if [ $i != "database.db" ] then if [ $i != "tiles" ] then if [ $i != "map.pdf" ] then if [ $i != "map.png" ] then svn export -q $1/resources/$i ...
Since you're not going to have a user interacting with the program, I'd say make configuration variable (in an app.config file) responsible for sending/not sending the data. That way users who don't want to report errors can just change a flag in a config file. I'd personally have it turned on by default and then giv...
create table question_bank ( question_id uniqueidentifier primary key, question_exam_id uniqueidentifier not null, question_text varchar(1024) not null, question_point_value decimal, foreign key ( question_exam_id ) references exams (exam_id) );
I work for one of those consulting firms mentioned by Carlton, and let me tell you that we are the only company to have developed an in-house (proprietary) tool that helps us jump start the conversion process from RPTs to RDLs. Our current tool only supports Crystal Rpts 9 and older, and the RDL 2000 and 2005 formats....
According to the [Mono roadmap][1] I'm not sure if Linq is available for mono? At least some of Linq might be available in the very latest release, but Linq to DB is listed for Mono 2.4 (Feb 2009) [1]: http://www.mono-project.com/Mono_Project_Roadmap
|javascript|asp.net|
I'm writing a web page in ASP.NET. I have some Javascript, and I have a submit button with an onClick event. Is it possible to call a method I created in ASP with Javascript's onCall event?
I'm writing a web page in ASP.NET. I have some Javascript, and I have a submit button with an onClick event. Is it possible to call a method I created in ASP with Javascript's onClick event?
|c#|asp.net|javascript|
SQL Server Recpvery States
|sql|backup|
When restoring a SQL Server Database, I notice that there are 3 different Recovery States to choose from: - Restore with Recovery - Restore with No Recovery - Restore with Standby I've always left it at it's default value, but what do they all mean? (Preferably in layman's terms)
SQL Server Recovery States
You might want to check out [Subsonic][1]. It is an ORM that uses an ActiveRecord pattern. I'm pretty sure most of its features work with the .NET Framework 2.0. [1]: http://subsonicproject.com/
You might want to create a web service for your common methods. Just add a WebMethodAttribute over the functions you want to call, and that's about it. Having a web service with all your common stuff also makes the system easier to maintain.
@[Jason Day][1], I think the 4 in the last %4s is significant if there are fewer than 4 characters. If there are more than 4 you are right, %4s and %s would be the same, but with fewer than 4 chars in g %s would be left justified and %4s would be right-justified in a 4 char field. b is actually minimum 16 chars for...
One problem I can see is that, in a large company, this pattern could allow the code to become difficult (if not impossible) for anyone to understand and use. If multiple developers are constantly adding their own methods to existing classes, separate from those classes (and, God help us all, to BCL classes even), I co...
Actually nlucaroni, your case isn't quite right. Your example doesn't include double-quotes, so id,age,name,... 1,23,phil, won't match my regex. It requires the format "XXX,XXX". I can't think of an example of when it will match incorrectly. All the following example won't include the deliminator in t...
This is not specific to any language, it´s just about best practices. I am using JPA/Hibernate (but it could be any other ORM solution) and I would like to know how do you guys deal with this situation: Let´s supose that you have a query returning something that is not represented by any of your domain classes. Do yo...
(N)Hibernate - is it possible to dynamically map multiple tables to the one class
|c#|nhibernate|orm|hibernate|gis|
I have the situation where i use GIS software which stores the information about GIS objects into separate database table for each type/class of GIS object (road, river, building, sea, ...) and keeps the metadata table in which it stores info about the class name and its DB table. Those GIS objects of different clas...
Maybe try [campfire][1] or [basecamp][2]. [1]: http://www.campfirenow.com/ [2]: http://www.basecamphq.com/
this is VB.NET code to check for any removable drives or CDRom drives attached to the computer: Me.lstDrives.Items.Clear() For Each item As DriveInfo In My.Computer.FileSystem.Drives If item.DriveType = DriveType.Removable Or item.DriveType = DriveType.CDRom Then Me.lstDrives.Items.Add...
[JUNG][1] is a good option for visualisation, and also has a fairly good set of available graph algorithms, including several different mechanisms for random graph creation, rewiring, etc. I've also found it to be generally fairly easy to extend and adapt where necessary. [1]: http://jung.sourceforge.net/
Cross-platform space remaining on volume using python
Using MAPI functions from within managed code is officially unsupported. Apparently, MAPI uses its own memory management and it crashes and burns within managed code (see [here](http://blogs.msdn.com/pcreehan/archive/2007/05/04/what-does-unsupported-mean.aspx) and [here](http://blogs.msdn.com/mstehle/archive/2007/10/03...
System.Web.Caching vs. Enterprise Library Caching Block
|caching|.net-2.0|enterpriselibrary|
For a .NET component that will be used in both web applications and rich client applications, there seem to be two obvious options for caching: System.Web.Caching or the Ent. Lib. Caching Block. - What do you use? - Why? ## [System.Web.Caching](http://msdn.microsoft.com/en-us/library/system.web.caching.aspx) ...
|.net-2.0|caching|enterpriselibrary|
|.net-2.0|caching|memcached|enterpriselibrary|
|.net-2.0|caching|enterprise-library|memcached|
For a .NET component that will be used in both web applications and rich client applications, there seem to be two obvious options for caching: System.Web.Caching or the Ent. Lib. Caching Block. - What do you use? - Why? ## [System.Web.Caching](http://msdn.microsoft.com/en-us/library/system.web.caching.aspx) ...
|php|cakephp|permissions|acl|
Is this what you are looking for? private List<ErrorItem<object>> _allObjects = new List<ErrorItem<object>>(); public IEnumerable<ErrorItem<A>> ItemsOfA { get { foreach (ErrorItem<object> obj in _allObjects) { if (obj.Item is A) ...
<code><pre> \#include &lt;string> \#include &lt;boost/next_prior.hpp> void reverse(std::string& foo) { using namespace std; reverse(foo.begin(), foo.end()); string::iterator begin = foo.begin(); while (1) { std::string::iterator space = find(begin, foo.end(), ' '); std::reverse(...
<code><pre> \#include &lt;string> \#include &lt;boost/next_prior.hpp> void reverse(std::string& foo) { using namespace std; std::reverse(foo.begin(), foo.end()); string::iterator begin = foo.begin(); while (1) { string::iterator space = find(begin, foo.end(), ' '); std::reverse(...
Sarcastic's reply is so much better than mine, but if you were working with filesystem paths, my **ugly hack below** could turn out to be useful too. (Translation: I typed it, so I'll be damned if I don't post it :) Path.Combine just slaps two strings together, paying attention to leading or trailing slashes. As far...
Tracking Refactorings in a Bug Database
|refactoring|bug-tracking|