// Computer Tips

// Computer Tips

I frequently find myself needing to look up simple Linux and programming commands. This page is a continuously updated repository of useful commands:

General

Grab all files of a given type from a webpage

1
wget -r -np -nd -l 0 -A.pdf http://security.cs.rpi.edu/courses/binexp-spring2015/lectures/

Adjust external monitor brightness

1
xrandr --output HDMI-1 --brightness 0.5

Edit all images in-place

1
2
3
4
5
# wxh+left+top
# Cropping
mogrify -crop 640x330+0+0 *.jpg
# Resizing
mogrify -resize 640x330+0+0 *.jpg

Photo metadata

1
2
3
4
# Read metadata
exiftool /tmp/my_photo.jpg
# Delete metadata
exiftool -overwrite_original_in_place -all= /tmp/my_photo.jpg
1
ln -s <src> <dest>

Change git remote URL for forks

1
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git

Get all Git submodules

1
git submodule update --init --recursive

Change video bitrate

1
2
# To get a 4mbps video
ffmpeg -i input.mp4 -b 4000k output.mp4

Make LaTeX machine readable

1
2
3
% Add these two lines in your preamble
\input{glyphtounicode}
\pdfgentounicode=1

Get Windows BIOS keys

1
sudo hexdump -s 56 -e '"MSDM key: " /29 "%s\n"' /sys/firmware/acpi/tables/MSDM

Watch a directory

1
2
# Updates every 0.1s
watch -n 0.1 ls -lt .

Fix Ubuntu and Windows time sync issues

1
timedatectl set-local-rtc 1 --adjust-system-clock

SSHFS Example

1
sshfs USER@IP:/$PATH $LOCAL_PATH

Copy SSH keys to server

1
ssh-copy-id id@server

Screen tips

1
2
3
4
5
6
7
8
# Create a named screen
screen -S myscreen
# Reconnect
screen -r myscreen
# List screens
screen -ls
# Detach
Ctrl+A+D

Jekyll setup

1
2
3
4
5
sudo apt-get install ruby-full build-essential zlib1g-dev
gem install jekyll bundler
bundle install
bundle exec jekyll serve --watch --trace
bundler exec jekyll build && bash -c 'cd _site && python -m http.server 3000' # workaround for Ruby3

Boot repair setup

1
2
3
sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install -y boot-repair && boot-repair

Fix annoying K380 function key defaults

1
2
3
4
5
6
7
8
9
10
# Download and build configuration script from https://github.com/jergusg/k380-function-keys-conf
# Then add the below to the root's crontab: * * * * * /home/nic/k380hack.sh
# k380hack.sh
/home/nic/software/k380-function-keys-conf/k380_conf -d /dev/hidraw0 -f on
/home/nic/software/k380-function-keys-conf/k380_conf -d /dev/hidraw1 -f on
/home/nic/software/k380-function-keys-conf/k380_conf -d /dev/hidraw2 -f on
/home/nic/software/k380-function-keys-conf/k380_conf -d /dev/hidraw3 -f on
/home/nic/software/k380-function-keys-conf/k380_conf -d /dev/hidraw4 -f on
/home/nic/software/k380-function-keys-conf/k380_conf -d /dev/hidraw5 -f on
# Clean? No. Effective? Yes!

Python and Jupyter

Show all Pandas columns

1
pd.set_option('display.max_colwidth', -1)

Increase width of Jupyter Notebook

1
2
3
# Add this to the first cell of your notebook
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:90% !important; }</style>"))

Install dependencies

1
pip install -r requirements.txt

Display a full numpy array

1
np.set_printoptions(threshold=np.inf)

Automatically reload modules for Jupyter

1
2
3
# add to beginning of notebook
%load_ext autoreload
%autoreload 2

Creating a new Jupyter Notebook

1
2
3
4
5
6
7
8
import numpy as np
from matplotlib import pyplot as plt
from scipy import interpolate
import matplotlib.image as mpimg
import os
import PIL.Image as Image
%load_ext autoreload
%autoreload 2

Main function

1
2
3
4
5
# wtf is this so hard to remember?
def main():
    print("hey there")
if __name__=="__main__":
    main()

Raspberry Pi

SSH

touch ssh to enable ssh in /boot

WiFi

In /boot/wpa_supplicant.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="NAME"
scan_ssid=1
psk="PASSWORD"
key_mgmt=WPA-PSK
}

network={
   ssid="TELLO-D8A5A9"
   key_mgmt=NONE
}

GPIO cheatsheet

1
pinout

NMap to find devices

1
sudo nmap -sn 192.168.1.0/24

ROS

Build with debug flags

1
catkin_make -DCMAKE_BUILD_TYPE=Debug

Miscellaneous

Get GTK thumbnails back

1
sudo apt install gnome-icon-theme

Video thumbnail previews in Dolphin

1
2
sudo apt install ffmpegthumbs mplayerthumbs kffmpegthumbnailer kio-extras
# and then enable Previews by going to Dolphin Preferences

Setup a Samba share in Dolphin

1
2
sudo apt install kdenetwork-filesharing libsmbclient samba smbclient
# right click to Share folder after this

Change to libinput for touchpad

Uninstall synaptics.

Fresh Install

1
2
zoom code slack
geany mendeleydesktop