by Jonny | Mar 14, 2013 | Updates
I’m currently working/studying exercise 17 from Learn Python the Hard Way. In this exercise I learned two new things, and those two reasons are why I created this new category which will cater for my programming experiences, as opposed to me creating hundreds of pages and having my navigation bar up-top filled with drop down menus on the “code” navigation link.
As for my programming abilities so far, I’ve been typing out every single piece of code in this eBook by hand (As requested by the author) with no copy and pasting whatsoever! I’m quite proud of that actually.
Anyways, in the exercise it states that I need to condense the following code:
from sys import argv
from os.path import exists
script, from_file, to_file = argv
print "Copying from %s to %s" % (from_file, to_file)
# we could do these two on one line too, how?
in_file = open(from_file)
indata = in_file.read()
print "The input file is %d bytes long" % len(indata)
print "Does the output file exist? %r" % exists(to_file)
print "Ready, hit RETURN to continue, CTRL-C to abort."
raw_input()
out_file = open(to_file, 'w')
out_file.write(indata)
print "Alright, all done."
out_file.close()
To this:
from sys import argv; from os.path import exists; script, from_file, to_file = argv; print "Copying from %s to %s" % (from_file, to_file); in_file = open(from_file).read(); print "The input file is %d bytes long" % len(in_file); print "Does the output file exist? %r" % exists(to_file); print "Ready, hit RETURN to continue, CTRL-C to abort."; raw_input(); out_file = open(to_file, 'w').write(in_file); print "Alright, all done."
# we could do these two on one line too, how?
# indata = in_file.read()
# out_file.write(in_file)
# out_file.close()
# in_file.close()
As you can see I condensed the code to just one line with semi-colons, and I hashed out the code that wasn’t needed for the operation that the code is to do. It still works and copies from one file to the other.
I got rid of close() as I’m still not sure yet what purpose that serves in relation to this, though I’m assuming I can just add this to the end; though it’s throwing up errors. I’m just looking to progress onward and if I run into an issue like that I’ll have a sit down and think about solving it or asking on websites designed for these types of issues.
I also combined from the original code in line 18 and 19 to this:
out_file = open(to_file, ‘w’).write(in_file)
Not sure if that is correct; however, the script is still functioning and does its’ job.
I’m sure if an expert Python programmer came and saw this they would faint, but I’m still trying to learn and I know I have a long road ahead of me.
New Parameters & Formatters
import exists – This will confirm whether a file exists or not. If a file exists it will report back with True, if the file doesn’t exist it will report back with False. In Windows Powershell, it outputs the following:
Does the out-put file exist? True
len() – (length) This will measure the length of a file. In the above example the output in Windows Powershell is:
The input file is 686 bytes long
by Jonny | Feb 26, 2013 | Updates
I just came across this brilliant video about getting people to learn how to code. It’s amazing. It features a handful of creators in the past century who have created something with code and who have become successful.
The Code.org website is about teaching people to program and to encourage those who may have had a slight interest to have an even bigger interest. It has certainly got me excited. Perhaps, I won’t have to go to university after-all, and I can learn how to program completely free – this I think is the premise behind Code.org.
by Jonny | Aug 24, 2012 | Updates
Recently, my 500GB hard drive failed on me and I looked on the internet for anything that could recover my files from the hard drive, which admittedly, I should have backed-up.

F:\ is not accessible. Data error (cyclic redundancy check).
Cyclic Redundancy Check Error & what I did.
I searched on the internet for a solution and found out what the error message means. CRC (Cyclic Redundancy Check), I looked at a few solutions however none of them worked for me. So, I thought instead of trying to get my hard drive accessible again, I thought I’d just get the data off first that I needed. (The data I should have backed up)

Recovering files on a failed hard drive
Recovery
So, I found this as a solution. I’ve managed to already get access to around 1,000+ files (Though they aren’t the files I need, so I’m continuing the scan), however there is a data-limit on the program, since I’m using the trial version. (The program, bought, costs around $59.) The paid version allows you to download as much information from the defective hard drive, while the trial allows you to only take off around 1GB of data.
That’s all I need as I’m purely trying to recover a web design which I originally bought and I want to place it for free on my website over at SimpleTemplates.org. It’s only a small file.
How long?
However, according to the program to scan the entirety of the 500GB hard drive, I need to wait 255 hours, which is around 2 weeks of concurrent scanning. I can do this, but eventually or before all that, it will find this web design, so I no longer need to continue any more scans.
So, what program are you using to do this?
The program I’m using was created by Power Data Recovery. (Google search; not direct link to their site) – They make other premium programs for hard drive failures which includes automatic back-ups and the like.
Also for future reference, I have also done some research into other programs that have been recommended in the blogosphere:
- PC Inspector File Recovery
- NTFS Reader
- Restoration
- Undelete Now!
Hopefully, someone will have found this useful. Hardware failures, especially hard drive failures are not fun at-all.
by Jonny | Aug 20, 2012 | Updates

In the middle of a Udacity.com lesson! 🙂
Recently, I found this great website where you can learn how to program.
I thought I’d give my experience and thoughts on how things are going and what Udacity provide and who they are.
So what is Udacity.com?
The site essentially offers free courses where you can learn programming. Right now, I’m studying the first unit of programming (CS101) and I’m in the process of learning Python. I’ve installed the Python interpreter and Java as well, for that matter. (Though, I’ll be learning Java later on, once I get the gist of Python)
CS101?
CS101 is a course on the Udacity website and essentially it tells you the basics of programming and it is a step-by-step guide into programming with Python. At the end of CS101, I should have completed programming my own search engine equipped with a cool little robot website indexer.
Links:
http://www.udacity.com/
http://www.codecademy.com
Review of UNIT-1
I’ve gone through UNIT 1 and I feel I have more of an understanding with Python, although I’m still confused in some areas. – This may mean I have to go back through the entire UNIT again, so as to ensure I haven’t missed anything. I’ve written only 2-pages and should have probably noted down a lot more. I’m actually quite excited in learning Python as this type of interactive learning is quite fun and not too confusing. Although on some occasions it has been a little confusing for me.
I hope to make it through this course alive and well, with hopefully a new understanding of programming. – I’ve also found another website which has also been helpful called “Codecademy.com”, that is equally as good although there aren’t any university professors explaining things, you have a highly interactive interface helping you along the way.
I just hope I can focus on this one thing and not get too distracted. I think this is a great opportunity and I hope I can get something out of this. I have to give thanks to whoever set this up and especially to the professors who assembled all of this. Now I have homework to do! 🙂
Update
I’ve decided to take a different direction. I feel that for me the Udacity.com course was a little confusing. I feel as if I couldn’t understand a lot of the questions as the course furthered on. I feel this is due to a lack of practice. While I did repeat UNIT 1 again, I still had the same issues. In the mean time, I’ve been using Codecademy.com. – I feel that the examples and the longer explanations there are more understandable for me. Once I complete the Codecademy course I feel I’ll have a better understanding of the Udacity course and of the requirements in order to create the search engine.
So what’s the major difference?
Udacity explains and teaches too much of the theory, while Codecademy explains and teaches a lot of hands-on approaches. I’m not saying that is all of what Udacity does, but Codeacademy is specifically telling you how to do things with better examples. (I feel that this is a little easier for people who are just starting out learning Python) It does indeed (Codecademy) hold your hand along the way, but if you are just starting out, how else are you going to learn? If it doesn’t hold your hand and you get confused then it can totally put you off of programming. At least with this approach you can learn the right way to do things then apply it in other scenarios.
So, perhaps you have had the same issues as me and the Udacity course is a little confusing, well, I feel that the Codecademy course will ease you in with better explanations and examples.
Step 1:
Codecademy.com (Python)
Step 2:
Udacity.com (CS101)
Why do Codecademy first then Udacity?
As said previously: I feel this way, you can can have a better understanding of Python before heading onto the Udacity course. While I like Udacity.com, I feel, perhaps, that a lot of explanations are quite difficult to grasp. Which is why I think Codecademy is a little better at the explanations. I almost feel that once you complete the Codecademy courses you can take that information you have learned and use it on Udacity.com.
I’m trying really hard to get this and I know it will take time, as my mathematical abilities suck, but we’ll see where this gets me. I have been writing down lots of notes so hopefully when I go out and I can just pull them out to remind myself what I’ve learned. I’m also trying to remember how to code and what the layout should be. I’m thinking of buying a book on Python just so I can read it when I’m out. I think I need to make this like an idol-worship thing and become fanatic about learning the language, in order to improve.
Life is tough shit, here in the real world. Being lazy, doing nothing is nice and relaxing, but that won’t get me a good paying job in the future. Plus, if I can learn a programming language, then if at any point I go to university, it won’t be so difficult on me. (i.e. It’s like preparing for university) — I’ll probably have quite the advantage in comparison to not having much knowledge on programming itself.
by Jonny | Nov 7, 2011 | Updates
Although I really want to learn Mandarin I'm finding great difficulties in grasping the language. Or I find great difficulties in understanding in what is being taught by my teacher. I try to translate what she is saying into English but always seem to fail. There are many differences when it comes to translating and those differences can impact an entire sentences' wording or understanding. – It is also time consuming. I need to get out of the mode of translating and I need to start thinking about what characters when combined together mean. Otherwise I'll be in a whole lot of trouble when it comes to next semester. Although I will be re-taking the same level.
I'm just dissapointed with myself. I used to be the highest in my college class for computer programming. As for Mandarin-Chinese, I'm the lowest and it feels like shit to be honest. I talked to my friend who also suffers from anxiety and Adult-attenton Deficit Disorder and he said you have to take it at your own pace. While I stopped taking Ritalin I feel I have slipped back into my unfocused mode. I really can't focus on the language anymore. I need those tablets in order to be able to study. Otherwise I find myself drifting elsewhere after 5 minutes of trying to write down the characters and remember them.
Tomorrow I shall be recieving that medicine, but not before I go to class which starts in the morning. So I will struggle. However that goes to say I probably or likely will still struggle when on the medicine, although it will help me progress and be more upfront. *sigh*