Thursday 21 April 2022

Using AWS EC2 Linux servers with Github

 This post attempts to show you how to

  • create AWS EC2 Linux server instances
  • connect to them using SSH
  • clone your GitHub repo onto the instance

Create AWS EC2 Instance

AWS is 'Amazon Web Services'.  Basically Amazon provide rack upon rack of computers that you can borrow.  They provide many cloud based services most of which I don't really understand what they are, but when I want to use an AWS Linux server I need to use EC2.  It stands for "Elastic Compute Cloud" and it basically offers a whole range of different machines with different operating systems running on them.  You can rent just one of them, or you can rent armfuls of them.

  • Login to AWS and go to the EC2 dashboard
  • click on 'Launch Instances' to configure an instance and launch it.

AWS EC2 Instance configurations: Operating System

Choose the operating system you want installed on the instance.  I choose Amazon Linux because I think I read that it is best tailored to AWS EC2 instances.  Ubuntu is an alternative option.

AWS EC2 Instance configurations: Instance Type

This is basically how good the computer you are renting is and what it's spec is.  It's worth considering a 'free tier' config if you are in your first year. 
  • t1 is older than t2 and t3 is the newest.
  • a vCPU is a sort of standardised AWS performance CPU
  • other specs are obvious

AWS EC2 Instance configurations: Key Pair

You need to create a pair of keys to ssh to the instance from a terminal.  The public key is stored on the instance and you must save the private key locally.  This means that only someone with the private key can connect to the instance.
  • Create a key pair - use RSA and .pem
You must save the private key.  Confusingly the private key has a .cer filetype not a .pem one, but it still seems to work fine.

Make sure you change the permissions of the private key because ssh checks and fails if it is public:

chmod 400 woodys_private_key.cer

AWS EC2 Instance configurations: Network Settings

Allow SSH traffic from anywhere unless you're doing something very sensitive.

AWS EC2 Instance configurations: Storage

Self explanatory

AWS EC2 Launch Instance

Check the summary matches how you think you've configured it and , hit the 'Launch Instance' button.

Congratulations.

Connect to an AWS EC2 Instance using SSH

#1 private key

Make sure you have the private key from the instance's key pair on the machine you want to ssh from.

Make sure it only has user read access:

chmod 400 woodys_private_key.cer

#2 Public IPv4 address

Note the public IPv4 address associated with the instance from the EC2 Dashboard. E.g. 34.226.22.46

#3 SSH

The user for the EC2 instance is always `ec2-user`.

ssh -i ~/Downloads/woodys_private_key.cer ec2-user@34.226.22.46

Reply 'yes' to confirm you want to connect.


Clone your GitHub Repo

Assuming you have code already on a github repo.

Install Git on your instance

sudo yum install git

Clone repo

On the repo's GitHub page, click on the green 'code' button.  Copy the https .git address.  E.g. https://github.com/Woody/my_repo.git

Clone the repo into the 'workspace' directory

git clone https://github.com/Woody/my_repo.git workspace

It shouldn't need any username/passwords

Push repo changes back to GitHub

This process is slightly more involved.  Basically you need to use a username and 'password', but GitHub have replaced passwords with personal access tokens.

Check that you have a valid GitHub 'personal access token'

GitHub have sort of replaced passwords with 'personal access token's or PATs.  You need to create one through a bizzare route, then use the PAT as your password.  

Make sure you select the permissions that you want the PAT user to have. Presumably you want them to be able to access the 'repo' so check all the repo boxes at least.

The PAT is basically a password to you or I when you actually come to use it.

Push repo changes back to GitHub

Assuming you've committed changes locally on your AWS EC2 instance.  To push the repo back:

git push

This will prompt you for your "Username for 'https://github.com':"
Respond with your GitHub username (obviously).  E.g. woody

It will then prompt you for your "Password 'https://woody@github.com':"
Respond with your GitHub PAT not your GitHub password (less obviously).


Creating your own Bitcoin! (Well a ERC-20 token)

It is surprisingly straightforward to create your own cryptocurrency.  Anyone with programming experience can do it.

History

Bitcoin (2009) was the first, seminal, crypto currency.  It doesn't 'do' anything, it just exists, you can transfer it, and if you want to get involved in maintaining the blockchain, you can get rewarded with a few newly minted Bitcoin (BTC).

The bitcoin blockchain just records transactions between bitcoin accounts, and who has been granted new bitcoin for maintaining the blockchain (aka mining.)  The data content in the blockchain does not have to be restricted to just a list of transactions though.

Ethereum changed the rule book in 2015 by allowing users to store code in the blockchain as well as storing a list of transactions.  Users can run these code segments to create new crypto 'tokens' (new coins) and these can be transferred between user accounts too in addition to Ethereum's native Ether (ETH) coin.

The ERC-20 standard for creating new tokens was developed.  We are going to create an ERC-20 token.

The value of ETH has risen and demand for the Ethereum network has also risen to the point where recording simple transactions on the Ethereum blockchain has become very expensive (e.g. $100).

Binance is the largest cyrpto exchange and is very ambitious.  Binance saw an opportunity to address the high Ethereum network fees by copying the open source Ethereum code and creating their own network, the Binance Smart Chain (BSC). This uses the Binance coin (BNB) to pay for entries in the block chain and it is very much quicker and cheaper to use than the Ethereum network.

The code that is stored on the blockchain (smart contracts) is usually compiled from Solidity language source code.  Because BSC is a clone of the Ethereum network, the same Solidity code can be compiled to run on both networks.

BSC has published the BEP-20 standard for tokens that is the same as the ERC-20 token standard.

We are going to create a BEP-20 token.

To develop and debug your smart contract code test networks exist which run the same code as the main networks (Ethereum or BSC), but they are free to use.

We are going to create our token on the BSC test network.

Crypto accounts

Crypto coins/tokens are stored on a network in an 'account'.  An account consists of just two things:
  • A private or secret key.  
    • A long number.
    • May actually be a sequence of random words used to generate that number.
    • Everyone who knows this number (or words) owns the crypto. 
  • A public address.  
    • Another long number.
    • Software generated from the secret key
    • People can transfer money into the account by sending it its public address.
  • Blockchain entries recording what currencies are stored in this account on this network.

  (May actually be a sequence of random words wh

What is a crypto

#1 Create a MetaMask Wallet


dfs
d

The public address is generated from the secret key.
Cryptographic 'magic' means that it is not possible to obtain an account's secret key from it's public address.  However, the public address is generated from the secret key.

The private key may

    • It will be either a long number or a sequence of random words that can be used to generate that long number
    • Anyone who knows this secret key
  • * long a user needs to generate an address that they can use to send crypto coins to.  

Users hold their crypto coins in a 'Wallet'.  A wallet is essentially place to store their private/secret 'key's. one or more crypto accounts.  For each account in a wallet the user must a .  People 



Crea

Monday 13 April 2020

Beko DIN28R22 programming guide

The user manual isn't very useful to program the dishwasher quickly.  So here's my quick guide.

The buttons are labelled like this:

Key locations



Enter programming mode

  • Press "On/Off" (key 1)
    • to turn on machine
  • Press and hold both the 
    • "program select" (key 2) and the 
    • "time delay" (key 9) at the same time for 3 seconds
  • Wait for 3-2-1 countdown.

Navigating the programming mode

Press the "program select" (key 2) to rotate around the programming options. 
Press the "time delay" (key 9) to rotate around the selections for each programming mode.

When programmed don't forget to save the new settings by pressing the "On/Off" key

Programming Options

  • L - interior light (some models)
    • L 0 off
    • L 1 on
  • P - rinse aid
    • P 0 - 0 rinse aid doses
    • P 1 - 1 rinse aid doses
    • P 2 - 2 rinse aid doses
    • P 3 - 3 rinse aid doses
    • P 4 - 4 rinse aid doses
  • S ???
  • r - water hardness level ( adjust the 'regeneration adjustment switch' on the  inside of the dishwasher with a screwdriver to match the level set here.  See image below
    • r 1 Softest level - least salt
    • r 2
    • r 3
    • r 4
    • r 5 Hardest level - most salt
  • a (looks odd - a bit like a d) - automatic detergent detection
    • a 0 off
    • a 1 on

Cancel current program and drain early

  • Press and hold both the 
    • "program select" (key 2) and the 
    • "time delay" (key 9) at the same time for 3 seconds
"0:01 is displayed, close the door of the product and wait for the draining process complete. Draining is completed in 2 minutes and the machine gives an audible warning when it is completed." 

Hidden programming mode

Don't know what any of these modes do add comments if you know and I'll update the post.
  • Start from dishwasher off statePress "On/Off" (key 1)
    • to turn on machine
  • Press and hold both the 
    • "on/off" (key 1) and the
    • "program select" (key 2) at the same time for 3 seconds
  • Wait for 3-2-1 countdown.

Hidden programming mode options:

  • 1 Hft
  • 2 1Ft
  • 3 5Ft
  • 4 EEP
  • 5 dno
  • P/A (flashing) 4:02