Archive for category admin

Extracting amenity tag info from OSM database in 3 simple steps

Step 1. Download the needed OSM database in PBF format from here: planet.openstreetmap.org (be careful, it has huge size, many GBs)

Step 2. Install golang package for for decoding osm pdf files: github.com/qedus/osmpbf

Step 3. Use simple golang program below to decode whatever you need (let’s say you need to find all petrol stations)

Read the rest of this entry »

, , , , , , ,

Leave a comment

Creating ubuntu service for go app

Step 1

Install go program with go install in the app folder

Step 2

Download service script file from here: Service for go app

Step 3

Change {{USERNAME}} in the script to the user you use in ubuntu to run your app and change  {{APPNAME}}  to binary name in your $GOPATH/bin/, if needed fix the path in cmd variable to point to your own $GOPATH folder

Step 4

Rename the service remove ending ‘.sh’ and copy the service file in the folder  /etc/init.d/

Step 5

Run in the terminal chmod 700 /etc/init.d/goappservice

Step 6

Run sudo update-rc.d goappservice defaults

Step 7

Run sudo update-rc.d goappservice enable

Done!

Use usual service commands to work with your new service.

sudo service goappservice start|stop|restart|status

If there is a new version of the app then just run go install in the app folder and restart the service.

Enjoy

, ,

Leave a comment

Fixing not working auto-completion for golang in Visual Studio Code

gophervsMy favorite code editor for GO  (Visual Studio Code with Go extenstion from lukehoban) on my Mac sometimes loses its intelligent behavior when suddenly code completion stops to work.

Usually just couple of commands in terminal recovers auto-completion back to life:

  1. Close Visual Studio Code
  2. Open terminal and stop gocode with gocode close
  3. Update gocode with the command `go get -u github.com/nsf/gocode`
  4. Start Visual Studio Code again and enjoy.

, , , , , ,

Leave a comment

Configure Ubuntu to work as GO web server

Картинки по запросуI’m often creating go apps or services using Digital Ocean droplets with Ubuntu, that’s why I decided to create a script to automate configuration process.

 

The script is doing following:

  1. Installs and configures firewall (ufw, allows only ports 80, 443 & 22)
  2. Installs git (required by go)
  3. Installs mysql and secures it with mysql_install_db
  4. Installs the latest version of GO (1.7.5), configures go environment (PATH, GOPATH)
  5. Installs go application from public git repository, yours or my demo (development for private is in progress) with ‘go get’
  6. Configures go app to work as a service (add config into /etc/init.d), starts the service
  7. Installs and configures nginx to work as proxy for go app

Script can be started directly from github:

bash <(curl -s https://raw.githubusercontent.com/bykovme/webgolangdo/master/preparegolangapp.sh)

Check the script and find more information here: https://github.com/bykovme/webgolangdo

, , , , , , , , , , , , , ,

Leave a comment

Create ipa file for iPhone without signing to Apple (command line)

terminal-iconExporting to ipa file from XCode requires to login to Apple before doing that while you can have already all signing prerequisites locally on your Mac.

You can avoid login if you run the command below from in terminal (you can find the the path to your archive  by right clicking on it in XCode after archiving and “reveal in Finder”):

 

xcodebuild -exportArchive -archivePath "ArchiveName.xcarchive" -exportPath "ExportedIpaFileName" -exportFormat ipa -exportProvisioningProfile "YourProvisionProfile" ENABLE_BITCODE=YES

 

, , , , ,

Leave a comment

Install Razberry on Raspberry PI

razberry

Install Razberry as it is shown on the picture above.

Software  is installed with the command below:

wget -q -O - razberry.z-wave.me/install | sudo bash

Find in installation log user ID and password, they can be used to login remotely using https://find.w-wave.me

Check if service is running with

sudo service zbw_connect status

More information on Razberry project can be found here: http://razberry.z-wave.me

DONE

, , , ,

Leave a comment

Step by step tutorial: how to setup new Raspberry PI from command line

Writing image

Connect RPI to Wi-Fi

  • Check wireless connection with “sudo iwlist wlan0 scan”
  • Setup wireless with nano “sudo nano /etc/wpa_supplicant/wpa_supplicant.conf”
  • Add the config below to wpa_supplicant.conf in the end of the file
network={
    ssid="The_ESSID_from_earlier"
    psk="Your_wifi_password"
}
  • do “sudo ifdown wlan0” then “sudo ifup wlan0”
  • check address with ifconfig

Upgrade RPI to the latest packages, install mc

  • do “sudo apt update”
  • do “sudo apt upgrade”
  • do “sudo apt install mc”
  • set default editor to mcedit “sudo update-alternatives –set editor /usr/bin/mcedit”

Add your own user, configure sudoers, change password of pi

  • add new user with a command “sudo adduser youruser”
  • add the user to sudoers with visudo “sudo visudo”
  • add the following line in the end “youruser ALL=(ALL) NOPASSWD: ALL”
  • change password of pi user “passwd”
  • reboot your RPI with “sudo rpi”

Setup firewall

  • Install ufw with “sudo apt install ufw”
  • Allow minimum ssh ports with “sudo ufw allow 22/tcp”
  • Allow all other port you are going to use, i.e web “sudo ufw allow 80/tcp”
  • Enable ufw “sudo ufw enable”
  • Check the status “sudo ufw status”

Login with your user, fix locales

if you have the issue “warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)”, you can solve it with the command “sudo dpkg-reconfigure locales”, select en_US.UTF-8 as default

Make a backup

  • Make backup with ApplePI-Baker.app downloaded in the beginning

DONE

, , , ,

Leave a comment