If You’ve Ever Wanted to Learn Regular Expressions…

regex

Code School has a new class for that! I’d like to say at this point that I don’t now, nor have I ever, had any financial ties to Code School. I say that because I know I’ve done a fair amount of free advertising here for them. It’s only because their online classes are the best I’ve seen yet.

Regular Expressions, a.k.a. “regex”, is one of those subjects about which every developer should have at least a rudimentary understanding. There are plenty of books (such as Mastering Regular Expressions from O’Reilly) and websites (like RegExr) that teach the concepts and how to build them.

However, for someone that has never used them before, Code School’s Breaking the Ice With Regular Expressions is a great introduction that can be completed in a matter of hours.

LEGO Mindstorms EV3 Robot Hangs During Firmware Upgrade

LEGO Mindstorms EV3 robot starting screen

One of my kids is taking a robotics class and wants to join a First LEGO League team this year, so I just bought LEGO‘s newest Mindstorms robot, the EV3.

Just like many other computerized devices, such as desktop PCs to iPhones, the EV3 can easily be “bricked” if a firmware upgrade does not work properly or is interrupted before it is completed.

Fortunately, all is not lost. Though I found conflicting instructions on how to handle this situation on various fora and FAQ pages, I found that the steps below worked very well.

In all likelihood, if your EV3 is bricked during a firmware upgrade, you’ll see the “Starting…” screen that should only appear briefly when booting.

LEGO Mindstorms EV3 robot starting screen
EV3 starting screen

If the EV3 is stuck on this screen for more than 30 seconds or so, you should try the following steps.

  1. Remove a battery to turn off the device.
  2. Replace the battery. Your screen should remain blank. If not, pull all the batteries and wait 30 seconds before replacing them.
  3. Press the center and right buttons simultaneously, which should turn the EV3 on in update mode.
  4. Attempt the firmware update again, using the software installed on your PC or Mac.
The center and right buttons on the EV3 are circled.
EV3 showing center and right buttons

This worked for me, and I hope it works for you as well!

Searching for Text in the Create Statements of Views and Stored Procedures in SQL Server

SQL Server logo

This is closely related to my last post, where we were searching for text in the data itself, but now we’re just looking to see if the text exists in the statements that create views or stored procedures. This has been tested only on SQL Server 2008 R2. If you do not have permission on the database to see the definitions of views or stored procedures, then you will get zero rows returned. Otherwise, the names of the views and stored procs containing the text in @TestValue will be listed here, along with their respective CREATE statements. This script should run much faster than the one in the above-referenced post since no cursors are being used here.

-- Set database to search
USE dbname
GO
SET NOCOUNT ON
SET ANSI_WARNINGS OFF
------------------------------------------------------------------------------------------------------------------------------------
-- Set test value here
-- no other code below changes 

DECLARE @TestValue VARCHAR(MAX) 

-- If characters in @TestValue need to be escaped, use backslash
SET @TestValue = 'text to search for'
------------------------------------------------------------------------------------------------------------------------------------

SELECT DISTINCT
    o.name AS [Object_Name],
    o.type_desc,
	m.[definition]
FROM sys.sql_modules m
    INNER JOIN
    sys.objects o
        ON m.object_id = o.object_id
WHERE m.definition LIKE '%' + @TestValue + '%' ESCAPE '\';