Tuesday, December 31, 2013

Git resources


Wednesday, December 04, 2013

PHP and Class Variables

Pass a variable into a class through the __construct($variable) function


Variables set in the __Construct can be referenced throughout the class as $this->variable

Can be referenced outside the class as
$Class->variable

Variable Can be passed into a class function like Class::function(variable);

Thursday, November 21, 2013

Thursday, November 14, 2013

C++ understanding fstream

My brain choked the other day when dealing with the ifstream method inside of the the fstream directive.  I just couldn't wrap my brain around how the ifstream associates variable values.  My friend told me that I was an idiot.  He explained that ifstream works the same way that cin works.

basically
lets say you have a text file that is called names.txt and the file looks like this
Johnny Bobby Dave Suzy
Now you want to assign those values to variables using ifstream

Using 4 variables (name1, name2, name3, name4)  you'd just say
ifstream inputFile;
inputFile >> name1 >> name2 >> name3 >> name4;
Just like it would look with cin
cin >> name1 >> name2 >> name3 >> name4;
 C++ doesn't care if the input is coming from a text file or a keyboard.  Duh.

C++ assigning values to arrays

If you need to assign values to a two dimensional array use a nested "for" loop

ex:
const int ROW = 3;
const int COLS = 2;
int arrayN[ROW][COLS];
int counter1, counter2;

for(counter1 = 0; counter1 < ROW; counter1++)
 { for(counter2 = 0; counter2 < COLS; counter2++)
   {
    cin >> arrayN[counter1][counter2];
   }




When spitting an array out

for(counter1 = 0; counter1< COLS; counter1++)
 { for(counter2 = 0; counter2 < ROW; counter2++)
   {
    cout << arrayN[counter1][counter2];
   }
}

PHP Resources

Everyone could use a new trick or for their PHP bag. Here are some great resources that might just do the trick.

Village Host Pizza Lexington KY

I had the pleasure of eating at Village Host Pizza in downtown Lexington this weekend. I had the cheeseburger pizza. It was pretty good, however the thing to get at this restaurant is the salad bar. It might just have the best salad bar in Lexington .

Christmas Chimes

I wish this was better. It is a little slow. The bells aren't on pitch. It is just not as great as I would like.

Christmas favorites

Fantastic compilation of singers who where hot back in the day. Any Williams, Robert Goulet, Barbara Streisand - you name it. Great record

Christmas Strings

Fantastic record by the Herald Singing Strings playing some classic instrumentals of Christmas favorites. Great great great. The record was totally worn down.

Merry Christmas from Lawrence Welk and His Champagne Music

I absolutely love the happy sounding Lawrence Welk orchestra. These Christmas classics have the added flavor that Welks arrangements have. Some how he manages to make happy Christmas songs even happier!. Great.

Curl

  • curl XML on stack
  • HTTP Authentication with CURL
  • Command Line Curl
  • Instagram oauth with Curl
  • The best no nonesense curl resource on Codular
  • Monday, November 11, 2013

    Asp.net Resources

    I never thought in a million years that I would be learning how to develop on Microsoft platforms. I'm not exactly an enthusiast at this point, but I'm having to learn C# and ASP.net after the main developer at work left. Below is a series of resources that I've found helpful thus far.

    Wednesday, November 06, 2013

    Resources for Putting a SSD in an old Mac Book Pro

    I've wanted to upgrade my Mac Book Pro hard drive for some time now and I'm considering a SSD. Here is an article on doing just that. Installing a SSD in Mac Book Pro
    Corsair 360 GB SSD

    Monday, September 23, 2013

    Returning Multiple Values with a Function in PHP

    As I'm coding I try to package my code in useful pieces that make it easy to understand what is going on in my programs. What that means in practice is using functions to do the packaging. Functions are just actions that can include multiple statements and do multiple things. If variables are the nouns of your program then a function is the verb. Functions are sometimes also referred to as methods.

    Anyways, one action you might want a function to do is return a value. To do this you may have a function fetch results from a database or perform some equation base on a value being passed to the function. For example I could make a function that adds 10 to a value.
    function addTen($number) {
    $sum = $number + 10;
    return $sum;
    }
    echo addTen(5);
    In the above example I have a function called addTen that is passed a number and returns that number with 10 added to it. In order to have the code spit out the value you just echo out the function. Pretty simple

    Returning Multiple Values

    A function returning one variable is easy. Functions are meant to return a variable. Having a function return multiple variables is a little more complicated. The way it is achieved is with an array.

    Arrays are variables with multiple values. An example of an array might be a variable called $color. There are many colors, so it would make sense to create our variable $color using an array. To make an array you declare the variable and specify the values like so: $color = array(red,blue,green,black); You access the values by specifying the key (Pointing at which value you want). To access red you would: echo $color[0]; Arrays start with 0 as the first value. Another type of array are associative arrays. These types of arrays have user defined keys instead of the default numbered keys. For example I could have and array of the traits of a person: $person = array( 'name' => 'Jason', 'address' => '123 Main St.', 'age' => '25'); To access Jason's address you would echo $person['address'];

    So that brings us to the main objective here: Creating a function that returns multiple values.
    // This is handy if you had a function that could do a database call and return a bunch of values. You could then access those values as an array

    function animals() {
    $dog = "odie";
    $cat = "garfield";
    $rabbit = "bugs";
    $donkey = "eeyore";

    $animals = array (
    dog => $dog,
    cat => $cat,
    rabbit => $rabbit,
    donkey => $donkey
    );

    return $animals;
    }
    // set variable equal to the function returning the array

    $animals = animals();

    //access the values through the keys of the array

    echo $animals['dog'];
    echo "
    ";
    echo $animals['cat'];
    echo "
    ";
    This method has all sorts of uses. This is extremely useful when dealing with a database and you want to consolidate your fetch operations in a function but want to separate your styling code from the function.

    Hope you find this useful!