instruction stringlengths 0 30k ⌀ |
|---|
|oop|architecture|theory| |
I'm trying to boil down the concepts of coupling and cohesion to a concise definition. Can someone give me a short and understandable explanation (shorter than the definitions on Wikipedia [here](http://twurl.cc/4cx) and [here](http://twurl.cc/4cw))? How do they interact?
Thanks.
Anybody have a good, short exampl... |
Well, I don't think that there is something like that in js. You can always use eval instead of locals(). Like this:
eval(s+"()");
You just have to know that actually function *foo* exists. |
Well, I don't think that there is something like that in js. You can always use eval instead of locals(). Like this:
eval(s+"()");
You just have to know that actually function *foo* exists.
**Edit:**
Don't use eval:) Use:
var functionName="myFunctionName";
window[functionName](); |
AFAIK, no. If you just want to check the existence of a given variable, you can do it by testing for it, something like this:
if (foo) foo(); |
group_concat query performance |
|mysql|sql|performance| |
i am having serious performance problems (queries up to 55 seconds) while running a mysql query since i added a group_concat clause.
my query looks like:
select ... group_concat(distinct category.name) .... from page where
left outer join page_category on page.id = story_category.page_id
left ou... |
|visual-studio|vbscript| |
How two merge two projects in Mercurial. |
|mercurial| |
I have two separate mercurial repositories. At this point it makes sense that they "become one" because I want to work on the two projects simultaneously.
I'd really like the two projects to each be a subdirectory in the new repository.
1. How do I merge the two projects?
2. Is this a good idea, or should I
... |
I have two separate mercurial repositories. At this point it makes sense that they "become one" because I want to work on the two projects simultaneously.
I'd really like the two projects to each be a subdirectory in the new repository.
1. How do I merge the two projects?
2. Is this a good idea, or should I
... |
How two combine two projects in Mercurial? |
How to combine two projects in Mercurial? |
Take a look at [memcached][1]. It is a really cool, fast and lightweight distributed caching system. There are APIs for several of the most popular languages, including C#. It may not serve well on the client side (unless of course the client is obtaining the cached data from a server of some kind), but if you abstr... |
We actually just released some classes that help with exactly this kind of thing:
[http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=16449][1]
Specifically, check out the DatabaseImage sample.
[1]: http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=16449 |
Add a 'Generic Handler' to your web project, name it something like Image.ashx. Implement it like this:
public class ImageHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
using(Image image = GetImage(context.Request.QueryString["ID"]))
... |
Add the code to a handler to return the image bytes with the appropriate mime-type. Then you can just add the url to your handler like it is an image. For example:
<img src="myhandler.ashx?imageid=5">
Make sense? |
[@Clayton][1]: Do what? I can't believe, at this point, that your answer has 2 up-votes, considering you cannot overload operators in current, common browser-based implementations of JavaScript interpreters (i.e. neither you nor those that have up-voted your response know JavaScript very well).
To answer the origina... |
[@Clayton][1]: Do what? I can't believe, at this point, that your answer has 2 up-votes, considering you cannot overload operators in current, common browser-based implementations of JavaScript interpreters (i.e. neither you nor those that have up-voted your response know JavaScript very well).
To answer the origina... |
[@Clayton][1]: Do what? I can't believe, at this point, that your answer has 2 up-votes, considering you cannot overload operators in current, common browser-based implementations of JavaScript interpreters (i.e. neither you nor those that have up-voted your response know JavaScript very well).
To answer the origina... |
Clean the data before you store it. Generally you shouldn't be preforming **ANY** SQL actions without first cleaning up input. You don't want to subject yourself to a SQL injection attack.
I sort of follow these basic rules.
1. Only do modifying SQL actions, such as, INSERT, UPDATE, DELETE through POST. Never G... |
Users are evil!
Well perhaps not always, but my approach is to always sanatize immediately to ensure nothing risky goes anywhere near my backend.
The added benefit is that you can provide feed back to the user if you sanitize at point of input. |
I also found that this will work too.
System.Collections.IDictionaryEnumerator enumerator = hashTable.GetEnumerator();
while (enumerator.MoveNext())
{
string key = enumerator.Key.ToString();
string value = enumerator.Value.ToString();
Console.WriteLine(("Key = '{0... |
Do you actually have the single quotes in your command? I don't think they are necessary. Plus, I think you also need <code>--no-auth-cache</code> and <code>--non-interactive</code>
Here is what I use (no single quotes)
<pre>
--non-interactive --no-auth-cache --username XXXX --password YYYY
</pre>
See the <a h... |
I don't know if this is allowed but the best approximation I can find is:
Establish a fixed period of time to open each box and a precise order for opening them. That means, the prissioner will open the first 50 boxes, opening one box every minute. If the next prisioner have to come in at minute 13, then the previou... |
I don't know if this is allowed but the best approximation I can find is:
EDIT: Ok, I think this makes it. Of course I'm treating this as a computing problem, I don't think any prisioner will be able to perform this, although is pretty straight forward if you don't.
Find the first 50 primes, let's asume we hold t... |
Is something like [Gears][1] acceptable. This will let you store data locally to limit re-requests.
[1]: http://gears.google.com/ |
Is something like [Gears][1] acceptable. This will let you store data locally to limit re-requests.
I would also stay away from flash and silverlight and go straight to javascript/AJAX. JQuery is a ton-O-fun.
[1]: http://gears.google.com/ |
Why is pagination so resource-expensive? |
|pagination| |
It's one of those things that seems to have an odd curve where the more I think about it, the more it makes sense. To a certain extent, of course. And then it doesn't make sense to me at all.
Care to enlighten me? |
|pagination| |
|performance|pagination| |
[Lubos](http://stackoverflow.com/questions/29580/why-is-pagination-so-resource-expensive#29588) is right, the problem is not the fact that you are paging (which takes a HUGE amount of data off the wire), but that you need to figure out what is actually going on the page..
The fact that you need to page implies there... |
[Peter's answer](http://stackoverflow.com/questions/29004/parsing-xml-using-unix-terminal#29023) is correct, but it outputs a trailing line feed.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:template match="root">
<xsl:for... |
If you have no choice but to use MSTest, learn the keyboard shortcuts. They'll make your life a little easier.
Test in Current Context: CTRL+R, T
All Tests in Solution: CTRL+R, A
Debug Tests in Current Context: CTRL+R, CTRL+T
Debug All Tests in Solution: CTRL+R, CTRL+A
|
The view state only lasts for [multiple requests for the same page][1]. Changing the query string in the URL is requesting a new page, thus clearing the view state.
Is it possible to remove the reliance on the view state by adding more query string parameters? You can then build a new URL and Response.Redirect to it... |
I recommend checking out the book referenced by jko:
> a book from The Pragmatic Bookshelf called [Stripes: ...and Java web development is fun again][1]
Whilst still in 'beta' the book covers everything very well.
Another good place to start is [this ONJava article][2].
I have used Stripes on a few project... |
Working copies are sticky to a branch by definition, as changing to a different branch means changing the base-Subversion-URL used to access the repository.
However sticky-revision files... that's not a concept that Subversion has.
See appendix A of the subversion book: [Subversion for CVS Users][1]
One workarou... |
Working copies are sticky to a branch by definition, as changing to a different branch means changing the base-Subversion-URL used to access the repository.
However sticky-revision files... that's not a concept that Subversion has.
See:
- Appendix A of the subversion book: [Subversion for CVS Users][1]
- [S... |
**Short answer:** no.
**Long answer:**
Working copies are sticky to a branch by definition, as changing to a different branch means changing the base-Subversion-URL used to access the repository.
However sticky-revision files... that's not a concept that Subversion has.
See:
- [Subversion update command... |
**Short answer:** no.
**Long answer:**
Working copies are sticky to a branch by definition, as changing to a different branch means changing the base-Subversion-URL used to access the repository.
However sticky-revision files... that's not a concept that Subversion has.
See:
- [Subversion update command... |
What's the best way to implement an 'enum' in Python? |
|python|enums| |
I'm mainly a C# developer, but I'm currently working on a project in Python.
What's the best way to implement the equivalent of an enum in Python? |
EDIT: You cannot overload operators in current, common browser-based implementations of JavaScript interpreters.
To answer the original question, one way you could do this, and mind you, this is a bit of a hack, simply [serialize the two arrays to JSON][2] and then compare the two JSON strings. That would simply tel... |
@[Darren][1], Upon further examination, I've come to the conclusion that one assumption I had about *needing* Read permissions was incorrect.
SOAP web services only need the "Run scripts" permission enabled because the .wsdl apparently comes from the web service in the form of a script execution response. So the mini... |
if you have phpMyAdmin installed, it is a nobrainer: Run the query (haven't got a copy loaded, so I can't tell you the details, but it really is easy) and check neer bottom for export options. CSV will be listed, but I think you can also have SQL if you like :)
phpMyAdmin will give CSV in Excels dialect, which is pr... |
You could also consider [Grails][1] ("Groovy on Rails") which gives you the benefits of a Rails framework and the use of the Java VM.
[1]: http://grails.org/ |
>>In addition to allowing full control to "Everyone" does the location also allow processes with a medium integrity level to write?
>How do I check that ? I am new to Vista, I don't like it too much, it's too slow inside a VM for daily work and for VStudio usage inside a Virtual Machine, it doesn't bring anything ne... |
Crop MP3 to first 30 seconds |
|mp3| |
**Original Question**
I want to be able to generate a new (fully valid) MP3 file from an existing MP3 file to be used as a preview -- try-before-you-buy style. The new file should only contain the first *n* seconds of the track.
Now, I know I could just "chop the stream" at *n* seconds (calculating from the bitra... |
|mp3|ffmpeg| |
**Original Question**
I want to be able to generate a new (fully valid) MP3 file from an existing MP3 file to be used as a preview -- try-before-you-buy style. The new file should only contain the first *n* seconds of the track.
Now, I know I could just "chop the stream" at *n* seconds (calculating from the bitra... |
Do you want the decimal or not?
if not use
select ceiling(@value),floor(@value)
if you do with 0 the do a round
select round(@value,2)
|
You're worrying too much about internal implementation details. Don't pre-optimize.
Go with VARCHAR(500) |
Can I put an ASP.Net session ID in a hidden form field? |
|asp.net|session|yui| |
|asp.net|hacking|session|yui| |
I don't know if this is allowed but the best approximation I can find is:
EDIT: Ok, I think this makes it. Of course I'm treating this as a computing problem, I don't think any prisioner will be able to perform this, although is pretty straight forward if you don't.
Find the first 50 primes, let's asume we hold t... |
I don't know if this is allowed but the best approximation I can find is:
EDIT: Ok, I think this makes it. Of course I'm treating this as a computing problem, I don't think any prisioner will be able to perform this, although is pretty straight forward if you don't.
Find the first 50 primes, let's asume we hold t... |
I don't know if this is allowed but the best approximation I can find is:
EDIT: Ok, I think this makes it. Of course I'm treating this as a computing problem, I don't think any prisioner will be able to perform this, although is pretty straight forward if you don't.
Find the first 50 primes, let's asume we hold t... |
What is a 'closure'? |
|functional-programming|terms|computer-science| |
I asked a question about Currying and closures where mentioned.
What is a closure? How does it relate to currying? |
What is a 'Closure'? |
|functional-programming-t|computer-science| |
|functional-programming|terms|computer-science| |
|functional-programming|computer-science|programming-terms| |
|functional-programming|computer-science|programming-terms|glossary| |
|functional-programming|computer-science|glossary|programming-terms| |
I asked a question about Currying and closures where mentioned.
What is a closure? How does it relate to currying?
Additional:
Kyle's answer is great but to my poor procedural/OO mind Ben Childs answer is really useful. |
The only way to really know is to test it, and the answer may even vary depending on what compiler and platform you are on. Modern compilers are _really_ good at optimizing code these days, and you should never try to outsmart the compiler unless you can prove that your way is really faster.
With that said, you'd b... |
OK my verdict :-) : I have used successfully zend without mod_rewrite and it's as you've all said site/index.php/controller/action. I knew that before posting this. I've also found out around the net a technique that "pushes" 404 pages to index.php therefore what is not a resource (eg. CSS, image, etc) gets there, with... |
You will want to wire your URL to the Django [create_object generic view][1], and pass it either "model" (the model you want to create) or "form_class" (a customized [ModelForm][2] class). There are a number of [other arguments][1] you can also pass to override default behaviors.
Sample URLconf for the simplest cas... |
Yes, with --slave-skip-errors=xxx in my.cnf, where xxx is 'all' or a comma sep list of error codes. |
Be aware that TFS does not support sharing files between different projects, as VSS does. If you have any such shared files the link between them will be broken during the migration, resulting in initially identical, but now distinct files in each project. Updates to one of these files in TFS will no longer propagate t... |
something like this?
var myList = new List<string> { "a","b","c" };
var items = from item in db.Items
where myList.Contains(item.Name)
select item;
that would create a sql statement like
SELECT * FROM Items [t0] where Name IN ('a','b','c') |
Good Mercurial repository viewer for Mac |
|mercurial| |
Is there a good, native Mac tool to view Mercurial repositories, similar to gitnub for Git? |
Use [a symbolic link][1]. :)
[1]: http://tinyurl.com/63z9hp |
I would suggest you start by removing the UpdatePanels at first, and make sure your control orgy is working correctly with postbacks. Once you have that working, try adding the UpdatePanels back in from the bottom up. |
Supposing you can create a common repository for all your projects (a common folder in your source control tree, for example), you could add the master pages as links by using relative paths.
However, IIRC, Visual Studio makes local copies of files added from external paths. You might have to text-edit the solution... |
This site looks promising: http://snipplr.com/view/6889/regular-expressions-for-uri-validationparsing/
They propose following regex:
/^([a-z0-9+.-]+):(?://(?:((?:[a-z0-9-._~!$&'()*+,;=:]|%[0-9A-F]{2})*)@)?((?:[a-z0-9-._~!$&'()*+,;=]|%[0-9A-F]{2})*)(?::(\d*))?(/(?:[a-z0-9-._~!$&'()*+,;=:@/]|%[0-9A-F]{2})*)?|(... |
Performance vs Readability |
|performance| |
Reading [this question][1] I found this as (note the quotation marks) "code" to solve the problem (that's perl by the way).
100,{)..3%!'Fizz'*\5%!'Buzz'*+\or}%n*
Obviously this is an intelectual example without real (I hope to never see that in real code in my life) implications but, when you have to make th... |
|performance|fix-typo| |
The best place to start with getting control of your email is definitely Merlin Mann's excellent [Inbox Zero][1] series. In particular his [Google Tech Talk video][2] is a great talk.
[1]: http://www.43folders.com/izero
[2]: http://video.google.com/videoplay?docid=973149761529535925&hl=en |
Maybe try a parallelizing utility instead rewriting the loop? I'm a big fan of xjobs. I use xjobs all the time to mass copy files across our network, usually when setting up a new database server.
<http://www.maier-komor.de/xjobs.html> |
If you don't want to actually clear out your inbox, you could use a good search utility like Google Desktop, Yahoo Desktop Search (is that what it's called) or my current favorite, Xobni.
With these tools you don't have to worry about where you put the mails you saved. Just save them all and let the tools find it. |
Instead of a plain bash, use a Makefile, then specify number of simultaneous jobs with `make -jX` where X is the number of jobs to run at once. |
Instead of a plain bash, use a Makefile, then specify number of simultaneous jobs with `make -jX` where X is the number of jobs to run at once.
Or you can use `wait` ("`man wait`"): launch several child processes, call `wait` - it will exit when the child processes finish.
maxjobs = 10
foreach line in ... |
How do I unit test a WCF service? |
|wcf|unit-testing| |
We have a whole bunch of DLLs that give us access to our database and other applications and services.
We've wrapped these DLLs with a thin WCF service layer which our clients then consume.
I'm a little unsure on how to write unit tests that only test the WCF service layer. Should I just write unit tests for the ... |