|
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 May 17 2017 04:58 supereddie wrote: Also, maybe you don't need a database at all and just use Excel's data tables? Just put the 'source data' on a seperate sheet . Also also, you can enable 'Filter' on rows and columns (just select the rows/columns in Excel and press Filter): possible filter values will be available in a dropdown.
Yeah, after checking out "ribbontab" (never heard that term before, thought it was something special lol), I dulged in a lot of helpful stuff that most likely covers all my needs. Feel a bit stupid now, I just googled waaaaaay to complicated. I might ditch the database since they already distribute their by hand sorted tables per dropbox.
|
On May 17 2017 05:22 tofucake wrote: I've never even heard of them. What language are they for?
They're for Elixir 
Overall, this looks like slightly worse Rails. If you want simple and performant, you could always go with something like Kemal which is built on top of Crystal. Something I've been wanting to get into lately. We've recently created a simple script in Crystal to populate our database for performance testing and it did it so good that it killed our server (weren't expecting it to be this good).
|
On May 16 2017 16:17 Manit0u wrote:Show nested quote +On May 16 2017 08:54 Nesserev wrote:First of all, format the code in a way so that an actual human can parse it. That said... is this a real copy/paste code example? The code makes no sense, uses no proper function prototyping, setjmp and longjmp clearly work very differently and are improperly used, wtf is this? setjmp (v) int v; { ... } Is this some archaic C dialect, what's going on? It's C89/90: https://software.intel.com/en-us/articles/old-style-c-function-argument-declarations-are-supportedAlso, the code is formatted really bad even in the PDF. I guess someone has been teaching C for a long time and never bothered to actually track changes to the language or educate themselves past the initial point... Doesn't bode well. Edit: Here's the code brought up to a bit more modern standards (but it still doesn't make much sense): + Show Spoiler + #include <stdio.h>
int setjmp(int v); int longjmp(int v); int fun1(void); int fun2(void);
int main(void) { int r = setjmp(r);
if (r != 0) { printf("error\n");
return 2; }
fun1();
return 0; }
int setjmp(int v) { /* ... */ return 0; }
int longjmp(int v) { /* ... */ return 1; }
int fun1(void) { printf("start fun1\n");
fun2();
return 0; }
int fun2(void) { int d;
printf("start fun2\n");
longjmp(d);
return 0; }
+ Show Spoiler + #include <stdio.h>
int setjmp(int v); int longjmp(int v); int fun1(void); int fun2(void); int *add; //using global, not sure if best idea int main(void) { int r = setjmp(r); if(r!=0) { printf("error\n"); return 2; } fun1(); return 0; } int setjmp(int v) { add = &v; //used a global variable return 0; } int longjmp(int v) { int *p; //pointer p = &v; //save argument address *(p-1) = *add; //return address = address in main return 1; } int fun1(void) { printf("hi1");//testing fun2(); printf("hi2");//testing return 0; } int fun2(void) { int a; longjmp(a); return 0; }//output SHOULD be "hi1" //output is currently "hi1" "hi2"
Here's my latest attempt at it. I added comments to all lines I added and slightly modified so I can test easier while coding.
Honestly not sure if this is the right approach but as I understand it the call stack has the arguments of the function right above the return address so by changing *(p-1) I am changing the return address in the stack?
I'm pretty lost. Prof kind of alluded to doing something with the stack and said we just need to make it output "hi1" only and he doesn't care too much how we code it as long as we're not using builtins/assembly/some other 'clearly disingenuous way'. Anyone got something for me? D: My TA's basically told me they have no idea how to do this and would have to look over it during this week to figure it out lol.
Also please let me know if my use of pointers are bad, I'm very new to C and haven't touched C/C++ pointers since my intro class.
edit:
I have another idea but I'll try again in the morning. I'll update if I finish some code up before work.
|
Showing 90 changed files with 98 additions and 517 deletions
I like to commit removal of 65 files from our migrations. Panic is slowly spreading
|
On May 17 2017 05:40 Manit0u wrote:Show nested quote +On May 17 2017 05:22 tofucake wrote: I've never even heard of them. What language are they for? They're for Elixir  Overall, this looks like slightly worse Rails. If you want simple and performant, you could always go with something like Kemal which is built on top of Crystal. Something I've been wanting to get into lately. We've recently created a simple script in Crystal to populate our database for performance testing and it did it so good that it killed our server (weren't expecting it to be this good). Fuck performance, I want my shit to work at all times. Erlang VM (the shit that Elixir runs on) is so fucking stable that people say bad things about you when you program defensively. It might have its shortcomings, but stability is not one of them. Neither is performance.
|
On May 17 2017 05:37 Artesimo wrote:Show nested quote +On May 17 2017 04:58 supereddie wrote: Also, maybe you don't need a database at all and just use Excel's data tables? Just put the 'source data' on a seperate sheet . Also also, you can enable 'Filter' on rows and columns (just select the rows/columns in Excel and press Filter): possible filter values will be available in a dropdown. Yeah, after checking out "ribbontab" (never heard that term before, thought it was something special lol), I dulged in a lot of helpful stuff that most likely covers all my needs. Feel a bit stupid now, I just googled waaaaaay to complicated. I might ditch the database since they already distribute their by hand sorted tables per dropbox.

Seriously, wtf.
E: I mean, sure, there's plenty of perfectly reasonable things you can do this for. But this is a production database of important stuff we're talking about right?
|
|
I think it's likely we don't understand what the professor wants, because dyslexic is missing something or the professor hasn't communicated it properly.
in other news, my last final(discrete structures) i got an 86. I don't know what the curve was yet.
So I passed all my classes. On to the 300 level! 351 (notoriously hard class) this summer. I am sure I will be VERY active here, and some of you will probably have a lot of fun with the questions.
|
On May 17 2017 20:28 Nesserev wrote:Show nested quote +On May 17 2017 13:48 dsyxelic wrote:On May 16 2017 16:17 Manit0u wrote:On May 16 2017 08:54 Nesserev wrote:First of all, format the code in a way so that an actual human can parse it. That said... is this a real copy/paste code example? The code makes no sense, uses no proper function prototyping, setjmp and longjmp clearly work very differently and are improperly used, wtf is this? setjmp (v) int v; { ... } Is this some archaic C dialect, what's going on? It's C89/90: https://software.intel.com/en-us/articles/old-style-c-function-argument-declarations-are-supportedAlso, the code is formatted really bad even in the PDF. I guess someone has been teaching C for a long time and never bothered to actually track changes to the language or educate themselves past the initial point... Doesn't bode well. Edit: Here's the code brought up to a bit more modern standards (but it still doesn't make much sense): + Show Spoiler + #include <stdio.h>
int setjmp(int v); int longjmp(int v); int fun1(void); int fun2(void);
int main(void) { int r = setjmp(r);
if (r != 0) { printf("error\n");
return 2; }
fun1();
return 0; }
int setjmp(int v) { /* ... */ return 0; }
int longjmp(int v) { /* ... */ return 1; }
int fun1(void) { printf("start fun1\n");
fun2();
return 0; }
int fun2(void) { int d;
printf("start fun2\n");
longjmp(d);
return 0; }
+ Show Spoiler + #include <stdio.h>
int setjmp(int v); int longjmp(int v); int fun1(void); int fun2(void); int *add; //using global, not sure if best idea int main(void) { int r = setjmp(r); if(r!=0) { printf("error\n"); return 2; } fun1(); return 0; } int setjmp(int v) { add = &v; //used a global variable return 0; } int longjmp(int v) { int *p; //pointer p = &v; //save argument address *(p-1) = *add; //return address = address in main return 1; } int fun1(void) { printf("hi1");//testing fun2(); printf("hi2");//testing return 0; } int fun2(void) { int a; longjmp(a); return 0; }//output SHOULD be "hi1" //output is currently "hi1" "hi2"
Here's my latest attempt at it. I added comments to all lines I added and slightly modified so I can test easier while coding. Honestly not sure if this is the right approach but as I understand it the call stack has the arguments of the function right above the return address so by changing *(p-1) I am changing the return address in the stack? I'm pretty lost. Prof kind of alluded to doing something with the stack and said we just need to make it output "hi1" only and he doesn't care too much how we code it as long as we're not using builtins/assembly/some other 'clearly disingenuous way'. Anyone got something for me? D: My TA's basically told me they have no idea how to do this and would have to look over it during this week to figure it out lol. Also please let me know if my use of pointers are bad, I'm very new to C and haven't touched C/C++ pointers since my intro class. edit: I have another idea but I'll try again in the morning. I'll update if I finish some code up before work. So, setjmp and longjmp's goal is to basically unwind the stack instantly to a certain prior state (when setjmp is called; stack frame of calling function still has to be on the stack when calling longjmp). Normally, this is done by saving the content of all registers to a buffer, and then using longjmp later to overwrite all current register values. Problem is, you can't access the register values without assembly... so yeah, throw the idea of implementing the actual behaviour of setjmp and longjmp out of the boat, cause that's not gonna happen. (An added problem is that, because during the execution of a function not all variables are necessarily stored within registers, and variables can be changed or pushed/popped from the stack during function execution, it becomes clear that setjmp and longjmp can lead to some nasty shit. However, this probably won't be a problem with such simple functions, so let's ignore that.) -- So, let's go back to the ultimate goal of using setjmp/longjmp, which is stack unwinding. Can you unwind the stack without directly accessing any registers? Well, you could try manipulating registers by manipulating the return addresses on the stack, but then you end up again in "implementation land" with call conventions, compiler implementations, etc. which is probably way worse than the relatively clean "default" solution of setjmp and longjmp. So, uh... I think this is a lost battle. I'd be glad if anyone could correct me :/
Here's a nice article about it: http://blog.reverberate.org/2013/05/deep-wizardry-stack-unwinding.html
I'm not a C dev myself (just an occasional dabbler) so I can't help much in this case.
|
I asked on stackoverflow and got similar responses (cant be done or awful assignment forcing bad workarounds which defeats purpose of assignment). I gave pretty much all the directions I was given...
Dunno if this helps but this was what the professor showed and talked about using the stack. He said he basically gave us the answer to the project with this: + Show Spoiler +
|
Wait a second. Your professor is giving you examples of code written in style that was used 30 years ago, that is compiled for embedded system/router architecture which was introduced 32 years ago?
This is madness...
|
On May 17 2017 23:28 Manit0u wrote: Wait a second. Your professor is giving you examples of code written in style that was used 30 years ago, that is compiled for embedded system/router architecture which introduced 32 years ago?
This is madness...
Yeah idk this is easily the worst cs class ive taken. My data structures class was in pascal as well but wasnt as bad since we were allowed to choose from python or c/c++ for any submissions. This prof is ridiculously lazy. Used same slides for years (not even made by him and is out of date) and the random midterm uploaded online by a student 5 years ago was pretty much identical to the midterm we just took.
|
trying to understand this is like the world's hardest puzzle
|
On May 17 2017 23:13 dsyxelic wrote:I asked on stackoverflow and got similar responses (cant be done or awful assignment forcing bad workarounds which defeats purpose of assignment). I gave pretty much all the directions I was given... Dunno if this helps but this was what the professor showed and talked about using the stack. He said he basically gave us the answer to the project with this: + Show Spoiler +
Image links are broken.
|
On May 17 2017 23:38 dsyxelic wrote:Show nested quote +On May 17 2017 23:28 Manit0u wrote: Wait a second. Your professor is giving you examples of code written in style that was used 30 years ago, that is compiled for embedded system/router architecture which introduced 32 years ago?
This is madness... Yeah idk this is easily the worst cs class ive taken. My data structures class was in pascal as well but wasnt as bad since we were allowed to choose from python or c/c++ for any submissions. This prof is ridiculously lazy. Used same slides for years (not even made by him and is out of date) and the random midterm uploaded online by a student 5 years ago was pretty much identical to the midterm we just took.
This is highly suspicious. Clearly you can change the return address by writing in the stack but the main problem is restoring the SP. The slide does not show the epilogue of the function, just before the j $31.Though if you use this web site https://godbolt.org/ you can see that it would have
addiu $sp,$sp,40
And there is no way (that I know) to do this without assembly.
Anyway, I would give up and ask him when he returns the assignment.
|
If i wanted to study multivariable calculus on my own, for purposes of machine learning, can anyone set me on a track of what I could study for that?
Like, to avoid an entire course worth of work, a way to study only the topics that are relevant to ML ?
|
@acrofales Sorry I was unable to get it fixed but the direct links work. Not sure if a tl issue or that sites issue. Id make another but away from pc atm.
@hanh Thats what Ive been hearing too. The weird thing is we were given 3weeks for this assignment which implies that its difficult, but the prof basically straight up said he did the assignment for us with the above example so that would mean it should be easy...
I still have 2 weeks on this so Ill prob bother the prof more till he tells me to f off. Going to my friend after work today who used to ta for this guy since my current ta's seem just as lost. If he cant get it it probably means giving up or just ignoring his stipulations.
|
If the professor is a scumbag, I would consider going to a professor who is not a scumbag who has also taught C at the college, approaching him in a very courteous and professional way and ask him to try to help make sense of it.
If even another prof can't make sense of it then you have grounds to challenge it if it hurts your grade.
|
On May 17 2017 23:41 Acrofales wrote:Show nested quote +On May 17 2017 23:13 dsyxelic wrote:I asked on stackoverflow and got similar responses (cant be done or awful assignment forcing bad workarounds which defeats purpose of assignment). I gave pretty much all the directions I was given... Dunno if this helps but this was what the professor showed and talked about using the stack. He said he basically gave us the answer to the project with this: + Show Spoiler + Image links are broken.
+ Show Spoiler [Fixed links] +
|
|
|
|
|