Noob to Hacker

A narrated quest - From ignorance to bliss

Recent Posts

  • All Moves for Each Pokemon Type (Fire, Water…) in Pokemon Go

    All Moves for Each Pokemon Type (Fire, Water…) in Pokemon Go

  • The best Pokemon Go tips and advice

    The best Pokemon Go tips and advice

  • Complete List of Moves and Attacks for Each Pokemon in Pokemon Go

    Complete List of Moves and Attacks for Each Pokemon in Pokemon Go

Day 4 – Basics of programming with C

March 5, 2016 by Noobtohacker

I learned some more things about C:

  1. To print text to screen we need a function that does this. The function comes packaged with C in a library called the “Standard Input/Output library”.  (stdio.h)
  2. The way you include a file with C is by writing: #include<myfile.h>
  3. Some programming languages require you to create a function to write a program. The function that does this on C is the function “main”.
  4. In C you call a function by putting the function name along with any arguments within parenthesis. At the end you put a semi-colon.
  5. The function to print something on C is printf(“Hello”);
  6. On C u need to specify when to return back control to operating system when the program finishes. To do this you use “return” . For example return 0;

e.g example_function (“Text to print”);

The syntax for main is:

int main (void) { … code goes here … }

  • So it seems the “int” states the kind of output that is going to be produced. In this case an integer. When writing a function we need to state the kind of output we can expect from the function.
  • Lastly, “main” means that we are not passing any variable to the function.

 

Filed Under: Learning Computer Science

Day 4 – Handling errors in your code with Python with TRY/Except

March 5, 2016 by Noobtohacker

Day 4 – Handling errors in your code with Python with TRY/Except

As I mentioned on my first post, before starting this blog I did take CS 101 Intro to Computing Science at Udacity (Although I have forgotten 99% of it), which was pretty much my first ever encounter with code. The exercises and class used python as a language to learn, and so of course Python will be the language I will be focusing on more at the beginning and will try to become good at it.

Today for a complete random reason I decided to look into some simple code and saw that TRY and EXCEPT was being used. So I watched some videos about it on youtube like the ones below, and it all became clear:

  • Python Basics: Try and Except
  • Python Tutorial: Using Try/Except Blocks for Error Handling
  • Python 3 Programming Tutorial – Try and Except error Handling
  • Let’s Learn Python – Basics #5 of 8 – Exception Handling

TIP: Whenever you don’t know something, try to find at least 3/4 different videos explaining the same thing. You will learn different things and approaches from each video.

So. what is the role of Try/Except?

Well, programs sometimes crash. Python is a program that will not “compile” before running, which means that it will run even if there is a bug. At the same time, whenever it reaches a bug, then it will stop, and it will show you an Error and some information so that you know where things went wrong.

Now, what if we don’t want the program to stop if there is an error, and instead we want the program to do more things whenever there is an error, even continuing with the next lined? That is exactly the purpose of Exception Handling, which is done through TRY and Except.

Try and Except allows you to tell the computer what to do, whenever there is an error, or even more specifically, what to do if ever there is a specific kind of error. I imagine that other programming languages will also have similar commands to do same thing.

Now, in terms of what to use, the recommended option is to use except Exception as e: and then print (e) as the image on the header. This will basically catch any kind of error in the code analyzed and will display the error message in a nice way so that you can act on it.

Final conclusions

  • It is used in parts of the code that are more prone to error
  • It is used to avoid the program to stop if there is indeed an error
  • It is used to tell the program what to do whenever an error happens

Things not yet fully understood

Whenever an error is found, then the EXCEPT part of the try/except clause is called and runs. However, if there was still more code inside that try/error block, after the first error happened, that code will not be read and you will then lose info on that section.

How do you then make sure that this doesn’t become a problem? Is there any way to tell the computer that after an error is found, then it should keep going from the next line after the line in which it found the error, so that further stuff can also be found?

Best.

 

 

Filed Under: Learning Computer Science

Day 3 – A break – Learning about SEO

March 4, 2016 by Noobtohacker

Today instead of keeping it up with the programming videos I have decided to instead learn a bit about “Google Search Console” through this kind of video.

I build a little blog like this one talking about a different topic about a year ago. In the blog I give some information and I also sell a little guide-book that I made. I have never cared about SEO and in the last year it had 12.000 page views. I want to learn a bit about SEO and use that page as an experiment to see if there is any way I can improve the traffic etc.

Basically I learned to day that there is a tool that Google Provides called “Google Search Console”. This tool is used precisely to check if you have any errors in your page that is annoying google’s crawler, or that is making your site less attractive for the crawler. You can also check all the words that are being searched that make your website appear on google, and in which position you appear for each keyword!

I won’t go into depth here but basically it seems helpful to search and add to your content some terms that are triggering your site to appear on the results. I changed one or two terms and will check after sometime if it made any difference.

 

Filed Under: Learning Computer Science

Day 2 – Instruction Pointer

March 3, 2016 by Noobtohacker

Again reached home at midnight after another 15 day hour workday. Really tired but looking forward for the weekend to dedicate some hours to speed things up!

Still managed to pull through and learn some little new things:

  • “At any point in a program, the instruction pointer contains the address in memory of the next instruction to execute”
    • From wiki: “In most processors, the PC is incremented after fetching an instruction, and holds the memory address of (“points to”) the next instruction that would be executed. (In a processor where the incrementation precedes the fetch, the PC points to the current instruction being executed.)”
  • Instruction pointer could actually jump from a list to another , in essence “You can create as many programs as you want, each program starting at its own unique address in memory”. These smaller programs are called “function”.
  • Every programing language gives you a way to give plain English names to functions (Also called routines, methods).
    • This is not hard to understand. There can be for instance a function: addition (x,y) = x + y. Then you can say for example “addition(2,3)” and the output will be 5.
  • Every program will be useless if it didn’t have a way to display something to the screen. There is always a function that is some sort of ability to print text to the screen.
  • Extra info you give to a function is called a “parameter” or an “argument”. In the function before, the parameters are x and y.
  • After a function is done it returns to the line of code after the line where it was called. However it can also return extra information like for instance information with regards if whatever it is that is meant to do worked or not etc.
  • A “return value” is information that is returned from a function back to the program that called it, and you can use that information after that.
  • Some programing languages require you to create a function for your main program. Your program is actually a function in iself! 🙂

Today a bit more theoric concepts. At least those concepts I understand! Too tired to do more really. More this weekend.

Filed Under: Learning Computer Science

Day 1 – CPU, and how a computer (and a program) in its core works

March 2, 2016 by Noobtohacker

Day 1 – CPU, and how a computer (and a program) in its core works

Today was a very long day and I didn’t have time to study, still managed to pull through and learned some interesting things.

  1. Programs are also “data” stored on RAM addresses like anything else. They are a series of instructions, numbers, addresses… RAM btw, is just a series of slots where 1 and 0 are stored :), and a link to the CPU.
  2. Now there is a game happening between CPU and RAM, and info is exchanged constantly between these twp. CPU accesses RAM constantly and executes intructions etc.
  3. Inside the CPU itslef, the game happens between the Control Unit and the ALU.
  4. The CPU at the end of the day are wires carrying info, on/off, high/low voltage, which represent the 0’s and 1’s.
  5. There is always one wire that turns on and off at a given rate, the clock, and how many times per second this happens (HZ) is basically what we hear of 2Ghz processor… this means the clock switches on and off 2 Billion times per second! That is one of the things that allows so many computations to happen so quickly.
  6. How does a CPU work? Well, it seems pretty damn hard to fully understand, but this video is really awesome in breaking it down. Although I don’t fully get it (Will re-watch another day again slowly), at the end of the day there seems to be a game between the Control Unit and the ALU, helped by “flags” (don’t understand yet) and “registers” basically a component used to “store” a value for some time. These are like a little RAM inside the CPU itslef.
  7. In terms of possible CPU instructions in RAM, there seem to be different depend on CPU. But in the video it explains the following: LOAD (Fetches value from RAM), ADD (Adds two values together), STORE (Saves result in RAM), COMPARE (Compares 2 numbers together to see which one is larger, or if they are the same), JUMPIF (If certain condition is met, go fetch a specific variable from an out of order RAM address), JUMP (Jumps without condition), OUT (Output data to external device like a monitor), or IN (Fetches data from external device like keyboard).

As a pending task I need to re-watch the video again and try my best to fully understand the example little program it puts. I feel it is super important to understand this well to get the essence of every computation later on.

I need to also clarify what is the essential differences between the ALU and the Control Unit.

If ever want to go deep into this they reccomend a book in the video “But How do It Know“? I might read it in the future, or might not. Not sure.

 

Filed Under: Learning Computer Science

  • « Previous Page
  • 1
  • …
  • 6
  • 7
  • 8
  • 9
  • Next Page »