I love making my own tools for the simple and mundane tasks I face during the day. One of those tasks is the repeated need for testing regular expressions that I am faced with when programming. Yes, there are a multitude of regular expression testers on the web today, and all of them have a laundry list of cool things they do. But none of them are mine, and none of them are necessarily simple. And few of them let you see how they work. So with that, I decided to take one of the many tools I’ve built for myself and offer it here for you.
My (very) simple regular expression is just that… a simple tester that takes a regular expression and a subject string and gives you back your matches as PHP would see them in your application. There is one small bit of robustness (I had to use robustness… the word is just so cool) added to this tester that will allow you to group your matches together (
PREG_SET_ORDER) and allow you to include the string position of the match in the subject (
PREG_OFFSET_CAPTURE). But that is where the robustness ends the simple kicks in again.
So if you want a simple little regular expression tester, or just want to see how I’ve coded mine, feel free to use my tester for your own needs. Have fun, stay curious and GO BIG.
A little while ago I was in need of a way to take tab separated data sets and make HTML tables out of them cleanly. Mostly this was from data copied from a spreadsheet, but sometimes copying from web pages or even text documents has brought this need up for me. So in keeping with my mantra of “Why not write a program to do that?” I decided to write a simple HTML table maker that will take in tab separated, structured data and return an HTML table from it, complete with column headings, a caption and a summary (sidenote: I know that table summaries are being deprecated… still, I included it because at the moment they are still in use for pre-HTML5 markup).
So without further ado, I bring you my simple HTML table maker. It isn’t the most robust thing in the world, but it is still pretty neat. Plus? It totally serves my purpose to the tee. So if you don’t like it, why not gank the code for it and make it better?
Some things come at you hard and fast, and hit you in the face like a rush of ice cold water on a hot summer day. Others wrap their arms around you and tell you it’s going to be ok while coaxing you into a peaceful calm. Still others reach into the very core of who you are and add value – strength, courage, determination, resolve – to an otherwise broken and fragile being. This poem, by Rudyard Kipling, is one of those that just encourages and strengthens me.
If you can keep your head when all about you
Are losing theirs and blaming it on you;
If you can trust yourself when all men doubt you,
But make allowance for their doubting too;
If you can wait and not be tired by waiting,
Or, being lied about, don’t deal in lies,
Or, being hated, don’t give way to hating,
And yet don’t look too good, nor talk too wise;
If you can dream – and not make dreams your master;
If you can think – and not make thoughts your aim;
If you can meet with triumph and disaster
And treat those two imposters just the same;
If you can bear to hear the truth you’ve spoken
Twisted by knaves to make a trap for fools,
Or watch the things you gave your life to broken,
And stoop and build ‘em up with wornout tools;
If you can make one heap of all your winnings
And risk it on one turn of pitch-and-toss,
And lose, and start again at your beginnings
And never breath a word about your loss;
If you can force your heart and nerve and sinew
To serve your turn long after they are gone,
And so hold on when there is nothing in you
Except the Will which says to them: “Hold on”;
If you can talk with crowds and keep your virtue,
Or walk with kings – nor lose the common touch;
If neither foes nor loving friends can hurt you;
If all men count with you, but none too much;
If you can fill the unforgiving minute
With sixty seconds’ worth of distance run –
Yours is the Earth and everything that’s in it,
And – which is more – you’ll be a Man my son!
If you are interested in learning more about this poem or would like to socialize and connect with folks who have delved deep into this piece, check out All Things If, a blog dedicated to this poem.
Someone on the Professional PHP Group asked the question yesterday about whether Dreamweaver has a utility to write setters and getters to your PHP classes for you. I know that ZendStudio has this feature and I am pretty sure that NetBeans has it as well.
But as I thought about this, I thought “How cool would it be to be able to take a list of PHP properties and build a class out of that list complete with your getters and setters?”. That’s when my inner nerd took over and I created a very simple PHP Class Generator.
It is not the most robust tool in the world, but if you are looking for a quick way to build out a class of getters and setters from a simple list of variables, this little tool might be right up your alley. I’d encourage you to play with it and see if it can help you. If it does, tell me about it in the comments.
Oh yeah, a major thank you goes out to Jason Memory of Full Throttle Web Solutions for his help and wizardry in all things regex.
This post is being written in response to the following email I received today:
I came to you site via a search for something about chronic fatigue.
Based on your posts it seems your wife was doing pretty poorly and
over time has greatly improved. I also have CFS and it is really bad
right now. I wondered if you’d be willing to share with me anything
your wife did to help her improve (medical treatments and self care,
lifestyle changes etc.) I am desperate and rarely see anything posted
online about people who’ve improved so I really would love to know
what you wife did, didn’t do etc. I really appreciate the help if
you’re able to share some info. Thanks soooo much.
There were a lot of changes made in her lifestyle, my lifestyle and our family dynamic that have contributed to her (continuing) recovery. It would be unfair to say that she has completely recovered from this dastardly illness, but she has made huge improvements and advancements when it comes to her health. Several things have contributed to her improvement, some of which are:
- She saw a doctor who prescribed different medications for different symptoms of her illness. Out of respect for her I won’t go into that publicly (feel free to email robert [at] robert-gonzalez [dot] com) but the medications she took helped her tremendously in the way of sleep, piece of mind and overall physical health.
- She became more physically active. I don’t know if this was a matter of willpower or a renewed sense of energy but activity actually helped her get more active which continued to help her improve.
- She took on a hobby. Last summer she got bitten by the theater bug and began to devote an extraordinary amount of time to it. The demands of performing and rehearsing required her to devote all of her resources to it and, without really being able to NOT commit (without letting down her theater family) she just continued to indulge in her passion. This alone, I think, has sparked a tremendous amount of recovery for her.
- She has taken on a new outlook on what is and isn’t important in life. That might sound almost lame to have to say that, but one of the things that seemed to cause her a lot of stress was worry over the things that were going on at home, with the kids, with our money and with our family. As she began to find peace in where we were, right where we were, the stress that she was feeling began to gradually minimize, freeing her to live without the burden of having to “perform” in order to maintain order in her life.
- She prayed. A lot. And so did her friends and family. If you are a religious/spiritual person then prayer will be invaluable to you. It was to her, and she would attest to that fact.
- Lastly, and probably most importantly, she had help. Lots and lot of help. From her family (the kids and I), her extended family (sister, parents, in-laws) and her friends. Many a night were we served by friends bringing meals over for us or family helping us clean our home or take the kids somewhere. I’m sure it wasn’t easy or convenient for them, but in the end they showed our entire family what true love was all about by really stepping up and helping us out in pretty much any way we needed it.
I’m sure there is plenty more that has help contribute to my wife’s recovery over the last few years. And while she has made tremendous strides in healing, she will admit that she still has bad days here and there. Still, she has plenty more good days than bad and she strives everyday to make each day count. She has become incredibly active in the kids’ lives, education and hobbies. She has taken a renewed interest in learning and teaching and she has developed a penchant for spirited fun and adventure. She has also gotten some semblance of control over her sleeping patterns, started to watch her diet and began talking a lot with her friends and family.
Essentially she has gotten to the point where she is able to live life again in a healthier way that allows her to continue to live each day as fully as she can. Again, she still has bad days, but at the end of the day, she is doing worlds better now than she was just two years ago.
Thank you for the email asking this question. If you have any other questions feel free to email me directly at my email address that I posted inside of this post. Thanks.