Skip to main content

Posts

Showing posts from 2016

Java Example: LinkedList

The purpose of this example is simply get some decent exposure to the LinkedList class. A phone directory is the most desirable choice to show this data structure . Within our phone directory program, we'll want to be able to: add a new record, delete the current record,  change the first name of the current record,  change the last name of the current record,  change the phone number of the current record,  select the current record, show all records and  quit the program. The phone directory will store the first name, last name and the phone number. When inserting, we're going to want to insert the new record into the correct order without creating or using a sorting algorithm . You may have duplicate names but not duplicate phone numbers. The phone directory should be sorted by last name, first name, phone number. When deleting a record, there will not be a current record that's selected. To select the record after deletion, you must use the select the curre

Creating your own ArrayList in Java

Wanted to show that certain data structures in Java can be created by you. In this example, we'll go ahead and create an ArrayList data structure that has some of the methods that the built in ArrayList class has. We'll create 2 constructors: The default constructor that creates an ArrayList with a default size of 10. Constructor that allows an initial size to be passed to the array. We'll also create a number of methods: void add(Object x);  A method that allows you to place an Object at the end of the ArrayList. void add(int index, Object x);  A method that allows you to place a value at a given location. Object get(int index):  Allows you to retrieve a value of the arrayList array from a given location. int size();  Allows you to get the number of elements currently in the Arraylist. boolean isEmpty();  Tests to see if the Arraylist is empty. boolean isIn(Object x);  A method that sees if a particular object exist in the arrayList. int find(Object x);  

How to Install and use phpDocumentor

If you have Windows, and are running WAMP, this is the step by step installation guide to getting phpDocumentor to work. This write-up assumes that you have WAMP installed and working. Download Composer from  https://getcomposer.org/ Run through the installation with the default settings. It will locate php for you automatically. If you're having any issues with the install, Google the response. There shouldn't be any errors though. If you have CMD opened, close it now. Open CMD and type in composer . If something starts happening, Composer is installed correctly. Go to the directory that you want to install phpDocumentor . In your project directory, create a JSON file. Name it, composer.json and add the following code to it { "require-dev" : { "phpdocumentor/phpdocumentor" : "2.*" } } For example, let's say that your project directory is located in C:/wamp/www/your_project , you're going to want to open CM

Java Vectors

The purpose of the following example is to get you acquainted with the Vector class in Java. We're going to create a program that simulates a deck of cards. The constraints are; you may only use Vectors and arrays. As you may know, Vectors only accept objects so your cards should be objects. The initial portion of the program display the cards and their suites in order (i.e. Ace of Diamonds, King of Diamonds, Queen of Diamonds ... 2 of Diamonds ... Ace of Hearts, King of Hearts ... ). You are to create your own shuffle algorithm; do not use Collections.shuffle(). Here's what I came up with.

Anagram in Java

Recently I was given a problem that stated: Create an anagram program in Java that reads a text file and computes the anagrams of the words. If the words are anagrams of each other, put them on the same line; if they're not, print each one on a new line. The anagram program should create a new text file. The only data structure that you can use is an array. You must create your own sorting algorithms. This was my solution to it.

We Need to Go Green

I'm sure that everyone pays attention to the news. For one reason or another, I'm going to assume funding practices, our politicians are hesitant to pursue cleaner energy alternatives. We shouldn't be biased since other countries are not participating either, but we should lead as an example for the rest of the world; after-all, the world watches our nation very closely. The dependence on fossil-fuels is in direct correlation with the demand for it. What's causing this increase in Greenhouse gases? I'll let the experts answer that: NASA . So what's happening? "The last monitoring station in the world without a 400 parts per million reading has now reached it, NOAA confirms." -- The Guardian "In the remote reaches of Antarctica, the South Pole Observatory carbon dioxide observing station cleared 400 ppm on May 23, according to an announcement from the National Oceanic and Atmospheric Administration on Wednesday. That’s the first time it’s

MOZ Page/Domain Authority Error

It started off like every other night; my brother and I were exchanging SEO related tips. Our nightly conversation consisted of the numerous PBN's that were recently taken down. PBN's used to be the way, black-hat-way, to rank sites quick and dirty. Google caught on and started cracking down on the thousands of PBN's in existence. Certain people still claim that they work, and I don't doubt it, but the fame is short-lived. The potential of having your site banned is not worth the risk. I was showing him a blog that I recently started. it showed a MOZ PA of 77 and a DA of 92. I knew that the content I was writing was good and I'm sure people are sharing it, but for it to show a PA of 77 was suspicious after the blog being up for a month. A quick Google search showed that all Blogspot accounts were ranked at 77. We searched further and saw that all Tumblr accounts had a PA of 94! After browsing through numerous different forums, we couldn't find any addition

Remove index.php from CodeIgniter's URL

I've seen plenty of write-ups on how to remove index.php from your URL. What these write-ups don't seem to account for is if you're working on a WAMP server. So here are the steps to remove index.php using .htaccess Step 1 Open application/config.php $config [ 'index_page' ] = "index.php" needs to be $config [ 'index_page' ] = "" You may also have to change $config [ 'uri_protocol' ] = "AUTO" to $config [ 'uri_protocol' ] = "REQUEST_URI" You might also have to clear your base_url $config [ 'base_url' ] = "" Step 2 Create a .htaccess file in your CodeIgniter root directory (the directory where you see your application, assets, system folders and add the following code to your .htaccess file: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond % { REQUEST_FILENAME } ! - f RewriteCond % { REQUEST_FILENAME } ! - d RewriteRule ^ ( . * ) $ index .

Proving a Proposition is a Tautology in Discrete Math: Example

Proofs aren't always easy to write out but I'll attempt a lengthier proof that I've recently seen. The assertion is that the proposition  [p → (q → r)] →  [(p → q) → (p → r)] is a tautology. We can approach this in a couple of different ways. One way would be to create a truth table, which I'll demonstrate below and the other will be to do it with inference laws. I'm not going to list out all of the inference laws, but will instead just work out the example. The truth table should display True for all of the different combinations and as can be seen below it does. p q r q → r p → (q → r) p → q p → r (p → q) → (p → r) [p → (q → r)] → [(p → q) → (p → r)] T T T T T T T T T T T F F F T F F T T F T T T F T T T T F F T T F F T T