Category Archives: Development

laravel – php artisan simple reference

commanddescription
php artisan listhelp
php artisan tinkerrun tinker
php artisan make resource MyTablecreate resource
php artisan make resource MyTable -collectioncreate resource
collection
php artisan make:exception MyExceptioncreate exception
php artisan make:command MyCommandcreate command
php artisan make:request MyRequestcreate request
php artisan make:event MyEventcreate event
php artisan make:listener MyListenercreate event listener
php artisan make:MyJobcreate job
php artisan make:factory MyFct -model=MyModelcreate factory
php artisan db:seed -class=MySeederexecute seeder
php artisan db:seed –class=DatabaseSeederexecute all seeders

ElasticSearch notes

Resources:

For installation check this url. (DEB page link)

Default cluster configuration:

cluster name elasticsearch

Start/stop service

SysV:

sudo -i service elasticsearch start
sudo -i service elasticsearch stop

Systemd (read more here):

sudo systemctl start elasticsearch.service
sudo systemctl stop elasticsearch.service
sudo systemctl restart elasticsearch.service
sudo systemctl status elasticsearch.service

sudo systemctl enable elasticsearch.service
sudo systemctl disable elasticsearch.service

sudo systemctl start kibana.service
sudo systemctl stop kibana.service

Version and log information

view log sudo journalctl -f
view log for service sudo journalctl –unit elasticsearch

Cluster information

Health curl -X GET “localhost:9200/_cat/health?v”
Indices curl “localhost:9200/_cat/indices?v”

Index management

index stats curl -X GET “localhost:9200/mydb/_stats?pretty”
get all documents curl -X GET “localhost:9200/_search” -H ‘Content-Type: application/json’ -d'{ “query”: { “match_all”: {} } }’
get all documents http://localhost:9200/mydb/_search
count all documents curl -X GET “localhost:9200/mydb/_count”
count all documents http://localhost:9200/mydb/_count
delete index entries curl -XPOST ‘localhost:9200/mydb/_doc/_delete_by_query?conflicts=proceed’ -H’Content-Type: application/json’ -d’ { “query”: { “match_all”: {} }}’
delete index curl -X DELETE “localhost:9200/mydb”

sd

xbindkeys configuration

Setup:

  1. mouse side button 8 sends Enter
  2. mouse side button 9 sends alt+left
  3. tilde sends ctrl+w

 

Installation:

sudo apt-get install xautomation
sudo apt-get install x11-utils
sudo apt-get install xdotool

To find the keycodes run xev or xbindkeys -k:

xev
xbindkeys - k

Here is a sample script:

#send alt+left on side button 9
"xte 'keydown Alt_L' 'key Left' 'keyup Alt_L'"
   b:9

#send Enter on side button 8
"xte 'key Return'"
   b:8

#Using keycodes
"xte 'keydown Control_L' 'key w' 'keyup Control_L'"
    grave + release

 

References:

Vue links

Basics

  1. Official Style guide (v2)
  2. Deverus Style guide
  3. https://michaelnthiessen.com/26-time-saving-tips/

Authentication

  1. Authentication best practices
  2. User authentication with Vue and Vuex (jason watmore)
  3. https://scotch.io/tutorials/handling-authentication-in-vue-using-vuex (scotch.io)
  4. Cookie authentication for APIs

Rest API

  1. Implement with Vuex
  2. API calls with Vuex

Tools

  1. Basic understanding of elixir, gulp and webpac
  2. https://ponyfoo.com/articles/json-web-tokens-vs-session-cookies

Forms

  1. Submit with enter
  2. Use autofocus

Validation

  1. masks

Routing

  1. https://stackoverflow.com/questions/30414860/how-can-i-define-a-route-differently-if-parameter-is-not-integer

Templates

  1. Best Vue JS templates 2018
  2. https://stackoverflow.com/questions/50891858/vue-how-to-pass-down-slots-inside-wrapper-component

Deployment

  1. https://appdividend.com/2018/07/13/vue-history-mode-routing-tutorial/

Use PostMan to post JSON to REST backend

  1. Set web method to POST
  2. Add to the Headers:
    1. a key named: Accept with value application/json
    2. a key named: Content-Type with value application/json
  3. Optionally, if authentication is required:
    1. a key named: Authorization with value: bearer: token
  4. Add the JSON data to the raw area of Body of Postman
  5. Click send.

Token example::

Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sb2NhbGhvc3RcL21pYWNcL2FwaVwvYXV0aFwvbG9naW4iLCJpYXQiOjE1NTc2NjgwOTUsImV4cCI6MTU1NzY3MTY5NSwibmJmIjoxNTU3NjY4MDk1LCJqdGkiOiJDa0VRVUZDa2xTZm9OcTZHIiwic3ViIjoxLCJwcnYiOiI4N2UwYWYxZWY5ZmQxNTgxMmZkZWM5NzE1M2ExNGUwYjA0NzU0NmFhIiwibmFtZSI6Ik1pQWMifQ.AWCjjEQh-Tmc4I9z3R0AA1QLUm5IuZAYSlRjeL5IrLo

Headers:

postman_laravel

Body:

postman_laravel_2