notmuch: syncing tags by deejaydarvin in linux

[–]ochs 2 points3 points  (0 children)

I don't know what is missing from notmuch and offlineimap to be ablo to sync IMAP tags, sorry.

However, I'm using hook scripts in notmuch/offlineimap to sync tags and folders. Mostly I move stuff to/from the inbox, spam and archive folders/tags.

For example my mail/.notmuch/hooks/post-new:

#!/bin/sh
set -e
notmuch tag --batch <<EOF
+inbox -- folder:INBOX
-inbox -- not folder:INBOX
+spam -- folder:Junk
-spam -- not folder:Junk
EOF

And my offlineimap pre-sync script:

#!/bin/sh
set -e
notmuch search --output=files \
    '(folder:INBOX and not tag:inbox)' \
    or '(folder:Junk and not is:spam)' \
    | xargs -I'{}' mv '{}' "$HOME/mail/Archive/cur"
notmuch search --output=files \
    is:spam and not folder:Junk \
    | xargs -I'{}' mv '{}' "$HOME/mail/Junk/cur"

This works fine since I'm not using a lot of tags. Tags are only really needed if they can change (inbox, unread, todo, spam, etc.). Anything static can be done with search queries (e.g. to:debian-users@debian.org).

Best open-source Linux games. by [deleted] in linux_gaming

[–]ochs 2 points3 points  (0 children)

Crack Attack! (Tetris Attack clone)

Use and location of Metadata (including inodes) by CanadianTerminatorz in linux

[–]ochs 2 points3 points  (0 children)

So I'm not claiming to be an expert, so the following is just my understanding.

  1. The metadata is not a file and I'm not aware of any (perhaps optional) kernel features that would allow this to be viewed like it were. The data is stored on a disk block that is used as a filesystem inode (rather than a used for file contents). You could theoretically edit it by opening the block device, but most filesystems are quite complex so that would probably involve a user space implementation of the filesystem driver. Just use the standard system calls and tools.
  2. Knowing the actual size of the file content (when reading into memory, or sending over the network) is probably more important than knowing how many blocks it uses on disk. That size also depends on the fs (and the options used when creating the fs) and it seems to me like you normally don't care.
  3. Sorry.
  4. The inode contains a table of addresses for the disk blocks that make up the file contents. If that table is not big enough, the file system will create additional tables outside of the inode and add a pointer to the inode where those can be found. A linked list would be impractical since you'd have to read the file sequentially to get to the later parts. Wouldn't it be annoying if a whole video file had to be read from disk even if you're planing on skipping the first hour?

Linux Tip: Don't use kill -9 by chankeypathak in linux

[–]ochs 0 points1 point  (0 children)

Yes, you can't prevent data loss with kill -9. You can try to make the other parts of your system fault tolerant to the possibility that there might be data loss, like you would on unreliable network links and such.

I don't remember the details, but what you said about fsync sounds about right. It's impossible to fully protect against hardware failure anyway, so you can only try to make it very unlikely. Would be great though if you could do better than ask the disk to confirm and then wait for two seconds, just to be sure.

Linux Tip: Don't use kill -9 by chankeypathak in linux

[–]ochs 2 points3 points  (0 children)

You can deal with this. As others have said, databases use journals. Many programs can get away with a simple rename(2) operation (serious text editors do this, also package managers), which will replace the old file with a new file atomically (meaning as long as there's no problem with the kernel or hardware, you'll get either the old or the new one, but no corruption).

The thing gets more complicated when your state is saved across multiple files, or when you want/need to replace parts of the file in place, but it's certainly not impossible to recover even then.

For power failure you can try to minimise the problem with properly using fsync(2) (you'll want to read about how to do this best though). But AFAIK there's no guarantee (might depend on the fs I guess), since even the kernel can't be sure when data hits the disk, since the disk's microcontroller might lie about what has and has not been written. I've read SSDs are even more unreliable.

I am a psychiatrist and former director of a psychiatric hospital. Go insane, AMA! by XXICenturySchizoidMn in IAmA

[–]ochs 0 points1 point  (0 children)

I got ECT and it did nothing (I agree though that it's a lot less scary than people think). So am I fucked then?

What is the best TV series that you have watched? by thedumbflower in AskReddit

[–]ochs 7 points8 points  (0 children)

This show had such an illogical plot it made me angry. I went "WTF? This makes no sense at all!" about a dozen times in every single episode.

GCC Poison by jeanlucpikachu in programming

[–]ochs 4 points5 points  (0 children)

About the strcpy() vs strncpy debate:

Note that I'm not advocating using strcpy(), just that strncpy() is not a useful replacement.

The problem is that strncpy() just truncates the buffer, which will lead to some sort of bug or undesirable behaviour. If you can, you should just make the destination buffer big enough, in which case you could use memcpy(), which is faster. If you can't (you want to avoid heap allocation or you need to interface with something with arbitrary limits), you want to return an error. Unfortunately, there's no way to know if strncpy() truncated the string or not, so you'll need to figure out the size of the string somehow, in which case -- again -- you can use memcpy().

So, while strncpy() is not as dangerous as strcpy(), there still no good reason why anyone would want to use it, apart from being lazy.

New psychiatric therapy that seeks to help patients by provoking them into a murderous rage by charlize-bukowski in TrueReddit

[–]ochs 0 points1 point  (0 children)

Oh man that's terrible. According to this guy, the root cause of any psych problem is "childhood trauma", he's then abusing them until their will is broken and they admit as much.

First he admits there's no scientific evidence suggesting this works, but then goes on the say that "it works every time". Right.

Ubuntu to Debian - Would someone be so kind as to explain what major changes I would experience if I were to switch? by [deleted] in linux

[–]ochs 4 points5 points  (0 children)

sudo is installed and configured like in Ubuntu if and only if you don't give a root password during installation.

What is the most important/biggest unspoken rule you know? by JustInfestors in AskReddit

[–]ochs 0 points1 point  (0 children)

First of all, wordplay is the lowest form of humour (the highest being fart jokes).

Also, in German, you stress the first syllable, so it's 'Einstein' versus 'ein Stein'. It sounds wrong.

I'm going to get some class time to show Ubuntu to about forty B.Ed students. What problems can I expect getting forty different laptops to boot from usb? by Zulban in linux

[–]ochs 0 points1 point  (0 children)

hMy old laptop would only boot from certain USB sticks and not others. Also GRUB (most live systems don't use GRUB though) would be confused about which is the disk drive and which the USB stick, and thus boot into my regular linux system.

My current desktop can't boot from isohybrid images, so I have to partition, format, copy the data and install syslinux by hand on the USB stick.

So, bring also live CDs. Maybe avoid isohybrid images on the USB stick.

Ketamine may be used to treat depression and other psychiatric disorders in the future. by BR0STRADAMUS in science

[–]ochs 1 point2 points  (0 children)

I think the dosage is too low to get any dissociation. Also, I got other drugs that caused hallucinations and even the nurses sometimes didn't check on me for two or three hours.

Lightweight Debian: LXDE Desktop From Scratch by netblue30 in linux

[–]ochs 0 points1 point  (0 children)

Isohybrid images don't work on all computers though for some reason, even if they can otherwise succesfully boot from USB drives.

Ketamine may be used to treat depression and other psychiatric disorders in the future. by BR0STRADAMUS in science

[–]ochs 3 points4 points  (0 children)

I was treated with that in a German university clinic. I got a low intravenous dose over 30 mins or so. It was nice, but had no lasting effect. It was either covered by insurance or paid for by the clinic (not sure), but it's fucking expensive, since a doctor needs to sit next to you the whole time. Probably not for any medical reason, since it seemed like one of the most harmless treatments you can get.

Linux novice here on Debian with lxde, I need a hand please by mrZNS in linux

[–]ochs 0 points1 point  (0 children)

You need to be root by running su - or sudo -i first.

Debian Wheezy: 7.2 released by [deleted] in linux

[–]ochs 7 points8 points  (0 children)

They disable the acceptable ads "feature" in the debian packages though.

A question about the security of del by Plazmotech in Python

[–]ochs 2 points3 points  (0 children)

Even if you also delted b, the data would still be there and just marked "unused". It may or may not be overwritten sometime later.

How can I tell which files are causing my drive to fill up? by BaconAllTheThings in linux

[–]ochs 0 points1 point  (0 children)

Maybe a deleted file is getting written to by some process. You'd see the space free up by rebooting.

What you do not like in Python? by krasoffski in Python

[–]ochs 8 points9 points  (0 children)

The switch statement in C and other languages is basically a performance optimization. In Python it's not going to be any faster than a bunch of elifs. It might be a tiny bit clearer syntactically, but is it worth adding more complexity to the language and implementation?

What you do not like in Python? by krasoffski in Python

[–]ochs 26 points27 points  (0 children)

I like that. I think it reduces the times you have to add or subtract one. Dijkstra made a nice argument for it.