|
Quick question: I've started watching some of MIT's Open Courseware lectures on computer science. They're pretty cool but as you can see here, not that many of the courses are available in video lecture form. Is there another OCW-type program that has better CS materials?
|
# ? Sep 27, 2009 20:18 |
|
|
# ? May 14, 2024 10:00 |
|
Triple Tech posted:People who don't know anything about the construction of virtual products think they can be made in Internet time. Try reading my post next time. I said I didn't know how to code; I never said that I hadn't asked someone who does how long my idea would take to make.
|
# ? Sep 27, 2009 20:23 |
|
Eclipse12 posted:Try reading my post next time. I said I didn't know how to code; I never said that I hadn't asked someone who does how long my idea would take to make. That's right, you never said it. No one can read your post and figure out what you didn't say. Hope you're better with software requirements than with forum posting!
|
# ? Sep 27, 2009 20:34 |
|
Eclipse12 posted:Try reading my post next time. I said I didn't know how to code; I never said that I hadn't asked someone who does how long my idea would take to make. I did read your post, that's why I asked for clarification
|
# ? Sep 27, 2009 20:50 |
|
Eclipse12 posted:Try reading my post next time. I said I didn't know how to code; I never said that I hadn't asked someone who does how long my idea would take to make. Here's another thing you didn't say: what the project actually is.
|
# ? Sep 27, 2009 21:02 |
|
floWenoL posted:Here's another thing you didn't say: what the project actually is. See, this is what I wanted to avoid. All I was really wondering was where I should post if I'm looking for work on a project. I didn't want to make a new thread for it if that's not how things are done here. I've never come to the PC forum before, so I didn't know the ettiquette and wanted to check before making a new post about it.
|
# ? Sep 27, 2009 21:17 |
|
Eclipse12 posted:I've never come to the PC forum before, so I didn't know the ettiquette and wanted to check before making a new post about it. Well one bit of etiquette is not to ask non-programming questions in the programming questions thread! It honestly would have been less bad if you'd just made a thread. Not that this is to imply that we wouldn't make fun of you in a different thread.
|
# ? Sep 27, 2009 21:24 |
|
Probably a really stupid question, but I have a question about for-each loops. I fully understand how to use them and what they do, but is there any reason (above readability) to use one in place of, say, a for loop stepping through an array? Is there a performance improvement either way? Edit: I'm more specifically talking about Java here, if that makes any difference.
|
# ? Sep 28, 2009 14:25 |
|
Flamadiddle posted:I fully understand how to use them and what they do, but is there any reason (above readability) to use one in place of, say, a for loop stepping through an array? Is there a performance improvement either way? Readability is a fantastic reason to write code that way. I highly doubt there will be significant performance overheads either way. Optimization: Just say no. Edited to Add: Accessing by index might be faster in theory, but the code will have to do boundary checks and the compiler will have to eliminate them. Meanwhile inlining iteration is simpler. On the whole I doubt that what the code compiles to will look significantly different, if at all different (depending on the data type) Besides you should be using collections and avoid arrays
|
# ? Sep 28, 2009 15:40 |
|
Thanks for that. Will go and read up on collections this evening.
|
# ? Sep 28, 2009 16:32 |
|
for-each is also good for iterating over anything that inherits from Collection such as maps, sets, linked lists, etc. I think for-each is best when you just want to access and modify each element but not when you want to delete it. In that case you will run into concurrent modification exceptions.
|
# ? Sep 28, 2009 18:29 |
|
RussianManiac posted:anything that inherits from Collection such as maps quote:I think for-each is best when you just want to modify each element but not when you want to delete it. quote:In that case you will run into concurrent modification exceptions.
|
# ? Sep 28, 2009 18:38 |
|
I have a dumb question that's somehow made it to me despite being the least qualified to answer this. We have a service which allows you to use a URL to launch various tools on our side which are made from an in house scripting tool. However, when you enter the URL, it returns an ID for the created instance for reference as a new web page. One of our customers is using this to let their end users do various things, but does not want to have the return page with the ID show up. Is there a way in HTML to suppress this return page from appearing when their end user hits submit, or to redirect to a different confirmation page? I assume it's a simple thing, but googling turned up nothing. Thanks!
|
# ? Sep 28, 2009 18:52 |
|
Mustach posted:They don't. Collection has method to return iterator, although specifically it appears that class has to implement http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html to be allowed in for-each loop. You most definitely can delete elements from some Collection while inside for-each loop. I guess what I should have said is that some classes do not support this, and if they do you should be calling remove() method on the iterator, which I am not sure how to do if you are using for-each loop because the variable it gives you is reference to element inside collection itself not the iterator. If you had for-each loop over a Set and tried calling remove on the set with the current element, you most definitely will get concurrent modification exception.
|
# ? Sep 28, 2009 18:58 |
Flamadiddle posted:Probably a really stupid question, but I have a question about for-each loops. wikipedia posted:Unlike other for loop constructs, however, foreach loops [1] usually maintain no explicit counter: they essentially say "do this to everything in this set", rather than "do this x times". This can potentially avoid off-by-one errors and make code simpler to read.
|
|
# ? Sep 28, 2009 19:12 |
|
RussianManiac posted:Collection has method to return iterator, although specifically it appears that class has to implement http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html to be allowed in for-each loop.
|
# ? Sep 28, 2009 19:41 |
|
Mustach posted:I misunderstood you on the deletion part, but Map is not a Collection or an Iterable. Yea I think you are right. What I do is just iterate over keySet. is that efficient?
|
# ? Sep 28, 2009 19:42 |
|
The docs say that it's backed by the Map, so probably.
|
# ? Sep 28, 2009 19:44 |
|
I don't see why a map shouldn't be iterable, assuming it's based on an rbtree or some other balanced bst e: or a skiplist
|
# ? Sep 28, 2009 19:56 |
|
Otto Skorzeny posted:I don't see why a map shouldn't be iterable, assuming it's based on an rbtree or some other balanced bst in C++ STL its iterable
|
# ? Sep 28, 2009 20:02 |
|
Java maps are not collections directly, but do provide three collection views — keySet, values, and entrySet. All three are just views over the existing map and do not require copying internal structures. You can generally remove but not add entries through these collections, although entry sets generally allow both; otherwise their implementations are complete, and usually defined in the obvious ways in terms of the map. It's generally better to iterate over an entry set than the key set, because in most implementations it avoids a bunch of unnecessary map-lookups, but the types involved to be really gratuitous; e.g. Iterator<Map.Entry<String,List<MyObject>>>. A respectable entry set implementation will avoid allocating a new Map.Entry object for every entry in the map, either by making the internal structures implement Entry or by creating a single Entry instance for the entire iteration (usually coincident with the iterator). foreach loops are really nice sugar as long as you don't need an explicit reference to an iterator or an index.
|
# ? Sep 28, 2009 22:20 |
|
rjmccall posted:Java maps are not collections directly, but do provide three collection views — keySet, values, and entrySet. All three are just views over the existing map and do not require copying internal structures. You can generally remove but not add entries through these collections, although entry sets generally allow both; otherwise their implementations are complete, and usually defined in the obvious ways in terms of the map. yea I usually iterate over keySet because it makes more sense for most algorithms involving maps. I haven't found a nice way to delete stuff from Collection while using foreach loop, is there one?
|
# ? Sep 28, 2009 22:58 |
|
I was kind of hoping there was a rationale provided for maps not being collections directly
|
# ? Sep 28, 2009 23:01 |
|
RussianManiac posted:yea I usually iterate over keySet because it makes more sense for most algorithms involving maps. Why? Usually you want both the key and the value, which is exactly what entrySet is for. RussianManiac posted:I haven't found a nice way to delete stuff from Collection while using foreach loop, is there one? Nope; you'll have to go back to using an iterator --- or better yet, removeAll if you can swing it. Otto Skorzeny posted:I was kind of hoping there was a rationale provided for maps not being collections directly Ontologically, it seems correct that a map shouldn't be a collection, but that it's straightforward to view it as one. But everyone has their own views here. Practically, making Map a collection of entries would require awkward overloads for a few methods like remove(). It would also tempt novices to use methods like add() instead of put(), with disastrous results --- recall that the collections hierarchy went in long before generics.
|
# ? Sep 29, 2009 00:03 |
|
I was thinking of using mono for something so that I can run the program on linux and windows and because I like C#. However, there seems to be some sort of sperger war going on between Miguel de Icaza and RMS. So should I trust my gut feeling and use mono anyways because RMS is probably spergin' about nothing or does he have a valid case? Trying to form my own opinion is difficult because this seems to have turned into a religious war of some sort.
|
# ? Sep 30, 2009 16:27 |
|
The hard bit will be cross platform libraries. I would ignore RMS talking about stuff that will be unlikely to affect you.
|
# ? Sep 30, 2009 17:59 |
|
tef posted:The hard bit will be cross platform libraries. http://www.mono-project.com/GtkSharp would probably work pretty well. quote:I would ignore RMS talking about stuff that will be unlikely to affect you. It's usually best to ignore the ranting of the deeply paranoid
|
# ? Sep 30, 2009 20:43 |
|
My experience in computing has been that the value of a person's opinions is directly proportional to their physical appearance and hygiene. Stallman is a hideous forest creature who eats things he picks off his feet. Nuff said.
|
# ? Oct 3, 2009 17:49 |
|
What's the reason for using anonymous namespaces instead of the static keyword to achieve internal linkage? Is it just customary?
|
# ? Oct 4, 2009 01:11 |
|
GrumpyDoctor posted:What's the reason for using anonymous namespaces instead of the static keyword to achieve internal linkage? Is it just customary? Classes can't be declared static.
|
# ? Oct 4, 2009 01:49 |
|
Avenging Dentist posted:Classes can't be declared static.
|
# ? Oct 4, 2009 05:24 |
|
CptAJ posted:Quick question: I've started watching some of MIT's Open Courseware lectures on computer science. They're pretty cool but as you can see here, not that many of the courses are available in video lecture form. http://webcast.berkeley.edu/ has video and audio lectures for some things, although they don't organize it as well as MIT does.
|
# ? Oct 4, 2009 20:01 |
|
CptAJ posted:Quick question: I've started watching some of MIT's Open Courseware lectures on computer science. They're pretty cool but as you can see here, not that many of the courses are available in video lecture form. There's also some stuff from Stanford here: http://see.stanford.edu/see/courses.aspx
|
# ? Oct 4, 2009 23:03 |
|
This is more of a scripting question than programming, but I didn't want to start a whole new thread for it. Is there a way for me to write a .reg file that will edit a user specific key like HKEY_USERS\S-1-5-21-blah-blah-blah-123456\Software\Microsoft\Internet Explorer\Main, but that will work for any user on any machine? I want a way to restore a homepage by clicking a reg file. Edit: I tried using HKEY_CURRENT_USER again and got it to work. I was changing the wrong key before, which is why I thought it wasn't working. Hillridge fucked around with this message at 16:19 on Oct 5, 2009 |
# ? Oct 5, 2009 15:45 |
I'm trying to think of a simple set of rules to determine if "6-1" should be interpreted as 6:00AM-1:00PM or 6:00PM-1:00AM. The one closer to normal business hours is the 'correct' one. I feel like this should be really simple, but I just can't think of what it is.
|
|
# ? Oct 5, 2009 21:14 |
|
fletcher posted:I'm trying to think of a simple set of rules to determine if "6-1" should be interpreted as 6:00AM-1:00PM or 6:00PM-1:00AM. The one closer to normal business hours is the 'correct' one. I feel like this should be really simple, but I just can't think of what it is. Distance in hours between centers of time (a la center of mass).
|
# ? Oct 5, 2009 21:34 |
Avenging Dentist posted:Distance in hours between centers of time (a la center of mass). As in, the distance between the center of the input time and the center of the business day? What about for an input of something like "5-6" ?
|
|
# ? Oct 5, 2009 21:57 |
|
fletcher posted:As in, the distance between the center of the input time and the center of the business day? What about for an input of something like "5-6" ? Center of business day (9-5): 1 PM Center of input: 5:30 XM 5:30 PM - 1 PM = 4.5 hours 1 PM - 5:30 AM = 7.5 hours The answer should be clear. You probably mean something like 6-8, in which case just pick one. Or you may also want to massage the center of your business day if people don't like getting up as rear end o'clock for a meeting. Avenging Dentist fucked around with this message at 22:13 on Oct 5, 2009 |
# ? Oct 5, 2009 22:06 |
|
An alternative heuristic that gives slightly different answers than the center-of-business-day option is to enumerate the hours in each candidate range, give one point for hours that are in the normal business day, and subtract one point for hours that are not. So, (5,6) enumerates to: 5 - 6 : -1 point 5 - 18 : 3 points 17 - 18 : -1 point 17 - 6 : -13 points And sorting reveals (5,18) as the most sensible interpretation. This method is nice if you like tweaking, because instead of the one point for/one point against metric, you can easily adopt to a table with a score for each hour of the day, based on presumably real data like the average number of people in the office at that hour. It won't be very different than the results you'd get from AD's suggestion, but you can pretend it's better.
|
# ? Oct 5, 2009 22:28 |
|
|
# ? May 14, 2024 10:00 |
Awesome! Thanks guys!
|
|
# ? Oct 5, 2009 22:38 |