Skip to main content
 

Serve.sh updated for terminal use

After publishing the previous article about serve.sh - the shell script I created to easily serve websites in development - I made some changes to make it easier to run it from the terminal, for example over ssh. I thought I'd share it with you.

One of the problems with the original script was that it was optimized for a GUI setting - ie. start the script by clicking on it from the desktop. However usually I want to run it from the terminal. I don't like typing so I added code to make the script available from any directory to the ~/.bashrc:

export PATH=$PATH:~/bin

Then moved it to that path and renamed it to shave another 3 characters off the syntax:

mv ~/Desktop/serve.sh ~/bin/serve

In addition I noticed that prompting which site should be served was just a workaround for commandline arguments, which are now added. It doesn't check that you entered an argument though. So the new script now requires you to specify which directory you want to serve: to serve the current directory simply run:

serve .

Latest script contents:

#!/bin/bash
my_path=`readlink -f $1`
sudo rm /var/www
sudo ln -s $my_path /var/www
echo Now serving $my_path...

 

Serve.sh - A shell script for serving sites

I am experimenting with using a Linux virtual machine as my web development environment of choice. I store the vm on a removable drive so that I can develop from any location, without having to setup a working environment. Previously I had to check out the repositories, setup a local webserver and I had trouble keeping things working, because every configuration change had to be applied in every location. Now it is all centralized and my life is simpler.

The aim is to make working on projects as easy as possible. I have all projects checked out in a folder called /var/sites. They are mostly PHP projects and because of my shared hosting environment they share a single apache configuration. How can I easily serve them? Having seperate virtualhosts for each project would result in me having to make manual changes on every location again, so this was not the way to go.

Instead I created a simple shell script that creates a symbolic link from the Apache's webroot to the project I am working on:

[gallery link="file"]

#!/bin/bash
echo "Available sites:"
ls  /var/sites
echo
echo -n "Type site to serve: "
read site
if [ -z "$site" ]
then
exit
fi
sudo rm /var/www
sudo ln -s /var/sites/$site /var/www

 

[Patch] CodeIgniter Helper class patch for Textile

For those that do not follow me on twitter (@pacifika), I've created a patched version of Textile, the html generator alternative to Markdown, to make it easier to use in CodeIgniter projects. I have provided the patch and patched Textile on support forums of both projects.

[Patch] CodeIgniter Helper class patch for classTextile.php · Textpattern CMS Support Forum.

After patching, you can just use Textile like this:

$this->load->helper('textile');
$text = Textile("Dude this is *my* code!");

For more information read the post on the forums!

 

How To Search for Asterisk in Excel

A while ago I had to normalize values in an Excel sheet where some of the values contained an asterisk (*) and some did not. However it's not immediately clear how to search for a asterisk. It turns out the escape character is a tilde so searching for ~* is the correct way to do this.

[caption id="attachment_247" align="alignleft" width="300"]Searching for ~* to search for an asterisk in excel Searching for ~* to search for an asterisk in excel[/caption]

 

iTunes App Updates Sync

Wouldn't it be useful if iTunes would (have at least the option to) sync app updates to your device automatically after downloading them? How often I have forgot to sync and find out later in the day that my apps are still out of date.

 

Intranet Migration Strategy

Next week we're turning off our old intranet site so I have setup a "Migration Switch" and a redirection page so that from the moment we turn off the site people will not be able to access it. Because if we actually turn off the site we would receive phonecalls with people needing access to their lost data, and because certain parts of the old intranet are reused in our new one, we instead check if the page is embedded, and if it's not check that the user is on a whitelist of specifically allowed users (us). If this is not the case we redirect them.

Next week we will remove all navigation links to the old intranet, turn on the switch, and remove the documents from the search indexer on the (new) intranet. There must be better terminology for old and new intranet.

Hopefully this will ensure that everything works smoothly.

 

Create an Avatar Specific Communication Channel

Sometimes you will want to create a listener that will not interfere with any other avatar using the same object near you. The basic solution of detecting the owner creates a lot of overhead, therefore a better solution is to have individual channels.

Thanks to Winter Seale, on the SecondLife scripters mailing list:

use an avatar specific
channel. To do that I would define a function:

integer get_channel(key avatar, integer offset){
 return (integer)("0x"+llGetSubString((string)llGetOwnerKey(),-8,-1))
 + offset
 }

Then in your script, use:

 llSay( get_channel( llDetectedKey(number), -1234 ), (string)llDetectedKey(number) );
 ...
 llListen( get_channel( llGetOwner(), -1234 ), "", "", "");

* The reason this is better is that it keeps only one script (the
avatar's) listening on this channel. Without this, a script for every
person with a HUD would have to execute code every time your in world
object was touched.

 

Hear no iPad, see no iPad

What's the Deal With These Windows PC Guys Saying Stupid Things in Australia About the iPad?

Microsoft cannot get a tablet out so it's best to marginalise the whole market.

Via Daring Fireball.

 

A Conversation between Two Chat Bots

splotchy ==> You are a great conversationalist. One of the best I've seen.
jabberwacky ==> So are you. Especially since I can correct your statements to my liking.

via http://www.yiransheng.com:80/2010/03/bot">Yiran's MBA Experience|A Conversation between Two Chat Bots.

 

How I concentrate in a noisy office

We have seven people in a smallish office and typically two people discuss a problem by shouting across the room, while another person is busy making phone calls. As a developer it can be hard to concentrate on programming with all this noise around. That is until I discovered the Inception app.

From the http://inceptiontheapp.com:80/">official website:

Experience your life as a dream [..] This app is a dream machine that transforms the world around you into a dreamworld. It uses augmented sound to induce dreams through the headset of your iPhone and iPod Touch. It will change your perception of reality.

The idea of this app is that you listen to it while you do live your life, and in certain situations it unlocks interactive dreams, for example on a sunny day - or in a busy place. The still dream I'm listening to currently records audio through the microphone and playsback the samples through an echo with pitch-shift, resulting in an ever-changing soundtrack.

In my busy office with headphones on, this successfully creates an interactive soundtrack blocking all communications. I prefer it to a regular radio station and other solutions I've tried.

Update: Unfortunately this app no longer works with iOS 8. Recommendations are welcome!

 

 

Mark Zuckerberg is TIME Magazine's Person of the Year? Where's the "dislike" button?

Facebook's users are not connecting directly with each other. They are speaking to Mr. Zuckerberg, who first writes down and files away everything said, and then maybe relays it to the intended destination, if it suits him.

Mark Zuckerberg is TIME Magazine's Person of the Year? Where's the "dislike" button?

 

 

Rotate PHP logs

Our php.log was nearing 550MB so I was investigating how to rotate the logs. The easiest solution seems to be using logrotate (ubuntu linux) with a script like follows.

sudo nano /etc/logrotate.d/php5
/var/log/php5/*.log {
   daily
  daily
   14 days
  rotate 14
  missingok
  nocompress
  sharedscripts
  postrotate
  apache2ctl graceful
  endscript
}

You can check the configuration by running logrotate --force /etc/logrotate.d/php5

 

 

When is it SQL Server RAM Upgrade Time?

How do you know you need more RAM?

Take a look at your Buffer Cache Hit Ratio, ideally you want to be at 95% plus.

via Less Than Dot - Blog - The SQL Server Memory Leak Confusion.

 

Subversion repository creation rule

Do not use capitals for repository names!
Because when checking out a working copy you will have to specify the respository url case sensitive. Failing to provide the correct case sensitive name result in things might appear to work but you might get access forbidden messages for certain users in some point, and other mysterious errors, such as the svn commit error below:

access to '/svn/project/!svn/act/c50e0f11-eec3-154a-9695-20ec222ad7f3' forbidden

 

InstaPlay 1.0

As a hobbyist music producer, I have a lot of samples of sounds. As I have decided to start organising these, I needed a quick way to fire off samples in wav and mp3 format through Windows Explorer.

So I created InstaPlay. This is a simple sound player. To install it simply unzip it in a directory that's in the path, and then associate wav and mp3 files (and whatever else you want to use) with it.  It also has a few features:

  1. Just double click or run a soundfile to hear it play.
  2. Nice speaker icon in system tray while a sound is playing. Double click it to quit InstaPlay and stop playback.
  3. Run  another sound file to switch playback to that instead.

This program will help you categorize more efficiently as you can move the sound that's being played without pesky 'file in use' prompts.

Download Info
Download the latest version (v1.0 - updated 14/oct/2010)

 

Quote of the week

I'd post the other two examples, but I wouldn't want to take all the fun out of reading the manual.

Source: stackoverflow.com

 

Resume RSync until finished

I noticed a backup of ours did not finish and that the temporary file rsync uses was still listed. A quick google search indicated that rsync had lost its connection. Thanks to Ian Young's article on the subject rsync now resumes when cut off and hopefully the backup will complete now.

 

Progressing your life

Lesson of life: Instead of wishing you were at a certain point with your life, think about something manageable today that you can do towards that goal.