Cynics Soapbox

Random thoughts...

Quad Upgrade

When I built the quad I went with a simple controller with the intention of upgrading at some point once I had more idea “what I was doing 🙂 Of course, such an open ended target was a total cop out and after some discussions with a friend and having a little more time on my hands than I had, I recently decided the time was right to start looking at an upgrade. This is what I had (a Hobbyking KK2....

Routing D'oh!

React-router is a great addition to React, but yesterday marked the first time I had used it for a project. It led to a period of head scratching, but maybe this post will help someone else avoid the same mistake I made! Simple Setup Installing it was simple enough. npm install --save react-router Having installed it I then added the import lines, import {Router, Route, Link, browserHistory} from 'react-router'; and then added some routes to the root component. render(( ), document....

postgrest views

When is a view updateable? The answer becomes important when using views to access the data via postgrest. If a view isn’t updateable then insert, update and delete operations will fail. It’s possible to check by requesting ‘/’ from postgrest to get information about the endpoints available and looking at the insertable field. [ {u'insertable': False, u'name': u'fruits', u'schema': u'public'}, {u'insertable': True, u'name': u'colours', u'schema': u'public'} ] In the above, attempts to insert, update or delete from /colours will fail, but...

postgrest lessons learned

I’ve been spending some time recently getting to grips with postgrest by writing a small schema and figuring out how it all sits together with the help of a simple python client. The plan is to continue to develop it as a react/redux app once I have postgrest and the data figured out 🙂 The following are just some things I’ve learned that may have helped me from 10 days ago and may help someone else. Roles I’...

letsencrypt

The idea behind letsencrypt is great. Wanting to add an SSL certificate for one of my domains I decided it was time to see how it worked. Installation No package is yet available for Ubuntu, so it was onto the “less preferred” git route. $ git clone https://github.com/letsencrypt/letsencrypt ... $ cd letsencrypt The posts I read said to run a command, answer the questions and all would be good. $ ./letsencrypt-auto --server https://acme-v01.api.letsencrypt.org/directory auth After...

Command line babel?

Babel is a great project and a really useful npm module. I’ve use it in almost all of my webpack experiments, but recently I had a need to use it from the command line. Thankfully there is the babel-cli module. However, things weren’t as simple as some of the blog posts I found suggested. Starting with a new project and npm the initial installation is the usual breeze. $ npm init -y $ npm install --save-dev babel-cli According to the...

Webpack: sass & import, names

Having started moving to sass for my project and including the required bits in my webpack configuration (blog post), the next issue I ran into was that importing didn’t seem to work as expected. Require not Import? One of the additions I made to my webpack config was to add a resolve section, allowing me to use more convenient and simpler require lines in my javascript. resolve: { modulesDirectories: ['node_modules', 'components', 'css', 'fonts'], extensions: ['', '.js', '.jsx',...

sass

Continuing my delve into React, webpack and so on and after adding a bunch of css files, I decided it was time to join the 21st century and switch to one of the css preprocessors. LESS was all the rage a few years ago, but now sass seems to have the mindshare and so I’m going to head down that route. Installing Oddly enough, it installs via npm 🙂 npm install --save-dev node-sass npm install --save-dev sass-loader Webpack Config The...

Webpack Dev Server

After using webpack for a few days, the attraction of changing to using the dev server are obvious. The webpack-dev-server is a little node.js Express server, which uses the webpack-dev-middleware to serve a webpack bundle. Install Oddly enough, it needs installed via npm! However, as we’re going to run it from the command line, we’ll install it globally. sudo npm install -g webpack-dev-server Running After install, simply running the server (in the same directory as the webpack....

React Mixins

Having written a simple test app I’m continuing to use it to try and develop my React knowledge 🙂 One aspect that I did find a little annoying was the amount of code I seemed to repeat. I kept thinking that I should have a base class and simply inherit from it – a pattern I have used a lot in other languages, but this is React and nothing I had seen suggested that pattern. Enter the Mixin A react mixin...

React Lessons Learned

I’ve been playing with React for a few days now and, as always, have run across a few things that made me scratch my head and seek help from various places. In an effort to capture some of the errors and mistaken assumptions I have made, I’ll try and show them in a very simple way below. As always, comments and suggestions for improvement are more than welcome. A Simple Page To try and show the issues I...

More Webpack

Following on from yesterdays experiments with webpack and react, I’ve changed things round a little today in an effort to make things even simpler. webpack.ProvidePlugin One of the annoying aspects of splitting the single file into smaller pieces was the need to add the require lines to every one. I thought there must be a simpler way – and there is! The ProvidePlugin allows you to tell webpack that certain requires should be added as needed. To use it...