Disabling Upstart Service in Ubuntu (11.04+)

Took me few weeks to find out that this one-liner does wonder:

echo manual >> /etc/init/mysql.override

(the line above is to disable mysql, obviously. And must be done as root)

The answer is on first hit (as of this post’s writing) of googling “ubuntu disable service” but you need to scroll down a bit and ignore shitload of crappy, outdated explanations to find that small gem.

Unfortunately doesn’t apply to previous LTS. Or does it?

Moebooru/Rails 3, and more

After working on it for several weeks, finally it got to the point where it’s relatively usable. No more Bundler-on-Rails2 evilry and the fact that 3.0 branch is still supported.

The best part is the one above. Yes, Moebooru now runs on Rubinius/Puma. The only foreseeable problem is it uses Process.pid on file uploads which, when several people uploading (or working with) files at same time, the temporary filename will collide.

Though due to me aiming more for workable implementation instead of correct implementation, there are quite a lot legacy stuff still in there:

  • repeated_auto_complete doesn’t work in Rails 3 without vendoring or updating the gem itself  (and I did both since Bundler’s git functionality seems broken in Rubinius).
  • prototype_legacy_helper must be used since I haven’t had time to upgrade the *_remote functions (and still thinking how to do it).
  • verification gem since I haven’t upgraded the route and its functionality, which previously built-in in Rails 2.3 has now removed.
  • Unsightly lib/core_ext. Just look at evilry I have added to make it behave like 2.3-stable.

On the brighter side, now I can start cleaning up the code. Or upgrade all the way to Rails 3.2 ( ¬‿¬)

Optimize all the queries!

While digging more into the code called “Moebooru” which was forked from “Danbooru”, I noticed this:

def self.included(m)
  m.after_create :increment_count
  m.after_destroy :decrement_count

def increment_count
  connection.execute("update table_data set row_count = row_count + 1 where name = 'users'")

def decrement_count
  connection.execute("update table_data set row_count = row_count - 1 where name = 'users'")

Counting takes ages, right. Except it is not. I’ve done this, yes, but on a table with 10+ millions of data (this one has ~400k in mainline danbooru), with multiple data inserted (this one got, uh, one every other week?) and queried every second (see below), and with the required count method not a simple select count(1) on some_table (which is what the example above used for).

The best part? It’s only used once, when user registers:

def set_role
  if User.fast_count == 0
    self.level = CONFIG["user_levels"]["Admin"]
  elsif CONFIG["enable_account_email_activation"]
    self.level = CONFIG["user_levels"]["Unactivated"]
    self.level = CONFIG["starting_level"]

  self.last_logged_in_at = Time.now

Moebooru Update

I haven’t been able to work on Moebooru for most of this month but I got to work on it this weekend. At ~30 changes, it went from -alpha to -beta.2 after receiving good amount of tests.

Summary of changes (more or less):

  • Most instances of RAILS_ENV and RAILS_ROOT have been replaced with newer Rails.env/Rails.root
  • Better Javascript handling in Development mode by moving cached Javascript from application.js to cached/all.js
  • Removed AssetCache modification library
  • Replaced HTML5Sanitizer’s html5sanitize with Rails’ built-in sanitize (because the former doesn’t work in 1.9)
  • Fixed Note Editor’s “History” button
  • Fixed Comment page’s pagination
  • Fixed Tag Relation search function
  • Updated “hack” for UTF-8 handling in Rails 2.3 with Ruby 1.9
  • Merged updates from moe branch
  • Reverted change which put class definition in <html> tag as it currently required by Javascript

Moebooru rebased

Since I forgot to branch the original source, the branching looked awesomely crappy. Therefore I decided to rebase entire thing to ease up keeping track with Moebooru “mainline”. All my commits are now in branch “default”. If you didn’t do any change, backout up to revision 9174b6b5b02d and then pull again. And then, don’t ever touch moe branch again anymore.

moebooru again

Last week I posted about my random project which involves modernizing moebooru without doing complete rewrite (see this for yet another complete rewrite attempt).

Let’s revisit the plan:

  • Upgrade to Ruby 1.9: done, need testing.
  • Update all plugins: mostly done, can use some trimming.
  • Update anything deprecated: nope
  • Migrate to Bundler: done, not sure how to test.
  • Use RMagick instead of custom ruby-gd plugin: nope
  • Use RMagick instead of calling jhead binary: nope
  • And more!: I hope you didn’t expect me to do more while there are incomplete items above.

Sure looks good. Need more testing though. There’s also one part which I totally had no idea why should be changed when upgrading to 1.9. Just grep for FIXME to see which it is and hopefully fix it up for me (or explain what it does).

As usual, having completed the work for today, live demo is up and open for everyone to break (…if there’s anyone, that is).

[ Live Demo | Repository ]

bcrypt in Debian

WARNING: using method below will lock yourself out when using emergency console since whatever crypt it’s using surely doesn’t understand bcrypt (as I experienced myself). Additionally, this solution won’t add bcrypt support to other applications using crypt interface like proftpd unless it’s started by preloading libxcrypt.so first (also from my own experience).

As much as Drepper want to pretend bcrypt is wrong solution, it actually gives one benefit: ease of switch to Linux. Some systems use bcrypt by default or configurable to use it. On other case, there might be time where you need system’s (or applications using system’s) crypt to handle bcrypt passwords from external system (usually web applications).

It’s quite difficult to enable bcrypt support in RHEL based distro as there is no libxcrypt and pam_unix2 packages available. Thankfully it’s available in Debian (and derivatives) in package libpam-unix2.

The README.Debian says to modify files in /etc/pam.d but if I remember it correctly, it confused apt PAM handling system or whatever. Fast forward few weeks, I discovered a better way to use it by creating PAM configuration in /usr/share/pam-configs. Since it’s mostly equivalent to normal pam_unix, I just copy and modify the file using this (long-ass) oneliner sed:

sed -e 's/pam_unix.so/pam_unix2.so/g;s/^Name: Unix authentication$/Name: Unix2 authentication/;s/pam_unix2.so obscure sha512/pam_unix2.so obscure blowfish rounds=8/;s/ nullok_secure//' /usr/share/pam-configs/unix > /usr/share/pam-configs/unix2

Then execute pam-auth-update, select Unix2 authentication and deselect Unix authentication. Don’t forget to update passwords for all other users as well or they won’t be able to login since pam_unix2 doesn’t recognize sha based hashes.

Actually, change all other users password to use md5 first before replacing the PAM with pam_unix2.

Update 2012-04-01: Removed nullok_secure since it isn’t supported.

Update 2012-06-09: Added warning.

An Attempt to Update moebooru Engine

If you didn’t know, the current moebooru running on oreno.imouto is using ancient version of many things. It also uses a custom lighty module (mod_zipfile) which doesn’t seem to be available anywhere.

I’ve updated it with latest Rails 2.x and made it compatible with nginx. Mostly. You can see it running here.

The plans:

  • Upgrade to Ruby 1.9.
  • Update all plugins.
  • Update anything deprecated.
  • Migrate to Bundler.
  • Use RMagick instead of custom ruby-gd plugin.
  • Use RMagick instead of calling jhead binary.
  • And more!

We’ll see if I can actually finish this one. Grab the source here. Yeah, I’m using Mercurial for a Rails project.

Compiling PuTTY for Windows

Because of one awesome bug inflicts eye-cancer when using Consolas font and deactivated “Bold text is a different colour”, I had to recompile PuTTY by hand (more like, by gcc). I initially tried to compile the PuTTYTray one but apparently they successfully mixed C and C++ code and completely broke the build procedure using mingw. Or I missed something obvious.

Anyway, I went back to vanilla PuTTY. As it turns out, compiling using latest mingw’s gcc isn’t a good idea since it removed -mno-cygwin option and therefore broken unless you do some magic edit. Thanks to that, I stopped bothering trying to compile it under Windows and used mingw-gcc for Linux (which is able to produce Windows binary). Here be the steps from beginning. Tested on Debian 6.

apt-get install mingw32 subversion perl
svn co svn://svn.tartarus.org/sgt/putty putty
cd putty
perl mkfiles.pl
cd windows
make VER="-DSNAPSHOT=$(date '+%Y-%m-%d') -DSVN_REV='$(svnversion)' -DMODIFIED" TOOLPATH=i586-mingw32msvc- -f Makefile.cyg putty.exe

Patch is done before make (duh) and the diff can be found here. If you’re lazy (like me) you can just download the build at my server (link at bottom). Should be virus-free but I guess you can notify me if you encounter one. Built everyday until it breaks.

  • exe: the program
  • sha512: hash of the program
  • zip: both program and its checksum

[ exe | sha512 | zip ]

Debian’s sources.list

I kept forgetting them whenever I need one so I’ll put mine here and be happy:

###### Debian Main Repos
deb http://http.debian.net/debian squeeze main contrib non-free
#deb-src http://http.debian.net/debian squeeze main contrib non-free

###### Debian Security Update Repos
deb http://security.debian.org squeeze/updates main contrib non-free
#deb-src http://security.debian.org squeeze/updates main contrib non-free

###### Debian General Update Repos
deb http://http.debian.net/debian/ squeeze-updates main contrib non-free
#deb-src http://http.debian.net/debian/ squeeze-updates main contrib non-free

###### Debian Backports Repos
deb http://http.debian.net/debian-backports squeeze-backports main contrib non-free
#deb-src http://http.debian.net/debian-backports squeeze-backports main contrib non-free

###### Dotdeb Repo
#deb http://packages.dotdeb.org squeeze all
#deb-src http://packages.dotdeb.org squeeze all

It should cover mostly used packages and will keep me sane. Also debian-volatile has been replaced with debian-updates (god knows why it’s called like that) since squeeze (6.0) but in case I need to take care a lenny or earlier (derp) machines, this should also be added:

deb http://volatile.debian.org/debian-volatile lenny/volatile main contrib non-free

Oh and Debian/kFreeBSD within a FreeBSD system is quite funny.

Update 2012-12-27: Use improved CDN.

Daily craps

  • LOL U-U-Uma Uma. Not good for health.
  • Noizi Itou drew the cover.
  • LAWL 22MB PNG. Perhaps I should mirror moe.imouto/noizi_ito…
  • a manga with nijikon main character. Recommended. LOL.
  • wat.
  • Danbooru 1.14.0 has released. I still wonder what “Final tagged version” means. And I think I’ll use tagged ones instead of trunk from now on. Why? Just because. 😛
  • ^– actually, it means less maintenance.
  • With that, I’ll also stop using -current for animu server o.o
  • Not before 4.4 released though – which means I’ll have to struggle with -current until November – or until I switch to NetBSD. The reason is simple: Danbooru requires PostgreSQL 8.3 which only available as package on -current (I forced to manually compile before using -current). – Or maybe until I switch to Shimmie (which sucks).

FreeBSD: 0, NetBSD: 1, OpenBSD: 1

Sil3112 (SiliconImage SATALink RAID PCI Card) is not properly supported by FreeBSD. The installer halted successfully on all my three attempt at installing it. (First one even stopped when formatting – said that it can’t find the hard disk drive LOL).

OTOH, NetBSD and OpenBSD can use that piece of hardware just fine albeit the claim of the card as “crappy” on certain mailing lists.

I did it!

Tonight, system.genshiken-itb.org got a system upgrade!

[10:42] ~# dmesg | head
OpenBSD 4.3-current (GENERIC) #878: Tue May 27 09:18:05 MDT 2008

I upgraded it. Remotely.

Nothing is more thrilling than reboot with new kernel while praying nothing bad happens O_O (which means, if IT happens, the server won’t be accessible until I got time to go to the location of the server…)

Now I can finally install PostgreSQL from packages – not compiling from source anymore 😀

Too bad there’s still no cksfv 🙁

My themes

Here’s a cell phone themes for you: lulz1 (ha creative name 😀 )

Designed specifically for Sony Ericsson W880 (yes, my phone). May or may not work for other SE phones version 4.5 with display resolution of 240×320 (which includes, but not limited to: K790, K800, K810, S500, T650, W580, W830, W850). And might work for other models with display resolution of 240×320.

Based on iPhony by adhamsomantrie.com (modified without permission 😀 )

Wallpaper uses art from xephonia (used without permission 😛 )

Suggestions are welcome.

[ Download here ]

Got pawned… by gparted

(Gparted is an open source partition editor)

Here’s the chronology:

  1. SP3 got!
  2. Install!
  3. Decided to install on old system (20 gb partition)
  4. Finished install
  5. Installed lots of programs
  6. Wanted to install NWN2…
  7. …not enough space!
  8. No worry, there’s still 50 gb space I can use to enlarge the partition
  9. Ubuntu + Gparted come to rescue!
  10. Resized in blink of eye
  11. Open the partition with Ubuntu… looks fine
  12. Restart!
  13. Nothing happen orz
  14. Boot with Windows XP Installation disk (fixmbr/fixboot)
  15. Restart!
  16. Still nothing happens orz
  17. Try repair!
  18. Restart!
  19. Now there are fancy characters on screen…
  20. wtf
  21. Rinse and repeat from step #11
  22. Still error!
  23. WTF
  24. Reinstall come to rescue o_O
  25. That, and one day work gone *poof*. Redo from beginning 👿

Lessons learned.

Multi-booting Windows, (x/k/ed)Ubuntu, OpenBSD

I actually liked Windows’ boot manager: it’s simple that it’s stupid (LOL)

But that’s it: I’m not going to use other boot manager if there’s any Windows installation in same drive (assuming all OSes are in same drive).

For OpenBSD, it’s really easy: just read the installation faqs. 😛

For (x/k/ed)Ubuntu, there’s no instruction available but it’s not much different with OpenBSD’s:

  • At installation, make SURE to install GRUB on the ROOT partition of the system (using advanced option on last step) – and take note the location (ex: /dev/sda2)
  • After installation you’ll get to Windows directly without given choice for OS: don’t worry, we’ll add it now
  • Go download dd for windows
  • Use dd –list to see which is the Ubuntu root partition. Easy way: Harddisk# is the same as system partition – usually C: drive. Then for Partition#, use this formula: /dev/[s/h]d[a-z]#. So /dev/sda2 would have partition number 2 (Partition2)
  • Then do this: dd if=?DeviceHarddisk#Partition# of=c:ubuntu.pbr bs=512 count=1
  • And edit boot.ini (System Properties -> Advanced -> Startup and Recovery Settings -> Manually edit startup file). Add line like this: C:ubuntu.pbr=”Ubuntu”
  • Reboot, there’ll be Ubuntu in boot choice list.
  • There might be another countdown… to remove: go find it yourself 😛
  • Yay finished


It uses 40MB of memory and eats all cpu resource when opening a folder with lots of application in it.

Will do a wait and see approach for a month before uninstalling it and replacing with something lighter like free antivirus from Avast! or Avira.