mandarg

13 thoughts; 1 stream
last posted Dec. 17, 2018, 3:49 a.m.
0
Joined on April 1, 2014, 3:03 p.m.
get recent cards as: atom
0 thoughts
updated Feb. 2, 2016, 7:03 p.m.

Streams by this user that have been favorited by others.

No favorited streams yet.

0

Turns out the canonical way to swap CapsLock and Ctrl on Debian-based systems is to set XKBOPTIONS="ctrl:nocaps" in /etc/default/keyboard.

Reference: https://unix.stackexchange.com/questions/452391/execute-command-to-swap-caps-lock-and-ctrl-at-startup

0

You can use the ts utility from moreutils to prepend a timestamp to every line of your command output.

0

If you see a new process state I in your top output, it's due to these commits.

Currently people use TASK_INTERRUPTIBLE to idle kthreads and wait for 'work' because TASK_UNINTERRUPTIBLE contributes to the loadavg. Having all idle kthreads contribute to the loadavg is somewhat silly. Now mostly this works OK, because kthreads have all their signals masked. However there's a few sites where this is causing problems and TASK_UNINTERRUPTIBLE should be used, except for that loadavg issue. This patch adds TASK_NOLOAD which, when combined with TASK_UNINTERRUPTIBLE avoids the loadavg accounting.

0

Swappiness is a kernel parameter that controls how often your pages are swapped to disk. A low value causes the kernel to avoid swapping; a higher value causes the kernel to try to use swap space. The default value is 60.

$ cat /proc/sys/vm/swappiness
60
0

What is lexical scoping? A simple example in OCaml:

# let f x = x + 2;;
# let g x = f (f x);;
# let f x = x * x;;

# g 10;;
- : int = 14
# f 10;;
- : int = 100
0

apt-cache show on Debian/Ubuntu gives you a decent amount of information about an installed package. I have used this before, but not consistently.

e.g.

$ apt-cache show python
Package: python
Priority: important
Section: python
Installed-Size: 658
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Matthias Klose <doko@debian.org>
Architecture: amd64
Source: python-defaults
Version: 2.7.3-0ubuntu2.2
Replaces: python-dev (<< 2.6.5-2)
Provides: python-ctypes, python-email, python-importlib, python-profiler, python-wsgiref
Depends: python2.7 (>= 2.7.3), python-minimal (= 2.7.3-0ubuntu2.2)
Suggests: python-doc (= 2.7.3-0ubuntu2.2), python-tk (= 2.7.3-0ubuntu2.2)
Conflicts: python-central (<< 0.5.5)
Breaks: python-bz2 (<< 1.1-8), python-csv (<< 1.0-4), python-email (<< 2.5.5-3), update-manager-core (<< 0.200.5-2)
Filename: pool/main/p/python-defaults/python_2.7.3-0ubuntu2.2_amd64.deb
Size: 167552
MD5sum: 81b302b2f98d8125fa60a886a61644fe
SHA1: 336fcd82246e00f52455112dba780fa34cb0eaa8
SHA256: bec692c0b1629e68002b317d3bcef0e6234d723d7aafcec5e0d81eb94449b76c
Description-en: interactive high-level object-oriented language (default version)
 Python, the high-level, interactive object oriented language,
 includes an extensive class library with lots of goodies for
 network programming, system administration, sounds and graphics.
 .
 This package is a dependency package, which depends on Debian's default
 Python version (currently v2.7).
Multi-Arch: allowed
Homepage: http://www.python.org/
Description-md5: d1ea97f755d8153fe116080f2352859b
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 5y
Task: minimal

Package: python
Priority: important
Section: python
Installed-Size: 658
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Matthias Klose <doko@debian.org>
Architecture: amd64
Source: python-defaults
Version: 2.7.3-0ubuntu2
Replaces: python-dev (<< 2.6.5-2)
Provides: python-ctypes, python-email, python-importlib, python-profiler, python-wsgiref
Depends: python2.7 (>= 2.7.3), python-minimal (= 2.7.3-0ubuntu2)
Suggests: python-doc (= 2.7.3-0ubuntu2), python-tk (= 2.7.3-0ubuntu2)
Conflicts: python-central (<< 0.5.5)
Breaks: python-bz2 (<< 1.1-8), python-csv (<< 1.0-4), python-email (<< 2.5.5-3), update-manager-core (<< 0.200.5-2)
Filename: pool/main/p/python-defaults/python_2.7.3-0ubuntu2_amd64.deb
Size: 166114
MD5sum: 5e0615e173a3834d0b2e97768bfe4d2c
SHA1: a748ba4f38c3dd94bc6d782a8421499b01c406f3
SHA256: ec8a24ec3cf3dfdf42581fa529e0ee69dc08bd8c29aeb601c329c337e5605e0e
Description-en: interactive high-level object-oriented language (default version)
 Python, the high-level, interactive object oriented language,
 includes an extensive class library with lots of goodies for
 network programming, system administration, sounds and graphics.
 .
 This package is a dependency package, which depends on Debian's default
 Python version (currently v2.7).
Homepage: http://www.python.org/
Description-md5: d1ea97f755d8153fe116080f2352859b
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 5y
Task: minimal
0

Peteris Krumins has a nice post about his favourite regex

It is this: [ -~] — everything from the space to the tilde, which is all printable characters. Though I think the space makes it hard to read, and if I ever use this in anything, I'd like to make it a bit more explicit 😊

0

A common workflow is to sed -i '<expression> somefile.conf to change things in the file, followed by cat somefile.conf to see if things changed.

Using word designators in Bash is pretty useful for this. e.g. In the scenario above, after the sed command running cat !$ will show you the (hopefully, correctly modified) file contents.

From this answer, to show the sections of the bash manpage on history expansion:

man  -P 'less -p ^HISTORY\ EXPANSION' bash
0

sed can be used to replace regex-defined sections of text in a file with random number like this.

The solution in the answer linked utilizes the concepts of “hold space” and “pattern space” in sed. This answer goes over them in detail.

0

Emacs has pretty decent line processing functions. delete-matching-lines (which deletes lines matching a specific regex) is often great when you want to quickly delete a bunch of lines with a particular word, prefix, or tag.

Xah Lee reference page

0

To quickly close window in Emacs and kill the buffer that was open in it, use C-x 4 0 (function kill-buffer-and-window)

Manual reference

0

Quick difference between "greedy" and "lazy" in regex: consider a phrase with nested parentheses, e.g. (the quick (brown) fox jumps over the lazy dog).

  • The lazy regex \(.*?\) captures only up to the first end parenthesis, i.e.(the quick (brown)

  • Whereas the greedy one \(.*\) captures all the way to the end (the quick (brown) fox jumps over the lazy dog).

0

In emacs-term, you can switch between character mode (which sends your command to the underlying shell) and line mode (which allows you to edit text at will) by using C-c C-j or C-c C-k.

Manual Reference

0

Turns out the canonical way to swap CapsLock and Ctrl on Debian-based systems is to set XKBOPTIONS="ctrl:nocaps" in /etc/default/keyboard.

Reference: https://unix.stackexchange.com/questions/452391/execute-command-to-swap-caps-lock-and-ctrl-at-startup

0

You can use the ts utility from moreutils to prepend a timestamp to every line of your command output.

6 years ago
0

If you see a new process state I in your top output, it's due to these commits.

Currently people use TASK_INTERRUPTIBLE to idle kthreads and wait for 'work' because TASK_UNINTERRUPTIBLE contributes to the loadavg. Having all idle kthreads contribute to the loadavg is somewhat silly. Now mostly this works OK, because kthreads have all their signals masked. However there's a few sites where this is causing problems and TASK_UNINTERRUPTIBLE should be used, except for that loadavg issue. This patch adds TASK_NOLOAD which, when combined with TASK_UNINTERRUPTIBLE avoids the loadavg accounting.

0

Swappiness is a kernel parameter that controls how often your pages are swapped to disk. A low value causes the kernel to avoid swapping; a higher value causes the kernel to try to use swap space. The default value is 60.

$ cat /proc/sys/vm/swappiness
60
8 years ago
0

What is lexical scoping? A simple example in OCaml:

# let f x = x + 2;;
# let g x = f (f x);;
# let f x = x * x;;

# g 10;;
- : int = 14
# f 10;;
- : int = 100
0

apt-cache show on Debian/Ubuntu gives you a decent amount of information about an installed package. I have used this before, but not consistently.

e.g.

$ apt-cache show python
Package: python
Priority: important
Section: python
Installed-Size: 658
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Matthias Klose <doko@debian.org>
Architecture: amd64
Source: python-defaults
Version: 2.7.3-0ubuntu2.2
Replaces: python-dev (<< 2.6.5-2)
Provides: python-ctypes, python-email, python-importlib, python-profiler, python-wsgiref
Depends: python2.7 (>= 2.7.3), python-minimal (= 2.7.3-0ubuntu2.2)
Suggests: python-doc (= 2.7.3-0ubuntu2.2), python-tk (= 2.7.3-0ubuntu2.2)
Conflicts: python-central (<< 0.5.5)
Breaks: python-bz2 (<< 1.1-8), python-csv (<< 1.0-4), python-email (<< 2.5.5-3), update-manager-core (<< 0.200.5-2)
Filename: pool/main/p/python-defaults/python_2.7.3-0ubuntu2.2_amd64.deb
Size: 167552
MD5sum: 81b302b2f98d8125fa60a886a61644fe
SHA1: 336fcd82246e00f52455112dba780fa34cb0eaa8
SHA256: bec692c0b1629e68002b317d3bcef0e6234d723d7aafcec5e0d81eb94449b76c
Description-en: interactive high-level object-oriented language (default version)
 Python, the high-level, interactive object oriented language,
 includes an extensive class library with lots of goodies for
 network programming, system administration, sounds and graphics.
 .
 This package is a dependency package, which depends on Debian's default
 Python version (currently v2.7).
Multi-Arch: allowed
Homepage: http://www.python.org/
Description-md5: d1ea97f755d8153fe116080f2352859b
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 5y
Task: minimal

Package: python
Priority: important
Section: python
Installed-Size: 658
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Matthias Klose <doko@debian.org>
Architecture: amd64
Source: python-defaults
Version: 2.7.3-0ubuntu2
Replaces: python-dev (<< 2.6.5-2)
Provides: python-ctypes, python-email, python-importlib, python-profiler, python-wsgiref
Depends: python2.7 (>= 2.7.3), python-minimal (= 2.7.3-0ubuntu2)
Suggests: python-doc (= 2.7.3-0ubuntu2), python-tk (= 2.7.3-0ubuntu2)
Conflicts: python-central (<< 0.5.5)
Breaks: python-bz2 (<< 1.1-8), python-csv (<< 1.0-4), python-email (<< 2.5.5-3), update-manager-core (<< 0.200.5-2)
Filename: pool/main/p/python-defaults/python_2.7.3-0ubuntu2_amd64.deb
Size: 166114
MD5sum: 5e0615e173a3834d0b2e97768bfe4d2c
SHA1: a748ba4f38c3dd94bc6d782a8421499b01c406f3
SHA256: ec8a24ec3cf3dfdf42581fa529e0ee69dc08bd8c29aeb601c329c337e5605e0e
Description-en: interactive high-level object-oriented language (default version)
 Python, the high-level, interactive object oriented language,
 includes an extensive class library with lots of goodies for
 network programming, system administration, sounds and graphics.
 .
 This package is a dependency package, which depends on Debian's default
 Python version (currently v2.7).
Homepage: http://www.python.org/
Description-md5: d1ea97f755d8153fe116080f2352859b
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 5y
Task: minimal
mandarg favorited DRMacIver
8 years, 5 months ago
0

Peteris Krumins has a nice post about his favourite regex

It is this: [ -~] — everything from the space to the tilde, which is all printable characters. Though I think the space makes it hard to read, and if I ever use this in anything, I'd like to make it a bit more explicit 😊

0

A common workflow is to sed -i '<expression> somefile.conf to change things in the file, followed by cat somefile.conf to see if things changed.

Using word designators in Bash is pretty useful for this. e.g. In the scenario above, after the sed command running cat !$ will show you the (hopefully, correctly modified) file contents.

From this answer, to show the sections of the bash manpage on history expansion:

man  -P 'less -p ^HISTORY\ EXPANSION' bash
mandarg favorited ncoghlan_dev
8 years, 8 months ago
0

sed can be used to replace regex-defined sections of text in a file with random number like this.

The solution in the answer linked utilizes the concepts of “hold space” and “pattern space” in sed. This answer goes over them in detail.

mandarg favorited paltman
8 years, 8 months ago
0

Emacs has pretty decent line processing functions. delete-matching-lines (which deletes lines matching a specific regex) is often great when you want to quickly delete a bunch of lines with a particular word, prefix, or tag.

Xah Lee reference page

0

To quickly close window in Emacs and kill the buffer that was open in it, use C-x 4 0 (function kill-buffer-and-window)

Manual reference

0

Quick difference between "greedy" and "lazy" in regex: consider a phrase with nested parentheses, e.g. (the quick (brown) fox jumps over the lazy dog).

  • The lazy regex \(.*?\) captures only up to the first end parenthesis, i.e.(the quick (brown)

  • Whereas the greedy one \(.*\) captures all the way to the end (the quick (brown) fox jumps over the lazy dog).

0

In emacs-term, you can switch between character mode (which sends your command to the underlying shell) and line mode (which allows you to edit text at will) by using C-c C-j or C-c C-k.

Manual Reference

Thoughts by this user that have been liked by others.

No liked thoughts yet.