I'm looking for a collection that offers list semantics, but also allows array semantics. Say I have a list with the following items:
apple orange carrot pear
then my container array would:
container[0] == apple
container[1] == orangle
container[2] == carrot
Then say I delete the orange element:
container[0] == apple
container[1] == carrot
I don't particularly care if sort order is maintained, I'd just like the array values to function as accelerators to the list items, and I want to collapse gaps in the array without having to do an explicit resizing.
Hi guys,
I started to use the new ConcurrentDictionary from .Net4 yesterday to implement a simple caching for a threading project.
But I'm wondering what I have to take care of/be careful about when using it?
What have been your experiences using it?
I looking for "translator" for JavaScript like already is CoffeScript, which will be work for example with forEach (inspired by Groovy)
myArray.forEach() -> val, idx {
// do something with value and idx
}
translate to JavaScript
myArray.forEach(function(val, idx){
// do something with value and idx
});
or something more usefull...
function event(cb){
foo()-> err, data1;
bar(data1)-> err, data2;
cb(data2);
}
the method are encapsulated
function event(cb){
foo(function(err,data1){
bar(data1, function(err, data2) {
cb(data2);
});
});
}
I want ask if similar "compiler" to JavaScript like this even better already doesn't exists?
What would be super cool... my code in nodejs looks mostly like this :-)
function dealer(cb){
async.parallel([
function(pcb){
async.watterfall([function(wcb){
first(function(a){ wcb(a); });
}, function(a, wcb){
thirt(a, function(c){ wcb(c); });
fourth(a, function(d){
// dealing with “a” as well and nobody care my result
});
}],
function(err, array_with_ac){
pcb(array_with_ac);
});
}, function(pcb){
second(function(b){ pcb(b);});
}], function(err, data){
cb(data[0][0]+data[1]+data[0][1]); // dealing with “a” “b” and “c” not with “d”
});
}
but, look how beautiful and readable the code could be:
function dealer(cb){
first() -> a;
second() -> b;
third(a) -> c; // dealing with “a”
fourth(a) -> d; // dealing with “a” as well and nobody care about my result
cb(a+b+c); // dealing with “a” “b” and “c” not with “d”
}
yes this is ideal case when the translator auto-decide, method need to be run as parallel and method need be call after finish another method. I can imagine it's works
Please, do you know about something similar? Thank you for any advice;-)
So my question is simple, and I guess it boils down to how anal you want to be about collision detection. To keep things simple, lets assume we're talking about 2D sprites defined by a bounding box. In addition, let's assume that my sprite object has a function to detect collisions like this: S.collidesWith(other); Finally the scene is moving and "walls" in the scene can move, an object may not touch a wall.
So a simple implementation might look like this (psuedo code):
moveWalls();
moveSprite();
foreach(wall as w) {
if(s.collidesWith(w)) {
gameover();
}
}
The problem with this is that if the sprite and wall move towards each other, depending on the circumstances (such as diagonal moment). They may pass though each other (unlikely but could happen).
So I may do this instead.
moveWalls();
foreach(wall as w) {
if(s.collidesWith(w)) {
gameover();
}
}
moveSprite();
foreach(wall as w) {
if(s.collidesWith(w)) {
gameover();
}
}
This takes care of the passing through each other issue, but another rare issue comes up. If they are adjacent to each other (literally the next pixel) and both the wall and the sprite are moving left, then I will get an invalid collision since the wall moves, checks for collision (hit) then the sprite is moved. Which seems unfair. In addition, to that, the redundant collision detection feels very inefficient. I could give the player movement priority alleviating the first issue but it is still checking twice.
moveSprite();
foreach(wall as w) {
if(s.collidesWith(w)) {
gameover();
}
}
moveWalls();
foreach(wall as w) {
if(s.collidesWith(w)) {
gameover();
}
}
Am I simply over thinking this issue, should this just be chalked up to "it'll happen rare enough that no one will care"? Certainly looking at old sprite based games, I often find situations where the collision detection has subtle flaws, but I figure by now we can do better :-P. What are people's thoughts?
I want to react when somebody shakes the iPhone. I don't particularly care how they shake it, just that it was waved vigorously about for a split second. Does anyone know how to detect this?
I m trying to invoke a URL in C#, I am just interested in invoking, and dont care about response. When i have the following, does it mean that I m invoking the URL?
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
Let's say I have programmers and artists working on a project. The artists have some folders they care about:
/Doodles
/Images/Jpgs
And maybe the programmers have a folder like this:
/Code/View/Jpgs
What is the best process in Mercurial to keep the 2 Jpgs folders synced? I have used Vault, where you can have 2 or more files/folders linked in a repository so updating one updates another. Is there a way to do the same thing with Mercurial?
I want to get, via ajax, a collection of data objects and parse them into JS data.
Currently I have 2 choices:
- Server returns valid javascript code and then I eval it.
- Server returns JSON object and then I eval the json object
What is the fastest of these in Firefox? (I only care about the "parsing" performance, not server or data transfer)
var phoneBookTableValue = [];
phoneBookTableValue.push({ "key":"1", "value":["3396,Accounting ,CCH,,,,","1"]});
phoneBookTableValue.push({ "key":"2", "value":["3284,Acute Care ,CCH,,,,","2"]});
phoneBookTableValue.push({ "key":"3", "value":["3265,Acute'Care East ,CCH,,,,","3"]});
When running the javascript file I get the error "missing ] after element list. Can U help me? PLZ!
I'm not a usability specialist, and I really don't care to be one.
I just want a small set of rules of thumb that I can follow while coding my User Interfaces so that my product has decent usability.
At first I thought that this question would be easy to answer "Use your common sense", but if it's so common among us developers we wouldn't, as a group, have a reputation for our horrible interfaces.
Any Suggestions?
ISO 8601 and RFC 3339 seem to be two formats that are common the web. Should I use one over the other? Is one just an extension? Do I really need to care that bad?
Could someone provide a link to a good coding standard for Haskell? I've found this and this, but they are far from comprehensive. Not to mention that the HaskellWiki one includes such "gems" as "use classes with care" and "defining symbolic infix identifiers should be left to library writers only."
how to force HTTP_DOWNLOAD not to resume downloads ( for free unpaid members for example ,but i'll take care of this ) .. I tried to miss with the range commands , I got it not resuming but in the same time doesn't send the file size and the user will not know how % has completed or how big the file is ....
any help is appreciatd
I need to write some coding style convention document in C++ for my team, is there any example or reference how such document is made, what should I define? which convention is should be avoided? is there any C++ coding style standard defined somewhere? or care to share some if you have one?
*note: I know its been asked many time, but what I need is something like this http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html but specifically for C++
Rails routes are great for matching RESTful style '/' separated bits of a URL, but can I match query parameters in a map.connect config. I want different controllers/actions to be invoked depending on the presence of a parameter after the '?'.
I was trying something like this...
map.connect "api/my/path?apple=:applecode", :controller = 'apples_controller', :action = 'my_action'
map.connect "api/my/path?banana=:bananacode", :controller = 'bananas_controller', :action = 'my_action'
For routing purposes I don't care about the value of the parameter, as long as it is available to the controller in the 'params' hash
Coming from Eclipse/Java, I noticed that in VisualStudio/C# it is not mandatory to care about Exceptions. While Eclipse forces the user to implement a try-catch-block or to add a throws declaration, this is not the case in Visual Studio.
What is the reason Visual Studio doesn't inform about unhandled exceptions?
Can I configure Visual Studio to force me to implement try-catch-blocks, or at least add a compiler-warning?
What is the ending 'r' for and the leading 'd' for in file permissions on Linux?
Example:
drwxr-xr-x
I know about the user, group, others part, and I know w=write, r=read, x=execute.
But I don't know about the leading 'd' and the trailing 'r'.
Care to explain?
Thanks
Would it be possible to run ssh-keygen without human interaction?
I have a shell script that takes care of server deployment from start to finish, but ssh-keygen is the only remaining piece that still requires my input.
Would it be possible to feed the parameters to it?
Or is there something similar to debconf-set-selections that could be used for this?
*running Debian
For years I've been piping out to sendmail in my Perl programs to send email, but I have the strong sense I ought to use a module. It would make me feel less dirty.
Care to recommend me one module over the others, with reasons why? Thanks in advance!
What is a good light weight JavaScript IDE?
I don't care too much for the one built into VS because it seams lacking.
I've been using 1st JavaScript Editor Pro as a alternative for working with JavaScript but I wanted to see if there is any thing else out there that is better and light weight.
I have an asp.net website which as part of a wizard uses an embedded google map to select a location by clicking on the map to place a marker. How do I automate this with Selenium?
In particular I've tried:
ClickAt
DoubleClickAt
MouseDownAt
MouseUpAt
In all cases passing the map div id as the locator and "100,100" as the coordinate.
I don't care where on the map the marker is placed, as long as I can place that marker.
In the case where Dictionary<object, object> myDictionary happens to contain a single item, what is the best way to retrieve the value object (if I don't care about the key) ?
if (myDictionary.Count == 1)
{
// Doesn't work
object obj = myDictionary.Values[0];
}
Thanks
In non-ARC code retained properties handily take care of memory management for you using the self.property = syntax, so we were taught to use them for practically everything.
But now with ARC this memory management is no longer an issue, so does the reason for using properties evaporate? is there still any good reason (obviously other than providing public access to instance variables) to use properties anymore?
I'm looking at putting together a high-performance multi-threaded iPhone app that's doing a couple of fairly high-intensity operations concurrently. Is the performance difference between NSThread and POSIX threading enough to care about here? If so, I would assume POSIX threads would be more efficient because it bypasses the obj-c overhead. Is this correct?