An opinion on including multiple JS files in your project

There are many ways to solve an issue. Some work better than others though their pureness may be questionable. Getting many JS scripts and modules loaded is one such puzzle. I’m not a huge fan of require.js for a number of reasons that are already clearly, and eloquently, expressed by others. It is great at what it does, just not what I really want to use.What I do like is using a tool such as YUI compressor to facilitate delivering robust production code.

The following code is something I found on http://www.laurencegellert.com/ which I have since extended and included into my own projects.

#!/bin/bash

# This script generates the following:
# Combined and minified javascript file for use in the app

echo
"Combining JavaScript into temp files."

# temp.js is the uncompressed file with everything combined
cat
./app/js/jquery.js
./app/js/file1.js
./app/js/scriptX.js
./app/js/xyz.js
> ./app/js/temp.js

echo
"Compressing Combined JavaScript."
java
-jar yuicompressor-2.4.7.jar --type js -o ./app/js/temp.js --charset utf-8 ./app/js/combined.min.js

echo
"Cleaning up temporary files."

rm
./app/js/temp.js

And yes, I do work on OSX as well as Win8.

How to install MemCached with Apache, PHP, and MySQL on FreeBSD

memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

Danga Interactive developed memcached to enhance the speed of LiveJournal.com, a site which was already doing 20 million+ dynamic page views per day for 1 million users with a bunch of webservers and a bunch of database servers. memcached dropped the database load to almost nothing, yielding faster page load times for users, better resource utilization, and faster access to the databases on a memcache miss.

Notes

  • There are definitely steps in this that can be changed, extended, other, but these will get you what you want in a good learning fashion. And learning is key!
  • You can just as easily install memcached on an IIS server.
  • Yes you can download binaries with pkg_add etc. but building will help you literally see what is going where. One just has to make sure that some housekeeping is performed during the build process. This is done with the clean parameter in the make command.
  • This appears to be quite a popular post. Please keep in mind that version numbers change so update the strings below.
To Start

First off build a FreeBSD box. It’s easy, fast, and best of all free once you have the hardware – real or virtualized. Don’t forget to install the ports. You’re going to need them going forward.

For dependency issues we’re going to install all the items in this order:

  1. MySQL Server 5.x
  2. Apache 2.x
  3. PHP5
  4. PDF-Lite
  5. PHP Extensions
  6. MemCached

1: MySQL

Move to the ports folder, specify some build parameters that will helps speed things up a tad.
cd /usr/ports/databases/mysql51-server
make BUILD_OPTIMIZED=yes BUILD_STATIC=yes
make install clean
Edit /etc/rc.conf and add mysql_enable=”YES”
Apply the configuration file: cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf
Assign the master password: /usr/local/bin/mysqladmin -u root password ‘new-password’
Start MySQL: /usr/local/etc/rc.d/mysql-server start

2: Apache

cd /usr/ports/www/apache22
make install clean
Edit /etc/rc.conf and add apache22_enable=”YES”
Edit /boot/loader.conf and add accf_http_load=YES

3: PHP

cd /usr/ports/lang/php5
make install clean  !!In the popup at the least check off “Build Apache Module”
4: PDF Lite
fetch ftp://ftp.swin.edu.au/gentoo/distfiles/PDFlib-Lite-7.0.2.tar.gz
sudo mv PDFlib-Lite-7.0.2.tar.gz /usr/ports/distfiles/

5: PHP Extensions
cd /usr/ports/lang/php5-extension 
make install clean !!Confirm that sockets is selected.
Apply the configuration file: cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini
Enabling Apache to run PHP
Edit the Apache configuration file /usr/local/etc/apache22/httpd.conf and add
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Change DirectoryIndex index.html to DirectoryIndex index.php index.html
Start Apache /usr/local/etc/rc.d/apache22 start
6: MemCached
cd /usr/ports/databases/pecl-memcache
make install clean
cd /usr/ports/databases/memcached
make install clean
Edit /etc/rc.conf and add memcached_enable=”YES”
Start MemCached with /usr/local/bin/memcached -d -u nobody
Confirming MemCached is running
Run netstat -an to confirm that a process is listening on TCP 11211
It may also be useful to run /usr/local/bin/php -i | grep -i ‘memcache’

Installing OS X Snow Leopard From a USB Drive

Just like with most other versions of OS X, 10.6 Snow Leopard can be installed from a USB drive which is especially beneficial if you’re a Macbook Air user…

Before you start make sure that you have enough space , Leopard is just a shy over 6.2Gigs, and that your USB drive is bootable.

  1. Using DiskUtility select the USB drive
  2. Format it as Mac OS Extended (Journaled.) Give it a sensible name in case you need it later
  3. Still in Disk Utility, use the restore option with source = DVD and destination = USB drive
  4. Start the restore and wait. Should be less than 15 minutes
  5. Connect the USB drive to the MAC and reboot / boot it holding the option/alt key down until you see a list of available volumes.
  6. Select the USB volume and install.

iPhone OS X development course on iTunes University from Stanford

Stanford University has posted another complete lecture and presentation slide series for the Winter 2010 term’s iPhone Application Development course.

Downloaded from iTunes more than 4.4 million times last year this latest series of closed-captioned! lectures are now updated to include APIs from the latest iPhone OS 3.1 SDK OS X etc.

There’s no support available so don’t even try to ask them (Stanford ) for help.

Handbrake goes 64bit with a 0.0.1 release

A minor thing for most but for those who care after a year without any updates, the developers responsible for the “mighty fine” video transcoder Handbrake have released version 0.9.4 of the open-source software. With such a small change in the version number, it would be easy to assume that there are not very many new things included, but that assumption really couldn’t be further from the truth. In total, there have been over 1,000 changes since 0.9.3 and, while they might not all be life-changing, many of them make for a better user experience though the removal of the presets is a blessing/curse at times. The 64bit update apparently increases overall speed by 10%.

As with version 0.9.3, you still need to have VLC installed to rip video from a DVD

How to rename your iPhone application in Xcode…

To rename your application, modify the “Product Name” build setting, which is part of the Packaging build settings collection.

Follow these steps for changing an application’s name in Xcode:

  1. In Xcode, double-click the target’s name under “Targets” in the Project window.
  2. Choose the Build pane from the ensuing Info window.
  3. Select “All Configurations,” “Debug,” or “Release” from the Configuration popup menu.
  4. Note that the application’s name will only be changed for the configuration you selected.
  5. Select the Packaging collection and assign a new name to “Project Name.”

Saving a packet trace in Mac OS X

  1. Log in with an administrator account.
  2. Open Terminal (/Applications/Utilities).
  3. To start the trace, you will type a command, followed by the Return key. The command you choose needs to match the way your computer connects to the Internet.

    For built-in Ethernet, type:

    sudo tcpdump -i en0 -vvv -n -s 0 -w ~/Desktop/DumpFile.dmp

    Note: Both “en0” and “-s 0” include a zero, not the letter O.

    For AirPort, type:

    sudo tcpdump -i en1 -vvv -n -s 0 -w ~/Desktop/DumpFile.dmp

    Note:-s 0” includes a zero (0), not the letter O.

    For a VPN connection or a dial-up modem (PPP), type:

    sudo tcpdump -i ppp0 -vvv -n -s 0 -w ~/Desktop/DumpFile.dmp

    Note: Both “ppp0” and “-s 0” include a zero, not the letter O.

  4. When prompted for a password, enter the one for your administrator account. You’ll see a message in Terminal such as “tcpdump: listening on en0…” which lets you know the computer is actively capturing network traffic.
  5. Now, perform the network activities that involve the issue you’re trying to capture packets for.
  6. When you’re ready to stop capturing packets, click the Terminal window to bring it to the foreground.
  7. Press Control-C.

Grand Central Dispatch ported to FreeBSD

Those who know me know that I am a huge proponent of FreeBSD. Since I first toyed around with it with version 2 and got comfortable starting with version 3 it has consistently impressed me with it’s features and abilities. Now Apple’s Grand Central Dispatch, which was recently open sourced, has been ported to FreeBSD from OS X and is planned to be included by default in FreeBSD 8.1. Also known as libdispatch, the API allows the use of function-based callbacks but will also support blocks if built using FreeBSD’s clang compiler package. FreeBSD’s porting efforts should help to make GCD easier to port to other operating systems with conventional Unix or Unix-like kernels, including OpenBSD, NetBSD, Linux, and Solaris.


If you’re new to FreeBSD a key thing about it is its release process.

Murray Stokely recently released the FreeBSD Release Engineering paper which goes to great length in detailing the different phases of the release engineering process leading up to the actual system build as well as the actual build process and very important discussion on the future directions of developmen. I would highly recommend reading through it. Here’s an excerpt:

This paper describes the approach used by the FreeBSD release engineering team to make production quality releases of the FreeBSD Operating System. It details the methodology used for the official FreeBSD releases and describes the tools available for those interested in producing customized FreeBSD releases for corporate rollouts or commercial productization.

The development of FreeBSD is a very open process. FreeBSD is comprised of contributions from thousands of people around the world. The FreeBSD Project provides anonymous CVS[1] access to the general public so that others can have access to log messages, diffs (patches) between development branches, and other productivity enhancements that formal source code management provides. This has been a huge help in attracting more talented developers to FreeBSD. However, I think everyone would agree that chaos would soon manifest if write access was opened up to everyone on the Internet. Therefore only a “select” group of nearly 300 people are given write access to the CVS repository. These committers[5] are responsible for the bulk of FreeBSD development. An elected core-team[6] of very senior developers provides some level of direction over the project.

The rapid pace of FreeBSD development leaves little time for polishing the development system into a production quality release. To solve this dilemma, development continues on two parallel tracks. The main development branch is the HEAD or trunk of our CVS tree, known as “FreeBSD-CURRENT” or “-CURRENT” for short.

A more stable branch is maintained, known as “FreeBSD-STABLE” or “-STABLE” for short. Both branches live in a master CVS repository in California and are replicated via CVSup[2] to mirrors all over the world. FreeBSD-CURRENT[7] is the “bleeding-edge” of FreeBSD development where all new changes first enter the system. FreeBSD-STABLE is the development branch from which major releases are made. Changes go into this branch at a different pace, and with the general assumption that they have first gone into FreeBSD-CURRENT and have been thoroughly tested by our user community.

In the interim period between releases, monthly snapshots are built automatically by the FreeBSD Project build machines and made available for download fromftp://ftp.freebsd.org/pub/FreeBSD/snapshots/. The widespread availability of binary release snapshots, and the tendency of our user community to keep up with -STABLE development with CVSup and “make world”[7] helps to keep FreeBSD-STABLE in a very reliable condition even before the quality assurance activities ramp up pending a major release.

Full Paper here

Compiling Aircrack on 10.6 Snow Leopard

First off get it by using:
svn co http://trac.aircrack-ng.org/svn/trunk/ aircrack-ng
Now, you need to edit common.mak to build for a 32-bit architecture using 10.5 headers, and have it use gcc-4.0 instead of 4.2.
Find this line:
CC = $(TOOL_PREFIX)gcc
and replace with:
CC = $(TOOL_PREFIX)gcc-4.0
Then find this line:
CFLAGS ?= -g -W -Wall -Werror -O3 -Wno-strict-aliasing
and replace with:
CFLAGS ?= -g -W -Wall -Werror -O3 -Wno-strict-aliasing -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk
Go back to Terminal and:
cd aircrack-ng
make
sudo make install
The binaries can be found here: /usr/local/bin/

Remember you can only really use it to poke at already captured data…