Skip to content

Instantly share code, notes, and snippets.

@cschu
cschu / gist:c55fbaf38a94200469757cd7eebdad52
Last active April 21, 2026 10:01
Single quotes in single quotes
1. Use ANSI-escaped string (last answer in https://stackoverflow.com/questions/25608503/using-single-quotes-with-echo-in-bash)
```
echo $'\''
```
2. via awk: use octal escape sequences (' = 39, https://unix.stackexchange.com/questions/593212/awk-print-apostrophe-single-quote)
```
awk '{print "\047" $0 "\047"}' input
@cschu
cschu / inplace_rotate.py
Created June 28, 2019 22:49
Rotate list in-place
def rotate(L, n_rotations):
"""
rotates list L in place by n_rotations
[a,b,c,d] -> [b,c,d,a] (n_rotations = 1)
[a,b,c,d] -> [c,d,a,b] (n_rotations = 2)
assumption:
n_rotations can be at most |L| - 1, i.e. |L| rotations
will result in L itself, |L| + 1 in L rotated once, etc.