Showing posts with label useful. Show all posts
Showing posts with label useful. Show all posts

terminal setup in linux mint

Updated version

sudo apt-get install tmux


Commands:

In tmux, hit the prefix ctrl+b (my modified prefix is ctrl+a) and then:

Sessions

:new<CR>  new session
s  list sessions
$  name session

Windows (tabs)

c  create window
w  list windows
n  next window
p  previous window
f  find window
,  name window
&  kill window
 

Panes (splits)

% vertical split " horizontal split o swap panes q show pane numbers x kill pane + break pane into window (e.g. to select text by mouse to copy) - restore pane from window ⍽ space - toggle between layouts

 
Set up scrolling 
put this command in your ~/.tmux.conf

setw -g mode-mouse on

# Lower escape timing from 500ms to 50ms for quicker response to scroll-buffer access.
set -s escape-time 50
 
 

Mount yandex webdav on local dir

apt-get install davfs2 
mkdir /mnt/yandex.disk 
mount -t davfs https://webdav.yandex.ru /mnt/yandex.disk/
 
# check: 
df -h /mnt/yandex.disk/ 

Mount windows shares in linux



Use sudo if needed

Mount

mkdir /mnt/share
mount -t cifs //windowsmachineip/sharename -o username=user,password=urPassword /mnt/share

Unmount

umount /mnt/shares

autocomplete from history in terminal (in linux mint)

create a file .inputrc

in your home directory and put there
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
TAB: menu-complete



Restart your terminal.

How you can autocomplete from history using Up and down keys.


Dropbox in linux mint

Hmm. It doesn't work.
I see the icon when i do
dropbox stop
dropbox start
but I cannot clic on it.

Installed nemo-dropbox. At least now I have "Copy dropbox link" command in menu.
Don't forget to do
$ killall nemo
after installation to make it work.

Final Solution

source 
Use 
dropbox stop && dbus-launch dropbox start
Or 
Do: opening 'Preferences' -> 'Startup Applications' and editing the dropbox entry so the command now reads:
CODE: SELECT ALL
dbus-launch dropbox start

 update might overwrite the change. I think it's better to leave the existing entry alone (only disabled) and create a new entry (e.g. "Launch DropBox") with the new start command (`dbus-launch dropbox start`)

C++ IDE for linux


CLion is awesome but expensive.

Found Codelite http://www.codelite.org on http://stackoverflow.com/a/1775460.
Looks good. No disgust after 10 minutes of work.

I was able to debug C code of Numpy in Virtualenv.
1. Launched from console after activating of virtual environment
> source ./<path to activate>/activate
2. add breakpoints
3. Run (F5)

Debugging numpy (any C code of Python) using gdb

I created a tiny python script that executes some python code, that executes some C code:

# contents of dbg_broadcast.py
import numpy
print list(numpy.broadcast([[1,2]],[[3],[4]]))

> gdb python
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
.................. bla bla bla ..................................................

# Adding breakpoint to function "arraymultiter_new" (example):
(gdb) break arraymultiter_new

# There is name completition by Tab.
# Run script
(gdb) run dbg_broadcast.py 
Starting program: /home/asdasd/work/bin/python dbg_broadcast.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, arraymultiter_new (__NPY_UNUSED_TAGGEDsubtype=0x7ffff6abbf80 <PyArrayMultiIter_Type>, 
    args=0x7ffff32dd050, kwds=0x0) at numpy/core/src/multiarray/iterators.c:1578
1578 {
(gdb) 


And here we are.





avconv

convert video to jpeg with good quality
avconv -i input_video.mp4 -qmax 1 -qmin 1 images_%05d.jpg

crop video
avconv -i input.avi -vf crop=<width>:<height>:<x>:<y> output_%05d.png


create gif using http://gifmaker.me/

Operations with lists in Java

Initializa list:

List<String> names = Arrays.asList("Bob", "John", "Alice");

Free PDF Editor for Linux

Looks good for linux mint/ Ubuntu
https://code-industry.net/free-pdf-editor/

Keyboard layout switching. Toggle between 2 of 3 languages.

 Let's say you have 3 languages on your linux machine: English, Russian and Belarusian. You frequently switch between EN and RU. Sometimes you write something in EN and BY. So you don't want to press Alt+Shift three times constantly, only when writing something in Belarusian.
I have made a followin script for that:


#!/bin/bash
current=`setxkbmap -query | grep layout|cut  -d ',' -f 2`
echo $current
if [ "$current" == "by" ]
then
    notify-send -t 500 -i keyboard "Keyboard layouts: US/RU"
    setxkbmap -model pc105 -layout us,ru -variant altgr-intl, -option grp:alt_shift_toggle
else
    notify-send -t 500 -i keyboard "Keyboard layouts: US/BY"
    setxkbmap -model pc105 -layout us,by -variant altgr-intl, -option grp:alt_shift_toggle
fi


Here I assume that Alt+Shift will be used to switch languages inside a group.
Save the scipt in /usr/local/bin as toggle_en_ru.sh (for example).
Add execution permissions. Like
sudo chmod +x /usr/local/bin/toggle_en_ru.sh

Go to keyboard layouts settings and add a new shortcut. Assign a shortcut for switching between languages groups. I decided to use Win+Space for language pairs (EN/RU <-> EN/BY) switching.


Sources and ideas from:
http://superuser.com/questions/505466/2-and-more-keyboard-layout-groups-in-linux-changed-by-different-hot-key


Querying existing configuration:
$setxkbmap -query