Yearly Archives: 2014

How to find your starred questions (favourites) in Stack Overflow

Stack-Favourites

You can mark questions in the Stack Exchange network simply by clicking the little star icon. A yellow star means you’ve marked it as a favourite, a grey one means you haven’t. It’s a convenient bookmarking system.

But where can you see a list of what you’ve starred? It’s not exactly obvious, so let me show you how to access your favourited questions and up voted answers. I’m using Stack Overflow as an example, but the principle is the same on all Stack Exchange sites.

  • head over to your Stack Overflow profile (click on your badge at the top)
  • find favorites at the bottom
  • now select added to see your starred/favourited questions
  • or select votes to see which answers you’ve up-voted

Hope this helps!

  • http://meta.stackexchange.com/questions/54276/where-are-my-starred-questions

How to change your DNS Servers in Windows

DNS is a service that translates a domain name into a numeric IP so that one computer can talk to another. We deal with it all the time, but most mere mortals are not aware of their importance. In this article I’d like to show you how to change your computer’s DNS entries in Windows.

 

Why change DNS Servers?

In a nutshell, if all works well on your system, perhaps you don’t need to tweak those settings. However, if you can consistently see some websites but not others, or you get weird intermittent connection problems, then your DNS entires may be querying servers that are not as “hot” as others.

Faster DNS Servers can provide quicker answers, resulting in faster results when browsing.

When the IP address of a domain changes, it takes a while for this change to propagate through the world. Some servers know changes quicker than others. Some servers may not see new data at all for several days.

ISPs and corporate networks usually provide their own DNS Servers, but it’s never clear how good they are. Google and OpenDNS provide very fast and free services which usually outperform those provided by your ISP or corporate network.

 

Change DNS Servers in Windows 7, Windows 8.1 and Windows 10

It’s not easy to find this hidden option, but the good news is this works on all flavours of Windows.

Search for “Network and Sharing Center” which will bring up a window that lets you choose the option “Change adaptor settings”. This will bring up the list of networks, one of which is likely connected to the internet.

Screen Shot 2014-12-29 at 15.15.01

 

In my case it’s a LAN connection, but it could also be a WiFi connection. Right-click the appropriate one and choose Properties.

The next window looks rather scary and isn’t very intuitive for humans. Scour the list for something that relates to Internet Protocol Version 4 (TCP/IPv4) as highlighted here:

Screen Shot 2014-12-29 at 14.10.08

Select this item and click Properties. Another scary window opens. This one has two parts on the General Tab, and it’s the lower one about DNS that we’re interested in (the top part is for obtaining an IP address – let’s leave it alone).

The default is “Obtain DNS Server automatically” which means we have no idea who is being queried. Instead, select “Use the following DNS server addresses” and add both DNS Servers of your choice. In this screenshot I’m using Google’s DNS:

Screen Shot 2014-12-29 at 14.11.25

As soon as you hit OK the changes will be in effect. You can close all other windows we opened during the course of this setup.

  • http://windows.microsoft.com/en-us/windows/change-tcp-ip-settings#1TC=windows-7

 

Popular DNS Servers

Google’s DNS Servers are:

  • 8.8.8.8
  • 8.8.4.4

The OpenDNS Servers are:

  • 208.67.220.220
  • 208.67.222.222

There are many other free and premium DNS Servers you can use. Search for “free dns servers” and see lists like these: http://pcsupport.about.com/od/tipstricks/a/free-public-dns-servers.htm

Have fun 😉

How to override auto-detected Email Settings in iOS

IMG_5845.PNG

The nature of any automation is that sometimes it just doesn’t work. Apple’s iOS is no exception.

When you add a new email account on your iOS device, several mail providers’ settings can be auto detected. It’s there to make our lives easier so that we don’t have to add details for mail servers and ports manually. Yahoo Mail and Gmail.com are detected perfectly, but other services – for example GMX – are not.

This is no problem if iOS simply says that you need to add details manually (as with Plesk mail), but it is an issue if iOS has detected the correct POP settings and you’d much rather use IMAP. iOS offers no way to change these settings when auto detection was successful.

There’s a trick which will let you specify your own settings by bodging your password. Do the following:

  • under Settings – Mail, Contacts, Calendars – add a new account
  • choose other, then select Add Mail Account
  • This will show you a dialogue similar to the one in the screenshot above. Fill out your details but deliberately choose the wrong password. A single letter of your choice will do.
  • Hit Next and the auto-detection goes to work, telling you the password was wrong.
  • Now configure the settings to your liking, including a choice of POP and IMAP, incoming and outgoing mail servers, encryption options and ports.

I found this out by helping my friend Oliver leave POP behind for good on his new iPhone 6. In case you need the GMX IMAP details, they can be found here:

FIXED: The wp-content folder does not show itself via FTP in Plesk 12 and CentOS 7

Screen Shot 2014-12-24 at 21.49.49

I’ve noticed a weird bug in Plesk 12 on CentOS 7: when you connect via FTP, the wp-content folder does not show up – all other folders can be seen as usual. It’s a rather crucial folder for WordPress users.

At first I had suspected a problem with the ProFTP service which is not the stock version, but a specially compiled version for use with Plesk, and Plesk takes care of this system services (it’s called psa-proftpd in case you’re interested). But ProFTP is not the problem.

Thanks to the amazing Sergey Lystsev from Parallels for letting me know that the issue is instead with SELinux: when it’s used in Enforcing mode (which is the default), wp-content does not show itself via FTP. Switching it to Permissive mode or disabling SELinux altogether solves the problem.

The entire issue will be fixed in the next release of Plesk, and it’s already working in the latest update to the Plesk Preview 12.1.13. CentOS 5 and 6 are not affected.

How do we fix it, Cap’m?

To disable SELinux on CentOS 7 we can use this:

Or, to switch to permissive mode, use this:

Now we’ll need to restart the xinetd service as well as Plesk for the changes to take effect:

Connect to your site via FTP and see if the wp-content folder shows itself.

To permanently change the SELinux configuration so that it survives a server restart, check out my other article here:

  • https://wpguru.co.uk/2014/12/how-to-control-selinux-in-centos-7/

How to allow Passive FTP Connections in Plesk

Plesk-LogoA little while ago I’ve written an article about opening Passive FTP Ports specifically for using Plesk on Amazon AWS. Here’s a slightly more condensed version about how to do this on any server if you need it.

Passive FTP ports are not open by default when you install Plesk. To make it happen we need to patch the ProFTP configuration with a range of ports (anything between 49152 and 65534) and open the same range in our firewall.

You’ll find the ProFTP config file in /etc/proftpd.conf. There’s no need to open the whole available range, I’ll settle for 99 possible ports here. Add the following somewhere at the top of the file, outside any global declarations:

For the changes to become effective we’ll need to restart the xinetd service which ProFTP is part of in Plesk:

This will allow passive connections – but you also need to open those in your firewall. The easiest way to do this is via the Firewall Extension in Plesk:

Screen Shot 2014-12-18 at 18.20.48

Select Modify Firewall Rules, then Add Custom Rule. Give it a title, then add your port rage and click OK. Your changes are not effective yet because Plesk needs to restart the firewall service. To do this hit “Apply Changes”, followed by “Activate”. Wait a moment and Plesk will have taken care of it.

If you don’t want to use the extension, here’s how you can open those ports manually. On CentOS 6 you can manually add that port range on the command line like this:

On CentOS 7 you can do it like this:

Testing testing… this thing on?

To make sure everything is working, simply use your favourite FTP client and try to make a passive connection. If you get timeout errors something isn’t right.

You can also use a great web based tool to check if passive connections are working thanks to Tim Kosse: https://ftptest.net

Enjoy!

Further Reading

  • https://wpguru.co.uk/2014/03/how-to-allow-passive-ftp-connections-in-plesk-on-amazon-ec2/
  • http://www.proftpd.org/docs/howto/NAT.html
  • http://www.proftpd.org/docs/directives/linked/config_ref_PassivePorts.html
  • http://ftptest.net

How to quit vi without saving your changes

It just occurred to me that even though I know my way around vi fairly well, I never had to quit it without saving my changes. Usually I just go back in and overwrite my mistakes.

Today I did something though that wasn’t as easy to eliminate: instead of pasting an IP address, I accidentally pasted a 4000+ character stylesheet. Dang!

So how do we leave vi and NOT save our changes? Here’s how:

  • press ESC to exit editing mode (insert/append/whatever)
  • press : (the colon character)
  • enter q!

Now you’re back on the command line without any saved changes.

Remind me: how do we SAVE changes again?

There are several ways of doing this, but my personal favourite is this:

  • press ESC to exit editing mode (insert/append/whatever)
  • press SHIFT + Z twice

This will put you back on the command line and your changes are saved.

  • https://kb.iu.edu/d/afcz
  • https://wpguru.co.uk/2012/03/how-to-use-vi-to-edit-files-in-linux/

How to control SELinux in CentOS 7

SELinux – when installed – can take on one of three modes:

  • Enforcing
  • Permissive
  • Disabled

To check which mode SELinux is running on, we can use either sestatus for a more detailed output, or simply getenforce for a one liner:

getenforce on the other hand will literally just say a single word, like “Enforcing”.

To change this mode, edit /etc/selinux/config:

Change the file according to the comments and restart the system for the changes to take effect.

setenforce command

If SELinux is running and either set to Enforcing or Permissive, you can change its mode on the fly without restarting the server using the setenforce command like so:

You won’t get any feedback if all goes well. Note that if SELinux is disabled, the setenforce command won’t work.

setenforce is practical if you’d like to change the SELinux policy only temporary and your settings will not be retained. So the next time you restart the server, SELinux will come back with whatever is set in /etc/selinux/config.

Find out more about SELinux and what it’s good for here:

  • https://www.digitalocean.com/community/tutorials/an-introduction-to-selinux-on-centos-7-part-1-basic-concepts
  • http://wiki.centos.org/HowTos/SELinux

How to find and replace in MySQL with phpMyAdmin

mysqlSometimes you need to replace a string in your database with another string, and it can be rather tedious to plough through a large table manually. Thankfully MySQL can execute raw queries such as find and replace.

This comes in handy if you’ve moved a WordPress installation to another URL: you only need to tweak two values in the options table, but there may be countless image references and links in the posts and options table too. That’s where find and replace can come in handy.

You can execute the following statement either on the MySQL command line, or use phpMyAdmin’s Raw SQL option:

Screen Shot 2014-12-05 at 15.42.10

That big text field is where we’ll use the following code. Before we do however, make a backup of your database because there is NO UNDO FUNCTION in MySQL. A cute typo can break things beyond repair!

Here’s what the find and replace statement looks like in principle:

For WordPress specifically, if you’d like to replace text strings inside posts and pages, then wp_posts would be your table, and field_name is the column of that table. So for wp_posts this will be post_content. You can see the field labels at the top of each column when you select a table.

To replace a URL in all posts and pages the statement would look like this:

As soon as you hit GO, MySQL will go to work and show you a success or failure message. The above would replace all image references and links from your old domain to the new one, where WordPress is installed in a subfolder.

Make a note of your table prefix and replace it accordingly. wp_ is the default, but this can easily be changed into something else for security reasons. Be cautious of trailing slashes when you’re replacing URLs.

Also note that a small letter “l” and a capital “I” look surprisingly similar in the phpMyAdmin! If you keep getting errors like “this table does not exist”, it’s something to watch out for before questioning your sanity again 😉

 

Replacing URL strings in WordPress

I use this technique when I need to replace URLs across an entire WordPress installation. Those can hide not only in posts, but also in widgets and menus. Here’s a list of places to hunt for them:

  • wp_posts table, in the posts_content field (links inside posts and pages)
  • wp_links table, in the link_url field (the old Link Manager)
  • wp_postmeta table, in the meta_value field (URLs of Custom Menu items)
  • wp_options table, in the option_value field (anything saved by themes and plugins)
  • wp_comments table, in the comment_content field (URLs inside comments)

And while we’re talking about replacing URLs: if you need to change the root URL of a WordPress installation, this is done in wp_options too. Look for two values called siteurl and home.

 

Further Reading

  • http://stackoverflow.com/questions/11839060/find-and-replace-text-in-all-table-using-mysql-query
  • http://www.hongkiat.com/blog/how-to-search-and-replace-wordpress-in-blog-post/
  • http://roborr.net/blog/website-tips-tools/how-use-phpmyadmin-do-find-replace-your-database

How to boot Windows into Desktop Mode, bypassing the Metro Start Screen

I’ve just installed the Windows 10 Technical Preview on my Samsung NC10. During the installation I was offered to transfer my settings from another PC, so I chose my Surface Pro running Windows 8.1.

All settings were copied truthfully, including the fact that Windows boots up with the Metro Start Screen. It’s not what I had expected, mainly because my other Windows 10 installations don’t do this. So how do we change this behaviour?

It’s very simple, let me show you how. This works on both Windows 8.1 and the Windows 10 Tech Preview.

Enter Desktop Mode, then right-click the Task Bar at the bottom of the screen. Anywhere will do, as long as it’s not over an icon. Select Properties, then choose the Navigation tab at the top. You’ll see something like this:

Screenshot (85)

Tick the box that says “When I sign in, go to the Desktop instead of the Start Screen”. Windows may sign you out on this occasion, and when you’re signed in you’ll boot straight into Desktop mode.

Windows 10 Start Menu

New in Windows 10 is the Start Menu, as seen from Windows 95 to Windows 7. Microsoft have brought it back in Windows 10, but its use is optional. The Start Menu is enabled on new installations by default, but since I had copied all settings from a Windows 8.1 it was disabled.

To bring it back, choose the Start Menu tab and tick the top box that reads “Use the Start Menu instead of the Start Screen”.

Screen Shot 2014-12-04 at 16.13.05

Don’t look for this option in Windows 8 – it’s only available in Windows 10.

How to move databases between subscriptions in Plesk

You can move databases and database users between subscriptions in Plesk. There’s no web interface for this, but with a bit of manual database tweaking you’ll soon get the hang of it.

I recently split a subscription into two for a client and this trick came in handy.

Before we begin, make sure you backup the psa database – that’s what Plesk uses to keep track of internal values, anything from user names, passwords, and which service is associated with what. If you ruin psa you’ll ruin your Plesk installation. Use caution!

Editing psa

You can use phpMyAdmin from Plesk to edit the psa database. Head over to Tools and Settings (or the Server Tab), Database Servers and click the little wrench icon. This will open phpMyAdmin in a new window.

Screen Shot 2014-12-04 at 11.34.02

Find the psa database and click on the little disclosure plus icon. This will show you all its tables, similar to this:

Screen Shot 2014-12-04 at 11.37.24

Scroll down to find data_bases and db_users. Open either of them (with the little disclose icon again) and you’ll find a list of databases and users respectively. Note the column dom_id. This is how Plesk knows which subscription (or domain) this database belongs to. MySQL takes care of the actual database, the value here is for visual representations in Plesk only.

The difficult bit is to find out which numeric dom_id translates into which domain. There’s not an easy way to extract that info from Plesk, so we’ll use a quick workaround: create a new identifiable database (and user) in the subscription we’d like to move to and simply look at which dom_id it gets.

Creating a Dummy Database

Back in Plesk, head over to the subscription you’d like to move your database to and create a memorable user/database combo. Anything will do, we’ll delete this later. Call it “aaaaaaaaa” or “comehere” – up to you.

Once done, head back over to psa database in phpMyAdmin, refresh and look at the data_bases (and db_users) again. You’ll see something like this:

Screen Shot 2014-12-04 at 11.50.55

Now we know that our important_database (and important_user) need a dom_id value of 2 instead of 1. Change it in both tables – and you’re done!

Head back into Plesk and check your subscriptions: the database and user will have disappeared from subscription 1 and will now appear in subscription 2.

Thanks to Matt Nelson for this tip!

  • http://www.silverark.co.uk/articles/item/220-moving-a-database-between-domains-in-plesk.html