THE definitive guide to making Windows 7 run on Boot Camp with VirtualBox!

Here is the scenario:

You have a bootable method of installing Windows 7 (more on this in a future post) and a copy of VirtualBox.  You have one partition on your hard drive – Macintosh HD.  You are trying to figure out a way to use Windows 7 on a Boot Camp partition, but still be able to use VirtualBox to control this partition as well.  Google returns all sorts of results of people frustrated in trying to get their Windows partition to work with VirtualBox.  No need to fear though!  It can be done in just a few simple steps!

Read the rest of this entry »

Enable jQuery with the dollar sign ($) in WordPress

Like many avid jQuery users, I was often frustrated when trying to develop my own theme or plugin for WordPress and found that I could not use the $ shortcut for jQuery.  While this is not much of a problem if I was writing my own program, I was trying to incorporate the plugins that other users had created.  Unfortunately, there is no nice answer to this problem.

WordPress by default loads prototype on the main blog, without jQuery.  The admin pages of WordPress use both prototype and jQuery.

Load jQuery on the main blog

To load jQuery on the main blog, you need to make use of WordPress’s wp_enqueue_script function.  Here is a sample chunk of php code to use to include jQuery. Simply put this at the beginning of your header.php file, before the Doctype declaration:

<?php

function loadScripts(){

wp_enqueue_script('jquery');

}

add_action('wp_print_scripts',loadScripts);

?>

This will load the jquery library when the other scripts WordPress automatically inserts into your pages are added.

Use the $ sign in your jQuery plugin

To use the $ sign in your jQuery plugin, simply include the following line at the beginning:

var $ = jQuery;

This will override the global prototype shortcut which uses the $ sign for your plugin.

How do I incorporate other jQuery plugins?

To add a plugin for jQuery, you need to first load it with the wp_enqueue_script function, and then resolve the issue of the $ sign in one of three ways:

  1. Do a find-and-replace in the plugin javascript to replace all occurrences of ‘$‘ with ‘jQuery.’
  2. Include the line of code from the above step at the beginning of the plugin javascript.
  3. Load a javascript file before the plugin file that contains the line of code from the above step.

For example, to include the dropshadow and rounded corners plugins:

<?php

function loadScripts(){

wp_enqueue_script('jquery');

//You can use an absolute path, where '/' is the root of your WordPress installation.

wp_enqueue_script('master','/wp-content/themes/Katz%20Dental/scripts/js/master.js');

wp_enqueue_script('jquery.dropshadow','/../scripts/js/jquery.dropshadow.js');

wp_enqueue_script('jquery.corners','/../scripts/js/jquery-corners-0.3/jquery.corners.js');

}

add_action('wp_print_scripts',loadScripts);

?>

This will load your master.js file, which contains the line of code that allows you to reassign the $ sign shortcut.

Voila!  We now have jQuery up and running on WordPress!

PHP Security 1::Error Reporting

Welcome to the first of the PHP Security posts.  I will be giving some broad, basic security concerns that are a must-read for any PHP developer.

The first topic of discussion will be the concept of error reporting.  This is an extremely useful feature of PHP, as it allows developers to debug their code quicker.  However, while error reporting is all well and good for development purposes, it is a big no-no for a production environment.  Read on for how to log your errors without displaying any sensitive debugging information to the end-user.

Read the rest of this entry »

Arpspoof for Dummies – a HowTo Guide

Welcome back everyone. This post is intended to provide a simple approach to learning the fundamentals of arp spoofing. By the end of this article, you will be fully equipped with how to arpspoof a machine.

Note: These techniques should be used only to test your own networks. It is illegal to spoof computers on networks you do not own, or have a court order for.
Read the rest of this entry »

Website Optimization

Website optimization is becoming increasingly important as more and more users browse the internet. To attract visitors, it is important to make sure that the site loads quickly, and in this article I will discuss the common areas where website optimization can be applied, and recommendations on how to optimize your site.

Read the rest of this entry »

Installing PHP5 on IIS 6 with the GD Library

So after spending about three hours on my windows machine here at work trying to get PHP and GD to cooperate with IIS, I thought I would write about it to save everyone some headaches. Now, just as a preface, as much as I dislike windows, especially since thanks to darwinports or fink on my mac I am able to install everything I need with one command, I have to say that IIS really was not difficult at all to work with. Just make sure to adhere to the following steps and everything should work OK:

Read the rest of this entry »

MySQL LOAD DATA LOCAL INFILE returns Column count does not match value count at row 1 error

Scenario: I have a comma-separated value list (*.csv) file that I would like to import into my database. However, I put in the code:

LOAD DATA LOCAL INFILE '/path/to/csv/file.csv'
INTO TABLE test_table
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'

and I get an error: Column count does not match value count at row 1.

Now, normally when I see this error I immediately think that I am trying to insert values into more columns than there actually are in the table. Once I verify that I am assigning one value per column, and that EVERY COLUMN gets a value, the next thing to check with an error like this is the primary key column. Usually this will be an auto_increment column, but it still needs a value when inserting into a row. If you are simply adding to the file, you can use ” or ‘\N’ as a value for this field – it will automatically assign itself the next proper number in the sequence.
Read the rest of this entry »

Increase mac system volume above the max – VLC, QuickTime, and AudioHijack

After trying numerous times to figure out a way to get my laptops speakers to go louder than the default, I finally found a couple of solutions. My problem has been that I will be listening to an audio or video file, and it plays too quietly, and I need to make it louder. A big issue is that sometimes, it is not your computers fault; the file may have been recorded quietly, which will affect the playback volume.

First, not much of a solution, is to play back video or audio files with the VLC media player. The volume controls here can raise the volume to about 400% I believe.

For those users who use Quicktime, there is a hidden option to raise the volume above the max. If you are streaming media and Quicktime is embedded in your browser, simply holding the shift key and clicking the volume icon will display a larger volume slider. In the standalone Quicktime application, when the volume is already on max, hold shift and press the up arrow to raise the volume above the max. If this becomes too loud, or you want to play another file on normal volume, pressing up or down will reset the volume to the default max.

Finally, the last solution I have is to use Audio Hijack. Simply open up the application, and if the application you are using for playback is not in the sidebar, simply add it. Then hijack the program BEFORE you open it (unless you also have Instant Hijack installed), and then in the effects tab, slide the Master Gain slider all the way to the right. This will output audio at 200%. If, for some reason, you need to make the volume even louder, then on one of the effects squares, click on the square and select 4FXEffect -> Double Gain. Raising the In or Out knobs seems to raise the output volume even more – in that case I usually try to raise the knobs symmetrically, instead of leaving the In maxed and the Out low, but I do not think this makes a difference.

Hope this helps you, let me know how this works!

Mac Os X Terminal Hints and Tricks

The Mac OS X Terminal provides access to the UNIX shell on your Mac.  This post is going to explore the different tweaking options that the Terminal can be used for, such as changing the sheet speed, changing hidden application icons in the dock, and more!  Some of these tips can be found on the great Mac OSX Tips website as well.

One point I will make before delving into the wnderful world of tweaking, is that it is sometimes very helpful to save some of these tweaks as ‘aliases.’  For instance, now I may want to speed up the sheet display, but at some point maybe I won’t, but by that point I will have forgotten how to change it.  Wouldn’t it be nice if I could simply type into Terminal ‘fastsheets’ to set the sheet display speed to fast and ‘slowsheets’ to set the sheets back to normal.  More information on aliases coming soon!

Note: All tweaks listed are easily reversible, and the default settings will be displayed under each tweak, so you can easily and readily go back to the system default if needed.

Change Mac Sheet Display Speed

For those who are unfamiliar, "sheets" are the panes that slide down from the top of the screen in an application.  An example of this are the menus in Firefox, Word, TextEdit, and other applications.  However, I personally find the display speed to take too long for me; I want my computer to run quickly and display quickly, not take a long time to show me a dialog.  Fortunately, there is a fix!  In the Terminal, simply type:defaults write NSGlobalDomain NSWindowResizeTime .001

You do not necessarily need it to be as fast as .001, so choose a number that suits you. 

Reset: The default value for the sheet display speed is .2

Translucent Dock Icons

This has easily been one of my favorite tweaks ever.  Normally, you can press Command+H to hide an application, or on the main menu you can select hide.  However, wouldn’t it be nice to actually see that the application is hidden?  This tweak will make the Dock icon of any hidden application appear translucent.

defaults write com.apple.Dock showhidden -bool YES

Reset: Run the command in Terminal, using NO instead of YES

Deactivate Dashboard

Perhaps the most useful tip for some, and perhaps quite useless for others.  I personally love this hack, as the Dashboard takes up more memory than I would like, especially when you have more than a few widgets running.  The following command will disable the Dashboard, but it takes two commands – one to disable the dashboard, and one to restart the dock.  This is perfectly reversible with no harm done.

1. defaults write com.apple.dashboard mcx-disabled -boolean YES
2. killall Dock

Reset: Run the commands again in Terminal, using NO instead of YES

Screensaver as Background

This is a very memory intensive hack, but is kind of cool as well.  I use this occasionally just for fun, or if I have a nifty screensaver that I want to see on my desktop.  I normally have an alias entitled ‘screenbg’ which will run the command.

/System/Library/Frameworks/ScreenSaver.framework/Resources/ ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background

Whatever screensaver is currently set under System Preferences will now be displaying on your desktop.

Reset: In the Terminal window, press the interrupt command, Ctrl+C to end the command

iTunes Arrows

As you may have noticed, clicking on an arrow next to an artist’s or album’s name in iTunes will take you to their albums in the iTunes music store.   This tweak will instead search your iTunes library for the artist or album.

defaults write com.apple.iTunes invertStoreLinks -bool YES

Reset: Run the command again in Terminal, using NO instead of YES

Finder Display Hidden Files

A simple command that will have the finder display all those hidden files cluttering up your system.

defaults write com.apple.finder AppleShowAllFiles TRUE

Reset: Run the command again in Terminal, using FALSE instead of TRUE

Safari Debug Menu

A nifty little debug menu that offers you many different options, such as accessing the Javascript Console, user agents, etc.  Always worth having.

defaults write com.apple.safari IncludeDebugMenu 1

Reset: Run the command again in Terminal, using 0 instead of 1

Skip Disk Image Verification

CAUTION: This may not always be the most advisable method!  Some disk images may in fact be corrupt, at which time you will wish that you had verification enabled.  I, however, am usually a bit trusting, and will only download images from sites I know, so I do not mind turning verification off, which speeds up mounting disk images.

com.apple.frameworks.diskimages skip-verify TRUE

Reset: Run the command again in Terminal, using FALSE instead of TRUE

Expanded Save Dialog

This tweak will display the fully expanded save dialog as the default, instead of the one line dialog box.

defaults write -g NSNavPanelExpandedStateForSaveMode -bool TRUE

Reset: Run the command again in Terminal, using FALSE instead of TRUE

Address Book Debug Menu

defaults write com.apple.addressbook ABShowDebugMenu -bool true

 

Reset: Run the command again in Terminal, using FALSE instead of TRUE

Preview’s PDF Zoom

Sometimes, the zoom level in Preview is set at an outrageous amount when it is opened through Spotlight, way above 100%.  To change the default zoom in Preview, simply type in the following command.  (NOTE:  10=100%).  This problem is often encountered when Spotlight opens a PDF and highlights the search term.

defaults write com.apple.Preview Preview -dict-add PVPDFSpotlightSelectionSize 10

 

Reset: Run the command again in Terminal, using 10 at the end instead of the custom number you used.

 

Posted in Tips. 1 Comment »

Almost Finished!

Im happy to say that my main website, http://pdworks.freehostia.com/ is finally almost done.  Everything there is set up, except for some reason the Image page des not display galleries correctly on Internet Explorer 6.  If anyone knows how to fix this issue I would appreciate it.  It works on Internet Explorer 7 and all the other web browsers that I use.  Heeeelp!