Thursday, October 20, 2011

Customize Terminal for Mac OS X Snow Leopard

Wanted to permanently change the default prompt used in the Mac Terminal as well as add other customizations to Terminal behaviour. Found mixed recommendations on the web for how to do this, but none of which worked for me on a MBP with OS X 10.6. In the end I just guessed at a few things at eventually did the following:

- Edit the file /etc/bashrc (that's right, not '.bashrc' but simply 'bashrc').
- Append the desired value for $PS1, which overrides the definition already present in the file.

For example, to customize my prompt and have all 'ls' commands become 'ls -al' I appended the following:

PS1='\u: \w\$ '
alias "ls"="ls -al"

Thursday, October 13, 2011

Notes on Installing Lighty (lightTPD) + PHP on Mac OS X

Although, in general, a relatively easy process when done as described here, it still wasn't w/o issues for me. The two main articles I based the install off of are as follows:

1. Install PHP5, lighttpd and Imagick on Mac OS X Leopard
2. Symfony flying with Lighttpd on Mac OS X 10.6

In my case I was using Snow Leopard (10.6) and didn't care about Imagick or Symfony so simply ignored those parts. My system is also already a running MAMP (Mac+Apache+Mysql+Php) so in the end I configure Lighty to run on port 81 and, for the sake of this blog, I'm not bothered with installing MySQL because I already have it. If you need to install MySQL, however, there's now a self-installing package for Mac OS X so it should be a breeze.

I found the following useful for if things go wrong:

- Check if lighttpd was loaded AND enabled using the terminal command "sudo launchctl list".
- Open up the ever-handy Console utility (Applications>Utilities>Console) and view the Console Message or system.log. If Lighty is trying to start but failing it should show a message about every 10 seconds explaining why it failed.

INSTALLING LIGHTY

In my case, the main reason the default installation didn't work is because of the following default Lighty configuration:

server.network-backend = "linux-sendfile"

Which results in the following error: "server.network-backend has a unknown value: linux-sendfile"

Not sure what the 'best' value should be on a Mac, but simply changing this to:

server.network-backend = "writev"

worked for me.

I also tripped on the following, so watch out! The modules.conf file says "at least mod_access and mod_accesslog should be loaded" and then the server.modules variable shows only "mod_access" by default. So I added "mod_accesslog" but this only stopped Lighty from loading. So don't do this! Later realized that the accesslog module is already included in the master lighttpd.conf file.

Also, you do NOT need to add modules to the server.modules variable if there's already a predefined .conf file in the conf.d directory. Simply un-comment the line in modules.conf that includes the appropriate file. This is because the include file does this for you.

INSTALLING PHP

Again, mostly just followed the instructions. Below are things that varied for my install or selections I made when instructions differed.

1. The install command in the Imagick instructions is out-dated and will not install MySQL. The command in the 'Symfony' instructions look more up-to-date but still didn't work for me. I had to instal several extensions separately. The commands I used were

"sudo port install php5 +fastcgi +pear"
"sudo port install php5-mysql"
"sudo port install php5-xsl"
"sudo port install php5-gd"
"sudo port install php5-mbstring"
"sudo port install php5-iconv"
"sudo port install php5-curl"
"sudo port install php5-openssl"
"sudo port install php5-soap"

Installation of php5-mysql output the message "To use mysqlnd with a local MySQL server, edit /opt/local/etc/php5/php.ini and set mysql.default_socket, mysqli.default_socket and pdo_mysql.default_socket to /opt/local/var/run/mysql5/mysqld.sock" but I just ignored this (tried doing it, as well as making the appropriate directory with group permission for mysql user, but then Lighty connections to MySQL started failing).

2. Config files were located at /opt/local/etc/php5 and I copied from the dev default file since that's what I'll be using Lighty for.

3. Didn't bother with changing the extension_dir variable.

4. My install came with a hierarchical .conf file structure so enabling PHP involved multiple .conf files as opposed to a single lighttpd.conf file. This involved...
- un-comment the line "include "conf.d/fastcgi.conf" in modules.conf
- adding the following to the end of the fastcgi.conf file:

fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => socket_dir + "/php-fastcgi.socket",
"bin-path" => "/opt/local/bin/php-cgi"
)
)
)

- Note that the socket directory uses a pre-defined variable, unlike the fixed
paths given in the referenced instructions.

5. Setup ownerships and permission mostly according to the 'Symfony' instructions, but my paths were based on variables defined in lighttpd.conf. For example, the pid file path was
server.pid-file = state_dir + "/lighttpd.pid",
which was equivalent to
"/opt/local/var/run/lighttpd/lighttpd.pid".
As a result, the folders and location of files I needed to give www ownership to varied from those in the 'Symfony' instructions.

6. Note that my install had no lighttpd.wrapper file, so they start/restart command were not applicable. I had to start/restart using load/unload with the launchctl command. For example:
"sudo launchctl load /opt/local/etc/LaunchDaemons/org.macports.lighttpd/org.macports.lighttpd.plist"

ADDING VHOSTS
For this I used the simple_vhost module.

1. Un-comment the following line in modules.conf

include "conf.d/simple_vhost.conf"

2. Edit simple_vhosts.conf accordingly. For example,

simple-vhost.server-root = vhosts_dir + "/"
simple-vhost.default-host = "lighty.anotherlocalhost"
simple-vhost.document-root = "/anotherlocalhost/"

In this example above, the path

vhosts_dir + "/lighty.anotherlocalhost/anotherlocalhost/"

MUST exist. That is, the path to the doc-root includes a directory named after the default-host variable.

3. Add an entry for lighty.anotherlocalhost into you hosts file (/etc/hosts) and clear the cache for this (terminal command: "dscacheutil -flushcache").

Saturday, October 1, 2011

Handling Upfront Payments with FrontAccounting

Maybe it's just because I'm new to all this accounting stuff, but I didn't find the method of logging upfront payments in FrontAcounting very intuitive. Maybe it's similar for all accounting software but, in anycase, here's how I worked it out.

This applies to sales with an upfront (aka, prepaid, on demand, paid in advance) payment method. For example, you receive a payment online via PayPal which goes directly into your PayPal account, and then you process the order accordingly with no further invoicing required. I found that there are 2 different ways to handle this in FA which I will refer to as the Traditional Method and the Quick Method. I call the longer method traditional because it was once the only option before FA added 'Direct' invoicing.

TRADITIONAL METHOD:

PRE-REQ: By default, FrontAccounting does not create a prepayment payment option so, if not already done, you must do this manually. Under Setup>Payment Terms, create a new payment option of Payment type 'Prepayment'. For example, create one named PayPal.

[1b]
When order is received create an applicable sales order (Sales>Sales Order Entry) and select the desired prepayment option (that you should have created), such as PayPal, for the Payment field.

[2]
Once the order has been processed/shipped create the Delivery Note & Sales Invoice by first using Sales>Delivery Against Sales Orders and selecting the sales order in step 1, then using Sales>Invoice Against Sales Delivery and again select the same sales order. This step will generate the appropriate Delivery Note and Sales Invoice entries in the journal. The Delivery Note handles inventory transactions while the Sales Invoice debits the Accounts Receivables for the order amount. Optionally, you can combine steps 1b & 2 using Sales>Direct Invoice.

[3]
Add payment using Sales>Customer Payments and select the sales order created in step 1 (note that sales order will only show here if it was created with a pre-pay payment type). Also remember to select the appropriate receiving bank account (such as PayPal). If applicable, as is the case with PayPal, include the transaction fee in the Bank Charge field*. This step creates a Customer Payment entry in the journal which essentially transfers Accounts Receivables (as created by the previous step) to an actual bank account.

For cases where some or all of the revenue received from the sale can be reported prior to shipping, the additional steps below can be added to the process. Note, however, that according to accounting rules revenue from retail sales must, in most cases, be reported only once the product has shipped.

Add this step before 1b:
[1a]
Make a customer payment (Sales>Customer Payments) for the amount that is to be received as income prior to completing the order.

Add this step after 3, although step 3 may no longer be necessary if revenue received prior to sales order was the complete amount:
[4]
Now assign the Sales Invoice to the Customer Payment using Sales>Allocate Customer Payments or Credit Notes. There you should see the Customer Payment you created in step 1 which, after you select the allocate icon, you can assign to the Sales Invoice created in step 2.

*NOTE: Bank charges by default go to the Interest & Bank Charges account. If you'd like to track PayPal fees to a different account you can create one and assign it as the Bank Charges Account under Setup>System and General GL Setup. However, because this option is not bank specific ALL customer/supplier payment charges will now go to this account. If you only use PayPal for payments that involve charges, this is OK, otherwise you'll have to live with all charges being clumped together into the default account.

QUICK METHOD:

The much (much much) quicker method involves just a single FA form but you cannot control the date of journal entries (all entries occur at once), you cannot enter an optional bank charge, and the order amount must be paid in full in one shot.

PRE-REQ: You must create your PayPal account as a Cash Account and you must relate this account to Point of Sale (POS) transactions under Setup>Points of Sale as well as under Setup>User Accounts Setup>User's POS.

[1]
Create a Direct Invoice (Sales>Direct Invoice) and select the "Cash Only" Payment type. If you configured POS correctly (see PRE-REQs above) the PayPal cash account should be the Cash Account under the Cash Payment section. Place the invoice and that's it! This will automatically create the Delivery Note, Sales Invoice, and Customer Payment journal entries which ultimately puts money directly into you bank account. For more details on what these journal entries do refer to the Traditional Method.

Wednesday, September 28, 2011

Notes on FrontAccounting Install

After comparing several book-keeping solutions (see Comparison of accounting software) I decided to go with FrontAccounting. This would be a fitting choice for me because it's PHP based and this would make any future integration with existing software (also PHP based) easier. It also appeared to have a nice up-to-date interface.

Here are some notes of things I found were left out of the installation procedures/manuals, at least for version 2.3.7.

- Install requirements page will give this bogus error about a 'config_db.php' file not being writable. What it's really trying to say is that it cannot create the file because it doens't have write access to the root FrontAccounting directory. For the sake of installation, give the directory that you're running FrontAccounting from full r/w access (777).

- Install requirements page mentions that directory '../company/0' needs to be writable but forgets to mention the 'company' directory itself also need to be writable if you plan on adding any more than 1 company. If you forget to do this, FrontAccounting will allow you to add additional companies anyways but then you'll get strange behaviour and won't be able to delete them.

- If your using the latest release of MySQL, all the .sql script files under the 'sql' directory will need to be updated. Replace all 'TYPE' occurrences with 'ENGINE'.

- To set desired currency, remember to set under Setup>Company Setup>Home Currency as well as for each applicable bank account under Banking & GL>Bank Accounts. You must set the currency for the bank account before any transaction is created that relates to it, otherwise FrontAccounting will not let you change the currency, even if you delete relevant entries. So be sure to set the proper currency for each bank account before making any journal/GL entries.

- When adding a new company, remember to assign a new script password even though it's optional. I found that if I didn't do this the results were unexpected. In my case, the password for the demo user of the demo company was assigned, even though I would have expected the existing admin password to be used.

- Keep in mind that certain admin features available under setup (such as create new company, system diagnostics, etc.) are only available if logged in as the admin to the first company that was created. In my case, that was the demo company.

- If you are installing extensions (Setup>Install/Activate Extensions), remember to activate any applicable access afterwards under Setup>Access Setup or you won't be able to access the installed extension. Additionally, you must do this for each user in each company that should be able to access the extension. At least this was the case for me for the "Import CSV Items" extension.

Here are some other non-setup related tips I found helpful:

- If you need to edit transactions from a year other than the current, you can set the active year under Setup>Company Setup>Fiscal Year.

Conclusion to Strange Hard Drive Behaviour on MBP

Looks like issues described in my previous post (Strange Hard Drive Behaviour On MacBook Pro), regarding plenty of intermittent hangs and beach-balls on a MacBook Pro (MBP) with OX Snow Leopard, can all be blamed on the hard drive. Despite the 'rebirth' I experienced with it, it ultimately just deteriorated again over a relatively short amount of time (about 2 weeks), eventually rendering the MBP once again useless.

I've had a hard drives fail on me before and have known of plenty others, but this is the first one I've come across one that still functions, but has some sort of major handicap. In fact, I still use it externally to successfully backup the MBP, it just takes a lot longer than it should.

So despite symptoms that closely resembled issues described in the threads noted below. My issue was not solved by any amount of software updating or O/S reinstalling.


Random freezing from Snow Leopard - total lock-up for about 30 seconds

INSERT-HANG-DETECTED: System Freezes in Snow Leopard and Leopard

Thursday, September 15, 2011

Macs: Allowing users of the same group to edit your files

See: Mac OS X Server v10.5, 10.6: Setting a custom umask

This is how I like the Mac setup because the MBP I use has two accounts, both of admin level. W/o this change, the other user can't do anything to files you've created, even if they are shared with you. Incase that article ever goes away, here's the important part of it:

Umask for user applications

In Mac OS X v10.5.3 and later, you can create the file /etc/launchd-user.conf with the contents "umask nnn". Do not include the quotation marks and replace nnn with the desired umask value, such as 027 or 002.

This will set the user's umask for all applications they launch, such as Finder, TextEdit, or Final Cut Pro, and control the permissions set on new files created by any of these applications.

Umask for system processes

In Mac OS X v10.4 and later, create the file /etc/launchd.conf with the contents "umask nnn". Do not include the quotation marks and replace nnn with the desired umask value, such as 027 or 002.

This will set the umask for all processes. Changing this value is strongly discouraged because it changes the permissions on files used by the system software. If the permissions are too restrictive, dependent software may not work. If the permissions are too open, they may introduce security issues.

Monday, September 5, 2011

Strange Hard Drive Behaviour On MacBook Pro

Experienced some strange and, thus far, inexplicable behaviour between a MacBook Pro and its hard drive. The Mac would intermittently go off into lah-lah land, allowing the user to do nothing more than move the mouse cursor that had turned into the typical spinning kaleidoscope. It was like the Mac entered a temporary coma upon random user interaction like opening a folder, starting an app, browsing the internet... pretty much anything could trigger it. However the length of time that the Mac remained in the coma seemed to increase with each occurrence, sometimes taking 5+ minutes to wake up. Eventually, it would just stay in this coma state requiring a forced restart. Note that during each coma minimal life could be detected (mouse still moves, some mouse-overs still work, menus may still drop-down) and I could always put my ear to the laptop and hear the hard drive clicking away like mad in search of something it never seemed to find.

At first, forced shut-downs resulted in the Mac taking 20-30 minutes to boot up again. But eventually each forced shut-down resulted in the Mac "loosing track" of the hard drive. Booting up the Mac in Verbose mode yielded various complaints all related to issues with the hard drive (could not find it, I/O errors, time-outs, etc...) and eventually the screen would just continuously roll-over with error messages. If not in Verbose mode you'd miss out on all this fun and be left staring at an Apple logo slowly burning itself into your LCD.

Sometimes, enough forced restarts would get the Mac to boot again (albeit 30 minutes later), but most times required a boot from the system disk, followed by a so-called 'successful' disk repair, followed by another 30 minutes of boot up, followed by more random comas, followed by another forced shut down,... and so the cycle continued until even a boot from the system disk could do nothing. Why? Because at that point the Mac could no longer even mount the drive! (Note: in case you're wondering, I wasn't continuing the cycle just for fun but, rather, with each attempt trying to recover data from the drive before it's suspected death). Now, with the Mac not even finding the drive, I assumed it dead... Wrong!

Now things get interesting. A scheduled trip to a Mac 'genius' at the local Mac store resulted in the 'genius' proclaiming my hard drive dead and suggest I buy a new one off the internet. Ok, I'm cool with that, but I still want to know WHY the stupid thing died after just 1-1/2 years. Thankfully the 'genius' said getting to the drive was easy as cheese and instructed me to just take out the screws on the bottom. Right on, let see what's in this baby! So I took the drive out and popped in another to see if I could isolate the issue. As suspected, the Mac finds the new drive w/o issues and I'm even able to re-install OS X and go on about life as usual. But, I decide not to do that. Wanting to know why the drive died I do a little more poking around and find that with a USB-SATA cable, my WinXP laptop can detect it just fine. Unfortunately, due to the Mac format, i can't actually read it and recover anymore data. If I do the same on the Mac (plug it in over USB), it fails to mount. So I figure, since my WinXP machine can at least detect it, I'll run some tests.

First I do the obvious thing and consult the mfr of the drive, Hitachi, for a drive test. Man, that was a bad idea! Their drive test, called Drive Fitness test (DFT), which you place on a boot-up disk, first failed to do anything other than spin the CD-ROM drive. After much wasted time troubleshooting, I eventually burned the supplied ISO again to find it now works... kind of. It works on my old WinXP box but requires the drive to be internal and my old WinXP box doesn't support SATA. So I try the boot disk on both the Mac and a newer WinXP box. With both the new machines I just get a bunch of HIMEN/XMS errors, blah blah blah more errors, and it dies. Many minutes more wasting time troubleshooting and still no go. WTF Hitachi! So then I go to the Seagate website and download their SeaTools boot-up ISO, also for testing drives. This time it works fine, on all machines. Thanks Seagate! So I run the boot disk on the newer WinXP box but the Seatools 'short' test says the drive is fine. So I install the drive back in the Mac just to double-check and... no dice. Ok, so let's try the 'long' test. This one really is long. A good 3 hours later, the result is a big fat PASS. Well, some suggestions I came across on the web say that some issues may only be detected by mfr software. Except in this case the mfr s/w doesn't do diddly squat! Again, WTF Hitachi! Ok, so for some reason I decide to try the same long test with the drive installed in the Mac. So I remove the other drive (with the new OS X install) and put the original drive back in, forget to boot up off the disk, and the Mac starts up fine (yes, on the F'd up hard drive) as if nothing ever happened. Ok, I'll say it again, WTF!

So, somehow a 'long' test (which explicitly states it doesn't affect drive data) using Seagate s/w on a Hitachi drive somehow cured the drive. Well, I doubt that, but here's my theory. I think the Mac got into some buggy state that was "not happy" with the drive. Maybe some stored RAM parameters (PRAM/NVRAM) were causing the issue. I learned later that these can be reset, but too late to try now. The drive at hand uses the relatively new "GPT Protected" partition format so maybe there's still some bugs to iron out in the interface between OS X and this partition type. In any case, I'm convinced the state of the drive never changed but the state of Mac easily could have during use with the temporarily installed drive with newly installed OS X. The fact that the problematic drive started to work again after the long test is surely just coincidence.

PS. Part of why I'm going on and on and on about this (sorry about the length) is that I've heard multiple other cases where MacBook owners have had their hard drives declared dead long before their expected life. Maybe some of these people replaced a perfectly good drive! If you end up in this situation, maybe this blog will save your ass. Or rather, your hard drives ass.

Thursday, August 4, 2011

Opening multiple VLC windows on Mac

Searching through forums to figure out how to open another instance of VLC on a Mac brings up some pretty mixed results. So here's the method that actually works. I'm sure this applies equally well to any other application as well. Open the terminal and run the following command:

open -n /Applications/VLC.app

The -n option is what tells Mac to open another instance even if one already exists.

NOTE: Although you have two VLC icons in the dock now, dragging files to the icons will not work correctly. The Mac will link the icons to the same instance of VLC. You'll need to drag files to the player control panel instead or just open them through the file menu.

Wednesday, August 3, 2011

Reporting Lost Non-Tracked Mail to Canada Post

So today I learned that there is a formal method to report lost non-tracked mail (such as lettermail) to Canada Post. Unfortunately, there is no fast an easy way to do this online. If it were a tracked item, you could open a ticket online via the Canada Post website, but for non-tracked items there's no such luck. However, I found that you can call Canada Post customer service (1.800.267.1177) and they will officially record the matter and give you a reference # regarding the issue. I was hoping they would record where the item was dropped off (location of Canada Post depot) but they only record the recipient postal code. So they'll maybe catch trends of mail lost at the distribution center used for the recipient but, unfortunately, will never catch any trends of employees loosing/stealing mail where it was dropped off. Ah well, better than nothing. So, if mail continues to get lost on route to the same locations you can call back Canada Post with your list of reference #'s and request that some action take place. Hmmmm.... I wonder if any action actually would take place in that scenario??? Otherwise, they claim they'll simply use the reports to improve their services.

Monday, January 3, 2011

J-T Topo For New Geology Tour Road Bouldering, Featuring Scum Bag

In the Fall of 2008 I was caught in yet another wind-blasted day in Joshua Tree and set off down Geology Tour Rd in search of climbs out of the wind and stumbled upon a set of secluded boulders in which lay one surprisingly sick looking line.  I first wrote off the line as personally unfeasible, but vowed to come back and try it anyways because it looked so enticing.  Not at all green to exploration of Joshua Tree problems, I knew the line was uniquely featured and the boulder itself of unusually solid rock for the area.  A true gem just a stones throw from developed climbing in the Towers of Uncertainty.

I returned in the Winter of 2008 to begin work on the new line and eventually linked all the top-half and bottom-half moves, but an ascent from sit-down to top-off would take more tips than I had to offer for that season.  On the positive side, this allowed for additional exploration of surrounding boulders and in-turn revealed plenty of fine warm-up problems and other fun moderates.  I returned in Spring of 2009, with support (spotting) from my lovely wife and eventually bagged it.  A special thanks to my daughter Fiora for cheering me on!  I named the problem Scum Bag (V?).  It's not the hardest thing out there, but I find it interestingly beta intensive and worthy of becoming a Joshua Tree classic.

I haven't developed enough hard lines to give it a decent rating, but I found it harder than V10's I've done.  Then again, it also felt easier than some V8's I've tried!  Anyways, let's just say it's harder than most JT probs.

Although I made a topo of the area shortly after doing the problem, it was accidentally wiped from my computer.  I've since tried to re-make it, but the long stretch from when I was last there means some ratings are coming from vague recollection.  Anyways, take a look (embedded below) and if you're in Joshua Tree for some bouldering check these out and give your feedback!

(Note: You can use the 'Open in new window' button, top-right, to save a copy of the file.)