/dev/blah

things i want to remember, things i want to share

Développeur Python et adepte Linux depuis 2005, Core développeur Kivy, passionné par beaucoup trop de choses.
Profil Github gpg signature bitcoin address

Install ubuntu desktop on software raid

written by tshirtman, on 5/4/14 1:55 PM.

Being a bit naive about raid systems, i had to look up a bit at how to reinstall my ubuntu system on a raid1 on my two new SSDs.

Googling reveal much confusion and not very up to date information, so i ended up learning a bit about mdadm and the installer.

So here are the simple^W steps i followed.

  1. boot on your live cd/usb, chose “try ubuntu without installing”

  2. when booted up, fire a terminal, and install mdadm

    sudo apt-get install mdadm
    
  3. if you already have your raid devices created, assemble them

    sudo mdadm --assemble /dev/md0
    

    (repeat and adjust for each device)

    If you, as me, though it was a good idea to have a swap raid device (raid0 :3), be sure to swapoff the two partitions before trying to assemble the device, for me it was:

    sudo swapoff /dev/sda2
    sudo swapoff /dev/sdb2
    sudo mdadm --assemble /dev/md1
    
  4. if you need to create the devices, use mdadm too

    sudo mdadm --create --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
    

    (repeat and adjust for each device, level 1 is mirroring)

  5. start the installer, at the partition step, select “do something else” and be careful that no partition used by a device is directly mounted (including swap ones, that are automatically mounted, use “no dot use this partition” on them, they should be switch type from “swap” to “linux-swap”).

  6. select your mdXpY and other partitions just like you would use /dev/sdXY partitions.

  7. don’t forget to select the correct boot device (grub install).

    Install should happen cleanly.

  8. After the install is complete, you still need to make your system, able to work with raid, as mdadm is not installed by default, it won’t boot currently, so when the install is complete, select “continue testing”, then chroot to the installed system.

    cd /media/ubuntu/*/
    sudo mount -o bind /proc proc
    sudo mount -o bind /sys sys
    sudo mount -o bind /dev dev
    sudo chroot .
    sudo apt-get install mdadm
    

    if you have issues with network, try to copy /etc/resolv.conf from the host system

    sudo cp /etc/resolv.conf etc/
    
  9. Still in the chroot, reinstall and update grub

    sudo grub-install /dev/sda
    sudo update-grub
    
  10. You can now leave the chroot and reboot to your new system.

    exit
    sudo reboot
    

And voilà! You should have a bootable software-raid ubuntu desktop install.

Now, really, this should be much simpler, i really don’t see any reason that the desktop install image doesn’t have the raid configuration options in the partition choices, and is not aware enought to fix all these little annoyances.

Tip me if you like this :)

Prepare for the Kivy contest #2

written by tshirtman, on 3/16/14 2:50 AM.

Developers, developers… rejoice!

kivy contest

The kivy project is organizing a second contest!

From the 15th of April, when the theme will be revealed, to the 15th of May, the final deadline, all the interested candidates will compete to produce the nicest application possible, once month to make the difference, and collect prices :).

Prizes will be announced before the beginning of the contest, the python software foundation kindly offered to sponsor the contest, if you are or know somebody interested in sponsoring the contest, please contact us at contest@kivy.org.

Tip me if you like this :)

Mails, moving from offlineimap to mbsync (isync)

written by tshirtman, on 3/12/14 1:39 AM.

I’ve been mostly happy with the mail setup i documented some time ago, but i never was fully convinced by offlineimap, it was often slow, sometime blocking, and felt a bit unreliable. Last time i went out looking for a replacement, there wasn’t much of them around, and although i had read a bit about mbsync, it didn’t seem nearly as commonly used as offlineimap, the voices praising it were few.

Discussing my issues with offlineimap at work the other day, i discovered that a co-worker had been using mbsync for his setup for years, and seemed to have zero issues with it. So i decided to give it a whirl.

I based my configuration on information found in the arch linux wiki which is often a very nice source of information, even for users of other distributions, especially for users of uncommonly used, nerdy, pieces of software. I directly pointed my configuration to my existing Maildir, and after a few runs (the first one seemed to chock a bit on the number of mails to sync), it went well and have been running very reliably since.

I’m not running it into a crontab yet, i’m just keeping a terminal next to the mutt one, with a simple script like:

while true;
do; sleep 10m
mbsync -a; date
done

Which allows me to see when was the last sync, and what actually happens during the sync. I must say i’m really happy i don’t have to go forward and code my own IMAP synchronization tool, that would probably have been a very pointy experience.

Tip me if you like this :)

What "Easy" means

written by tshirtman, on 3/7/14 1:08 AM.

As a techy, i often judge my abilities to do various things as an indication of my value. There is a problem with that, though, because for tasks of apparently similar complexities, there are some that i find extremely easy, and others that i struggle with.

An important difference between these task can be the time i spent struggling with them in the past, as well as how similar they are to others tasks i achieved. It’s easy to forget the price i paid to find them easy now. It was an investment of time and energy, if i was lucky, that investment was done willfully and by having fun, but not always.

But what it means is that just because i find a task easy, it doesn’t mean it’s easy for my co-workers or friends, even if i struggle with tasks which they do find easy, they aren’t better or worse than me (well, maybe they are, but it’s not that simple), they did different time investments, and so we can help each-other. And i should have as much understanding for their difficulties, that i hope they have of mine.

The idea behind this is that we all have a comfort zone, that we spent time digging, and it can be of different size, and of different depth. You can always dig at the same place, but chances are you’ll be limited in your movements, or you can dig all other the place, but chances are you won’t dig very deep, unless you spend all your time digging, but then you may grow tired of digging pretty fast. It’s important to have an habit of digging though, so you increase your comfort zone regularly, and make a lot of things easier for you, because that’s how you can really master things. Don’t worry, you won’t run out of places to dig.

So next time you find something hard, rejoice, you aren’t bad, you are just digging in a new place, out of your comfort zone, and you’ll conquer that space, if you want to.

Tip me if you like this :)

Kpritz

written by tshirtman, on 3/3/14 2:23 AM.

Just because it seemed not to hard, i spent the evening (actually about 2 hours) making a Spritz clone using kivy.

Code is a bit crude and all, but here it is for your enjoyment:

https://gist.github.com/9316552

Here is an apk if you want to actually try it.

Only flat text files are supported, opening the option window is a bit slow (because of ColorPickers), but it’s functionnal, progression is saved, all the options i though were needed are there, and it seems usable.

You can find a lot of free book in the .txt format over at project gutenberg.

Tip me if you like this :)

Firefly

written by tshirtman, on 2/26/14 1:35 AM.

Yeah, i like to be late at these things.

So i watched the sadly unique and incomplete Firefly season, in the past few weeks, finished yesterday. I had made the choice not to look too much into the culture around the show, and any information source about it, only choosing to watch it on the impact it seemed to have on a lot of persons in my demographics, that is: geeks.

And i have to say it was a really great experience, stopping very abruptly, sure, and all the fans have been, i’m sad it stopped in such an unfinished state, but at least i had the notion of this before even starting watching, the fact that it achieved such popularity despite such a harsh cutoff was part of what convinced to watch it in the first place (also, the fact that it wouldn’t take so much time to catchup was definitely a seller). The show is grandiose, attention to details and psychology of the characters is incredible, and each episode introduce very interesting narrative and aesthetic choices. Dialogs are really well written, and action is very well balanced with humor and drama.
It’s also self evident that a lot of plot elements have been opened and would have been explained a lot later in the show, that there was a lot of depth to explore in the long-story.

Anyway, i can only recommend it, be warned that you’ll be frustrated, but i believe its still worth it, what there is is not enough, but it’s too good to miss anyway.

Tip me if you like this :)

[book] What's property, Proudhon.

written by tshirtman, on 2/25/14 1:10 AM.

Some serious reading here, this book took the better part of my commuting time in the last few weeks, i really wanted to know what made this man so (in)famous, and i don’t regret giving it the time. The book published in two parts (memoirs), the second one addressing a lot of the critics that met the first one.

The book is entirely constructed as a demonstration that property, and specifically private property of production means, is false, in the sense that it creates contradictions, leading to injustice in societies that adopt it. Of course, such a proposition is bound to raise a few eyebrows, and the way Proudhon puts it, by very analytical deconstructions, certainly makes one feel there is a great danger here, if you think property is an important part of societies, or even, as a lot of people believe it (no judgment here), the one funding bloc of civilization. Proudhon is not proposing that everybody is free to dispose of everything, though, he goes a long way to make the distinction between possession, and property, and while he consider the latter false, the former is deemed right and very important for civilization. I’ll surely betray the author for trying to put it in a few words, but in short, you have possession of what you need to live and work, of what you produce, but you can’t possess what you don’t directly use. This distinction makes all profit not derived from one’s work, impossible, and in Proudhon’s view, justice possible.

To show the injustice of property, the two historical justifications for property are proven to be baseless, the first one being that the first person to declare something to be his property, and strong enough to hold it, can claim it as a property, is just a sanction of strength, and not a principle of justice of any kind, because it means that families will inherit different shares based on the share of their parents, and the number of their siblings (since the inheritance is not just for the first child anymore), and as the constitution makes everyone equal in rights, from birth, the birth can’t be the origin of different rights. The second source of property, work, is in no better position, because it’s self evident that a lot of exception would apply, the first one would be that it would only apply on any unclaimed property (building something in your neighbor’s garden won’t give you any right on it, you’ll rather have to pay for the destruction of your work), and secondly, when you cease to work, is the thing you worked on still your property? Proudhon’s claim that if no, then it’s possession, and if yes, then work gave you more than you earned, you only earned the benefit of your work, the better production it created, not the tool itself.

Proudhon also claims that his views are just a clarification from the views people really hold, although they are unable to understand it. He shows a lot of example where we don’t accept the principle of property as inherently inviolable, and that in the end, people just have to recognize that property is just a misconception of possession, which is the true principle we can accept.

It’s important to note that Proudhon is not a communist, he regrets that nobody came up yet with a system that doesn’t consist of either property or communality, the price of communism, a very rigid state making liberty impossible in his views, is too high to be considered a good alternative to property. His system would only share wealth among people producing what other people needs and are ready paying for, be it food or poetry, it seems pretty clear that there wouldn’t be much help for unproductive (by their peer’s definition) members of the society (considering that it’s the fact that property makes people wealthy not by their work, but by the work of others with their assets, so by not being productive themselves, that Proudhon’s disagree with, we can say it’s a coherent position). We can note that the mechanical limitation in accumulation of wealth in such a system would mean that wealth disparities would be much lower than todays standards (and they are much bigger than people usually think these days).

Proudhon also seem to be far from a revolutionary, he notes in a few places that his memoir is addressed to intellectuals, not to the common man, and that nobody wants to see the reaction such a thing would cause, especially in hard economic times. He calls for a deep change in legislation, before change comes up in a disastrous way, going as far as saying “saying that only an overthrow can bring reform, is, for me, doing a syllogism, and looking for truth in the unknown”, in other words, revolution is a gamble you don’t want to make.

This book was also interesting because of the expressed views on history, being written in the 1830′s, a mere 40 years after the French revolution, yet in a way more modern time (XIXth century) than this period. Of course, Proudhon being very radical in his views, it will make sense to seek other opinions on the persons and ideas discussed here, but it’s very interesting nonetheless.
The XIXth century was a high time of intellectual reflection and discussions, a lot of systems being proposed and tried, science was tentatively applied to government systems, with of course, varying success.

On the other hand, it’s interesting to see that Proudhon hold some very conservatives opinions, regarding women, for example, of course, they are symptomatic of his time, but he notes his disapproval of the early feminist movements, considering that women are simply not built to hold the same qualities as men.

On the literary side, i appreciated the style in a lot of places, but some parts where lengthy and a bit unexciting, the lack of structure (it looks like a 250 pages rambling followed by another 150 pages rambling) and the terse style, although often enjoyable, made me feel like i was crossing a desert more than a few times, maybe that’s also why i need to get back into the habit of reading :).

Closing up, i think i got out of the book with a deeper understanding of the intricacies of rights and property, of the difficulties of making equality and justice happen without limiting liberty too much. And it gave me motivation to read other books of the same kind, that is, theoretical studies on societies and socialism.

Tip me if you like this :)

Monitoring your git status.

written by tshirtman, on 2/20/14 1:58 AM.

It’s not uncommon to query various git commands to know your current state in your repository, before doing the commands that do actual things.

To avoid doing some of them needlessly, or missing important information, it’s a common solution to customize a shell prompt to add the most important information in it.

However, that’s usually quite limited, and when developing on a project, or doing some refactoring or even rebasing, you’ll often do the same commands over and over.

Doing something over and over is bad, it makes you tired and mistake prone, and computers are good at doing repeated actions for you, so you just know to know the right tools.

The watch linux command allow to execute a command every nth second (n being 2 by default), so you can let that run in a shell next to the one you work in.

A first step then is:

watch git status --short

not very advanced, but actually helpful, however, there is a few over commands you’ll want to see, for example, the existing branches and the one you are on, the git log is cool too, and git reflog, being one of my favorites.

watch "git status --short && git branch && git log --graph --oneline && git reflog"

It’s nice to see on what commit a branch is, too, so let’s add that to the branch command.

watch "git status --short && git branch -v&& git log --graph --oneline && git reflog"

We have a problem, though, log and reflog will usually be way longer than our terminal can afford, and you’ll not see reflog at all.

watch "git status --short && git branch -v&& git log --graph --oneline | head -n 10 && git reflog"

(it’s actually not needed to cut the tail of reflog, as it’s the last command)

But all of this is a bit lacking in colors, lets add them!

watch can allow colors to be used, but we still have to force git to show
them. To avoid things getting to messy, we’ll define a few git aliases:

git config --global alias.cstatus "-c color.status=always status --short"
git config --global alias.bc "branch --color -v"
git config --global alias.ll "log --graph --pretty=format:"%C(yellow)%h %C(blue)%ci%C(green) %an %C(red)%d %Creset%s"

then our watch command can be

watch -c "git cstatus && git bc && git ll | head -n 10 && git reflog --color"

This is starting to look good, but there is some need of a separation between the various commands, i found it best to simply leave an empty line.

watch -c "git cstatus && echo &&git bc &&echo && git ll | head -n 10 &&echo && git reflog --color"

There is still one ugly detail though, and that’s the header produced by the watch command, thanksfully, it can be easily discarded using the -t option:

watch -ct "git cstatus && echo &&git bc &&echo && git ll | head -n 10 &&echo && git reflog --color"

The result is probably that you want to add a few things to .gitignore, delete a few branches hanging around for no reasons, and slap people doing too long commit titles :P. Which is probably a good task for the forthcoming spring :).

Bonus points if you use a tiling windows manager, and can give this a chunk of the side of your screen ;).

Tip me if you like this :)

Using tex_coords in kivy for fun and profit

written by tshirtman, on 2/19/14 1:45 AM.

Your gpu is an awesome thing, it can do all kind of calculations, very fast. For example, instead of telling it exactly how you want each pixels to be, you can throw textures and vertices at it, and have it correctly deduce how this things will have to look.

To do this, though, you must tell it what part of the texture will be stuck to each vertice. This is usually denoted using texture coordinates.

Texture coordinates, like usual coordinates, indicate the place of something. Instead of noting them x and y, they are often called u and v, which allows to clearly note what parts of an equation relate to each.

While kivy offers you high level canvas instructions, it gives you a pretty good access to lower level features, and you can actually manipulate the texture coordinates of your Rectangle instructions. This allow for cheap zooming, repeat-scrolling, and other image manipulations, since your gpu is doing all the actual work.

tex_coords = u, v, u + w, v, u + w, v + h, u, v + h

which is better understood as:

tex_coords = [
    u,     v,
    u + w, v,
    u + w, v + h,
    u,     v + h
]

considering a default tex_coords value, where u and v = 0, and w and h = 1 (all values are relatives, so usually between 0 and 1).

u, v + h-------u + w, v + h
|              |
u, v-----------u + w, v

which means the 4 angles of your texture, will be on the 4 angles of your rectangle, how dull!

One way to play with different values, is to create a little app showing you the effect of deformations.

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.widget import Widget
from kivy.properties import ObjectProperty, ListProperty
from kivy.core.image import Image as CoreImage

kv = '''
#:import chain itertools.chain
RootWidget:
    canvas:
        Color:
            rgba: 1, 1, 1, 1
        Rectangle:
            pos: root.pos
            size: root.size
            texture: app.texture
            # here is our usage of the calculated texture coordinates
            # we devide by 100 because we took the input with a 100x100
            # rectangle as default value
            tex_coords: [x / 100. for x in chain(*root.points)]

        PushMatrix
        # translate the rectangle to make it easier to play with
        Translate:
            xy: root.width / 2, root.height / 2

        Color:
            rgba: 1, 0, 0, .5
        Line:
            points: chain(*root.points + root.points[:1])
            width: 2
        PopMatrix
'''


def dist(point, pos):
    return ((point[0] - pos[0]) ** 2 + (point[1] - pos[1]) ** 2)
    # ** .5 # who cares about square root here? it doesn't change the order


class RootWidget(Widget):
    # the default values, a 100x100 square, displayed around the middle of the screen
    points = ListProperty([[0, 0], [100, 0], [100, 100], [0, 100]])

    def on_touch_down(self, touch, *args):
        # compensate the translation done in canvas
        pos = touch.pos[0] - self.width / 2, touch.pos[1] - self.height / 2

        touch.ud['point'] = min(
            range(4), key=lambda x: dist(self.points[x], pos))

    def on_touch_move(self, touch, *args):
        # compensate the translation done in canvas
        pos = touch.pos[0] - self.width / 2, touch.pos[1] - self.height / 2
        # update the point
        self.points[touch.ud['point']] = pos


class TexCoordsApp(App):
    texture = ObjectProperty(None)

    def build(self):
        self.root = Builder.load_string(kv)
        self.texture = CoreImage.load(
            'GrassGreenTexture0002.jpg').texture
        self.texture.wrap = 'repeat'
        return self.root


if __name__ == '__main__':
    TexCoordsApp().run()

The texture have been scrapped on the web and is not very interesting, but you can find it here.

Of course, this is much more a learning device (helful because these transformation are not quite straighforward for our brains) than a practical application, but a lot more can be done.

Here is, for example, a little infinite scroll app uting this concept.

edit: Ben Rousch kindly created apks out of the two examples, if you want to try them on android: TexCoordsExample ScrollExample

Tip me if you like this :)

Switching to i3wm

written by tshirtman, on 2/17/14 12:15 AM.

I’ve been a wmii user for more or less 5 years, and until now although it was not much maintained anymore, i was unable to replace it with something else.

Last time i checked, neither awesome, i3, xmonad, or either of the few tiling WMs i tried, seemed to fulfill my needs, i wanted dynamic tagging of workspace, full keyboard navigation, and the same tag on all screen in a multiscreen setup (more on that later). So, although it had a few bugs, i decided that wmii was still the best thing out there.

Recently, hobbestigrou suggested me having a look at qtile, being in python, it would be easy to script and adapt to my use case.

I did look into it yesterday, and spent some time configure it for my use. In the end, i had most things working, although i wasn’t crazy about the window placement capabilities, and using the doc hadn’t been a thrilling experience.
The last standing point however was, the separate tag management per screen, but, at that point i was ready to give that a chance, considering i often pinned a window to all workspaces on the second screen (but not all the time).
So i decided to give a second chance to i3wm, considering it’s the spiritual successor of wmii, i may be more excited at the window placements.

And while it took me some time to wrap my head about the tree system of i3 (the split shortcut (Meta4+v) turned out to be quite important), i have to admit it solves all the limitation of wmii’s one, while avoiding the limitations of layout systems of other tiling managers.

Now, i3 doesn’t expose a dynamic tagging system out of the box, but it offers a nice cli api, and i found a blog post offering a good explanation on how to use it, i adapted it to make it slightly faster, but the idea stands.

I’m still a bit confined by the inability to share tags across screens, i gave myself a way to move a window/container from one screen, but it’s still a bit different. I won’t try to force i3 to see only one screen, as i did on my first try, because that caused all sorts of swampy issues, and it’s clearly not the way it’s meant to be used.

Other than that, it’s pleasing to see all the nice improvement of the window manager over its ancestor, it’s certainly way more pleasing to look at, and to configure.

Anyway, my configuration is now on github, for my own profit (easier to setup on multiple machines), and for the curiosity of others :).

Tip me if you like this :)

Tags

#FIXME 3G absurd ad_sense alterway aléatoire android animation anonymity atheism bach backlog bash bitcoins blog blogging boldness book books boulot bricolage bépo C canvas captcha captures carte SD censure christianity chroot CLI cli cloudwatt code colors comfort zone command line community company life conferences contest copwatch copwatchnord-idf core-devs cours ct705 culture deb debian debug deformation dehors dessin dev distribute distribution débutant déploiement développement ebooks eeepad eeepc effect ego empty en escher event firefly flappy bird flask fosdem foss fr fun game garden gdb geek culture git github goals graphics grrr gödel hack hackathon hacked hacking health hooks i3 images IMAP inspirational install isync java jeu jeu video jinja2 jni keyboard keynav kivy kv lame learning lib libre life linux lol macosx magnet mail mailing-list mails maths mbsync meetings memory leak mesh meta mint mirroir MIT module motivational mouse museomix mutt nexus7 no-mouse notmuch nottoomuch offlineimap onycroit opencourseware osc packaging paris passphrase password patch pentacatyl people perte de données ping pip planning plugin positioning pr procrastination programmation progress project projet property proudhon proxy psf publisher/consumer pull-down pygame pyjnius pypi python pythonar qtile raid rapsberry pi reading recorder references release religion responsive review reviews réseau réseaux sociaux résurection salon screenshots script self service shows shutil shyness sizing solib sortie sousous!!! spam spritz stash status systeme système templating terminal texture texture coordinates Thomas Paine thread thème tiling time time management. tip tips tools transformer tutorial tv twitter typematrix typing ubuntu ubuntu-fr ultimate-smash-friends unity update upload images useless usf utils value VDM video vie/mort vim virtualenv visite widget windows wm wmii work workflow workflow. zine études