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!

    Thursday, September 12, 2013

    Passing SESSION variables between Domain and Subdomain

    An issue I came across recently was that when I set a Session variable at the subdomain level of my site I couldn't access that session variable at the root level. In other words, when I set $_SESSION['name']= "John"; at http://john.harbison.com I couldn't access $_SESSION['name'] at www.harbison.com. That sucks! I did find the answer though thanks to Jeroen on Stack Overflow.

    The solution is to give your SESSION a Name! You need to name the session before you even start the session. So here is the code:
    $some_name = session_name("some_name");
    session_set_cookie_params(0, '/', '.some_domain.com');
    session_start();
    I love the internet!

    Monday, August 19, 2013

    Make Subdomain a Variable with PHP

    I wanted to create a dynamic page using a subdomain as a variable. What a user would do is put in a subdomain and it would pull up a page based off of that subdomain. For example: A user would type in http://car.file-drive.com and it would pull up a picture of a car. Of course car could be anything. It could be a list of names or anything at all. The way that it works is with a Wildcard subdomain. Here are the steps to do this.

    1. Setup Wildcard Subdomain at your domain Registrar

    You can skip this step if you host your dns record locally or with your hosting provider. I don't so I had to add the Wildcard record. My registrar is Godaddy so I just logged in, edited my DNS record and added a new CNAME record. I set the Host to * and it POINTS TO @

    2. Setup Wildcard Subdomain with Web Host

    My web host is Host Gator. I had to log in to the CPANEL and navigate to the subdomain settings. I added a new wildcard subdomain here for File-drive.com. So the settings again were * which is the character that means "any" just like a wild card in poker which can be any card. If this is an "add on" domain you'll need to point the subdomain to the proper root directory of your domain. File-drive is an add on so I had to point * to public_html/file-drive.com

    3. Use PHP to Pull out the Variable

    Now that the wildcard subdomain is set my domain can have any and as many subdomains as I want. What we have to do from this point is to break apart the url and get the variable from the subdomain. Will use
    <?php $subdomain = array_shift(explode(".",$_SERVER['HTTP_HOST'])); ?>
    to get the subdomain and set it to $subdomain.

    At this point you can do all sorts of things. You could echo or print out the subdomain. You could make a database call using the subdomain variable. You could do pretty much anything you want to.
    Enjoy!

    Tuesday, August 13, 2013

    Add A Google Map to Wordpress Contact Page

    This tutorial is assuming you know how to create a page or a post in Wordpress. Additionally this will provide info to add a map to any page, not just a contact page.

    Get your Map code

    1. Goto Google and Google the address you want to get your map for - click on the map picture that results. If that doesn't work goto https://maps.google.com/ and do your search.
    2. Once the result is displayed change your view to whatever you want to display on your page. You might change to a satellite view or a traffic. You may want to tweak other settings in this window. If it is displaying on this page then it will display on your page
    3. Click the Link Icon (photo below 1.)
    4. Click and copy the <iframe> code (Photo above 2.)
    5. Go to WordPress and click to edit the page/post you want to add your map to
    6. In your editor Click "Text" tab (Photo above 1.) If you have content on this page already you will need to place your cursor after/before the content you would like the map displayed
    7. Update or Save your page/post

    To Resize the Google Map

    If your map isn't the size you want you can edit the code that Google supplies and change the size.
    • In the code that you pasted above look for the Width and Height Parameters. It should look like: <iframe width="425" height="350" . . . . These parameters describe the size of the map that displays
    • To make the width larger type in a larger number. I changed mine from 425 to 800. This is in Pixel increments. This number should be less that 1028
    • To make the height of your map larger edit the height="350" value. Change the 350 to something larger. I used 700.
    • Once you've set the correct sizes click Update and save your post
    • Be sure to leave the "Quotation Marks" around the numerical value
    Good Luck!

    Add Photo to a Word Press Post or Page

    To add pictures to posts and pages go to the edit page of the post/page. Put your cursor in the text area where you want your picture. Above your text editor is a button that says “Add media” . Go through the dialogue that it prompts to either upload a new image or to choose one from the media gallery.

    Here is a video: http://www.youtube.com/watch?v=FxxFt3a0T5w

    Monday, August 12, 2013

    Customizr Slider: Create and edit new slider


    The customizr Theme for Wordpress features a very large slider on the home page that is somewhat difficult to edit. The theme has a demo slider installed with little to no direction on how to edit it. below are the steps necessary for creating and editing the slider.

    1. Create and image for the slider

    The dimensions the default slider is 1200 X 500

    2. Upload the image

    Click the "Add new" link under Media.
    Select your file and upload (you can upload more sliders if you want to at this time. Adding them to the slider is the same once the slider has been created)

    3. Click "Edit"

    Editing Media: In this window you can add captions, descriptions and add this media to your slider. We first need to create a new slider. Near the bottom of the page there will be a section called "Slider Options"
    1. By default this will be set to "No" - Change it to yes.
    2. The title - this will be the Main title of your slide
    3. Description - is the text below the title on the slide
    4. Link - You can choose the slide to link to a page of the site
    5. Choose a Slider - If this is your first time creating a slider you will have to make a slider to add your photo to. In the box type out the name of your slider and hit "Add a slider"
    Once you've completed your first media upload and created your new slider. you can just repeat the process on the rest of your slide items.

    4. Add a slide from Media Library

    Upload your new image and from the media library click "Edit". From the new window navigate to the slider options at the bottom. You can Add a title and description like described in number 3. above. This time though:

    1. Instead of creating a new slider, use the drop down to select the slider
    2. You can delete the entire slider from this screen
    3. To arrange the items in the slide, just drag and drop them into order
    Finally once you've finished editing the slider be sure to save that slide's information before navigating away. Click the "Update" button

    Set Your New Slider to the Home Page

    1. Click Appearance on the left Bar - then select Customiz'it.
    2. Next Click "Front Page" from the left Nav
    3. choose your new slider from the "SLIDER OPTIONS".
    4. Save and close
    For more information check out the links below.
    Message board on theme

    Thursday, August 08, 2013

    Ambrotype Repair: Part 4

    I've spent the majority of the time cloning healthy parts of the photo to cover damaged parts. My main photoshop tools are the spot heal and clone. I've also had to use the dodge tool to lighten shadows created by the glass cracks. This is gonna take some time!

    Overall now:

    Theseus ship and teleportation

    The act of teleportation is questionable. It might happen it may not. Some scientist believe it could take quadrillions of years to accurately beam a human being to another place in space (link). This problem alone makes the feat problematic since the universe isn't even a fraction of a quadrillion years old. Basically teleporting using current technology is like trying to download the entire Lost series over dial up internet
    The idea behind teleportation is interesting. The process is to take the atoms that make up a person, pull them apart separately, then put them together again in a completely new location. Seems straight forward, but that brings up the philosophical issue; is rebuilding a person atom by atom creating the same person or just creating a copy. Is that copy the same person.

    This problem first surfaced with philosopher Plutarch in a story called the ship of Theseus.
    The ship of Theseus, also known as Theseus's paradox, is a paradox that raises the question of whether an object which has had all its components replaced remains fundamentally the same object. The paradox is most notably recorded by Plutarch in Life of Theseus from the late 1st century. Plutarch asked whether a ship which was restored by replacing all and every of its wooden parts, remained the same ship. Wiki Page
    Just something to think about. Do you think a teleported person would be the same after transmission or would the current arrangement of atoms that make us up be lost in transmission?
    This was inspired by Reddit: What are the most mindblowing recent advancements most people still don't know about?

    Wednesday, August 07, 2013

    Deep Purple Song



    So interesting to see all the different renditions of this song. In one instant it is very jazzy, the next very pop, and lastly it is very embellished and almost a waltz.
    Deep Purple was written by Peter DeRose and published in 1933. It was originally just a piano composition however it was soon converted to big band orchestra.

    The song took on another personality when Nino Tempo and April Stevens made song a pop hit. It hit number one on the US Pop charts in 1963 and actually won a Grammy for Best Rock and roll record. Aside from Nino Tempo and April, Donny and Marie Osmond recorded the song in 1976 and it hit the charts again.

    Other interesting facts:
  • Deep Purple was supposedly Babe Ruth's favorite song.
  • The Band Deep Purple got their name from the song because of constant requests for the song from the guitarist's grandmother.
  • The Beach boys covered the song - Brian Wilson may have been seriously inebriated. It is laughable
  • Ambrotype Repair: Part 3

    Crack Repair

    The most obvious damage to the photo is the enormous cracks that came when it was broken. Additionally there are some scratches and general wear that has occurred to the photos sensitive image. All of these things will be fixed as I use photoshop to clone and replace damaged parts of the image with parts that are not damaged. It is kind of like how a plastic surgeon might graft healthy skin to repair scarred skin. This process is rather laborious so there may be some delays in posts.

    Ambrotype Repair: Part 2

    The first step was to run adjustments and curves on the photo. Ambrotypes don't have much contrast in them by nature, so running curves on the photo really allow much more depth to the photo. I also added a desaturation layer to pull out some of the weird colors that came with pumping up the contrast. There was a little rose pigment added to the original on the cheeks and chin of my great great grand parents. I want to leave that in, however I don't want the ugly greens and browns that seep in from the background. Adding the adjustment layer allows me to reduce some of those ugly colors without degrading the original photo.

    Ambrotype Photo Repair: Part 1


    Mary and Aaron Kinslow were my Great-Great Grand parents on my Grand Mother's side. They had Ambrose Kinslow who had a daughter Ma (Not her name) Kinslow who married a Nunn who had a bunch of daughters. One daughter was Susie Nunn who married Gill Harbison. They had two kids, Kay and David Harbison. David was my dad. SOOOOOO yeah, I'm related to the old folks and I'm going to be fixing this picture. I'll post the progress here.

    About the Photo

    This Ambrotype was taken around 1840-60. Ambrotypes are a type of photograph that is taken on glass. The light-sensitive chemical compound is put on the glass, then exposed to the light through the camera lens. The actual picture is a positive image that is white. You wouldn't be able to tell much by holding the glass to light. In order to see the details you must put the glass over a dark background like black cloth or paper.
    This particular picture was broken and therefore was in many pieces. Since the photo has to be lit from the front, scanning was not an option.
    To get the photo digitized I piece the broken picture together over a piece of black cardboard. I put a florescent light directly above the glass at an angle and took a picture of the photo using my Canon 6D. To repair the photo I will be using Photoshop.

    Monday, August 05, 2013

    Brachiopod 419.2–358.9 million years ago


    Devonian, Silurian Period or Ordovician fossil of Frankfort kentucky. Probably found in limestone. Brachiopods were marine animals. Brachiopod wiki
    Kentucky fossil Regions

    Crinoid 358.9–298.9 million years ago


    Mississippian Period of South Central Kentucky. Crinoids and blastoids are echinoderms. There still are crinoids in the present day oceans however over 600 varieties are extinct. The Mississippian period would have been Early Carboniferous which was 358.9–298.9 million years ago.
    South Central Kentucky would have been shallow sea with lots of shallow sea plants. Crinoids are the fossil remnants of stems of flower like animals. Carboniferous period
    Crinoids
    Missippian Period of Kentucky

    Syro Hittite Idol: 1180 - 700 BC


    Small Syro Hittite Idol 1180 - 700 BC. Sadigh
    Ancient Resources Syro Hittite on Wikipedia

    Celtic bracelet 400 BC - 600 BC


    This celtic bracelet served as both adornment as well as money. Celtic tribes used various items like rings or bells as currency. A bracelet would have served as well.

    Sadigh Gallery
    Ancient Resources Celtic

    Raven Run Hike Lexington KY

    Reb and I hiked Raven Run just outside of Lexington Sunday Aug 4, 2013. The hike was mostly covered which was nice. There were some great views of the Kentucky River. There were a few muddy spots but tennis shoes would work pretty good. The paths were very rocky so expect a good work out on the knees. To do the entire loop took about 2 hours. You could probably do it faster and some hikers were even running. It was hilly so expect to go down the hill, then back up. There is a nature center there as well. I was really impressed. From Lexington it was about a 20 minute drive. Will definitely do this hike again.

    Dick Contino: An Accordion in Paris

    Accordion music from the 60s. French flair. This record has it all. Sweeping strings. The song choices are great and make a fantastic smooth sounding record that just screams for lovers to kiss. I like it.
    Two Loves Have I (J'Ai Deux Amours)  2:15  
    Mam'Selle  2:59  
    The Petite Waltz  2:15  
    Comme Ci Comme Ca  2:40  
    My Man  2:12  
    The Song From Moulin Rouge (Where Is Your Heart)  2:45  
    Beyond The Sea (La Mer)  2:55  
    Under The Bridges Of Paris  2:23  
    Symphony  2:46  
    Domino  2:43
    
    Here is some interesting Dick Contino trivia. He was drafted during the Korean War. He ended up fleeing his post at Fort Ord and got labled as a draft dodger. He was jailed but ended up serving in the Air Force and finally getting honorably discharged.
    He was born in January 1930 and as far as I know is still living in Las Vegas.

    Andre Kostelanetz and his Orchestra: Today's Golden Hits

    Originally released 1966. Another fantastic symphonic arranged pop record. This record features Michelle (Beatles) Yesterday (Beatles) Help (Beatles) Unchained Melody (Nat King Cole) A taste of Honey (Herb Alpert) and more.
    The weirdest rendition is Unchained Melody. The beat is strange and it features odd instrument choices like marching toms and a balalaika.
    Overall this is a great little snap shot of hit songs arranged with 60s orchestras.

    Andre Kostelanetz and his Orchestra: I Wish You Love

    Pop strings. Cake. Champagne Music. Whatever you want to call it this stuff is sugary goodness. Andre Kostelanetz was a Russian orchestral conductor / arranger with the gift of converting pop hits of the day into orchestral pieces. I Wish You Love came out in 1964 and features many hits like Blue Velvet (originally Bobby Vinton), I will Follow Him ( Little Peggy March) I Wish You Love (Nat King Cole) Fools Rush In (Elvis).

    Chances are you won't find this on iTunes or Rhapsody because they are symphonic covers to popular 60s songs. Licensing for the originals are hard enough in this digital age, so a cover is just going to get lost in the mix. That is what makes this record so fantastic.

    Monday, July 22, 2013

    Moqui Marbles


    The iron oxide concretions found in the Navajo Sandstone exhibit a wide variety of sizes and shapes. Their shape ranges from spheres to discs; buttons; spiked balls; cylindrical hollow pipe-like forms; and other odd shapes. Although many of these concretions are fused together like soap bubbles, many more also occur as isolated concretions, which range in diameter from the size of peas to baseballs. The surface of these spherical concretions can range from being very rough to quite smooth. Some of the concretions are grooved spheres with ridges around their circumference.[4][5]

    The abundant concretions found in the Navajo Sandstone consist of sandstone cemented together by hematite (Fe2O3), and goethite (FeOOH). The iron forming these concretions came from the breakdown of iron-bearing silicate mineralsby weathering to form iron oxide coatings on other grains. During later diagenesis of the Navajo Sandstone while deeply buried,reducing fluids, likely hydrocarbons, dissolved these coatings. When the reducing fluids containing dissolved iron mixed with oxidizing groundwater, they and the dissolved iron were oxidized. This caused the iron to precipitate out as hematite and goethite to form the innumerable concretions found in the Navajo Sandstone. Evidence suggests that microbial metabolism may have contributed to the formation of some of these concretions.[12] These concretions are regarded as terrestrial analogues of the hematite spherules, called alternately Martian "blueberries" or more technicallyMartian spherules, which the Opportunity rover found at Meridiani Planum onMars.[4][5]

    Thursday, July 18, 2013

    Apache Rewrites to hide variables

    I've been absolutely fighting with rewrites over the past week. Why do you want to know about rewrites? You can easily hide variables with it.

    Example

     Let's say you want to hide a variable in a clean url. I want http://www.store.com/catfood.html instead of http://www.store.com/product.html?p=1234233

    If you are dealing with apache servers then you'll be dealing with the .htaccess file. Here are the steps required to make that example happen.
    Step 1: open .htaccesss. If you are on a linux server running Apache you should have one. If it isn't showing then it might be a hidden file. If you don't have an .htaccess file then you need to make one. It should be in the root of your public_html folder on your server.
    Step 2: RewriteEngine On   #you need this bit of code to turn on Rewrites
    Step 3: RewriteRule PATTERN SUBSTITUTION FLAG and example would look like this RewriteRule ^(.*)?\.html product.php?p=%1$1 [QSA] 

    The Pattern is "^(.*)?\.html" which uses a regular expression to say Any characters before .html. So if someone types in toyota-camry.html it will take "toyota-camry" from the url - what it does with it is explained in the next part

    The Substitution says "okay you have toyota-camry as a variable - we'll place that variable in your substitution and on the server we'll run product.php?p=toyota-camry. That means you with this rewrite we can obstruct the variable from view and the end user will just see the clean url. Pretty cool.
    So this little .htaccess rewrite handles hiding the variable and give your site a clean looking URL. What this doesn't do is actually process the variable. If you are using PHP you'd need some $_GET methods to process the product id that is being passed to it. That is another lesson all together.

    The Flag is [QSA].  There are lots of different flags, but what that flag means is "append query string from request to substituted URL".  This way you can add on additional query items to the newly formed URL.  Basically it means you could have catfood.html?t=wet and it would pass the varible properly without ignoring the variable.

    Some other cool things you can do with rewrites:

    • You are trying to create dynamic subdomains. Otherwise you'd have to setup each instance in the DNS record. (This one requires adding a wildcard A record on the DNS record)
      •  RewriteEngine on
        RewriteCond %{HTTP_HOST} ^(.*)\.exampleDomain\.com
        RewriteRule ^(.*)$ http://exampleDomain.com/%1/$1 [L]
    • You want to hide directories and file structure. http://www.domain.com/gallery.html instead of http://www.domain.com/pictures/gallery1/index.php
      •  RewriteEngine on
        RewriteRule gallery.html$ pictures/gallery1/index.php [L]

    Additional resources:

    This is an absolutely fantastic resource by addedbytes Url rewriting for Beginners

    Saturday, July 13, 2013

    Robert Berger 460 train watercolor


    My newest watercolor. A fantastic watercolor if the steam engine 460 of the Pennsylvania line. Bob had some very realistic originals for sale at the Berea Craft festival July13,2013

    Berea craft festival 2013





    Friday, July 12, 2013

    Prehistoric Indian Gorget - Brookville IN


    Meteorite sliver. Sweden 800,000 YO


    This fine specimen is an Octahedrite meteorite. It gets its' classification due to the crystal patterning of the iron in the meteorite. "Octahedrites are the most common structural class of iron meteorites. The structures occur because the meteoric iron has a certain Nickel concentration that leads to the exsolution of kamacite out of taenite while cooling." --view wikipedia This specific meteorite is probably a sliver from the Muonionalusta meteorite that struck northern Sweden around 800,000 years ago. Here is an awesome link about meteorites in the region, along with pictures of pieces being excavated.

    Clay pipe conglomeration 1880s


    Purchased in Metamora Indiana Fall 2012 - The pipe is originally from Point Pleasant Ohio. It was discovered in a creek in Clermont County Ohio. Here is a paper over the pipes from that region

    Trilobite




    Purchased in San Antonio May 2013.