Wednesday, February 13, 2019

Python configure on Debian: compiling and linking against OpenSSL doesn't work

If you are running ./configure on a new download of Python and you get this:

checking whether compiling and linking against OpenSSL works... no

And you already have openssl installed...

Make test after a build returns:

Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, https://github.com/libressl-portable/portable/issues/381

just do:

sudo apt-get install libssl-dev

Now when you run ./configure you should see:

checking whether compiling and linking against OpenSSL works... yes
checking for X509_VERIFY_PARAM_set1_host in libssl... yes
checking for --with-ssl-default-suites... python

Thursday, January 24, 2019

Treat period as a word boundary in vim

If cw in vim is selecting past '.' to the next whitespace or non-alpha (for which I would usually use cW)

If you do set you may find:

iskeyword=@,48-57,_,192-255,.

If you do :set iskeyword-=.; it will remove it.

NB: This is probably file-type specfic (e.g. in RedHat while editing a .sh file, but not when invoking vim with no file)

If you don't want to set this globally, you can use :setlocal for certain filetypes (in ~/.vim/after/ftplugin/.vim)

Source: https://stackoverflow.com/questions/19571022/how-can-i-include-periods-when-selecting-a-word-in-vim

Monday, September 17, 2018

Simple bash "UUID" generator

If you need a UUID-like string in a bash script, e.g. for the message part boundary in an email, this is probably about as simple as you can get:

#!/bin/bash

MD5SUM=/usr/local/gnu/bin/md5sum
DATE=/usr/local/gnu/bin/date

MD5=$($DATE +'%s.%N'|$MD5SUM)

B1=${MD5:0:8};B2=${MD5:8:4};B3=${MD5:12:4};B4=${MD5:16:4};B5=${MD5:20:12}

BOUNDARY="$B1-$B2-$B3-$B4-$B5"

Wednesday, August 15, 2018

Using lftp to mirror sub directories.

lftp can nicely mirror sub directories... just do: mirror --use-pget-n=5

Wednesday, May 30, 2018

perl5/perlbrew/etc/bashrc: line 103: perlbrew: command not found

If you're getting /path/to/perl5/perlbrew/etc/bashrc: line 103: perlbrew: command not found Try checking to see you don't have a $HOME/.perlbrew/init file which points to an old version of perlbrew which has been deleted.

Say no to whichcraft

Interesting and useful history and alternatives to which command https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then/85250#85250

Tuesday, May 15, 2018

Lazy way to resort a table in SQL

When you have a query and you want to sort the output but the query is too complex to see what to sort on. (say your output column isn't a selected column, but rather generated data)

select
case
        when substring(t1.some_column, 1, 1) = '#' then rtrim(t1.some_column)
        when 'some_group' in ('group_a', 'group_b', 'group_c', 'group_d', 'group_e') then  '#' + rtrim(t1.some_column)
        else rtrim(t1.some_column)
end as 'op_col_1',
case
 when t1.ip_col_1 = 'a' then 'ant'
 when t1.ip_col_1 = 'b' then 'beetle'
 when t1.ip_col_1 = 'c' then 'centipede'
 else 'no_bugs'
end as 'op_col_2',
from table_one t1

You can wrap the whole lot in brackets and sort by the column order or the generated name:

select * from (
select
case
        when substring(t1.some_column, 1, 1) = '#' then rtrim(t1.some_column)
        when 'some_group' in ('group_a', 'group_b', 'group_c', 'group_d', 'group_e') then  '#' + rtrim(t1.some_column)
        else rtrim(t1.some_column)
end as 'op_col_1',
case
 when t1.ip_col_1 = 'a' then 'ant'
 when t1.ip_col_1 = 'b' then 'beetle'
 when t1.ip_col_1 = 'c' then 'centipede'
 else 'no_bugs'
end as 'op_col_2',
from table_one t1
) query_out
where op_col_1 like 'blah%'
order by op_col_2
or
order by 2

Thanks Chris!

Tuesday, April 24, 2018

Sybase column name and datatype of all columns in a table

SELECT syscolumns.name, systypes.name FROM sysobjects
JOIN syscolumns ON sysobjects.id = syscolumns.id
JOIN systypes ON systypes.type = syscolumns.type
AND systypes.usertype = syscolumns.usertype
WHERE sysobjects.name LIKE 'my_table'

https://stackoverflow.com/a/28940121/224625

Tuesday, October 31, 2017

Show seconds in ls -l output on Solaris 10

If you need to show the seconds (and year) in the output of ls -l on Solaris:


$ ls -le /path/to/file

Friday, August 26, 2016

Ardour4, JACK, ALSA... Rosegarden, qsynth etc...

When you install Ardour on a fresh Debian install you will probably find that the sound isn't working.

Here's what I did to get it going.

sudo aptitude install ardour

I also installed these.

sudo aptitude install Qtractor
sudo aptitude install audacity

I installed these 2 to convert mp3s to ogg so I could import them.
Qtractor lets you import mp3 but ardour doesn't

sudo aptitude install ffmpeg
sudo aptitude install dir2ogg


To control/configure jack....

sudo aptitude install jack-tools qjackctl

This lets JACK and Pulse talk to each other, otherwise they lock each other out.

sudo aptitude install pulseaudio-module-jack

I'm not sure if I needed this, but this was one step:

sudo aptitude install linux-image-4.6.0-1-rt-amd64

This was the key: https://ubuntuforums.org/archive/index.php/t-986080.html


I would bet you need to look at the Ardour mixer and route the Main Output channel to your soundcard outs.

In Ardour press Alt+M (to view the mixer) then at the bottom of the Main Output strip there should be a button labeled Output - click that, then add your soundcard outs to the appropriate channels in the dialog box that pops up.

There shouldn't be any issue with the format of your wav file as ardour will resample things for you (at a better quality rate than ProTools actually).

This issue could also stem from you not having JACK configured correctly. In Ardour's open dialog, if you haven't already started the JACK audio server, there will be a tab that says audio setup - this is Ardour's own JACK startup script. It should work fine by default, but you should probably read up on JACK and qJackCtl.

To get Rosegarden going I used this page: http://gauthampai.livejournal.com/62383.html
The key to that was installing the soundfont, and qsynth.

Once you've got it configured and working, you also need to start qsynth before Rosegarden and have it running the whole time Rosegarden is. If you restart qsynth you'll probably need to restart Rosegarden for it to reconnect.