This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct foo | |
| { | |
| int x; | |
| float y; | |
| }; | |
| struct foo var; | |
| struct foo* pvar; | |
| var.x = 5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Login shell: .bash_profile | |
| Interactive shell: .bashrc | |
| To color code your prompt on a Mac, use the following template: | |
| \[\033[COLOR_CODE_HERE\]PROMPT_ESCAPE_OR_TEXT_HERE\[\033[0m\] | |
| ---------------------------------------------------------------------------- | |
| Most Linux distributions use a little different format: | |
| \e[COLOR_CODE PROMPT_ESCAPE\e[0m | |
| ---------------------------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| redirect.c | |
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <fcntl.h> | |
| #include <sys/types.h> | |
| #include <sys/stat.h> | |
| /** | |
| * Executes the command "grep Villanova < scores > out". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #TF-IDF | |
| TF-IDF = tf * idf = tf * log(N/n) | |
| tf: number of times a term appears in a document | |
| N: total number of documents | |
| n: number of documents that contain a term | |
| TF-IDF stands for "Term Frequency, Inverse Document Frequency". | |
| It is a way to score the importance of words (or "terms") in a | |
| document based on how frequently they appear across multiple documents. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| All POSIX semaphore functions and types are prototyped or defined in semaphore.h. To define a semaphore object, use | |
| sem_t sem_name; | |
| To initialize a semaphore, use sem_init(): | |
| int sem_init(sem_t *sem, int pshared, unsigned int value); | |
| sem points to a semaphore object to initialize | |
| pshared is a flag indicating whether or not the semaphore should be shared with fork()ed processes. LinuxThreads does not currently support shared semaphores | |
| value is an initial value to set the semaphore to | |
| Example of use: | |
| sem_init(&sem_name, 0, 10); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| monitor DP { | |
| status state[5]; | |
| condition self[5]; | |
| // Pickup chopsticks | |
| Pickup(int i){ | |
| state[i] = hungary; // indicate that I'm hungary | |
| test(i); //set state to eating in test() only if my | |
| //left and right neighbors are not eating | |
| if(state[i] != eating) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //The name of our remote is origin and the default local branch name is master. | |
| //The -u tells Git to remember the parameters, so that next time we can simply | |
| //run git push and Git will know what to do. Go ahead and push it! | |
| git push -u origin master | |
| //diff of most recent commit, which we can refer to using the HEAD pointer | |
| git diff HEAD | |
| git diff --staged | |
| //unstage files by using the git reset command |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| char* ReadFile(char *filename) | |
| { | |
| char *buffer = NULL; | |
| int string_size,read_size; | |
| FILE *handler = fopen(filename,"r"); | |
| if (handler) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Arithmatic Expansion | |
| # Arithmetic expansion with backticks (often used in conjunction with expr) | |
| # Arithmetic expansion with double parentheses, and using let | |
| z=$(($z+3)) | |
| z=$((z+3)) # Also correct. | |
| # Within double parentheses, | |
| #+ parameter dereferencing | |
| #+ is optional. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //comment and uncomment multiple lines | |
| //commenting lines from 66 to 70 (inclusive). | |
| :66,70s/^/# | |
| :66,70s/^#/ |
OlderNewer