mysql connect in php

Know all the other main mysql functions off by heart. *Always* forget the order of mysql_connect’s variables. Even though they are obvious!

$conn = mysql_connect('localhost', USERNAME, PASSWORD) or die ('Could not connect to db');
mysql_select_db(DATABASE);

although mysqli and pdo are safer/better to use.

mysqli

$mysqli = new mysqli('localhost', USERNAME, PASSWORD, DATABASE);

pdo:
http://php.net/manual/en/ref.pdo-mysql.php

<?
$pdosettings = array(
    PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
);

$pdo = new PDO(
    'mysql:host=HOSTNAME;dbname=DATABASENAME',
    'USERNAME',
    'PASSWORD',
    $pdosettings
); 

?>

bash script using awk to tar.gz a directory

There is probably a nicer way to do this, but this works + is quick. there was a reason for splitting it into letters but left that out for this post. it won’t do anything not starting with a-z btw obviously.

it .tar.gzs each subdirectory under /directory/ (obv. change this) to its own .tar.gz file.


for letter in {a..z}
 do
 \rm tmpfilealldirs.txt
 find /directory/$letter* -maxdepth 0 -type d > tmpfilealldirs.txt

awk 'BEGIN{FS="\/";OFS=""}{\
 out_file = "alldirs"; \
 print "tar czf ", $3 , ".tar.gz /directory/", $3 >>out_file \
 }' tmpfilealldirs.txt

done

&nbsp;

Run ie7, ie8, ie9 on os x using MS’s virtual machines

https://github.com/xdissent/ievms#readme

Overview

Microsoft provides virtual machine disk images to facilitate website testing in multiple versions of IE, regardless of the host operating system. Unfortunately, setting these virtual machines up without Microsoft’s VirtualPC can be extremely difficult. These scripts aim to facilitate that process using VirtualBox on Linux or OS X. With a single command, you can have IE6, IE7, IE8 and IE9 running in separate virtual machines.

Requirements

Installation

The VHD archives are massive and can take hours or tens of minutes to download, depending on the speed of your internet connection. You might want to start the install and then go catch a movie, or maybe dinner, or both.

Once available and started in VirtualBox, the password for ALL VMs is “Password1″.