|
clay posted:I have an 2d array set up like this in C: What exactly are you trying to do? mmap is used to treat files as if they were loaded in memory; the closest thing would be to mmap a region that is backed by an anonymous file.
|
# ? May 4, 2008 23:12 |
|
|
# ? May 14, 2024 14:07 |
|
floWenoL posted:What exactly are you trying to do? mmap is used to treat files as if they were loaded in memory; the closest thing would be to mmap a region that is backed by an anonymous file. I'm loading the netflix dataset to memory. Right now I have it load the entire dataset into memory each pass which is pretty silly and takes about 4 minutes. I want to mmap it all once so I can just load the mmaped file. clay fucked around with this message at 23:53 on May 4, 2008 |
# ? May 4, 2008 23:39 |
|
clay posted:I'm loading the netflix dataset to memory. Right now I have it load the entire dataset into memory each pass which is pretty silly and takes about 4 minutes. I want to mmap it all once so I can just load the mmaped file. Are you trying to load multiple times in the same process or running multiple processes. If it's the former, just allocate the array as an int** and pass it around. code:
code:
poopiehead fucked around with this message at 12:21 on May 5, 2008 |
# ? May 5, 2008 01:41 |
|
clay posted:I'm loading the netflix dataset to memory. Right now I have it load the entire dataset into memory each pass which is pretty silly and takes about 4 minutes. I want to mmap it all once so I can just load the mmaped file. I'm still not sure why loading in a file requires a 2-d array, but the canonical code to mmap a file for reading is: code:
|
# ? May 5, 2008 09:14 |
|
edit: nvm wrong place to put this!
notMordecai fucked around with this message at 14:48 on May 5, 2008 |
# ? May 5, 2008 14:41 |
|
Does anyone know of a Greasemonkey script for YouTube that will: * Not automatically start the video, but load it * Have everything on the page expanded (More From:, More Info:, etc.) I have tried looking around on Google for such a script and of course have looked at YouTube's settings and can not seem to find anything that does these things. Thanks!
|
# ? May 5, 2008 22:52 |
|
I'm sure this has been covered before, but the search function is down for the forum, so I will ask. I was looking into working on open source projects to get experience for my job search. Is there any good information out for those looking to get into open source projects? I'm looking for some basic entry level info.
|
# ? May 6, 2008 18:16 |
|
Well most open source programs are written in Linux so you should familiarize yourself with the build environment and tools. The languages vary but I'd say that the majority are written in C/C++. Other than that you can get started by just checking out the source code and looking at their data structures. A lot of OS projects have developer wikis which can steer you in the right direction.
|
# ? May 6, 2008 18:21 |
|
This a javascript issue and hopefully someone can help me, btw: The "programmer" who designed/created the peice of poo poo software/web interface I was put incharge to "patch" together to fix, was a complete moron (I just had to say that somewhere). EDIT: I was able to fix it, turns out it wasent a frame but a DIV with overflow set to scroll. Just needed to implemnenet: document.getElementById("div id").scrollTop=y; I loath the man who orinigally created this garbled mess of code I have to fix. wolf_man fucked around with this message at 14:44 on May 7, 2008 |
# ? May 6, 2008 20:37 |
|
I'm not exactly sure where to put this, and I'm hesitant to make a thread in SH/SC about it so I'm going to try here first. I'm working with an excel spreadsheet that has to be formatted a certain way in order to integrate with our database, and thanks to the stupidness of another staff member of the library, I have a column of 40,000 items that need to be reformatted. Normally, if it's a short list I do it by hand but since it's so large I figured I'd ask here for help writing a script/macro/whatever it is I need. So basically the column looks like this: JA1304B37 B375F93 TAE236A32 And I need it to magically transform into this: JA 1304 B37 B 375 F93 TAE 236 A32 So Basically inserting spaces after the first letters, and then in between the letters and numbers, but not between the last set. So if someone can point me in the right direction I'd be very appreciative.
|
# ? May 7, 2008 06:46 |
|
A regular expression can do this easily. You just need a text editor that lets you replace using a regular expression. This will match the test and separate it into 3 tags. code:
Then all you have to do is replace using the 3 tags. This is how you would do it in notepad++. Notice the spaces between the 3 classes. code:
Janitor Prime fucked around with this message at 08:12 on May 7, 2008 |
# ? May 7, 2008 08:02 |
|
MEAT TREAT posted:A regular expression can do this easily. You just need a text editor that lets you replace using a regular expression. Ok, so I understand why and how this works, I just can't get it to work in notepad ++. I've hit ctl+r to bring up the F/R box, imputed this, and nothing seems to happens. It'll either say, not found, or 0 found depending on whether I pick find or count. Am I missing something obvious here?
|
# ? May 7, 2008 09:43 |
|
Yes you need to switch to the replace tab and then you push the replace all button.
|
# ? May 7, 2008 11:17 |
|
Does anybody have experience doing open source work with freshmeat.net? I'm looking for some experience, and I am looking to find a good site to do it.
|
# ? May 7, 2008 16:53 |
|
This is more of an algorithm question than programming.. but is there a more efficient random permutation/shuffling algorithm than Fisher-Yates shuffle? That's what I'm using currently to shuffle >200K entries in a table.
|
# ? May 7, 2008 17:22 |
|
It is an in-place O(n) shuffle when implemented correctly, so finding something faster might be a challenge. Why are you shuffling the table?
|
# ? May 7, 2008 17:32 |
|
CrusaderSean posted:This is more of an algorithm question than programming.. but is there a more efficient random permutation/shuffling algorithm than Fisher-Yates shuffle? That's what I'm using currently to shuffle >200K entries in a table. It looks like that algorithm works in O(n) time. If I'm right, I can't imagine a shiffle algorithm that would work faster. Of course, I'm new to this so I could be wrong. edit: beaten by above post
|
# ? May 7, 2008 17:36 |
|
tef posted:It is an in-place O(n) shuffle when implemented correctly, so finding something faster might be a challenge. Whoops, didn't see it was O(n). I'm not really shuffling a table. I have a large array of strings and I'm permuting the order of each string.
|
# ? May 7, 2008 19:40 |
|
I've searched the web for this, but can't really find a good answer. What good is an interface? I understand what one is, and how I would implement one, but I don't understand the benefit of using one instead of just writing the classes that would use it by themselves without using the interface. It seems like if your class "inherits" and interface, it must include all of the methods in the interface, but why not just write the class with all the methods anyway? Can anyone clarify this for me? darfur fucked around with this message at 19:48 on May 7, 2008 |
# ? May 7, 2008 19:46 |
|
darfur posted:I've searched the web for this, but can't really find a good answer. Hiding methods that consumers don't need to know about, for one. Here's a quick example of a really good reason to use an interface: code:
code:
Another good reason is being able to change implementations under the hood without the consumer having to be aware of it. Let's say you have a connection class. Could be a connection to a database, could be a connection to a network socket, could be a connection to some dank nugz from the kid your parents warn you away from all the time, but all your consumer cares about is that it's a connection to some resource. If you give them a DatabaseConnection, they have to write new code when you decide that databases are stupid and you'd rather have them use a NetworkConnection. If these connections implement a common interface, however, the consumer won't have to change anything in order to get your data from a new source. edit: continued, more formally and less contrived: Interfaces are contracts: they guarantee that a class has methods X, Y, and Z. It doesn't specify how that contract will be fulfilled, that's the job of the class that implements the interface. Interfaces allow a programmer to separate the design (the interface) from the implementation (the class). csammis fucked around with this message at 20:21 on May 7, 2008 |
# ? May 7, 2008 20:17 |
|
darfur posted:I've searched the web for this, but can't really find a good answer. Consider the Java List interface: http://java.sun.com/j2se/1.5.0/docs/api/java/util/List.html You can see that among the implementations give there are ArrayList, LinkedList, and Vector. So anything that takes a List, and uses the List methods, can be called on any of these implementations. From a consumer's point of view, if they just want to get some data, the fact that ArrayList.get() and LinkedList.get() behave entirely differently under the hood is irrelevant. Another example: event handlers. All event handlers for a given event implement the same interface, but they may (and hopefully do) have different behavior, and you may have multiple different event handlers for a particular event. Incoherence fucked around with this message at 20:22 on May 7, 2008 |
# ? May 7, 2008 20:20 |
|
Incoherence posted:Another example: event handlers. All event handlers for a given event implement the same interface, but they may (and hopefully do) have different behavior, and you may have multiple different event handlers for a particular event. Huh? Event handlers (callbacks, whatever you call them in your language) are methods, not interfaces. The fact that you can have multiple event handlers for a single event has zilch to do with interfaces, it has to do with how events are implemented in your architecture.
|
# ? May 7, 2008 20:23 |
|
Interfaces allow you to have more freedom than simple inheritance while at the same time giving you all the benefits like polymorphism. I'll give you a good example of one I did recently. I was writing a B+ tree data structure. If you've ever studied the B+ tree you know that it has 2 different kinds of nodes. It has index nodes which are really just 2 arrays with one being an array of pointers to other nodes and it has the leaf nodes which is where the data is actually stored. Now both these classes share a lot of methods like insert, search and delete but each one has to implement it differently since they have different internal structures. So I created a Node interface with the above methods which these two classes implement. Now I can pass around Node objects without having to worry if they are leaf nodes or index nodes*. Now I could have used normal inheritance with abstract functions but then if I ever wanted to inherit from another class I couldn't. e: csammis where those methods come from? You have to inherit them from some place and in languages that don't allow multiple inheritance you have to use interfaces so that you can have multiple even handlers for one object. I think Incoherence said it wrong, I'm sure he meant that one object can have multiple even't handlers like keyboard and mouse, not that many objects can share the keyboard event handler. Because in that case you are correct, interfaces have nothing to do with it. Janitor Prime fucked around with this message at 20:43 on May 7, 2008 |
# ? May 7, 2008 20:27 |
|
I've just started using SVN for a personal project a few weeks ago and made a branch to add a couple of features. When I try to merge my branch back to the trunk (using the dry run option), it skips all the files I added even though they're versioned in the branch. The SVN docs/book are no help, any ideas? EDIT: Nevermind, apparently "From" and "To" mean "To" and "From" in SVN lingo. Anode fucked around with this message at 21:16 on May 7, 2008 |
# ? May 7, 2008 21:10 |
|
MEAT TREAT posted:e: csammis where those methods come from? You have to inherit them from some place and in languages that don't allow multiple inheritance you have to use interfaces so that you can have multiple even handlers for one object. I think Incoherence said it wrong, I'm sure he meant that one object can have multiple even't handlers like keyboard and mouse, not that many objects can share the keyboard event handler. Because in that case you are correct, interfaces have nothing to do with it. I know what Incoherence meant about one event having multiple handlers, but I'm not sure where you're coming from. Inheriting a method? Where are you inheriting the method from when you use a delegate in C#? How about registering a method callback in C++? Event handling is a concept that has absolutely nothing to do with interfaces. Interfaces only come into it as an implementation detail of Java's Listener pattern.
|
# ? May 7, 2008 21:31 |
|
CrusaderSean posted:Whoops, didn't see it was O(n). I'm not really shuffling a table. I have a large array of strings and I'm permuting the order of each string. Not sure how you're storing the strings, but if it is by value you'd probably get a huge speed up by shuffling references/pointers to the strings instead.
|
# ? May 7, 2008 21:53 |
|
csammis posted:I know what Incoherence meant about one event having multiple handlers, but I'm not sure where you're coming from. Inheriting a method? Where are you inheriting the method from when you use a delegate in C#? How about registering a method callback in C++? Event handling is a concept that has absolutely nothing to do with interfaces. Interfaces only come into it as an implementation detail of Java's Listener pattern. Well that shows how much I know about either of those languages.
|
# ? May 7, 2008 21:54 |
|
csammis posted:Huh? Event handlers (callbacks, whatever you call them in your language) are methods, not interfaces. The fact that you can have multiple event handlers for a single event has zilch to do with interfaces, it has to do with how events are implemented in your architecture. I was trying to think of an example where you would have multiple implementations of an interface and want to hold them all in a list and run them all in sequence, without using the one on the project I work on (I can't figure out a good way to generalize/anonymize it).
|
# ? May 7, 2008 23:08 |
|
Incoherence posted:I was trying to think of an example where you would have multiple implementations of an interface and want to hold them all in a list and run them all in sequence, without using the one on the project I work on (I can't figure out a good way to generalize/anonymize it). There's a concept in Cocoa/ObjC called class clusters, in which a type has a bunch of private subtypes which are implemented independently and never exposed to the user. That page has a more complete and in-depth justification than any forum post could.
|
# ? May 7, 2008 23:12 |
|
Awesome replies! They make a lot of sense to me, at least I think. In MEAT TREAT's tree, for the insert function, would it just take an INode as the parameter, and then you could pass it any class which inherits the INode interface and that class' specific implementation of insert would be what gets called? That is my understanding as to how an interface would work there, is this correct? Would you have to make sure you don't link different types of INodes together or is that what this enables you to do? darfur fucked around with this message at 09:54 on May 8, 2008 |
# ? May 8, 2008 09:50 |
|
So I have a structured array in C++, compiling for Windows under VS2005, and I'd like to be able to save it and load it to a file at will. I hear that there's a way to essentially save/load the entire thing to and from memory in one go somehow, instead of doing retarded looping, but I can't see much info on it. Can anybody suggest as to how I would go about this?
|
# ? May 8, 2008 23:33 |
|
darfur posted:In MEAT TREAT's tree, for the insert function, would it just take an INode as the parameter, and then you could pass it any class which inherits the INode interface and that class' specific implementation of insert would be what gets called? That is my understanding as to how an interface would work there, is this correct? Would you have to make sure you don't link different types of INodes together or is that what this enables you to do? (Insert yammering about the C++ virtual keyword here, but if you're talking about interfaces you assume the methods are virtual. Also insert yammering about how this is actually an instance of the Composite Design Pattern, and that if you're in academia there are all sorts of neat things you can add to this like the Visitor Pattern.)
|
# ? May 9, 2008 00:36 |
|
Did Microsoft change anything about how Visual Studio handles exceptions with version 2008 64bit? If you had an uncaught exception in 2005 and had run the application in the debugger, you used to get a popup with the exception and the debugger automatically opened on the offending line. But I can't seem to get the same working in 2008. Even a completely new project whose only line is "throw new Exception()" simply throws the exception then ignores it.
|
# ? May 11, 2008 16:40 |
Hi guys. I am bad at shell scripting. Please help me. I have a set of data files I want to repeatedly run a program on, with both input and output files marked by padded integers, i.e. they go from 00000 in increments of 20 all the way up to 02000 (or whatever min/max). So I need a little loop that uses the padded integers: ./program < input.00000 > 00000.out ./program < input.00020 > 00020.out ... etc. (the < and > characters denote input and output and are actually necessary in the program's call line) Can anybody help me out real quick? You'll probably save me a couple hours of looking up how to do this...thanks in advance!
|
|
# ? May 13, 2008 01:27 |
|
heres a really lovely way that would probably work. But I know for sure there's a much easier way to do it, Just don't know linux well enough. the syntax is close but definitely wrong, but until someone answers for real, that should workcode:
code:
poopiehead fucked around with this message at 02:02 on May 13, 2008 |
# ? May 13, 2008 01:55 |
|
The first line of the loop is for i in `seq 0 1000000`, and you need spaces before the ]s (also, you might want to use elif instead if fi/if). Otherwise, what poopiehead said. Edit: I can't read. Edit 2: vv Use `seq 0 20 1000000`. 10011 fucked around with this message at 02:07 on May 13, 2008 |
# ? May 13, 2008 02:03 |
That looks just fine, but how do I make the step-size 20 in the for call? Edit: Thanks guys! Edit 4: I didn't fix it. Still have bad syntax near the unexpected token if. Waaah... mdemone fucked around with this message at 20:13 on May 13, 2008 |
|
# ? May 13, 2008 02:03 |
|
How would I make a piano-roll style GUI, like for use with MIDI? I could probably get as far as drawing some lines in OpenGL, but I don't really know how to proceed from there, or how to make a piano roll that fits in with an existing GUI framework. Are there any references out there on writing custom GUIs/widgets or whatever? Preferably in Python (a long shot, I know)?
|
# ? May 13, 2008 13:08 |
|
Moof Strydar posted:I could probably get as far as drawing some lines in OpenGL, but I don't really know how to proceed from there, or how to make a piano roll that fits in with an existing GUI framework. Are there any references out there on writing custom GUIs/widgets or whatever? Preferably in Python (a long shot, I know)? Absolutely - both wxPython and PyQT are fantastic GUI frameworks (I prefer PyQT). Google will find you lots of good stuff.
|
# ? May 13, 2008 18:19 |
|
|
# ? May 14, 2024 14:07 |
|
Do we have an Actionscript thread? My head is going to explode trying to sort out that language.
|
# ? May 14, 2008 04:09 |