Monday, December 28, 2015

Quick and Dirty OCR on OS X for Free

Wait, Stop, Don't spend that $80+ on some fancy OCR software just yet.  There are some free open source tools out there and with a bit of work you can have very functional workflow using them and OS X. This guide will help you set up an applet you can drop images onto to OCR them to plain text.  This will not create PDF's, formatted, or indent documents, but rather just one large text block that is structured the same as the source text with line breaks.  The following tools are used, but instructions are provided below so you don't need to download anything from the sites.
  • Homebrew The missing package manager for OS X
  • Tesseract Open Source OCR Engine
  • Automator

Friday, December 4, 2015

Bookmarklet to Post to Slack from your Bookmarks Bar

I use Slack, and one think we love to do is share new articles and discuss them.  But the good old copy and past the link was annoying me, so I created a Bookmarklet that will share your current page to a selected channel.

Monday, October 19, 2015

Fix for Pillars of Eternity Blank Screen on OS X

Here is a quick fix for the blank/non-responsive screen in when going full screen in Pillars of Eternity on OS X (El Capitan). Note that you will have to do this before you run the game each time as it will reset the settings with bad ones each launch.

Thursday, October 8, 2015

Making Time Based Graphs with Chartist

I have been implementing some custom charts with Chartist recently.  Overall things have gone very well with some simple tweaks and fiddling to get things exactly how I want.  It is very nice to be be able to easily adjust the charts with CSS right in the normal site code.

Friday, October 2, 2015

Problems with Java Based OS X Applications Hanging when Entering Text

So I found another problem with my new upgrade to OS X 10.11.  That is that the Java web application I was using, Adobe Ad Hoc Analysis in this case, would hard lock every time i tried to enter text in a text box.  The only solution was to force quit the application.  After much testing I found the culprit was the RescueTime helper applet.  Basically this applet gets Accessibility access so that it can inspect windows and record time used but is glitching on the java windows and causing the lock up.

There could be other programs causing the same issues even if you don't use RescueTime but are having the same problem.  To troubleshoot do the following.

  • Close out of the java program that is locking up.
  • Open System Preference > Security & Privacy > Privacy > Accessibility.
  • Note with items are check and then uncheck them all.
  • Restart your java program and attempt to reproduce the issue.
  • If it is working correctly then quit, re-enable one item, and try again until you find the culprit.
  • If you can't get around the error even with all Accessibility options off that you must have some other issue.
Anyway if you find any items fix the problem you can just leave them off though they might hinder there applications functionality.

OSX 10.11 Stuck On Grey Screen After Login

After upgrading to El Capitan yesterday I ran into an issue where my computer would boot up going through the loading bar and display the login screen if  enabled.  Upon logging in, or automatic login, the system would hang at a grey screen.  After some testing with the network I figured out that it was not actually locking up and would respond to traffic.

To determine if your issues is due to the same problem wither SSH into the computer once booted if remote login was enabled or boot to Recovery Mode  and launch the Terminal.  Then run the following to see recently logged errors.

tail /var/log/system.log | grep 'Segmentation fault'

Or if using the Recovery Mode terminal the following thought the drive name may be different.

tail /Volumes/Macintosh\ HD/var/log/system.log | grep 'Segmentation fault'

If either of these commands produce any results that you have found your problem.  The culprit is Unsigned Kernel Extensions or .kext modules.  In the good old days developers could just install these as needed to add code level kernel functionality but no for improved security OS X requires that all Kernel Extensions be signed by the developer.  This is overall a good thing because these are privileged and could easily lead to malicious behavior by untrusted sources.

Anyway the problem where is that the upgrade didn't disable the unsigned Kernel Extensions it found and instead just doest't load them.  This is fine and normally it would just mean that whatever applications depend on them would jus not work until updated but for whatever reason there are a few special cases that cause the login process to hang.  I ended up removing all the Virtual Box and Soundflower modules and then was able to boot without issue.  I have not tried to Re-install or upgrade wither yet but atlas my computer boots.

To remove these again go to the Terminal and do the following.  You will nee to authorize them with your administrative password.

sudo rm -Rf /System/Library/Extensions/Waco*
sudo rm -Rf /Library/Extensions/VBox*
sudo rm -Rf /Library/Application\ Support/VirtualBox/*
sudo rm -Rf /System/Library/Extensions/Soundflower*
sudo rm -Rf /var/folders/*

Again note the additional prefix if using the Recovery Mode ant that thedick name may be different.

sudo rm -Rf /Volumes/Macintosh\ HD/System/Library/Extensions/Waco*
sudo rm -Rf /Volumes/Macintosh\ HD/Library/Extensions/VBox*
sudo rm -Rf /Volumes/Macintosh\ HD/Library/Application\ Support/VirtualBox/*
sudo rm -Rf /Volumes/Macintosh\ HD/System/Library/Extensions/Soundflower*
sudo rm -Rf /Volumes/Macintosh\ HD/var/folders/*

Finally just reboot and enjoy.

Tuesday, September 29, 2015

Raspberry Pi B Crashing when Running on SD Card

I have been having surtax crashes with my Raspberry Pi B for a few months now and it is a very irritating intermittent issue.  The unit basically locks up and even on resetting the power it won't always turn back on, but rather just sit there with no lights and no display and I end of having to cycle the power 2-5 times to get it to start again.

Anyway, I finally figured out there it appears to be an issues with the SD card.  At first I thought that it was just an off brand card and the Raspberry Pi just didn't like it.  But after some testing and hands on trials I figured out that it appeared to be an actual problem with the electrical connection and even though the card seamed seated properly to poor connection would cause the card to be or become unreadable.  This was easy to verify by lightly pressing on the SD card and then turning on the Raspberry PI.  It turned right on and worked perfectly and as soon as I let go it died again.  I can't see any physical defects and the card looks to be seated and pressing firmly into the contacts but I guess it's not sufficient.




I found a simple solution, a simple light pressure chip clip/close pin on the SD-card solved the problem perfectly.  I added a bit of cloth above the SD card and ensured that the clasp was pressing just above the SD Card's contact points and placed it over the end of the Raspberry PI and it works like a charm.

Wednesday, September 16, 2015

XBian RC2 ASS Subtitles not Displaying in MKV Videos

Minor issues I found when updating to the current release of XBian on my Raspberry Pi B.  Namely that subtitles would not work from MKV videos.  Heres a simple fix for the issue.  SSH into the xbian and run the following:

sudo apt-get install libass5

Friday, July 31, 2015

Drag and Drop in Umbraco 7

This code will let you add drag and drop logic to Umbraco v7 using the new AngularJS interface.  It doesn't require and backend code updates but can't be created as a package because there is no way to update the umbTree directive as needed.  There are only two files that need to be changed on the client.  Note that updates to umbraco will overwrite these changes.  Also note that due to lack of support in the underlying jQuery-sortable plugin for touch events this will not work on tablet devices.

First a set of changes for the umbTree and umbTreeItem directives in umbraco/Js/umbraco.directives.js.

 This patch was generated on 7.2.8 so may not work on other versions automatically.  You can manually apply all the listed changes on any 7.* version and they should work as expected with no changes needed.

Secondly, to allow for dragging items to collapsed nodes or nodes they don't already have children, the following needs to be added to the end of the line in umbraco/assets/css/umbraco.css.

Friday, May 29, 2015

For Each to loop over HttpFileCollection Files

Recently I was working with file uploads in .NET and found that theres no clean way to loop over each uploaded file.  Here is a extension method for easily looping through the list and it allows filtering by field name and applying Regex to the file name.

Samples:

Source Code

Friday, May 22, 2015

Convert .htaccess deny rules to web.config

Recently I was looking for a easy way to convert a large list of spammer and hacker IP Addresses from Apache .htaccess allow/deny rules into a format I could use on our IIS Server.  I found that there is really no good way to do this but after some work and a bit of coding here is a solution.

This solution will allow you to take a large list of access rules and apply them to an IIS website.  Additionally this is done in a file so there is no need to manually add records.

Collect your List of Rules

I used the following as a general blacklist of malicious and spammer client's to block.  There are other sources or you may have your own list.  Compile all the lists into one file and don't worry about duplicates, the script later on will resolve those.

Convert the Rules to Web.config Equivalents

I have created a simple javascript tool to convert the above lists into web.config rules.  To do this go here and enter all your rules into the first text box.  Make sure you supply all rules at once so that they can be de-duped.  If the list does end up having duplicates then IIS will not start up properly.

Ensure you have the Features Installed

Next log onto your server and make sure that you have the Web Server > Security  > IP and Domain Restrictions role installed.  You may need to add it as it's not selected by default.

Apply your new Rules

Finally open up the web.config files for each of your main sites and add the generated text to the system.webServer/security/ipSecurity section. Save and reload the website to ensure it's working.  

Example Web.config File

Tuesday, May 5, 2015

Manually replace a SSL Certificates in IIS 7

Recently I was trying to update SSL Certificated on our Windows Server on IIS7 and when trying to complete the Certificate Request I was getting a cryptic error.

CertEnroll::Cx509Enrollment::p_InstallResponse: ASN1 bad tag value met.

In short I wasn't able to find much help on this but after much fiddling I found an alternate procedure to import SSL Certificates in PKCS#7 or  X.509 formats.

Instead of trying to import the certificate directly in IIS add it to the certificate story manual by doing the following.  Then refresh and it will show up in IIS as expected.

  1. Save the certificate and make sure it is accessible on the server.
  2. On the server open up MMC.
    1. Start > Run > MMC
  3. Add Certificates Snap-in
    1. File > Add/Remove Snap-in
    2. Select Certificates > Add > My User Account > Add
    3. Select Certificates > Add > Computer Account > Next > Finish
    4. Click Ok
  4. Check in both Current User and Local Computer for old certificates to remove
    1. Look under Personal > Certificates
    2. Remove the old certificate you are trying to replace by selecting it and pressing delete.
  5. Import the new certificate by either method
    1. Double Click it in the file browser and choose Install Certificate
    2. Under Local Computer > Personal > Right Click and select All Task > Import.
  6. Move the new certificate to the proper store
    1. Expand either Current User > Personal > Certificates or Current User > Other People > Certificates to find the new certificate.
    2. Verify the expression date so ensure you have found the new certificate.
    3. Drag the certificate into the Local Computer > Personal > Certificates store.
  7. Look up the Certificate Thumbprint
    1. Now that there certificate is in the proper location Double Click on it to view the details.
    2. Click on Details > Edit Properties and set the Common Name to the proper domain name.
    3. Ok to go back and then scroll down to find the Thumbprint and copy this to your clipboard.
  8. Import the Private Key
    1. Open an elevated Command Prompt
      1. Start > Type command > Right Click > Run As Administrator
    2. Enter the following command replacing sample Thumbprint with the value you looked up above.  Make sure to keep the quotations.
    3. certutil –repairstore my “00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f”
    4. Now go back to the Certificate loaded into the Personal store and refresh and you will see a little key icon next to it.  Without this it won't be able to sign pages in IIS.
  9. Now if you go back to IIS you will see your certificate
    1. If you don't see the new certificate then it either wasn't moved the the proper location or doesn't have the private key required to function.

Monday, March 23, 2015

Prevent Google Chromes on OS X from navigating when scrolling

I have been having this very irritating issue when using the Apple Magic Mouse and Google Chrome.  No matter what I tried when I would use the vertical finer scrolling gesture to scroll up and down the page Chrome would go back and forward in the page history when scrolling to the top or bottom of the page.  This was vary frustrating and is apparently a but in the Chrome touch implementation as it happened in no other browser.  After much headaches, I could just turn off two finger navigation but I use it in other browsers where it works correctly, I finally found a solution.

The Solution:

Open up Terminal and Enter the following.
defaults write com.google.Chrome AppleEnableMouseSwipeNavigateWithScrolls -bool false
<enter>

Tada!

Thursday, January 29, 2015

jQuery .ensure() Function to Wait for a Condition Before Executing Code

Overview

This is a very nice little plugin I wrote for jQuery to handle situations that don't have callbacks.  You can do this manually in code by adding a timeout but what if the function takes to long, or what make users with a faster device wait for slower devices by over estimating the timeout.

Please note that most libraries have their own callbacks and jQuery had a $().done() mechanism that will do this for common functions and libraries.  This solution is for those odd ball code bits that don't or that you don't have control over.

It takes a few pieces of information:
  • selector
    • The root jQuery selector you are binding to, it will become the this in the isValid call.
    • If your waiting for a new item to be created do $(document).ensure(selector).done().
  • isValid (default $(this).exists())
    • This is the function that is run each iteration.
    • It should be optimized and return a bool result.  Ie don't walk the DOM every time, select the proper parent node into a variable or pass as the selector.
  • delay (default 500 milliseconds)
    • Miliseconds between each iteration.
  • tries (default 0)
    • Maximum number of times to try, 0 for unlimited.

Examples:

Source Code: