Skip to main content

Posts

Showing posts from 2015

SQL: Selecting Values from a table with multiple initial values

The easiest way to explain this is by providing an example. Lets say that you have a table within the database called wheels. Lets say that you want to be able to provide the long description to a customer after he or she clicks on the particular wheel to view details, the abbreviated description to the warehouse and sales staff (to look it up on the boxes) and the short version to the customer when he or she is initially searching for the wheels; you don't want the customer to have 500 options for chrome (i.e. Chrome w/ Black Inserts, Chrome w/ Black Inlay, etc). So you decide to store the finishes in a separate table called wheel_finish. The issue arises when you're selecting the item from the table. You can't execute the statement by calling an sql command like the one stored in $wrong_sql. Instead, you have to do a select statement for each individual finish within the main select statement. Here's an example:

Trick for PHP Server timeout

Every once in a while I'll need to run an extremely time-consuming query that compares two or more tables in a database and updates multiple tables from there. Realistically speaking, it would take way more than 30 seconds to compute. Sometimes, and there are numerous occasions that I've run into, it's not realistic to do everything on your local server (where you can extend the execution time) and you must do it on the non-accessible server where you host your site. My trick is to load the content into a $_SESSION, loop through the that session and after every 50 to 100 iterations, refresh the page. After each iteration the current value of the session is unset to avoid duplicate values. After all values have been unset, the script will end.

Pride in your Work

I'm asked frequently how is that I'm able to receive job offers on almost a weekly basis without applying anywhere. There are a few techniques of course, such as making sure that you're well connected and that you have a steady online-and-offline presence. But I strongly believe that the main reason is the fact that I take extreme pride in pushing myself to achieve new benchmarks at work (and in life in general). My feeling is that regardless of your feeling towards a specific employer, strive to achieve your best: it's practice for the next job. That way, your work ethic, consistency, dedication and precision will be regarded highly by your current employer, future employer and of course you.

Setting Goals

I've previously mentioned that I follow a check-list to a t each and every day regardless of the situation. My brother has even made a rather dark joke once saying that when confronted about what I was doing staring at a phone during someones hypothetical funeral, I would reply "perfect time to finish reading my articles...don't want to waste any time." Another important tendency to develop is to achieve goals and accomplish them on time. I've generated a list of work related, as well as life-related, goals that I want to finish over the next 1 to 5 years and now that it's out in cyber-space I hold myself personally accountable to finishing them. A few goals actually begin tomorrow; others have already been in progress and a few are about to be completed.

Java: Aggregation

"Aggregation is a special form of association. It is also a relationship between two classes like association, however its a directional association, which means it is strictly a one way association. It represents a Has-A relationship. For example consider two classes Student class and Address class. each student must have an address so the relationship between student and address is a Has-A relationship. But if you consider its vice versa then it would not make sense as an Address doesn’t need to have a Student necessarily." Why we need Aggregation? To maintain code re-usability.

Planning Your Life

What an important topic and yet it's quite underutilized. People need to escape the mindset of: Go to school Get good grades Get a degree Get a job Work 9-5 Make and spend money Although vital, numerous studies point to the fact that more money doesn't necessarily equal happiness. At a certain point you'll buy everything that you've ever wanted but you won't know who you truly are. I'm planning on sitting down with my wife this weekend and creating a list of what we believe defines us as individuals. What are our goals and ambitions? What makes us happy? What kind of a person is our dream person? A quick one for me: to have a PhD in Theoretical Computer Science and to have multiple bachelor degrees in fields like Math, Physics, Biology, Philosophy, Psychology and Chemistry.

Abstract Class Example

An example from my code of an abstract class and how to extend it to a concrete class. You really don't have to understand what's going on in the code; the purpose of this code is just simply to show you how to extend and utilize an abstract class. The Abstract Class The Concrete Class that extends that Abstract class

Normalization

What is Normalization? Normalization, more commonly referred to as database normalization, is the process of organizing the attributes and tables of a relational database to minimize redundancy. The first step in creating and using a relational database (like MySQL) is to establish the database's structure. Database modeling is crucial for successful long-term management of information. You'll carefully eliminate redundancies and other problems that would undermine the integrity of your database. Normalization involves decomposing a table into less redundant (and smaller) tables but without losing information; defining foreign keys in the old table referencing the primary keys of the new ones. The objective is to isolate data so that additions, deletions, and modifications of an attribute can be made in just one table and then propagated through the rest of the database using the defined foreign keys. A typical example of normalization is that an entity's unique ID is...

Abstraction vs Encapsulation

"You do abstraction when deciding what to implement. You do encapsulation when hiding something that you have implemented." Abstraction refers to the ability to make a class abstract in OOP. An abstract class is one that cannot be instantiated. All other functionality of the class still exists, and its fields, methods, and constructors are all accessed in the same manner. You just cannot create an instance of the abstract class. If a class is abstract and cannot be instantiated, the class does not have much use unless it is subclass. This is typically how abstract classes come about during the design phase. A parent class contains the common functionality of a collection of child classes, but the parent class itself is too abstract to be used on its own. Encapsulation is one of the four fundamental OOP concepts. The other three are inheritance, polymorphism, and abstraction. Encapsulation is the technique of making the fields in a class private and providing access to...

PHP Polymorphism

Polymorphism is a topic that programmers seem to be afraid of...even though it's a simple concept attached to a frightening word. Polymorphism describes a pattern in object oriented programming in which classes have different functionality while sharing a common interface. A variable of a supertype can refer to a subtype object. An example: Circle and Rectangle class implement the shape interface. Shape contains the getArea() declaration. By implementing the Shape interface, Circle and Rectangle must have the getArea() method. Each method performs a different operation since retrieving the area is different when it comes to circles and rectangles. Lets say you have a file with the function computeCost(). That method will take the getArea() and multiply it by 1.25. If you wanted to compute the cost for the circle, you would have to instantiate the Circle class, pass the radius, call the computeCost() function and pass the instantiated circle object. Within the computeCost() m...

Abstract Classes

Just wanted to list a few key features of abstract classes that might help you grasp the concept. So what defines an abstract class? A class with the abstract reserved word in its header.  Abstract classes are distinguished by the fact that you may not directly construct objects from them using the new operator.  An abstract class may have zero or more abstract methods. Consider using abstract classes if any of these statements apply to your situation: You want to share code among several closely related classes. You expect that classes that extend your abstract class have many common methods or fields, or require access modifiers other than public (such as protected and private). You want to declare non-static or non-final fields. This enables you to define methods that can access and modify the state of the object to which they belong. Benefits? Code management and speed of modification. Cleaner code. If you have certain methods that you know will alway...

CMS

"A content management system (CMS) is a computer application that allows publishing, editing and modifying content, organizing, deleting as well as maintenance from a central interface. Such systems of content management provide procedures to manage workflow in a collaborative environment. These procedures can be manual steps or an automated cascade. CMSs have been available since the late 1990s. CMSs are often used to run websites containing blogs, news, and shopping. Many corporate and marketing websites use CMSs. CMSs typically aim to avoid the need for hand coding, but may help it for specific elements or entire pages. The function and use of content management systems is to store and organize files, and provide version-controlled access to their data. CMS features vary widely. Simple systems showcase a handful of features, while other releases, notably enterprise systems, offer more complex and powerful functions. Most CMSs include Web-based publishing, format manageme...

PHP Generate Links

The following code can be used throughout your existing PHP classes. If you use a similar URI pattern, you won't have any issues with instantly plugging the methods into your existing code. Otherwise, you may have to tweak them slightly. To generate a link, you'll call the generateLink() method from your file and pass either NULL or an associative array with key/value pairs to add onto the URI. i.e. Example URI: http://example.com/index.php?page=view_by_size&type=0&id=10&xxx=something $this->_frequent->generateLink(array("type" => "2")); Read the comments above each method to understand what's happening:

Meteor Shower Tonight

Get ready for a spectacular meteor shower tonight. NASA will be broadcasting the entire event over their website starting at 10:00pm: https://www.youtube.com/user/ScienceAtNASA "The Perseids have been observed for at least 2,000 years and are associated with the comet Swift-Tuttle, which orbits the sun once every 133 years. Every August, the Earth passes through a cloud of the comet’s orbital debris. This debris field -- mostly created hundreds of years ago -- consists of bits of ice and dust shed from the comet which burn up in Earth’s atmosphere to create one of the premier meteor showers of the year. The best opportunity to see the Perseid meteor shower is during the dark, pre-dawn hours of Aug. 13. The Perseids streak across the sky from many directions, with theoretical rates as high as 100 per hour. The last time the Perseids peak coincided with a new moon was in 2007, making this one of the best potential viewings in years."

Programming: Not for the faint of heart

“If you can't explain it to a six year old, you don't understand it yourself.” -- Albert Einstein I love and hate this particular saying. I love it for the simple fact that it's absolutely right and hate it because it's one of the most aggravating sentences ever created: let me explain. Once you explain what you're working on, people have the tendency of assuming that they can do your job as well as you can. I can instantly see their minds working and saying, "we can just hire anyone off of the street to do his job; heck, I can even do his job! Why are we paying him again?"  If you explain it using your field's vocabulary then they start thinking you're pretentious and that you need to step back down to Earth like every other normal person.  So, it's a lose, lose situation. Programming takes it to a completely new level. You have to be truly passionate about what you do. Slowly, but surely, you'll find out that your progr...

Specializing

You may have recalled that I wrote about whether to specialize or broaden your knowledge. http://dinocajic.blogspot.com/2015/08/broadening-your-overall-knowledge-or.html Although I'm still a believer in broadening your knowledge, I think I've finally come to the conclusion to specialize 80% and broaden about 20%. Why? It hit me the other day when I started researching "Positive News" articles. To date, I've read (and recorded) over 6,000 articles: most are negative by nature or they simply make you want to rip your hair out (i.e. any news related to Donald Trump). However, these seem to dominate. I try to skip over them as much as I can but it takes me roughly 30 minutes every day to just figure out what I'm going to read. Seems like a waste of time and one can't help but read the titles of articles as one is browsing for articles to read. So, I've come to terms with substituting news articles (most of them anyway) with tutorials or industry re...

Future of Web Programming

I knew it was inevitable that PHP will one day be replaced by a more client friendly language, but didn't think it would come so soon and was quite surprised that JavaScript would leap as far as it has. I believe the MEAN framework will do just that. It was almost like you needed PHP (or another server side language) to perform database task, but now there's AngularJS that allows you to connect to the mongoDB (vs. MySQL). Although it will take some time for JavaScript to take over, client demand will surely outpace PHP's page reload method. "No, JavaScript won't be the only language in the programming world, especially given the surprising number of ads for Cobol programmers still being filed, but it will certainly begin to seem that way. JavaScript is inescapable on the browser, which now dominates almost everything a client computer does. Now the server side is embracing it with tools like Node.js. JavaScript will assuredly become more dominant in oth...

CodeIgniter

Just a quick update. Started looking at CodeIgniter and the framework is extremely simple to use. If you have MVC experience (or are looking to get some) and a decent understanding of PHP itself, CodeIgniter might be the way to go for you. Day 2 into it and I was ready to start building websites with it on Day 1. Read the documentation since it's surprisingly very helpful. Browsed through their forum section and it looks like they have a decent following. I've already made a few examples over the past few days but will start an actual site this Monday. After that, Laravel.

Benefits of PHP MVC Frameworks

I've been reluctant to switch to an MVC framework for quite some time now, but the benefits outweigh the negatives. I'm officially going to start using CodeIgniter, Laravel, Yii, CakePHP, Symphony and Zend to create (or modify existing websites) and to adhere to those standards. Each website will be written with a different framework of course. I'll let you know how each framework does for me as I finish each site creation or transition. Some benefits for using an MVC framework: Code and File Organization When you setup a PHP Framework, it already has a certain folder structure. It is expected from you to follow the same standards and keep everything organized in a certain way. Once you get used to this model, you will never want to go back. Utilities and Libraries All top PHP frameworks come with certain Libraries and Helpers, that help you with: Form Validation Input/Output filtering Database Abstraction Session and Cookie Handling Email, Calendar, Pagin...

Stress-Free Work

The number one (#1) thing that will push me away from a job is the stress-level. I've had the tendency of creating unnecessary stress for myself in the past by attempting to improve areas that I saw were flawed; just be careful if you attempt to do the same that the owner (or your manager) doesn't micromanage everything for he or she will make your life somewhat miserable if you attempt, and succeed, at doing more than your current duties entail.  With that said, there are also different types of stress: direct and indirect. Direct stress for me is my current salary, unrealistic deadlines and unnecessary aggravation directed towards me. Indirect stress is witnessing aggravation directed towards someone else. Although not as stressful, I do have to take a vacation from time to time to escape the indirect stress. My current job is great in the aspect that it really doesn't produce much stress for me anymore. I've stuck with the company for 6 years now and will be t...

Broadening your overall knowledge or specializing

I've recently run into a dilemma: whether to keep the specialized to broad learning ratio at 70% - 30% or move more towards a 100% specialized learning. It seems more likely that financially I'll attain better results if I move more towards the 100% computer programming all the time regime; I struggle with this almost daily. I've achieved my financial dreams that I set out for myself 3 years ago; I honestly didn't think I'd achieve them this quickly. I've bought everything that I've ever wanted and live in a place that I honestly could retire in. I guess my only real dilemma is status; whether I want it or not. Do I want to be recognized as an expert in a field or not? When I look at it this way, I know that what I'm doing is exclusively for myself and I move back towards the broad learning. The only problem is that it's difficult to keep motivated when you break your day apart into so many different tasks (i.e. I'll read 4 books at a time and...

Vacations

It seems that every time I take a vacation I exclusively use it to catch up on work, whether work-work or home-work related. This vacation so far has been roughly the same. I have focused on tasks related in or around the house such as assembling the bookcases. Regardless of the task, it seems that every time I do genuinely feel rested. My mind doesn't have to deal or listen to the politics and that's enough for me. I am dedicating the remainder of this vacation to my son and spending every second with him. If you haven't taken a vacation in a while, take one. You'll feel better.

Positive Thinking

Your belief (or lack of) doesn't have to dictate your positive thinking capabilities. It seems that once you start requesting proof of everything, going as far as refusing to answer a simple "do you believe in this" question (without some proof), your mind starts spiraling into a somewhat pessimistic outlook on life. It came to the point that my inner-voice would break down everything that anyone said to me into simple philosophical questions: does this question violate any fallacies? Should I even answer such a question? When you get consumed by questions like that, your mind (or at least mine) seems to slowly stray away from happiness in general. I read an article not too long ago on a scientific study that stated how a person's brain will actually look different if they just though positively for at least 2 weeks. I decided to give it a try. I constantly listened to music, watched stand-up comedy and pushed negative and even neutral thoughts out of my head. A...

Behaving like Humans

It seems like the topic of whether the government (money coming out of our paycheck) should help the poor and underprivileged during the time when they need it the most, such as during the time of unemployment. While undergoing lengthy conversations with these individuals, the one thought keeps resurfacing itself over and over again: that many Americans have lost their sense of humanism and are blindly following what they're told is destroying America. During the conversation, I'll always pose the following question: Do you believe that every single person truly has the motivation, will power and intelligence to do what you want them to do? They'll always answer with a forceful yes. Nothing is ever that simple. Ask yourself how are there still cannibals in the world. Why do the North Korean people still truly love their leader? How are genocides still possible? People are bread very differently. It's up to us and our government to educate them differently and no...

PHP: Error Reporting

As previously mentioned, this post deals with Error Reporting. The class itself is pretty simple. You have the main() method that creates the error page and you can also call the error() method from another class to email and store the message. In both instances the previous and current pages are recorded for diagnosis. If you take a look at the storeErrorMessage() method, you'll notice how the error message is constructed and stored into the $error variable. The sendErrorToWebmaster() method is then called. In another file, instantiate the class. Where an error is likely to occur, construct the $error variable and call the error() method i.e. $this->_error_reporting_obj->error($error);

PHP: Recording Page Hits

Wanted to create something that was easy to use, maintain and grow. It's extremely basic as it is. It stores the page visited and if the user is logged in, their id; if the user is not logged in, it currently stores "0" as the user id. Later, this class might expand to store the user's browsing history by recording their IP address and the pages that they visit. You'll first need to create 2 tables within your database: pages and statistics. You'll need 3 but I'll show you how to create two. The third one is users that you should probably already have if your users are logging in at all. Note: I'll show you how to create the ReportError class in my next post. The pages stores the URI for each page. You don't want to store the page within the statistics table, just the id. This is for optimization and to minimize repetitiveness. The next table is the statistics table. This table contains the id's referencing other tables and the times ...

PHP: Main Controller Tweaks

I wrote about the main controller a few days ago. Looking at it now, I've decided to make one tweak that was necessary and one that's purely for performance (and to keep consistent). To review the previous version, visit: http://dinocajic.blogspot.com/2015/07/php-main-controller.html The main change done is to the processHeaders() method. When logging in or out, it's required that the SESSION and COOKIE creation and deletion is done before any information is submitted. This is what the processHeaders() method looked like before: And this is what the modified processHeaders() method looks like. As you can clearly see, the logout, the SESSION based login and the COOKIE based login are all processed through this method.

My thoughts on Climate Change

There have been so many studies done on humans' effect on climate change that the burden of proof shifts from the people trying to prove that it's real to the people that negate it. For accurate information regarding climate change, visit: http://climate.nasa.gov Some stats for you: Carbon dioxide levels in the air are at their highest in 650,000 years Carbon dioxide (CO2) is an important heat-trapping (greenhouse) gas, which is released through human activities such as deforestation and burning fossil fuels, as well as natural processes such as respiration and volcanic eruptions.  As of June 2015, we're at 400.47 ppm (concentration of mid-tropospheric carbon dioxide in parts per million). The 10 warmest years in the 134-year record all have occurred since 2000, with the exception of 1998. The year 2014 ranks as the warmest on record. Sea level rise is caused primarily by two factors related to global warming: the added water from melting land ice and the ex...

Breaking down Stress: How it forms and what it does

You might have noticed by now that I like to break down everything to it's simplest forms. Today, I'm tackling stress. The following document contains a series of paragraphs that I believe best helps explain the phenomenon. "Stress is simply a reaction to a stimulus that disturbs our physical or mental equilibrium. In other words, it's an omnipresent part of life. A stressful event can trigger the “fight-or-flight” response, causing hormones such as adrenaline and cortisol to surge through the body. A little bit of stress, known as “acute stress,” can be exciting—it keeps us active and alert. But long-term, or “chronic stress,” can have detrimental effects on health. You may not be able to control the stressors in your world, but you can alter your reaction to them. Cortisol is a steroid hormone, belonging to a broader class of steroids called glucocorticoids, produced by the adrenal gland and secreted during a stress response. Its primary function is to redistribute...

Microsoft Word Mail Merge

Mail Merge is extremely simple in Word 2010 however it seems that because I don't use it as often, I always have to dig around and find out how to use it. Here are the step-by-step instructions on how to easily do mail merge. 1. Create an Excel Sheet with headers in the top row (i.e. Name | Address | Street | ST | Zip) 2. Populate the Excel sheet with the content. Save upon completion. 3. Open Word 2010 4. Click the  Mailings  tab. 5. Click  Start Mail Merge  and select  Labels . 6. Select  Label Vendor  (i.e. Avery) and select  Product Number  (i.e. 5160 Easy Peel Address Labels). Click  OK . 7. Click on the  Select Recipients  and select  Use Existing List . 8. Browse and find your Excel Sheet and Click  OK . Make sure that  First row of data contains column headers  is checked. 9. Make sure that your cursor is in the first label ...

PHP: The Main Controller

Last time I wrote about using the index.php page as the gateway to the main controller: http://dinocajic.blogspot.com/2015/07/php-using-indexphp-as-your-main.html Since it's a secure habit to place all of your code outside of the visible directory (outside of the www or public_html folder), I've created a class that index.php directs all of the information to and that class is the one that actually processes everything. Breakdown of the Main class All files included in the beginning All required classes instantiated In the __construct(), the redirect is called to push all domains to a specific domain name Due to the amount of times certain hacks are attempted on the server, I've decided to place some of the common ones in the preventHack() method and prevent them before any other code is called. The available pages that the website contains are populated into an array Headers are processed. i.e. Logs the user in if $_COOKIE's are set Previous page is record...

PHP: Using index.php as your main controller

For a normal sized website you can use one page as your point of entry and retrieval of all of your pages. In the following example, I've created a class called IndexController that tests whether we're on a test server or not (to display errors or not) and then calls the class that will process the ?page $_GET variable.

PHP Pagination

The Pagination class is one that always gives me trouble when using someone else's code. I've created this class and hopefully have documented it enough for you to jump right into it. All you'll need to do is add the following code to the class that you're using: Instantiate the Pagination class Add the $per_page variable and set it to how-many you want to display per pag. i.e. $per_pag = 20; Call the getStartAt() method to create the int from where the sql query will begin. This is the query that calls your items to be displayed to the page and really has nothing more to do with the rest of the pagination: $start_at = $this->_pagination_obj->getStartAt($per_page); $sql = "SELECT vehicle, image FROM customer_rides WHERE approved = '1'"; $sql .= " AND brand = 'XX'"; $sql .= " LIMIT $start_at, $per_page"; At the end of the code, you'll need to call the createPageNumbers() method and pass the sql code...

JavaScript Redirect

When I need to redirect the user after the headers have been sent in PHP, I use JavaScript. I have a frequent code class that stores methods like this. The following method, redirect(), contains 3 parameters: $time Time to stay on current page before redirecting.  i.e. if you want to display a message and redirect in 5 seconds $location The page where you're going to be redirecting the user to i.e. index.php $folder_one_up In case you want to use this from a folder within the directory i.e. somewebsite.com/admin/ Note. You can create an additional parameter, such as $level to indicate how many folders deep your script is i.e. somewebsite.com/admin/manager/

Beginner Java Exercise: Check Palindrome

A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. Allowances may be made for adjustments to capital letters, punctuation, and word dividers. In this simple exercise, we're going to be checking for palindromes. Examples of palindromes: noon moon noom 14455441 The program prompts the user to enter a sentence or a word. It then calls the isPalindrome() method to check whether the word is actually a palindrome. It sets two variables, low and high to 0 and the length of the string - 1 respectively (remember that the string starts at 0; that's why you need the -1). It compares the two characters at low and high locations. If at any point through the iteration the characters at the low and high locations do not equal each other the isPalindrome() method will return false.

Fear

The definition of fear is as follows: "an unpleasant emotion caused by the belief that someone or something is dangerous, likely to cause pain, or a threat." It's definitely a strange feeling to know that something doesn't exist yet your FEAR takes over. I'm here to break it down into chemical terms on what exactly occurs when you watch that scary movie and are afraid to take a shower afterwards. I'll also explain the different types of fear. "In humans and animals, fear is modulated by the process of cognition and learning. Thus fear is judged as rational or appropriate and irrational or inappropriate. An irrational fear is called a phobia. Fear is closely related to, but should be distinguished from, the emotion "anxiety", which occurs as the result of threats that are perceived to be uncontrollable or unavoidable. The fear response serves survival by generating appropriate behavioral responses, so it has been preserved throughout evolut...

A Simple PHP Class

Not all PHP classes have to be complex. Below is an example of a simple PHP class depicting the About Us page. I'm not going to list the other parts that are needed to make the class work, just the class itself to demonstrate that with enough planning certain classes can look exactly the same way. Looking at the code, you'll notice that the displayBreadcrumb() method can be separated into it's own individual class as well (or frequently used code class) and an array of crumbs can be passed as the parameter with the key set to the name of the page and the value as the link to that page.

The return of Confederacy in Modern Times

It seems like most wars end the same way: as a cease-fire, but the hatred continues. Recently there has been quite a significant amount news-coverage on bringing down the Confederate flags and eradicating the nation of any symbols related to the Confederacy; I couldn't agree more. Most people need a refresher on the Civil War that occurred here. "The American Civil War, known in the United States as simply the Civil War as well as by other sectional names, was a civil war fought from 1861 to 1865 to determine the survival of the Union or independence for the Confederacy. Of the 34 states that existed in January 1861, seven Southern slave states individually declared their secession from the United States and went on to form the Confederate States of America. The Confederacy, often simply called the South, grew to include eleven states, although they claimed thirteen states and additional western territories. The Confederacy was never recognized diplomatically by a foreign ...

Blood Oxygenation Process

One of my favorite topics when I was studying pre-med was the oxygenation process. The purpose of this article is to see if I still remember it. The picture will be added after I finish writing it. De-oxygenated blood would come in from the body to the Superior and Inferior Vena Cavas. It would enter the right atrium, flow through the tricuspid valve into the right ventricle, up through the pulminary valve into the and into the pulminary arteries going to the lungs. Once oxygenated, it would flow back through the pulminary veins and into the left atrium, through the mitral valve, into the left ventricle, up through the aortic valve, into the aorta and to the body where it oxygenates the cells.

PHP User Authorization

In the previous post regarding Authorization, I wrote about the portion that deals with returning users. To reference that post visit: http://dinocajic.blogspot.com/2015/07/php-user-authorization-returning-users.html This one completes it. Start with main() It double checks to make sure that the username $_SESSION is not set. If so, it redirects the user to the main page. By redirecting, the script that was written in the previous post is called to log the user in.. It checks for form submission. If not, call form() method Checks form fields and sanitizes the content If there were errors, display form() method with errors If everything is good, log the user in through the logUserIn() method If not successful, display error message and call the form() method If it made it to this point, the cookie and session are set User is redirected to the main page

Beginner Java Exercise: Accessing Private Data Fields

To prevent tampering, sometimes it's necessary for data fields to be declared as private in a class. If you attempt to access a private data field from a client, a compile error will occur. In the following example, we have a two classes: CircleWithPrivateDataFields.java and TestCircleWithPrivateDataFields.java. In CircleWithPrivateDataFields.java, the radius and numberOfObjects are private data fields. To access them you do so with a get method (getter or accessor). You'll just append get to the property name and finish it off with () to create a method: i.e. getNumberOfObject(). If the data field is a boolean type, you'll need to use "is" instead of "get." To modify the private data field, you'll need a set method. Same concept as above except you replace get with set: i.e. setRadius(). In the following example we also use the keyword "static." All that means is that the value is accessible without instantiating the class, is not ...

LHC Discoveries

While most websites are reporting on the latest celebrities news, I was pleased to see that a few news agencies were reporting on the newest LHC discovery. The LHC has just discovered the pentaquark particle, a particle whose existence was theorized 50 years ago. "A quark (/ˈkwɔrk/ or /ˈkwɑrk/) is an elementary particle and a fundamental constituent of matter. Quarks combine to form composite particles called hadrons, the most stable of which are protons and neutrons, the components of atomic nuclei. Due to a phenomenon known as color confinement, quarks are never directly observed or found in isolation; they can be found only within hadrons, such as baryons (of which protons and neutrons are examples), and mesons. For this reason, much of what is known about quarks has been drawn from observations of the hadrons themselves." "A pentaquark is a subatomic particle consisting of four quarks and one antiquark bound together. As quarks have a baryon numbe...