Sunday, April 22, 2018

Dyson AM09 Fan & Heater H2 Error

No idea what the actual error is and I couldn't find anything useful on the web, so hopefully this will help someone else.
I assumed that the H2 error meant that something was dirty, clogged up or that it was overheating because it was dirty or clogged up because the error only showed up when it was in Heater mode.
The heater would run for about 30 seconds, then it would show the error and switch over to the high speed fan , I assume to try to blow out the dust.
I proceeded to open it up to give it a deep clean because the Dyson instructions for cleaning this thing are ridiculous and don't help at all. Gently wiping down the outside and vacuuming the intake holes....really Dyson, really?! I used cotton swabs and 91% alcohol to clean everything I could get to, starting at the base (in hindsight, this part may not be necessary at all). Then I got to the top of the device where the actual air comes out of and noticed that there was a lot of build up on the heater coils. I couldn't get to them without taking apart some vital wiring components, so I didn't want to fool with that.
Then I decided to leave it open and just blow it out with compressed air. Canned air may work (not sure how high the psi is on those) for you, but I used a small air compressor with the limit set to 80psi.

WARNING : This may void your warranty. Do this at your own risk, you assume full responsibility for following the below tips. 
Here is what to do:

1. Pry the plastic piece out that is covering up the one screw that holds the base to the top part.

2. Use a T9 bit to take the screw out (point A in the picture below)
After the screw is out, hold onto part B in the picture above with one hand and hold the base with the other hand. Twist until you feel it loosen up. Be very careful opening this part up since there are wires connecting the two pieces. Take your air nozzle and go to town on the inside portion, especially targeting the heater coils. Dust will fly everywhere so I recommend wearing something over your eyes.
Also point your air nozzle into the slits where the air comes out as illustrated by the green lines in the photo below.

Put it back together and test it out.

Friday, February 23, 2018

Replacing your HDD with a SSD in a Mid-2009 Mac

What you'll need:
  • T6 screwdriver
  • PH000 philips screwdriver
  • SATA to USB connector ( or SATA to Thunderbolt if you feel like spending the cash)
  • Apples DiskUtility Application
  • 2.5 inch SATA SSD (e.g. Samsung 850 EVO), size is up to you
Before we swap the drives out we want to test our speeds so that we can compare with what we get afterwards. You can run the below commands a few times, then take an average if you want a better representation.

Write Speed (16GB file, lower the values of the bs and count params for a smaller file)
52.872 MB/sec write speed

Read Speed
50.6726 MB/sec read speed

Also, in the Disk tab of the ActivityMonitor you can see a real-time measurement of reads/writes per second, which where an approximate match to the values I got above.

Hook up the new drive

The next thing to do is clone the current disk over to the SDD. I used a SATA to USB connector I found online to connect it to the Mac and I used the DiskUtility app to clone the disk.
Once you plug the disk into the USB port you should get a pop-up message that says "The disk you inserted was not readable by this computer."
Options are Initialize..., Ignore or Eject.

I chose Initialize, which will automatically open the DiskUtility application. At this point you should see an orange icon with the size, brand and model of your SSD. In my case it showed "250.06 GB Samsung SSD 850 EVO 250G Media".
The disk I am replacing is showing as "250.06 Hitachi HTS545025B9SA02 Media".

Format the new drive

Next up is formatting the new drive. To do this select the new drive, select the Erase tab, select "Mac OS Extended (Journaled)" for the format and give the new partition a name. I named mine "Macintosh SSD". Double check that you have the correct drive selected, then click the Erase button, you'll get a confirmation box.

Clone the old drive

Next, we will use the Restore function to essentially clone the original drive.
Choose the Restore tab, drag and drop the original disk partition into the Source field, then drag and drop the new disk partition (that was created by the format) into the Destination field. Then click the Restore button. Be careful with this part because clicking on one of the drives without dragging it will cause either the Source or Destination fields to change.
If you get a pop-up saying "The startup disk can’t be used as a restore source." then you will have to do this from the recovery console.
To get into recovery mode follow the instructions here or hold down Command+R immediately after restarting your Mac and continue to hold it until you get the utilities window.
Once you're in, repeat the drag-n-drop steps above. It took about 2 hours for the cloning process to complete. After the cloning process is complete, click on the apple icon and choose Shut Down.

Swap out the drives

Now you can flip the laptop over, take out the screws to the cover, unscrew the two screws in the bracket holding the drive in place, gently lift the drive up just enough to pull the SATA connector off of the old drive (don't handle the ribbon, just the connector), take out the 4 screws on the old hard drive (you'll need the T6 for this part). Installation of the new drive is the reverse of the steps above.

Test results after the swap:
196.577 MB/sec write speed
272.187 MB/sec read speed

What do I do with the old drive?
I used the same SATA to USB connector that I used for the SSD to hook up my old drive.
Start up disk utility , select the old drive, go to the Erase tab,  select Security Options, slide the slider all the way to the right to the most secure option, then select Erase. This will take a while, but the 7 pass erase will ensure that nothing can be recovered. Then take the hard drive to your trusty computer part disposal company where they will also take steps to securely destroy the drive by either shredding it completely or drilling holes in the drive.

Wednesday, October 11, 2017

ColdFusion to Sails.js Conversion : Find/Replace Tips/Tricks

Use your IDE of choice, I prefer Sublime Text because it uses the Perl Compatible Regular Expressions (PCRE) engine from the Boost library and I love me some regex. I will show examples for .js syntax, but if you need this in .ejs format just add <% to the beginning and %> to the end like in the first example below.  I always have the case sensitive button off in Sublime, so if you are using a different editor make sure you use the proper ignore case flag or you may get mixed results. These examples are meant to speed up the conversion, some additional refactoring may also be necessary.

more to come...

Wednesday, July 27, 2016

ColdFusion to Node.js Conversion : Setup Part 1

This multi-part post will be community comment driven, which basically means that in an effort to not spend too much time on details that might not matter to the viewers out there, I am only going to share the details which I think are important at the time of publishing the posts. If people (or bots) comment and want more details, I will add them to the original post. As always, constructive criticism is always welcome.

Since I am currently using the CFWheels framework (which is inspired by Ruby on Rails or RoR), I chose to try out the Sails.js framework for Node.js (which is also similar to Rails).

1st thing I did was get Node and Apache working together by adding this to my Apache vhost(VirtualHost) block:
ProxyRequests on
ProxyPass / http://localhost:8124/
And adding this to my hosts file (/etc/hosts):       mynewapp.node www.mynewapp.node

This allows me to setup an alias in my host file and reference the URL as you normally would without adding the portnumber on the end of the URL. Instead of having to use http://localhost:8124/ , I can now use http://mynewapp.node
After that I installed the "sails-mysql" npm package in order to get the app working with my existing MySQL database.
npm install sails-mysql --save

The next thing I did, because one very frustrating thing you will find is that you have to "lower" then "re-lift" your sails app after every change you make. I installed sails-hook-autoreload to take care of this for me as I make code changes.
npm install sails-hook-autoreload --save-dev
// I used "--save-dev" instead of "--save" above because this package 
is not required in a production setting.
NOTE: create a "[your-sails-app]/config/autoreload.js" file with at least the following configuration:
module.exports.autoreload = {
  active: true,
  overrideMigrateSetting: false
Otherwise the overrideMigrateSetting will be defaulted to true and sets the "module.exports.models.migrate" setting to "alter" which will wipe out any database tables you have setup models for!! This is a good time to mention taking frequent backups of your database. Since I am using an existing MySQL database I am using the "module.exports.models.migrate = safe" setting for both development and production environments.

to be continued....

Tuesday, June 14, 2016

Bitnami WordPress htaccess Redirect for Author Pages

As their page notes, for security purposes, the htaccess configuration has been moved outside of the webroot and AllowOverride is set to "None"
In this instance I have an EC2 instance spun up from a BitNami (HVM) AMI.
The default file to edit is

Make a backup of the file before you edit.
Add this block anywhere in the file to redirect all author landing pages to the home page.

<Directory /opt/bitnami/apps/wordpress/htdocs/>
    RedirectMatch 301 "^/author/.*"
Customize to your liking if you would rather redirect to a different page.
When you're done editing, run this to restart apache, then test your changes.

sudo /opt/bitnami/ restart apache
/* Joey */

Sunday, November 8, 2015

CfWheels and Controller Init Caching Gotcha

I recently discovered an issue where logic inside of a controllers init gets cached when your environment is set to production. By default, when in the production environment the cfwheels setting of cacheControllerInitialization defaults to true.
At the time I had logic in the init method that checks if the user agent is CFSCHEDULER and the remote address is localhost/ I used this logic to authenticate scheduled tasks that run on a secure section of the site.
I found this when sporadically the authentication would pass even though the logic returned false and I noticed the init method was _never_ being called, which led me to find that caching setting.
The fix was to extract the logic out into another method and add that to the list of filters.

/************** Before **************/
<cffunction name="init">
    <cfif CGI.remote_addr EQ "" AND CGI.HTTP_USER_AGENT EQ "CFSCHEDULE">
        <!--- let the CF ScheduledTask pass through --->
        <!--- add custom logic to impersonate authenticated user --->
        <cfset filters(through="getCurrentUser,isAuthenticated,isAdmin", type="before")>

/************** After  **************/
<cffunction name="init">
    <cfset filters(through="isScheduledTask,getCurrentUser,isAuthenticated,isAdmin", 

<cffunction name="isScheduledTask">
    <cfif CGI.remote_addr EQ "" AND CGI.HTTP_USER_AGENT EQ "CFSCHEDULE">
        <!--- let the CF ScheduledTask pass through --->
        <!--- add custom logic to impersonate authenticated user --->

Wednesday, February 20, 2013

ColdFusion Invalid Image Format Solution

For those who have gotten the following error:
"java.awt.color.CMMException: Invalid image format" and tried
the solutions posted here with no avail.

We are going to use the power of Java's JAI (Java Advanced Imaging) library to tackle this one.

//path to image
imagePath = "pathToImage";

//create java file object, passing in path to image
imageFile = createObject("java","").init(imagePath);

//create a FileSeekableStream, passing in the image file we created
fss = createObject("java","").init(imageFile);

//create ParameterBlock object and initialize it (call constructor)
pb = createObject("java","java.awt.image.renderable.ParameterBlock").init();

//pass in FileSeekableStream

//create JAI object that will ultimately do the magic we need
JAI = createObject("java","");

//use the JAI object to create a buffered jpeg image using the parameter block we just created
buffImage = JAI.create("jpeg", pb).getAsBufferedImage();

//pass the buffered image to the ColdFusion imagenew() method.
New_Image = imagenew(buffImage);

//make sure we close the stream, or you'll pay for it later

From what I could find CF/Java chokes on some jpeg's due to their format.
Specifically speaking, the EXIF format vs. the JFIF format.
Read this for more information on these two standards.

Some cameras only add the EXIF segment to the file header of the jpeg and images from those cameras are the ones I see issues with.
To see some samples of this, check out the images on this website.
Download some of those images and see if your image processing code can handle them!

To get more information on your images check out this page and it will tell you all about it, including if the image has JFIF or EXIF segments added.

If anyone has questions about the above code, please don't hesitate to ask.

Hope this helps some of you, since I could not find any solution out there.

Dyson AM09 Fan & Heater H2 Error

No idea what the actual error is and I couldn't find anything useful on the web, so hopefully this will help someone else. I assumed th...