Upgrading postgres version

Suppose you made a brew upgrade and postgres got upgraded. Follow then these steps to upgrade your old DB data to the new version.

Start to move of your old data directory:
mv /usr/local/var/postgres /usr/local/var/postgres_96_20171110

Initialize a new fresh DB with the new version of postgres
initdb /usr/local/var/postgres/

Check which postgres services are running and stop all
brew services list

Stop all postgres services, one command for each:
brew services start postgresql

Run postgres upgrade tool(-b and -B are the bin directories for old and new version, and -d and -D same for data directories):
pg_upgrade -b /usr/local/Cellar/postgresql\@9.6/9.6.6/bin/ -B /usr/local/Cellar/postgresql/10.1/bin/ -d /usr/local/var/postgres_20171110 -D /usr/local/var/postgres

Start the postgres service again:
brew services start postgresql

Debug Magento 2 using PhpStorm

I had to spend some time to get my PhpStorm working with debugging a Magento 2 store we are developing. This is a short notice of what I found out and how I got it working.

A couple of weeks ago I had a working setup where I could debug both command line commands and pages using PhpStorm. Last weeks I have been developing a command line but swapped back to some page coding now and it did not work. In my initial setup I mainly followed this setup but since I use MAMP(none PRO) this article was helpful.

After a bit of struggling I found out the reason why it was not working any longer. Because of some mysterious reason I had checked the “Use path mappings…” check box. DON’T!

And as you see above it works just fine with using localhost in the servers configuration.

Another useful things to solve this was to add xdebug.remote_log="/tmp/xdebug.log" to the two php.ini files and restart MAMP and then look at the log with tail -f /tmp/xdebug.log. I noticed I had a couple of lines like this:
I: Connecting to configured address/port: localhost:9000.
W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (19).
W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (19).
I: Connected to client. :-)

The lines starting with W(guess meaning Warning) should not be there. It means the connection was not completely successful even though reading the line indicates some sort of success but there is the error too.

And while we are at it. I have not yet figured out the meaning of this button.

There seems to be no need to listen for PHP debug connections using this setup.

Configure WLAN on Raspberry Pi Z W

To setup my Raspberry Pi Z W I have combined two different guides since editing the files on the SD did not work, nor did I had the energy to setup Vagrant.

Start by flashing a micro SD card as described here using Etcher.

Insert the card into a Mac or PC and add enable_uart=1 to the end of config.txt as described here.

Insert the SD card in the Raspberry Pi and boot it as described here using a USB serial cable. Then in a terminal window run screen /dev/tty.usbserial-A7005Gpd 115200 (change to your device tty) to connect to the serial terminal on the Raspberry Pi.

Now you can follow this guide from step 3. Though I did not configure mine for two networks and here are how my configuration files look like:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


sudo nano /etc/network/interfaces

source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface home inet dhcp

Ta bort plast som fastnat

Fick ju lite problem med skrivaren på grund av felaktiga inställningar och var lite fundersam till hur plockar man isär den och sedan sätter ihop den för att få bort plast som fastnat. Som tur är har andra redan gjort det och det fanns bra filmer på YouTube. Denna tyckte jag var bäst.

En sak som är viktig vad gäller PrimaCreator skrivaren är att den säljs under flera olika namn och det vanligaste verkar vara MonoPrice Select Mini och söker man på det hittar man tex denna utmärkta Wiki med gott om kunskap om skrivaren och instruktioner.

Ny 3D skrivare och inställningar till den

För ca en månad sedan dök det upp en post i 3D Sweden om en 3D skrivare som kostade relativt lite och verkade vara av bra kvalité, PrimaCreator P120. Så jag slog till och beställde en.

Så här om helgen var det dags att testa den rejält men stötte på problem. Det gick bra med t.ex. den katt söm följde med en fil för på minneskortet men så fort jag slicade själv så gick det åt skogen. Testade en hel del men sedan i ren desperation postade jag i 3D Sweden och fick rätt snabbt svar! Tack Niklas! Det visade sig vara först och främst Retraction Distance som var fel. När jag ställde in det på 3.15mm så fungerade det perfekt.

För andra som skaffar denna skrivare och köper samma plast(filament) så här finns mina inställningar för Cura:
generella Cura profilen
material filen

Och här är en bild på skrivarinställningarna och start och slut kod.

Start kod:
; From Niklas Ramström
G28 ; home all axes
G92 E0 ;zero the extruded length
G1 X5 Y119 E10 F1000.0 ; extrude 10mm to prime the nozzle
G92 E0 ;zero the extruded length again
G1 Z3.0 F9000 ;move the head 3mm up just to be safe
G92 E0 ;zero the extruded length again

Slut kod:
; Mix of Niklas Ramström and default
M104 S0 ; turn off extruder
M140 S0 ; turn off bed

G92 E1
G1 E-1 F300

G91 ; use relative coordinates
G1 Z0.6 F5000 ; lift nozzle by 0.6mm
G90 ; use absolute coordinates
G28 X0 ; home X axis
G1 Y119; move Y axis to end position
M84 ; disable motors
M107 ; turn off fan

LetsEncrypt certificates for a new site

How do you add certificates for a newly setup website? Like this:

sudo ./letsencrypt-auto run -d www.friluftslivifjallen.se,friluftslivifjallen.se --redirect

I have the old letsencrypt client installed so for a newer installation change letsencrypt-auto to certbot. More about the certbot command line options can be found here.

This post is just a quick self-reminder to be used in the future when I set up new sites on my server.