Wednesday, June 21, 2017

ImageMagick: montage images into one

montage -label '%f' -geometry +4+4 -pointsize 20 -tile 4x6 *.tiff mtg.jpg

Tuesday, June 13, 2017

Monday, June 12, 2017

UFW: forward trafic on a port 8333 to different computer/ip and back

Full node is running on: ip_full_node Redirection is done on server: ip_of_uwf_server *nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-F
-A PREROUTING -i eth0 -p tcp --dport 8333 -j DNAT --to-destination ip_full_node:8333
-A POSTROUTING -p tcp -d ip_full_node --dport 8333 -j SNAT --to-source ip_of_uwf_server
-A POSTROUTING -s 10.8.0.0/8 -o eth0 -j MASQUERADE
COMMIT
Based on: https://serverfault.com/a/586553

Monday, May 01, 2017

HDMI audio output in Arch for KDE

aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC898 Analog [ALC898 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC898 Digital [ALC898 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0


aplay -D plughw:1,7 /usr/share/sounds/alsa/Front_Right.wav

Monday, March 27, 2017

VirtualBox: resize disk in linux

Resize to 350GB using VirtualBox 5.18: VBoxManage modifyhd "/home/myhome/VirtualBox VMs/arc/arc.vdi" --resize 350000 Full path to virtual disk (e.g., arc.vdi) is important. Without the full path, the following error occurs: VBoxManage: error: Cannot register the hard disk '/home/myhome/VirtualBox VMs/arc/./arc.vdi' {54199b9e-0a91-4d84-a7d0-fe2b47ed8f47} because a hard disk '/home/myhome/VirtualBox VMs/arc/arc.vdi' with UUID {54199b9e-0a91-4d84-a7d0-fe2b47ed8f47} already exists
VBoxManage: error: Details: code NS_ERROR_INVALID_ARG (0x80070057), component VirtualBoxWrap, interface IVirtualBox, callee nsISupports
VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 179 of file

Thursday, March 23, 2017

Linux: mkdir and cd in one command

mkcd () {
case "$1" in */..|*/../) cd -- "$1";; # that doesn't make any sense unless the directory already exists
/*/../*) (cd "${1%/../*}/.." && mkdir -p "./${1##*/../}") && cd -- "$1";;
/*) mkdir -p "$1" && cd "$1";;
*/../*) (cd "./${1%/../*}/.." && mkdir -p "./${1##*/../}") && cd "./$1";;
../*) (cd .. && mkdir -p "${1#.}") && cd "$1";;
*) mkdir -p "./$1" && cd "./$1";;
esac
}

From: http://unix.stackexchange.com/a/9124/90216

Monday, March 20, 2017

Windows 8.1: start chrome in new session and monitor

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=c:/monitor1

Monday, March 13, 2017

Linux SPSS 24: R 3.2 was not found in this location.

When installing R essentials for linux it is unclear how to specify R path. Without this, the following error occures:

 R 3.2 was not found in this location. Please click Previous to select a different location, or install R 3.2 on this computer and run this installation again.
For me the answer was to proved a path where `lib64` of the R package is located, not where the R binary is as show on this screenshot


In the screenshot /opt/r32 is my installation folder (I compiled version 3.2.2 it myself from source). The binary R is in /opt/r32/bin. This will not work. The path must be to R folder inside lib64 folder.


Tuesday, March 07, 2017

Chrome through ssh tunel

ssh -ND 1080 user@remote_server_ip -p 2222 google-chrome-stable --proxy-server="socks5://localhost:1080" --proxy-bypass-list="localhost;127.0.0.1"

Saturday, March 04, 2017

Arch Linux: libXm.so.4 missing

Install openmotif package: sudo pacman -S openmotif This is needed to run Ansys, for example.

Saturday, February 25, 2017

Sunday, February 19, 2017

Tuesday, February 14, 2017

Imagemagick: bash split large images into smaller

for f in *.tiff ; do fbase=`echo $f | cut -d '.' -f 1`; echo $fbase; convert -crop 510x510 +repage $f sub/${fbase}_%02d.tiff ; done

Thursday, February 09, 2017

Sunday, January 22, 2017

MATLAB: Run using xfce4 launcher without termianl window

Add -desktop parameter, e.g., /opt/MATLAB/R2016a/bin/matlab -desktop

Friday, January 20, 2017

Monday, January 16, 2017

MPV: Check twitch stream quality and specify one

Get stream format codes and avaliable resolutions youtube-dl -F https://www.twitch.tv/burkeblack
Gives, e.g.: [twitch:stream] burkeblack: Downloading stream JSON
[twitch:stream] burkeblack: Downloading channel access token
[twitch:stream] burkeblack: Downloading m3u8 information
[info] Available formats for 24252344256:
format code extension resolution note
meta mp4 multiple Quality selection URL
Audio_Only mp4 audio only 128k , mp4a.40.2@3561785328572937k
Mobile mp4 400x226 292k , avc1.66.30, mp4a.40.2
Low mp4 640x360 692k , avc1.66.30, mp4a.40.2
Medium mp4 852x480 992k , avc1.77.30, mp4a.40.2
High mp4 1280x720 1760k , avc1.77.31, mp4a.40.2
Source mp4 1280x720 3561k , avc1.4D4020, mp4a.40.2 (best)


Select the quality format you want, and play it. For example, for medium: mpv https://www.twitch.tv/burkeblack --ytdl-format=Medium

Sunday, January 15, 2017

MPV: Play youtube playlist with shuffle and repeat (i.e. loop)

mpv -no-video --shuffle --loop https://www.youtube.com/playlist?list=PL55713C70BA91BD6E

Wednesday, January 11, 2017

Saturday, January 07, 2017

wondershaper: bashrc aliases

Assuming name of interface to use is `enp0s3`. Yours can be different. Thus, needs to change it wshaperstart()
{
local downloads=3000;
local uploads=50;

[[ -n $1 ]] && downloads=$1;
[[ -n $2 ]] && uploads=$2;

echo "Executing: sudo wondershaper -a enp0s3 -d $downloads -u $uploads";

sudo wondershaper -a enp0s3 -d $downloads -u $uploads
}

alias wshaperclear="sudo wondershaper -c -a enp0s3"

Thursday, January 05, 2017

Arch Xfce: Add print screen screenshot window

Add the following coomands to keyboard shortcuts into xfce4:
 xfce4-screenshooter -f
 xfce4-screenshooter -w

Tuesday, January 03, 2017

Arch: Specify clang in Clion

Go to Preferences/Settings -> Build, Execution, Deployment -> CMake -> CMake option -D CMAKE_C_COMPILER=/usr/bin/clang -D CMAKE_CXX_COMPILER=/usr/bin/clang++


Monday, January 02, 2017

Lightttpd: Put website on different port

sudo vim /etc/lighttpd/lighttpd.conf and add for example: $SERVER["socket"] == ":81" {
server.document-root = "/srv/www/mysite"
}

Arch: FAILED (unknown public key 2E1AC68ED40814E0)

gpg --recv-keys --keyserver hkp://pgp.mit.edu 2E1AC68ED40814E0 or gpg --recv-keys --keyserver http://pgp.mit.edu:11371 2E1AC68ED40814E0 or sudo pacman-key -r 2E1AC68ED40814E0

Arch Linux: Install lighttpd and php.

sudo pacman -S lighttpd php-fpm
Add the folowing line to: /etc/lighttpd/lighttpd.conf include "conf.d/fastcgi.conf"
Create folder conf.d and file fastcgi.conf with the following contents:
server.modules += ( "mod_fastcgi" )

index-file.names += ( "index.php" )

fastcgi.server = (
".php" => (
"localhost" => (
"socket" => "/run/php-fpm/php-fpm.sock",
"broken-scriptfilename" => "enable"
))
)

Enable php-fpm and lighttpd services: sudo systemctl enable php-fpm
sudo systemctl enable lighttpd

To start now php-fpm and lighttpd services: sudo systemctl start php-fpm
sudo systemctl start lighttpd

To check, go to /srv/www/ and create file index.php <?php
phpinfo();
?>
Make sure index.php has permission to be executed and read. To enable phpmyadmin sudo pacman -S phpmyadmin And place the following in /etc/lighttpd/lighttpd.conf alias.url = ( "/phpmyadmin" => "/usr/share/webapps/phpMyAdmin/")

server.modules = (
"mod_alias"
)