7
Sep
2017

Nginx Application Server

07 Sep 2017
Laravel location / { proxy_pass http://127.0.0.1:8300; proxy_redirect http://127.0.0.1:8300/ /; proxy_read_timeout 60s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } location ~ \.php$ { proxy_pass http://127.0.0.1:8300; proxy_redirect http://127.0.0.1:8300/ /; proxy_read_timeout 60s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } Config { "applications": { "laravel": { "type": "php 7.0", "user": "nobody", "group": "nobody", "workers": 2, "root": "/var/www/vhosts/laravel/public", "script": "index.php", }, }, "listeners": { "*:8300": { "application": "laravel" } } }
6
Sep
2017

Message reminder

06 Sep 2017
vi /path/to/message.sh #!/bin/bash PID=$(pgrep gnome-session) dbus=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-) export DBUS_SESSION_BUS_ADDRESS=$dbus notify-send -u critical "$1" crontab: `0 * * * * /path/to/message.sh "my message"`
19
Aug
2017

Ubuntu Service Autostart

19 Aug 2017
vi /etc/systemd/system/mongodb.service [Unit] Description=High-performance, schema-free document-oriented database After=network.target [Service] User=mongodb ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf [Install] WantedBy=multi-user.target `systemctl start mongodb` `systemctl enable mongodb` vi /etc/systemd/system/elastic.service [Unit] Description=Port forwarding for 9200 After=network.target [Service] User=javelin ExecStart=/usr/bin/ssh -NTC -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -R 9201:15.0.33.22:9200 user@host.com RestartSec=3 Restart=always [Install] WantedBy=multi-user.target systemctl start elastic systemctl enable elastic https://blog.kylemanna.com/linux/ssh-reverse-tunnel-on-linux-with-systemd/
15
Jul
2017

Install Xdebug for PHP Ubuntu

15 Jul 2017
Prepare to install: apt install php7.0-xdebug php --version Find xdebug path (latest by year): find / -name 'xdebug.so' 2> /dev/null Config update `vi /etc/php/7.0/fpm/php.ini`: zend_extension="/usr/lib/php/20160303/xdebug.so" xdebug.remote_autostart=on xdebug.remote_enable=on xdebug.remote_handler="dbgp" xdebug.remote_host="localhost" xdebug.remote_port=9000 xdebug.remote_mode=req xdebug.overload_var_dump=off xdebug.idekey = PHPSTORM xdebug.max_nesting_level = 512 xdebug.file_link_format = phpstorm://open?%f:%l Then restart: service php7.0-fpm restart
12
Jul
2017

screen

12 Jul 2017
screen -ls screen -dmS mytabname php artisan dosomething screen -r mytabname detach: ctrl+a , d ls -laR /var/run/screen/
12
Jul
2017

DisplayLink Ubuntu

12 Jul 2017
1. Install drivers (http://support.displaylink.com/knowledgebase/articles/684649-how-to-install-displaylink-software-on-ubuntu) 2. Disable secure boot 3. Create file: $ vi /usr/share/X11/xorg.conf.d/10-intel.conf Paste This: Section "Device" Identifier "Intel" Driver "intel" Option "VSync" "false" EndSection Best Solution: $ cat /etc/X11/xorg.conf.d/20-intel.conf Section "Device" Identifier "Intel Graphics" Driver "Intel" Option "AccelMethod" "sna" Option "TearFree" "true" Option "TripleBuffer" "true" Option "MigrationHeuristic" "greedy" Option "Tiling" "true" Option "Pageflip" "true" Option "ExaNoComposite" "false" Option "Tiling" "true" Option "Pageflip" "true" Option "VSync" "false" EndSection 4. Reboot 5. CPU decreasing compiz https://askubuntu.com/questions/689602/disable-all-visual-effects-in-ubuntu-15-10
26
May
2017

Simple mail server

26 May 2017
Before installation mysite.com MX record points to mysite.com **Step 1** Need to do https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-on-ubuntu-16-04 **Step 2** Setup all, except ClamAV (if RAM is enough, ClamAV can be installed) https://help.ubuntu.com/community/PostfixAmavisNew How to siable ClamAV: # @\bypass_virus_checks_maps = ( # \%bypass_virus_checks, \@\bypass_virus_checks_acl, \$bypass_virus_checks_re); **Step 3** Instead Dovecot i prefer this https://help.ubuntu.com/community/PostfixBasicSetupHowto Installing courier IMAP and POP3 apt install courier-pop apt install courier-imap Then service courier-authdaemon start systemctl enable courier-authdaemon /etc/init.d/postfix restart **Step 4** Setup SPF https://www.digitalocean.com/community/tutorials/how-to-create-a-spf-record-for-your-domain-with-google-apps **Step 5** Setup DKIM https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-dkim-with-postfix-on-debian-wheezy **Step 6** Setup DMARK https://habrahabr.ru/company/mailru/blog/170957/
17
May
2017

After Hacking

17 May 2017
tail /var/log/auth.log find . -type f -newermt 2017-01-01 ! -newermt 2017-01-31 grep -lr --include=*.php "base64_decode" grep -lr --include=*.php "@require"
14
Mar
2017

Vue.js

14 Mar 2017
`Example 1` ```html <template> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true"> <i class="icon-bell2"></i> <span class="visible-xs-inline-block position-right">Activity</span> <span v-if="notifications.length > 0" class="status-mark border-pink-300"></span> </a> <div class="dropdown-menu dropdown-content"> <div class="dropdown-content-heading"> Activity <ul class="icons-list"> <li @click="readAll()"><a href="#"><i class="icon-menu7"></i></a></li> </ul> </div> <ul class="media-list dropdown-content-body width-350" v-if="notifications.length > 0"> <notification v-for="notification in notifications"> <a href="#">{{ notification.target_id }}</a> already parsed <template slot="time">4 minutes</template> </notification> </ul> <ul class="media-list dropdown-content-body width-350" v-else> No activity </ul> </div> </li> </template> <script> export default { methods: { readAll: function () { axios.post('/notes/readed') .then(function (response) { this.notifications = []; }.bind(this)) .catch(function (error) { console.log(error); }); }, }, data() { return { notifications: [] } }, mounted() { axios.get('/notes') .then(function (response) { this.notifications = response.data; }.bind(this)) .catch(function (error) { console.log(error); }); Echo.private('App.User.' + window.Laravel.userId) .notification((notification) => { console.log(notification); this.notifications.push(notification); }); } } </script> ``` `Example 2` ```html <template> <div class="target-create-pane"> <div class="form-group"> <label class="control-label col-lg-2">Site ID</label> <div class="col-lg-10"> <input name="id" type="text" v-model="site_id" @blur="blured()" class="form-control"> </div> </div> <div class="tabbable tab-content-bordered" v-if="groups.length > 0"> <ul class="nav nav-tabs nav-tabs-highlight"> <li class="active"><a href="#groups" data-toggle="tab" aria-expanded="true">Groups</a></li> <li class=""><a href="#friends" @click="loadFriends()" data-toggle="tab" aria-expanded="false">Friends</a></li> </ul> <div class="tab-content"> <div class="tab-pane has-padding active" id="groups"> <table class="table target-create-table table-condensed"> <thead> <tr> <th width="3%">Follow</th> <th>Group</th> <th>Screen Name</th> <th>Public</th> </tr> </thead> <tbody> <tr v-for="group in groups"> <td><input :id="group.id" type="checkbox" :value="'-' + group.id" name="groups[]"></td> <td> <a href="" target="_blank"> <img :src="group.photo_50" width="30" class="group-photo"> </a> <label :for="group.id">{{ group.name }}</label> </td> <td>{{ group.screen_name }}</td> <td v-if="group.is_closed == 0">Yes</td> <td v-else>No</td> </tr> </tbody> </table> </div> <div class="tab-pane has-padding" id="friends"> <table class="table target-create-table table-condensed"> <thead> <tr> <th width="3%">Follow</th> <th>Friend</th> <th>Screen Name</th> </tr> </thead> <tbody> <tr v-for="friend in friends"> <td><input :id="friend.id" type="checkbox" :value="friend.id" name="friends[]"></td> <td> <a href="" target="_blank"> <img :src="friend.photo_50" width="30" class="group-photo"> </a> <label :for="friend.id">{{ friend.first_name }} {{ friend.last_name }}</label> </td> <td>{{ friend.domain }}</td> </tr> </tbody> </table> </div> </div> </div> <div class="text-right"> <button type="submit" :disabled="submitDisabled" class="btn btn-primary">Save <i class="icon-arrow-right14 position-right"></i></button> </div> </div> </template> <script> export default { methods: { loadFriends: function () { if (this.friends.length == 0) { axios.post('/friends', { site_id: this.site_id, }) .then(function (response) { if (response.data) { this.friends = response.data; this.submitDisabled = false; } }.bind(this)) .catch(function (error) { console.log(error); }); } }, loadGroups: function () { axios.post('/groups', { site_id: this.site_id, }) .then(function (response) { if (response.data) { this.groups = response.data; this.submitDisabled = false; } }.bind(this)) .catch(function (error) { console.log(error); }); }, blured: function () { this.groups = []; this.friends = []; this.loadGroups(); } }, data() { return { friends: [], groups: [], site_id: 9999999, submitDisabled: true } }, mounted() {} } </script> ```
13
Mar
2017

Git snippets

13 Mar 2017
git config receive.denycurrentbranch ignore vi .git/hooks/post-receive #!/bin/bash cd ../ env -i git reset --hard chmod +x .git/hooks/post-receive git diff --name-status SHA1 SHA2 | cut -f2