HTML

The (almost) Perfect Phone Regex

Posted on

While working on an inline form validation feature for A6X, I needed to be able to validate phone numbers. The phone regex with the plugin I was using was crappy and didn’t allow you to enter things such as an extension, or use (###) for the area code. Every validation plugin I used had, in my opinion, bad regex, which only took into account a small fraction of ways to type a phone number.

I wanted to be able to do things like:

  • Use (###) format for the area code
  • Add a +1 for a country code
  • Use . instead of –
  • Add an extension, etc

Yet for some reason, literally no regex that I found would allow for this in its entirety. So, obviously, I handcrafted my own.

This allows you to enter phone numbers in many different formats:

  • +1 is entirely optional, but still allowable
  • You can enter the area code with or without surrounding parentheses (###)
  • Numbers can be spaced with spaces, a . or a – (or nothing) – such as 123-4567, 123.4567, 123 4567
  • You can optionally enter an extension
    • Allowable formats: “ex”, “ext”, “extension” followed by a space, a . or a – (or nothing) and then some numbers

The only reason I say it’s “almost” perfect is because while loosely designed around US numbers, it may/may not validate for other countries. Any country with seven digit numbers should theoretically validate. And of course, there’s probably the case where someone wants to enter a weird character like a tilde (~) or something, which isn’t supported.

Regardless, though, I think this is the most effective regex for a phone number I’ve seen on the internet.

Food

Spaghetti and Homemade Meatballs

Posted on

The other day, I remembered that I’ve had some ground chuck sitting in my freezer for probably at least a month. I wanted to make a fairly fast, delicious meal. At first I thought about burgers, but I didn’t have any buns (or real bread, for that matter). I have about six pounds of spaghetti, bought from Sam’s Club, so I settled on Spaghetti and meatballs.

Protip: If meat is properly packaged, it can be frozen anywhere from six months to one year and still be considered edible. Just be careful of odd tastes from freezer burn after a certain point.

I have to warn you that the pictures below are likely going to be crappy – they were taken from my iPhone 3GS and I apparently don’t have very steady hands.

The original recipe for the meatballs comes from allrecipes.com and has been modified slightly to fit my needs.

The Meatballs

Start the meatballs first because while they are in the oven, you can cook the spaghetti and then everything comes out at the same time.

Ingredients

20 ounces (1.25 lbs) ground beef / chuck / turkey*
1 egg, beaten
1/3 cup italian bread crumbs
Olive oil or PAM

Optional:
Salt / Pepper
Italian Seasoning
Oregano
Basil

* You can use your choice of meat. Turkey tastes great and tends to have very little fat. Using 99% fat-free meat will not work well with this recipe.

Preparation

  1. Preheat oven to around 350 degrees
  2. Wash your hands
  3. In a bowl, hand mix the meat, bread crumbs, beaten egg and any optional ingredients you decided to use.
    1. If you don’t have bread crumbs, you can substitute it for thoroughly crushed croutons. Remember, it should look like crumbs.
    2. Protip: Clip your nails before shoving your hands in the meaty goodness
  4. Get out a pan and either:
    1. Spray it with PAM, or
    2. Pour some olive oil on it and ensure that it’s fully covered
  5. Once everything seems evenly mixed, roll into balls and place onto the pan. You can use an ice cream scooper or large spoon if you want.
  6. Bake the meatballs for 15 minutes.
  7. Carefully (don’t burn yourself) flip the meatballs over and bake for another five minutes.
  8. Turn off oven and remove meatballs.
  9. Transfer the meatballs to a different container if you want

The Spaghetti

Remember to cook the spaghetti while the meatballs are in the oven. If you time it right, they will be done at the same time, and everything will be nice and hot!

Ingredients

Pasta (I used angel hair)

Preparation

  1. Fill a pot with water and bring to a boil.
    1. Protip: Leave at least 1 1/2 – 2″ of space at the top so that your boiling water wont overflow when the pasta is inserted. Always account for added volume.
  2. Once the water is boiling (and don’t cheat – it should be fully boiling), add the pasta.
  3. Stir occasionally to keep the pasta from clumping or attaching to the pot.
  4. The pasta packaging will tell you how long to cook the pasta for, but you can usually get by with 8-10 minutes. If you’re unsure, just do a taste test with a noodle to see.
  5. Once the pasta is ready, shut off the burner and drain the pasta. Be careful of the scalding water.

The Sauce

Hey – I’m in college, I’m not some master Italian chef. If you want to roll your own sauce, feel free, but I just turned towards a jar.

Ingredients

Pasta Sauce

Preparation

  1. Pour some sauce into a pot and heat it on low-medium until it’s bubbling a little.
  2. Make sure to stir it occasionally

You can even add your completed meatballs to the sauce for a couple minutes! Yum!

The Final Product

Miscellaneous

Hi there.

Posted on

For a while now, I’ve been wanting to set up a website for myself. Every time I create an account somewhere, there’s an input where I can enter a link to my website, and every time, I leave this field blank. Why? Because I’ve never taken the time to set up a website for myself. This is going to change starting now.

If you click on the picture (or if you have good eyes), you can see that I’ve had this domain since July 3rd, 2007. Over four years, and I still have never gotten this site up and running. I’ve done several concepts, and had even coded a few custom blog/CMS systems for personal use, but never did anything with them. Perhaps I’ll look for all of my old site mockups and post them at some point.

For now, though, I’ll just inform you about the types of posts I’ll likely create on this website. I’ll post about my endeavors with my web server, which includes posts on installing debian, nginx, mysql, php and others, as well as endeavors with web design and development.  As a college student, I try to find new ways to make food less, well, boring. I’m tired of eating Ramen at least once a day, and I like to try to concoct recipes – I’ll probably post those. I also like to post about the things that happen to me – be it related to school, something personal, etc.

I haven’t created my custom template for wordpress yet, but since I’m starting to post, I’ll likely be motivated to create one. I hope.

That’s about it for now, I think. Thanks for reading!