This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
blog:spring2016:aslater1:journal [2016/03/09 04:12] – [March 6, 2016] aslater1 | blog:spring2016:aslater1:journal [2016/05/05 00:39] (current) – [May 4, 2016] aslater1 | ||
---|---|---|---|
Line 104: | Line 104: | ||
I'm so close to getting the mbe1 project done! Unfortunately, | I'm so close to getting the mbe1 project done! Unfortunately, | ||
This project wasn't so bad, I think I'm getting arrays more. They' | This project wasn't so bad, I think I'm getting arrays more. They' | ||
- | I thought I was going crazy when I kept seeing a '' | + | I thought I was going crazy when I kept seeing a '' |
+ | |||
+ | ====March 9, 2016==== | ||
+ | I take it all back, Mercurial. \\ | ||
+ | **__Learn' | ||
+ | * Loops evaluate chronologically | ||
+ | * Make sure to initialize stuff at 0, to make sure it doesn' | ||
+ | * Print out each step of the loop, including if statements | ||
+ | * Version control source code in the case that you, say, accidentally overwrite it | ||
+ | |||
+ | ====March 15, 2016==== | ||
+ | I'm still working on the cos0 project, and so far so good. My math is off, as only one quarter of the circle is visible, but I'll keep tinkering, hopefully I'll get it together. \\ | ||
+ | On an unrelated note: I am __super__ pumped to be learning about file input/ | ||
+ | ====March 17, 2016==== | ||
+ | Finally got done done with cos0, and just shy of 160 lines. All right! Getting better with loops, although I did have a seemingly superfluous " | ||
+ | **__Learn' | ||
+ | * warning incompatible ... -> check to make sure you included the header file | ||
+ | * if statements can save from seg faults | ||
+ | * Math > trial + error | ||
+ | ====March 28, 2016==== | ||
+ | So the sam0 project was a no go, not really proud of that one. I'm going to redo it, just to make sure that I really grasp the idea of multiple functions. \\ \\ I'm really excited to start working with C++, I'm still a little shaky on the idea of object-oriented languages, but I think I'm on the verge of getting it. My plan is to write make a simple game, // | ||
+ | ====April 7, 2016==== | ||
+ | The cbf project is done, and I kept having a problem with getting the program to stop output once it reaches the end of the file. Because the characters were actually printed in a for loop that was nested inside of the while loop, the while loop would have already run before the for loop could determine if if had reached the end of the file. \\ \\ | ||
+ | I cobbled together a solution involving an array ( which I should have stored the '' | ||
+ | ====April 11, 2016==== | ||
+ | So I was thinking that I could manage to get through this course without the use of pointers, but unfortunately that is not the case ( which is probably a good thing).\\ \\ ' | ||
+ | ====April 12, 2016==== | ||
+ | Getting really weird output? Try initialing the variable to 0. | ||
+ | ====April 17, 2016==== | ||
+ | < | ||
+ | int i = 0 | ||
+ | int proj [ i ]; | ||
+ | ... | ||
+ | proj[ i ] = something; | ||
+ | </ | ||
+ | WILL SEGFAULT | ||
+ | < | ||
+ | int i; | ||
+ | int proj[ i ]; | ||
+ | ... | ||
+ | proj[i] = something; | ||
+ | </ | ||
+ | WILL **NOT** SEGFAULT ( but is still bad ) | ||
+ | i is typically the incremental value ( so you don't really use it for the declaration), | ||
+ | ====April 19, 2016==== | ||
+ | Holy wall of text, Batman! \\ | ||
+ | Here's the thing: it turns out if you initialize an array with an index of 0, you're going to have a bad time. Which makes since because you're saying that you want to store zero elements. That's why it will crash and burn when you run the program. \\ \\ In more relevant news, I actually went back through and fixed what may have been the most inefficient program ever. Instead of having main make the array, I just opened the file in each one of my functions (4 times). That was just the beginning, as there were nested loops and a million variables with no point. \\ \\ I went back through and had main put all the values in the array, and then passed the pointers to the functions. This way I didn't have to open and close the file, and the math turned out to be a lot easier. The code itself is way less complex, and I managed to cut down on more than 40 lines of superfluous garbage. In other words, I think I'm //finally// starting to embrace pointers. Just in time for the semester to be over! | ||
+ | ====May 2, 2016==== | ||
+ | So I've been doing the stuff. | ||
+ | \\ \\ I used some(a lot) switch cases in the project. They took a little to get used to, but they' | ||
+ | \\ \\ Por Ejemplo: | ||
+ | <code c 1> | ||
+ | switch (pineapple_pizza) | ||
+ | { | ||
+ | case 1: | ||
+ | printf(" | ||
+ | break; | ||
+ | case 2: | ||
+ | printf(" | ||
+ | break; | ||
+ | case 3: | ||
+ | printf(" | ||
+ | break; | ||
+ | case 4: | ||
+ | printf(" | ||
+ | break; | ||
+ | default: | ||
+ | printf(" | ||
+ | exit(1); | ||
+ | } | ||
+ | </ | ||
+ | Where the "case #" is referring to the condition you're checking for. Don't forget the '':'' | ||
+ | ====May 4, 2016==== | ||
+ | Oh man, I just had all of the breakthroughs. | ||
+ | \\ \\ Turns out, if you're compiling multiple c files, and you simply use | ||
+ | < | ||
+ | gcc file1.c file2.c file3.c -o combinedfiles | ||
+ | </ | ||
+ | Your functions won't be able to " | ||
+ | \\ \\ | ||
+ | So, when using multiple files you can just throw the above into a header file (making sure to include it in main). When you compile the c files functions work! | ||
+ | <code c 1> | ||
+ | #ifndef HEADERFILE_H_ | ||
+ | #define HEADERFILE_H_ | ||
+ | |||
+ | int stuff(char this, char that); | ||
+ | |||
+ | #endif | ||
+ | </ | ||
======UNIX/ | ======UNIX/ | ||
====January 25, 2016==== | ====January 25, 2016==== | ||
Line 167: | Line 256: | ||
- tar -cf [something.tar] [desired file] | - tar -cf [something.tar] [desired file] | ||
- Be careful w/ chmod | - Be careful w/ chmod | ||
+ | |||
+ | ====March 8, 2016==== | ||
+ | Much customization very wow. \\ | ||
+ | I //may// have procrastinated a little bit on this one. Setting the path to home is just '' | ||
+ | I'm planning on doing some more reading into the config files and their options, they seem pretty neat. | ||
+ | ====March 14, 2016==== | ||
+ | I kept getting an error message when I was converting the rle image to the png format. I think I might have accidentally altered one of the files because when I did the whole thing over again, everything was okay.\\ | ||
+ | **__Learn' | ||
+ | * offset: is the distance from the beginning of the file, this is why this number gets " | ||
+ | * count: Count this many " | ||
+ | ====March 21, 2016==== | ||
+ | I've been doing some exploration of grep and Wget for that matter. I'm trying to find a way to view the contents of a web page and grep it to just show certain information. I've been trying curl, too which is pretty similar to Wget. I also downloaded lynx, which is probably the coolest browser ever (move over Google Chrome). \\ | ||
+ | I kind of regret not paying as much attention to wget in the customization project, it has some __really__ cool features. I already went back and made some adjustments to my terrible, terrible config file. Cool stuff, yo. | ||
+ | ====March 28, 2016==== | ||
+ | I wasn't really aware of what an mbr was, so learning about it was pretty cool. The next project looks a little intimidating and complex. \\ \\ | ||
+ | I'm still getting used to using regular expressions, | ||
+ | ====April 5, 2016==== | ||
+ | So, all the stuff I said I would do last week is a no-go. I still want to make a variation of primerun so I'm not going to abandon that pursuit. | ||
+ | \\ \\ Regular expressions are tripping me up a a little bit, but I think that practice will help. I'm using more wildcards, so hopefully it will be the same with Regular Expressions. | ||
+ | \\ \\ Still working on udr2, and I see that time management is a factor of the next project. | ||
+ | ====April 11, 2016==== | ||
+ | chmod! | ||
+ | |||
+ | ^ Privilege | ||
+ | ^ read | **r** | 4 | | ||
+ | ^ write | **w** | 2 | | ||
+ | ^ execute | ||
+ | |||
+ | There are three modes: | ||
+ | User Mode: u \\ | ||
+ | Group Mode: g \\ | ||
+ | Other Mode: o \\ | ||
+ | Example: | ||
+ | < | ||
+ | -rw-rwxr-- | ||
+ | with modes being: | ||
+ | u | ||
+ | -|rw-| | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | The command to set a file to have these privileges would be | ||
+ | < | ||
+ | chmod 674 somefile | ||
+ | </ | ||
+ | ===Set UID, GID & Sticky Bit=== | ||
+ | Really good information [[https:// | ||
+ | |||
+ | This one's a little different. UID/GID are denoted by an upper or lowercase '' | ||
+ | Sooo...\\ | ||
+ | SET UID: 4 \\ | ||
+ | SET GID: 2 \\ | ||
+ | STICKY BIT: 1 \\ | ||
+ | ==Where' | ||
+ | ^ S location | ||
+ | ^ User | | ||
+ | ^ Group | ||
+ | ^ Both | | ||
+ | ^ " | ||
+ | ^ " | ||
+ | |||
+ | The ' | ||
+ | Example: | ||
+ | < | ||
+ | | ||
+ | -|rws| | ||
+ | | ||
+ | | ||
+ | 7665 | ||
+ | |||
+ | or | ||
+ | | ||
+ | -|rws| | ||
+ | | ||
+ | | ||
+ | 7664 | ||
+ | </ | ||
+ | ====April 20, 2016==== | ||
+ | Oh man, I can't remember the last time I submitted a Unix project on time. Not gonna lie, it feels pretty good. I think this was the first time I made, by myself, an actual complex-ish shell script. It doesn' | ||
+ | To get the values for the project portion I used an array, and I tried comapring it the way I'm used to, something like | ||
+ | < | ||
+ | array[index] | ||
+ | .... | ||
+ | array[i] = stuff | ||
+ | </ | ||
+ | but it just got too complicated. So, what I ended up doing instead is this: | ||
+ | < | ||
+ | array=(`command to get all the values of said array into a space separated list`) | ||
+ | </ | ||
+ | I actually did 2 arrays this way, and incremented through them both with a cool for loop. That being said...: | ||
+ | < | ||
+ | ${arr[*]} | ||
+ | ${!arr[*]} # All of the indexes in the array | ||
+ | ${#arr[*]} # Number of items in the array | ||
+ | ${#arr[0]} # Length of item zero | ||
+ | </ | ||
+ | with more information here [[http:// | ||
+ | \\ Yes.\\ | ||
+ | \\ Escape sequences are pretty cool. Unfortunately my c program now looks dull by comparison. \\ | ||
+ | | ||
+ | Wow, I feel like its been forever since I've done one of these. \\ So I've been working on the eoce and its been going ' | ||
+ | <code bash 1> | ||
+ | if [ some condition ]; then | ||
+ | whatever | ||
+ | fi | ||
+ | </ | ||
+ | Is the correct syntax for an if statement, don't have anything touch the brackets(besides ;), either.\\ \\ If there' | ||
+ | What if there' | ||
+ | <code bash 1> | ||
+ | if [ some condition ]; then | ||
+ | whatever | ||
+ | elif [ some other condition ]; then | ||
+ | whatever | ||
+ | elif [ another condition ]; then | ||
+ | whatever | ||
+ | else ## | ||
+ | whatever | ||
+ | fi | ||
+ | </ | ||
+ | What if you want a COMPOUND if statement, ie if this AND/OR this? | ||
+ | <code bash 1> | ||
+ | if [ some condition ]; then | ||
+ | whatever | ||
+ | elif [ some condition ] || [ another condition ]; then | ||
+ | whatever | ||
+ | elif [ some condition ] && [ other condition ]; then | ||
+ | whatever | ||
+ | fi | ||
+ | </ |