Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort_desc.png```,```sort_asc.png``` and other images not found error. That's because there is no static images downloaded with ```js``` and ```css``` file.
To fix the problem, you can download these images from Datables official github and place them at your static folder on your server.
Link ```https://github.com/DataTables/DataTables/tree/master/media/images```

After put these images on the server, you may open your downloaded ```datatables.min.css``` file and update the following section:
## Original version:
```css
.sorting{background-image:url("/DataTables-1.11.5/images/sort_both.png")}
.sorting_asc{background-image:url("/DataTables-1.11.5/images/sort_asc.png")}
.sorting_desc{background-image:url("/DataTables-1.11.5/images/sort_desc.png")}
.sorting_asc_disabled{background-image:url("/DataTables-1.11.5/images/sort_asc_disabled.png")}
```
## After update:
```css
.sorting{background-image:url("/static/img/sort_both.png")}
.sorting_asc{background-image:url("/static/img/sort_asc.png")}
.sorting_desc{background-image:url("/static/img/sort_desc.png")}
.sorting_asc_disabled{background-image:url("/static/img/sort_asc_disabled.png")}
```

Join query in Django


If we have two tables, virulence_genome and virulence_cds, and their schemas are as following:


                      Table "public.virulence_genome"
      Column      |         Type          | Collation | Nullable | Default
------------------+-----------------------+-----------+----------+---------
 genome_id        | integer               |           | not null |
 accession_number | character varying(50) |           | not null |
 strand           | integer               |           | not null |
 start_position   | integer               |           | not null |
 end_position     | integer               |           | not null |
 location         | character varying(20) |           | not null |


				Table "public.virulence_cds"
   Column    |  Type   | Collation | Nullable | Default
-------------+---------+-----------+----------+---------
 genome_id   | integer |           | not null |
 gene        | text    |           | not null |
 locus_tag   | text    |           | not null |
 note        | text    |           | not null |
 product     | text    |           | not null |
 cds_db_xref | text    |           | not null |


genome_id in virulence_cds is a foreign key of virulence_genome. What if we want to get gene names and their locations for genes that are not located on genome? Use sql query we could write something like:

select vc.gene,vg.location from virulence_cds vc join virulence_genome vg on vc.genome_id = vg.genome_id and vg.location !='genome';

What to do in Django view? I have propsed two ways to do it. Obvisouly one way is better than the other. So to find all CDs which are not located at genome, we could write:

def func(request):
	genome_ids=Genome.objects.filter(location='plasmid').values_list('genome_id')
	return Cds.objects.select_related('genome').filter(~Q(genome_id__in=genome_ids))

or

def func(request):
	return Cds.objects.select_related('genome').filter(~Q(genome__location='plasmid'))

Wrap text in a datatable

How to wrap long text in jQuery Datatable, Django Datable


I have seen different solutions on wrapping long text in datatable td, such as add wrap class into table property. But they all did not work sometimes.
The solution I proposed here is that add the following code to your site/page css property.

       

table.dataTable tbody td {
  	word-break: break-word; word-break: break-all; white-space: normal;
}
       
 
Because in the core, datatable is a standard table. So this solution also works on any html table, as long as it has table, tbody and td structure.

Use Smart Card (PIV) as Default Login Method in Windows 10

In order to Use Smart Card (PIV) as Default Login Method in Windows 10, your account have to have system admin privilege and you have logged in using smart card before.

Go to Local group Policy Editor >> Administrative Templates >> System >> Logon 
Double click "Assign a default credential provider"
In the opening window, click "enable"
Flowing instructions in this window, locate the CLSID associated with smart card login at 

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers
in my case is:
{8FD7E19C-3BF7-489B-A72C-846AB3678C96}
the value is "Smartcard Credential Provider" and it has some other values as well.

Converting m4a to mp3 on CentOS

Had couple m4a files created by youtube-dl can not being played in itunes in MacOS. Used ffmpeg in CentOS to verter them to Mp3 withour any issues. Here is the command I used:

ffmpeg  -i in.m4a -acodec mp3 -ac 2 -ab 320k out.mp3

For batch converting:

mkdir mp3s
for f in *.m4a; do ffmpeg  -i "$f" -acodec mp3 -ac 2 -ab 320k mp3s/"${f%.m4a}.mp3"; done

Oracle Apex: Editable Region in validation definition

I have been debugging why my tabular form in Apex 5.2 enters an error page http://servername/ords/wwv_floe.accept, containning
"Current tabular form data is too old; the source data has been modified.
Click here to discard your changes and reload the data from the database."

Surprisingly, when you have a custom defined validation rule PL/SQL Function body returning boolean) mixtured with some predefined rule, like "Item is not null". Whenever, a validation fail, the system will goes to this page, and some/all user input will lost. But if all validations are defined in the same way, either all using predefined rules, or all using custom defined rules, the application will not enter this page when there is avalidation fail. The error message will only show Inline in Notification.
Conclusion:
To avoid losing user input data on a tabular form, define all the validations using same method.

Download activity data from Garmin Forerunner 310XT on Linux

My everyday computer is running CentOS. There is no way install Garmin connect to upload data from my old 310XT. I am sure there are other ways to do so, but the following works for me.
There are two software packages need to install: openant and ant-fs.

1. Steps to install openant
 git clone https://github.com/Tigge/openant
cd openant
sudo python setup.py install

2. steps to install ANT-FS
git clone https://github.com/Tigge/antfs-cli
cd antfs-cli
sudo python setup.py install

3. Pair your ant receiver with your watch
antfs-cli  --pair

4. Read data from your watch
antfs-cli 
The downloaded fit data from your watch is saved at
~/.config/antfs-cli/###/activities/


Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...