|
xPanda posted:Is that correct? Yes. The listeners and connectors
|
# ? Aug 19, 2010 08:07 |
|
|
# ? May 31, 2024 05:19 |
|
shrughes posted:The listeners and connectors I want to see this made though, you could bill it as a self-authenticating modular client that does whatever it does and pretends it still has security.
|
# ? Aug 19, 2010 13:39 |
|
For what you're talking about, I heard a co-worker talking about Fabric for running remote commands. link with other info
|
# ? Aug 19, 2010 14:26 |
|
I'm looking for a recommendation for an image processing library. I want to be able to detect large roughly quadrilateral-shaped areas against a background, crop out sections of the images, find straight lines of some length, rotate images, and glue all this together with a scripting language - preferably Python or maybe Perl. I know some of this is doable with ImageMagic, so I don't need a one stop shop for everything, but I'd like something to deal with what I'd consider the hard parts: finding boundaries and lines. In case it matters, I'm looking at automatically taking a very large picture of a full side of a newspaper broadsheet (think a single piece of newspaper size paper, not just the contents of Page N), finding the actual sheet against the background, finding each page, and correcting for the angle that the picture was taken at by rotating each page (now dealing with Page N instead of the full sheet) as needed.
|
# ? Aug 24, 2010 18:13 |
|
OpenCV has python bindings http://opencv.willowgarage.com/documentation/python/index.html
|
# ? Aug 24, 2010 19:33 |
|
Nice - thanks!
|
# ? Aug 24, 2010 21:19 |
|
yeah, never mind.
einTier fucked around with this message at 06:53 on Aug 25, 2010 |
# ? Aug 25, 2010 06:43 |
|
I almost made a thread out of this because it can turn into a pretty big discussion, but I'll try my luck here instead. One of the things I ask interview candidates (C# application design, mostly) is an example of when they would use inheritance over composition. Nobody has given me a really good answer (they aren't necessarily supposed to get it 'right', it's just for discussion), and to be honest I'm not sure I have one myself. So, with the exception of deriving from third party base classes where required, where would you use inheritance over composition?
|
# ? Aug 29, 2010 18:17 |
|
I'm a fairly new programmer, and I'm working my way through project Euler. I just completed problem 18, where you must find the maximal sum travelling down through a triangle of numbers. I solved it (in python) using a brute force method, but I know that my style is completely god awful. The code gets the job done, but it's really unreadable, and in general I know there must be a better way to go about doing what I did. I represented the triangle as a list-of-lists. This way, instead of being an equilateral triangle, its a right triangle-- thus the choice of moving to the left or to the right is now the choice of moving straight down or moving to the right. So, I used two nested loops. The inner loop reads a string of 0s and 1s to decide how it is going to traverse through the triangle -- a string of all 0s would just loop straight down summing up the first entries of each list in the list-of-lists. anytime a '1' is found, the index being used on the inner-list is incremented. The outer loop systematically generates these strings of 0 and 1, so that the inner loop loops through all possibilities. The largest of all the loop-sums is printed. Whats happening isn't very complicated, but it seems really roundabout, clunky, nooobish etc. Is there a more normal way, stylistically, to do this kind of iteration? Because this really just seems off. Code is here: http://pastebin.com/8zdCC66n tools.intTOstrbin(x) is a function that takes a number and returns a string representing the number in binary. I can post that code too, but it's pretty simple and honestly I feel like I shouldn't be using a string like this anyway.
|
# ? Aug 29, 2010 19:37 |
|
Orzo posted:I almost made a thread out of this because it can turn into a pretty big discussion, but I'll try my luck here instead.
|
# ? Aug 29, 2010 21:58 |
|
TasteMyHouse posted:Whats happening isn't very complicated, but it seems really roundabout, clunky, nooobish etc. Is there a more normal way, stylistically, to do this kind of iteration? Because this really just seems off. Yeah, you just use recursion. Pseudocode follows: code:
A more efficient solution will take ~((table.length)^2) time, i.e. an amount of time proportional to the size of the input.
|
# ? Aug 30, 2010 01:34 |
|
TasteMyHouse, In addition to what shrughes said, when you get to problem 67, you're going to need the 'more efficient solution' that shrughes mentioned. But you might as well use it for this problem too if you're trying to learn. I won't give away the exact methodology, but to steer you in the right direction, you may wish to visit this: http://en.wikipedia.org/wiki/Dynamic_programming
|
# ? Aug 30, 2010 02:27 |
|
Plorkyeran posted:Never, except for when you have to. If it's possible to do something via composition, doing it via inheritance probably doesn't result in a sensible class hierarchy.
|
# ? Aug 30, 2010 02:28 |
|
This post is full of spoilers, so don't read if you want to figure it out yourself. A better solution to that problem is start at the row last-1, and last. You then compare the position below and the position below+1 and add the greater of them to the current one. I probably said that in a retarded way, so this example will help clear it up. Looking at the last two rows in the problem: 63 66 04 68 89 53 67 30 73 16 69 87 40 31 04 62 98 27 23 09 70 98 73 93 38 53 60 04 23 You add the greater of 04 and 62 to 63, which gives you 125. You repeat for everything number left in the row until your row last-1 equals the following: 125 164 102 95 112 123 165 128 166 109 122 147 100 54 You repeat this process all the way to the top and you'll know the answer.
|
# ? Aug 30, 2010 02:52 |
|
I've got a CS theory question (formal language theory stuff). I don't know anywhere besides here or the small math questions thread over in SAP, and I'm not lucking out over there. If this is wildly inappropriate I'm sorry. But, a cross-post: Under what conditions is the infinite union of languages a regular language? The regular languages aren't closed under infinite union in general because e.g. 01 ∪ 0011 ∪ 000111 ∪ ... = 0^n1^n is context-free. But it's fine to take the infinite union of certain sets to get a regular language in the end (e.g. w^1 ∪ w^2 ∪ w^3 ∪ ... = ww*). So what has to hold about each of those languages you're taking the union of if you want to get a regular language in the end? This is related to my research which mostly cares about infinite compositions of rational relations, but these are related ideas. Basically I have a rational relation R and I want to know when R^1 ∪ R^2 ∪ R^3 ∪ ... is rational itself. (Denoting n-fold composition with ^.) Yell at me if this does not immediately follow from my question.
|
# ? Aug 30, 2010 04:12 |
|
IlluminatusVespucci posted:Under what conditions is the infinite union of languages a regular language? "When it's regular." You can make any language with an infinite union of regular languages. IlluminatusVespucci posted:So what has to hold about each of those languages you're taking the union of if you want to get a regular language in the end? You probably already know this, but it's not what has to hold about each of the languages. There are no rules that an individual language must follow for the union to be a regular language. IlluminatusVespucci posted:This is related to my research which mostly cares about infinite compositions of rational relations, but these are related ideas. Basically I have a rational relation R and I want to know when R^1 ∪ R^2 ∪ R^3 ∪ ... is rational itself. (Denoting n-fold composition with ^.) Yell at me if this does not immediately follow from my question. Isn't R* = R^0 ∪ R^1 ∪ R^2 ∪ R^3 ∪ ... ? And that's rational (by definition). Since R is rational and R* is rational, we know that RR*, which equals R^1 ∪ R^2 ∪ R^3 ∪ ..., is rational.
|
# ? Aug 30, 2010 08:20 |
|
Orzo posted:I tend to agree, which is why it makes for a good interview question--every time someone gives an example of using inheritance I just ask them why they don't abstract the behavior into a composed class. But surely there's a proper place for it? Anyone? The only time that comes to mind is when you require runtime polymorphism. I will also usually allow for inheriting from small concrete mixins, as well. Lastly in c++ private inheritance is just syntactic sugar for composition, so if you prefer that stylistically I suppoe that's fine. Of course, there's never a reason for ten level deep inheritance hierarchy spaghetti, the kind I see so much of at work.
|
# ? Aug 30, 2010 12:23 |
|
Edit: No matter, the reason was my AWESOME webhosting company SUUUUUCCCKKKSSS rear end!!! Maybe I should look around for a new one, one where I'm allowed more than 1 database. Any suggestions? Death by Cranes fucked around with this message at 15:40 on Aug 30, 2010 |
# ? Aug 30, 2010 15:13 |
|
I am setting up a squeeze page that mimics this http://100newclients.com/ (with permission). Mine can be found at - http://houston-baseball-training.com/email.html How do I set up the video box on the right hand side to do what that one does? I have the video and know I need to use flash some how, but I have no clue how to use Flash. Also if someone would be interested in doing this for me since I assume it wouldn't take you that long compared to me, I would be more than happy to throw a few bucks your way.
|
# ? Aug 30, 2010 16:03 |
|
Orzo posted:I tend to agree, which is why it makes for a good interview question--every time someone gives an example of using inheritance I just ask them why they don't abstract the behavior into a composed class. But surely there's a proper place for it? Anyone? The only time I've seen it used where composition doesn't make sense: sharing implementation commonalities across several 'objects'. The most recent example I've seen was the PageRank implementation in JUNG (in Java). PageRank has a long inheritance chain: PageRank extends PageRankWithPriors extends AbstractIterativeScorerWithPriors extends AbstractIterativeScorer. The basest class implements all the common stuff you see in iterative algorithms: calculating the rate of change and comparing that against your epsilon, performing the each step until you meet your epsilon criteria or have passed the maximum amount of steps, etc. The biggest problem with inheritance is that you can't ever alter the inheritance chain easily. However, that's not an issue when you set off to implement specific algorithms: you're never going to be told that you have to change how PageRank works. "Oh Dave, I was talking to Sales and we've decided that we don't want a few of these iterative algorithms to have a maximum amount of steps. We just want PageRank to run forever if that's what it takes." I've never written something like this though, so I'm mostly using my imagination. I've always used composition.
|
# ? Aug 30, 2010 17:23 |
|
I always feel like I'm doing something wrong when I'm making function calls many levels deep in a program's execution and have to pass the parameters from function to function to function just so they'll be available when I need them. Am I missing something? I know I should avoid globals, but I don't know of another way around this. Maybe singletons? My preferred language is Python.
|
# ? Aug 30, 2010 17:43 |
|
If you've truly got global state, globals are not an evil thing, but from the sounds of it your problem is that you're writing the wrong functions.
|
# ? Aug 30, 2010 18:15 |
|
Otto Skorzeny posted:If you've truly got global state, globals are not an evil thing, but from the sounds of it your problem is that you're writing the wrong functions. Well, for instance right now the parameters that I'm passing down are needed to invoke a web service. The program constructs and sends emails with attachments, and I've made it so that each instance of the Email object can just send() itself. Each Email owns one or more EmailItem objects that represent attachments, and the attachments come from a webservice that the EmailItem uses to populate itself with data. So, I have to pass details about the web service to the class that builds the list of Email objects, then to the Email object, and then to the EmailItem object. The web service details don't differ for any object instance. It's definitely possible I'm going about this wrong, I've got close to no professional training in software design.
|
# ? Aug 30, 2010 18:32 |
|
shrughes posted:You probably already know this, but it's not what has to hold about each of the languages. There are no rules that an individual language must follow for the union to be a regular language. EDIT: Oh I see what you meant. Yes, obviously I mean what has to hold of each language in the infinite union and they're relationship to one another. Like a sufficient condition is that the languages are all concatenations of one another (as this would be L* or L+). I'm looking for either a) the necessary conditions or b) a broader sufficient condition (since L* is useless for my purposes as far as I can tell). quote:Isn't R* = R^0 ∪ R^1 ∪ R^2 ∪ R^3 ∪ ... ? And that's rational (by definition). Sorry, that was my abuse of notation. I was using ^ to denote n-fold composition of a single relation, not concatenation. E.g. R^4 = R ∘ R ∘ R ∘ R = R(R(R(R)))). Sorry if I misunderstand you. My real ultimate goal is to find a class S within the rational languages such that for every R in S the following infinite union is rational: R ∪ R ∘ R ∪ R ∘ R ∘ R ∪ ∪ R ∘ R ∘ R ∘ R ∪ ... I'm thinking of this as a first step but maybe that helps clarify what I want. illves fucked around with this message at 18:55 on Aug 30, 2010 |
# ? Aug 30, 2010 18:43 |
|
Smugdog Millionaire posted:The only time I've seen it used where composition doesn't make sense...
|
# ? Aug 30, 2010 18:51 |
|
Alfalfa posted:I am setting up a squeeze page that mimics this http://100newclients.com/ (with permission). Mine can be found at - http://houston-baseball-training.com/email.html http://forum.videohelp.com/threads/255412-How-to-convert-to-Flash-FLV-Video-and-add-it-on-your-homepage edit: I noticed he has an interactive feature that mutes the volume and obscures the picture until you enter your email, that makes it more complicated than a straight flv, you'll need to get the Macromedia Flash program ($$$) or hire this out, bit more than a couple bucks to integrate it all together though. baquerd fucked around with this message at 18:55 on Aug 30, 2010 |
# ? Aug 30, 2010 18:52 |
|
Sock on a Fish posted:Well, for instance right now the parameters that I'm passing down are needed to invoke a web service. The program constructs and sends emails with attachments, and I've made it so that each instance of the Email object can just send() itself. Each Email owns one or more EmailItem objects that represent attachments, and the attachments come from a webservice that the EmailItem uses to populate itself with data. So, I have to pass details about the web service to the class that builds the list of Email objects, then to the Email object, and then to the EmailItem object. The web service details don't differ for any object instance.
|
# ? Aug 30, 2010 19:39 |
|
Rocko Bonaparte posted:If the objects in between don't conceptually give a drat about the stuff you're passing along, then there's a problem. If they're all contributing in some way then I suppose that's all right, but it would be best if the little bits that contribute to the whole could theoretically be used to contribute to something else too. Yeah, the guy that builds the list of emails shouldn't have any knowledge of what web service gets used to pull attachments, but the way I've designed this it either has to or else I need to use globals. Would a better way be to not have the Email objects build themselves, but rather move up a level in the chain and feed each email into an object that's aware of the web service and adds the appropriate attachment? Are there any guides on general design principles like this? I read Clean Code awhile back and ended up with much, much better code as a result. I'd really like to improve further. I used to regularly have functions with like 16 arguments.
|
# ? Aug 30, 2010 21:16 |
|
How dangerous is the " character (that's a quotation mark, not two singlequotes) in regards to SQL injection attacks? I'm bumping up against some previously-written anti-hacking code that's disallowing any quotation marks in the query string or form fields, and after giving myself a very brief crash course I don't know why. I know why ' is dangerous, but " ought to be okay, right? What's the danger?
|
# ? Aug 30, 2010 21:31 |
|
CapnAndy posted:How dangerous is the " character (that's a quotation mark, not two singlequotes) in regards to SQL injection attacks? I'm bumping up against some previously-written anti-hacking code that's disallowing any quotation marks in the query string or form fields, and after giving myself a very brief crash course I don't know why. I know why ' is dangerous, but " ought to be okay, right? What's the danger? Your question, while well-intended, is ultimately the wrong one to ask. You don't want to filter out metacharacters yourself. You don't actually want to filter at all, actually - you want to use prepared statements/parameterized queries - but if you must do escaping, use your vendor's supplied escaping function. e: cf. http://bobby-tables.com/ for how to do this in practically any language with practically any database; feel free to ignore the xkcd schlock, but the info itself is fine Blotto Skorzany fucked around with this message at 22:31 on Aug 30, 2010 |
# ? Aug 30, 2010 22:28 |
|
Otto Skorzeny posted:Your question, while well-intended, is ultimately the wrong one to ask.
|
# ? Aug 31, 2010 02:51 |
|
Stored procedures != prepared statements
|
# ? Aug 31, 2010 02:57 |
|
Sock on a Fish posted:Yeah, the guy that builds the list of emails shouldn't have any knowledge of what web service gets used to pull attachments, but the way I've designed this it either has to or else I need to use globals. Would a better way be to not have the Email objects build themselves, but rather move up a level in the chain and feed each email into an object that's aware of the web service and adds the appropriate attachment? You talk a lot about building Email objects, so maybe look at design patterns like the Builder pattern or a Factory pattern for some idea on how to write objects expressly for making GBS threads out other objects. In the past I've recommended people look at a lot of programming design patterns to get an idea of what good design is generally like. Somebody that's decent enough with design will see most patterns and think, "no poo poo!" which is probably a good thing. It's also easy to go overkill with them, so only look at them for inspiration for what you need to do. However, if you've been used to ad hoc programming then do one in anal detail sometime just to see what it's like to stick to a design like that. You can see what it's like to take something abstract like that and make it into code, and the kind of nagging questions that'll won't pop up the first time until you're halfway through. Then you'll start to get an idea up front of structured ways of doing things, and then you're thinking in terms of design.
|
# ? Aug 31, 2010 04:56 |
|
Orzo posted:I'm not really familiar with this particular set of classes or what they do, so maybe I'm not following correctly, but why would this be a bad place to use composition again? It looks like there's some sort of hideous inheritance structure and these 'shared implementation commonalities' could easily be a separate class. It's significantly more convenient to use inheritance than composition. Inheritance gives you specific slots to fit your derived functionality and you don't have to repeat the same code. I'm imagining the PageRank object having a private PageRankWithPriors object and you essentially copy all the methods into the PageRank class that do nothing but call the inner object. That's a lot of pointless boilerplate and doesn't really get you anything. Your class still has a compile-time dependency on the 'base class'. Orzo posted:Or the shared code could be the main client class with the derived details being the composed strategies. Just from a keyboard pounding standpoint, I much prefer new PageRank() to code:
You think "I bet PageRank will be useful, I'll use that."
|
# ? Aug 31, 2010 16:27 |
|
I know you provided a link to the API but I don't really have time to read all of that right now, perhaps someone who is already familiar with it can illustrate what I'm trying to say better. The link you've provided doesn't seem to show which inherited methods are public and which aren't, so I'm having trouble seeing the actual interface of each level. It looks completely bloated though, classes should not be doing anywhere near as much as PageRank appears to be. Hopefully I can take a look at it more tonight. Or maybe you can provide a more abstract example which illustrates your side of the argument directly.
|
# ? Aug 31, 2010 18:31 |
|
I just learned that I need to learn Fortran, and fast. Today was the first day in my two of my grad level astronomy courses, and both courses are strongly rooted in the use of fortran. I have taken two programming classes in undergrad, C++ and Python. 1) I have done some googling, and I saw that one astro professor recommended the g77 compiler instead of a newer one for relative ease of use, but the article was from 2000 or something. Good idea? Some other students said they had been using this for research. 2) Should I buy a book, or are the online manuals helpful enough that I can learn its useful properties?
|
# ? Sep 1, 2010 05:51 |
|
ScaerCroe posted:I just learned that I need to learn Fortran, and fast. Today was the first day in my two of my grad level astronomy courses, and both courses are strongly rooted in the use of fortran. I have taken two programming classes in undergrad, C++ and Python. It really depends on what you need to be doing. As an example, if you need to do lots of interfacing between Fortran and C, I don't think a book is really gonna help you (because different compilers/OS/etc), but places online can explains the details. It also matters which version of Fortran you are working with. For example standard F77 has 0 dynamic memory management. F90 and on have some forms. It also matters if you are compiling in a "strict" enviroment. Strict means 72 character column maximum, no ! comments, first 5 characters are control characters only, etc. If you are in a non-strict environment you will have potentially 130-150 character column maximum, ! comments, and other stuff. It is worth noting Fortran programmers LOVE GOTO statements, because there is no WHILE loop in F77, and some compilers do not have a for loop construct. Look to BASIC here! Oh, and the type system by default is implicitly typed based on the first character of the variable name! Welcome to hell. Bottom line, you need to determine what dialect of Fortran you will be working with. You could just convince them to use f2c and get over Fortran, but that is unlikely. F77 standard Decent summary of F77 The wide weird world of Fortran format statements litghost fucked around with this message at 06:32 on Sep 1, 2010 |
# ? Sep 1, 2010 06:10 |
|
litghost posted:Welcome to hell. good luck, scientific code
|
# ? Sep 1, 2010 06:25 |
|
Dijkstracula posted:Now, the flip side is that F90/95 is actually not that terrible, so if you can possibly get away with using gfortran and a semi-modern language implementation, for God's sake, do it. But why would you write NEW code in Fortran? Any code that requires using Fortran is in F77 anyways (at least in my corner of the world). Of course you could port it to F90, but the problems with F77 (implicit variables, massive global state, non-typed interfaces, no modules, etc) don't go away without a rewrite.
|
# ? Sep 1, 2010 06:29 |
|
|
# ? May 31, 2024 05:19 |
|
Without knowing the language, I'd generally recommend getting a book up front for learning a language despite a multitude of sources online. I like to get a book that is in some way definitive of the language that I examine in isolation of a computer so that I can generally grok the nature of the language and the style of programming in it. I don't know if others learn a language in a similar way. But I am also pretty frustrated with what I feel like is a bunch of people that learned a little C in college applying that same procedural methodology to every new language they see. As a simple example, I'll find a lot of people at work not going anywhere near a foreach kind of loop in any of the newer languages because it never crossed their mind that such a thing could possibly exist and be useful.
|
# ? Sep 1, 2010 07:28 |