Thursday, December 26, 2019

grub2 background color on Ubuntu

  • 17.10 and later:
    sudo -H gedit /usr/share/plymouth/themes/default.grub
    
And change the grub background color as you want, in my case I change grub background to black (0,0,0)
if background_color 0,0,0 ; then
   clear
fi
Then, update grub
sudo update-grub


https://askubuntu.com/questions/47488/how-to-change-the-purple-background-color-in-grub

Nice teal that stands out from Win and Ubuntu alike: rgb(0, 123, 96)

Monday, December 23, 2019

Ubuntu upgrade kernel

Install ukuu and run it to get other kernel:
https://linuxhint.com/upgrade-kernel-ubuntu-1804/

Disable secure boot using an older kernel selected at grub level
https://wiki.ubuntu.com/UEFI/SecureBoot/DKMS

Only install critical security updates on ubuntu

I read the apt-get man page carefully when I got tired of manually editing the sources.list every time I wanted to only apply security updates (that means the second time).
Figured this solution out:
sudo cp /etc/apt/sources.list /etc/apt/security.sources.list
Edit the latter to contain only security repositories, then:
sudo apt-get upgrade -o Dir::Etc::SourceList=/etc/apt/security.sources.list
 
https://serverfault.com/questions/270260/how-do-you-use-apt-get-to-only-install-critical-security-updates-on-ubuntu 

Tuesday, December 10, 2019

Fix dual boot time discrepancy

http://ubuntuhandbook.org/index.php/2016/05/time-differences-ubuntu-1604-windows-10/

1. Disable UTC and use Local Time in Ubuntu:
In previous Ubuntu editions, you can edit the config file /etc/default/rcS to disable UTC.
In Ubuntu 16.04, open terminal (Ctrl+Alt+T) and run the command below instead:
timedatectl set-local-rtc 1 --adjust-system-clock
To check out if your system uses Local time, just run:
timedatectl

Friday, November 8, 2019

svn export in git

To obtain a "clean" source at some revision, do:

git archive | tar -x -C

Source: https://stackoverflow.com/questions/160608/do-a-git-export-like-svn-export

Setting Up "Local" Git Server

Inspired by https://dev.to/erhankilic/setting-up-your-own-git-server--26h6

sudo mkdir /git/example.git
cd /git/example.git 
sudo git init --bare
cd /home/
sudo git clone /git/example.git # (bcoz the repo has root permission in this example)

To use:
git add ... whatever
git commit -a
sudo git push # (bcoz the repo has root permission in this example)

Wednesday, September 25, 2019

download google drive files in bash

https://www.matthuisman.nz/2019/01/download-google-drive-files-wget-curl.html

https://github.com/matthuisman/files.matthuisman.nz/blob/master/gdrivedl

Thursday, August 15, 2019

KDE disable super_L (windows key) key shortcut as menu luncher Ask

https://superuser.com/questions/1156130/kde-disable-super-l-windows-key-key-shortcut-as-menu-luncher

In kde plasma 5.8 the super/win key is also used to trigger the launcher, when pressed and released without combining it with another key. To disable the feature, put
[ModifierOnlyShortcuts]
Meta=
in ~/.config/kwinrc.
Taken from: https://blog.martin-graesslin.com/blog/2016/08/modifier-only-shortcuts-available-in-plasma-5-8/ https://www.reddit.com/r/kde/comments/55udc1/how_do_i_stop_the_meta_key_from_opening_the/d8epzzj/

Friday, July 19, 2019

Monday, June 10, 2019

MiKTeX add custom bibtex style sty

SEE ALSO https://win-dmatenine.blogspot.com/search?q=bibtex

You should create a LocalTeXMF root directory, say in your personal directory. Whatever the exact name you give it, you have to declare it via MiKTeX OptionsRoots tab, Add button. Everything you'll put in this directory must respect the TeX Directory Structure (TDS).
In this root, copy the .bst file as \LocalTeXMF\bibtex\bst\elsarticle\elsarticle-num-ident.bst, then refresh the FNDB. That's all.

to refresh the FNDB
in DOS prompt (--admin only if system-wide effect needed):
EDIT: "--admin" option was necessary for bibtex4word to acknowledge new style
> initexmf --admin --update-fndb

Thursday, May 9, 2019

git diff difftool

Git does allow you to configure suppression of the confirmation per-diffed file:

git config --global --add difftool.prompt false

The caveat is that a large number of diffed files will result in a long sequence of closing the , reopening , etc for each (this assumes that the above is significantly worse than having to hit n repeatedly during default behaviour — you can always interrupt the process by hitting Ctrl+C on the terminal, regardless).

All in all, this config change is still useful for single file diffs. For broad diffs I will stick to Aaron's suggestion of performing diff by folder and opening that:

git difftool --dir-diff



https://www.scootersoftware.com/vbulletin/forum/beyond-compare-4-discussion/version-control-aa/12475-usability-skip-git-difftool-confirmation-prompt-and-or-enable-multi-tab-opening

Wednesday, April 17, 2019

grub change default option

sudo nano /etc/default/grub

the line

GRUB_DEFAULT=0

must be changed with the desired value, indexing starts with 0. Then save, exit and execute:

sudo update-grub

reboot to test...

triple boot 2x Ubuntu and Windows?

https://askubuntu.com/questions/228890/how-can-i-triple-boot-xubuntu-ubuntu-and-windows

Start your installation using the Ubuntu 12.04 LTS CD.
  • When you reach the Installation Type Page, select Something Else.
  • Now, you will get a page listing your partitions.
  • Select /dev/sda2 and select Modify
  • Now, give the Use as as ext4 and mount point as /
  • You can just reuse your existing swap partition.
  • Continue with the installation.
After the installation, you should be having a system that you desired.

Wednesday, March 20, 2019

ITK "In place" filtering

a true "in-place" filter overwrites each pixel of the
input buffer with the resultant output pixel value and then passes the
input buffer as its output. All filters capable of this should inherit
from itk::InPlaceImageFilter (if you find one that doesn't, please let
us know). You to turn on/off this functionality eg.
filter->InPlaceOn(), filter->InPlaceOff().

The itk::MeanImageFilter does not inherit from
itk::InPlaceImageFilter, the reason being it is a neighbourhood
operation; neighbourhood operations *cannot* be run in-place (the
output for one pixel may be used as the input for another pixel!).
 
https://itk.org/pipermail/insight-users/2010-October/038501.html 

Tuesday, March 19, 2019

ImageJ/FIJI match histogram

https://stackoverflow.com/questions/25085871/match-histogram-imagej

You can use the HistogramMatcher class included in Fiji (in its sub-project CorrectBleach).
Here is an example Beanshell script (you can run it via the Script Editor in Fiji):
import ij.IJ;
import histogram2.HistogramMatcher;

// get first image
imp1 = IJ.openImage("http://imagej.nih.gov/ij/images/bridge.gif");
// get second image
imp2 = IJ.openImage("http://imagej.nih.gov/ij/images/boats.gif");

ip1 = imp1.getProcessor();
ip2 = imp2.getProcessor();

hist1 = ip1.getHistogram();
hist2 = ip2.getHistogram();

matcher = new HistogramMatcher();
newHist = matcher.matchHistograms(hist1, hist2);

ip1.applyTable(newHist);
imp1.setProcessor(ip1);

imp1.show();
imp2.show();

// show the histograms of both images
IJ.run(imp1, "Histogram", "");
IJ.run(imp2, "Histogram", "");

Tuesday, February 26, 2019

external drive ext4 and ntfs side by side - permissions

https://www.linuxquestions.org/questions/linux-newbie-8/i-set-up-an-ext4-partition-on-external-hd-to-store-media-files-permission-issues-4175469722/

backup data from ext4 drive

Source: https://askubuntu.com/questions/963442/backup-ext4-data-to-exfat-partition

"
I advise you against using rsync. You should use either rdiff-backup, Duplicity, or Borg Backup.
rsync is great for mirroring – that is: syncing – folders. You, however, probably want a backup. Imagine you accidentally delete something, then your cron job starts a sync before you can stop it. This means you just lost that data, even though you thought you had a backup. But you only had a mirror. Now if you already made a copy of that copy, you can get your data back as long as that's not already overwritten, too. But if you don't notice your mistake for some time, your data is lost.
Now, there is an rsync switch (-b/--backup) to prevent this. But you're probably still better off using a tool which is actually designed for making backups.
rdiff-backup is such a tool. It does, however, lack encryption.
Duplicity offers encryption. I did, however, make the personal experience that it doesn't restore data reliably. That is, when I tried to get a folder back to a previous state, the one file I really cared about just wasn't restored. And I know that file existed before for months because I just accidentally screwed it up, right before I wanted to restore it. Duplicity wouldn't let me restore that file and when I tried to get the folder back to various points in time, all of which I would've been fine with because there were no major changes to that file for months, it just didn't put that file in the restored folder and didn't even print a hint indicating that that file was missing.
I don't know whether this is actually a problem with Duplicity or whether it's a problem with Deja Dup as I used Deja Dup (which uses Duplicity, which in turn uses rsync, btw.) for backing up. I did, however, try restoring the file/folder both via Deja Dup and directly via Duplicity. It didn't work.
About half a year ago, a friend of mine asked me about how I do my backups. The reason she asked me was because she experienced the exact same problem with Deja Dup.
As my trust in Deja Dup was already gone after I experienced the problem myself, I switched to Borg Backup, which I recommend you should too.
Borg Backup takes a bit to get started on but once you know how it works, it's great. It offers versioning, encryption, compression, and deduplication. Backups with Borg Backup are faster than with Deja Dup and you get to enjoy awesome features like being able to mount your backup repository.
That is, you issue a mount command and then enter the location you mounted your repository to. You will then see a list of backup labels as folders. You can enter any one of these folders and look for your files. No need to restore them revision by revision. They're just all there in the mounted repo.
This means you can use normal command-line features and tools on those revisions. For example, I recently found out that I accidentally deleted my Firefox desktop file some time ago. Didn't notice for weeks. A simple
ll */home/christoph/.local/share/applications/firefox.desktop
in the mounted directory gave me a list of all the revisions containing that file. I simply copied the newest one out. But if you wanted, you could take that list and do a diff on the results to see what changed without having to restore anything first. Plus, mounting and searching the repo was way faster than the time Deja Dup takes to just figure out what file is gone.
If you use Borg Backup, it will actually keep track of ownership and permissions without the file system in the backup location having to support ownership or permissions as those are encapsulated by Borg.
Borg can be used perfectly well with cron jobs. It's just a single command you need to issue. There is an archive name you need to specify which needs to be a different one for each backup. If you issue the commands by hand, you can write something more meaningful in there. I simply use date +%c for archive names because my backups are created automatically.
Storing your first backup on a FS with journaling is certainly a good idea. As you then only create other backups and it's not terrible if you have to throw the FS your 2nd backup is on away because it got compromised when the power went out, using a non-journaling FS for it is acceptable.
You can sync this second backup from the first one via rsync. There is no problem with this as you already made sure you can go back to previous versions via Borg Backup, and – if you want – Borg already took care of encryption, too.

"