samedi 17 octobre 2015

dynamic language refactoring

I forked a project on github. ~1000 lines of python, single file of course. I can't bear reading this kind of code, so I devised to refactor it.

I don't have a battle tested method. Of course I have some ideas, isolate functional dependencies, scopes. Gradually eliminating global variables. The issue is I did it on the fly, without a clear plan, a `framework`. Now 2 weeks in, 70% of the code base is cleanly modular now, the code run, but I saw some regressions, nothing major but still, I haven't the slightest idea of how many and how large the regressions are. That brings me back to the framework thing. Refactoring isn't an object, I understand it, it's a craft. The first idea is of course surrounding the code base with regression tests. The original project had none, no tests at all. And I only learned unit testing on OOP, not on black boxes / god module. What else can one do ? how to make the migration as logical, documented and predicatble as possible ?

smallest possible working commit

When coding I often have to fight my urges to change existing code too much. New way to write a function, decouple big into small ones, reorder them, rename variables, etc etc[1]. This is the artsy part of my brain trying to express ... but it's counter productive. I need another dogma, another fetish. Recently I landed on the idea of challenging myself to make the smallest possible set of changes to a piece of code in order to fix an issue. That includes not even fixing loose formatting. Anything that isn't directly and strictly necessary to resolve the problem shouldn't be done. yet.

Ergonomic and aesthetic modifications will be done in a following commit.

As mentioned in [2], Single responsibility principle applies here to.

[1] Or even working on many changes at once.

jeudi 8 octobre 2015

parallella headless ubuntu image default credentials

In case you're too impatient to search for them after downloading the OS image from here

The credentials are: parallella/parallella (listed on step 5 tab

dimanche 10 août 2014

Not so shallow changes - archlinux 64bits / c2d / ssd / wmii / fish

From firesales I got a cheap 80GB intel SSD. Put it in my ThinkPad X60s and basically saw jesus and allah doing the funky chicken. Everybody says it, but until you see it, you will underestimate the impact of a ~no latency disk drive. That old core duo suddenly boots in 5 seconds top. BIOS, Grub, two lcd blinks, and then desktop.

A few weeks later, actively procrastinating, I want to fix the laptop status LED at the bottom of the LCD. I found out it was probably the LCD cable, which doubles as LED driver, that might be partially failing. Having a x61 with a bricked motherboard on a shelf, I want to see if I can leverage its LCD cable, in the case it's compatible, which I don't know.

Reaching for this cable costs time since it requires to disassemble almost everything, but I'm going for it. I start with the x61 LCD block. Then remove the keyboard on my x60s to access the LCD cable socket on the motherboard. At that point I'm only testing compatibility on this side of the cable. I boot the x60s and the LCD works fine (it's badly shattered on 30% of the surface, but the panel is ok everywhere else, so I'm able to see the BIOS splash screen). #cool

Now I have to dismantle the panel from the lid etc etc, on both laptops. Only when everything is in pieces I realize, the cables are electrically compatible, meaning both sides are the same sockets and wires. But. But... the LCD panels are build upside down. One has the controller circuit at the bottom, the other at the top. The cables are built specifically for one kind, no way to stretch or fold it back, it's too short. #fail

Time to rollback. I rewire the old panel, ~difficultly. Plug cables and power supply, not the case screws since time taught me to screw things only after testing. No backlight on the LCD. I can see shades meaning pixels are drawn but no light. I unplugged the inverter cable a bit (with free scary static noise) while installing it in the lid. Easy to fix. 2nd boot, now the backlight works fine, so fine I can see a ~10pixel wide black band in the middle. It's regular and small so I try to poke around to see if the cable is not seated properly. No luck. I discover that below the LCD are running to very thin, very dense cables called 'tab bonds' which are the final panel data feeders. Indeed, fiddling with them fix the fringe of the black band, but it's not stable.

some links:

The laptop works fine but that weird strip is too distracting. And that laptop was a little too slow, and 1.5GB of RAM too short. I have that other x61 c2d/4GB lying around. Let's retire the x60s, even though I love this little crippled bastard, he took everything I through at him. #soldier.

I plug the ssd in the x61, boot my old 32bit system. But I wanna try 64bit, because I don't like only having access to 3GB when there are 4. Also I noticed that software behaved a little differently in 64bit, so I format / reinstall everything.

To try things early I dont install xmonad/haskell, only wmii. It's a very small and ~limited window manager. But I realize it does what xmonad did, and the basic paradigm of stacked window titles is very easy on my mind. Much easier than the 2d split of xmonad (surely xmonad can emulate wmii but I'm not in the mood for writing haskell #noob).

So that's a first. I'm not missing xmonad in the slightest for my usage.

I also tried fish. I may not program in it, but it's light and ergonomically heaven compared to bash and even zsh.

Final note:

  • arch
  • base-devel (gcc, make...)
  • python3, guile ...
  • emacs
  • chromium
  • alsa, cmus, mpv
2.5GB (including pacman and chromium caches, so more ~2GB).

Pretty slick.

vendredi 7 mars 2014

taking notes aka compiler targetting your brain ISA

learning better by correlating one domain to another. idea into graphemes. idea into actions, into spoken words, shapes.

remember taking notes in high school. The more I paid attention to formatting the better I learned. First I pruned the content. Similar to the original meaning of lecture, I sorted and picked words differently. IIRC it was mostly based about the "newness" of a subpart of the concept discussed. The less I understand it, the more carefull I'll be when writing it down, the more space I'll allocate to this part. It's a differential overlay of my brain. The format was important too, even though I despise the term format for it's superficial conotation, it is a reflection of relationships between ideas. Most of the time it's nested (up down dimension). But there's also aside dimensions which made me use colors to denote comments or any kind of lateral relationship. In the end it looked like the handwritten projection of a DAG into a yaml/xml structure. Maybe the term ontology would fit.

dimanche 2 mars 2014

xargs, map and gnu parallel -- async

Fed up with `xargs` syntax, I googled for rants about it being a poor `map` function, and found ... `map`: Someone wrote a lighter non parallel `gnu parallel` and called it map.

Redditors didn't think it was important and mentioned gnu parallel being better so I reinstalled it. My first attempt a few years ago didn't go very well. Since I gained the ability to RTFM. So I can do some basic stuff. And I also read some blog article ... Weak me.

Here's a small test reminding me of talks about golang, async, concurrency etc :

$ time parallel -j12 ping -c1 ::: DOMAINS &> par

real    0m11.023s
user    0m0.563s
sys     0m0.110s

$ time for dom in DOMAINS; do ping -c1 "${dom}" ; done &> seq

real    1m1.509s
user    0m0.013s
sys     0m0.027s

DOMAINS is {google,amazon,microsoft,yahoo,bing}.{com,fr,}


ps: someone suggested me these too
  - parallel tutorial
  - parallel man #example(s)

lundi 17 février 2014

Using pyvenv and pip under python 3.3 -- article list

Just a quick gathering