Author Archive
Vi / Vim Shortcuts
by RedCoupe on Jun.15, 2011, under Web design / development
Im always forgetting the very useful vi shortcuts, so here’s a list of them:
ˆ = Control key
If you see a 10, this can be replaced by any number
| Operation | Keys |
|---|---|
| Return to Command mode from Insert, overwrite or append mode | Escape |
| Enter Insert mode | i |
| Enter overwRite mode | R |
| Enter append mode | a |
| Enter append mode at end of this line | A |
| Enter Insert mode on a new line after this | o |
| Enter Insert mode on a new line before this | O |
| Delete this word and enter Insert mode here | cw |
| Delete this line and enter Insert mode here | cc |
| Delete the next 10 lines and enter Insert mode here | 10cc |
| Move cursor left one character | left arrow or h |
| Move cursor left e.g. 10 characters | 10h |
| Move cursor down one line | down arrow or j |
| Move cursor down 10 lines | 10j |
| Move cursor up one line | up arrow or k |
| Move cursor right one character | right arrow or l |
| Save this file and continue | :w |
| Save this file and exit | :wq |
| Abort without saving changes to this file | :q! |
| Quit (no changes made) | :q |
| Save as a new file “new-file” | :w new-file |
| Load the file “myfile” into vi | :e myfile |
| Delete the character under the cursor | x or Del |
| Delete the current word (inc. space) | dw |
| Delete the next 10 words | 10dw |
| Delete the current line | dd |
| Delete the next 10 lines | 10dd |
| Delete rest of this line, right of the cursor | d$ |
| Yank the current line onto the clipboard | yy |
| Yank the current word onto the clipboard | yw |
| Paste the clipboard | p |
| Undo | u |
| Redo | ^r |
| Jump to the bottom of the file | G |
| Jump to e.g. the tenth line of the file | 10G |
| Jump to the top of the file | gg |
| Jump one page forward | ^f |
| Jump half a page forward | ^u |
| Jump one page back | ^b |
| Jump half a page back | ^d |
| Search for text from cursor | /text |
| Find next occurrence of text | n |
| Find previous occurrence of text | N |
| Start of next word | w |
| End of next word | e |
| Start of the tenth word forward | 10w |
| Start of next sentence | ) |
| Start of previous sentence | ( |
| Start of line | 0 (zero) |
| End of line | $ |
| Top of screen | H |
| Bottom of screen | L |
| Middle of screen | M |
Welcome back PSN
by RedCoupe on Jun.09, 2011, under PS3
For the ‘Welcome Back’ package I’ve gone for WipeOut HD (with Fury pack) and Infamous, for the PSP I’ll probably go for Little Big Planet and ModNation Racers. As a Playstation Plus subscriber I was pleased to be able to download Burnout Paradise as a freebie, nice one.
Get dropdown list label value
by RedCoupe on Jun.09, 2011, under Web design / development
I was working on a couple of web pages this morning to allow completion of a course booking form, user then submits to a thankyou page, confirmation emails are sent etc.
The problem I faced was that only the course ID was being passed to the thankyou page so in the emails that are generated, it displays Course Details: 7 , instead of Course Details: 12/12/2011 PHP Basics.
So my initial thought was to create a hidden field just before the end form tag together with some javascript that gets the relevant label value:
document.getElementById('coursedetails').value = document.getElementById('training_id')[document.getElementById('training_id').selectedIndex].innerHTML;
Then in the thankyou page I just got Request.Form(“coursedetails”), this is in ASP VBScript just in case you were wondering. Works like a charm.
Since doing this is I should have done it a much easier way and not have to rely on JavaScript being enabled. I already had the value because I was already using it to display the dropdown list label. So the hidden field could have just contained the default value of the currently selected item.
MS SQL Server – get second from last record
by RedCoupe on May.18, 2011, under Web design / development
Using MS SQL Server, I’ve been trying to get the second from last record that had been created because I want to do some comparison code to display what has been changed.
Anyway just form future reference here’s the SQL I used:
SELECT TOP 1 * FROM dbo.tbl_MailList_Items WHERE item_id < (SELECT MAX(item_id) FROM dbo.tbl_MailList_Items) ORDER BY item_id DESC
This works perfectly for my situation and doesnt rely on just subtracting 1 from the id column because my id column is not fully incremental due to records being deleted etc.
Killzone 3
by RedCoupe on Mar.15, 2011, under PS3
Well what can I say, I’m finding this game absolutely awesome. The graphics and sound are fantastic and both the single player campaign and online multiplayer are incredibly addictive.
When I first played this I thought the controls seemed a bit kind of ‘sloppy’ but having spent quite a few hours on it, I’ve got used to it with no problems.
Big thumbs up for me, love it!
Ubuntu subdomains on Apache2
by RedCoupe on Sep.21, 2010, under Web design / development
From a standard Apache2 install I created a folder in /var/www/ called ‘testsite’ (without the quotes).
Go to the following folder:
/etc/apache2/sites-available
…and create a file called something suitable, for this purposes of this blog post I’ll just call my file testsite, It’s contents should be:
<VirtualHost *:80>
DocumentRoot /var/www/testsite/
ServerName testsite.localhost
ServerAlias testsite.myubuntubox
<Directory /var/www/testsite/>
Options Indexes FollowSymLinks MultiViews +Includes
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Then run the following command:
sudo a2ensite testsite
Edit your /etc/hosts file and add the following lines:
127.0.0.1 testsite.localhost 127.0.0.1 testsite.myubuntubox 192.168.0.6 testsite.myubuntubox
Obviously the ip address 192.168.0.6 may be different depending on your network setup.
Restart Apache:
sudo /etc/init.d/apache2 reload
I also had to edit my c:\windows\system32\drivers\etc\hosts file on my other PC to make sure that when I visit http://testsite.myubuntubox/ it resolves correctly, so I now have the following:
127.0.0.1 localhost 192.168.0.6 myubuntubox 192.168.0.6 testsite.myubuntubox
That’s it, all working, now I can develop multiple websites locally using subdomains. Personally I would rather do it this way than putting websites into folders, seems to work better with Dreamweaver.