Wednesday, 5 October 2016

box table drawing characters

https://en.wikipedia.org/wiki/Box-drawing_character http://www.johndcook.com/blog/2008/08/18/entering-unicode-characters-in-linux/ ctrl+shift+u, hex number. Linux:
$ gucharmap
Keyboard:

left cntrl + left shift + u, 255c, enter

or

hold left cntrl + left shift + u, release u, 255c, release ctrnl,sjrt

The numbers can be from the keypad or line across then top 2500: ─ 2502: │ 250C: ┌ 2510: ┐ 2514: └ 2518: ┘ 251c: ├ 2524: ┤ 252c: ┬ 2534: ┴ 253c: ┼ ┌──┬──┐ │ │ │ ├──┼┬┬┤ │ ││││ └──┴┴┴┘

Tuesday, 4 October 2016

http://julialang.org/blog/2015/10/glvisualize http://nbviewer.jupyter.org/github/jr3cermak/robs-kitchensink/blob/master/jupyterhub/notebooks/NCAR-SEA-2015.ipynb https://groups.google.com/forum/#!topic/jupyter/11tzXQ45ZKE

Monday, 26 September 2016

mounting drives specifying offset


$ ls /dev/sda*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda5

$ sudo fdisk -l /dev/sda
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5c7f4b84

Device     Boot   Start       End   Sectors   Size Id Type
/dev/sda1          2048    999423    997376   487M 83 Linux
/dev/sda2       1001470 976771071 975769602 465.3G  5 Extended
/dev/sda5       1001472 976771071 975769600 465.3G 8e Linux LVM

$ sudo mount /dev/sda2 /mnt/sda2
mount: wrong fs type, bad option, bad superblock on /dev/sda2,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
The offset here is 1001470*512 bytes = 512752640 to get to the second partition:

sudo mount -o ro,loop,offset=512752640 /dev/sda /mnt/sda2/
If using an image file, use the filename instead of /dev/sda

Wednesday, 14 September 2016

Yet another backup rsync script. This one works on Ubuntu, 2016 September.

For some reason, my old backup scripts aren't working. A simpler approach is to add this sort of thing to a script called by cron:

rsync -vrmxz --progress --include='*.ipynb' 
  --include='*/' --exclude='*' /home/me /mnt/J/backup/
which starts at the current directory and works through all sub-directories, grabbing each .ipynb file and copying it to /backup. The parameters: a: archive mode. Preserve attributes. v: verbose. Not needed for the silent cron version. z: compress during transfer. Not needed if creating a first copy locally but useful for network xfer. x: one filesystem: don't cross file-system boundaries. r: recursive. m: prune empty directories. Essential. progress: live feedback. Not needed for silent cron version. include: files to include exclude: files to exclude. This is required even though we used an include command. *.* is essential. Make neater using variables:

hour=`date +%H`
i="ipynb"
rsync -vrmxz --progress --include="*.$i" --include='*/' 
  --exclude='*' /home/me /mnt/J/backup/hour$hour/
Regarding ddrescue solutions, watch for squashfs: it will create a compressed backup image that can be mounted. Seems better than ddrescue piped to gzip or so.

Monday, 23 May 2016

future

netatmo

Julia cheat list.

Flattening nested lists: use vec(l) DataFrames: Set data up either column or row centric as desired. If row centric, add a new row with,

using DataFrames
DF = DataFrame

In [106]:

a = DF(a = [1,2,3], b = [4,5,6])
# add a new row at the end. `;` is shorthand  for vcat, I think.
a = [a; DF(a = [7], b = [8])]
Out[106]:
        a b
1 1 4
2 2 5
3 3 6
4 7 8
Column-centric to me, often feels better:

In [109]:

a = DF(a = [1,2,3], b = [4,5,6])
a[:newColumn] = [7,8,9]

Out[109]:
a b newColumn
1 1 4 7
2 2 5 8
3 3 6 9
but then plotting with GadGly is much neater if we have three columns with all the data: c1 -> x axis; c2 -> y axis; c3 = color of plot. At plot time, rearrange so that the column title becomes the color entry:
Out[109]:
a b newColumn
1 1 4 7
2 2 5 8
3 3 6 9

In [110]: b = stack(a, [:a, :b])

Out[110]:
       variable value newColumn
1 a 1 7
2 a 2 8
3 a 3 9
4 b 4 7
5 b 5 8
6 b 6 9

Wednesday, 4 May 2016

Beautiful acoustics log-log scales with GadFly


# Set up acoustics graph parameters.
drop = [log10(i) for i in [500, 700, 900, 5000, 7000, 9000, 50000, 70000, 90000]];
xlist = [[1000:1000:9000]; [10000:10000:100000]]
ylist = [[400:100:900]; [1000:1000:9000]; [10000:10000:100000]];
labx = x -> x in drop ? "": @sprintf("%0.0f", 10^(Float64(x)-3));
laby = y -> y in drop ? "": y > log10(900) ? @sprintf("%.0f", 10^(Float64(y)-3)): @sprintf("%0.1f", 10^(Float64(y)-3));
xt, yt = [log10(i) for i in xlist], [log10(i) for i in ylist]
xl, yl, tit = "f (kHz)", "|Ze| (kΩ)", "High resolution LCR measurement of Prowave device.";



int = res["20160504-1"]["int"];
plt = DataFrame(f = f, absZe=abs(int[f]))
plot(plt, x = :f, y = :absZe, Geom.line, 
  Scale.x_log10(labels=labx), Scale.y_log10(labels=laby), 
Guide.xlabel(xl), Guide.ylabel(yl), Guide.xticks(ticks = xt), Guide.yticks(ticks = yt), Guide.title(tit))
Created,