Tuesday, 29 September 2020

How to disable the Caps Lock key on Ubuntu

Keyboard

I dont like Caps Lock, it's the the most unnecessary key on the keyboard in my opinion. I hardly ever write more than couple of words in capitals, but often accidently hit the key; suddenly finding myself TYPING IN ALL CAPS LIKE A SCREAMING MONKEY. Here’s an easy way to disable your Ubuntu’s Caps Lock key.

1. Install dconf

I already had this installed
$ sudo apt install dconf-tools

2. Disable caps lock (reenable by pressing both shift keys at once)

$ setxkbmap -option "caps:none"
$ setxkbmap -option "shift:both_capslock"
I did only disable for now.

-- UPDATE
This works but running this automatically is of course what was missing in this post so I added step 3 

3. Add this to your .bashrc file

vim .bashrc

Wednesday, 2 September 2020

Connecting to MS SQL server with pyodbc


Small project I'm working on at work requires connection to MS SQL server. For the task I'm using python3 with pyodbc library and I got stuck for a while trying to connect. looks like it has to do with the ODBC Driver 17 for SQL Server. After some time searching for solution, I found FreeTDS.

First install FreeTDS on your Linux:
apt install tdsodbc freetds-bin
Next configure FreeTDS by adding this to /etc/odbcinst.ini
[FreeTDS]
Description=FreeTDS
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup=/usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
Finally activate
odbcinst -i -d -f /etc/odbcinst.ini
And now I can run pyodbc in my code
import pyodbc
connection = pyodbc.connect('DRIVER={FreeTDS};'
	'Server='+dbhost+';'
	'Database='+dbname+';'
	'UID='+dbuser+';'
	'PWD='+dbpass+';'
	'TDS_Version=8.0;'
	'Port=1433;')
    
cursor = connection.cursor()
cursor.execute("SELECT * FROM tablename; ")

for row in cursor:
	print(row)
Thursday, 23 April 2020

How to fix a "cURL error 28: Connection timed out" in WordPress?



My Wordpress Site Health Status check showed me some critical issues that I needed to take further look at. "The REST API request failed due to an error."

The REST API request failed due to an error

Error: cURL error 28: Operation timed out after 10000 milliseconds
 with 0 bytes received (http_request_failed)

After a lot of search results that did NOT lead me to the right direction I finally stumbled up on a short article about this subject. A few items in a list on "How to Fix" this. The most interesting line in the article mentioned the Query Monitor plugin to check the status of the HTTP API Calls in the admin page where the error is displayed. And that vas the single most helpful plugin I ever found. Within a minute I had identified the problem the problem which was I my case the WP Social Avatar plugin.

wp-social-avatar error

This Query Monitor plugin saved my day, but mostly a lot of time.

*** EDIT *** It turned out I had second plugin causing the same error. "PHP Code For Posts" that has has been closed and is no longer available for download.

--cheers