18. February 2017

How to configure Two-Finger Scrolling in openSUSE KDE to behave the same way like Apple MacBook

Two-Finger scrolling in openSUSE – KDE has same default configuration like Windows 10 on Lenovo. This configuration came from old days when users were using only mouse to navigate on the web. When using touchpad it’s natural to expect that it would behave similarly to a tablet or Apple MacBook. Apple made the switch in the direction some time ago to make it more natural. For some reasons developers keep the old style on Linux and even on Windows. Luckily it is possible to change the configuration very easily.

Go to System Settings and click Hardware – Input Devices

Select Touchpad from left pane, Scrolling from the tabs and check option Reverse scrolling – Vertical. Then click Apply.

15. February 2017

GitHub unable to clone repository – Permission denied (publickey)

After upgrade to new version of SSH you may experience the following problem with return code 255:

Permission denied (public key).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

This happened to me after upgrade from Linux Mint 17 to 18.

How to diagnose the problem?

Run following command:

ssh -v git@github.com

You will see several lines of output and one of them is typically the reason. In my case it was:

...
debug1: SSH2_MSG_NEWKEYS received
debug1: Skipping ssh-dss key ~/.ssh/id_dsa - not in PubkeyAcceptedKeyTypes
...

DSA keys were disabled in SSH 7. Solution is to generate new key with different type, for example RSA.

ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub

Replace your key at GitHub by newly generated one. You can re-run “ssh -v” command to check whether the communication was established correctly:

PTY allocation request failed on channel 0
Hi georgik! You've successfully authenticated, but GitHub does not provide shell access.
...
debug1: Exit status 1

That’s a good sign. The connection was established and now you can try to clone a repo.

9. February 2017

Courier Mail Server stops delivering emails after upgrade to 0.76

It might seem like a minor upgrade to go from version 0.75 to 0.76. In the case of Courier Mail Server, it’s a huge change in the orchestration of services.

Courier Mail Server has a very good modular architecture which allows independent control of each aspect of mail delivery. You can separately restart or change each service like MTA, POP or IMAP. Even encrypted variants of servers are available as separate services. The version 0.76 is pushing it even further in the fashion of micro services.

There is new service ‘courier’ which is responsible for scheduling mail delivery after mail was accepted via SMTP or SMTP-SSL. If you’re not aware of this new service you might wonder why is Courier not logging any activity after accepting email. Just make sure that service is running. You can start it by:

service courier start

After the start of the service, you may see that emails are being processed, but they’re not delivered to local mail users. In the log, you can find many error messages like:

/usr/bin/maildrop: Unable to change to home directory.

The other major change is the switch from courier-maildrop to common maildrop. That might seem like a minor change, but it could render your server completely useless. Emails won’t be simply delivered to user’s mailbox:

/usr/bin/maildrop: Unable to change to home directory.

The problem is that maildrop is accepting different parameters than courier-maildrop. Package maintainers recommends to change line with maildrop in /etc/courier/esmtpd from:

DEFAULTDELIVERY='|/usr/bin/maildrop'

to:

DEFAULTDELIVERY='|/usr/bin/maildrop -w 90 -V 1 -d ""'

If you do not have time to play with maildrop, you can change to default configuration:

DEFAULTDELIVERY=./Maildir

Here is the explanation of changes from package maintainers (click image for detail):

Restart services and delivery should start. It might happen that services do not shut down, because upgrade changed user from ‘daemon‘ to ‘courier‘. Then the solution is to terminate services by:

pkill -9 -f courier

Then you can start services and everything should work ok.

1. January 2017

Excellent talks from GOTO Stockholm 2016

I’d like to share with you references to great talks from GOTO Stockholm 2016 related to software development. These speakers are talking about concepts and ideas that are definitely breaking comfort zone of software development.

It is not just Microservices – Fred George

Key takeaway: “If you are doing iteration cycles by two or three weeks and you did it last year or year before. You’re not agile anymore. You should be going faster and faster.”

Software that Fits in Your Head – Dan North

Key takeway: “This is uncomfortable truth. Code is not an asset. Code is the cost.”

26. December 2016

How to build app with MobX annotations via webpack using Babel 6

I was searching for hints how to build games based on React. There is nice simple react-game-kit. The kit contains demo where you can as a player discover the kit itself.

Just type:

git clone git@github.com:FormidableLabs/react-game-kit.git
cd react-game-kit
npm install
npm start

Then you can open the demo in your browser: http://localhost:3000/

react-game-kit-demo

I was trying to build my own game based on code from react-game-kit. I hit one problem that webpack was not able to process MobX annotation @observable in GameStore.

Module build failed: SyntaxError: Unexpected token (4:2)

  2 | 
  3 | class GameStore {
> 4 |   @observable characterPosition = { x: 0, y: 0 };
    |   ^

The problem is described in MobX documentation. The annotation @observable is available only in ES7 which is fairly new. In case of Babel 5 or 6 you should use “Stage 0” processing.

Here is how to fix the problem:

npm install babel-plugin-transform-decorators-legacy --save-dev
npm install babel-preset-stage-0 --save-dev

The first package “transform-decorators-legacy” allows you to use decorators with Babel 6. The second package allows you to enable plugins in Stage 0 of build by Babel.

Then you need to tell webpack to use the plugin for decorators transform. Add list of plugins to query section of webpack.config.js:

...
  query: {
    presets: ['es2015', 'react'],
    plugins: ['transform-decorators-legacy', 'transform-class-properties']
  }
...

Now you can start the webpack and @observable will be processed.

If you want to learn more about MobX, there is nice tutorial at Egghead.io.

10. February 2016

Story behind PF2016


Slides available in formats: PDFSlideShare

Source code: GitHub/ysoftdevs/pf2016

14. December 2015

Slides from talk at FI MUNI: C++ and Software Engineering 2015


Slides available in formats: PDFSlideShare

Source code: GitHub/ysoftdevs/cpp-examples

9. December 2015

Thunderbird and Outlook solution of problem with Courier IMAP sslv3 alert illegal parameter

E-mail clients like Thunderbird or Outlook stopped to communicate with Courier IMAP/SMTP/POP TLS after some upgrade.

The only clue in log file was this error message:

courier couriertls: accept: error:14094417:SSL routines:ssl3_read_bytes:sslv3 alert illegal parameter

The problem was that certificate for IMAP (/etc/courier/imapd.pem) and /etc/courier/dhparam.pem were containing too short key. The short key was sufficient in past for encrypted communication. Unfortunately maintainers of Debian package forgot to add fix for upgrade.

It is very simple to fix the issue. Just generate DH with sufficient length.

DH_BITS=2048 mkdhparams

This command will update /etc/courier/dhparm.pem.

Make sure to update all pem files in case that they contain DH record.

Restart services and clients should be able to reconnect without problem.

If you still experience some issues with PEM files check out article PEM routines:PEM_read_bio:no start line.

24. May 2015

How to revert no-site-packages for virtualenv on Windows with Python 3.4

Python has support for virtual environment. It’s very handy to set up isolated space where you can store specific packages for the project. You can use command virtualenv to create virtual environment.

It’s very common to add option --no-site-packages which will isolate environment from packages installed in system.

Sometimes it is necessary to revert this option.

Linux and Mac users can control it by mechanism based on one file:

venv/lib/python3.4/no-global-site-packages.txt

When this file exists Python is ignoring packages from system.

In case of Windows there is configuration file stored in venv/pyenv.cfg and you can change configuration of global packages:

home = c:\Python34
include-system-site-packages = true
version = 3.4.3

Change the configuration and call Scripts\Activate.ps1 to load Python virtualenv to PowerShell.

23. May 2015

Flask OAuthlib Multiple Scope Values for calling Google API

Google provides myriad of APIs for invoking operations on Google App Platform. It’s possible to integrate this calls with custom app using OAuth.

One option is to write app based on Flask (Python Microframework) with OAuth support provided by Flask-OAuthlib.

There is simple example of web app in Lepture’s repo.

The key practice in OAuth world is to get user’s consent to access API on her/his behalf. Often implemented by simple consent screen.

google-consent

You need to perform two steps to display consent screen:

  • enable API in Developer Console
  • define scope in your application

The second step is straightdorward:

google = oauth.remote_app(
    'google',
    ...
    request_token_params={
        'scope': 'https://www.googleapis.com/auth/userinfo.email'
    },
    ...
)

It works perfectly. The only problem is that this solution provides access just to one API.

The question is: How to request access to multiple scopes?

You can find many hints about OAtuh for other frameworks, that you should separate scopes by comma. That won’t work.

Correct solution is to use white space as delimiter of scopes (as suggested for HTML forms).

google = oauth.remote_app(
    'google',
    ...
    request_token_params={
        'scope': 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/calendar.readonly https://www.googleapis.com/auth/tasks'
    },
    ...
)
  • Where’s the fish?

  • Translations

  • Further info

  • Twitter

    Follow @jurajmichalek on twitter.

  • Comments

  • Tags

  • Topics