A Decentralized Internet?

I believe that the internet is truly the most important invention the world has ever seen. It gives the world of knowledge to the masses and is not controlled by any one person.

The last remaining problem with the internet is that all traffic routes through internet servrice providers (ISP’s). Each and every single request you ever make to the world wide web at some point routes through your ISP, and ISP’s are controlled by whom?

ISP’s are the last blockade to true freedom of speech and knowledge.

I recently stumbled across something called Maidsafe.


Is this a solution?

Persisting sessions between node js app restart with redis and passport js

Install Redis onto your server & start

Redis is a “NoSQL” key-value data store. More precisely, it is a data structure server. Not like MongoDB (which is a disk-based document store), though MongoDB could be used for similar key/value use cases. The closest analog is probably to think of Redis as Memcached, but with built-in persistence (snapshotting or journaling to disk) and more datatypes.

Similar to a MySQL server or a Mongod server, Redis needs to be installed and run for your app to be able to establish a connection.

After installed to your server, run this command to start it, the default port it will be listening on should be 6379:

Now to your node app.

First, include the connect-redis and redis to your package.json file eg:

Install the new dependencies

Next, require them in your kickoff file, for me it is server.js:

Now start a redis client which will be passed to the session construct.

Now simply pass your redis client to the session construct like so:

And that is it, your node app should be able to persist session data between app restarts.

Local to dev server running a node instance via rsync on windows

This guide has now been extended, please visit here: http://www.beingyesterday.com/linux/bitbucket-sourcetree-ide-rsync-dev-server/


The following setup is good for remote teams, it allows everyone from directors to developers to view the work in progress. It keeps the dev’s computer light ie no local node required just a good ide or editor.

Step 1 – Download and install cygwin

https://cygwin.com/  Download the cygwin setup.exe file. Move the .exe file to a new location, eg “C:cygwin_install_directorycygwin.exe”.

The first run through the setup will create install the all the basics and the cywin terminal.
First run through:
1 – Now run the setup-x86_64.exe, choose the first option “Install from internet”.
2 – On the next screen leave the default install location to be “C:cygwin64”.
3 – On the next screen set the “Local Package Directory” to be the folder you created at the start.
4 – Connection type, whatever suits.
5 – Choose a mirror to download from.. I have always used the cygwin.mirror.constant.com
6 – Just click next and whatever else follows to finish the install.

You should now have a cygwin terminal available, this is a linux style terminal. In “C:cygwin64” you will find a std linux directory structure. You don’t have much else yet, ie no ssh or rsync or basically anything.
Second run through, you need to download nano, ssh and rsync:
1 – Run the setup-x86_64.exe again and use the above settings, ie same local package dir and same mirror.
2 – When you land at the “select packages” dialogue box it should look like this:
select cygwin pachages
3 – Don’t just install everything as it takes about a week to get it all, also you only a fraction of what is available. You will have to run this each time you want something new, ie 3 times for nano, ssh and rsync. Start by searching for “nano”. The interface is horrid. After searching for “nano” where it reads “Install” in the image below it should read default on your screen, press the word “Default” and it should switch all the options below to install… the interface really had no thought put into the design:
cygwin intsall
4 – Just hit next and it will download and install “nano” to c:cygwin64.
5 – Repeat the last four steps for ssh then rsync.

You now have rsync ready to go on you machine, you now just need to add the path to the binaries to your $PATH environment variable.
1 – Go to “Control Panel /All Control Panel /ItemsSystem” then click “Advanced system settings on the left”
2 – On the “advanced tab” click the “Environment variables” at the bottom.
3 – Might as well add the new path to the globals, in the second box scroll down and click to edit the Path variable and add your new option which should be “C:cygwin64bin;” like this:
windows path variable
4 – You now have all the unix tools in your windows cmd, eg to list the contents of a folder both the windows “dir” and the unix “ls” will work. You also have a right click with normal options that cmd bizarely missed out, if think cmd was designed by a chimp on drugs. Here’s a list of some basic unix commands: http://mally.stanford.edu/~sr/computing/basic-unix.html

Step 2 – SSH keys between your local machine and the dev server

You should now have ssh and rsync available to your windows command prompt which means any programs on your local machine have access to rsync, however you don’t want to be entering your password every single time you want to run rsync on your local file set to push changes to your dev server. This is where ssh keys come in.
Create your key set
1 – Open your cygwin terminal.
2 – Run

to make sure you are in you users home directory.
3 – Run

4 – Just press enter and accept all the defaults.
5 – This will have created a new folder “/home/john/.ssh/” with two files inside “id_rsa” and “id_rsa.pub”. List the contents of the folder to see the hidden “.ssh” folder with the options “l” and “a”:

Now you just need to place the public key onto the dev server.
1 – The id_rsa.pub is what goes on the server, run cat on the file to display:

2 – What the cat spat out you need to copy to the server. Open another cygwin terminal and ssh to your dev server:

3 – ensure you are in you home directory,

4 – If your home directory doesn’t have a .ssh folder in it, just run ssh-keygen to create it and accept all the defaults.
5 – Create/edit a file within .ssh/ called “authorized_keys”:

6 – Right click and paste the contents of your public key, it is important that there are no line breaks in the key else shit wont work, each key must be on its own line and must occupy a single line only. Comments start with hash #.
7 – In nano there are a bunch of options listed at the bottom of the page. With the key pasted in, exit the file “ctrl + x”, it will be asking some Q’s at the bottom of the page, just press enter till you exit nano.
8 – If this is a new authorized key file set the permissions to 0600:

That’s it, you should now be able to ssh to your dev server without being prompted for a password. Test this by logging out of the server and ssh’ing back in (‘logout’ from cli in the server to logout).

Running the rsync command

So far you should have the cygwin packages for ssh nano and rsync installed and you should be able to ssh to your dev server without being prompted for your password. Now lets try running rsync.

Try running this from a new cygwin terminal, obv with your own details in 🙂

The command broken down,
-avz options are to do with compression and speed.
–delete this flag will delete any files it finds on the target that do not exist on the source.
–chmod=ug=rwx,o=rx This sets the permission of the files on the target, this is required on windows as permissions are handled differently between unix and windows. Without it you files would not have any permissions set at all
-e”ssh -p 22″ this flag saying use port 22 for the ssh connection
/cygdrive/d/work/projectX/ this is the source, note the trailing /. cygdrive is kind of like the mnt folder in linux, it is where other drives are accessed.
john@ this is the target note the trailing /
The / at the end of the paths there says to rsync, copy everything from within the folder.

See these two posts for linking rsync commands to editors: phpstorm/webstorm komodo edit/netbeans/eclipse

Keep your node alive and auto restarts during your rsync

pm2 is your friend here. This can keep your node application running even after you close your terminal. With the –watch flag, your node instance will restart each time a file is changed

After you have started your app you can tail the logs with



Now you are all setup. Run an rsync command and watch your pm2 logs fly by in a cygwin terminal, save a file and give your graphics designer a shout to get him to look at something without having to get him to come over to you.

Creating a host entry on windows and macs

A computers hosts files is effectively a local domain name server… It is somewhere your computer will look first  before asking your ISP which IP to head to for any particular domain name, eg google.

The name of the file is “hosts” without a file extension.

Hosts files on macs, windows and linux are all the same (thankfully, just in different locations) and all must be edited by the computer admin account.

On windows the location is at:


To add an entry to your hosts file on windows:
1 – search for “notepad.exe” from the start menu
2 – right click and choose “run as administrator
3 – Once you get into notepad (after pressing Yes to the UAC popup) hit file > open
4 – Navigate to the above location ie: c:/windows/system32/drivers/etc/
5 – The drop down above open and cancel shuold read “Text Documents (*.txt). As we need to open our “hosts” file, choose “All files” and there should be a list of files appear.
6 – Choose the “hosts” file and open.
7 – There might be a bunch of stuff in there already. Just scroll right down to the bottom if so.
8 – Now enter you entry, for this example my ip is and my domain is john.test.com. The entry will then look like this on its own line:  john.test.com

9 – After entering the entry, just hit file save and close. Now when you point your browser to john.test.com (or whatever you entered) the browser will head off to or whatever IP you entered.

(on some older versions of windows a reboot was required to take note of the new entry, not on win7 or win8)

On macs and linux the location is:


1 – Editing the hosts file requires a terminal command prompt. Just search for it in spotlight or applications (on mac’s it is in /applications/utilities/terminal).
2 – With a terminal open type then press enter:


3 – You should be asked for your password, type it (you wont see your password being typed for security but it is being entered) then press enter.
4 – Now you to edit the hosts file. Try one of the following to access the hosts file:

nano /etc/hosts


pico /etc/hosts

5 – Hold ‘ctrl’ and then ‘v’ to scroll to the bottom of the page (there is no mouse).
6 – Type in your entry eg:  john.test.com
7 – Hold ‘ctrl’ and press ‘x’  at the bottom of the screen it should be asking something like:

“Save modified buffer….”

Press enter, then press enter again.

8 – You should now be out of the file. Close terminal. Your browsers should now go to when you enter john.test.com into the address bar.