instruction stringlengths 0 30k ⌀ |
|---|
**High Resolution, Low Overhead Timing for Intel Processors**
If you're on Intel hardware, here's how to read the CPU real-time instruction counter. It will tell you the number of CPU cycles executed since the processor was booted. This is probably the finest-grained counter you can get for performance measurement... |
Easy to oversee and easy to fix: the sanitizing of data received from the client side. Checking for things such as ';' can help in preventing malicious code being injected into your application. |
Supports classes, methods, attributes, encapsulation, data hiding, inheritance, polymorphism, abstraction...? |
A [Match][1] is an object that indicates a particular regular expression matched (a portion of) the target text. A [Group][2] indicates a portion of a match, if the original regular expression contained group markers (basically a pattern in parentheses). For example, with the following code:
string text = "One c... |
You can never ask too many or "stupid" questions. The more questions you ask, the more answers you receive. |
[Here][1] is a YUI compressor script ([Byuic][2]) that finds all the js and css down a path and compresses /(optionally) obfuscates them. Nice to integrate into a build process.
[1]: http://brilaps.com/index.php?content=byuic "Here"
[2]: http://brilaps.com/index.php?content=byuic "Byuic" |
See obligatory comic below...
In general, I try and get a feel for the business model my customer/client is trying to emulate with the application they want built. Are we building a glorified forms processor? Are we retrieving data from multiple sources in a single application to save time? Are we performing some ki... |
You're almost certainly missing something. A lot of things, probably. Don't worry, it's ok. Even if you remembered everything and covered all the bases stakeholders aren't going to be able to give you very good, clear requirements without any point of reference. The best way to do this sort of thing is to get what ... |
What you are asking for is a level of optimisation the linq-to-sql does not provide. I think your best bet is to create a query that returns exactly the data you want, possibly as an anonymous type:
from order in DB.GetTable<Orders>()
join product in DB.GetTable<Products>()
on order.ProductID = product... |
As a junior programmer, I'm still trying to get into the habit of writing tests. Obviously it's not easy to pick up new habits, but thinking about what would make this work for me, I have to +1 the comments about code reviews and coaching/pair programming.
It may also be worth emphasising the long-term purpose of te... |
I agree that you should definitely put this logic behind the clean interface of:
public String lookupDays(String group, String date);
but maybe you should stick the data in a properties file. I'm not against hardcoding this data in your source files but, as you noticed, Java can be pretty wordy when it comes... |
I believe whenever there is only 1 option, it will definitely stagnate innovation. If all we had was 1 language, then we wouldn't be able to solve anything but what that language was designed to solve.
Imperative languages like Java and C# solve a certain set of problems pretty well, but it also helps to think in a... |
No. Competition is good. It may make a web developers job easier, but I think it's bad for the industry. I personally prefer having choices.
I believe Joel Spolsky's technique of creating his own language (Wasabi) to insulate his company from being platform specific is a good one. I also believe it is a good ... |
Add a "Setup Project" project to your solution. New Project > Other Project Types > Setup and Deployment. You can then choose what is installed and where. |
There is [DiffMerge from SourceGear][1]. It's pretty good. Araxis Merge is one of the programs I miss from Windows. I wonder if it works under Wine ;) Might have to give it a try
[1]: http://www.sourcegear.com/diffmerge/ |
Some compilers support "%b" although that is not a standard.
Also see here for an interesting discussion:
http://bytes.com/forum/thread591027.html
HTH |
Some runtimes support "%b" although that is not a standard.
Also see here for an interesting discussion:
http://bytes.com/forum/thread591027.html
HTH |
[BeyondCompare][1] has also just been released in a Linux version.
Not free, but the Windows version is worth every penny - I'm assuming the Linux version is the same.
[1]: http://www.scootersoftware.com/moreinfo.php |
What are the statistics of HTML vs. Text email usage |
|email| |
What the latest figures are on people viewing their emails in text only mode vs. HTML?
[Wikipedia][1] and it's [source][2] both seem to reference [this][3] research from 2006.
[1]: http://en.wikipedia.org/wiki/Html_email
[2]: http://www.emaillabs.com/tools/email-marketing-statistics.html
[3]: http://www... |
What the latest figures are on people viewing their emails in text only mode vs. HTML?
[Wikipedia][1] and it's [source][2] both seem to reference [this][3] research from 2006 which is an eternity ago in internet terms.
An issue with combining both HTML and text based emails is taking a disproportionate amount of ... |
Tools -> Import and Export Settings.. -> [X] Import Selected ... -> Save Current -> Choose options you wish to change |
You might be able to get a handle to the file if you try opening the file after converting the file name to a short (8.3) file name. Failing that can you map the dir the file is in as a drive and access the file that way? |
Subclipse for Eclipse has an excellent graphical diff plugin if you are using SVN (subversion) source control. |
How do I add another run level (level 7) in Ubuntu? |
|ubuntu|runlevel|upstart| |
Ubuntu has 8 run levels (0-6 and S), I want to add the run level 7.
I have done the following:
1.- Created the folder **/etc/rc7.d/**, which contains some symbolic links to **/etc/init.d/**
2.- Created the file **/etc/event.d/rc7** This is its content:
# rc7 - runlevel 7 compatibility
#
# This... |
According to Booch, the following elements:
Major:
* Abstraction
* Encapsulation
* Modularity
* Hierarchy (Inheritance)
Minor:
* Typing
* Concurrency
* Persistence |
I use [**ShrinkSafe** from the Dojo project][1] - it is exceptional because it actually uses a JavaScript interpreter ([Rhino][2]) to deal with finding symbols in the code and understanding their scope, etc. which helps to ensure that the code will work when it comes out the other end, as opposed to a lot of compressio... |
I use [**ShrinkSafe** from the Dojo project][1] - it is exceptional because it actually uses a JavaScript interpreter ([Rhino][2]) to deal with finding symbols in the code and understanding their scope, etc. which helps to ensure that the code will work when it comes out the other end, as opposed to a lot of compressio... |
I use [**ShrinkSafe** from the Dojo project][1] - it is exceptional because it actually uses a JavaScript interpreter ([Rhino][2]) to deal with finding symbols in the code and understanding their scope, etc. which helps to ensure that the code will work when it comes out the other end, as opposed to a lot of compressio... |
I found this solution that generates a random hex encoded string. The provided unit test seems to hold up to my primary use case. Although, it is slightly more complex than some of the other answers provided.
/**
* Generate a random hex encoded string token of the specified length
*
* @para... |
right click on the folder you want to download in, and open up "tortoise-svn -> repo-browser".
Enter in the URL above in the next window.
right click on the "trunk" folder and choose either "checkout" (if you want to update from SVN later) or "export" (if you just want your own copy of that revision).
|
Traditional ASP .NET vs MVC |
|asp.net|asp.net-mvc|classicasp| |
As someone with some winforms and client applications experience - is it worth going back and learning the way traditional ASP .NET pages work, or is it okay with moving straight into ASP .NET MVC?
I'm kind of looking for pitfalls or traps in my knowledge of general C#, that I won't know from the screencast series a... |
|asp.net|asp.net-mvc|webforms| |
|asp.net|mvc|webforms| |
There's nothing that will automatically do what you want.
However, there is a python zipfile module that will make this easy to do. Here's how to iterate over the lines in the file.
#!/usr/bin/python
import zipfile
f = zipfile.ZipFile('myfile.zip')
for subfile in f.namelist():
pri... |
It depends on your motivations. If you're going to sell yourself as an ASP.NET developer, you will need both.
If this is just for your own pleasure, then go to MVC.
My personal feeling is that webforms will be around for quite a few years more. So many people have time and energy invested in them. However, I t... |
Plenty of things tripped me up in the beginning, but none more than simple mechanics. Concepts, I took to immediately. But miss a closing brace? Easy to do, and often hard to debug, in a non-trivial program.
So, my humble advice is: don't understimate the basics (like good typing). It sounds remedial, and even si... |
Plenty of things tripped me up in the beginning, but none more than simple mechanics. Concepts, I took to immediately. But miss a closing brace? Easy to do, and often hard to debug, in a non-trivial program.
So, my humble advice is: don't understimate the basics (like good typing). It sounds remedial, and even si... |
I'm totally at a loss as to why some of you seem to think that throwing gobs of objects at the code is the way to go. For example, there are exactly four seasons, and they don't *do* or *store* anything. How does it simplify anything to make them objects? Wing is quite right that these should probably be ***constant... |
You don't need to do this stuff to just run your tests.
If you're writing tests for an application, you should just need to set the _Test Host_ and _Bundle Loader_ build settings for your unit test bundle target and they will be run as part of your build. If you're writing tests for a framework you don't even need ... |
From Joshua Bloch, the Java Guru himself in Effective Java 2nd edition:
"Item 69: Prefer concurrency utilities to wait and notify". |
the problem is that you cannot use 'printf' with va_args. You must use vprintf if you are using variable argument lists. vprint, vsprintf, vfprintf, etc. (there are also 'safe' versions in Microsoft's C runtime that will prevent buffer overruns, etc.)
You sample works as follows:
void myprintf(char* fmt,... |
How can an app utilize multiple cores or CPUs in .Net or Java? |
|c#|java|multithreading|multithreaded|quadcore| |
When launching a thread or a process in .Net or Java, is there a way to choose which processor or core it is launched on? How does the shared memory model work in such cases? |
|c#|java|multithreading| |
Recommendation for 3rd party editing/syntax highlighting control - WinForms. |
|.net|winforms|components| |
I'm looking for a quality WinForms component that supports syntax highlighting, code folding and the like. The key criteria are:
1) Stability
2) Value (price)
3) Ability to easily customize syntax to highlight
4) Light weight |
It's not trivial to map them back and forth, so I doubt there's a tool that does it automatically. But this link might help you out: http://vyaskn.tripod.com/oracle_sql_server_differences_equivalents.htm |
I am guessing this is for a singleton pattern or something like it. What you want to do is not lock your object, but lock the counter while your are modifying it.
private static int counter = 0;
private static object counterLock = new Object();
lock(counterLock) {
counter++;
myCo... |
[This][1] is a very comprehensive reference.
[1]: http://www.codeproject.com/KB/dotnet/vbnet_c__difference.aspx |
I've found the answer I was looking for:
HttpResponse.RemoveOutputCacheItem("/caching/CacheForever.aspx"); |
Take a look at the [Library of Free Data Models][1]. There are tons of example database designs, with diagrams that cover real-world scenarios (and some just fun/funny ones as well). I haven't ever used one as-is, but it's often been handy to get an idea of how to approach the problem of mapping the needs of the situat... |
Both Jotspot and MediaWiki allow you to do this. The latter has support for a lot of plugins, of which this is one. The format is essentially PageTitle@something. Jotspot is a hosted solution where you get your own email address, MediaWiki is self-hosted and you give it a mailbox to monitor for incoming.
Articles ar... |
Here are some resources I could find on the web. They include examples you are looking for:
* [Designing and creating a Relational Database - Dr Lorna Scammell: Newcastle University Database Adviser](http://www.campus.ncl.ac.uk/databases/design/)
* [Sample Data Models for Relational Database Design ](http://www.dat... |
Once you get into resharper, you really don't want to leave, its done a massive amount to improve my productivity.
It depends though on what you are doing. Are you doing a lot of TDD when you write tests, write code, then refactor?
Unless you are pretty intensely into refactoring then I'd suggest that you might n... |
Frankly there is no better way.
I'm sure we could all write snippets that use clever tricks that assume limited character sets, but at the end of the day at somepoint you have to convert the characters.
The best approach for this conversion is to do so prior to the comparison. This allows you a good deal of flexi... |
Assuming you are looking for a method and not a magic function that already exists, there is frankly no better way. We could all write code snippets with clever tricks for limited character sets, but at the end of the day at somepoint you have to convert the characters.
The best approach for this conversion is to do... |
I prefer that people not use the term "scripting language" as I think that it diminishes the effort. Take a language like Perl, often called "scripting language".
* Perl is a programming language!
* Perl is compiled like Java and C++. It's just compiled a lot faster!
* Perl has objects and namespaces and closures... |
The Setup Project is the way to go. If you're going to be deploying the installer from a web site, I recommend creating an MSI file as the project output (as opposed to a Setup.exe output). Most of my clients block the download of EXE files. |
As been stated, the code actually work out the number of elements in an array, not struct. I would just write out the sizeof() division explicitly when I want it. If I were to make it a function, I would want to make it clear in its definition that it's expecting an array.
template<typename T,int SIZE>
size... |
As been stated, the code actually work out the number of elements in an array, not struct. I would just write out the sizeof() division explicitly when I want it. If I were to make it a function, I would want to make it clear in its definition that it's expecting an array.
template<typename T,int SIZE>
size... |
As been stated, the code actually work out the number of elements in an array, not struct. I would just write out the sizeof() division explicitly when I want it. If I were to make it a function, I would want to make it clear in its definition that it's expecting an array.
template<typename T,int SIZE>
inli... |
As been stated, the code actually work out the number of elements in an array, not struct. I would just write out the sizeof() division explicitly when I want it. If I were to make it a function, I would want to make it clear in its definition that it's expecting an array.
template<typename T,int SIZE>
inli... |
You can try to connect to one of well-known Web sites on a port that may not be available from outside - 200 for example. Most of firewalls work in DROP mode and it will simulate a timeout for you. |
I have found the problem - please see the adug.com.au mailing list for exact
details of the solution, but in summary -- the version of Indy that comes
with D2009 (version 10.2.5) has 2 errors in the IdMessageClient.pas unit in
two lines that set the name= and filename= in the attachment part processing
(one lin... |
Personally I would say MVC is the way to go for web sites. You have a lot more control over the HTML and CSS and at the same time the controller pattern works very well with HTTP. Event driven web programming is great for small sites or for people who are not that clued up with HTML and CSS and more low-level concepts. |
The easiest thing would be to drop your connection using [CurrPorts][1].
However, in order to unit test your exception handling code, perhaps you should consider abstracting your network connection code, and write a stub, mock or decorator which throws exceptions on demand. You will then be able to test the applicat... |
<%= is shorthand for Response.Write().
<%# indicates that you're working with the data container in a data bound control. |
You might install Microsoft Loopback driver that will create a separate interface for you. Then you can connect on it to some service of yours (your own host). Then in Network Connections you can disable/enable such interface... |
Do people use the Hungarian Naming Conventions in the real world? |
|selfdocumentingcode| |
Is it worth learning the convention or is it a bane to readability and maintainability? |
|selfdocumentingcode|hungarian| |
|hungarian|selfdocumentingcode| |
|hungarian|self-documenting-code| |
|conventions|hungarian|self-documenting-code| |
My answer to this conundrum is to have 100% line coverage of the code you can test and 0% line coverage of the code you can't test.
My current practice in Python is to divide my .py modules into two folders: app1/ and app2/ and when running unit tests calculate the coverage of those two folders and visually check (I... |
@pointernil..
It's more of no estimation coupled with a Indy-Jones Head-First approach to tackling a story. I estimate stories by their content.. currently I don't take into account the time required to find the right incantation for the control library to play nice. That sometimes takes more time than my application ... |
Python - When to use file vs open |
|python| |
What's the difference between file and open in Python? When should I use which one? (Say I'm in 2.5) |
It's possible to do without. However, you will make life hard for yourself -- your organization will want to use standard tools that live on top of DWs, and those tools will expect a star schema -- a lot of effort will be spent fitting a square peg in a round hole.
A lot of database-level optimizations assume that ... |
QT: meaning of slot return value? |
|qt| |
According to the documentation the return value from a slot doesn't mean anything.
Yet in the generated moc code I see that if a slot returns a value this value is used for something. Any idea what does it do?
|
According to the documentation the return value from a slot doesn't mean anything.
Yet in the generated moc code I see that if a slot returns a value this value is used for something. Any idea what does it do?
----
Here's an example of what I'm talking about. this is taken from code generated by moc. 'message' i... |
You should always use `open()`.
As the [documentation][1] states:
> When opening a file, it's preferable
> to use open() instead of invoking this
> constructor directly. file is more
> suited to type testing (for example,
> writing "isinstance(f, file)").
Also, python 3.0 will have `file()` [removed][2].
... |
The company [Navicat][1] has released an Oracle client for Mac (and they do a Windows version too).
It's not free, but I think you can get a 30 day demo.
[1]: http://www.navicat.com/ |
I'm gonna have to agree with Mike on this one and say that without competition there is very little incentive to innovate.
|
How many users of the app will there be? Is there possibility of using windows integrated authentication for SQL authentication? |
How many users of the app will there be? Is there possibility of using windows integrated authentication for SQL authentication?
**Updated**: If you can give each user a SQL login (windows integrated or sql) then you can pickup the logged on user using the SYSTEM_USER function.
|
How many users of the app will there be? Is there possibility of using windows integrated authentication for SQL authentication?
**Updated**: If you can give each user a SQL login (windows integrated) then you can pickup the logged on user using the SYSTEM_USER function.
|
Defacto standards are bad because they are usually controlled by a single party. What is best for the industry is for there to be a foundation of open standards on top of which everyone can compete.
The web is a perfect example. When IE won the browser war, it stagnated for _years_, and is only just now starting to... |