This blog no longer exists.
You will be redirected to something cool.

Wednesday, August 31, 2011

Move Ahead in Perl or Try Something New?

I'm just about halfway done with my Perl course and it feels really good. I'm not sure if I'm going to go on to a more difficult Perl course or to go on to another language.

There two sides to this coin. If I go on to the cert for open source programming, this course is it for Perl. I would then move on to an intro course for Python, a course on the Unix file system (which would be fun), an intro course on PHP, and the finish off with a database programming course (which I think would be a blast.)

If I stay with Perl and move on to more advanced Perl-y things, I think I would learn more about computer science, in general, but it would be more focused on one particular language versus "Survey of Computer Science" so to speak.

Tonight's section was difficult for me, but I got everything down. My big problem was that, while my code worked, it was generating warnings.

My code was as follows:
if ($var eq undef)
{
  do a thing
}
else
{
  do something
}

To fix it, I did the following:
if ($var)
{
  do something
}
else
{
  do a thing
}

Chip learning some
Ruby with me
I don't think the solution I came up with was in the chapter I'd just read, but it was marked correct. I am trying to solve problems with the information they present versus going off on my own and using "outside" information to solve things.

It's been really hard because I've been wanting to write methods, loops, etc, pretty much since I started out in the course, but haven't gotten there yet. I'm trying to keep it relevant to exactly what is taught so I don't get ahead of myself and learn bad habits.

I am going to go hog wild on some Ruby stuff, though. I read a little more of Well-Grounded Rubyist, but had to stop as I wanted to try something out that I was learning... and I'm have a big problem getting Ruby installed. (I recently formatted.)

Tuesday, August 30, 2011

Perl index()

I was playing with index() in Perl today, which was a lot of fun. I started off with something similar to this code, which prints out the following:

Here is a list of my programming books
1 The Well-Grounded Rubyist
2 Pragmatic Thinking & Learning
3 Programming Ruby 1.9
4 Learning Perl

I learned how to use index() in the course I'm taking. In this example, I am using index() to print out ONLY Ruby books (and their ranking). I am aware that it's very redundant code (I'll change that later.)

Index() determines the position of a character in a string. If the string doesn't contain the character, index() will return -1.

Some interesting stuff I'm learning.

Beginning Programming: Why Learn Ruby

If you're new to programming, Ruby is a great programming language to start off with. The Ruby community has composed many guides, videos, blogs, books, etc in order to teach this programming language to those who are new to computer science. Most of these guides teach the fundamentals of computer science while showing how to program in Ruby. Another great reason to choose Ruby is because the language's syntax is much easier to read and understand than other programming languages.

Friday, August 26, 2011

Perl Heredoc & Conditionals

I just finished learning more about heredocs in Perl in my Perl programming course. After getting set up on Ubuntu, I decided to get comfortable programming in Linux again (it's a super pain in Windows.)

Here I am playing around with a few new concepts and some things (like variables/scalars) which I'm definitely comfortable and used to using. This tiny program I wrote is extremely redundant (I could write this thing to be teeny-tiny in Ruby, but I'm not at that point in Perl.) However, writing this helped me think in a more Perl-y way.

I'm using scalars, a heredoc, if statements/conditionals, and the split() function. I did this in order to write out a list of programming books in different languages and then retrieve the data with split() in order to list how many of each type of book I have. I then used an if statement to print out 'book' or 'books' based on the quantity. Quite redundant, but it works and I'll learn to make it smaller as I progress in the course.

Go ahead and check out my horrid, little program. (Yes, I know it needs a loop. I'll add it in a later update, in a later blog post :P)

Monday, August 22, 2011

Perl Heredoc

I'm learning about something called a heredoc in Perl. It's an interesting concept that I've not come across so far in Ruby (although a friend tells me that this does exist in Ruby.)

Essentially it's for multi-line strings -- and they make code a quad-billion times easier to read. Don't quote me on the quad-billion thing... I'm not sure how many ease-of-reading units there are in Perl code without a heredoc nor how many there are with a heredoc.

It'll take a bit to get used to using a heredoc, especially the empty line thing -- what's that about? Well, I'll learn it!

Tomorrow I'm going to finish the lesson on the here document thing and then read up on using a heredoc in Ruby because that will be interesting. I shall post what I find.

Sunday, August 21, 2011

Adding, Concatenation, Ruby, & Perl

I've noticed some similarities between Ruby and Perl, but have noticed some really strange differences. One of these is this:

0.1 + 0.1
0.1 + "0.1"
"0.1" + "0.1"

In Ruby, the answers would be as follows:
0.2
Error: String can't be coerced into Float (TypeError)

0.10.1

In Perl:
0.2
0.2
0.2

I'll have to do some digging to see why it happens like this in Perl, but it's really strange to me, perhaps because I learned it, well, the Ruby way.

Friday, August 19, 2011

Perl (Learning a New Language)

Welp, I'm taking a Perl course. So no Ruby for a while -- okay, so that's a lie. I <3 Ruby so I'll definitely be programming in it for fun. I'm learning a new language, I'll be strapped for time  to play around in Ruby, but I'll make it happen

I learned that Perl can be considered to be a procedural language, function, and object-oriented programming language. However, the class focuses on procedural programming with Perl. This will be a lot of fun! I'm definitely excited.

I've already written that basic "Hello World" program and have done a bit of coursework although I'm jumping ahead of myself since nothing will really start until next week. I also learned about pragmas which sent me on one of those Wikipedia black holes of information searchin'. I did enjoy reading about directives and their usages in various programming languages including Ada, Haskell, and C. Good times, good times.

Wish me the best of luck! Any cool programs that I write in Perl will definitely be posted here, so keep an eye out! 

Thursday, August 18, 2011

Word Length Checker

This tool checks for word length, but instead of pasting text into a box, it's more complicated than that. Here's the problem I was having and why I created this tool:

One of my niche sites has several hundred posts of varying length. Since Panda it hasn't been doing so well, and a huge part of this is the length of each post. The only posts that are doing well are the longer ones. So I wanted to find each of the offending "short" posts and expand on the topic of each. There are several hundred posts, so it's something that will take quite a bit of time doing manually, thus this tool was born.

While there is a better way to do this than by pulling the blog's RSS feed (the feed only hold x amount of information) I decided that this would be the quickest way to get the program up and running. The program is written in Ruby and uses nokogiri & open-uri so that it can retrieve and parse not only the feed, but each post on the feed. It then takes each post and counts up the words. The end result is a list of articles (and their content) which does not pass a minimum word length (which is essentially just a list of blog posts I need to lengthen.)

It's a work in progress, thus the gist over the formal repo, but head on over to the project to check it out!

Monday, August 15, 2011

Ruby SERP Checker Repo

Recently, Google made a large number of changes to their SERPs, so I have decided to abandon my SERP checker project (RankyPanky) that I was writing in Ruby. As Google has been rolling out update after update (We're on Panda 2.6 now, right?,) it's getting increasingly difficult to parse Google SERPs.

Constructocat by jsncostello
I removed the Repo from Github. However, if you want to see the code and fix it, mangle it, etc... you can! I left the code in a Gist for ya'. Head on over to the RankyPanky SERP checker Gist and have at it!

The code is half complete, and, I apologize, a mess. I was trying to implement a number of features shortly before I stopped writing. To make things simpler in creating a Gist, I removed the RSpec tests. If you need/want the spec, just send me a line and I'll hand it over.

While this project is at an end, I did make use of what I learned of nokogiri in my latest project, which I will share soon!

Wednesday, August 10, 2011

C Programming Exercises



This article has been moved.
You will be redirected shortly. Alternatively, you can access it directly by going to:
C Programming Exercises