RedCoupe

Author Archive

Vi / Vim Shortcuts

by 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

OperationKeys
Return to Command mode from Insert, overwrite or append modeEscape
Enter Insert modei
Enter overwRite modeR
Enter append modea
Enter append mode at end of this lineA
Enter Insert mode on a new line after thiso
Enter Insert mode on a new line before thisO
Delete this word and enter Insert mode herecw
Delete this line and enter Insert mode herecc
Delete the next 10 lines and enter Insert mode here10cc
Move cursor left one characterleft arrow or h
Move cursor left e.g. 10 characters10h
Move cursor down one linedown arrow or j
Move cursor down 10 lines10j
Move cursor up one lineup arrow or k
Move cursor right one characterright 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 cursorx or Del
Delete the current word (inc. space)dw
Delete the next 10 words10dw
Delete the current linedd
Delete the next 10 lines10dd
Delete rest of this line, right of the cursord$
Yank the current line onto the clipboardyy
Yank the current word onto the clipboardyw
Paste the clipboardp
Undou
Redo^r
Jump to the bottom of the fileG
Jump to e.g. the tenth line of the file10G
Jump to the top of the filegg
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 textn
Find previous occurrence of textN
Start of next wordw
End of next worde
Start of the tenth word forward10w
Start of next sentence)
Start of previous sentence(
Start of line0 (zero)
End of line$
Top of screenH
Bottom of screenL
Middle of screenM
Leave a Comment : more...

Welcome back PSN

by 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.

Leave a Comment : more...

Get dropdown list label value

by 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.

Leave a Comment : more...

MS SQL Server – get second from last record

by 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.

Leave a Comment : more...

Killzone 3

by 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!

Leave a Comment : more...

Ubuntu subdomains on Apache2

by 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.

Leave a Comment : more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!