compjootery

Record of some of the computer tech I deal with so that it's documented at least somewhere.

Sunday, 4 September 2016

CSP in Julia - Sieve of Eratosthenes

The Sieve of Eratosthenes

Finally I got my head round Julia's CSP technique. The nomenclature is a bit different to what I'm used to. This is using producer/consumer which is single threaded. To do multi threaded uses different primitives, which is a shame. Perhaps one can adapt this setup using multiple RemoteRefs. We'll see.

This algorithm is translated from the Limbo code in Stanley Marbell's book Inferno Programming With Limbo which is still my favourite programming language although I haven't written any code in it for something like 10 years!

function sieve(prime, pipeline) function unsieved() while (u = consume(pipeline)) > 0 if mod(u, prime) != 0 produce(u) end end produce(0) # send end of candidates end println(prime) n = 0 for n in consume(pipeline) if mod(n, prime) == 0 break end end if n > 0 # not end of candiates sieve(n, Task(()->unsieved())) end end const LIMIT = 1024 sieve(2, Task(()->(for i in [3:LIMIT; 0] produce(i); end)))

Thursday, 21 July 2016

Another server - more courier fun

It's been a while since I did a proper courier installation. The one on CentOS was a botch. I have Debian Jessie in the VM now, phew

Usual stuff #apt-get install postfix courier-imap courier-imap-ssl

The ssl installs an SSL certificate that Thunderbird / Iceweasel doesn't accept because of DH key being too short. And then some other crap. I solved some of it before blogging so I forget what I did to kind of get it working.

# DH_BITS=2048 mkdhparams

Of course, then I got thinking, there are free SSL certificate issuers around, time to see if I can get a proper cert.

So off to https://startssl.com/ and see what to do. Once one has a login - local SSL cert installed in the browser - make sure you extract it (I haven't done that yet so I can't say how).

You will have to validate control of the domain by receiving an email at one of the ones listed as contacts in the WHOIS for the domain (e.g. postmaster@example.com)

Then you can go to the Tool Box and start the process of generating a:

(o) Web Server SSL/TLS Certificate

This takes you to https://startssl.com/Certificates/ApplySSLCert where you can add up to 5 domain names, which should be enough for most private stuff. And a Certificate Request generated with:

# openssl req -newkey rsa:2048 -keyout yourname.key.enc -out yourname.csr

the .key.enc has a keyphrase, you will need to produce a decrypted version

# openssl rsa -in server.key.enc -out server.key

Paste the .csr into the form on the same page and a new SSL cert is generated.

The Certificate List link will give you the wherewithall to download a server.pem file for your certificate. This is not enough to use in courier.

# cat server.key server.pem > /etc/courier/imapd.pem
# /etc/init.d/courier-imap-ssl restart

And that was that, Thunderbird was happy to connect, K9 Mail on my phone needed an "accept certificate" pressing but it accepted it. I guess one can add StartSSL CA certs to these things too.

plan9port on Debian Jessie

apt-get install build-essential git libx11-dev libfreetype6-dev libfontconfig1-dev libxext-dev

# cd /usr/local
# git clone https://github.com/9fans/plan9port plan9
# cd plan9
# sh INSTALL

Sunday, 15 November 2015

Xen Config stuff

This is information I don't want to lose. I got it from http://blog.hostduplex.com/2011/02/24/reconfigure-dns-on-xenserver-5-6/ but it is :

  1. Run a console
  2. # xe pif-list
    Take note of the uuid of your management interface.
  3. # xe pif-reconfigure-ip uuid=youruuid mode=static IP=ipaddresshere netmask=subnetmask gateway=yourgateway DNS=dnsserver1,dnsserver2

Now you'll need some memory. From http://serverfault.com/questions/292560/citrix-xenserver-how-to-add-ram-to-a-guest-vm-without-xencenter

# xe vm-list name-label=NAME params=all |grep memory
...
# xe vm-memory-limits-set dynamic-max=300000000 dynamic-min=300000000 static-max=300000000 static-min=16777216 name-label=Local-PerformanceVM

Connect to your machine # xe console uuid=UUID

Ok The whole shebang

Make the Jessie template
Then name a VM to use it :
# xe vm-install template=Debian\ Jessie\ 8.1\ \(64-bit\) new-name-label=$VMNAME
# xe vm-param-set uuid=$VMUUID other-config:install-repository=http://ftp.uk.debian.org/debian
# xe network-list bridge=xenbr0 --minimal
# xe vif-create vm-uuid=$VMUUID network-uuid=$NETUUID mac=random device=0
# xe vm-memory-limits-set dynamic-max=4000000000 dynamic-min=3000000000 static-max=4000000000 static-min=167772160 name-label=$VMNAME
# xe vm-start name-label=$VMNAME

Friday, 2 January 2015

ucspi-tcp installing on Centos and others

This is the same error
/usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference in envdir.o
as this guy but my solution doesn't need you to edit files manually !

echo '/^gcc s!$! -include /usr/include/errno.h! w q' | ed cc-conf

Friday, 4 July 2014

Machine perception of time, if only nanoseconds were seconds

I have copied this verbatim from Unmumble because I have referenced it a few times I don't want it to disappear.

Let's just discuss the time scale. The processor of your computer lives by the nanoseconds: the majority of the CPU can do several things for one nanosecond; generally, these are the simple math and the comparisons. To make this perception easer, we assume that you are the processor, and instead of nanoseconds you live and work second by second. In order to make it clear, we apply this metaphor to the single-core processor.

You are able to keep simultaneously a few things in your mind (the register). Not more than a dozen or two in your active memory, however you are capable to recall any of them almost instantly. You keep the important information handy, whether it is on the scratch pad on the desk (L1 cache) that is available in a couple of seconds or one of the books that is on the shelf (L2 and more cache), which is so well organized that every piece of information you cannot get in a dozen seconds or so.

If you cannot find what you are looking for there, you have to go to the library on the street (it is RAM). Fortunately, it is pretty close, so that you can walk over there, take a book and return to the work in only eight and a half minutes, and it is a lot, because some libraries are thousands of times greater than the size of a typical book store. It is a little inconvenient, until you remember that the library has the free delivery service, so you do not have to worry at all, if there is work to do while you are waiting.

But the local library keeps only the popular books (which is quite true, because your book shelf, the scratch pad, and even a dozen or two factors in your head are usually made on the same principle). The problem is that if you need something, and it is missing there, you will have to wait a little longer. How long? Well, let’s imagine Amazon.com in the age of discoveries. They send out an old wooden ship, and it may take weeks, perhaps months, and often you have to wait three years before you get a response.

Welcome to the hard drive world where your information is extracted by the rapid unwinding of metal plates. Many metric tons of sweat were shed in order to speed up the process as fast as possible, but it's hard to compete with the electrons that are flying over the wires.

So when someone says that the SSDs are splendid, because they are able to turn this slow unpredictable old sailing ship into a powerful steam engine vessel. A good SSD can often make a voyage in less than a week, and sometimes it could do in less than a day. It can also make the thousands of trips for information per year.

Saturday, 8 February 2014

Plan9port on CentOS - failed

Another distro, another set of nonsense.

I already had all the dev tools installed from doing courier

yum groupinstall 'Development Tools' yum install rpm-build gcc mysql-devel openssl-devel cyrus-sasl-devel pkgconfig zlib-devel pcre-devel openldap-devel postgresql-devel expect libtool-ltdl-devel openldap-servers libtool gdbm-devel pam-devel gamin-devel

So I don't know which of those is necessary for plan9port
Of course, we need the X11 code to compile rio & co The error is > cd /usr/local/plan9/src/cmd/devdraw; mk all 9c -I/usr/include x11-alloc.c x11-inc.h:17:28: error: X11/IntrinsicP.h: No such file or directory x11-inc.h:18:28: error: X11/StringDefs.h: No such file or directory

So first I tried this

yum install libX11-devel

no help, so then

yum install xorg-x11-proto-devel

no help, so then

yum install yum install libXt

oops not source code so no help, so then

yum install yum install libXt-devel

yay! that was the one.
not so fast Hot-Shot

>>> cd /usr/local/plan9/src/cmd/rio; mk all 9c -I/usr/include -DDEBUG -DSHAPE -DDEBUG_EV -DDEBUG event.c event.c:9:34: error: X11/extensions/shape.h: No such file or directory

so

yum install libXext-devel

woohoo

Not so fast Hot Shot

/home/matt/.vnc/xstartup: line 27: xsetroot: command not found sh: xsetroot: command not found

yum install xorg-x11-server-utils

Not so fast Hot Shot

rio: X_CreateWindow(0x20): BadMatch (invalid parameter attributes) rio: failure during initialisation; aborting

fucked, CentOS is now useless to me