Blog

jQuery Templating

Sat, 18 Sep 2010

jQuery Templating

I found out recently that the jQuery team will no longer be taking the template plugin beyond beta. So I looked up a new way to handle templates, and you can accomplish the same thing by creating a function and running an function.apply(jsonData) to it.

output = function() {
	return "<div>"+this.login+this.email+"</div>";
}

$.get('index.php?url=user/listing', function(o) {
	for (var i = 0; i < o.length; i++) {
		$("#listing").append(output.apply(o[i]));
	}
}, 'json');


Rackspace CentOS 6 From Scratch

Sat, 18 Sep 2010

Here is a series of commands you can use to setup your CentOS 6.X server with PHP 5.4, MySQL, Apache, and the many tools you'll probably want. For newbies, the $ symbol means it's a shell command, you don't actually put in the $ symbol :)

$ passwd
$ yum update
$ nano /etc/sysconfig/iptables
Add
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
$ /etc/init.d/iptables restart
$ yum install httpd
$ chkconfig httpd on
$ yum install mysql-server mysql mysql-devel php-mysql
$ chkconfig mysqld on
$ /etc/init.d/mysqld start
$ yum groupinstall "Development Tools"
$ yum install libxml2-devel httpd-devel libXpm-devel gmp-devel libicu-devel t1lib-devel aspell-devel 
openssl-devel bzip2-devel libcurl-devel libjpeg-devel libvpx-devel libpng-devel freetype-devel 
readline-devel libtidy-devel libxslt-devel
$ wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
$ rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt; rpm -K rpmforge-release-0.5.2-2.el6.rf.*.rpm; 
$ rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm; 
$ yum install libmcrypt-devel
$ wget http://www.php.net/get/php-5.4.0.tar.bz2/from/this/mirror;tar jxf php-5.4.0.tar.bz2;cd php-5.4.0/

$ ./configure \
--with-libdir=lib64 \
--prefix=/usr/local \
--with-layout=PHP \
--with-pear \
--with-apxs2 \
--enable-calendar \
--enable-bcmath \
--with-gmp \
--enable-exif \
--with-mcrypt \
--with-mhash \
--with-zlib \
--with-bz2 \
--enable-zip \
--enable-ftp \
--enable-mbstring \
--with-iconv \
--with-icu-dir=/usr \
--enable-sockets \
--with-openssl \
--with-curl \
--with-curlwrappers \
--with-gd \
--enable-gd-native-ttf \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-zlib-dir=/usr \
--with-xpm-dir=/usr \
--with-vpx-dir=/usr \
--with-t1lib=/usr \
--with-libxml-dir=/usr \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-soap \
--with-xmlrpc \
--with-xsl \
--with-tidy=/usr \
--with-readline \
--enable-pcntl \
--enable-sysvshm \
--enable-sysvmsg \
$ make && make install
$ nano /etc/httpd/conf/httpd.conf
Find: DirectoryIndex
Prepend: index.php
Add to Bottom:
ServerName yourServerName
NameVirtualHost *:80

<VirtualHost *:80>
   DocumentRoot /var/www/vhost/yoursite.com
   ServerName www.yoursite.com

  <Directory "/var/www/vhost/yoursite.com">
        Options FollowSymLinks
        AllowOverride All
        Order Allow,Deny
        Allow From All
  </Directory>
</VirtualHost>
$ mkdir /var/www/vhost /var/www/vhost/yoursite.com
$ cd /var/www/vhost/yoursite.com
$ touch index.php
$ /etc/init.d/httpd restart
$ wget http://git-core.googlecode.com/files/git-1.7.9.2.tar.gz
$ tar -zxvf git-*
$ cd git-*
$ ./configure
$ make && make install


Adobe Labs Authentication

Sat, 18 Sep 2010

If you've ever found yourself stuck trying to get passed an HTTP Authentication using Adobe Browser Labs or Microsoft Expression Web + SuperPreview you can get through it by passing a URL parameter like this:

http://username:password@website.com

Then you should be good to go! Happy CSS Validating!



Sublime Text 2 Hotkeys

Sat, 18 Sep 2010

I've been using Sublime Text 2 for a few days now, and I am blown away. I might actually replace my long used Notepad++ with it, it is amazing! Here are some Sublime text 2 Hotkeys or shortcuts to speed you along!

CTRL + ALT + 1,2,3,4	Multiple Window Panes
F11			Full Screen
SHIFT + F11		Distraction Free Mode

CTRL + Click		Multiple Cursors

CTRL + D		Highlight Closest Word
CTRL + L 		Highlight Line
CTRL + SHIFT + SPACE	Highlight Scope (The paragraph/code block)
CTRL + SHIFT + M 	Highlight to Brackets (If you are in [] or () or {})

CTRL + SHIFT + K	Delete Line

CTRL + /		Code Comment
CTRL + SHIFT + /	Multiline Code Comment

CTRL + F3		(After Highlighting) Quick finds next words
ALT + F3		(After Highlighting) Selects all matching words with multiple cursors

CTRL + SHIFT + F 	Find in Files
CTRL + F 		Find
CTRL + G		Go to Line
CTRL + H 		Find / Replace

CTRL + `		Show Console
CTRL + P 		Jump To Anything (Open file,etc)
CTRL + P .. @		Show functions in current file
CTRL + ]		Indent
CTRL + [		Outdent
TAB			Indent
SHIFT + TAB		Outdent

CTRL + SHIFT + UP	Swap line up
CTRL + SHIFT + DOWN	Swap line down
CTRL + SHIFT + D 	Duplicate Line

CTRL + J 		Join Lines (Try with selecting several)

CTRL + SHIFT + [	Code Fold
CTRL + SHIFT + ]	Code Unfold


Codeigniter Brushup

Sat, 18 Sep 2010

I am doing a brush up and CodeIgniter for an exciting new job move. I've got to familiarize myself with the libraries a bit better. So far it's quite easy, and this framework feels pretty solid.

So I will try to follow up some of that with a few video tutorials on YouTube in the upcoming week or two, however I will be relocating so I'm not certain I'll be publishing very many up front. Subscribe to my Youtube to stay tuned :)