The Daily Awesome Blog Thoughts, stories and ideas.

Supervisor

sudo apt-get install supervisor

Restarting

sudo service supervisor start
sudo supervisorctl reload

/etc/supervisor/conf.d/queue.conf

[program:queue]
command=php artisan queue:listen
directory=/home/vagrant/laravel-root/automation
stdout_logfile=/home/vagrant/laravel-root/automation/app/storage/logs/supervisor.log
redirect_stderr=true

sudo supervisorctl

supervisor> status supervisor> reread queue: available supervisor> add queue queue: added process group supervisor> start queue queue: ERROR (already started) supervisor> status queue RUNNING pid 27174, uptime 0:00:11 supervisor> help supervisor> exit;

Renaming a Branch in Git

First, you want to change your local branch. This couldn’t be easier:

git branch -m my-hot-feature feature-15

Delete the remote branch with the old name: git push origin :my-hot-feature

Re-create the remote branch with the new name: git push origin feature-15

React JS

sync 2 states - change in UI triggers change in data model - chanfe in data model changes UI

Two way data binding: - key-value observing (KVO) - used in Ember.js, Knockout, Backbone and iOS - dirty checking - Angular.js

Virtual DOM - fast, in-memory representation of real DOM - when state of model changes, UI is rendered to virtual dom - React calculates difference in virtual dom - prior vs. new - React only updates what needs to be updated in the real DOM

react and react-dom separated into two components in order to reuse modules in rect-native - share components that behave same across platforms

React virtual DOM is a tree of react nodes. ReactNode: - ReactElement - light, stateless, immutable, virtual representation of a DOM element - ReactText - sring or text

ReactFragment is an array of ReactNodes

var React = require('react');
var ReactDOM = require('react-dom');
/**
* React.createElement(type, props, children)
* type:
* - string: h1, div, p, etc.
* - React class is created by React.createClass() method
* props - js obejct passed from a parent element to a child element {className: 'header'}
* we use className because class is reserved in js
* children - child elements this element should have
* */
var reactElement = React.createElement('h1');
ReactDOM.render(reactElement, document.getElementById('react-application'));

MongoDB Group By

Laravel App on Digital Ocean

Get your $10 credit @DigitalOcean - that’s 2 month of server time - 512 MB/ 1 CPU/ 20 GB SSD/ 1000 GB Transfer https://www.digitalocean.com/?refcode=40a47f269a5b

  1. Copy Keys ssh-copy-id user@123.45.56.78 or cat ~/.ssh/id_rsa.pub | ssh user@123.45.56.78 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys" https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys–2

  2. Error logs: /var/log/apache/error.log

  3. Installing composer curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer https://getcomposer.org/doc/00-intro.md

  4. Installing curl sudo apt-get update sudo apt-get install php5-curl

  5. Add swap memory

  • First try to run composer this way:

php -d memory_limit=-1 /usr/local/bin/composer update If it works, just add memory_limit=-1 to your php.ini and you should be good.

  • If it doesn’t and your box is a Homestead or Ubuntu, check if you have swap memory in your server:

free -h

And you should see something like: Swap: 2.0G 93M 1.9G

If you don’t, you better add some to your box:

sudo dd if=/dev/zero of=/swapfile bs=1024 count=2048k
sudo mkswap /swapfile
sudo swapon -a
echo "/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab
echo 10 | sudo tee /proc/sys/vm/swappiness
echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf
chown root:root /swapfile
sudo chmod 0600 /swapfile https://laracasts.com/discuss/channels/forge/laravel-5-deploy

Enable rewrite module

sudo a2enmod rewrite sudo service apache 2 restart