Sunday, 15 March 2020

Git commands

what is the best way to connect local folder to existing github repo?

 https://stackoverflow.com/questions/50025872/how-do-i-connect-a-local-folder-to-an-existing-github-repo

# Initialize the local directory as a Git repository.
git init

# Add files
git add .

# Commit your changes
git commit -m "First commit"

# Add remote origin
git remote add origin remote repository URL
# Remote URL look like this https://github.com/user/repo.git

# Verifies the new remote URL
git remote -v

# Push your changes
git push origin master

 

 Create github repository


1. rm -rf .git

2. create a git repository on website.

3.
echo "# SydneyCameraRepair" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin 
git push -u origin master

To use Github destkop


Git commands

change branch (will show error if branch does not exist)
git checkout CE-1234

current branch name
 git branch | grep \*

Find all branch like CE-1234
git branch | grep CE-1234


check who is my origin
git remote -v

remote git commands?
Git remote …
https://help.github.com/en/github/importing-your-projects-to-github/adding-an-existing-project-to-github-using-the-command-line

who am I?
git config –list


history
git log

git log with file changes
git log --name-only

Revert to previous code
git log
git log –oneline
git checkout 27d2991486a742a16bc2d317b6d29d96a02b210c
git checkout -b CE-1234-kkk

//delete a remote commit 
https://ncona.com/2011/07/how-to-delete-a-commit-in-git-local-and-remote/
git reset --hard  44780335d2c5790917e5908cbdd18b283b650e41
git push origin +CE-1234


quit?
q

//----------------------
Git Frequent
//----------------------

//rename local branch
git branch -m <new_name>
//delete local branch
git branch -d master

//get remote master
git checkout --track origin/master

//create local branch
git branch CE-1234
git checkout CE-1234 or ...
git checkout -b CE-1234

//create local branch from the remote master branch
git checkout -b CE-1234 origin/master

//git push local
git commit -a -m "first commit"

//git push remote
git push -u origin CE-1234


git stash
git stash pop
git stash clear

//Discard all local changes to all files permanently:
git reset –hard
or 
git stash

git reset vs revert
https://stackoverflow.com/questions/8358035/whats-the-difference-between-git-revert-checkout-and-reset

https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting

https://stackoverflow.com/questions/22620393/various-ways-to-remove-local-git-changes

https://docs.gitlab.com/ee/topics/git/numerous_undo_possibilities_in_git/

git fetch
get pull

Saturday, 14 March 2020

The very first ember table

The very easy ember table didn't show.

https://opensource.addepar.com/ember-table/docs/quickstart

Make sure after installing ember-table, restart the ember server
ember s


Then it shows.


work-order-table.hbs
{{this.isLarge}}
{{columns.firstObject.name}}


<EmberTable as |t|>
<t.head @columns={{columns}} />
<t.body @rows={{rows}} />
</EmberTable>



work-order-table.js
import Component from '@glimmer/component';

export default class WorkOrderTableComponent extends Component {
constructor(...args) {
super(...args);
this.isLarge = true;

this.columns = [
{
name: `First Name`,
valuePath: `firstName`
},
{
name: `Last Name`,
valuePath: `lastName`
}
];
this.rows = [
{
firstName: 'Tony',
lastName: 'Stark',
},
{
firstName: 'Tom',
lastName: 'Dale',
}
];
}
}






Ember data read from json file

Search for 'json file' from Ember tutorial page



It talks about putting json file public >> api >> workorder.json
Main route file, workorder.js file will read the json file as below.


export default class WorkordersRoute extends Route {

async model() {
let response = await fetch('/api/workorders.json');
let parsed = await response.json();
console.log("parsed", parsed);
return parsed;

}
}

You can add css into public >> assets >> scr.css
and include it from index.html file.

<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/sydney-camera-repair.css">


API working, route is working. good



{{#each @model as |wo|}}
<span class="mybold">{{wo.id}}</span>
<WorkOrderListing @workorder={{wo}} />
{{/each}}



Create Workorders api on Lumen



1. Create controller
Http >> Controllers >> WorkOrderController.php

2. Create Model

WorkOrder.php
Make sure class name is WorkOrder not Author.

3. Add routes
routes >> web.php
$router->get('workorders', ['uses' => 'WorkOrderController@showAllWorkOrders']);
$router->get('workorders/{id}', ['uses' => 'WorkOrderController@showOneWorkOrder']);
$router->post('workorders', ['uses' => 'WorkOrderController@create']);
$router->delete('workorders/{id}', ['uses' => 'WorkOrderController@delete']);
$router->put('workorders/{id}', ['uses' => 'WorkOrderController@update']);



4. Make sure your database (matthew_schema according to .env file) has 'work_orders' table. If model name is WorkOrder, system looks for work_orders. If model name is Author it looks for authors table.


5. Copy 1200 rows from browser to ember project /api/json file.
/Users/inheeoh/work/sydney-camera-repair/public/api/workorders.json

6. Ember routes will filter only this year's tasks.


7. it shows on website.







Tuesday, 10 March 2020

Let's install Lumen on LAMP in AWS

I had an error while running the first lumen command.
ubuntu@ip-172-31-26-11:~$ composer create-project --prefer-dist laravel/lumen authors


Problem 1
    - phpunit/phpunit 8.5.x-dev requires ext-dom * -> the requested PHP extension dom is missing from your system.

resolution:
https://stackoverflow.com/questions/43408604/php7-install-ext-dom-issue

In above link, both below commands failed and takes long.
composer update
composer require cviebrock/eloquent-sluggable

For above memory exception, below link has a solution.

https://github.com/geerlingguy/drupal-vm/issues/547


sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Above seems working. Failed to download....Now trying to download from source ...INstalling... continue.

composer update is finished.
Below takes forever. have a coffee.
composer require cviebrock/eloquent-sluggable
I also had bunch of below error. which could be resolved by below url. I think I should have installed these first.
https://stackoverflow.com/questions/41274829/php-error-the-zip-extension-and-unzip-command-are-both-missing-skipping
The zip extension and unzip command are both missing,
NOw, let's create the lumen project again.
composer create-project --prefer-dist laravel/lumen authors
Beautiful, project created on LAMP! It was not working on XAMPP.
Before running sql part, migration, you have to 
(1) create schema manually by running mysql
(2) edit .env with root userid/password
Deploy
This url saved me!
https://laracasts.com/discuss/channels/lumen/how-to-deploy-lumen-on-web-hosting
and this looks helpful as well.
https://stackoverflow.com/questions/55629307/how-to-deploy-lumen-framework-on-shared-hosting-subdomain
lumen deploy The requested URL was not found on this server.'
The error fixed by below
https://stackoverflow.com/questions/28242495/laravel-the-requested-url-was-not-found-on-this-server

ubuntu@ip-172-31-26-11:/etc/apache2/mods-enabled$ sudo vim /etc/apache2/apache2.conf 
ubuntu@ip-172-31-26-11:/etc/apache2/mods-enabled$ sudo systemctl restart apache2

Following the godaddy url, my lumen api structure look as below.


Install XAMPP

Installation
Ssh connection
matthew@SYDNEY-D-003:~/Dropbox/TechDoc/AWS Documentation/keypair$ ssh -i "matt_singapore_ec2_keypair.pem" ubuntu@54.251.163.161
ubuntu@ip-172-31-16-44:~$ sudo apt-get update
sudo /etc/inid.d/apache stop
Restart webserver
sudo /opt/lampp/lampp restart
Change config file >> all granted
phpmyadmin
username: root
password: xxx
Go to index.html
ubuntu@ip-172-31-16-44:~$ cd /opt/lampp/htdocs/