Angular 4: Bootstrap & Components (part 2)

First install Bootstrap, $ npm install –save bootstrap Then add bootstrap to .angular-cli.json which can be found in the root of the project. Find the ‘styles’ and add the path for bootstrap like this, “styles”: [ “../node_modules/bootstrap/dist/css/bootstrap.min.css”, “styles.css” ], Then in the project root run, $ npm install, Create a component called ‘sum’ with, $…Read More

Hardening SSH

SSH created key-pair More information on this topic at securing-your-server. On your local machine, create a 4096-bit RSA key-pair, $ ssh-keygen -b 4096 If you get a message to say that this already exists or to over write a file, then do not proceed, unless you want to create a new key-pair. If one exists,…Read More

Raspberry Pi 3 Express Application (part 8)

Check Node and npm are installed, $ node –version v7.4.0 $ npm –version 4.0.5 Install Express generator globally, $ npm install express-generator -g Check it, $ express –version 4.14.0 Create a new directory inside /opt/nodeserver $ mkdir tempGraph This will create several folders as well as the package.json file with all dependencies. Next install these…Read More

Raspberry Pi 3 DS18B20 Temperature Sensor (part 6)

Open /boot/config.txt $ sudo nano /boot/config.txt and add dtoverlay=w1-gpio to the end of the file. Reboot the system, $ sudo reboot Then run, $ sudo modprobe w1-gpio $ sudo modprobe w1-therm The change directory /sys/bus/w1/devices/ and list its contents, Change directory into 28-000006c87ee2 and then ‘cat w1_slave’. The ‘t=16125’ this a temperature reading of 16.125…Read More

Raspberry Pi 3 Node Server & systemd (part 5)

Run a simple Node server. Create the file and path, /opt/nodeserver/server.js const http = require(‘http’); const hostname = ‘0.0.0.0’; // listen on all ports const port = 8080; http.createServer((req, res) => { res.writeHead(200, { ‘Content-Type’: ‘text/plain’ }); res.end(‘Hello people, I am a server \n’ + new Date().toISOString()); }).listen(port, hostname, () => { console.log(‘Server running at…Read More

Raspberry Pi 3 Static IP Address & No-ip setup (part 3)

To set up a static IP address on the Pi 3 which will remain constant inside you LAN open /etc/dhcpcd.conf $ sudo nano dhcpcd.conf Add to the bottom of this file, interface eth0 static ip_address=192.168.1.30 static routers=192.168.1.1 static domain_name_servers=192.168.1.1 interface wlan0 static ip_address=192.168.1.30 static routers=192.168.1.1 static domain_name_servers=192.168.1.1 Here 192.1.68.1.30 is the static ip address I…Read More

Setting up gh-pages

Login to github.com and create a new reporitory. Copy the link for this repository. It will look like this, https://github.com/<user-name>/<repo-name>.git On your local machine create a new directory, $ mkdir testGHpages cd into it $ cd testGHpages git init this directory $ git init Add a simple index.html file to this directory. <!doctype html> <html…Read More

D3.js Basic json Graph

Basic example of graphing using D3.js version 3 Useful links used for this post: http://alignedleft.com/tutorials/d3/axes https://square.github.io/intro-to-d3/ <!DOCTYPE html> <html lang=’en’> <head> <meta charset=’utf-8′> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js” type=”text/javascript”></script> <script type=”text/javascript” src=”https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js”></script> <script src=”https://cdnjs.cloudflare.com/ajax/libs/crossfilter/1.3.12/crossfilter.min.js” type=”text/javascript”></script> <script src=”http://cdnjs.cloudflare.com/ajax/libs/dc/1.7.5/dc.min.js” type=”text/javascript”></script> <script src=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js” type=”text/javascript”></script> <link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css”> <link rel=”stylesheet” href=”css/tempGraph.css”> <link href=”http://cdnjs.cloudflare.com/ajax/libs/dc/1.7.5/dc.min.css” rel=”stylesheet” type=”text/css”> <script src=”https://d3js.org/d3-array.v1.min.js”></script> <script src=”https://d3js.org/d3-collection.v1.min.js”></script> <script src=”https://d3js.org/d3-color.v1.min.js”></script> <script…Read More

Part 7: Django Login, Logout & Registration

Login form: Adapted from the login tutorial at techand startup. Create a new app called ‘accounts’ $ python manage.py startapp accounts Add ‘accounts’ to settings.py INSTALLED_APPS = [ ‘accounts’, ‘django.contrib.admin’, ‘django.contrib.auth’, …………. Go to crudProject/views.py and add to the top of the file, from django.shortcuts import render_to_response Below that add, def loggedin(request): return render_to_response(‘registration/loggedin.html’) If you…Read More

Python Dictionary into HTML Template

The following Python code will find instances of {body} in a file template.html and replace it with a string. Then a new file index.html is created with this change. generate.py with open(‘template.html’,’r’) as template_file: template = template_file.read() tokens = {‘title’: ‘My Title in a Dictionary’, ‘header’:’Stuff for heading’, ‘body’: ‘The body stuff’, ‘footer’: ‘This is…Read More