├── make.sh ├── advice.png ├── .gitignore ├── README.md ├── LICENSE └── advice.c /make.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cc -std=c99 -g -O0 advice.c -o advice 4 | -------------------------------------------------------------------------------- /advice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/afiskon/c-good-advice/HEAD/advice.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | advice 31 | 32 | # Debug files 33 | *.dSYM/ 34 | *.su 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # c-good-advice 2 | 3 | A good free advice or quote every day! 4 | 5 | Hint: add to your ~/.bashrc: 6 | 7 | ``` 8 | # Message Of The Day 9 | alias advice="advice | cowsay" 10 | advice 11 | ``` 12 | 13 | ![Good advice](https://raw.githubusercontent.com/afiskon/c-good-advice/master/advice.png?20170528) 14 | 15 | Crossplatform Python version of cowsay [can be found here](https://github.com/afiskon/archlinux-on-desktop/blob/master/home/eax/bin/cowsay). 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-2018, Aleksander Alekseev 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /advice.c: -------------------------------------------------------------------------------- 1 | /* vim: set ai et ts=4 sw=4: */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define VERSION "0.3" 9 | 10 | static const char* advices[] = { 11 | "Be yourself.", 12 | "A man can be himself only so long as he is alone, " 13 | "and if he does not love solitude, he will not love freedom, " 14 | "for it is only when he is alone that he is really free.", 15 | "Who are you? What do you want?", 16 | "A second chance! That’s the delusion. There never was to be but one. " 17 | "We work in the dark - we do what we can - we give what we have. " 18 | "Our doubt is our passion, and our passion is our task. " 19 | "The rest is the madness of art.", 20 | "And that's why you are dangerous. You've mastered your passions.", 21 | "Say what you know, do what you must, come what may.", 22 | "KISS", 23 | "DRY", 24 | "Performance is not a problem.", 25 | "To improve is to change; to be perfect is to change often.", 26 | "If you can't hack it you don't own it.", 27 | "Where other men blindly follow the truth, remember, nothing is true. " 28 | "Where other men are limited by morality or law, remember, everything is permitted.", 29 | "Know the rules well, so you can break them effectively.", 30 | "Choose to be optimistic, it feels better.", 31 | "One great question underlies our experience, whether we think about it or " 32 | "not: what is the purpose of life? ... From the moment of birth every " 33 | "human being wants happiness and does not want suffering. Neither social " 34 | "conditioning nor education nor ideology affects this. From the very core of " 35 | "our being, we simply desire contentment ... Therefore, it is important to " 36 | "discover what will bring about the greatest degree of happiness.", 37 | "Share your knowledge. It is a way to achieve immortality.", 38 | "There are two kinds of designs in this world: those that are useful, " 39 | "and those that you can formally prove to be correct.", 40 | "What I cannot create I do not understand.", 41 | "The best way to learn is by making mistakes.", 42 | "I would't like to be in your shoes, Connor. What could be worse than having to choose between two evils?", 43 | "Keep your expectations low boy, and you'll never be disappointed.", 44 | "Success is not final, failure is not fatal: it is the courage to continue that counts.", 45 | }; 46 | 47 | 48 | unsigned int 49 | hash(const unsigned char *data, const size_t data_len) { 50 | unsigned int hash = 0x4841434B; 51 | for(int i = 0; i < data_len; i++) { 52 | hash = ((hash << 5) + hash) + data[i]; 53 | } 54 | return hash; 55 | } 56 | 57 | int 58 | main(int argc, char* argv[]) 59 | { 60 | struct timeval time = {0}; 61 | 62 | if(argc > 1) 63 | { 64 | if((strcmp(argv[1], "-v") == 0) || (strcmp(argv[1], "--version") == 0)) 65 | { 66 | printf( 67 | "advice v" VERSION "\n" 68 | "(c) Aleksander Alekseev 2016-2018 | https://eax.me/\n" 69 | ); 70 | return 0; 71 | } else { 72 | fprintf(stderr, "Usage: %s [-v|--version]\n", argv[0]); 73 | return 1; 74 | } 75 | } 76 | 77 | gettimeofday(&time, NULL); 78 | 79 | /* srand((time.tv_sec * 1000) + (time.tv_usec / 1000)); */ 80 | srand(hash((const unsigned char*)&time, sizeof(time))); 81 | 82 | int idx = (sizeof(advices)/sizeof(advices[0])) * (((double)rand()) / ((double)RAND_MAX+1.0)); 83 | printf("%s\n", advices[idx]); 84 | return 0; 85 | } 86 | --------------------------------------------------------------------------------