DBC Blog

A Look At Some of The Things I Learned During Phase 0.

Asking the Right Questions

| Comments

Week Nine Cultural Blog post

How not to Ask

A few months ago I was playing around with Kali Linux using a virtual machine in windows. I was having a problem switching to the Superuser using the su command.

Below is my question the way I originally posted it.

su cannot execute bin/bash/****

Hi I installed kali Linux on a vm machine and I cannot change my user to root from the terminal using su. sudo works fine but whe I try su it says cannot execute bin/bash/****(my user name) not a directory.

Thank you,

And this is what a helpful user turned it into.

su cannot execute bin/bash/****

I installed Kali Linux on a VM machine and I cannot change my user to root from the terminal using su. The command sudo works fine but when I try to su, it says “cannot execute bin/bash/****(my user name) not a directory”.

Looking at the differences he did not change much if at all in terms of technical info. Where he did shine though is making my question readable. The question I submitted looked like a tweenager text. Looking back now I do not know if I would have answered it myself, seeing as the poster (me) did not really have any attention to detail.

And yes my question was answered and it resolved my issue.

Rebuilding My Blog

| Comments

Week Nine Technical Blog post


This week one of the challenges were to redo our blog. I decided to use a framework to help accomplish that.

The framework the I chose is called Octopress. I am using it now to generate this blog post. Getting it set up took a lot longer than I initially assumed it would take. Downloading and setting it up was pretty straight forward, the part that gave me the most trouble was how to integrate it with my existing blog that was being hosted by github pages.

To get it to work I had to delete my current repo that contained all of my current data. First I converted all of my previous posts to markdown. I used an online conversion tool and was left with a little bit of formatting to do manually. I then created a new post for each of the older posts. (This is why all of my post written before April have the same date.) The next step was to create a new blank repo on github that pointed to my github page. Then I had to deploy and push my new blog.

After working through many issues I managed to get it live. This is why this blog has a “new and improved” look.

SQL Injection

| Comments

Week Eight Technical Blog Post

March 28, 2015

Little Bobby Tables

Today I will be writing about SQL Injection. SQL Injection is a way to insert code maliciously into an entry field in an application. This attack can be used against any database but is usually used against websites.

There are a few different methods that are used to maliciously send commands to the server. Today I will be writing about one of them.

Incorrectly filtered escape characters.

This type of SQL Injection occurs when input from user entry fields are not filtered for escape characters. Escape characters are special characters used in programming that tell the program, that the character after them is not to be read the usual way rather as a different character. A common example is the “ \”.

For example, an name entry field in a website. The website takes the input from the field and turns it into a select statement.

SELECT * from USERS WHERE name = (entry field);

This code looks for the specified user name and returns it from the database.

However this user name can be set to whatever the person on the other side of the field wants.

For example if '' or '1'='1' is entered it turns into the following SQL statement SELECT * FROM users WHERE name = '' OR '1'='1';

This statement would return all the names in the database because 1 = 1 is always true.

This vulnerability can also be exploited to delete or modify data in the database. See the story of Little Bobby Tables.

Ruby vs JavaScript

| Comments

Week Seven Technical Blog Post

March 22, 2015

Looping Through Arrays

Today I tried a something different and made a vlog to explain the some of the differences between Ruby and Javascript.

Hope you enjoy!

When to Use What

| Comments

Week Six Technical Blog Post

March 15, 2015

Variable Scope

Today I will be writing about variable scope. Scope defines where in a program a given variable is accessible. Ruby has four types of variables each can be accessed by different parts of a program hence “scope”. The four types are: local, instance, class and global.

The first type, Local Variables are local to the method or code they are declared in. Naming convention also states that they start either with an underscore _ or a lower case letter. If you try to use a local variable in a method that it was not declared in it will give you an error: "NameError: undefined local variable or method ``x' for main:Object" This is because outside of the local method in which the variable was declared it does not exist.

The next type is the Instance Variable. This variable is available to any instance of a class. If I have a class Bike with an instance variable @gears and I instantiate a new instance of Bike, let’s call it mountain_bike, @gears -the one that belongs to mountain_bike will only be accessible to mountain_bike not to any other instance of the class Bike. Instance Variables start with an @.

Class variables are similar to instance variables but it is shared across all instances of the class. Going on the earlier example @@gear will now be accessible not just to mountain_bike but to any instance of Bike. Class variables start with @@.

Global variables start with an $ and are discouraged from use. This is because they can be read and changed from anywhere in the code and this makes it very hard to track down bugs. They are accessible to any and every bit of code.

Chutes and Ladders or D&D?

| Comments

Week Five Technical Blog Post

March 8, 2015

Classes and How To Use Them.

This is an example of a class.

This class creates a die that can be used to play various games. Let us break up the code step by step.

The first step is to call the “Class” method, we do that by writing “class” and then the name we want to give it.(In this case Die. (Classes start with capital letters.)) Now it is time to call the attributes. An “attribute” is a method built in to the class “class”, in this case “reader” lets us read the amount of side the die has after we create it. Here we get to the methods the live in the Die class. The method “initialize” is used when creating most classes and it is what we use to set the amount of sides and what we want written on them. The next bit of code makes sure that we create a die with a minimum of one side.

Now comes the fun part do you see “@label” and “@sides”? They are what is called an instance variable, this means they can be used by any method that is contained in the class. All instance variables start with an “@” and they follow the same naming conventions that normal variables have.

After this we have a new method, a method that is contained in a class is called a instance method. This means it can only be called on an object of of the Die class. In our method “roll” we roll the die and it gives us one of the sides that we initialized the die with.

This class is very useful it can be used for a simple game of Chutes and Ladders or a complicated many sided die used in D&D. Because we have created this class we can do whatever we want with it. We can give it as many sides as we want, we can put what ever we want on them. With a little tinkering we can even make it return more than one side every time we call “roll” on the die.

So what are you waiting for go and have fun!

Enumerable Methods

| Comments

Week Four Technical Blog Post

February 28, 2015

Let’s Get Profiling

In Ruby there are many ways of getting the same things done. In one example you can write extremely lengthy code or you can use an Enumerator. An Enumerator is a method that takes a block of code and runs a collection of data on piece at a time through it. Today I will be writing about the Enumeratorgroup_by.

group_by is used to break a collection into “groups” based on the criteria that you give it. When it is called on a collection of data, it can be a hash or an array (of strings or integers), it runs on each piece and groups them by some criteria that I give it. Then it returns a hash with the key representing the group and the value an array of the “members” of that group.

Here is some code that will show you how it works.

In this example x was set to an array holding some strings, group_by was called to separate the strings by their length. The output was a hash5 =>["hello"] 3=>["how", "are", "you"] it grouped the strings the word “hello” has five letters as the key shows us, and the others all had three letters and are grouped together under the “3” key.

Another code example.

In this code snippet we ran the range 1 through 20 (that’s what (1..20) means) and separated them by the remainders of four. They are grouped by what the remainder would be if the number was divided by four.

This is a very useful tool to have when you are trying to separate items.

Arrays vs. Hashes

| Comments

Week Three Technical Blog Post

February 22, 2015

Showdown: Arrays vs. Hashes

This week we have started learning Ruby. Ruby is a high level object-oriented language. There is much to explore in Ruby and I have going at it all week, but in this blog post I want to talk about two objects in Ruby that have helped enormously in completing my exercises for the week.

Arrays and Hashes. Arrays and Hashes are both ways of storing information that is assigned a label in Ruby. However they are not the same and each have their own uses.

Array: An array is list of information that is tied to its order in numbers. This list can be made up of “strings”(regular text), integers, floats(numbers with decimal points) and even other arrays. The way to initialize an array is to put a set of elments between square brackets like this:

a = [ 1, 'cat', 3.14 ] An array with three elements

Each element in the array is set to a specific number. 1 is set to 0 (arrays always start from zero) “cat” is 1 etc.

Now that they are set in the array they can be called and have methods work on them.

Hashes: Hashes are similar to arrays but you need to supply both the key and the value. For example if you want 1 to equal “cat” you would have to set it. Hashes are initialized with squiggly brackets like this:

my_hash = {
  1 => 'cat'

if I would want to call cat I would have to write 1. But with a hash I can set it to be anything I want.
my_hash = { 'kitten' => 'cat' }

Now I have to call ‘kitten’ to get back cat.

Fat Stacks

| Comments

Week Two Technical Blog Post

February 15, 2015

Pad My Margins

The first time you try to learn CSS (CSS stands for Cascading Style Sheets), you will hear about many different properties that can be used to change the underlying HTML. From the color of the font all the way to the spacing between lines. In this article I would like to talk about three things that determine the edges of the boxes we are using.

Margins: The term margin is relatively familiar to most people. We see them every day, in the books we read and the websites we visit. In CSS, margins give what we call “white space”; distance between the various elements on the page. This can make things easier to read and also change the way the entire web page is laid out. Margins can be specified for any of the four sides of the box. They are on the outside of the border.

Borders: Borders can be invisible or as wide as the page, they can also be anything in between. Borders encompass every element we have on the page. The border on some boxes my be set to zero pixels (a measurement of screen size) you may not see them but they are always there. Borders separate the edges of the boxes they contain. You can set a specific border to be blue or indigo dotted or dashed thick or thin. There is really no end to the combinations that can be made.

Padding: Padding is the lowest level of space between the contents of a box and it edges. Padding fits in between the border and the contents. Many times when a border has been set around a box filled with text, it is difficult to read as it butts up against the border. Padding gives the ability to create “white space” in between the text and the border.

There Is No Try Only Do

| Comments

Week One Technical Blog Post

February 5, 2015

Come and Git It

Version control, roll it around on your tongue one more time, version control. Sounds like some thing the Terminator would say. As a gamer save points are gold; every time one is reached “wheeeew safe”. A boss just crushed you? No problem save point! That, my friends is version control in a nut shell. Whenever a change occurs in the material being worked on, whether it’s code, spread sheets or the manuscript for the next best selling crime thriller, version control will log the change and allow you to roll back the change as if it never occurred. So how do you use version control you ask, well that’s what git is for.

Git, sounds like an insult from the old south doesn’t it? Slow down, the inventor is not American and cannot be blamed for how it may make you feel.(He actually stated that it is named after him; git being a British insult meaning “jerk”). His name is Linus Torvalds and is mostly famous for creating Linux an open source operating system (this is being written on a machine running Linux). So what does git actually do, you ask? Git is what you use to save your game as we alluded to earlier ,and recall (or revert) to that (or any other saved) point in time/development. Git also has tools to combine changes and has a detailed log of every edit. But what about multiple developers? If you are in Bora Bora and your partner is in Nome? No problem thats what GitHub is for.

GitHub is a website that is big into anime. Don’t believe me? Their logo is a cross between an octopus and a cat called Octocat. This Octocat passes git repositories between developers. Ha I know I’m pretty lame I can’t help it. To stick with gaming analogies GitHub is like playing on Steam. You download the game from Steam and play it on your computer but many stats are saved online. GitHub is similar in it that it allows people to upload projects online making it possible for anyone to download it to their own computer and make improvements. After working on their locally downloaded copy users are then able to “push” it back to GitHub, where it gets reviewed and if found to be useful, added and merged with the main repository. There are millions of public repos on GitHub currently, with more being added every day. So come on and join us its never too late.