Chris Tate-Davies

An archive of helpful tit bits of information for development, and probably some stuff that is incomplete, wrong or boring…

Showing hidden files on Mac OS

Posted on | April 15, 2011 | No Comments

Learning MacOS recently, and couldn’t find some hidden files, i.e. .htaccess

To fix this, easy.

Open Terminal, and paste the following in (both lines together), and press enter. Done.

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

To reverse the operation and re-hide them, change TRUE to FALSE.

iPhone iOS 4.2+ no longer automounting in Ubuntu

Posted on | April 13, 2011 | No Comments

I had this problem, which meant my iPhone no longer automatically mounted in Ubuntu 10.10. I had recently upgraded the iOS to 4.3.1 and this turned out to be the cause of the issue.

So, to fix it:

  1. Click on the System menu, then Administration and Software Sources. You’ll have to enter you administrator password.
  2. The Software Sources window will open.
  3. Click on the Other Software tab and click on the Add… button.
  4. Enter the following into the APT line box:
  5. ppa:pmcenery/ppa
  6. Press “Add Source”
  7. Then click “Close” And then “Reload” on the next question.
  8. Click back on the System menu. then Administration and finally Synaptic Package Manager.
  9. Once the window has loaded, click into the search box, and search for:
  10. libimobiledevice1
  11. The program may tell you that it will need to uninstall libimobiledevice0 and upgrade some other thing. I said OK to all this and then press Apply.
  12. It will run through, download the new modules and install them.
  13. Restart your computer for these changes to take effect.

Creating a copied branch in SVN

Posted on | April 11, 2011 | No Comments

To create a new branch in SVN, its very simple.

svn copy <source> <destination> -m <message>

This will copy the SVN in the source folder, into a new branch under <destination>. Very simple.

More, in depth information can be found here: http://svnbook.red-bean.com/en/1.5/svn.branchmerge.using.html#svn.branchmerge.using.create

Discovery Enchilada Recipe

Posted on | March 23, 2011 | No Comments

I need these all the time as I seem to have a problem remembering the amount of water to use…

Ingredients

1tbsp oil.
500g minced beef.
1 Discovery Enchilada Kit.
200ml water.
50g Cheddar cheese, grated.

Instructions

Pre-heat oven to 200°C. Heat oil in a pan and fry mince until browned.

Add sachet of spice mix, cook for a few seconds, then add 200ml of water.

Bring to the boil and simmer for 30 minutes, or until the mince is tender and dry.

Fill the corn tortillas with mince, roll up pancake style and lay side by side in an ovenproof dish.

Pour over Enchilada sauce, sprinkle with cheese and cook in a pre-heated oven at 200°C/400°F/Gas Mark 6 for 20 minutes, or until browned.

How to use Nano on Unix-like systems

Posted on | February 22, 2011 | No Comments

Nano is a basic text only text editor in Unix. It has no real GUI as such, and there is very little mouse interaction. But this makes it very useful, especially when SSHing to your web server. Here are some basic commands for you.

Opening Nano to edit a file is as simple as

Nano filepath/filename &

Note the & on the end to tell Terminal to carry on and not wait.

Key Shortcuts

With all these key shortcuts, the shortcut is called by holding CTRL and pressing the shortcut key:

Moving around the file:

CTRL + A -> Move the cursor to the start of the line.
CTRL + E -> Move to the end of the line.
CTRL + Y -> Page Down.
CTRL + V -> Page Up.
CTRL + _ -> Move to a specific line/column.

The mouse wheel on my Ubuntu will move the cursor up and down. I don’t know if this is design or just luck.

Editing the file:

CTRL + K -> Cut the whole line the cursor is on. (Similar to deleting, however you can re-paste these – see below)
DELETE -> Deletes the character ahead of the cursor (as you’d expect).
BACKSPACE -> This deletes the character before the cursor (again, as expected).

Copy and Paste:

ALT + 6 will copy a line into the copy buffer. You may copy more multiple lines into the buffer, and when you paste them, they will paste in the order that you coped them.
CTRL + K to cut a line

CTRL + U will paste what ever is in the buffer. As mentioned before, if you copy multiple lines, they will be pasted in the order that you copied them. Neat.

Saving:

CTRL + O -> Save the current file. You will be prompted for the filename which will default to the current file.
CTRL + X -> This will quit the application. However, if the file has changed, you will be prompted if you want to save changes.
CTRL + T -> When performing file actions, CTRL+T will show you a basic file browser…

More:

CTRL + G -> This will show the full Nano help file with many more commands.

Accessing /var/www/ as normal user

Posted on | February 17, 2011 | No Comments

Some useful linux commands to help with editing web pages on a server:

To give access to others to my www folder (so I don’t have to login as sudo):

chmod 2775 . -R

To show the groups for the selected user:

groups <username>
groups www-data

To add the www-data user to the local user’s group. (When you create a user, i.e. Bob, Ubuntu will create a Bob group.)

sudo usermod -G Bob www-data

To add a bunch of groups to a user:

sudo usermod -G groups,separated,by,commas username

Stupid Microsoft error messages

Posted on | January 19, 2011 | No Comments

Why is it that the Microsoft developers have an inability to get their systems and processes to output a meaningful error message now and again? I mean, is it really that hard?

I try to stay away from company slagging, but Microsoft, really…?

I have recently bought an XBox 360 and I think its great. Had no crashes, and no problems with it, until I joined XBox Live. I was offered a month free – great. I used that, and then on the XBox dashboard, I noticed an advert for another free month. Double great. However, when I tried to activate this, I received a cryptic error message on the screen. Something like, “This operation failed. Error 8005342″ – nothing else.

Great. I searched on Google, and found that many people had this error, and someone seemed to think that registering my credit card details, on www.xbox.com might be a good idea to try. I did this and re-attempted the procedure with success this time. So, why if the error is “no credit card details entered” – why the bloody hell doesn’t the error message say that??!?!

And just now, I was trying to install .Net framework 4 on a test PC. I receieved another message, “The install failed due to a fatal error”… Helpful. What if someone you know dies and all the doctor said was, “he died”. “Why?”, “He’s dead”

Helpful.

Turned out, I needed to install something called the Microsoft Windows Imaging Component. Again. Why not tell me this instead of “a fatal error”

Its no wonder people have so much trouble getting used to using a computer!!!

Sorry for the rant. Just pisses me off!

How to use mysqldump

Posted on | January 18, 2011 | No Comments

Using mysqldump to back up a database

If you want to make a super quick backup of a MySQL database, the best tool for the job is the native mysqldump. Its also a command line utility, so you can use it from a telnet or SSH connection, etc…

The basic command structure of mysqldump is:

mysqldump -u {username} -p{password} {database} > {backup-file}

I.e. If you had root access, and you wanted to backup all the tables within the “customers” database you could run this command:

mysqldump -u root -p customers > mybackup.sql

This would dump all the data to the mybackup.sql file. Note I didn’t enter a password. Mysql will ask you for your password in this instance. If you wanted to enter the password (where it could be seen, or saved into a BASH history) then you use the command -pABC123 where ABC123 is the password (not the lack of a space between -p and ABC123 – this is important!)

But if you are security conscious, omit the actual password from the command line, and merely use -p as this will prompt you for the password and therefore BASH or DOS will not store it.

If you wanted to only dump certain tables from the database, specify them after the database. For example, to back up the “address” and “billing” tables:

mysqldump -u root -p customers address billing > mybackup.sql

Restoring a mysqldump file

If you want to restore a mysqldump’ed file into MySQL – you can simply run the following command:

mysql -u {username} -p{password} {database} < {backup-file}

Note the change of direction for the < symbol and the fact we’re calling the mysql command, and not the mysqldump command!!!

So, to squirt my backupfile back into the customers database

mysql -u root -pABC123 customers < mybackup.sql

NB. This will overwrite your current database tables with whatever is in the backupfile!

Using mysqldump to backup ALL databases

If you have lots of databases, then you simply use the –all-databases command to back them all up into one file:

mysqldump -u root -pABC123 --all-databases > mytotalbackup.sql

Using mysqldump to backup multiple databases

By using the –databases switch, we can state which databases we want backed up. Separate each database name with a space.

So to backup “customers”, “orders” and “misc” we use the following syntax:

mysqldump -u root -pABC123 --databases customers orders misc > multiple-databases.sql

Advanced techniques

Compressed backups

More often than not, a database dump will be several hundred MB in size, if not more. MySQL can zip this for you automatically using the gzip command:

mysqldump -u root -pABC123 customers | gzip > compressed-backup.sql.gz

The pipe before the gzip tells mysqldump to send the output to the next command, which is gzip and that, in turn, is asked to create “compressed-backup.sql.gz”

Dumping the data definitions

If you wanted a “skeleton” structure of the entire database, then mysqldump will allow this, by using the –no-data switch:

mysql -u root -pABC123 --no-data customers > customers-structure.sql

Zend_Db – Performing a LIKE search

Posted on | January 12, 2011 | No Comments

When performing a simple SQL search using Zend_Db_Select,

$select->where('name = ?', 'chris');

But what if you want to do a LIKE search?

$select->where('name LIKE ?', 'chris%');

Simples.

Linux – CHMOD 777

Posted on | January 12, 2011 | No Comments

Just a note, when you update the permissions of a file:

chmod +777 somefile.txt

This change will only last as long as the session is logged in, i.e. once you reboot, it will revert back to what the permissions were.

« go backkeep looking »
  • Chris Tate-Davies

    Hello there. This is my little "repository" on the world wide web. Its for nothing more than documenting things that I might need again in the future. You could describe it as an extension to my memory.

    Also an online collaboration of my thoughts through the day. I'll try to keep the real random stuff out and keep the blog on course.

    Thanks for stopping by... Hope you find what you're looking for...

  • Tags