Musings
Tuesday, October 26, 2010
LFS - Linux from Scratch
A new day a new project. Today I've started to work on my LFS build. I am preparing my spare G3 Mac (eeew) to be a dev environment for LFS. At this point I am not sure if this computer will be suitable for a dev environment as i have not been able to install other versions of Linux.
If not there's always my eeepc.
LFS - Linux from Scratch
A new day a new project. Today I've started to work on my LFS build. I am preparing my spare G3 Mac (eeew) to be a dev environment for LFS. At this point I am not sure if this computer will be suitable for a dev environment as i have not been able to install other versions of Linux.
If not there's always my eeepc.
Saturday, October 16, 2010
Hey guys,
So in the last tutorial we looked at how to output to the terminal using std::cout. This is a really useful tool however we cannot actually create anything to output other than what we have hard coded into the application. This tutorial shows how to modify what we have in the program to create something more interesting.
Code
Output
11
3
28
1
3
Now what does all this mean? Let's analyse each line. First there is the standard introduction which we used with our Hello World program. We #include the iostream library which contains cout and endl. We then define some variables as integers using the keyword int. Each declaration is formatted like this "int variableName = value". You can also set a variable with just the type, such as with 'c'.
Once we have created our variables we will run them through operations. By placing an operation on the right of an equals sign we put the result into the variable on the left. So 'c = a + b' really is the same as how we would format it in mathematics. After each operation we output to the screen the result, which is stored in c, and the endl command, which performs a line break.
Look at each equation. We can see addition, subtraction, multiplication and division. But what is this last one? This % is called modulus. This looks for the remainder of any division equation. We can see this in the output. 7 % 4 is 3, because 7 goes into 4 once with a remainder of 3. Note that because we are using integers the division of 7/4 does not equal 1.75 as would be the case with real numbers, but 1. This is the total number of times 7 will divide as an integer, or whole number.
This is a good way of seeing how the simple math tools work for C++.
Any questions?
So in the last tutorial we looked at how to output to the terminal using std::cout. This is a really useful tool however we cannot actually create anything to output other than what we have hard coded into the application. This tutorial shows how to modify what we have in the program to create something more interesting.
Code
#include
using namespace std;
int main() {
int a = 7;
int b = 4;
int c;
c = a + b;
cout << c << endl;
c = a - b;
cout << c << endl;
c = a * b;
cout << c << endl;
c = a / b;
cout << c << endl;
c = a % b;
cout << c << endl;
return 0;
}Output
11
3
28
1
3
Now what does all this mean? Let's analyse each line. First there is the standard introduction which we used with our Hello World program. We #include the iostream library which contains cout and endl. We then define some variables as integers using the keyword int. Each declaration is formatted like this "int variableName = value". You can also set a variable with just the type, such as with 'c'.
Once we have created our variables we will run them through operations. By placing an operation on the right of an equals sign we put the result into the variable on the left. So 'c = a + b' really is the same as how we would format it in mathematics. After each operation we output to the screen the result, which is stored in c, and the endl command, which performs a line break.
Look at each equation. We can see addition, subtraction, multiplication and division. But what is this last one? This % is called modulus. This looks for the remainder of any division equation. We can see this in the output. 7 % 4 is 3, because 7 goes into 4 once with a remainder of 3. Note that because we are using integers the division of 7/4 does not equal 1.75 as would be the case with real numbers, but 1. This is the total number of times 7 will divide as an integer, or whole number.
This is a good way of seeing how the simple math tools work for C++.
Any questions?
Wednesday, October 13, 2010
Quitting - Having no time
Having no time in something which many people claim is an issue for them. I was one of these people until I had a revelation. I did one simple calculation and have since changed my perspective on time.
Hours in the day X Days in the week
24 X 7
That makes 168 hours in the week. This does not sound like much until you start to take the things you percieve as taking up the most of your time out and look at how much free time you actually have.
Here is the breakdown of my time.
If I sleep 8 hours a night that totals to 56 hours a week. I still have 112 hours left. I then take
Sleep - 8 hours a night - 56 hours a week
Shower/shave - 35 mins a day - 4.5 hours a week
Travel - 1.5 hours each way - 21 hours a week
Work - 8 hours 5 days a week - 40 hours a week
House chores/eating - 1 hour per day (This is definitely an exaggeration) - 7 hours a week
Totalled up, that's 128.5 hours per week. That leaves me with 39.5 hours a week totally unaccounted for. I have eaten, showered, travelled, worked, travelled, eaten, something and slept.
The next step in this experiment is to find out what I fill those last 39.5 hours a week on and better manage them. At this point I am not using them properly and this needs to change.
Hours in the day X Days in the week
24 X 7
That makes 168 hours in the week. This does not sound like much until you start to take the things you percieve as taking up the most of your time out and look at how much free time you actually have.
Here is the breakdown of my time.
If I sleep 8 hours a night that totals to 56 hours a week. I still have 112 hours left. I then take
Sleep - 8 hours a night - 56 hours a week
Shower/shave - 35 mins a day - 4.5 hours a week
Travel - 1.5 hours each way - 21 hours a week
Work - 8 hours 5 days a week - 40 hours a week
House chores/eating - 1 hour per day (This is definitely an exaggeration) - 7 hours a week
Totalled up, that's 128.5 hours per week. That leaves me with 39.5 hours a week totally unaccounted for. I have eaten, showered, travelled, worked, travelled, eaten, something and slept.
The next step in this experiment is to find out what I fill those last 39.5 hours a week on and better manage them. At this point I am not using them properly and this needs to change.
Sunday, October 10, 2010
Motivation method - how much does it cost?
One method of motivation which people often find works well is the 'how much will this cost me? ' method. The standard methodology is to look at the long term costs of something and from that decide if it is worth it.
An example is smoking. If I smoke alarm pack of cigarettes per day and each pack costs $12, which is pretty average nowadays, how much will it cost per week?
$84 per week is not enough to dissuade a person from an addictive habit, so we go higher. How much for a month? $336, still not enough. Year? $4368 is enough to make most people change a habit, but this can be scaled up to a ten yearly level, so $43, 680, which is enough for almost anyone.
As I said in my previous post my issue is not quitting. I have quit almost everything I need to quit. I need to start new things. This means I need to change the way I use this system. I have to think about quitting inactivity.
Here's hoping.
C++ tutorial 1 - Hello World
Hey guys,
This is a standard Hello World program, purely meant to show how to layout your program. If you are interested in more I will put up more tutorials in C++ and also do some PHP, MySQL and JavaScript. Not to mention HTML and CSS.
This tutorial assumes that you have Code::Blocks already installed and working. To test this you can copy and paste the code at the bottom, rather than type it out manually. If you do not yet have Code::Blocks I will be covering the setup in a couple of new tutorials soon.
//Include the in/out stream library
//this line makes the program see calls such as 'cin' and 'cout' as references from the std library
//start the main function of the program
//use the standard output function for C to print "Hello World!" and end the line
//Return a normal termination signal to the system
Without comments
This is a standard Hello World program, purely meant to show how to layout your program. If you are interested in more I will put up more tutorials in C++ and also do some PHP, MySQL and JavaScript. Not to mention HTML and CSS.
This tutorial assumes that you have Code::Blocks already installed and working. To test this you can copy and paste the code at the bottom, rather than type it out manually. If you do not yet have Code::Blocks I will be covering the setup in a couple of new tutorials soon.
#include <iostream>using namespace std;int main() { cout << "Hello world!" << endl; return 0;}Without comments
#include <iostream>
using namespace std;
int main() {
cout << "Hello world!" << endl;
return 0;
}Quitting
How many times have people told you that quitting smoking is one of the most difficult things to experience? When do you hear people saying 'quitting smoking was easy'?
I've quit. I quit almost 4 years ago now, and something which people are always amazed by is that i quit cold turkey, no patches or cutting down, just bam, quit! My partner tried to quit at the same time, unsuccessfully. I have seen many people try to quit and not so many succeed. Why?
I did not find quitting all that difficult. I have a much worse problem now. I can quit anything, but starting something... that is a bit more difficult.
My next few articles will focus on starting things, with me trying each of the different techniques. There are many things which may help and I intend to find out which ones actually work.
Comments?
I've quit. I quit almost 4 years ago now, and something which people are always amazed by is that i quit cold turkey, no patches or cutting down, just bam, quit! My partner tried to quit at the same time, unsuccessfully. I have seen many people try to quit and not so many succeed. Why?
I did not find quitting all that difficult. I have a much worse problem now. I can quit anything, but starting something... that is a bit more difficult.
My next few articles will focus on starting things, with me trying each of the different techniques. There are many things which may help and I intend to find out which ones actually work.
Comments?
Subscribe to:
Comments (Atom)