How to do a Search and Replace String or str_replace() in MySQL

We were recently tasked with updating the name of a company on various pages of a large content managed website. This task could’ve taken quite some time and I found myself thinking how easy it would be if the site were static and I could do a simple find and replace or search and replace.

I started doing this by hand… until my brain engaged and I realized how easy it would be to do with a simple MySQL query. Using MySQL’s built in replace function I wrote the following query to do a string replace operation that replaces old_string with new_string for all occurrences within a particular column.

UPDATE table_name SET column_name = replace(column_name, 'old_string', 'new_string');

This was a quick and painless way to update a large data set.

Book Notes: Why Grace Changes Everything by Chuck Smith

Without it grace our lives are dry and dusty. But when grace comes, it transforms our lives into something rich and beautiful. Pastor Chuck Smith explains the mystery of grace and reveals the surprising truth: We can never grow in grace by our own efforts. True grace flows from the heart of the Father through the love of Jesus Christ. To know that God is for you, that He loves you, is the greatest source of security you will ever know. That is grace-and that is what makes life worth living.

But later I discovered that the ultimate witness we can offer the world is the love we have for one another, a love that flows from the very heart of God Himself. Conforming to rules and regulations simply can’t produce that kind of love relationship. We can try to impose the law on our relationships, but God’s love is the only way to gain the stability and security we long for. The Bible tells us that love is the fulfillment of the law. In fact, when asked which was the greatest commandment, Jesus replied that it was to love the Lord with all our heart, mind, soul, and strength, and to love our neighbor as ourselves. Love — not the law — is the key to our relationship with God and with one another. (Page 12)

He revealed to me the meaning of the simple, well-worn but rarely understood word: grace. From that time onward I encountered such a free and loving relationship with God that I could not have cared less if I ever saw a spectacular miracle in my ministry. (Page 14)

In fact, the more we experience God’s love the more He Himself becomes the primary desire and focus of our entire life. The coercive aspects of the law become unnecessary. We find ourselves longing to please God simply because we love Him. (Page 14)

Whenever we try to establish our righteousness by keeping rules, eventually we are forced to admit we operate on a sliding scale. I will ask look morally better to myself than I do to you, and you will always look morally worse to me than you do to yourself. I can look at your life and see all kinds of flaws; but when I look at myself, the few flaws I notice don’t seem so bad. (Page 18)

The root meaning of the word grace is “beauty.” In the New Testament, grace means “God’s unmerited favor.” Grace is God giving to me something that I cannot obtain on my own. Grace is being accepted by God even though I do not deserve it, even though I am not worth of it. (Page 22)

God is a specialist at taking the unlikeliest of candidates and turning them into trophies of His grace. (Page 40)

In other words, true faith is more than a verbalization. True faith leads to appropriate actions. If I truly believe a certain thing, then my actions will be in keeping with what I believe. I may vehemently protest a belief in something, but if my actions are inconsistent with my professed believe, then my belief must be called into question. (Page 59)

Our actions must be in harmony with what we believe or our belief can be called into question. (Page 60)

There are many who claim to have a relationship with God, who throw around all the right Christian buzzwords and catchphrases, but who simply aren’t walking with God in any practical way. It is crucial that we learn to “walk our talk.” Our lives must be consistent with the calling, the blessings, and the profession we make concerning our new relationship with God. (Page 68)

It is when we admit our utter powerlessness, however, that we find hope. We finally turn to the grace of God the Lord intervenes and begins to do a work that we could not do for ourselves. It is not until we find ourselves driven by desperation to a cry for helplessness and hopelessness that we begin to enjoy real victory in Christ. (Page 103)

A love relationship with God is vastly different from that. NO longer do I debate whether something is right or wrong. Rather, I find myself asking, “Is this pleasing to my Father?” I love Him and want to please Him. He loves me so much that I don’t want to hurt Him. Sometimes even where the law is silent, my heart tells me God would be grieved if I carried out an activity I’m considering. (Page 127)

I am a Dad! My son Colton Stemkoski was born 1-9-14.

My wife and I are excited to announce that our son Colton William Stemkoski was born at Deaconess Medical Center in Spokane WA on January 9th 2014. He weighted 8.0 lbs and was 20.5 inches long. We are really excited to welcome him and can’t wait to watch him grow. As an amateur photographer I have already taken loads of pictures of him, here are a few for you to enjoy and I am sure there will be many more to come.

How to Select Row From a Table Where a Particular Field Starts With a Specific Letter or Number

I have seen countless instances around the web where people are using the letters of the alphabet to sort a large recordset, in fact, I have even done it before but it has been ages since that project and I had forgotten exactly how I accomplished it.

Today I working on a project where I need to sort through a large number of manufactures for a particular customer. They wanted them sortable by clicking on a the first letter of the manufacturers name.

For the English alphabet, my solution was quite simple. By using the MySQL LIKE statement and filtering out everything after 1 letter I was able to quickly and efficiently find matches for a particular letter. The example below shows a sample query assuming we are sorting by the letter A.

SELECT * FROM table_name WHERE column_name LIKE 'a%'

I also found this solution works well for numbers and other symbols. Unfortunately, in my case the client wanted all items that start with any number grouped into a single result set because there was a small number of those items. Essentially, we I needed to do a MySQL select statement that captured all items that started with any number and return those manufacturers. After doing some noodling I came up with a solution that works quite well:

SELECT * FROM table_name WHERE column_name RLIKE '^[0-9]+'

This regular expression will capture any number 0-9 and include it in the result set. This strategy could amended with different regular expression to fine tune the data selected.

How to Programmatically Trigger a Click with Plain/Standard Javascript

I was working on an older website today and ran into a problem I hadn’t faced before. I needed to modify a complex Javascript based slideshow, that was written several years ago so that it would automatically rotate between slides without user interaction. This slideshow works well but has no methods I can use to configure its functionality. I looked through the code and it was not structured in a way that I could easily modify its functionality without a substantial amount of code and testing. I decided the easiest solution would be to set a timeout that would trigger a programatic click of the next button allowing the slideshow to operate unmodified.

Until today, I had never had to trigger a click with standard Javascript. I have done it a few times using the jQuery trigger() method but jQuery was not included on this older website.

Example of triggering a click using the jQuery trigger method:


I did some experimentation and discovered that this can be achieved using plain Javascript quite easily. The following code triggers a click on an element with the id of test by calling the onClick() method programmatically:


This simple bit of code will get the element with the id of test and then will simulate a click on that element. Enjoy!

Fixed: Google Drive Silently Crashing on Mac OSX Mavericks / OSX Mountain Lion

google_drive_logo_3963At our office we love Google Drive. We use it to store just about everything. Since migrating to Google Drive we have been incredibly happy with the service. Our users can now access important information from any computer and they are not confined to our office location or VPN. That said, we have had one major problem we had a great deal of difficulty resolving. For some reason, several of our users have had problems with Google Drive silently crashing on a very regularly, almost hourly basis. Other users have had no problems at all. For many, this issue has been maddening, and after hours of research we were unable to find a solution online for our problem so we have been living with it for quite some time. We have even gone as far as considering moving to Dropbox or another solution to solve this problem.

It turns out, the real problem was we were struggling to see the pattern. As we figured out the pattern the problem was easy to solve:

Our revelation came when we realized that for some uses Google Drive was installed under the computers administrative account and for other users it was installed as an administrator under their account. This happened based on the era in which the computer was setup and dependent on which administrator configured the computer. It appears that while Google Drive will function to a limited degree if the software is added under the administrator account something within the operating system causes Google Drive to crash regularly. We discovered that if we were to uninstall Google Drive and then reinstall it when signed in under the account for the Google Drive user, Google Drive ran smoothly without crashing. Victory! Now back to work.

Connecting: A Documentary About User Experience Design

If you are involved in web design, mobile app design, or software design in any capacity this is a must watch documentary.


The 18 minute “Connecting” documentary is an exploration of the future of Interaction Design and User Experience from some of the industry’s thought leaders. As the role of software is catapulting forward, Interaction Design is seen to be not only increasing in importance dramatically, but also expected to play a leading role in shaping the coming “Internet of things.” Ultimately, when the digital and physical worlds become one, humans along with technology are potentially on the path to becoming a “super organism” capable of influencing and enabling a broad spectrum of new behaviors in the world.

A Quick Visit to Las Vegas

New York New York Hotel

Kayla and I decided to take a quick trip to Las Vegas right after Christmas. Check out some of our photos.

Life Center Marriage Retreat 2012


Every year since Kayla and I got married we have attended the Life Center Married Couples Retreat. The Life Center Married Couples retreat is a weekend long event put on by Life Center church in Spokane. This year, we traveled to Whitefish Montana and stayed at the beautiful Lodge at White Fish Lake. We had a great time, learned a lot, and got some good weather that allowed us to do some exploring. Here are some photos I took while on the adventure:

Whale Watching

Island Adventures Whale Watching

Kayla and I were recently staying in the Mukilteo area for her friend Ashley’s wedding. The bridal shower was on Friday afternoon and the wedding was on Saturday. Since we had to spend a couple nights in the area, I decided to surprise Kayla and make a weekend vacation out of our trip. A couple summers ago on our cruise to Alaska we got to go on whale watching tour and Kayla loved it. I knew she would be excited to go again so I booked a tour with Island Adventures out of Anacortes WA. We were lucky enough to have some good weather and an excellent time. Check out the photos below: