Archive for July, 2009

How to select the First row from a MySQL table

You can use the following command to get the first row from a MySQL table:

SELECT * FROM table LIMIT 1

Explanation:

table - table name

By limiting the returns to 1 (LIMIT 1) we get the first row from the table.

Example:

SELECT * FROM tusers LIMIT 1

  • email
  • Add to favorites
  • Facebook
  • Twitter
  • MySpace
  • del.icio.us
  • LinkedIn
  • Digg
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • IndianPad

2 Comments

How to select the Last row from a MySQL table

You can use the following command to get the last row from a MySQL table:

SELECT * FROM table ORDER BY field DESC LIMIT 1

Explanation:

table - table name

field - table field

This command orders the table by DESCENDING order and limits the number of rows returned to 1. Since DESCENDING reverses the normal table order, we get its last row.

Example:

SELECT * FROM tusers ORDER BY user_id DESC LIMIT 1

  • email
  • Add to favorites
  • Facebook
  • Twitter
  • MySpace
  • del.icio.us
  • LinkedIn
  • Digg
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • IndianPad

No Comments

Select random rows from a MySQL table

If you ever come across the need of randomly select rows from a MySQL table:

SELECT * FROM table WHERE field1 = value ORDER BY RAND() LIMIT x

Explanation:

table - table name

field1 - table field

value - value you want field1 to be

x – number of rows to return

Example:

SELECT * FROM tusers WHERE active_user = ‘Yes‘ ORDER BY RAND() LIMIT 10

This command returns 10 random rows of active users from table tusers.

  • email
  • Add to favorites
  • Facebook
  • Twitter
  • MySpace
  • del.icio.us
  • LinkedIn
  • Digg
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • IndianPad

No Comments

The 12 Principles Of Successful Freelancing

This was taken from the book “The Principles Of Successful Freelancing” authored by Miles Burke (which I highly recommend) and should be used as guide lines to your sucessful freelancing career:

  1. Get Organized – Keep your workspace tidy and plan ahead (short- and long-term).
  2. Control Stress – Remain calm and work through issues to avoid early burnout..
  3. Research – Spend quality time researching your proposed business-it’s more than a five minute web surf.
  4. Be Passionate – Love your work! You should enjoy what you do for a living.
  5. Budget – Save for a rainy day rather than spend every cent as it comes in.
  6. Value your Health – Bad health stops you from working. Take time to exercise and maintain a nutritious diet.
  7. Embrace Selling – Enjoy the sales challenge-it’s easier than you think!
  8. Satisfy Customers – Don’t do average work-exceed their expectations and make them need you.
  9. Grow Your Network – Value family and friends’ support, and meet new people all the time.
  10. Maintain Cashflow – It’s what is in the bank that counts, not what you are billing-understand the difference.
  11. Continually Learn – Keep acquiring new skills and knowledge, every week. Let it slip and you could be left behind.
  12. Achieve a Work/Life Balance – Your life should be more than work-maintain a good balance for health and success.
  • email
  • Add to favorites
  • Facebook
  • Twitter
  • MySpace
  • del.icio.us
  • LinkedIn
  • Digg
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • IndianPad

No Comments

How to check if an LPAR is part of a SYSPLEX?

If you need to check if an LPAR is part of a SYSPLEX or the SYSPLEX name it belongs to simply issue the command: D XCF

Example:

D XCF

Returns:

RESPONSE=TST1
IXC334I  09.32.10  DISPLAY XCF 309
SYSPLEX TESTPLEX:   TST1 TST2 TST3

Notes:

  1. the command was issued from LPAR TST1
  2. in red we can see the SYSPLEX name (TESTPLEX)
  3. in blue we can see that 3 LPARs (TST1, TST2 and TST3) are part of the SYSPLEX TESTPLEX
  • email
  • Add to favorites
  • Facebook
  • Twitter
  • MySpace
  • del.icio.us
  • LinkedIn
  • Digg
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • IndianPad

No Comments

How to know which IODF file is currently being used?

If for whatever reason you need to know which IODF file is currently being used by the system, just issue the command: D IOS,CONFIG

Example:

D IOS,CONFIG

Returns:

RESPONSE=TST1
IOS506I 10.18.20 I/O CONFIG DATA 118
ACTIVE IODF DATA SET = SYS1.IODF19
CONFIGURATION ID = TEST01         EDT ID = 00
TOKEN:  PROCESSOR DATE     TIME     DESCRIPTION
SOURCE: CMOS03   08-02-19 14:05:33 SYS1     IODF19
ACTIVE CSS:  0    SUBCHANNEL SETS CONFIGURED: 0
CHANNEL MEASUREMENT BLOCK FACILITY IS ACTIVE

As you can see LPAR TST1 is currently using IODF file SYS1.IODF19

  • email
  • Add to favorites
  • Facebook
  • Twitter
  • MySpace
  • del.icio.us
  • LinkedIn
  • Digg
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • IndianPad

No Comments

Pro PHP Security – Review

Author: Chris Snyder

Author: Chris Snyder

PHP being such a popular and versatile scripting language it’s natural that security is not to be taken lightly.

There are thousands of web sites in the internet dedicated to this subject as well as dozens of books. Finding the right one… now that’s a challenge!

Pro PHP Security” is probably one of the best. I warn you however, that sometimes it can be a tiresome book if you intend to read it from page 1 to the last one.

I say this because it details encryption methods, secure network connections and the likes that for a PHP developer it can be boring.

Lets face it, there are already encryption functions available and the need to know exactly and in detail how each encryption method works can be questionable.

However, no one forces you to read the entire book. You can skip the not so interesting parts and go directly to the good stuff.

The last two parts of this book (part 3 – Practicing Secure PHP Programming and part 4 – Practicing Secure Operations) are the crown jewels of this book, with lots of tips and PHP examples.

This book has the following Parts and Chapters:

  1. PART 1 – The Importance of Security
    • Chapter 1 – Why Is Secure Programming a Concern?
  2. PART 2 – Maintaining a Secure Environment
    • Chapter 2 – Dealing with Shared Hosts
    • Chapter 3 – Maintaining Separate Development and Production Environments
    • Chapter 4 – Keeping Software Up to Date
    • Chapter 5 – Using Encryption I: Theory
    • Chapter 6 – Using Encryption II: Practice
    • Chapter 7 – Securing Network Connections I: SSL
    • Chapter 8 – Securing Network Connections II: SSH
    • Chapter 9 – Controlling Access I: Authentication
    • Chapter 10 – Controlling Access II: Permissions and Restrictions
  3. PART 3 – Practicing Secure PHP Programming
    • Chapter 11 – Validating User Input
    • Chapter 12 – Preventing SQL Injection
    • Chapter 13 – Preventing Cross-Site Scripting
    • Chapter 14 – Preventing Remote Execution
    • Chapter 15 – Enforcing Security for Temporary Files
    • Chapter 16 – Preventing Session Hijacking
  4. PART 4 – Practicing Secure Operations
    • Chapter 17 – Allowing Only Human Users
    • Chapter 18 – Verifying Your Users’ Identities
    • Chapter 19 – Using Roles to Authorize Actions
    • Chapter 20 – Adding Accountability to Track Your Users
    • Chapter 21 – Preventing Data Loss
    • Chapter 22 – Safely Executing System Commands
    • Chapter 23 – Handling Remote Procedure Calls Safely
    • Chapter 24 – Taking Advantage of Peer Review

Pro PHP Security” should be one of the books in your bookshelf if you want to develop Secure PHP scripts.


  • email
  • Add to favorites
  • Facebook
  • Twitter
  • MySpace
  • del.icio.us
  • LinkedIn
  • Digg
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • IndianPad

No Comments

The Principles Of Successful Freelancing – Review

Author: Miles Burke

Author: Miles Burke

When I first saw this book I must confess it got me curious. I read some reviews (which were good) and I decided to give it a shot and buy it.

When I got the book (yes, because I buy most of my books online) I gave it a cursory glance  and decided to drop the book I had been reading to start this one.

I don’t have much free time to read a book in one day or just a few hours but this one was quick. It took me three days and I must tell you, what a great book!

It gives you a realistic approach on how to become a freelancer, what to consider, what to avoid, and what you should do to succeed as a freelancer.

The book presents you with advantages and disadvantages of freelancing which are of great value.

This book is of easy reading and it’s less then 200 pages which is great!

This book has the following chapters:

  1. Considering Freelancing?
  2. Prepare for the Transition
  3. Manage Your Money
  4. Set Yourself Up
  5. Win the Work
  6. Give Great Service
  7. Achieve Work-Life Balance
  8. Where to from Here?

I strongly recommend “The Principles Of Successful Freelancing” if you’re considering becoming a freelancer or if you’re already one and would like to check if you’re doing it right. :-)


  • email
  • Add to favorites
  • Facebook
  • Twitter
  • MySpace
  • del.icio.us
  • LinkedIn
  • Digg
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • IndianPad

No Comments

How to dynamically add or remove libraries from APF list

Countless times I’ve been asked if I remember the command to dynamically change the APF list.

Well, I’ve decided to include it here so that next time someone asks me I can tell them to come here. :-)

Now, this can be done in many different ways but I normally follow this path:

1. Add/Remove just a few libraries to APF list

If the number of libraries we’re talking is not much, then we can do it by issuing the following commands for each of the libraries (datasets):

To add:  SETPROG APF,ADD,DSNAME=dataset_name,VOLUME=volser

To remove:  SETPROG APF,DELETE,DSNAME=dataset_name,VOLUME=volser

Notes:

  1. If the datasets are in an SMS managed volumes then instead of VOLUME=volser it should be SMS.
  2. If the system is IPLed and you did not reflect the changes to your PROGxx member in PARMLIB then these changes will be lost.

2. Add/Remove lots of  libraries from APF list

If we’re talking of a considerable number of libraries then the best way is to update the PROGxx member of PARMLIB and then activate it dynamically.

Let’s assume:

PARMLIB: SYS1.PARMLIB

PROGxx: PROG00

In this case we would do the following:

  1. Update SYS1.PARMLIB(PROG00) and add/remove the libraries from APF list
  2. Issue command: SET PROG=00
  • email
  • Add to favorites
  • Facebook
  • Twitter
  • MySpace
  • del.icio.us
  • LinkedIn
  • Digg
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • IndianPad

No Comments

How to validate an email address format

There are several ways of validating an email address format.

Normally, I do it the following way:

1. I first define the regular expression for the email format:

define (“FORMAT”,”^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$”);

2. To validate the email address provided is correct:

if ( !eregi (FORMAT, $email)) echo “The email provided has an invalid format”;


Regular expressions can be a pain to understand and if it’s hard for you then I would recommend you read “Sams Teach Yourself Regular Expressions in 10 Minutes” from Ben Forta.

If however you are simply interested in some practical examples that you could use then I recommend “Regular Expressions Cookbook” from Jan Goyvaerts and Steven Levithan.


  • email
  • Add to favorites
  • Facebook
  • Twitter
  • MySpace
  • del.icio.us
  • LinkedIn
  • Digg
  • StumbleUpon
  • Google Bookmarks
  • Yahoo! Buzz
  • IndianPad

No Comments