Skip to content

Instantly share code, notes, and snippets.

View michaelaguiar's full-sized avatar
🎯
Focusing

Michael Aguiar michaelaguiar

🎯
Focusing
View GitHub Profile
@michaelaguiar
michaelaguiar / ajax.js
Created August 31, 2011 18:51
JQuery AJAX Request
var data = $(this).serialize();
$.ajax({
type: 'POST',
url: 'URLHERE',
data: data,
success: function(response) {
$('#result').html(response);
},
complete: function() {
// Complete
@michaelaguiar
michaelaguiar / htpasswd.sh
Created September 29, 2011 00:27
Create .htpasswd
htpasswd -cmb .htpasswd USERNAME PASSWORD
@michaelaguiar
michaelaguiar / hide_hidden.sh
Created September 29, 2011 00:28
Hide Hidden Files on Mac OS X
defaults write com.apple.finder AppleShowAllFiles FALSE
killall Finder
@michaelaguiar
michaelaguiar / show_hidden.sh
Created September 29, 2011 00:28
Show Hidden Files on Mac OS X
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
@michaelaguiar
michaelaguiar / print_obj.js
Created September 29, 2011 00:32
Print Object Contents
function printObject(object) {
var out = '';
for (var index in object) {
out += index + ': ' + object[index] + '\n';
}
print(out);
}
@michaelaguiar
michaelaguiar / states.htm
Created September 29, 2011 00:35
HTML State Dropdown
<select name="state">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District of Columbia</option>
@michaelaguiar
michaelaguiar / display_errors.php
Created September 29, 2011 00:39
PHP - Display All Errors
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
@michaelaguiar
michaelaguiar / validate_postal.txt
Created September 29, 2011 00:48
RegEx - Validate Postal Code
/^\d{5}([\-]\d{4})?$/
@michaelaguiar
michaelaguiar / mysq_backup.sh
Created September 29, 2011 00:49
Backup MySQL Database (Compressed)
mysqldump -u username -h localhost -p database_name | gzip -9 > backup_db.sql.gz
@michaelaguiar
michaelaguiar / email_attachment.php
Created September 29, 2011 00:51
PHP - Send Email Attachment
<?php
function emailAttachment($to, $fromName, $fromEmail, $subject, $message, $files) {
$headers = "From: $fromName<$fromEmail>";
// boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";