Cleaning up a linux machine (arch)

TLDR

journalctl --vacuum-size=100M #remove all logs, only retain 100mb
pacman -Scc #remove all package installation files (obsolete and current)
pacman -S bleachbit
bleachbit -c system.*

First, what's big on the system

du -d1 -h / 2>/dev/null | sort -h

This shows a sorted list of the largest dirs in `/`
You can do two levels down:

du -d2 -h / 2>/dev/null | sort -h

My result is:

0 /proc
0 /sys
0 /tmp
12K /dev
12K /srv
16K /lost+found
632K /run
4.3M /boot
13M /opt
15M /etc
75M /root
93M /home
2.4G /var
3.2G /usr
221G /mnt
227G /

I ignore /mnt (because that's an external drive)
Two dirs stand to mind: var and usr.
Let's see what's inside:

du -d1 -h /var /usr 2>/dev/null | sort -h

Then, a little bit deeper:

du -d1 -h /var/log /usr/share /usr/lib /var/cache 2>/dev/null | sort -h

Let's start with the logs

I have 717mb in /var/log.

I'm not a fan of deleting directories randomly, so let's do it the clean way:

$ journalctl --disk-usage
Archived and active journals take up 728.7M on disk.

Let's leave only 100mb of logs:

journalctl --vacuum-size=100M
...
Deleted archived journal /var/log/journal/ba5391...b.journal (8.0M).
...
Vacuuming done, freed 616.6M of archived journals on disk.

More info here on how to configure journalctl here.

Packages

I have 660M /var/cache/pacman. It was 1.8gb, but I ran pacman -Sc to remove unused packages. Let's remove the rest:

pacman -Scc

/usr/share/locale

A lot of users do remove it, or at least clean it up. But I might be a problem. But checkout bleachbit (next paragraph).

Bleachbit

Automatic cleaner. Will delete a lot of stuff, but for it was mostly locales.

$ pacman -S bleachbit
$ bleachbit -p system.*
Disk space to be recovered: 488.8MB
$ bleachbit -c system.*

You can look for more stuff to delete:

bleachbit --list
bleachbit -p thunderbird.*

Buying a new openwrt-compatible router. Howto

I need a new router, because the time machine I have been using for so long is finally giving up. It was a pretty strong machine. God bless her soul. Now I'd like to have something like this as a router:
solid run
https://www.solid-run.com/product/clearfog-pro/ But that's pricey and needlessly powerful, it costs extra to add wifi, box, power and so on.

OpenWRT

Since I found out OpenWRT exists I have continuously rooted my routers. OpenWrt is minimalistic linux made especially for routers. I don't like the fact that it's not a full-fledged linux - they had to minimize the footprint and some packages are incomplete/different. But it does its jobs perfectly.

There is a hardware compatibility list which now features devices with 1gb ram and 4gb flash. Unfortunately they either have no wifi, or not enough lan ports. Even the Bulgarian producer Olimex is featured close to the top.

Starting from top to bottom, here's how I chose my router:
(I skip all that have no wifi)

  • FLASH MB/RAM MB/NAME/Reasons
  • 256/1024/Gateworks Ventana GW5xxx/only two GbE ports;hard to buy
  • 16/128/EnGenius ECB1750/no GbE
  • 16/128/Belkin F9K1115/hard to buy
  • 32/128/WZR-HP-AG300H/no ac
  • 32/128/Meraki Z1/no ac
  • 16/128/EnGenius ECB1750/no GbE

Possibilities (all of them are available in local shops):
(all of them support some type of ac on 5Ghz)

  • FLASH MB/RAM MB/NAME/PRICE
  • 128/512/Linksys WRT1900AC/€235
  • 128/128/Cisco-Linksys EA6300/€106
  • 128/256/Buffalo WZR-600DHP2-EU/€100
  • 128/128/Netgear R6100/€100
  • 16/128/ZyXEL NBG6616/€85
  • 16/128/TP-LINK Archer C7/€98
  • 16/128/TP-LINK Archer C5/€75
  • 16/128/D-Link DIR-860L/€53

In the table I didn't put CPU type and whether they have USB 2/3 ports.

Poor guy's monitor emulator

Some mainboards won't boot without an active graphics chip which in turn won't start without a monitor connected.

This hack works with 3 resistors (75 ohm (50-150 is fine), 0.25 watt (0.125-0.500 watt is fine)).


Putt them like this

vga_dummy_electronic_schema

Resources:

https://www.techpowerup.com/forums/threads/how-to-make-a-dummy-vga-dongle.86507/
http://www.geeks3d.com/20091230/vga-hack-how-to-make-a-vga-dummy-plug/
http://www.electronics-lab.com/how-to-make-a-vga-dummy-plug/

Modules in Java? Finally! (OpenJDK 9 Jigsaw, JSR376)

I did a talk on Jigsaw at BGOUG.

The talk is for a very important new feature in Java SE 9. Code named Jigsaw, this feature modularizes the Java SE platform.
The coolest thing I do at the talk is to create a custom JRE.

Of course the jug and jPrime were mentioned.

Code: https://bitbucket.org/stybz/jigsaw.sty/src/

Video:

Presentation:

[jug.bg] Speaking at Riga Dev Day

So I'll do a talk about Http/2.0 at Riga Dev Day Conference. I'll be there representing the jug.bg. I'm pretty psyched to check out Latvia.

My session is on the first day

speaking-at-rdd16-2

 

Update: my talk didn't go too well, because the technicians couldn't manage to connect my laptop to the projector - even though they asked about what kind of laptop I had. It took us 15 min, the it was flickering the whole time and that made me nervous and I overshot my time, because of wrong time on screen.

And to top it all of they recorded it and said it will go to youtube in a couple of months. 🙁

Not that it matters, but all my demos worked, kind of a Pyrrhic victory.

Update2: Riga is awesome and very beautiful.

IMG_6612 IMG_6616 IMG_6641

[jug.bg] "Everything you need to know about Java Classloaders" by Oleg Shelajev

IMG_6594

Today Oleg presented a very interesting session about how class loaders work. He even remotely loaded classes from images (I imagine steganography).

Oleg works for Zero Turnaround, the company behind jRebel. Code examples here. The presentation is here.

One of the most interesting sessions so far IMHO.

[jug.bg] Adopt OpenJDK is not for mere mortals

forbidden.duke

A bit of introduction - we as a jug (java user group) got more active at the end of 2013 in no small part thanks to Ivan. We managed to build openjdk, import it in 3 major IDEs (eclipse, intellij and netbeans) and contributed a Virtual Machine with buildable openjdk 9 (both in fedora and ubuntu) and organized a couple of events, we decided we were ready for the next part.

At the end of 2014 we started timidly to try to contribute in the Adopt OpenJDK program. Adopt OpenJDK allows everyone* to participate in building and writing the java platform itself (or at least that's how we understood it *back then*).

We knew that LJC (London Java Community - their most popular jug) heavily participated in the new Date/Time API and soujava (Brasil's most popular jug) also managed to include code in the OpenJDK. Elated by these guys' successes we decided we had enough free time and sheer energy to contribute to the OpenJDK and thus put ourselves on the OpenJDK map.

In December 2014 we asked for something to work on. Nobody answered.

We decided to work on a simple Throwable convenience method (JDK-5050783). We had a hackaton. We submitted our fix. We were given some feedback and we submitted another. And we were told not to play with grown up stuff. That was a bit discouraging. But we didn't give up.

In February 2015 we started working on jaxp warnings. We fixed 43 easy warnings and submitted a patch. Then we fixed more harder warnings and submitted another patch. The great Joe Darcy answered but unfortunately we got nowhere again. That sucks.

A bit before that (Dec 2014) jug.bg member Doychin Bonzhev found a bug in the NetworkInterface and submitted a solution. He even submitted to another mail-list. He got a response (saying it is reasonable solution) and answered, but that was it. Nothing AFAIK followed.

So that was it for us. We gave up. Probably we didn't know the right people, but I argue that shouldn't matter. From time to time we get mentioned as collaborators in the Adopt OpenJDK by our dear friend Mani. We don't feel like that at all.

* Now you understand why the asterisk, right?

[jug.bg] jProfessionals 2.0

Today was the second edition of the jProfessionals format we started 5 months ago.

IMG_6574

jProfessionals is a one-day free conf. Smaller than jPrime (our star yearly event).

In the first version we invited Koshuke Kawaguchi. (the creator of Jenkins CI).

 

Today the first presenter was Richard Warburton.

IMG_6573

The session was about java 8 lambdas and even though it started as a very introductory session it turned out to be quite interesting. We discussed currying, Optional and the elvis operator.

What I learned is that Optional with value types is going to be fast (all in stack, no heap). Elvis is going in another direction - just a simple !=null check. Optional is kind of an explicit contract (preferred despite the verbosity and the extra object).

 

The second speaker was Vlado Tsanev aka tsachev.

IMG_6575

He talked about Spring REST Docs. The talk was one big live demo. REST Docs is a way to document a rest api automatically by extracting the info from the tests - it creates cURL commands, headers, params as so called snippets, and it allows the use of a adoc files with links to the REST Docs snippets.

 

After a tasty lunch it was time for "The Seven Deadly Sins of Microservices" by Daniel Bryant.

IMG_6576

It was a soft session with a lot of links and cool ideas of what microservices are good for and what they are not. There was a discussion on where people fail mostly using them. Very interesting and engaging - I bookmarked a lot of books that I'm never going to read.

 

Doychin Bondzev talked about Firebird (an alternative to postgres) - free, has triggers and is embeddable with nice tools and binary backup that is fast enough on windows.

 

Richard Warburton was next with another session for the future of Generics which was really fun.

IMG_6577

I finally understood why enums are defined recursively (Enum<E extends Enum<E>>).

 

Next was a talk about Jenkins Builds with Docker Containers by Petar Velikov from e-card.bg.

IMG_6578

It was quite interesting especially the docker part (he even used dockviz).

 

Finally there were two lightning talks. Martin Toshev talked about RxJava and RxJS.

Another guy - Teodor Tunev talked about Activiti - a java BPM platform far better than jBPM in his words.

IMG_6578

 

Finally some beer was due.

IMG_6580

(has not arrived yet)