Wednesday, June 19, 2013
Lorem Ipsum? That sounds like a made-up word for made-up words. (via clientsfromhell)
Tuesday, June 18, 2013

Windows 7/8 ‘Play To’ feature

Did you know, Windows 7 and 8 computers have their own version of Apple’s AirPlay called ‘Play To’? (Note: These two features are not compatible.)

Read this: Microsoft.com: Using the Play To feature to stream media.

Friday, June 14, 2013

Connecting phpMyAdmin to MySQL server via SSH

Encrypting communication between your computer and a MySQL server is important to reduces the risk of eavesdropping on an unsecured connection. The best and easiest way to accomplish this is to use SSH

Things you’ll need

  1. XAMPP running on you computer
  2. phpMyAdmin (Comes bundled with XAMPP)
  3. PuTTY (A free Telnet/SSH client)
  4. An external server running MySQL and SSH services

Step 1 - Setting up

Open up PuTTY. The first thing you will see is the Session window.

Enter your user name and host name in the host name box separated by an @. In my example bellow I used user@example.com. Use port 22 unless your SSH serviceis configured differently.

image

Step 2 - SSH Tunnel / Port Forwarding

In the Category list in the sidebar go to: Connection > SSH >Tunnels.

In the source port box type the port number you want to use. The default port for MySQL is 3306 but this may be in use if you have the MySQL service running in XAMPP, so it may be best to use port 3307.

In the Destination box enter the address to the MySQL server as it would appear if you were connecting to it on the server itself. This could be localhost:3306 but in my example bellow I used mysql.example.com:3306

Then click the Add button.

image

Step 3 - Save the PuTTY session

Back to the Session category, in the Saved Session box enter a name to remember this connection by. Then click Save.

Protip: When you reload PuTTY you can just double click the name of the saved session to open it without reconfiguring PuTTY again.

Step 4 - Configuring phpMyAdmin

Find the location for the phpMyAdmin installation (In XAMPP, this is the phpMyAdmin folder where XAMPP is installed.)

In the config.php file you want to add the following after…

$i = 0;
$i++;
$cfg['Servers'][$i]['verbose'] = 'mysql.example.com';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = 3307;
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
$cfg['Servers'][$i]['AllowRoot'] = false;

Save config.php.

Open your SSH session in PuTTY and enter your SSH password if/when asked.

Make sure the Apache service is up and running on your local machine and load up phpMyAdmin in your web browser (http://localhost/phpmyadmin/ for XAMPP)

Should then be able to log into your external MySQL server using the username and password you use to access it normally.

Friday, June 7, 2013

Pagination function for PHP

function pagination($curr_page, $total_pages, $offset = 2) {
$start = $curr_page - $offset;
if ($start < 1) $start = 1;
$end = $start + ($offset * 2);
if ($end >= $total_pages) {
$end = $total_pages;
$start = $end - ($offset * 2);
if ($start < 1) $start = 1;
}
return range($start, $end);
}
pagination($curr_page, $total_pages, $offset)

$curr_page is the current page being viewed.

$total_pages is the total amount of pages.

$offset is the amount of pages between the current page you want displayed by. The default is 2.

To use this function for example with Twitter Bootstrap

<div class="pagination pagination-centered">
<ul>
<?php foreach (pagination($curr_page, $total_pages, 3) as $i) { ?>
<li<?php if ($curr_page == $i) { ?> class="active"<?php } ?>><a href="?p=<?=$i?>"><?=$i?></a></li>
<?php } ?>
</ul>
</div>

If the current page is 6, it will produce something like this

[3] [4] [5] [6] [7] [8] [9]

Tuesday, June 4, 2013
Is a staircase terrain or an object?
Saturday, June 1, 2013
Joomla! is the work of the devil,
Wordpress will be hacked by the Chinese,
and Drupal has a steep learning cliff.
(via teksyndicate)
Sunday, May 26, 2013

HTML Tooltips using CSS pesudo selectors

Demo

HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8>
<title>Tooltips using pesudo selectors</title>
</head>
<body>
<div data-tooltip="Aren't I the sexiest?">Hover over me!</div>
</body>
</html>

CSS

Edit colours, borders, padding to fit you own styling.

[data-tooltip]:hover:before{
content:attr(data-tooltip);
display:block;
background:red;
color:#fff;
}

Thanks to doot0 for showing me this a while back. I’m sure he took it from someone else.

Thursday, May 23, 2013

Selecting a DNS provider

DNS. Domain Name System. The internets way of translating domains names such as techbuket.net to a corresponding IP addresses.

The DNS service is provided by servers across the internet which hold databases containing translations of domain names to IP addresses. Your ISP probably provides this service for you, but you can configure your computer of router to use a custom alternative service. Here are a selection of them.

OpenDNS is a well known alternative DNS service that uses the addresses 208.67.222.222 and 208.67.220.220. OpenDNS adds their own ‘Did you mean … ?’ search results and advertisements to non-exsistant domain names.

Google Public DNS is another well known alternative DNS service which is provided by Google at 8.8.8.8 and 8.8.4.4. Google is a pretty shady company anyway and who want to join a botnet voluntarily?

OpenNIC Project is the best freedom respecting alternative service located on many different addresses. You will need go to their website to find an address near you for the best DNS response times.

Tuesday, May 21, 2013
Computer memory scales

Computer memory scales

Sunday, May 19, 2013

Installing Windows from a USB drive

This is a guide works for Windows 7 and 8 and possibly for XP as well. I personally use this method myself rather than using an automated tool.

Step 1

Plug in a USB drive (Minimum size of 4GB)

Back up any contents you want to keep onto another drive as we are going to need to format this one.

Enter Command Prompt with administrative rights (Win key -> cmd -> Ctrl+Shift+Enter)

Step 2

In the Command Prompt window type “DISKPART” (Without quotes)
then type “LIST DISK”

Now you need to know the rough size of the USB drive you want to use as getting this incorrect could erase the incorrect drive. At the worst case it could be a hard disk.

My USB drive I want to use is around 4GB as show in the screenshot bellow. The other disk is the hard drive of my netbook I was doing this on.

Windows DISKPART

Step 3

You now need to enter into the Command Prompt window the following commands. This is the last chance to backup you USB drive before it is emptied.

SELECT DISK 1
CLEAN
CREATE PARTITION PRIMARY
ACTIVE
FORMAT FS=NTFS
ASSIGN EXIT

Formatting takes a few seconds to complete.

Step 4

If you are going to use an ISO of the Windows installation disk, you can mount it as a drive using a program called WinCDEmu (This is a pretty straight-forward process), Otherwise insert the Windows Installation disk into your DVD Drive.

Get to know the drive letter for the Windows Installation disk. I’ve mounted mine using WinCDEmu and it’s been assigned Z:.

You will also need to know the drive letter for the USB memory stick, which may of changed after formatting. Mine is assigned F:.

Devices with Removable Storage

Step 5

Enter the following commands into the Command Prompt window

Z:
CD BOOT
BOOTSECT.EXE /NT60 F:
XCOPY "Z:\*" "F:\" /S

Note the drive letters “Z” and “F” correspond to the items in the previews step. The XCOPY command will take some time to complete as it’s copying the entire contents of the Windows Installation disk.

Finished

And that is it. Make sure that when you boot to install windows you select the BIOS setting to boot from USB and to swap it back to the HDD when you have finished, or you’ll be in an infinite loop of installation.

(Source: intowindows.com)