Catch up on stories from the past week (and beyond) at the Slashdot story archive


Forgot your password?
For the out-of-band Slashdot experience (mostly headlines), follow us on Twitter, or Facebook. ×

Comment: A script.. (Score 1) 210 210

#! /bin/bash

# stop on errors
set -e

scriptname=$(basename $0)

# lock it
exec 200>$pidfile
flock -n 200 || exit 1
echo $pid 1>&200

# Rest of code

RSYNC_OPTIONS="-ah --no-inc-recursive"


if [ -d "$MOST_RECENT" ]; then
if [ -f "$SRC/.snapshots-filter" ]; then
    FILTER="--filter='merge .snapshots-filter"

CMD="$RSYNC $RSYNC_OPTIONS $FILTER --exclude=.git --exclude=.snapshots $LINK_DEST \"$SRC/\" \"$SNAPSHOTS/.temp/\""

mkdir -p "$SNAPSHOTS/.temp"
eval $CMD
touch "$SNAPSHOTS/.temp"

function moveBackup {
    if [ -d "$1" ]; then
        if [ $(((`date +%s` - `stat --format %Y "$1"`) / 60)) -ge $4 ]; then
            if [ -d "$2" ]; then
                if [ ! -d "$3" ]; then
                    mv "$2" "$3"
                    rm -rf "$2"
            mv "$1" "$2"

moveBackup "$SNAPSHOTS/around 3 months ago" "$SNAPSHOTS/around 6 months ago" "$SNAPSHOTS/around 9 months ago" 259110
moveBackup "$SNAPSHOTS/around 1 month ago" "$SNAPSHOTS/around 2 months ago" "$SNAPSHOTS/around 3 months ago" 86310
moveBackup "$SNAPSHOTS/about 15 days ago" "$SNAPSHOTS/about 23 days ago" "$SNAPSHOTS/around 1 month ago" 33030
moveBackup "$SNAPSHOTS/about 7 days ago" "$SNAPSHOTS/about 11 days ago" "$SNAPSHOTS/about 15 days ago" 15750
moveBackup "$SNAPSHOTS/about 3 days ago" "$SNAPSHOTS/about 5 days ago" "$SNAPSHOTS/about 7 days ago" 7110
moveBackup "$SNAPSHOTS/24 hours ago" "$SNAPSHOTS/about 2 days ago" "$SNAPSHOTS/about 3 days ago" 2790
moveBackup "$SNAPSHOTS/8 hours ago" "$SNAPSHOTS/16 hours ago" "$SNAPSHOTS/24 hours ago" 870
moveBackup "$SNAPSHOTS/4 hours ago" "$SNAPSHOTS/6 hours ago" "$SNAPSHOTS/8 hours ago" 270
moveBackup "$SNAPSHOTS/2 hours ago" "$SNAPSHOTS/3 hours ago" "$SNAPSHOTS/4 hours ago" 90

if [ -d "$SNAPSHOTS/1 hour ago" ] ; then
                mv "$SNAPSHOTS/1 hour ago" "$SNAPSHOTS/2 hours ago"


chown --reference="$SRC" "$SNAPSHOTS"
chown --reference="$SRC" "$MOST_RECENT"

Comment: Re:That again? (Score 1) 382 382

That's because "import wheel" in Python means something different than the similarly written statement in Java.

In Java an import written like that imports only one specific class. In Python it means import everything defined in the wheel "package". You can do the same in Java: import wheel.*

That syntax however is frowned upon, as it makes it less explicit about what you are actually using, and more assumptions must be made to understand the code. Did that class come from "wheel" or did it come from "stoneage", "car", "steam" or "yarn" ?

Anyway, contact me again when a Python snippet can actually survive being send by email.

Comment: Re:It's not that great (Score 1) 414 414

The semi-colon's mean I can split up a long line of code in nicely lined up parts with just the enter key. Without them, I might be changing what the code does, or I'd need to fix all the parts and add somekind of continue operator.

The fact that those semi-colon's are there is one of those things that makes Java more readable. I don't have to guess that a line will be continued or not (see Javascript). Making it optional just serves to confuse future readers of the code - that's why Java makes these mandatory. You can leave them out, but then you're code means something else.

This and the fact that Java often only gives you one option to write something is exactly what makes the language so readable. Try explaining that though to the Scala / Groovy / Clojure / Hip++ crowd however... they seem convinced that the number of keystrokes it what dictates development speed... perhaps I should sell them Dvorak keyboards...

Comment: Re:must fail (Score 2) 298 298

It is good practice to throw exceptions for even fatal errors. What they've missed however is to add information to the exception about the error (the stuff you propose they should log).

Somewhere way up the call stack you have a catch all exception handler, which is responsible for logging the exception -- so it is not necesarilly the caller who logs this. If the caller cannot handle the exception, it should just leave it and let it bubble up.

This way there's no need to duplicate logging code in every small little function that can't handle certain inputs.

Comment: Re:It depends (Score 1) 486 486

So will the os fragment the string, when it comes up to an other systems reserved memory spot. Will it overwrite it (Buffer overflow), will it find a contiguous larger memory block and copy the data there

Wow, this may have been the case eons ago when MMU's didn't exist, but in a modern day OS, you get an address space that's all your own. Nobody else is using it, and real memory is simply mapped (usually in chunks of 4k or 8k) into your address space -- it can be fragmented all over the place, it will still look like one nice big chunk to your program.

OS Disk management: A lot of the same concerns that memory management has. However a bunch of small request is easier to find free space, then asking for a larger spot. So they may be more seek time

Most filesystems already work with a minimum of 4k chunks. I cast serious doubts on your claim that smaller chunks are easier to find, it would depend on the data structure used for tracking free space and whether the filesystem is reserving space for you by leaving gaps at your last write location.

Comment: Re:Java is not written like other languages (Score 1) 411 411

No, they don't.

The program language has to be suited for such tools. The better you can reason about a language the better these tools can be, and Java really nailed that one. That's why you can refactor large code bases with it and have some level of confidence that you didn't break something.

Comment: Re:How parallel does a Word Processor need to be? (Score 1) 449 449

Yes, and it re-rerenders all the pages as bitmaps at 400% zoom, scales them back down to get proper anti-aliased results, then compresses them with JPEG and stores them into main memory... ...or how about just recalculating the page that you need to display?

Parallel processing is not gonna solve stupidity.

Many people are unenthusiastic about their work.