DevOps' tips & tricks for GNU/Linux developers
- Q: Ansi terminal for Windows
A:
1. download and install wsltty
2. launch your program under mintty: mintty.exe program.exe
- Q: globally replace include path details in whole Golang project using sed
A:find . -name '*.go' -type f -execdir sed -i \ "s#github.com/fiorix/go-smpp#github.com/Zensey/go-smpp#" \ '{}' \;
Changes from / to (example):
include "github.com/fiorix/go-smpp"
include "github.com/Zensey/go-smpp"
-
Q: simulate client disconnect on GNU/Linux server
A:
# iptables -A INPUT -s 11.22.33.44 -j DROP; iptables -D INPUT -s 11.22.33.44 -j DROP
where 11.22.33.44 is client's IP
- Q: How to set udev rule to grant access for usb termo-printer (for example Godex) ?
A:
Create and edit file /etc/udev/rules.d/99-printers.rules
Set ATTRS{idVendor} and ATTRS{idProduct} to proper vendor/product id of your printer:
ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTRS{idVendor}=="195f", ATTRS{idProduct}=="0001", ENV{ID_USB_INTERFACES}=="*:0701??:*", MODE="0666"
-
Q: Git. merge changes from given tag
A:
git fetch --tags origin
git merge tag_name
-
Q: Git. Push a tag to origin
A:
After creating a tag in local branch do git push origin <tag_name> for ex. git push origin v1.3.4 -
Q: Git. merge changes from given tag
A:
git describe --tags --always
-
Q: Esptool. Dump ESP's ROM (for 1 megabyte)
A:
./esptool.py --port /dev/ttyUSB0 read_flash 0x00000 0x100000 ./dump_1.bin
-
Q: Esptool. Erase ESP's ROM
A:
./esptool.py --port /dev/ttyUSB0 erase_flash
-
Q: Redmine. Get info about ticket using REST API
A:
wget https://Server/issues/12345.json?include=journals
-
Q: Batch conversion mp4 -> mp3
A:
find -name "*.mp4" -type f -execdir ffmpeg -i '{}' -f mp3 '{}'.mp3 \;
-
Q: How to share a folder using HTTP, for ex. to transfer files from PC to mobile ?
A:
Download webserver.go from https://gist.github.com/alexisrobert/982674
Run:
go run webserver.go
-
Q: How to capture audio of conversation in Skype / Voip or any other program
A:
Use audio-recorder. To install it on Ubuntu use repository ppa:audio-recorder/ppa.
-
Q: Test local syslog logging
A:
logger -t topic -p local0.debug TestMsg
-
Q: Git. Spawning a branch from an empty state, before any commit has been made
A:
git checkout --orphan my_namespace/new_project/master
- Q: Git. How to merge the last commit with a previous one
A:
git reset HEAD~1
git commit --amend - Q: Git. How to merge the last commit with a previous one
A:
git reset HEAD~1
git commit --amend