Skip to main content

Posts

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.