Skip to main content

Posts

Showing posts from June, 2015

Forms Class Example: Adding Users

I wanted to create a class that really utilizes the Forms Class to it's maximum potential. The following example is how to add an employee to your website so that he may access it with employee privileges.

You'll first have to create the tables within your database. The following tables are used in this example:
employeesStores the employee detailsid, first_name, last_name, location, street, street_two, zip, telephone, email, active, date_started, date_terminatedusersStores the login informationid, user_id, password, token, user_type, activelocationsAllows for multi-location supportid, location, street_address, zip, phone, activeuser_typesLists the different user type privilegesid, description The code itself is pretty straight forward. Start with __construct() and follow main(). The user will be presented with the form to enter employee detailsChecks will be administered to verify data accuracyUser is inserted into employees and users tablesAdmin is redirected to edit details p…

Working your Employees

Before I begin, I know that not every single person making a significant income sacrifices everything to achieve it, especially at the expense of their staff, but most employers work their employees to death to achieve that status.

America, the home of making the impossible possible. You really do get every opportunity out here. You'll have to know how to work the people you're dealing with to ultimately achieve what you want to achieve (I suggest reading up on psychology). :)

However, not every single person is as motivated or is capable of being motivated to the extent that some of us are. It's important not to exploit these people.

Capitalism dominates us, but why? What's the difference in pocketing $250,000, $350,000, $500,000 or even a million/year. I can answer that algebraically of course, but to what extent are we doing this? I've seen people demand horrific hours out of employees even going as far as requiring for the employee to be available 24 hours/day.

Following the List

I was asked today if I'll always follow my list...if my list will ever get shorter. I thought about it and responded with a definite yes to the former and no to the latter.

Once the decision came to optimize my day, that was it; it never occurred to me to stop. I always keep striving to optimize the list more so that I may add more to the list; it feels like that's the only way I feel productive, relaxed and accomplished.

I've always found comfort in knowledge. Whenever I feel anxiety, stress, boredom, etc, I turn to books, reading of any sort really, and learning new topics. I start feeling the relaxation instantaneously and a few days later I'm completely back to my normal self.

If you have no idea what I'm talking about, here's the list that I'm referencing:
http://dinocajic.blogspot.com/2015/06/keeping-on-point.html

E-Commerce: Beyond Programming

It finally came: the day your e-commerce site launched...and nothing. Many people that I've dealt with are under false assumption that the launch of their e-commerce site will instantly bring sales. Wrong!

That's when your work starts. Well actually, if your work started here, you're already somewhat behind. Selling online doesn't have to be necessarily done through your site.

While the developer is getting your site ready,

get your business license and secure your name (I hope this was your first step)open up a business bank accountlink that bank account with PayPal or another online payment processorsetup a phone numberpost products on Amazon, eBay, Craigslist, etcopen up a blogopen a Facebook, Twitter, Instagram, etc. With PayPal, you can even include buy-now links in your blog or Facebook page. 
Once it's operational, promote, promote, and promote. Capture any leads and follow up with them. Make sure that you and your staff mark every sale as extremely important…

Beginner Java Exercise: Selection Sort

The following example demonstrates how to utilize the Selection Sort algorithm.
You'll need to create a method called selectionSort() and pass an array. Loop through the array. Assign the current iterated i as the minimum. Test against other values. Once you find a value that's smaller, assign the current value to the minimum value. Test to see if the current value is different from the initial value. If so, swap the values for the two positions within the array.

Beginner Java Exercise: Calling Classes

Java, like most object oriented languages, separates codes into smaller chunks for easier maintainability and re-usability. You as a programmer have an option of separating code out to different methods within the class you're currently working on, or if enough related methods accumulate, to it's own separate class.

In Java, if you place the classes within the same directory you may call each class's methods, as long as they're public. To give you an example, we'll create a RandomCharacter class that generates and returns random characters, and a separate TestRandomCharacter class that utilizes the code from the RandomCharacter class.

Looking at the class below (RandomCharacter), you'll notice that there are 5 methods within the class. Each method does something different: refer to the notation above each method for the overview.


Now that we have the class setup, we can call the methods from this class within our TestRandomCharacter class. Note that the Rand…

Separation of Sales, IT and Marketing

If you're easily offended, don't read this....I'm just tired.

You'll find plenty of articles online on how everyone needs to collaborate together as a team, blah, blah, blah.

What these articles fail to tell you most often is how.

Having experience in all 3 fields, I find it interesting, and extremely aggravating, how in every job that I've had, sales staff wants to neglect their duties and focus all of their attention on marketing, IT, Graphics Design, etc. That sentence was maybe somewhat over-exaggerated but I hope that you can easily see my frustration; my heart-beat's elevating, and that neck-vein is starting to throb just by writing this article.

My problem is that everyone's an expert. If you have experience building websites, designing networks, researching and installing new hardware, creating industry specific graphics design, marketing online or offline, and are currently stuck in sales due to consecutive bad luck with hiring agents or some other…

Keeping On Point

Previously I wrote about a question that I was asked: How do I stay so motivated?
http://dinocajic.blogspot.com/2015/06/how-do-i-stay-motivated.html

I listed that it wasn't anything specific, but instead a collection of thoughts, beliefs, etc.

Today, as I was watering my lawn, and hating myself for the amount of time I'm wasting because I haven't installed the sprinkler system yet, I made a mental note to add to my daily checklist app the following: I need to spend at minimum 10 minutes per day doing daily house chores. It's starting to pile up...

I need to install the sprinkler systemI need to finish installing the outdoor camera surveillance systemWash and assemble my son's outdoor play swing-setInstall the Radiant Barrier inside the atticFinish the thorough organization of paperworketc, etc, etc When it hit me. The reason why I accomplish so many daily tasks is pretty simple: the Daily Success Checklist. If you're an Android user, you can download it: Daily Su…

Forms Class: Modified

As was inevitable, I ended up tweaking the Forms Class that I originally created. Changes include:

Adding a way to pass an additional button to the submit_button() methodForce to display a value that you want through the $forceValue parameter in input_type_text()select_option() checks for both $_POST and $_GET to display the selected optionEach method has a new parameter called $formGroup. Allows the user to wrap the method contents with the form-group div tag.

Favorite Quotes

The following quotes have helped shape who I am and I find it extremely important to review them daily. Certain quotes I'll explain...others I wont :)

Enjoy the collection....they'll grow with time.

"Ninety percent of uneducated American are religious. The amount of educated religious people: 60%. These are people with Graduate Degrees.  How many scientists in America are religious? About 40%. A graduate degree in any subject, gets you half-way there. Science is an increment from the overall educated people. Now you go to the Elite Scientist, 7% are religious. Here's my concern, when you're educated and you understand how physics works, and you're mathematically literate, and you understand data, and you understand experiment, and you go up to someone who doesn't have that training, and they're religious, and you ask them why are you religious believing in invisible things that influence your life? What's wrong with you? That's unfair! It's…

5000 Articles Read

As I was reading my daily 20 (as I like to call them), I checked my Twitter count to see if I've indeed reached the 20th mark for that evening.

Each day since last November, I've dedicated at least an hour each day to read 20 articles from numerous new sources. I haven't missed a day since that Thanksgiving Day when I decided to start it..in fact, most of the time I'll read more than 20.

205 days have elapsed since I've started this semi-aggressive reading and notating approach (each time I read an article, I'll post the link and title on Twitter). On day 204, I reached 5000; it just happened. I didn't think about it and it was a surprise truthfully speaking.

So I wanted to see how much I read on a daily basis, how many articles I've read per day on average, and how does that translate to books read.

June 20th, 2015
5028 articles total
~24.5 articles per day
Word count for today. I copied the text from each article and pasted it into Word, it came out to…

Collection of Books Read

The following collection was started in 2015. The reason I decided to start it in 2015 is because I would prefer to re-read most of the books that I've read prior to that year.

49). Consciousness and the Brain: Deciphering How the Brain Codes Our Thoughts Stanislas Dehaene
48). Origin Dan Brown
47). Fire and Fury: Inside the Trump White House Michael Wolff
46). Computer System Architecture: 3rd Edition M. Morris R. Mano
45). Who's in Charge?: Free Will and the Science of the Brain Michael S. Gazzaniga
44). Life 3.0: Being Human in the Age of Artificial Intelligence Max Tegmark
43). CodeIgniter for Rapid PHP Application Development David Upton
42). Concepts of Programming Languages (11th Edition) Robert W. Sebesta
41). Head First C: A Brain-Friendly Guide 1st Edition David Griffiths and Dawn Griffiths
40). Head First Algebra: A Learner's Guide to Algebra I Dan Pilone and Tracey Pilone
39). The Future of the Mind: The Scientific Quest to Understand, Enhance,…

Beginner Java Exercise: Method Overloading

Pretty self explanatory, so I won't go into too much of an explanation: just a quick example.

Method overloading is allowed in Java enabling you to define different methods with the same name as long as their signatures are different. The Java compiler determines which method to use based on the signature.

Beginner Java Exercise: Creating Custom Methods

A method is normally created to execute some repetitive code. For example, lets say you want to perform the quadratic formula on 10 different instances; Instead of writing the quadratic formula 10 different times, you create a method, pass the necessary parameters (in this case a, b and c) and have the code method return the value.

I honestly use it to make my code look cleaner and for re-usability across multiple classes.

In the following example, we'll find the greatest common divisor by utilizing the following steps: Instantiate the Scanner classPrompt for first integer and storePrompt for second integer and storeCall the gcd() method to calculate the greatest common divisorReturn the value and display it to the screen

PHP Forms Class: All Tied Together

In the last few examples concerning the forms, I've gone through how to create the Forms class and how to create a method to utilize that class.

To refresh your memory:
http://dinocajic.blogspot.com/2015/06/php-forms-class.html
http://dinocajic.blogspot.com/2015/06/php-forms-class-in-action.html

This time, I'm going to show you how I tie it all in by creating a real life example.

The following class was created as part of a larger web-application that inserts a purchase order into the database. It's very brief and the next class will add items to that purchase order.

What we want to store is:

PO #Date that the shipment is scheduled to arriveWhich location is the shipment arriving toWhat's the current status of the shipment. If it's ordered from China, for example, there can be a few different types of statuses: WaterRailTruck orHasn't ShippedOverview of the class AddPackingSlip I like to take the Java approach and import all of my classes at the beginning of t…

PHP Forms Class in Action

A couple of days ago I created a Forms class that I can re-use in most of my projects. I stated that I would show you an example of how I generate the form fields when they're needed. So here we go.

To reference the Form Class:
http://dinocajic.blogspot.com/2015/06/php-forms-class.html

In the following example I'm creating a form and utilizing the forms class to help me separate most of the HTML from PHP.

This is what the form will look like once the code is executed.
















To help guide you through the code:

$_form is instantiated prior to the method call. A random token is generated and set to $_SESSION['token'] to prevent Cross Site Request ForgeryAlso as an additional measure of security, we're only going to allow for the form to be valid for 5 minutes. So, we'll set $_SESSION['token_time'] = current time()The hidden field is generated with the random token as the valueInput type of text is called to generate po_number..Months are generated (i.e. 1 => Ja…