Installing Haskell ++ Emacs on Windows

Haskell

Firstly install the haskell-stack chocolatey package:

choco install -y haskell-stack

For me that perfectly installed haskell and meant that I could run stack commands and have stack ghci running in a DOS prompt.

Emacs

Chocolatey has an Emacs package:

choco install -y emacs

This puts the emacs binaries into the chocolatey bin directory. Then the .emacs file and the .emacs.d directory go into %APPDATA%.

This installs an Emacs windows program. I wondered if there was a DOS version similar to Vim. There is an Emacs For DOS – but this isn’t part of the Chocolatey package, which comes from the GNU Emacs FTP directory.

Intero

The haskell project have a new integration with Emacs. I have to say this installed remarkably easy. The only problem I had was that I’d put a bad config into %APPDATA%\stack\config.yaml and this created errors – that were well explained in Emacs.

It’s not 100% clear how you get things to work though. Bare in mind I’ve never used Emacs before today.

I have managed to get Haskell setup and working, which came with stack.

Following the Intero guide, the installation of the package was easy enough – just edit the %APPDATA%\emacs.d file. I restarted Emacs and the Intero package installed itself without errors.

Following the guide further I ran the stack new intro-demo command in a directory. This created the intero-demo directory and put everything in it. If you then ‘File > Open Directory’ in Emacs to open the intero-demo directory. Opening Setup.hs had the affect of getting Intero to install itself.

At this point things were actually working – but it wasn’t obvious the the error as you type checking was happening because it was erroring at the very first command of the Setup.hs

However if you open up a new Haskell file in the directory it should start doing error checking on the fly.

Advertisements

Hoping the Brexit vote was a protest vote, not a racist one

The only positive I hope from this is that the Brexit vote was a protest vote.

So I’m hoping the majority of ‘leavers’ aren’t siding with Farage, they don’t care about Boris – they just want to say Fuck You to all politicians and leaders.

This is probably the first and only time that the entire population have been given a protest vote. This is not a choice between one dodgy politician or another politician. This is not choosing between Trump or Clinton.

This is a chance to say fuck you to every single party. This is fuck you to the leaders of both the Conservative and Labour parties.

When this chance comes along – you don’t care about the consequences. You don’t care if the ‘leave’ campaign is spouting lies, you don’t care about the doom spouted by the ‘remain’ campaign. You just want a chance to say fuck you. You know the system is wrong and this is the only tool you’ve got to say so.

I certainly respect the people who protest for what they believe in. Perhaps I’m wrong for thinking all the pensioners don’t care about the consequences. Perhaps they know better than me that the pain of leaving is worth it.

There are some heart felt comments from leavers, not based on the crap spouted by the leave campaign, in this blog post Dear Brexiteer. What we need you to do now.:

“I voted leave , There its out there .. I trusted DC to come back from Brussels with a list of pledges that would let us have some tools to work with to make me feel that improvements could be made to the way we live..
Be it a better NHS ,Schools ,social care services,security. ..
He came back with nothing and nothing was offered .. in fact we were told that it would never change..
So people who have had enough like myself and 17 million others voted with our feet in the only way we know .. a very British revolt ..
Now we are being called racist and xenophobic but this is just so untrue for the masses.. we just need change .
The EU is a broken antique of a monster that isn’t up to listening to the working classes..
We have been called inward looking but again that is not true. . I concider myself Global I want to be able to talk with anyone across the world’s economy. .
Things will never be the same again and for that I feel that my cross mattered.
The first time I think the working class has ever mattered…”

So I hope when all the dust settles that we’re all still willing to tell Farage and Johnson to go fuck themselves (I’m pretty sure not many people care about what Gove says).

Jupyter on Windows with Chocolatey

Install Python

This is a quick post (and will probably be outdated quickly), but it took me a while to get it correct.

I wanted to install Jupyter on Windows. The recommeded route is via Anaconda but I like to use Chocolatey the Windows package manager as much as possible.

I used Chocolatey to install Python package (currently v3.5.1). Assuming you’ve installed Chocolatey already, run as administrator:

choco install -y python

This installs python to C:\Program Files\Python35. It also installs and pip.exe to C:\Program Files\Python35\Scripts.

Add C:\Program Files\Python35 and C:\Program Files\Python35\Scripts to your PATH then you should be able to run python and pip immediately.

Install PIP (hint: it’s already installed)

Note that pip gets automatically installed when you install python – nothing extra is required.

You can get led astray here by an official guide which suggests having to download and run ez_setup.py.

Don’t do this.

There is also confusingly a Chocolatey PIP package. Again don’t install this.

Otherwise you might end up here.

Running PIP packages

Because we’re using Chocolatey, the installation doesn’t follow the recommended installation for Jupyter.

The main thing is that you need to add the python Scripts directory to your PATH, as above.

Install Jupyter

Run as administrator:

pip install jupyter

This will install a jupyter.exe file into the Scripts directory. If that directory is in your PATH, then you should be able to directly run jupyter commands.

Create a Jupyter notebook

Jupyter runs inside the browser but installs files and all the save data in the directory that you run the jupyter command from.

mkdir jupyter
cd jupyter
jupyter notepad

If everything is working that will open up your browser at http://localhost:8888/.

Lock Stock Pomodoros

I give you http://pom.ianchanning.com. Pomodoros with a Lock Stock film quote at the end of each one.

I’m a little obsessive about timers (see bottom) and the other pomodoro timers I’ve tried failed on different counts.

I’ve tried to cram everything I find useful about a timer.

Firstly spacebar to start/stop. The timer should be something that sits in the background and requires minimal attention. So a quick ctrl+tab to get the the pomodoro tab and then hit space and then back to your work.

Secondly the timer appears in the title bar and it appears first. Then you can easily see that it’s running so that you can still see the timer when you have lots of tabs open.

Thirdly there’s a start and stop. Possibly this flies against what a Pomodoro timer should do. However any timer I have I want to be able to start/stop/reset. That’s just what a timer should do, it’s annoying if it doesn’t.

Fourthly the timer has to notify you properly when the pomodoro finishes. This is achieved through a buzzer and a browser notification. Notifications sometimes don’t work or you don’t see them so you need the buzzer backup. Sorry IE folks your browser is still terrible and can’t handle the Javascript Notifications and I can’t be bothered to fix it when it’s just for a personal project.

Fifthly a count of the pomodoros is useful to know how many you cranked out in the day.

Sixthly, a bit of browser responsiveness goes a long way.

And that’s it. No more please.

Well except I needed to put something in the notification so I jazzed things up with quotes from Lock Stock and Two Smoking Barrels. If you can’t take the ‘c’ word at least once then this timer is not for you.

For those who got this far. I started with the most basic timer I could think of that still had a simple start-stop mechanism. Then after staring at the jquery code I’d copied I realised I could make a generic jquery ticker function. So I can tick 25 minutes down and then tick the pomodoro count up 1 each time. The rest is a codged together front end on top of that.

Scrum unsucked

[Photo credit: darkmatter]

I’ve been reading into Scrum closer recently and it just seems like a horrible corruption of an inspirational idea, that could much more easily be integrated into normal project practices.

Agile

I love the agile principles. I’m repeating them here for my own benefit, I like a good list as much as the next.

  1. Customer satisfaction by rapid delivery of useful software
  2. Welcome changing requirements, even late in development
  3. Working software is delivered frequently (weeks rather than months)
  4. Working software is the principal measure of progress
  5. Sustainable development, able to maintain a constant pace
  6. Close, daily cooperation between business people and developers
  7. Face-to-face conversation is the best form of communication (co-location)
  8. Projects are built around motivated individuals, who should be trusted
  9. Continuous attention to technical excellence and good design
  10. Simplicity—the art of maximizing the amount of work not done—is essential
  11. Self-organizing teams
  12. Regular adaptation to changing circumstances

Each principle makes sense, even if, perhaps, it isn’t attainable.

Their manifesto is harder to figure out, but still has a great aspirational feel to it.

We value this Over this
Individuals and interactions Processes and tools
Working software Comprehensive documentation
Customer collaboration Contract negotiation
Responding to change Following a plan

However importantly note that the second column is still valued, but just not as much as the first.

Scrum

Now read the Scrum Guide™ (TM!). Scrum just seems like a conversion of agile concepts into sucky word project management.

I realised I’d already got it wrong with what a sprint was – I thought it was two weeks work. They suggest that it should be a month’s worth of work – which makes sense, but why not just call it a month’s worth of work – or if it’s going to be less just call it an increment.

Anyway I read through the Scrum Guide and here’s my unsucked version of their main concepts.

Scrum Guide™ Unsucked agile guidelines™
The Scrum Team The Team
The Product Owner The Client
The Development Team The Developers
The Scrum Master The Project Manager
The Sprint The Sprint (it isn’t actually that bad a word) / Increment
Sprint Planning Planning
Daily Scrum Talk
Sprint Review Sprint Update
Sprint Retrospective Sprint Review
Scrum Artifacts Documents
Product Backlog Issues
Sprint Backlog Sprint Issues
Increment Completed Issues
Artifact Transparency Simplification
Definition of “Done” Happy Client

Can I have a word…

Scrum style

“Shall we go over the Sprint Review later? I’m not convinced that the Product Backlog contains all that we require for the definition of done. The Daily Scrum this morning wasn’t great as the Scrum Master had to get the Development Team to better explain their progress to The Product Owner. We need to make the Sprint Backlog artifact more transparent as The Product Owner feels we haven’t followed what we agreed at the last Sprint Retrospective.”

vs sane

“Shall we go over the Sprint update later? I’m not convinced that the issues contain all that we require for the client to be happy. The talk this morning wasn’t great as the Project Manager had to get the developers to better explain their progress to the business. We need to simplify the Sprint’s issues as the client feels we haven’t followed what we agreed at the last Sprint review.”

Please let the first type of conversation cease.

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.

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.

Get the home page server example.js working

Here’s the code just in case something changes:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  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