I decided to replace Observer/Observable in my long-standing #java project today. My first and favourite design pattern 😞 but I had to blitz those warnings:
Observer becomes java.beans.PropertyChangeListener, and for 'update' you get 'propertyChange (PropertyChangeEvent e)'. Easy.
Observable goes - embed an instance of java.beans.PropertyChangeSupport in your class with 'add/remove PropertyChangeListener' wrapper methods.
To update, call 'firePropertyChange (name, oldValue, newValue)'.
In my battle against bitrot I resurrected a 2011 program I had written to display the galaxy information in the game #oolite. I wrote this back in 2011, and I remember playing the game a bit then - memories of Elite on the ZX Spectrum!
This image shows the user exploring star systems along the Maorin Pass in Sector 2, Colesque:
A #lisp application using Tk for a GUI can be made into an executable in CLISP and SBCL:
clisp> (ext:saveinitmem "hello" :executable t :init-function #'run)
sbcl> (save-lisp-and-die "hello" :toplevel #'run :executable t)
CLISP's executable is much smaller (x5, at only 9MB) but is a 'shared library', not an 'executable', like SBCL - double-clicking the file does not work.
Collecting some #lisp links:
Reading text files into Vim. As the files were originally stored on a Mac the line endings are marked ^M and are not recognised as line endings.
Make Vim recognise the Mac line endings by setting the file format for the currently edited file:
The display will update with correct line endings.
Set line endings for unix:
And finally save the file.
Pros for gogs:
- Issues are a convenient 'TODO' list
- Releases are created for tags (but this is only needed for public repos, which are on Notabug)
Cons for gogs:
- I had to edit out the 'social' stuff, to clean up the display
- Fancy avatar, several un-needed features
Cons for cgit:
- ... less easy to make a new repository
Pros for cgit:
- it's all about git
- nice compact index
- quicker rendering of files
Things worked better than I expected, until I had the server producing the cgit pages.
But there was a problem as the cgit.css file was not found.
I solved this with cgit/etc/cgitrc as:
by copying those two files from cgit/bin to /var/www/html/
I suspect there's a setup variable I'm missing.
NASA's curiosity rover, sat at Gale Crater, #Mars, is measuring the atmosphere and its constituents. Seasonal trends in oxygen and methane are currently unexplained, with levels rising from spring to summer and then falling in autumn.
"... three potential abiotic reservoirs of oxygen in the surface/subsurface of Mars
- oxidant, in the form of perchlorates;
- oxidant in the form of hydrogen peroxide; and
- oxidised rocks or hydrated minerals." Prof Atreya
On 13th November 1312 the future King Edward 'the Third after the Conquest' was born.
About his father (who was later forced to abdicate and murdered): 'Our King Edward has now reigned six full years and up until now he has achieved nothing praiseworthy or memorable, except that he has made a splendid marriage and has produced a handsome son and heir to the kingdom.' Vita Edwardi Secundi
Edward III was to be crowned as King on 1st February 1327, and reigned until his death - 21st June 1377.
Samples from asteroid Ryugu on their way back to Earth.
The Japanese spacecraft Hayabusa-2 launched in 2014. It made two touch-downs, in February and July this year, each time excavating part of the surface to collect a sample. The second one took samples from below the asteroid's surface.
The spacecraft should return its samples to Earth late in 2020.
In #julia, use Pkg to manage your dependencies - saved in your project's environment: the Project.toml and Manifest.toml files.
e.g. you have a project in "~/code/MyProject"
Get 'into' the project's environment:
(v1.2) pkg> activate .
(MyProject) pkg> status
Project MyProject v1.0.0
Here you can add/rm/update packages for MyProject.
NB: test has its own environment:
(MyProject) pkg> activate ./test
(test) pkg> add Test
(test) pkg> activate
My first #julia project completed.
It's not a complicated project - a rewrite of a neural net model I did in C as a student. But it has been a good exercise for getting to know Julia.
I like the language. Its syntax and structure combine some of the favourite aspects of other languages I like. But I wish it were more responsive: Ruby's better for short-running scripts, e.g. graphing some data.
On balance, I like Julia enough to try a second, larger project.
I think I'll be keeping #dwm. I like not having to think about the size of windows.
Java swing programs need some help, to avoid showing as a blank window:
My first #julia project is almost complete. It's a simple neural net style program, built from arrays. I read the Performance Tips in the documentation, to see what I could improve.
At start: 7m32s runtime
Added types to struct variables, which are mostly array types.
New runtime: 3m13s
Added @inbounds to most lines with array access
New runtime: 2m8s
I'm stopping here.
Next I could look into adding @simd to some loops, but ~3x is enough for now.
I have been experimenting with the documentation for #julia packages created using Documenter.
I do not need (or like) the "Edit on ..." link that appears on every page, so here's a script to get rid of it:
# This script removes the "Edit on GitHub" message in Julia documentation
for file in `find . -type f -name "*.html"`
sed -i -e"s/<a class=\"edit-page\".*Edit on GitHub<\/a>//g" $file
Over the last few days I've been watching the JuliaAcademy courses, which are currently free!
The ML courses introduce the Flux and Knet libraries with some basic examples. I'm currently half-way through the last course, on parallel computing, which is more technical and very interesting.
I don't know when the courses were made, or if it's just because I'm using the REPL and #julia version 1.2, but some function calls etc have changed or been deprecated.
I decided to experiment with DWM, a tiled window manager, instead of XFCE. I'm running XUbuntu, 18.04.
> sudo apt install dwm
I could select DWM at log in.
First customisation: to get date/time in corner, create ~/.xsession
while true; do
xsetroot -name "$(date "+%x %I:%M %p")"
To make the login program run .xsession on start up, I changed /usr/share/xsessions/drm.desktop:
Last week, I learnt something about remotes with #git. This week, I will start to think more about my 'commit' messages.
I'll try to keep the "7-rules" in mind. Especially about adding a 'body' to the message, under a 'title'. Explaining the what and why sounds like a useful thing to do.
Recently I've been "tidying up" and finding new homes for code - trying to keep older software from falling to 'bitrot'.
And today I came across this "Ten Years Reproducibility Challenge" by the ReScience journal:
I have some code in #lisp from ~2000-10, and lisp is pretty stable - but there might be some minor issues with the version of Lisp. It would be nice to have those case studies working and available.
There's a project in #java, but too young.
I've completed the first 'draft' of my trial project in #julia.
So far, procedural programming has been fairly straightforward, and I've been fighting my algorithms more than the language.
Arrays: there are some nice convenience functions for constructing arrays, like 'zeros', 'fill'.
Multi-dimensional arrays use [i,j] notation, and I need to look again at the difference between "multi-dimensional" and "array of arrays".
Next, I will try out the support for tests and documentation.