|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On June 26 2014 09:30 billy5000 wrote: Are there numerous, practical use of closures? In a broad sense, it seems to allow functions hold some "state" but I haven't come across a time when I would use it, ever. It seems like I'm on the lookout to avoid it rather than to actually use it. I may be exaggerating a bit when I say that since all you have to do is create a private function, or an anonymous function that takes the outer function's variables as arguments instead. When working in Javascript, where you have no class keyword and no namespace functionality built in, you can use closures to create private namespace for 'classes' (instantiated objects). The 'module' pattern is a good example, do some googling and you'll find all the awesome stuff you can do with closure.
|
Anyone with a good amount of TDD experience? How do you go about writing a piece of code test-first when you don't know the result?
Specifically, I want to calculate a list of all possible ways to split a given number between 0 and x (x is usually 13 or 14) into 7 numbers between 0 and 4 that sum up to x. The order of these 7 numbers is not important, so the numbers should be sorted. So for example with x = 3: (3,0,0,0,0,0,0) (2,1,0,0,0,0,0) (1,1,1,0,0,0,0)
Now this is not the first time I'm writing this algorithm, so I know what the code should do. But I want so practice TDD and I'm not sure how I would go about testing this. Every approach I can think of either feels like it doesn't test enough or tests way too much. Maybe I can find a better approach if I generalize the seemingly arbitrary limits of 13/14 and 7 (they do make sense in the context of the algorithm, which is analysis of Honor tiles in Mahjong hands).
Even worse, it's concievable that I would only want to return the length of these lists. That yields a series of numbers that look kinda regular for a while but then the limit of 7 kicks in and things get messy. In this case I really don't have a lot of ways to test the result aside from checking a few manually counted values. But those numbers get fairly large, and I also have a similar but more difficult problem that yields much larger numbers and is extremely susceptible to mistakes when counting manually.
Again, I know what an algorithm for this problem looks like, but I don't know how to develop such an algorithm test-first.
|
The test is passed if these conditions are fulfilled: - All vectors are unique - All vectors have a length of n (=7) - The sum of each vector equals x - The number of vectors equals the expected number (based on the combinatorics formula)
|
On June 29 2014 20:02 spinesheath wrote: Anyone with a good amount of TDD experience? How do you go about writing a piece of code test-first when you don't know the result? You know the result (or can infer it) because you need to write code.
On June 29 2014 20:02 spinesheath wrote: Specifically, I want to calculate a list of all possible ways to split a given number between 0 and x (x is usually 13 or 14) into 7 numbers between 0 and 4 that sum up to x. The order of these 7 numbers is not important, so the numbers should be sorted. The order is not important, therefore they must be sorted? So the order is important...
On June 29 2014 20:02 spinesheath wrote: So for example with x = 3: (3,0,0,0,0,0,0) (2,1,0,0,0,0,0) (1,1,1,0,0,0,0)
There you go. Your first test case. But maybe start with x=1 to make it easier?
On June 29 2014 20:02 spinesheath wrote: Now this is not the first time I'm writing this algorithm, so I know what the code should do. But I want so practice TDD and I'm not sure how I would go about testing this. Every approach I can think of either feels like it doesn't test enough or tests way too much. Maybe I can find a better approach if I generalize the seemingly arbitrary limits of 13/14 and 7 (they do make sense in the context of the algorithm, which is analysis of Honor tiles in Mahjong hands).
Yes, generalizing seems like a better idea. Have the limits injected in some form to the algorithm and adjust the algorithm accoringly.
On June 29 2014 20:02 spinesheath wrote: Even worse, it's concievable that I would only want to return the length of these lists. That yields a series of numbers that look kinda regular for a while but then the limit of 7 kicks in and things get messy. In this case I really don't have a lot of ways to test the result aside from checking a few manually counted values. But those numbers get fairly large, and I also have a similar but more difficult problem that yields much larger numbers and is extremely susceptible to mistakes when counting manually.
Again, I know what an algorithm for this problem looks like, but I don't know how to develop such an algorithm test-first. Your algorithm should either return a list, or the length. Make your decision before you start coding. Without knowing the context/usage, it look to me that returning a list is the better way to go.
|
Checked out Ruby for the first time, done some koans and all I can say is "What sorcery is this?!".
|
On June 29 2014 20:43 urboss wrote: The test is passed if these conditions are fulfilled: - All vectors are unique - All vectors have a length of n (=7) - The sum of each vector equals x - The number of vectors equals the expected number (based on the combinatorics formula) If I do that for x = 0 through 14, my test will run several seconds. Any of the larger x's will make it run quite a while. If I do it for any of the low numbers, it's trivial. I don't have the combinatorics formula. It's a rather tough problem to express in a constructive formula because of the n=7 limit.
On June 29 2014 20:49 supereddie wrote:Show nested quote +On June 29 2014 20:02 spinesheath wrote: Specifically, I want to calculate a list of all possible ways to split a given number between 0 and x (x is usually 13 or 14) into 7 numbers between 0 and 4 that sum up to x. The order of these 7 numbers is not important, so the numbers should be sorted. The order is not important, therefore they must be sorted? So the order is important... I guess I expressed that badly. I'm not looking for tuples (1, 2, 2, 3, 0, 1, 0), but for multisets {1, 2, 2, 3, 0, 1, 0}. A simple way to work with multisets at this level is to represent them as sorted arrays [0, 0, 1, 1, 2, 2, 3].
On June 29 2014 20:49 supereddie wrote:Show nested quote +On June 29 2014 20:02 spinesheath wrote: So for example with x = 3: (3,0,0,0,0,0,0) (2,1,0,0,0,0,0) (1,1,1,0,0,0,0)
There you go. Your first test case. But maybe start with x=1 to make it easier? So I do that for x = 1 through 5 or so. The number of list elements, starting at x = 1 is: 1, 2, 3, 5, 7, 11, 15, 21, 28, and at that point I stopped counting them manually. Such a test for x = 3 won't verify the correctness for x = 4 and so on. Only at x = 8 I am finally forced to start considering the n = 7 limit. That's a whole lot of hand-written test values, and who knows if that is enough to reach the point where the code yields the correct result for x = 13.
|
You only need to prove that the algorithm is correct; there is no need to to check every possible input. So break down your algorithm in smaller pieces that are easier to verify.
|
On June 29 2014 15:35 Blisse wrote: What are your opinions on people saying "work to live but don't live to work" or other shit like "chase your dreams"? Other than that it's fucking stupid that people use these quotes like they know what they mean and so they sound cool and profound,
I find it stupid how many people in tech. get stuck in this hole where they think work should be everything they do, so "work work work side projects side projects side projects hack hack hack" all the fucking time and there's this equal community who never work on side projects and who keep the stupid "work to live but don't live to work" as a personal motto basically. It might be because I'm still in school but it's so annoying to hear how extreme both sides are, especially where some people keep advertising how much they're preparing work and side projects to get better jobs. And I get really upset reading stuff like this because I know people all across the spectrum and when i talk to them they really don't like having these mentalities projected onto them (i.e. expectation of doing lots of side projects if programming isn't the most important thing in their life).
Work life balance is a weird thing, especially in tech where we are always connected -- but my guess is you would find this in any industry. I think you are tad off base when you say that people who work a lot only do so because they feel like that's what they should be doing, though. Some people, including myself, just really enjoy solving problems with code and being good at what we do. Putting in a lot of time and getting recognition for what you do is a great feeling. Having the satisfaction of solving a really hard problem that no one else on your team could solve is a great feeling. Most people who are in the tech industry probably started working in the field before they ever got paid to do so -- so it doesn't feel completely insane that they would continue to enjoy it after they start doing it as a profession.
I personally find that both sides just say these things to rationalize the decisions that they are making. They want to feel justified in leaving after 40 hrs a week when other coworkers are putting in 60-70 hours a week, or in my case, I want to not feel so bad that I spend more time with my company than I do with my wife and kid. I've chosen to work hard, I don't work on side projects but I'm continually working on making myself better for my current job. I am constantly reading new tech books / articles and trying to figure out if there are new languages or approaches our company could be using. In return, I've been treated well by my company and I've quickly risen through the ranks.
Other people that I work with have taken a different approach, they don't care about the job enough (my opinion, not their words) to work extra. In return, they spend more time with their family, and aren't going to be leading the company any time soon. They show up to work each day, do their work, and go home -- and they are fine with that. In the long run, I am too, because it takes people like that to make my company appreciate the work that I do.
Unfortunately for your dislike of the two extremes, I personally believe there isn't really a middle ground between these two: the job where you get to work a straight 40 and you make a lot of money and continually get promotions is a rarity. This is not a statement that those jobs don't exist, just that they aren't normal. You're going to need to decide which path you want to take, and then you can start using the verbiage that makes you feel good about the decision you made just like everyone else .
|
Yeah, I definitely think it's up to the individual to decide whether what they think is best for them. You shouldn't be forced to go in one direction or the other.
I think I know what you mean by the people who just grow to love solving problems and that's why they push extra hours to get better. I think that's a common occurrence with a lot of people.
My rant was based on those who feel as though they chose the "best" position and openly promote that "don't live to work" idea or the opposite "your job should be your dream". I guess I'm getting a bit jaded thinking that they're idiots in thinking that way and they make people who don't feel the same way feel like shit.
The example I'm referring to (if it makes it clearer) is that: a lot of kids in my program get to go to more well-known companies because they are more involved with side projects and other tech. projects. The same kids then go tell other students how they should live their life, that they should do more side projects like they have done, and they'll be more successful and happier, and while it's valid, it also shits on a lot of people who don't do that because they have other things to do (the group I connect with because I came from that background) in attempt (in my opinion) to elevate themselves above them, and it projects this idea that everyone should be like them and love working. Every time someone posts stuff on the Facebook group or subreddit asking for help, it's always "side projects side projects side projects" rather than helping them decide what extremity is for them. I feel biased, but I really dislike using the extreme verbiage that you "have to do side projects" or that you should not "live to work" that a lot of people I know seem to enjoy using. I especially dislike when they give advice in that same vain as though their experiences are the best way to do it.
|
Reading http://pchiusano.github.io/2014-06-20/simple-debruijn-alternative.html there is something that I don't understand, if anyone proficient in Haskell could explain to me.
I don't understand how this lam function can terminate lam :: (Expr -> Expr) -> Expr lam f = Lam n body where body = f (Var n) n = maxBV body + 1
bot :: Name bot = 0
-- Computes the maximum bound variable in the given expression maxBV :: Expr -> Name maxBV (Var _) = bot maxBV (App f a) = maxBV f `max` maxBV a maxBV (Lam n _) = n
since n makes a call to body, and body makes a call to n.
|
|
|
On June 30 2014 12:40 Blisse wrote: Yeah, I definitely think it's up to the individual to decide whether what they think is best for them. You shouldn't be forced to go in one direction or the other.
I think I know what you mean by the people who just grow to love solving problems and that's why they push extra hours to get better. I think that's a common occurrence with a lot of people.
My rant was based on those who feel as though they chose the "best" position and openly promote that "don't live to work" idea or the opposite "your job should be your dream". I guess I'm getting a bit jaded thinking that they're idiots in thinking that way and they make people who don't feel the same way feel like shit.
The example I'm referring to (if it makes it clearer) is that: a lot of kids in my program get to go to more well-known companies because they are more involved with side projects and other tech. projects. The same kids then go tell other students how they should live their life, that they should do more side projects like they have done, and they'll be more successful and happier, and while it's valid, it also shits on a lot of people who don't do that because they have other things to do (the group I connect with because I came from that background) in attempt (in my opinion) to elevate themselves above them, and it projects this idea that everyone should be like them and love working. Every time someone posts stuff on the Facebook group or subreddit asking for help, it's always "side projects side projects side projects" rather than helping them decide what extremity is for them. I feel biased, but I really dislike using the extreme verbiage that you "have to do side projects" or that you should not "live to work" that a lot of people I know seem to enjoy using. I especially dislike when they give advice in that same vain as though their experiences are the best way to do it. I work at [well-known company], and not doing side projects is totally fine. Getting in definitely does not require any of that. It does require passing weird interview structures that bear little resemblance to the actual job of software, but that's an entirely different topic of discussion...
|
On June 30 2014 15:21 phar wrote:Show nested quote +On June 30 2014 12:40 Blisse wrote: Yeah, I definitely think it's up to the individual to decide whether what they think is best for them. You shouldn't be forced to go in one direction or the other.
I think I know what you mean by the people who just grow to love solving problems and that's why they push extra hours to get better. I think that's a common occurrence with a lot of people.
My rant was based on those who feel as though they chose the "best" position and openly promote that "don't live to work" idea or the opposite "your job should be your dream". I guess I'm getting a bit jaded thinking that they're idiots in thinking that way and they make people who don't feel the same way feel like shit.
The example I'm referring to (if it makes it clearer) is that: a lot of kids in my program get to go to more well-known companies because they are more involved with side projects and other tech. projects. The same kids then go tell other students how they should live their life, that they should do more side projects like they have done, and they'll be more successful and happier, and while it's valid, it also shits on a lot of people who don't do that because they have other things to do (the group I connect with because I came from that background) in attempt (in my opinion) to elevate themselves above them, and it projects this idea that everyone should be like them and love working. Every time someone posts stuff on the Facebook group or subreddit asking for help, it's always "side projects side projects side projects" rather than helping them decide what extremity is for them. I feel biased, but I really dislike using the extreme verbiage that you "have to do side projects" or that you should not "live to work" that a lot of people I know seem to enjoy using. I especially dislike when they give advice in that same vain as though their experiences are the best way to do it. I work at [well-known company], and not doing side projects is totally fine. Getting in definitely does not require any of that. It does require passing weird interview structures that bear little resemblance to the actual job of software, but that's an entirely different topic of discussion...
I still don't understand why interviewers do that. I don't think it helps them find the best candidate for the actual job.
|
Hey guys, i'm new in this thread. Please forgive me if i'm posting this in the wrong thread or if i'm too offtopic.
I'm taking care of an e-commerce website, using Magento. Yesterday i've created a new Storeview for a second language (first being Dutch, second being English). I've translated all the products and categories. But i couldn't discover how to translate the homepage. Since it's a regular page at the CMS > pages section, i did not know how i could create a good translation magento will use when changing storeview on the frontend. I've checked up on several google results, but none really talk about how to create a correct homepage translation. Do any of you know how this works? Thanks for taking the time reading this
|
On June 30 2014 15:21 phar wrote:Show nested quote +On June 30 2014 12:40 Blisse wrote: Yeah, I definitely think it's up to the individual to decide whether what they think is best for them. You shouldn't be forced to go in one direction or the other.
I think I know what you mean by the people who just grow to love solving problems and that's why they push extra hours to get better. I think that's a common occurrence with a lot of people.
My rant was based on those who feel as though they chose the "best" position and openly promote that "don't live to work" idea or the opposite "your job should be your dream". I guess I'm getting a bit jaded thinking that they're idiots in thinking that way and they make people who don't feel the same way feel like shit.
The example I'm referring to (if it makes it clearer) is that: a lot of kids in my program get to go to more well-known companies because they are more involved with side projects and other tech. projects. The same kids then go tell other students how they should live their life, that they should do more side projects like they have done, and they'll be more successful and happier, and while it's valid, it also shits on a lot of people who don't do that because they have other things to do (the group I connect with because I came from that background) in attempt (in my opinion) to elevate themselves above them, and it projects this idea that everyone should be like them and love working. Every time someone posts stuff on the Facebook group or subreddit asking for help, it's always "side projects side projects side projects" rather than helping them decide what extremity is for them. I feel biased, but I really dislike using the extreme verbiage that you "have to do side projects" or that you should not "live to work" that a lot of people I know seem to enjoy using. I especially dislike when they give advice in that same vain as though their experiences are the best way to do it. I work at [well-known company], and not doing side projects is totally fine. Getting in definitely does not require any of that. It does require passing weird interview structures that bear little resemblance to the actual job of software, but that's an entirely different topic of discussion...
I think once you get a couple of decent programming jobs and your resume starts growing, the side project idea doesn't apply, but for new students with little experience I've found that it's all the craze. Without any extracurriculars or job experience, looking for a job doesn't seem that hopeful, which is what I get crossed up with. Yes, I guess it's valid advice to tell people to do the extracurriculars to get better chances of interviewing when applying to jobs, but I'm conflicted about how hard people push others to do this.
|
I'm in a bit of a pickle with Twitter Bootstrap...
I have:
<div class="row"> <div class="col-md-4"> <div class="panel"> </div> </div> <div class="col-md-4"> <div class="panel"> </div> </div> <div class="col-md-4"> <div class="panel"> </div> </div> </div>
More or less. This is just for example purposes as nothing else has any bearing on my problem.
The problem: - panels have varied-height content and I need them all to have the same height (panels, not content, but panels automatically resize to fit content instead of fill available container) - all columns are of the same size, panels won't resize to fill column no matter what I try (height: 100%, min-height: 100%, min-height: fill-available, etc. etc.)
Any ideas?
|
Generally if you want to resize different DIVs to have the same width or height (using the highest width/height of the group) you'll have to use Javascript. Both JQuery and Prototype have simple functions that you can call to get the actual height of the element. You can use that to iterate over all your panels, find the one with the highest height and set them all to that.
Height 100% is really tricky on DIV elements, especially floated ones. It might be better let the panel DIV decide the final height via Javascript and have the col-md-4 DIV just wrap around it.
|
On July 01 2014 20:32 Thezzy wrote: Generally if you want to resize different DIVs to have the same width or height (using the highest width/height of the group) you'll have to use Javascript. Both JQuery and Prototype have simple functions that you can call to get the actual height of the element. You can use that to iterate over all your panels, find the one with the highest height and set them all to that.
Height 100% is really tricky on DIV elements, especially floated ones. It might be better let the panel DIV decide the final height via Javascript and have the col-md-4 DIV just wrap around it.
I came to the same conclusion, although I wanted to try pure CSS approach first (since the site I'm working on is already running high on JS I'm trying to cut corners wherever I can).
|
been working on an old bison generated parser / flex generated scanner / symbol table / other things class in c++ hastily sown together sometimes in the 90s from an older c implementation.
it's pretty cool to see how general flex / bison was [forced to use old versions](esp flex) only using pre-processor directives, but dam... looking at un-indented, and un-indented, generated code, where every identifier might possibly be #undefined and #defined to be half a static yysausage or similar, and behind every #ifdef MANUALLY_COMPILED_IN_LATE_1980S #else #endif is a goto yysausagefactory; is rough!
ah, relief.
|
On July 02 2014 02:25 nunez wrote: been working on an old bison generated parser / flex generated scanner / symbol table / other things class in c++ hastily sown together sometimes in the 90s from an older c implementation.
it's pretty cool to see how general flex / bison was [forced to use old versions](esp flex) only using pre-processor directives, but dam... looking at un-indented, and un-indented, generated code, where every identifier might possibly be #undefined and #defined to be half a static yysausage or similar, and behind every #ifdef MANUALLY_COMPILED_IN_LATE_1980S #else #endif is a goto yysausagefactory; is rough!
ah, relief.
what does it parse?
I took a class on compilers this semester, so I got to know bison and flex little bit. I made a compiler for a little language, I can't even imagine how messy the generated bison code for a real language might look like hehe.
|
|
|
|
|
|