CATEGORY: Development

How to use Teensyduino to send cmd + enter

Recently we purchased a bunch of Teensyduino powered buttons for a trivia game we were building for a client’s convention as a fun learning experience. Now that the conference is through, the buttons are sitting unused, and my boss asked me if I could reprogram one of them so he could use it to send emails through Outlook on Mac.

It was a fun little exercise since I’ve never worked with programming Teensyduinos before. It turned out that this wasn’t so complicated to accomplish. I figured I’d share the script in case anyone else would find it useful.

If you need to send through Outlook on Windows, change the line

to

How to stop CouchDB on Mac OS

I have been working on a proof of concept using CouchDB. After getting the proof of concept working, I spun up a digital ocean droplet and proceeded to setup CouchDB on the server. I went to enable the SSH tunnel so I could access the CouchDB Futon instance and promptly ran into an error because my local instance of CouchDB was using the same port, 5984. I had a lot of trouble finding out an easy way to stop CouchDB because the documentation in the Wiki wasn’t accurate:

As a workaround, in Terminal, run

This will output something like:

99093 0 org.apache.couchdb.288008

Grab the highlighted portion and run

Substitute the process name accordingly and you should be able to run the ‘launchctl list’ command again and see the process is no longer present.

Regex to parse date formats when unknown

I’m working on an app that will parse different file sources and aggregate it for a report. Of course, each format has a different date format and trying to parse it all has proved to be a pain. I wrote a regex that’ll parse out just about every datetime format I’ve run into that I am sharing in case someone else finds it useful. I’ve put it on a Github gist along with a sample of the various dates I’ve tested it against and confirmed to work. If you find a format not covered by the regex, post a comment and I’ll update the gist.

Just a note that I haven’t finished parsing the timestamp (e.g. 1997-07-16T19:20:30+01:00) format. The date portion does get extracted correctly so I left it in.

Copy File Context to Clipboard via Command Line, Git Bash (Mingw64), or Terminal

I’ve been spending more time switching from SVN to Git and learning the command line options. I’m finding a lot of the Mac Git terminal commands I run aren’t the same in Git Bash (Mingw64). One of the commands I use is the pbcopy command to copy the ssh key to the clipboard to paste into Github and Bitbucket accounts. I’m starting to use it more as I am learning managing Linux servers and adding my key to login. I’m adding it here as a cheatsheet for myself but I thought others may find it useful.

On Windows, you can run this command to copy your ssh key to the clipboard:

On Mac:

or if you want to view it in the terminal window:

How to Copy and Paste into the Digital Ocean VNC Console

I recently signed up for Digital Ocean to test droplets for my development and linux management testing. I was securing the server and setup fail2ban, disabled the root login, and created a user account but forgot to change the user name from root to the user name I selected in my SSH client profile. I ended up locking myself out of the server and had to resort to logging into the admin panel on Digital Ocean’s website and use their browser embedded VNC client to restore my access. I quickly discovered that one of the downsides of using this panel is that you can’t copy and paste commands. Luckily there’s a workaround and you can use the browser console to do sendkeys through Javascript.

Bring up the console in the browser developer tools. Here’s a cheat sheet for keyboard shortcuts:

BrowserDescriptionWindowsMac
ChromeOpen Developer Tools and bring focus to the consoleCtrl + Shift + JCmd + Opt + J
FirefoxOpen ConsoleCtrl + Shift + KCmd + Opt + K
Internet ExplorerAfter hitting F12, you have to click the console tab.
There’s no direct shortcut to the console tab.
F12N/A

Paste this snippet into the textbox in the console window:

Chrome console

 

Update 9-21-16

Ruden and Sebastiaan’s pointed out there was a bug in the code above. This updated snippet has support for characters when using shift characters like !@#$%^&*()_+

You’ll receive a dialog prompt to enter the copy to paste in. Please note that you need to click on the VNC console and hit enter to execute the command.

Javascript Prompt

 

 

 

 

 

If you need to enter more than one command, just hit the up arrow on your keyboard in the console to get the script again for easy reuse.

Sitecore 8 Install Error: “The name you entered is not unique.”

Stecore Installer Error - The name you entered is not unique.I was working on my business partner’s computer to help him fix errors with his Sitecore instance for his certification class. He experienced multiple issues with the Sitecore 8 installer on Windows 8 and we went the manual route of deleting Sitecore to install clean and start from scratch. In the process, we:

  • Deleted the IIS website instance in the IIS Manager
  • Deleted the databases used by the instance
  • Deleted the root folder in the filesystem

After launching the installer again, it kept returning the error “The name you entered is not unique.” when naming the Sitecore instance to one previously used. After checking the IIS metabase and a few other typical locations, couldn’t figure out where the Sitecore installer was finding the name since we deleted everything manually. It turns out that the Sitecore executable installer creates a registry entry under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Sitecore CMS which is used to display information in Windows Programs and Features. This registry key is also checked during the installation process and if a child key with the same name as the one being installed is found, the above error message is shown.

To fix this:

  1. Start -> Run (or Windows Key + R)
  2. Type regedit
  3. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Sitecore CMS.
  4. Delete the registry keys containing the information about the previously installed instance.

NOTE: You’ll need to relaunch the installer as it apparently caches the key information.

 

Visual Studio 2013 package did not load correctly

Visual Studio Error MessageToday I loaded up Visual Studio to continue work on a project and created by a random bunch of errors. All were complaints that various packages could not be loaded. The one I captured was:

The ‘JavascriptWebExtensionsPackage’ did not load correctly.’ The problem may have been caused by a configuration change or by the installation of another extension.

I had just installed SyncFusion’s Essential Studio which apparently screwed something up. I tried doing a repair on Visual Studio which unfortunately did not work.

I was able to fix it by following these steps:

  1. Close Visual Studio Open the *Users*\AppData\Local\Microsoft\VisualStudio\12.0\ folder
  2. Rename the ComponentModelCache folder
  3. Restart Visual Studio.

Visual Studio should now rebuild the cache and no longer display the error messages.

ASP.NET MVC Model Generator

In making the switch to ASP.NET MVC, I’ve moved away from using my old Data Access Layer that I’ve used for years and have opted to use Dapper as my ORM of choice in the quest for optimal performance. My DAL was actually pretty optimized for WinForms and WebForms (using straight SQL Queries and SQL parameters) but mapping it to models wasn’t something I had in mind when I created it. I’m finding Dapper takes some getting used too but it is still pretty fast. The downside is that writing the code for Models to wire it up is proving to be a little tedious.

To that effect, I wrote a little application that has helped me generate the models from a database dynamically. It’s in it’s infancy stages and something I cobbled together in less than 8 hours but it works. I’ll add more features too as time goes on if there’s enough interest or to satisfy my own needs. In the meantime, I’m open sourcing the project as it may help others and I’d love to see it become something grander if others are willing to contribute to it. There’s also some useful bits of code that others may find useful to reference like dynamically reading fields from a database, pluralization/singularization of words, amongst others.

You can find the repository on Github: https://github.com/gregvarghese/MVCModelGenerator

SourceTree Crashes on Load

sourcetree errorI’ve recently started using Git for development and while I am getting used to the command line tools on Windows, I have been using Atlassian’s free tool, SourceTree to help manage my code. Recently I’ve run into an issue where SourceTree crashes on start up.”Oh dear. We’re sorry, but SourceTree just crashed. How terribly embarrassing.”

I submitted an issue (https://jira.atlassian.com/browse/SRCTREEWIN-3011) and received a response that didn’t solve the issue. I submitted a follow up but never heard back so I did some further digging and found that SourceTree was crashing because it corrupted a repo and was still trying to load it back up on start up. The application does not exit gracefully or even give you the option to start in a safe mode which loads nothing.

To prevent it from opening the repo on start up:

Open %localappdata%/Atlassian/SourceTree/opentabs.xml in notepad or another editor.
Delete the problem repo.

Viola! No more SourceTree crashes on start up.

How to Reset Sitecore 7.1 & Sitecore 7.5 Forgotten/Lost Admin Password

In working on implementing a Sitecore site into an existing code base inherited from another vendor, I discovered that the admin password had been modified and the vendor would not share it. Not being able to login to the admin section of Sitecore was not ideal to say the least. After scouring the web, most articles contained instructions on how to reset the password, but almost all of them applied to Sitecore 6 and below. For Sitecore 7 and above, most articles were not applicable as they introduced the PasswordSalt field into the database which Sitecore uses to hash the password.

If you’ve run into a similar situation, or you’ve forgotten or lost your admin account password, getting access back to everything is pretty simple. Load SQL Management (or your favorite SQL editor) and execute this query against your Core database:

This will now reset the default admin password to ‘b’ so that you may login to the Sitecore desktop. Happy editing!

There are no more results.