Showing posts with label Mac OS X. Show all posts
Showing posts with label Mac OS X. Show all posts

Tuesday, November 22, 2011

Yii. Rbac. No such file or directory (trying to connect via unix:///var/mysql/mysql.sock

To resolve the error in the title of this post:

1. Set the following in "/etc/php.ini"

pdo_mysql.default_socket=/tmp/mysql.sock
mysql.default_socket = /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock

2. Comment out the following line in "/protected/config/main.php" of your app:

'ipFilters'=>array('localhost','::1'),


3. Restart Apache:

sudo apachectl restart

Wednesday, January 12, 2011

Loop alphabet objective c

Objective C makes it easy:

NSMutableArray *alphabetArray;
alphabetArray = [[NSMutableArray alloc] init];
for(char c = 'A'; c <= 'Z'; c++)
{
[alphabetArray addObject:[NSString stringWithFormat:@"%c", c]];
}

Or if you want to do lower case:

NSMutableArray *alphabetArray;
alphabetArray = [[NSMutableArray alloc] init];
for(char c = 'a'; c <= 'z'; c++)
{
[alphabetArray addObject:[NSString stringWithFormat:@"%c", c]];
}

Thursday, December 16, 2010

Example for loop using bash script on Mac

Be careful when doing this... Note that ALL SPACES MUST BE EXACT. Or else bash will cry:


#!/bin/bash
a=1
while [ $a -le 10 ]
do
echo "Loop number $a"
a=$(( $a + 1 ))
done

Shell scripting for Mac (using bash)

An easy example using vi:


1. Type 'vi myscript' into the terminal.

2. Press 'i' for insert, and type your file. For example:

#!/bin/bash
echo "This is my script. Woo"

3. Press 'esc' key to exit insert mode.

4. Press shift+ZZ to save the file and exit.

5. Change the access rights on your file so it can be executed. For example:

chmod -x myscript

6. Execute your script by typing:

./myscript


That should get you started :)

wget for Mac

You could follow the instructions on here: http://www.mactricksandtips.com/2008/07/installing-wget-on-your-mac-for-terminal.html


Or, you could just use 'curl'

Wednesday, December 08, 2010

Make a PDF smaller in Mac OS X without any fancy tools

This has been frustrating me for a while. While Preview is an awesome bundled tool and all, it seems to think it is acceptable to create HUGE PDF files.

In order to not be hated by my EMail recipients, (see this comic strip: http://theoatmeal.com/comics/email), I tried to make the file size smaller. Here's what I tried and failed.

Also; Being the stubborn ass that I am, I wanted to do this without installing any extra tools.


My Original Size: 7 Pages of typed letter (i.e. a signed NDA agreement) at 3.8Mb (Ridiculous)

Attempt 1:
Open PDF in preview, click on File->Save As, Select 'PDF' and Quartz Filter=Black and White.

Fail: The size reduced to 594kb, but most of the text was faded out or missing. Not good.


Attempt 2:
Same as above; Open PDF in preview, click on File->Save As, Select 'PDF' but this time Quartz Filter=Reduce File Size.

Fail: Size was amazingly 217kb, but nothing could actually be read since the text had been totally blurred out. Not acceptable.


Attempt 3:
Same as above; Open PDF in preview, click on File->Save As, Select 'PDF' but this time Quartz Filter=Grey Tone.

Fail: Size was a whopping 15Mb.

Things were starting to get annoying.


So here's what finally solved it. Which is not pretty by any means.

1. Export each and every page in the PDF to JPEG format one by one.

2. For each new JPEG file, click on Save As->JPEG, then set the quality nearer to the 'Least' setting on the slide. Mine made each file about 100kb each.

3. Recreate the PDF by opening the first JPEG file in the series in Preview, then clicking View->Sidebar-Show Sidebar. Then drag and drop each of the JPEG files into the sidebar in order.

4. Select all the images in the Sidebar and then click on File->Print Selected Images.

5. Click on PDF-Save as PDF to create your new file.


My final file was 700kb and just as readable as the original.


Finally a win. Albeit a pyrrhic win.


For more about manipulating PDF files, try these following posts:

Free and Fast Way to Accurately Convert PDFs to Excel Files

Printing to PDF with doPDF

Concatenating PDFs with Ghostscript

Wednesday, October 20, 2010

Total Commander/Midnight Commander for Mac

So there comes a time in life when you need Total Commander, Midnight commander or any of the norton commander clones out there, but you're using a Mac and there's no such thing. That's what happened to me today.

So, later I realized that Total Commander is just a clone of Midnight Commander, which is a clone of Norton Commander (or whatever order of cloning may have taken place).


But then...

I found muCommander. Which has a build for Mac OS X. Woohoo!

Download it at http://www.mucommander.com/


Thursday, September 23, 2010

Del Key on Mac

Call me slow, but I've only just found out how to use the missing 'del' key on a Mac keyboard.

The shortcut is: fn button + delete.

Sunday, July 25, 2010

Enable .htaccess in Mac OS X Snow Leopard Apache

To enable .htaccess files in Mac OS X Snow Leopard:

1. Open terminal. Go to

cd /etc/Apache2

2. Then edit httpd.conf by typing:

sudo vi httpd.conf

3. Search for 'AllowOverride' by typing

/AllowOverride (+ return)

4. Change the line to:

AllowOverride All

(by using 'i' to insert and 'esc' to finish inserting text)

5. Search again for 'AllowOverride' by typing

/AllowOverride (+ return)

6. Change to:

AllowOverride All

7. Repeat these steps until all instances of AllowOverride are set to 'All'

8. Then save the file by pressing SHIFT+ZZ.

9. Then you need to edit your own website's file. CD to 'users' by

cd users

10. Then look for your conf file by typing:

ls

11. My file is called mark.conf, so I edit it by typing:

sudo vi mark.conf

12. Again, make sure the respective line reads:

AllowOverride All


13. Restart Apache by disabling then re-enabling 'Web Sharing' in System Preferences.






Saturday, July 24, 2010

MySQL for Mac OS X Snow Leopard

Simplified:

1. Go to here to get MySQL for Mac: http://dev.mysql.com/downloads/mysql/

2. Download the 32 bit .dmg archive. Click 'No thanks, just take me to the downloads!'

3. Run the archive and installer. (i.e. the mysql-5.x.xx-osx10.6-x86.pkg)

4. Set your root password by opening terminal and entering:

cd /usr/local/mysql/bin
sudo ./mysqladmin -u root password mysecretpassword

(I couldn't figure out the default password, nor was I asked to enter one during the installation)

5. Login and test it.

./mysql -u root -p

6. Open the dmg file you downloaded in step #2. Run the MySQLStartupItem.pkg.

7. Download MySQLWorkbench from http://dev.mysql.com/downloads/workbench/5.2.html if you need a GUI.