Categories
Uncategorised

Docker Cheat sheet

Quick commands :

— to rebuild after changes to the Dockerfile.
docker-compose build

— équivalent de vagrant up
docker-compose up -d

— accéder au container. container_php is the container name.
docker exec -it container_php bash

To install : https://docs.docker.com/install/linux/docker-ce/ubuntu/

Categories
Uncategorised

Symfony PHP Testing with PHPUnit (Reminders)

Start the web server
php bin/console server:start -d public

Run test on file
./vendor/bin/simple-phpunit tests/Controller/Api/filenametotest.php

Categories
Uncategorised

Console app hangs until a key is pressed

On Windows,

When you run a console application, it happens that it freezes and it unfreezes just by hitting a key.

That behavior just made me lose about an hour of computing time this morning. Like it is often, the answer seem to be on StackOverflow http://stackoverflow.com/questions/39664389/console-application-freezes-until-key-pressed-mouse-clicked

I’m trying this.

Categories
Development Security Technical Support

sysPass 2.1.8 – Text not being translated

After some hours being lost, I discovered why sysPass translation system was not doing anything even if locale was installed.

The issue lies in setLocales (/inc/SP/Core/Language.class.php), it doesn’t set all language variable.

putenv('LANG=' . $lang);

is not enough. The following line needs to be added.

putenv('LANGUAGE=' . $lang);

It works with this but according to ubuntu help page, the value we set for LANGUAGE would not be ideal. See for yourself at https://help.ubuntu.com/community/EnvironmentVariables.

I’m guessing the difference between LANG and LANGUAGE has to do with how the combo Apache/PHP is running. I didn’t see anything that indicated setting both variables might be wrong.

I discovered the fix which works with PHP 7.1.* when I saw the comment from “yuricardenas at gmail dot com” in the PHP manual, http://php.net/manual/en/book.gettext.php.

 

 

Categories
Uncategorised

PHPExcel – PHP 7

Don’t forget to install php zip library if phpexcel outputs a 0 byte file.

sudo apt-get install php7.0-zip

Categories
Uncategorised

MySQL – Remove definers

Remove definers from mysql dump files.

sed -r -e ‘s/DEFINER=’.+’@’.+’\s//’ < dump.sql  > dump-final.sql

I will update this entry when I can find the blog I found it on just so the person can get credit for it.

Other options is to rename the definers.

UPDATE `mysql`.`proc` p SET definer = ‘newdefiner’ WHERE definer=’olddefiner’ AND db LIKE ‘databasename’;

Categories
Uncategorised

Ubuntu – Start shell script from desktop shortcut

cd /usr/share/applications
sudo nano myapp.desktop

[Desktop Entry]
Name=MyScript
Comment=Description
Exec=sh -c ‘/home/USER/scripts/myscript’ && disown
Icon=/home/USER/scripts/icon.png
Terminal=false
Type=Application
StartupNotify=true

Replace USER by your username
For Icon, type the whole path to your image.

Drag and drop your newly created shortcut to Ubuntu left menu bar.

Categories
Uncategorised

Vagrant issues with mounting shares. Ubuntu 16.04

If you have the following when you do vagrant up :

Failed to mount folders in Linux guest. This is usually because
the “vboxsf” file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u www-data`,gid=`getent group www-data | cut -d: -f3`,dmode=775,fmode=774 vflsf_s8ktdqeoxrjd /var/www
mount -t vboxsf -o uid=`id -u www-data`,gid=`id -g www-data`,dmode=775,fmode=774 vflsf_s8ktdqeoxrjd /var/www

The error output from the last command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device

You probably have a different version of the guest additions installed in your virtual machine. if it is the case do the following.

sudo vagrant plugin install vagrant-vbguest

if that fails with :

Installing the ‘vagrant-vbguest’ plugin. This can take a few minutes…
/usr/lib/ruby/2.3.0/rubygems/specification.rb:946:in `all=’: undefined method `group_by’ for nil:NilClass (NoMethodError)
from /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb:275:in `with_isolated_gem’
from /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb:231:in `internal_install’
from /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb:102:in `install’
from /usr/lib/ruby/vendor_ruby/vagrant/plugin/manager.rb:62:in `block in install_plugin’
from /usr/lib/ruby/vendor_ruby/vagrant/plugin/manager.rb:72:in `install_plugin’
from /usr/share/vagrant/plugins/commands/plugin/action/install_gem.rb:37:in `call’
from /usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call’
from /usr/lib/ruby/vendor_ruby/vagrant/action/builder.rb:116:in `call’
from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:66:in `block in run’
from /usr/lib/ruby/vendor_ruby/vagrant/util/busy.rb:19:in `busy’
from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:66:in `run’
from /usr/share/vagrant/plugins/commands/plugin/command/base.rb:14:in `action’
from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:32:in `block in execute’
from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:31:in `each’
from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:31:in `execute’
from /usr/share/vagrant/plugins/commands/plugin/command/root.rb:56:in `execute’
from /usr/lib/ruby/vendor_ruby/vagrant/cli.rb:42:in `execute’
from /usr/lib/ruby/vendor_ruby/vagrant/environment.rb:268:in `cli’
from /usr/bin/vagrant:173:in `<main>’

Remove vagrant

sudo apt-get remove vagrant

Install it with the debian package coming directly from the vagrant website. https://www.vagrantup.com/downloads.html

Then run

sudo vagrant plugin install vagrant-vbguest
Categories
Technical Support

Ubuntu 16.04 – Installing epson WF-2650

Since LSB cannot be installed easily on ubuntu 16.04, drivers found on epson website is not really usable anymore.
I found my answer here –> https://askubuntu.com/questions/763157/ubuntu-16-04-installing-epson-driver-fails-on-lsb-3-2/763268#763268?newreg=2a690758362a43a6ac908da5423110dc

sudo apt-get install printer-driver-escpr

And then simply add the printer using DNS-SD connection.

Categories
Development

Allow connections to mysql through firewall (IPTABLES) from your network.

*Not in production*

List the content of your iptables and display your numbers.
sudo iptables -n -L --line-numbers

In my case, at the 7th line was the drop all line so it’s the place where I want to insert.
eth1 is the network interface on my computer that I wanted to allow access on. Run ifconfig to know which one you want to apply it on.
To give access to my network, I used a netmask 192.168.56.0/24
3306 is the default mysql port.

sudo iptables -I INPUT 7 -i eth1 -p tcp --dport 3306 -s 192.168.56.0/24 -j ACCEPT -m comment --comment "MySQL"

Do not forget to save !
sudo /etc/init.d/iptables-persistent save
sudo /etc/init.d/iptables-persistent reload

Reference:
snipt johan_adriaans
CentOS HowTos Network IPTables
AskUbuntu (Answer from user213088)