How To Enable Spell Check in TinyMCE

Have you been searching the interwebs for a way to add spell check into TinyMCE? There are a few plugins, but the ones I found depend on a server-side script. This is annoying because Browsers have spell check built in.

Well, it turns out, TinyMCE proactively turns off the built in browser spell check. You can re-enable it by adding the “browser_spellcheck” and “gecko_spellcheck” options, like this:

tinymce.init({ 
  ...
  browser_spellcheck : true,
  gecko_spellcheck: true
});

I’m not sure why they have two different options. They have documentation for the browser_spellcheck, but I found out about the gecko_spellcheck elsewhere. I’m assuming they are for different versions of TinyMCE.

Posted in How-Tos | Leave a comment

Simple JavaScript Inheritance

I have read quite a few posts on JavaScript inheritance. They all seem quite involved, and some are very complicated to implement. I took a crack at it, and this is what I came up with.

Here are a few advantages to this simple JavaScript inheritance:

  • Simple :)
  • Use the same pattern to instantiate new objects.
  • Supports “private” variables, functions
  • Supports “public” (“privileged”) variables, functions
  • Support “abstract” functions (sort of)

Methodology. All I’m doing is combining objects. I wrote an “extend” method that recursively combines objects together, and use it to combine the “this” variable inside a function with another object.

First thing, include this function somewhere in your code. This is the the secret sauce, the thing that makes it all possible (There’s actually nothing special about this method. You can use pretty much any “extend” method you like, like jQuery.):

function Extend(a) {
	if(typeof a != 'object')
		return false;
	function appendRecursively(a, b) {
		if(typeof a != 'object' || typeof b != 'object')
			return false;
		for(var i in b) {
			if(appendRecursively(a[i], b[i]))
				continue;
			a[i] = b[i];
		}
		return true;
	}
	for(var i in arguments) {
		if(i == 0)
			continue;
		appendRecursively(a, arguments[i]);
	}
	return a;
}

I can’t think of a better way to describe it than show you some code. Pay particular attention to the calls to “Extend” method. (See it on jsfiddle)

var Parent = function(o) {
	var self = this; // jump scope
	this.publicVariable = 'P publicVariable'; // public (privileged) variable
	var privateVariable = 'P privateVariable'; // private variable
	this.publicMethod = function() {
		output(self.publicVariable); // has access to public variables, methods
		output(privateVariable); // has access to private variables
		privateMethod(); // has access to private methods
	}
	this.getPrivateVariable = function() {
		return privateVariable;
	}
	var privateMethod = function() {
		output(self.publicVariable, privateVariable); // has access to public, private variables, methods.
	}
	this.abstractMethod = function() { // this is the closest thing JavaScript has to an abstract method
		throw 'abstractMethod() is not defined';
	}

	Extend(this, o); // simple instantiation
	return this;
}

// ** this is all you really need for inheritance.
var Child = function(o) {
	var child = new Parent(Extend(this, o)); // simple inheritance
	return child;
}

var GrandChild = function(o) {
	this.helloWorld = function(name) {
		return 'Hello, '+name+'.';
	}
	var grandChild = new Child(Extend(this, o)); // simple inheritance
	return grandChild;
}

var GreatGrandChild = function(o) {
	this.publicVariable = 'GGC publicVariable'; // override the variable set in Parent
	this.publicMethod = function() {
		return privateMethod();
	}
	var privateMethod = function() {
		return 'GGC privateMethod';
	}
	this.abstractMethod = function() {
		return 'GGC Abstract Method';
	}

	var greatGrandChild = new GrandChild(Extend(this, o)); // simple inheritance

	output(greatGrandChild.getPrivateVariable()); // has access to all parent's public methods, variables
	output(greatGrandChild.helloWorld('Great Grand Child'));

	return greatGrandChild;
}

output('_PARENT_');
var P = new Parent();
P.publicMethod();

output('_GRAND CHILD_');
var GC = new GrandChild({
	publicMethod: function() {
		return 'GC publicMethod';
	},
	abstractMethod: function() {
		return 'GC Abstract Method';
	}
});
output(GC.publicMethod());
output(GC.abstractMethod());

output('_GREAT GRAND CHILD_');
var GGC = new GreatGrandChild();
output(GGC.publicMethod());
output(GGC.abstractMethod());

// ** this is how you could use this inheritance model for simple object instantiation.
var InstantiatedObject = new Parent({
	abstractMethod: function() {
		return 'GC Abstract Method';
	}
});

function output(str) {
	console.log(str);
}

/*

Console Output:

_PARENT_
P publicVariable
P privateVariable
P publicVariable P privateVariable
_GRAND CHILD_
GC publicMethod
GC Abstract Method
_GREAT GRAND CHILD_
P privateVariable
Hello, Great Grand Child.
GGC privateMethod
GGC Abstract Method

*/

(See it on jsfiddle)

Don’t like the way I did it? That’s okay. Here are a handful of other ways:

Posted in How-Tos, Web Programming | Leave a comment

OCZ Technology Vertex 4 in a MacBook Pro

You probably found this blog post because you, like me, bought a OCZ Technology Vertex 4 for your MacBook Pro, and it’s giving you the spinning beach ball of death (freezes up). You probably also knew that it might have firmware updates and thought that it would be a simple update, then found that it was darn near impossible. Well, here’s what I found.

Method 1.

This was the method that gave me hope. I found it when I bought my Vertex 4 from Amazon (link). A reviewer gave detailed upgrade instructions, using a bootable CD made from an image downloaded from OCZ. This almost worked for me.

Method 2.

This is OCZ’s original instructions that the author of Method 1 adapted. You create a bootable CD, and run the utility. My instructions add a little clarity to this method.

Method 3.

This method is Mac specific. It details how to create a bootable USB drive, boot into the utility, and flash the drive. I couldn’t get the .dmg image to restore to my SD card, so I’m not sure if it will upgrade you to version 1.5. Please leave comments on your success/failure.

What I did.

  1. Back up all data. (this is a non-destructive firmware upgrade, so this shouldn’t be necessary, but I wanted to play it safe)
  2. Download the Linux-based Tool from OCZ and burn it to disk. Be sure to read and heed all warnings on this page. (How to burn an .iso to a disk)
  3. Connect your Mac to power. Let’s not be reckless :)
  4. Connect your Mac to ethernet. It won’t work otherwise.
  5. Plug in a USB mouse. Your touchpad won’t work in the utility.
  6. Restart your computer while holding down the “option” button.
  7. When you get the boot menu, select the disc, and hit “enter”. (You may have to wait a few seconds for the disc to show up as an option)
  8. When you see the startup screen, hit “enter.” You will then boot into a lightweight version of Linux with a few menu options on the bottom. This may take a minute or so, and it may give you some warnings or errors.
  9. Click on the “OCZ_Firmware_Current_Flash” icon on the bottom. (This is where my instructions are different than Method 1. The reviewer suggests to click on the “OCZ_Mac_Firmware_Flash” update tool, but this would never work for me. It told me to set my SATA controller to AHCI mode.)
  10. This will open a terminal-like window. Follow the instructions. It will tell you your current firmware version (Mine started at 1.4), and then run the firmware flash program.
  11. You’ll be prompted to restart your computer to complete.
  12. If your firmware started at version 1.4, you’ll be updated to 1.4.1 (or something like that). You’ll need to go through the update process again to get you to firmware 1.5. Repeat steps 6 – 11.

If this method doesn’t work for you, go ahead and try the other methods. If you have a different method, post a comment.

Method 5.

Send your OCZ Vertex 4 back and get a hard drive that is more Mac friendly. I read that the Crucial SSDs work out of the box.

Helpful Links:

OCZ Technology Vertex 4. This is the exact hard drive I bought.

Hard Drive Caddy Tray. I placed the hard drive that came with my Mac (a Hitachi 512 GB)  in this tray and replaced my Superdrive with it. That way, I don’t loose storage space.

Apple USB Superdrive. Some people get an enclosure for their superdrive. I couldn’t find one with good reviews, so I got an external. You may also want to go with a Samsung or AmazonBasics external.

Crucial m4 SSD. In case you don’t want to mess with flashing firmware. :)

 

 

Posted in Uncategorized | 4 Comments

How-To Sync Mercurial Repositories over SSH

It is simple to sync files using Mercurial over SSH.

1. Set up your computer to ssh to the remote computer without a password.

2. Add the following to the .hg/hgrc file (if it doesn’t exist, create it).

[paths]
default = ssh://user@target:port/path/to/repository

You can now push to default over SSH.

Posted in Development, How-Tos, Web Programming, Web Server Administration | Leave a comment

How-To SSH without a password

Sometimes you need to create an SSH connection without entering in your password. For instance, you are syncing files using a Version Control System (such as Git or Mercurial) over SSH, and your software isn’t set up to ask for a password every time.

The solution is simple: Store a file on the target computer identifying the source computer.

Here’s how you do it:

1. Generate an SSH key on the source computer (the one you will be making the connection from). When prompted, don’t enter a passphrase.

ssh-keygen -t rsa

2. Create an .ssh directory on the target computer. Enter the ssh password when prompted.

ssh user@Target mkdir -p .ssh

3. Add the source computer’s ssh key to the list of allowed keys on the target computer

cat .ssh/id_rsa.pub | ssh user@Target 'cat >> .ssh/authorized_keys'

You should now be able to make a connection without entering a password.

Posted in How-Tos, Web Server Administration | Leave a comment

Install Git on Mac OS X 10.7 Lion

  1. Download the latest version of Git from the Git Project Home
    1. If there is no specific version for Lion, the version for Snow Leopard works just fine.
  2. Open the .dmg file you downloaded
  3. Run the package
  4. Restart your computer
Posted in Development, How-Tos | 7 Comments

Install Grails on Mac OS X 10.7 Lion

  1. Download and Install the Java Software Development Kit (SDK).
    1. log on to http://developer.apple.com
    2. Search for “Java for Mac OS X 10.7 Developer ” on the downloads page
    3. Download and Install the latest. This will be a .pkg type install (not click and drag)
  2. Install Grails
    1. Go to http://grails.org/Download
    2. Download the “Binary Zip” under the current release.
    3. Unzip the downloaded file, and move to /Applications/Dev (or wherever you like), take note of the directory name.
  3. Add Environment Variables
    1. Open/Create /etc/launchd.conf
      sudo nano /etc/launchd.conf
    2. Add the following lines: (make sure to reference the proper directory names)
      setenv JAVA_HOME /Library/Java/JavaVirtualMachines/[VERSION].jdk/Contents/Home
      setenv GRAILS_HOME /Applications/Dev/[GRAILS VERSION]
    3. Save and Exit
    4. Add execute permissions
      sudo chmod +x /etc/launchd.conf
  4. Append reference to the grails /bin directory to the path
    1. Create a new path file
      sudo nano /etc/paths.d/grails
    2. Insert the following lines
      /Applications/Dev/[GRAILS VERSION]/bin
    3. Save and Exit
  5. Restart the computer
You should be able to type ‘grails’ at the command prompt and get a response.
Posted in Development, How-Tos | 2 Comments

Goodbye, Old Friend.

“Old Friends” would be more accurate, I guess.  Robin Dunbar suggested that a person can only maintain about 150 social relationships at one time.  These shoes account for two of my best friends.

These past few weeks have been pretty difficult for me. I mean, my shoes and I have been together for about six years. They were with me when I met my wife. We experienced Disney World for the first time together. And Disney Land. And Disney World again. They were with me when my daughter was born, and then my son. I can’t count how many steps we’ve taken or stairs we’ve climbed. These shoes have been with me more hours than any other possession I have owned. Ever. It really feels like two of my best friends are leaving me.

Then I found these:

They say that the best way to get over one love is to find another. I think I’ll be just fine.

Here’s to the next six years.

Posted in Uncategorized | 2 Comments

Perfect color bouncing flash indoors

Photography is, simply, capturing light.  Really good photographers understand how to capture light in difficult lighting situations.  Taking photos of a bright landscape is pretty simple because your camera does most of the work. Sunrises and sunsets take some exposure compensation. Indoor photography is even more challenging.

The best indoor photographs are taken in a studio with expensive studio lights.  Studio lights do three things: They move the light source away from the camera to provide depth, they diffuse (or spread out) the light to reduce harsh shadows, and they provide consistent light for color accuracy. Built-in flashes will lighten up the subject, but the image typically has less depth and harsh shadows.

This is why most hot shoe-mount flashes have swivel and tilt.  This makes it possible to bounce the flash off of a surface to get somewhat of a studio light feel in photographs. It diffuses the light across that surface, and it moves the light source away from the camera, which provides depth.

Bouncing poses a challenge.  Simply put, you are changing color temperature of the light source.  Photos bounced off a white or off-white surface will probably be “warm,” or have an orange tint.  The solution is to change your white balance settings.

ISO 400, 1/200, f/5.6, +2/3 flash, Sun WBThis photo was taken with the flash bounced off of a white ceiling (flash head was pointing strait up), with the following settings:

ISO: 400
Shutter: 1/200
Aperture: f/5.6
Flash exposure compensation: +2/3
White Balance: Sun

I have not touched up this photo.  It has depth, soft shadows, and the color quality is fantastic.

If you don’t have a hot shoe mount flash and would like better results indoors, try stepping back a few feet from the subject and zooming in a bit to compensate.

Posted in Photos | Leave a comment

How to disable cache in IIS

I have been developing a PHP application running on IIS, and recently came across some caching issues. Lots of them. Normally, caching doesn’t bother me. In fact, it can help performance significantly. However, when I am developing, I don’t want anything to cache. Ever. It throws off the development.

Here’s how to do it in IIS:

  1. From IIS, select the website.
  2. Open “Output Caching” under the IIS section.
  3. Click “Add…” from the Actions panel.
  4. Specify an extension, Check “User-mode caching” and “Kernel-mode caching” and select the “Prevent all caching” options under each section.
  5. Click OK
  6. Restart the website.
Posted in How-Tos, Web Programming, Web Server Administration | Leave a comment