# Second hand bicycles

In response to a blog post ‘Why I keep fixing my bike‘ about the risks of buying a dodgy second hand bike, I wrote the following comment. It’s something I’m quite passionate about so worth storing on my own blog…

I have bought at least 7 bikes second hand through either ebay or gumtree all without problem. Every bike has been exactly what I was looking for. I wouldn’t buy off an ebay seller with only a small repuatation – and almost all sellers I have seen when searching ebay have 100+ reputation.

I think the chances of getting a lemon are quite small, but you always have to be careful.

With a bicycle you are predominantly paying for a decent frame as the rest can be replaced. Its fairly unlikely that the frame will have been damaged. So buy bikes that have well made frames e.g. Cannondale. I’ve purchased a Specialized, Cannondale, Merkx, Orange, Klein and Marin bikes. Most of the bikes I bought would have had a new value in excess of $1000. I’d be most wary of buying a Specialized bike as they are the most common and the current Specialized bikes I’ve seen have very poor welding on the frames. Certainly don’t go buying cheap branded bikes new bikes e.g. and shop’s own brand. If you’ve got very little money you can pick up old retro racing bikes for less than$100.

Limit your search to only bikes that are near buy (i.e. 30 minute drive) so that you don’t waste much time.

There are many things you can look for:

1. Has the bike been stored inside – if you see a photo of it hanging up in a garage on its own rack its a pretty good bet that it has
2. Buy ‘fixed’ bikes without suspension as the suspension can be expensive to replace
3. Look at the type of gears that it has
4. Check how detailed the spec of the bike is – does the person list exactly all the components – this gives an indication of how much the person cares about the bike
5. Do they state where they bought it from
6. Do they display high quality images of close ups of the gears, the joins of the frame where cracks appear
7. What have they been using the bike for
8. How often do they clean the bike
9. Ask what year the bike is from as well as the exact make and model – then hopefully you can find a reference to how much the bike was when it was new.
10. Check the welding on the bike frame – how clean are the welds. You shouldn’t be able to see the welds – as that means it was a cheaply made bike by machines and never finished off.

# Dos command history

One of the nice things of Linux is the command history – it stores typically the last 1000 commands or so and its saved every time you log out.

DOS does have this through the doskey /history command and you can relatively easily append this to a file:

doskey /history >> %USERPROFILE%\history.txt%


The tricky bit is having this done for you on log out.

Via a Stack Overflow question on bash_history you can get close, using doskey macros which appends to a file on exit.

This only works for the current session though so you need to create a shortcut that runs the command each time with the following Target:
(my apologies if this is missing backslashes, WordPress keeps deleting them!)

%windir%\system32\cmd.exe /K doskey exit=doskey/history$g$g%USERPROFILE%\history.log$texit$1 \$2


Then you just have to remember to type exit each time…

Shortcut target

### Update

I also found three useful commands – but they’re only for your current session. Hat tip to Nifty Computer Tricks:

F3
get last command
F7
current list (use left/right arrow keys to paste to the command line)
F8
auto-complete (type the first few letters)

### Update 2 – Some extra love for the DOS prompt…

If you’ve got this working then I’ve added some extra basics. First you need to install Gow (and I suggest you do it using the Chocolatey package).

Then download my bang.bat / history.bat gist, extract it completely and put the bang.bat and history.bat into the Gow bin directory e.g. C:\Program Files (x86)\Gow\bin. These assume you are saving the history to %USERPROFILE%\history.log.

Then you’ll be able to do commands like history | grep mysql to list all your mysql commands in history.log with their line numbers. Then call bang 123 to execute the specific line of the history.log file.

# OpenVPN connects to VPN but no internet

For those stumbling down a similar path…

tldr; Check that your Windows Firewall is turned off.

## My setup

• OS: Windows 8.1 64-bit laptop
• OpenVPN: OpenVPN 2.3.4 x86_64-w64-mingw32

My OpenVPN has been working for at least 4 months without problem.

First thing to remind yourself is: When you get the VPN working – copy the OpenVPN log of a successful connection and the ipconfig /all to file so that you know what to compare when it breaks next time.

## Notes

• The VPN connection stopped working yesterday 17/10/2014
• Not exactly sure when
• It had been working at my office
• My Windows 7 desktop has a working VPN setup so I can compare the settings
• The OpenVPN gui suggests a connection has been made but no sites can be pinged (see commands below)
• All attempts at inconfig /renew, ipconfig /flushdns nothing worked
• Only differences between Desktop/Laptop I could find in ipconfig /all and OpenVPN logs was that laptop had IPv6 for the WiFi connection turned off and the following extra fail message UDPv4: No Route to Host in the log
• I tried turning IPv6 back on but that didn’t change anything
• Now the UDPv4 message disappeared – but didn’t reappear when I turned off IPv6 again – so that was a red herring
• Possible suggestion from my history when first setting up my VPN (http://www.rickygao.com/troubleshooting-general-failure-in-ping-or-tracert/) was to turn off IPv6 which is what I’d probably done before – but IPv6 is no problem on my Windows 7 desktop
• Pinging even a specific IP address does not work – this confirms its not a DNS issue
• Pinging localhost 127.0.0.1 does work
• Pinging the IP Address of the connected VPN does work
C:\Users\Ian>tracert google.com
Unable to resolve target system name google.com.

Ping request could not find host google.com. Please check the name and try again.


## Solution

Eventually found a solution that was to turn off the windows firewall, which came from this unbuntu forums post which eventually spotted that it was an iptables firewall issue.

## Post mortem

• I thought I’d turned off my firewall and it doesn’t explain why the VPN stopped working
• Best guess is a Windows update changed something in the firewall the caused the problem
• A failed update for Windows Malicious Software Removal Tool for Windows 8, 8.1 and Windows Server 2012, 2012 R2 x64 Edition - October 2014 (KB890830) – this was successfully installed the next day but didn’t help
• A successful Definition Update for Windows Defender - KB2267602 (Definition 1.185.3528.0)

# Google Docs to Markdown to WordPress

I’ve started a fairly standard process of writing a Google Doc when I’m trying to learn something technical that I don’t understand and then if its half useful posting it to WordPress.

I know I could then copy paste the code from there to WordPress – but I’m a fan of writing WordPress posts in Markdown. For one reason, I need to switch all the titles to be one level lower in WordPress than Google Docs and its simpler to do that in Markdown. Also and code I put into Courier font in Google docs gets converted to code in Markdown, but gets lost when copying and pasting.

So I’ve found that there’s a script to export Google Docs. There is an annoying issue in that you have to re-do the steps everytime you want to export a document to Markdown. To get around this, I suggest that you just have one document that you use for converting to Markdown and copy/paste each Google Doc into that. Upon running the script from the Script Editor you get emailed a markdown version of your document.

Then copy & paste the markdown syntax into WordPress.

# Windows Netbeans Composer notes

This is for installing the main packages that Netbeans suggests in the Tools > Options > PHP (tab)

I’m running the following setup currently:

• Windows 8.1 (64-bit)
• Netbeans 8.0.1
• The version of Composer doesn’t really matter

## Global packages

running composer global installs the packages into %APPDATA%\Composer (or ~/.composer/ in Linux)

### PHPUnit

From the installation instructions (https://phpunit.de/manual/current/en/installation.html) do:

composer global require "phpunit/phpunit=4.3.*"

This installs PHPUnit to C:\Users\[username]\AppData\Roaming\Composer\vendor\phpunit and puts the binary to use in Netbeans in C:\Users\[username]\AppData\Roaming\Composer\vendor\bin\phpunit.bat

#### Skeleton Generator

From the installation instructions (https://github.com/sebastianbergmann/phpunit-skeleton-generator) run:

composer global require "phpunit/phpunit-skeleton-generator=*"

### PHP_CodeSniffer

composer global require "squizlabs/php_codesniffer=*"

Then put C:\Users\[username]\AppData\Roaming\Composer\vendor\bin\phpcs.bat into Netbeans Tools > Options > PHP (tab) > Code Analysis (tab) > Code Sniffer section

### Mess Detector

composer global require "phpmd/phpmd=@stable"

Then put C:\Users\[username]\AppData\Roaming\Composer\vendor\bin\phpmd.bat into Netbeans Tools > Options > PHP (tab) > Code Analysis (tab) > Mess Detector section

### apigen

composer global require apigen/apigen:~2.8

Then put C:\Users\[username]\AppData\Roaming\Composer\vendor\bin\apigen.bat into Netbeans

# Installing Node.js on Windows 8

Node comes with an installer, but I hit a couple of bugs that knackered my initial attempts to call either node or npm.

I followed the installation instructions trying to run a command for the first time and got 'node' is not recognized as an internal or external command. For anyone else with the same issue here’s what I stumbled through.

I’m running Windows 8.1 (64-bit) with Node v0.10.32.

1. Run the .msi installer
2. This installs it to C:\Program Files\nodejs

In that directory is node.exe for running node commands and npm.bat for installing node modules.

## Environment variables

The simplest solution for this is just to do a restart, but for thos who don’t want to aka me…

The installer doesn’t seem to install the environment variables properly (at least it didn’t when I was using windows 8).

So although if you edit the Environment variables you will see that C:\Program Files\nodejs in the path, if you go into a command prompt and type echo %PATH% it doesn’t appear.

I’m not sure why – but I had to make a minor modification to the PATH, save it and then put the modification back for the nodejs to show up in the path.

Then you can run either node or npm from anywhere.

Here’s the code just in case something changes:

var http = require('http');
http.createServer(function (req, res) {
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');


For some reason even though C:\Program Files\nodejs had been added to the system PATH it wasn’t showing up in my path when running dos commands – it took editing the path and saving it to suddenly show up the nodejs in the path.

Once you’ve got the path set up properly then you just have to create the example.js file and run the following commands from a windows command prompt:

> cd C:\path\to\node\example
> node example.js


## Getting npm working

1. There is a npm.bat command in C:\Program Files\nodejs
2. However there’s a known npm issue that requires that the %APPDATA%\npm directory has been created manually otherwise npm doesn’t work
3. You’ll get an error along the lines Error: ENOENT, stat 'C:\Users\[username]\AppData\Roaming\npm'
4. So you have to create your own %APPDATA%\npm

N.B. For “dummies”, aka me: where ever you run npm install in the windows command prompt it will create a node_modules directory and install the module under there
e.g.

C:\Users\[username]> npm install grunt


will install grunt into C:\Users\[username]\node_modules\grunt not into %APPDATA% or C:\Program Files\nodejs\node_modules

Aside

# rebeccapurple

This site’s background is rebeccapurple, its based on the memory of Eric Meyer’s daughter. I have a daughter of two, so reading his tales of anguish are deeply moving.