петък, 25 декември 2020 г.

How to edit pdf to add signature with gimp

1. Import the pdf in Gimp

2. Make sure the resolution is at least 300dpi, best 600 pixels per inch

3. Import the signature as layer. It seems that it does it automatically if you copy/paste the picture from a world file.

4. You can move the layer when you paste it to fit it into position

5. You can rescale the layer to increase your signature (Layer -> Scale Layer)

6. When you're done, you have to merge down the layer to the page it belong to by first making the other layers (pages) invisible

7. Finally, export to pdf with the option to export layers and export  pages in reverse. 

That's it. The file is a bit big, but it will have a good enough resolution. If it doesn't, that's in image -> print size.

вторник, 14 юли 2020 г.

How to install ML python libraries on Sabayon

Check you're running the correct python
$eselect-python list
Install pip
$sudo equo install dev-python/pip
Reinstall python-exec just in case
$sudo equo install dev-lang/python-exec
Install your packages with the --user option. Useful libraries:
numpy scipy pandas matplotlib seaborn pymc3
$python3.6 -m pip install numpy --user

To open a notebook, first install Jupyer and python notebook
$sudo equo install dev-python/notebook  dev-python/jupyter_client

Then start your notebook
$jupyter notebook

and choose New.

P.S. It seems that getting theano and pymc3 is quite tricky. In case you wonder what are the requirements for those two, it's hard to say. See here and here.  I had to reinstall
numpy scipy mkl theano pandas

And then I had to change my gcc to 7.3.0 because for some reason gcc-8.2.0 won't work with binutils-2.33.0 with the gcc -g option and will give the remarkably stupid error "Error: unknown .loc sub-directive `view". But that you could see only if you open the temporary c file, scroll all the way to the middle and see the actual error. In the jupyter notebook I could see only "import error" and "execution error". It took me about 5 hours to figure out the problem. Nice.

P.S. I also did
export MKL_THREADING_LAYER=GNU
I have no idea if it helped.

P.P.S. I also installed Anaconda, because I thought it would help. It didn't, but in case it doesn't start, this is the thing that helped me (source):

Edit : ".../anaconda3//lib/python3.7/site-packages/anaconda_navigator/api/external_apps/vscode.py"

Add the line :

DISTRO_NAME = None

on Line 159 and indent it in line with the if above it (Outside it)



понеделник, 6 юли 2020 г.

Working autoclicker for Gentoo or Sabayon

It took some time to find a working autoclicker for Sabayon. I tried the most popular ones, but oddly enough they didn't work. For example, xdotool doesn't start at all, giving some very weird error  (i.e. "xdotool: symbol lookup error: /lib64/libpthread.so.0: undefined symbol: __write_nocancel, version GLIBC_PRIVATE").
What worked for me is xAutoclick (https://sourceforge.net/projects/xautoclick/). You have to do
$./configure
$./make
$sudo make install
And then I started gAutoClick. It gives you a very small window where you can specify how many clicks per what period (in milliseconds, you can see the help here http://xautoclick.sourceforge.net/documentation.html) and with what delay to start. And then the autoclick will follow your mouse. Which is pretty cool.

сряда, 27 май 2020 г.

Monitor cp progress

I often use cp to make backups (ok, I know sync is better, I just forget it. all the time).
So here's how you can monitor the cp progress (thanks to this amazing thread)
$watch lsof -p `pgrep -x cp`

I'm totally adding this to my scripts. You need sudo though.
Also useful 
$sudo  ls -l /proc/PID/fd
or
$watch -n1 lsof -p$(pgrep -x cp)
The rsync command:
$rsync -avP FROM TO 

вторник, 21 април 2020 г.

Convert a pdf and decrease size

First:
convert  -density 200 -trim AS1.pdf AS2.pdf AS3.pdf AS4.pdf AS_all.pdf
And then "Print to file". That's it. It decreased a 25MB file to 6.7MB. Pretty good.
P.S. That's an interesting one, but obviously it works only with 1 page:
convert -density 600 test.pdf -background white -flatten -resize 25% test.png

вторник, 7 април 2020 г.

uploading screenshots to steam on Linux

My steam overlay is not working. I have no idea why.
I enabled it both from Steam->Settings->In-Game and for each game separately, I added
LD_PRELOAD='/home/USER/.local/share/Steam/ubuntu12_32/gameoverlayrenderer.so'
as a game option, I changed all possible key-bindings to something free. And still, nada.
I checked the output of: 
$cat /tmp/dumps/`id -un`_stdout.txt
nothing very informative but some ELF errors which too annoying to even start working on.
So for the moment I'm leaving it aside and posting the workaround.
What I did is this:
https://steamcommunity.com/sharedfiles/filedetails/?id=1358157391
If you do what's described using Chrome, it actually uploads your screenshots as a screenshot, not as art. So that's something I guess.
In brief:
 Load http://steamcommunity.com/sharedfiles/edititem/767/3/
Press
Ctrl + Shift + J
Then paste into the console
$J('#image_width').val('1000'); 
$J('#image_height').val('1'); 
$J('[name="file_type"]').val("5");
And press enter. It gives some kind of error but still, it works. So after choosing your file and describing it, you end up with a Screenshot! :)
The only problem is that you cannot add tags, so it won't go to the Community Hub. 

dictionaries for LibreOffice

For whatever unknown reason aspell is not working well on my system. Like at all, spell-checking works fine only on Firefox because it has its own dictionaries obviously. In kwrite it works but only for some predefined dictionaries and I cannot add Bulgarian to it, even though I have aspell-bg installed. Oh well.
In any case, what helped in the end is downloading the dictionary for LibreOffice from:
https://wiki.documentfoundation.org/Language_support_of_LibreOffice
(for Bulgarian dictionary, go to:
https://extensions.openoffice.org/en/project/dictionaries-bg
for Spanish:
https://extensions.openoffice.org/en/project/diccionario-de-correccion-ortografica-separacion-silabica-y-sinonimos-en-espanol-espana)
Get the *.oxt files. 
And then from Tools->Extension Manager
You click Add and you add the dictionary you downloaded.
Note, you need to restart and also to change your dictionary by right-clicking and choosing Spelling and from the top of the window you choose your dictionary.
Happy spelling!

понеделник, 16 март 2020 г.

неделя, 8 март 2020 г.

How to make a gif from Huawei moving picture

I really like moving pictures. They are totally cool way to remember a fun moment and they are really easy to make. The big problem, however, is that they are a nightmare to share. Because they are recognised only by Huawei phones. Which is really a pity. It turned out it's pretty hard to export them to GIF-s as well. So here's what I found after all.
The only app which I've found so far to work with them is "Gif maker-editor". From it, you can choose "More->Motion photo-GIF" and turn your cool motion photo to a GIF. Of course, without the sound, which is also stupid, but whatever.
Then, if you want to edit your GIF (i.e. to remove a particularly ugly frame) you can do it from the app "GIF Maker- Gif Editor" (WTF with the names of those apps). From there, you select Edit->Manager and click on the - signs to remove a frame. Then you save it, and here you go a nice pretty GIF.
And with Motion Stills you can make normal GIFs. But they are not so fun as moving pictures :)

събота, 29 февруари 2020 г.

Sudden loss of FPS

To my greatest surprise when I tried playing games this week, I would play about 10mins and then the game would suddenly experience a total FPS drop at which point it has to be killed. I thought it's a problem with the latest KSP update, but then it happened with another game and I was like "What?".
Well, it seems like some genius decided that there should be a 10 mins limit of work for the discrete card (i.e. the Nvidia). Because...why not. Let's stop people from gaming and give them back their life. Oh well.
Anyway, luckily once I realised the problem is on my computer, it was very easy to find a solution using Google. So according to this forum, or Arch Linux's wiki, it's to add in the section Screen (or in my case Devices) of /etc/bumblebee/xorg.conf.nvidia
 
Option "HardDPMS" "false"
  
For now, $optirun glxspheres works for more than 10 mins without an FPS drop, so YAY! 
 
(the other solution, to type in terminal:
$xset s off -dpms
doesn't work, at least, it didn't for me.)
 

четвъртък, 9 януари 2020 г.

Install epson l3151 in ubuntu

So I've bought a new 3 in 1 device - Epson L3151 printer and scanner. These are the install packages I installed to get the printer and scanner running in Mint. (so far in Sabayon, I've only made the printer work, for some reason it simply doens't recognise the device even if it sees it in lsusb)
I probably have installed more packages than needed but especially with the scanner, the minimal install simply wasn't working. After I installed everything I saw related to scanning, it worked :) Btw, the printer is great, the scanner as well. I'm very happy with it - very easy to add the ink, very easy to manipulate. If only I could network install it without Windows, but that seems too hard and I don't have time for it now.

To install the printer (Epson drivers, the PPD for manual install): 
>sudo apt-get install printer-driver-escpr epson-inkjet-printer-escpr epson-printer-utility escputil mtink

To install the scanner, I basically installed all the scanning packages I found (the "official" Epson webpage) :
>sudo apt-get install imagescan-bundle-ubuntu imagescan iscan-plugin iscan-data sane sane-utils libltdl7 exim4-daemon-heavy simple-scan xsane imagescan-plugin-gt-s650 imagescan-plugin-networkscan imagescan-plugin-ocr-engine mawk

You should be able to see your scanner with these two commands:
>sane-find-scanner
>scanimage-L
or for debugging:
 >dpkg -l iscan* | grep ii
And to use the scanner, the only thing that worked is xsane
>xsane

Note, xsane is not easy to work with at first.
If you want to scan multiple documents, you FIRST choose in the main menu (the one with File, Preferences etc)-> Multiplepage (you can also set Color/Greyscale)
Then in Standard options, you choose A4
Then you click Scan in the Main window
A new scan appear in the Multipage menu. You can preview it with Show image
Then you scan the same way the other pages. Then you click on Save project (you should have chosen as filetype PDF). And then you have your PDF in the project folder.
Sources: Link1, Link2, Link3, Link4
 
For Manjaro not finding the printer/scanner I did 
$sudo pacman -S sane
 
https://help.ubuntu.com/community/sane_Troubleshooting 
 
pamac search epson-inkjet-printer-escpr  
pamac build epson-inkjet-printer-escpr
pamac build epsonscan
pamac build epsonscan2
pamac search -a escpr
pamac build  search -a escpr
pamac install epson-inkjet-printer-escpr2
https://wiki.manjaro.org/index.php/Printing
http://localhost:631/