SSH tunnel and port forwarding is great and convenient to use. But is it possible to set up a VPN like connection over SSH? If you are on Linux or Mac, you can use sshuttle: https://github.com/apenwarr/sshuttle If you are on Windows, you can use ProxyCap: http://www.proxycap.com/index.html Both are great software.
Tag: Linux
Enlarging Linux UDP buffer size
Posted onOne of the most common causes of UDP data gram lost on Linux is an undersized receive buffer on the Linux socket. How to enlarge Linux UDP buffer size? On Linux, you can change the UDP buffer size (e.g. to 26214400) by (as root): sysctl -w net.core.rmem_max=26214400 The default buffer size on Linux is 131071.
Read more
Filter away non-printable ASCII characters on Linux?
Posted onSometimes the commands’ output have some non-printable ASCII characters. How to filter away these non-printable ASCII characters on Linux? You can consider the problem as “how to leave only printable ascii characters?”. The printable characters in ASCII table are: Octal 011: Tab Octal 012: Line Feed Octal 015: Carriage Return Octal 040 to 176: printable
Read more
How to calculate the average of value in lines of a text file on Linux by a script?
Posted onHow to calculate the average of value in lines of a text file on Linux by a script? The file.txt is like: Run 0: Time used: 22.235331711 seconds. Run 1: Time used: 20.784491219 seconds. Run 2: Time used: 21.851638876 seconds. What I want it to calculate the average time. awk is handy for this purpose:
Read more
Setting sbt log level at the command line
Posted onsbt‘s log level can be set by execute set logLevel := Level.Error inside sbt. How to set the sbt log level at the command line? Add –error to sbt for specify the logLevel to error: sbt –error “your command”
Patching with git
Posted onTutorials on how to create patches and apply patches with git. A nice tutorial: https://ariejan.net/2009/10/26/how-to-create-and-apply-a-patch-with-git/ Manuals: git format-patch: https://www.systutorials.com/docs/linux/man/1-git-format-patch/git apply: https://www.systutorials.com/docs/linux/man/1-git-apply/
How to install multiple versions of sbt on my Linux host?
Posted onHow to install multiple versions of sbt on my Linux host For example, some projects use 0.12.x while some use 0.13.x. Installing neither in the system only is not sufficient enough. You may use the excellent sbt-extras: https://github.com/paulp/sbt-extras Most of the time, it detects the version of sbt needed in the project direoctory automatically: [zma@office
Read more
How to get the time at millisecond level on Linux with command line?
Posted onI know that gettimeofday() is a nice API. But how to get the number of seconds with milliseconds since the epoch time? You can get the time at nano-seconds level (although it is not guaranteed that the last digits are accurate) by: date +%s.%N
How to get the file length in C on Linux
Posted onHow to get the file length in C on Linux given the address of the file (e.g. “/tmp/a.txt”)? This function returns the length of the file: #include <sys/stat.h> long file_length(char *f) { struct stat st; stat(f, &st); return st.st_size; }
How to catch the kill signals sent by kill in C on Linux?
Posted onHow to catch the kill signals sent by the kill command in C programs on Linux? For example, I have a daemon progd running, and will kill it by: pkill progd The question is how to catch the signal sent by the kill command and response to it in the progd program implemented in C
Read more
Git branching tutorial
Posted onGood tutorials on git branching. The “Git Branching” chapter of Pro Git book is the best one that I ever seen: http://git-scm.com/book/en/Git-Branching It deserve the time to study the whole chapter. If you are working with a git server, this chapter is especially useful: http://git-scm.com/book/en/Git-Branching-Remote-Branches
How to force yum not to update certain packages?
Posted onHow to force yum not to update certain packages, such as kernel? I manually compiled a kernel module for a specific kernel version. As long as it works well, I do not want to update it. Another example is that I want a specific version of sbt. How to force yum exclude it from being
Read more
Formatting code shortcuts in Eclipse
Posted onFormatting code shortcuts in Eclipse. Shortcut: Ctrl + Shift + F No need to select the code.
How to force ibus to restart in Gnome 3?
Posted onHow to force ibus to restart in Gnome 3? There used to be a menu. But it does not provide the restart option anymore. To kill current ibus daemon: pkill -o ibus-daemon To start a new ibus daemon in Gnome 3, run this command in “Enter a command” tool by Alt+F2: /usr/bin/ibus-daemon –replace –xim –panel
Read more
Emacs highlighting part of lines that go over 80 chars
Posted onHow to make Emacs highlighting part of lines that go over 80 chars? I use the whitespace mode: ;; `lines-tail`, highlight the part that goes beyond the ;; limit of `whitespace-line-column` (require ‘whitespace) (setq whitespace-style ‘(face empty tabs lines-tail trailing)) (global-whitespace-mode t) More: https://github.com/zma/emacs-config/blob/master/.emacs Alternatively, you can run highlight-lines-matching-regexp with the expression .{81}. http://stackoverflow.com/questions/6344474/how-can-i-make-emacs-highlight-lines-that-go-over-80-chars
Running Chrome over SSH tunnel
Posted onHow to run Chrome on remote host over a SSH tunnel? This way, I can access resource that can only be accessed inside the remote host’s network. Running Chrome over a SSH tunnel is much easier than running Firefox over SSH from a Linux host: First, ssh to the remote host with -X option: ssh
Read more
How to install IE under wine on Linux?
Posted onHow to install IE under wine on Linux? Just need it for some testing. Do not want to reboot to Windows. We ever had ies4linux. But it is obsoleted now. linie is the latest effort. But there are issues and you may need to fix some problems by yourself. Installing a Windows VM may be
Read more
Printing a file in hexadecimal format of all content on Linux?
Posted onHow to print a binary file in hexadecimal format of all content? Use xxd: xxd file.txt or xxd -p file.txt
Changing a git commit message after I have pushed it to the server?
Posted onHow to change a wrong git commit message after I have pushed it to the server? If the remote repository is shared with others, it is better to let the wrong git commit message there. If you use the repository by your own and you are sure that no one else has pulled your latest
Read more
How to convert between dos and unix file coding in Emacs?
Posted onHow to convert between dos and unix file coding for files in Emacs? From Dos to Unix coding: M-x set-buffer-file-coding-system RET undecided-unix or C-x RET f undecided-unix Then save the file (C-x C-s). From Unix to Dos M-x set-buffer-file-coding-system RET undecided-dos or C-x RET f undecided-dos Then save the file (C-x C-s).