IV Notes
Search…
Command line
  • rsync is a better cp. You can easily get a copy with progress bar by just using rsync -P file_a file_b It also has a ton of other useful functions. Originally picked it up from this post: https://solovyov.net/blog/2011/rsync-better-cp/
  • To get the full processor name on Mac:
1
➜ sysctl -n machdep.cpu.brand_string
2
Intel(R) Core(TM) i7-3740QM CPU @ 2.70GHz
Copied!
  • To create a zero-filled file of specified size:
1
dd if=/dev/zero of=32mb.bin bs=32m count=1
Copied!
  • To run a program and report its maximum memory usage and other interesting things we can use usual GNU time(on Mac: brew install gnu-time will install it as gtime).
1
➜ gtime -v target/release/c
2
iterator returned: 384
3
4
Command being timed: "target/release/c"
5
User time (seconds): 0.77
6
System time (seconds): 0.62
7
Percent of CPU this job got: 99%
8
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.40
9
Average shared text size (kbytes): 0
10
Average unshared data size (kbytes): 0
11
Average stack size (kbytes): 0
12
Average total size (kbytes): 0
13
Maximum resident set size (kbytes): 3125868
14
Average resident set size (kbytes): 0
15
Major (requiring I/O) page faults: 0
16
Minor (reclaiming a frame) page faults: 781620
17
Voluntary context switches: 3
18
Involuntary context switches: 112
19
Swaps: 0
20
File system inputs: 0
21
File system outputs: 0
22
Socket messages sent: 0
23
Socket messages received: 0
24
Signals delivered: 0
25
Page size (bytes): 4096
26
Exit status: 0
Copied!
  • Or even simpler, to just print maximum resident set size at the end: gtime -f %M program_name
  • Convert an SVG files to multiple PNG files with different resolutions and pack them all in an ICO file:
1
# install `svgexport` and `imagemagick`:
2
brew install imagemagick
3
npm install -g svgexport
4
5
# this worked better than ImageMagick for me:
6
svgexport favicon.svg 16.png 16:16
7
svgexport favicon.svg 32.png 32:32
8
9
# and so on, and then combine them:
10
convert 16.png 24.png 32.png -colors 256 favicon.ico
Copied!
  • Run a command every 5 seconds: watch -n5 command
  • Convert GPS routes from .gpx to .kml without creating lots of points:
    1
    gpsbabel -i gpx -f input.gpx -o kml,points=0 -F output.kml
    Copied!
Last modified 5mo ago
Copy link