ed2k hash using ruby

I’ve created ed2k hashing implementation using ruby. It’s not too slow and only use core library (openssl).

def file_ed2k(file_name, output_mode = "hash")
  ed2k_block = 9500*1024 #ed2k block size is 9500 KiB
  ed2k_hash = ""
  file = File.open(file_name, 'rb')
  file_size = file.stat.size #while at it, fetch the size of the file
  while (block = file.read(ed2k_block)) do
    ed2k_hash < < OpenSSL::Digest::MD4.digest(block) #hashes are concatenated md4 per block size for ed2k hash
  end
  ed2k_hash << OpenSSL::Digest::MD4.digest("") if file_size % ed2k_block == 0 #on size of modulo block size, append another md4 hash of a blank string
  file.close
  ed2k_hash = OpenSSL::Digest::MD4.hexdigest(ed2k_hash) #finally
  return case output_mode #there are 2 modes, just the has, or complete with link.
    when "hash"
      ed2k_hash
    when "link"
      "ed2k://|file|#{File.basename(file_name)}|#{file_size}|#{ed2k_hash}|"
    end
end

You can then call the file_ed2k method (or whatever you name it) to calculate a file’s ed2k hash. ed2k link generation was created to reduce amount of IO involved when reading the file(s).

ef complete translation by nnl!

Yes it’s out! As mentioned in their website, there are two parts: installer file and data file. Installer file itself is available as DDL linked in their website and its data file is available on torrent and xdcc somewhere.

As I was the one pointed/arranged folks at [Commie] to provide the xdcc, aside the official(?) nnl channel on irchighway, it’s also available on Commie channel at Rizon.

File data (as of released 1 May 2010):

  • installer:
    • filename: ef_Lite_Installer_[nnl].exe
    • filesize: 5737984 bytes (5.74 MB / 5.47 MiB)
    • md5: 04e0304bc2efbc3f298af188f1a4fb46
    • sha256: 4945c1563d743284853f87619a0b5a5a2a8ef2ae602198083ecfd7398afc3703
  • data file:
    • filename: ef_Lite_Data_[nnl].cnd
    • filesize: 2315609468 bytes (2.32 GB / 2.17 GiB)
    • md5: d6a9ab3fc37ec715f8169990514b1e66
    • sha256: 6a20bb48a4787144e0f83ea4ca3ad397aece5380f5c09d9b85d8d9a716468ef6

(information as of today, may become irrelevant after several days/months/years)

XDCC:

[ nnl | Installer | Data file torrent ]

(yes, this post is another experiment to get free traffic, lololol)

(derp, WordPress broke my link. No wonder no one clicked on the torrent)

Magic Kaito – “Finally arrived!” edition

Magic Kaito – Originally published in 1988, making occasional appearances in its successor – and also haven’t actually finished thanks to being put on hold (counting at 4 volumes) – finally adapted into anime.

Unlike its pretentious (borrowing word from certain group(s) out there) successor, it mainly focuses at comedy side. The first episode followed quite closely with first chapters of the manga. I don’t know how long it’ll be though.

Simple tips when writing scripts

Be it bash, tcsh, perl, ruby, python, etc script, here’s my one simple tips for you:

  • Do not use direct path to the program path in the script’s shebang line – use /usr/bin/env <program> instead.

It’s foolish to assume that everyone have bash in /bin/bash (and it’s even worse if you assumed /bin/sh = bash and recent version of bash will fallback to POSIX feature subset when executed using /bin/sh). And it doesn’t make sense to assume every single perl/ruby/python/etc main binary is in /usr/bin/{perl,ruby,python}.

Instead of doing that, just use /usr/bin/env to let the shell decide where to find specified program. For example if you’re writing bash script, put

#!/usr/bin/env bash

.

This will ensure [1] no one will went RAGE when using your script. I know I did when seeing such scripts. Or as previously stated, #!/bin/sh as the shebang and somewhere in the script it uses [[. Totally (un)funny.

[1] Basically /usr/bin/env will execute the script using program specified in its argument based on PATH specified in the environment variable. It doesn’t matter where the actual binary is located as long it’s in the PATH.

Kaichou wa Meido-sama ep 1

I rarely watch shoujo anime but I think this one doesn’t feel too shoujo-ish. Looks like J.C.Staff tried to make this anime more gender-neutral.

Read more information about this series here. Be careful though – its character section contains some spoiler.

It’s got some light jokes here and there (well, one of its genre is romantic comedy) which I think well executed – at least for first episode.

Its basic premise is simple – a strict, valedictorian but poor student council president works at a maid cafe which then found by a boy which happen to have enough lulz. Hilarity ensues, etc.

The good thing about shoujo series is that the main hero (?) is actually likable unlike some generic eroge-turned-anime shit.

It is also relatively guilt-free (as opposed to B Gata H Kei) and wtf-free (o hai Heroman) and J.C.Staff should be able to produce something relatively amusing…

If you’re looking for light, general comedy for this season, then check either Working!! or this. 😀

Random craps

  • Sometime last week the default color scheme for WordPress’ Dashboard (3.0-alpha) was changed – it is now lighter at least the header part. For example check this blog’s login page.
  • TWGOK / The World God Only Knows / Kami Nomi zo Shiru Sekai is getting anime adaptation. And yes, I also agree that Jun Fukuyama would be perfect fit to be Keima’s VA. In case you’re living under rock, it’s a manga about a galge otaku given task to “capture” “runaway-spirit”-infested real-life girls. No more information currently available as of the time of this post.
  • Some more anime (sequels/new titles) announcements were made and you can check them either in moetron, ANN or Canned Dogs.
  • Latest WordPress requires more memory than ever. I can’t even upload a 1000×1000-something image because of memory exhaustion.

Working!! episode 1

I think this is the first time I see a pre-airing which has relatively good quality.

Working!! – yet another manga adaptation and yet another slice of life comedy anime animated by A-1 which did Sora no Woto in previous season. The basic is simple – it tells story about employees at a certain Family Restaurant. It goes without question that most (all?) of them are not quite normal.

Spoilers ahead.

Continue reading

Sora no Woto episode 12 (end)

Victory!!

It’s ended ;_;

Apart from lulz (fail) here and there, I think it’s overall good. Started out slowly… and kept the pace until the end. I don’t remember when they finished repair on Takemikazuchi though.

And lol @ whoever said this is K-ON! ripoff. See you later at the end of spring (hint: Angel Beats!).

Sora no Woto 11

Priceless

I’m wondering if there’s any Japanese subtitle on original broadcast… Even though it’s not really that important, it’d be annoying when most of time you don’t know what’s spoken.

Apparently it’s my first post about Sora no Woto.

And WordPress almost ate this post. I wasn’t able to upload the picture above in original resolution. It complained about exhausted memory or something.

Watch Gundams for free

If you happen to haven’t watched previous Gundam series yet, lives in US or have fast connection, check out link below to watch them for free. I don’t know about quality in YouTube and CR but ANN’s Gundam SEED actually looks decent apart from its low resolution.

I think there’s time limit on the availability so don’t miss it. Or just download the fansub/rip.

[ Watch here ]

Convert those units!

What’s the sums of 7.4 TiB, 231.33 GiB, 30191.01 MiB and 985256 KiB?

What time and date it would be (in same place) in 2 months, 6 weeks, 19 days, 2059 hours, 129 minutes and 21 seconds if it’s now 20XX-03-17 06:27:40, DST is in effect and will be ended tomorrow?

…I’ll skip on imperial units for my own sanity.

For first one, I’ll convert them all to bytes, calculate the sums and convert back to whatever unit I like. Compare that to calculating sums of them in SI prefix.

For second one… Um, anyone?

Sora no Otoshimono 2nd Season

Uh, ok. Apparently Flying Pantsu Sora no Otoshimono will have its second season sometime. At least this series still have something resembling plot…

Compare that with Koihime Musou which will have its third season. Third freaking season. Of plot-free anime.

Anyway, I just hope it’ll actually finished properly on second season since I got rather lazy (when I don’t?) to read its manga.

[ Source ]