Skip to main content

Posts

Showing posts from 2013

Quickly cast array elements in PHP

It's not immediately obvious, but there is a concise way to cast all elements of an array to a single type.  It's all possible with the array_walk() function. array_walk($test, function(&$value, $key){$value = (integer) $value;}); Used in an example it would look like this. $sampleArray = array("one"=>"1", "two"=>"2", "three"=>3, "four"=>"4d"); var_dump($sampleArray); array_walk($sampleArray, function(&$value, $key){$value = (integer) $value;}); //--------------------------------^ Required! ^ //--------------------------------------------------------+ Type to cast to. var_dump($sampleArray); NOTE:  It's important to note that the ampersand is necessary.  See the note about references on the second argument of the array_walk() function documentation.

Consolidated query executions version 2

This is an extension of a piece from late last year titled, " Consolidated query executions ."  That version had a problem in that it didn't work as advertised with MySQL .  As a result it has been re-worked and listed here.  It's pending further testing, specifically against SQL Server , it's just listed now in the event that it may prove useful to someone. private function run($sql) { $Query = $this->Conn->prepare($sql); if((func_num_args() == 2) && is_array(func_get_arg(1))) { $Query->execute(func_get_arg(1)); } else { $Query->execute(array()); } $errorInfo = $Query->errorInfo(); if($errorInfo[1] != NULL) { return $errorInfo[2]; } $rowCount = $Query->rowCount(); $rowCountStatus = $Query->errorCode(); $fetch = $Query->fetchAll(\PDO::FETCH_ASSOC); $fetchStatus = $Query->errorCode(); if(($rowCountStatus == "00000") && ($fetchStatus == "00000")) { return $fetch; } els

Toggle Wi-Fi radio with keyboard combination

Make sure the Wi-Fi radio is turned on if wireless access to a network goes missing.  It's common practice for vendors to include function buttons to toggle or control hardware features of their computers.  Typically, these control things like screen brightness and volume level.  Other toggles however, might be to cycle through monitor set-ups and to turn Wi-Fi on and off.  It seems like a "no brainer" but it can be simple to overlook if this control is never used, and this may well be the culprit of the network issue. The toggle is tripped with a function key combination.  This may be something like pressing the Fn and F2 keys together.  Presumably, there is a corresponding Wi-Fi indicator light on the machine, so if this lights-up after pressing this key combination, it's a good bet this has addressed the network "outage." NOTE:   The keyboard combination may vary by make and model.

Start Garden setting out to grow Michigan ideas

With roots in Michigan , this blog is fond of the state.  It's specifically fond of western Michigan.  Accordingly, it has interest in the success of the Start Garden venture capital project in Grand Rapids .  The enthusiasm comes not only from pride in the state, but because Michigan has been getting too much bad press concerning its economy lately.  This venture is good not only because it's good news on the business front in Michigan, but hopefully because it will have an impact on the tech business front as well. Check it out with some of the following pages. About Start Garden http://startgarden.com/about Start Garden in Grand Rapids http://startgarden.com/space What's happening at Start Garden http://startgarden.com/events

KB: Unable to get messages or calls in Google Hangouts for iOS

Issue Google Hangouts for iOS does not receive instant messages or phone calls, but they are delivered correctly when the application is explicitly loaded. Cause The notifications for the application are not properly set up in the Notification Center . Solution Add Hangouts to the list of applications that are allowed to show notifications in the Notification Center. Open the Settings application. Choose Notifications . If Hangouts is not listed under the section In Notification Center , then scroll down to the section called, Not In Notification Center . Select Hangouts . Toggle the Notification Center  control to On . Optionally, set any of the other toggles from this panel. Make sure that Hangouts is listed under "In Notification Center." Hangouts notification settings. To close, just back out to the main settings panel, and click the center button on the device. Environment Device iPhone, iPad, iPod touch

Debugger pointer colors in Eclipse

There are two settings to adjust the color of the line pointer while debugging an application in Eclipse .  The distinction between them may not clear, so it will be made here. The settings are located in: Window | Preferences General | Editors | Text Editors | Annotations The settings are Debug Call Stack and Debug Current Instruction Pointer .  The latter is the one that shows the line the debugger is currently stopped at.  If the "Vertical ruler" checkbox is ticked, a right-pointing arrow will show up along the left edge of the editor window.  If the "Overview ruler" box is ticked, then a little marker, the same color as the pointer color, will show up along the right edge of the editor. For the former item, this refers to the settings that apply to any other line in the call stack.  So, the debugger "jumps" around the code when a line in the call stack is selected.  The color of that line and its ruler settings compared to the current lin

Tag syntax argument is invalid complaint against CFML

A common gripe amongst ColdFusion detractors is its tag-based syntax.  And to be honest, who could blame them?  There is an endless collection of CFML code on the Internet that uses CF tags instead of CFScript notation.  This, in spite of CFML's support of script-based syntax since 1998 .  Granted, the provision was limited until version 9 , but that was 4 years ago. While some developers like the tag-style syntax, for those who don't it's easy to understand why the perception is that this is how CFML applications are coded. The following examples are comparing straight CFML with CFScript and are taken from Adobe's own help page. About CFScript http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0a0e0-7ffe.html First using CFML <cfif IsDefined("Form.submit")> <cfif (Form.lastname NEQ "") AND (Form.department NEQ "")> <cfset employee = structnew()> <cfset employee.firstna

iOS 7 interface design looks familiar

Without much "hands-on" time with an iOS -supported device, it's difficult to tell for sure, but something looks very familiar about the design cues of Apple 's new mobile system. In spite of the noise Apple made around it's announcements a few weeks back, all the talk around the Web seems to be focused on the new "flatter" look of the interface design.  What seems to be coming out of this new look has been a move to look more like Android . A flat look is not, by itself, revolutionary.  Everyone is doing it, but when Apple is taking more and more "heat" about no-longer innovating, following suit in the design department too is certainly not going to help cool things down. For some examples of this similarity, take in the pages below, but bear in mind a couple of points.  One is that this example is of a dialog box in each of iOS 7 and Android 4.1 and to be honest, there's probably not much room for anything ground breaking can be don

Internet shortcuts on Windows systems

Windows systems have the ability to create files that "open" in a browser.  Create a text file with a ".url" suffix and the following content. [InternetShortcut] URL=http://subdomain.domain.tld The system will even go out and grab the favicon.ico file from the site to use as the file's icon.  Naturally, longer URLs can also be used.  For example: [InternetShortcut] URL=http://subdomain.domain.tld/some/path A special note It's important to note that Windows systems will likely be particular about how this file is accessed.  Specifically, concerning making changes to the URL it points to and accessing it through "Save as…" dialogs.  For example, if trying to attach this shortcut to an email message the dialog will appear to do nothing and the system will be sluggish for a short while. A workaround is to use an additional filename suffix to prevent the system from "recognizing" the file as an Internet shortcut.  So, perhaps

Retrieve the definition for a stored procedure in SQL Server

Generally, once a stored procedure is created, the details of how it works can be forgotten.  Sometimes however, what a procedure does may need to be researched.  The following query makes an attempt to look-up the definition for a stored procedure in SQL Server . NOTE:   Set the value in the DECLARE line at the top to the procedure name to look for (partial strings are fine). NOTE:   SQL Server has the ability to encrypt the definition for a procedure.  A definition value of NULL likely means such is the case for this procedure. DECLARE @procedureName VARCHAR(MAX) = 'PROCEDURENAME' SELECT      sys.all_objects.name AS storedProcedureName     ,sys.all_sql_modules.definition AS storedProcedureDefinition FROM     sys.all_sql_modules     INNER JOIN sys.all_objects         ON sys.all_sql_modules.object_id = sys.all_objects.object_id WHERE sys.all_objects.name LIKE '%' + @procedureName + '%'

Identify an object type in SQL Server

SQL Server assigns the term "object" to a number of items.  These could be tables, views, columns, parameters, stored procedures, et cetera.  The following query can be used to identify the type of a SQL Server database object. NOTE:   The type is identified in the "type_desc" column. NOTE:   Set the value in the DECLARE line at the top to the object name to look for (partial strings are fine). DECLARE @search VARCHAR(MAX) = 'OBJECTNAME' SELECT * FROM sys.all_objects WHERE name LIKE '%' + @search + '%'

Identify the stored procedures a parameter belongs to in SQL Server

There may be times when it would be nice to know what stored procedures have parameters with a certain name.  For example, what procedures have a parameter named "username?"  Using SQL Server it's just a matter of querying some of the system tables to find out. NOTE:   Set the value in the DECLARE line at the top to the parameter name to look for (partial strings are fine). DECLARE @parameter VARCHAR(MAX) = 'PARAMETERNAME' SELECT      sys.all_parameters.name AS parameterName     ,sys.all_objects.name AS storedProcedureName FROM     sys.all_objects     INNER JOIN sys.all_parameters         ON sys.all_objects.object_id = sys.all_parameters.object_id WHERE sys.all_parameters.name LIKE '%' + @parameter + '%'

Boldness of social media foreseen since the 90s

By now everyone recognizes the " netiquette " phenomenon in today's social media-crazed world.  This being where people are brazen enough to say things about others that they would never have the bravura to say to the same people in person. In what might just be a case of being easily impressed, it's fascinating to see that author Daniel Kohanski was able to recognize this all the way back in 1998 when he wrote his book, The Philosophical Programmer:  Reflections on the Moth in the Machine . Sadly, in spite of having such an advanced notice of the issue, it's still a problem today.  Given modes such as Twitter , Facebook , instant messaging, and texting, combined with how many of us communicate using these channels, there's plenty of opportunity to quell the matter simply by not participating in the behavior.  But perhaps all these channels and the widespread use is what's perpetuating the problem.

Online tools for creating color schemes

By now it's pretty clear the importance color can play in design. As developers, syntax coloring has also become a mainstay of IDEs and mildly powerful text editors. The following resources may prove useful in identifying color themes both for designing applications as well as establishing pleasing syntax color schemes. Color Scheme Designer http://www.colorschemedesigner.com/ This one provides a great tool for choosing a scheme based on some of the common scheme classifications. It also provides a preview of what the scheme will look like on both a light and dark version of a web page. ColorCombos http://www.colorcombos.com/ This site has a collection of swatches for choosing a color combination, but it also has a tool that will yank the colors out of any web page. Colorspire http://www.colorspire.com/ Besides the familiar Photoshop-style color picker and the pool of 5 color chips to build the scheme from, the real nifty feature of this tool is its collection of bri

Ubuntu Unity reports the battery level for Bluetooth devices

Users may notice that Unity under Ubuntu 13.04 reports two battery levels under the battery icon in the top bar.  At first, this seems like a bug with the battery reporting, but clicking one of the battery icons will open the Power Statistics application. The two batteries are listed here as well and the secret is realized when selecting between the two.  Notice that one probably indicates details that can be associated with the laptop's battery itself.  The other will probably be associated with a Bluetooth device. NOTE:  This behavior was not noticed prior to 13.04 but may well have been there.

Next and previous tabs key bindings in Eclipse

Oddly, the key bindings for switching between tabs by simply moving left and right across the tabs is missing in Eclipse .  The commands exist, but there are no key combinations assigned to them.  Fortunately, using the key binding system in Eclipse can fix this quite easily.  And as an added bonus easy-to-remember combinations don't even need to be re-assigned before doing so. Using Mac keys as the template, a good set of combinations might be: Option + Command + Left (move across the tabs to the left) Option + Command + Right (move across the tabs to the right) Translated to Linux -based and Windows systems, this would be: Alt + Control + Left Alt + Control + Right NOTE:  Using the Keys preference panel, search for the term "tab" to jump right to the command to make the key assignment easier. Perhaps more perplexing than having this capability and not assigning a key stroke to it is that the commands only seem to be available via the "Quick Acce

Force checkout a branch with git

Occasionally, and probably against better practice, it's necessary to force a checkout of branch.  Doing so, necessarily overwrites any changes in the currently checked-out branch, but so be it. Using git it's done like this: git checkout -f BRANCHNAME The "-f" part is the "force" option.  Using "--force" instead does the same thing. Why would one do this?  If for no other reason, than because it may just be easier to stomp on the changes in one branch than to resolve the conflict.

Just a few things about fonts for programmers

While not a complete list by any stretch, this article will hopefully at least serve as a collection of some pretty decent typefaces for text editors and IDEs.  As for the reasons why one would need to put any real thought into what typeface to use in his or her editor, consider the following things that experience has rendered. A programmer's font should: Avoid ambiguity between characters.  This is specifically true for characters such as 1 and l , and 0 and O . Should be clear even when italicized.  Many editors italicize comments by default. Be mono-spaced, which will assist with justification. Panic Sans There is no place to download this font as it ships with Panic Coda . DejaVu Mono http://www.dejavu-fonts.org/wiki/Main_Page Droid Sans Mono http://damieng.com/blog/2007/11/14/droid-font-family-courtesy-of-google-ascender NOTE:   The items above are URLs to packages of fonts that include the specifically named sans, mono, et cetera versions. As an asid

Jelly Bean update for Motorola RAZR and RAZR MAXX, finally

It would appear that after Verizon 's promise of Jelly Bean for the Motorola RAZR and RAZR MAXX in November of last year, the accidental roll-out in December, and the recent "soak test," the update is finally reaching users.  It's a doozy, at better than 330 megabytes, so be sure the phone is plugged in or has a good deal of battery before starting the update. The gradual release of this update on Verizon has seemed erratic.  The RAZR M , I , HD , and HD MAXX , all got the update.  The Samsung Galaxy S III got it.  Naturally, the Nexus got it.  So it's bizarre the way this has been coming out in waves without any apparent rationale for what devices gets it, when.  Over the years there has been plenty of criticism in discussion groups for the way carriers deploy updates in comparison to the way Apple does it.  That being, independent of the carriers.  None-the-less, it's here so the complaining can start to wind down now.  Happy Jelly Beaning!

Verizon Wireless in application store shutdown mode

Verizon Wireless users can expect a change in the next month, and Motorola RAZR users should expect a second.  Verizon has chosen to shutter its app store with a stated timeline of the end of March 2013. According to the announcement the company has made available, users will have the store removed from their devices by March 27.  This presumably means that all the Verizon-developed applications will be gone as well.  With some digging around the Internet, it's easy to see that this change is welcome and that users will be happy to get space back on their phones, relinquished by the seldom used applications. RAZR users have also been promised an update to Android version 4.1 Jelly Bean with roll-out time frames going as far back as December of last year.  Currently, the roll-out is expected to be before the end of March which leaves the company with about a month left of wiggle room. This coincides nicely with the application store removal.  And it would make sense that th

Limiting search results by site

Experts Exchange has the irritating marketing tactic of posting a discussion article that often seems to match exactly what I'm looking for, but the response to the question requires registration.  Since the answer to most any question is likely somewhere else on the Internet as well it's possible to restrict search results from even showing anything from this site. Here's how to do it.  At least Bing , Duck Duck Go , Google , and Yahoo have the ability to specify a "sites" argument in a search.  It can be used to either force results from a specific site to be included or excluded.  The real nice part is that the syntax is the same for all of them, so including the following snippet into a search string can eliminate search results from Experts Exchange: -site:experts-exchange.com NOTE:  Whether pages are included or excluded depends on the (-) operator preceding the limiter. The following example could be used to search for how to use the SQL TOP c

Formatting date representations in DBeaver

The open source database client DBeaver has the ability to specify a format in which to present date and time values in results sets.  The tables defined here identify the date and time parts and what they will represent when used as part of the mask. To open the settings: Select File | Preferences Expand the Common item Choose the Date Formats item From the settings on the right side of this dialog, look for the Type pop-up menu and the Settings Name/Value fields.  There is a Name/Value combination for each item in the Type pop-up menu.  A custom mask can be supplied for the desired presentation of date and time data. Shorthand Description Example Date d Day without leading zero 7 dd Day with leading zero 07 M Month without leading zero 1 MM Month with leading zero 01 MMM Abbreviated month Jan MMMM Formal month January yy Short year 13 yyyy Full year 2

Connecting to SQL Server with jTDS using Windows Authentication

UPDATE:   At one point the tip in this article to set the USENTLV2 flag to true was accurate, but it appears it is no longer necessary, at least as far as DBeaver 's use of the driver is concerned.  If it solves an authentication problem, then great.  The expectation is that, an update in one of the packages that make this sort of connection possible has resolved the issue that at one time made this flag necessary. Connecting to Microsoft SQL Server using jTDS with a username and password that's managed by the database manager is pretty straightforward.  It may become a little more problematic however, when trying to use Windows authentication when connecting from a Windows machine. Do not supply a username and password. Set the USENTLMV2 property to true. NOTE:   Step 1 assumes a connection being made from a Windows machine.  If the connection is being made from something else, user credentials may actually be necessary. If the connection is being set up u

Get used to vertical photos and videos

Integrating cameras into mobile devices has been going on for quite a number of years now.  In that time the cell phone [mobile] camera has become quite a convenient feature.  However, an unexpected side-effect is that the perception of a "normal" orientation for a picture or a video is shifting. The expectation is that at some point in the near future the "natural" orientation of our photo and video content will switch to vertical instead of the far more practical, and pleasing, horizontal. It's almost as though the first camera appeared in a cell phone simply because the creators thought to do it.  Then, after the fact, the uses for the shooter were realized.  Today, people snap pictures on their mobile devices of nearly everything, and new services have sprung up around the Internet to cater to this doohickey.  Thanks to the mobile camera we have shots and footage of nearly everything now.  And as we continue to find new uses for our mobile cameras, we'

Google updates Contacts to leverage Voice

Google has updated its Contacts service to leverage its Voice service.  Users are now able to call or text contacts right from a contact's record.  By extension, this means that the contacts feature in the company's Voice service is being replaced by its existing Contacts service as well. The company has no doubt been using the same contacts data for each service, but now the two remain separate but are properly integrated with one another.  To use the new feature, simply search for a contact and hover over the desired phone number, and either a phone or a chat bubble will appear. Google voice controls Click the communication method you want and a Voice dialog will appear to finish the action with. Google voice dialog For now, the traditional contacts control in Voice as well as the new Contacts control are present.  It's reasonable to assume this will be the case for at least a couple of months.  It may also be the case that not all users are being

Eclipse KB: PDT fails to install with Juno

Issue Eclipse PDT 3.1.x fails to install on Eclipse Juno for Ubuntu 12.10. Cause Unknown, but the errors reported indicate a broken path of some sort.  It may be a broken path in a URL the package manager is using.  Or it may be a broken path in the package itself. Solution Point Eclipse to the PDT-specific repository. http://download.eclipse.org/tools/pdt/updates/release Environment Eclipse version 4.2 Juno Ubuntu PDT version 3.1.x Ubuntu version 12.10 Details The install software feature of Eclipse has a predefined repository for Juno with the following URL. http://download.eclipse.org/releases/juno This repository has an option for the PHP Development Tools (PDT) package under the following path. Programming Languages | PHP Development Tools (PDT) SDK Feature Installing PDT from this repository fails.