Uncategorized

Mounting a JFFS2 filesystem in Linux

This is described on this mailing list, but here’s the short of it in case that page ever dies:

If /dev/mtdblock0 doesn’t exist, do the following

mknod /dev/mtdblock0 b 31 0

Then do the following. The kernel modules can be enabled under Device Drivers->MTD. Make sure to get them all.

modprobe mtd # get this when enabling MTD
modprobe jffs2 # under Filesystems, Misc
modprobe mtdram # under MTD section
modprobe mtdchar # under MTD section
modprobe mtdblock # under MTD section
 
dd if=your.jffs2 of=/dev/mtd0
 
mount -t jffs2 /dev/mtdblock0 /your-mount-point
Uncategorized

Making Facebook Useful

I’m not a particularly big fan of Facebook, but I recognize its usefulness in some ways, so I have an account. My brother (and a bunch of other folks I know) seem to be pretty addicted to the site, for reasons unknown to me. Maybe that’s the same reason I find keeping a Twitter account useless (no, I don’t have one).

So imagine my surprise when I sign in today and discover that I can’t find friends of mine from a certain city I’m visiting soon. Searching for said city returns a bunch of people, events, *web results* and other things of no relevance. Apparently Facebook thinks people would rather find new “friends” than search the ones they have.

After searching *Google* for some sanity-checking, someone had this link to share, which apparently is exactly what I wanted in the first place. Attempts to find this page from the Facebook interface were met with frustration and failure, until about 10 minutes later I found it under “Edit Friends”. Edit Friends? What?

Maybe I’m overthinking it, but why is searching your friends list under “Edit” and actual searching doesn’t search your friends? Did the use-case focus group goof up?

Uncategorized

eDonkey2000 Hash in Python

As part of a filesystem watcher program I maintain as part of a larger site, I need to obtain the ed2k hash of some files. Believe me when I tell you I have searched high and low for an Edonkey2000 hash algorithm in python. I’ve seen massive libraries that scared the bejesus out of me, but nothing clean, concise, and without external dependencies. Enjoy the below. It’s worth noting it’s just as fast as the C version.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import hashlib
 
def hash_file(self, file_path):
    """ Returns the ed2k hash of a given file. """
 
    md4 = hashlib.new('md4').copy
 
    def gen(f):
        while True:
            x = f.read(9728000)
            if x: yield x
            else: return
 
    def md4_hash(data):
        m = md4()
        m.update(data)
        return m
 
    with open(file_path, 'rb') as f:
        a = gen(f)
        hashes = [md4_hash(data).digest() for data in a]
        if len(hashes) == 1:
            return hashes[0].encode("hex")
        else: return md4_hash(reduce(lambda a,d: a + d, hashes, "")).hexdigest()
Uncategorized

Linux Hates my Palm Pre

For the life of me, I can not get my desktop Linux to recognize (and thus charge or give filesystem access to) my Palm Pre. Apparently no one else on the Internet has this problem.

I’ve tried enabling low level usb debugging in the kernel, and I can see when I plug the device in:

usb 7-5.1.3: no configuration chosen from 1 choice

If I reboot the device, I see it automount for half a second during its “bootup” phase, having:

usb 7-5.1.3: configuration #1 chosen from 1 choice
sd 20:0:0:0: [sdf] Attached SCSI removable disk

But then it defaults to nothing once again. Works fine in Windows, which pains me to say. Works fine also when my computer itself boots up- Pre must negotiate with the hardware directly since the “charge” menu shows up… but once the Linux kernel kicks in, that’s all over.

It’s not a lack of power on the USB bus, I can trigger that error by other means, but it’s certainly not one of the log lines normally.

Ideas? I’m running out of my own.

My kernel: 2.6.31-gentoo-r6 SMP

EDIT:
“Solution”: root into the pre. execute as root:

usbnet disable

/sbin/reboot

Netcat + Tar for simple file transfers

This past week I spent 3 days watching a 3-thread sftp process transfer over a system backup of 53GB. This backup in particular had a ton of files and directories, and I suspect most of the actual time was spent querying and creating the files rather than the actual transfer itself. Now that everything is transferred over, I can rsync it against another machine, but that’s another story.

In searching for a better way than what I did, I found this cool gem:

On the sender:

tar cf - directory_to_copy | netcat other_host 7000

On the receiver:

netcat -l -p 7000 | tar x

[The Source](http://compsoc.dur.ac.uk/~djw/tarpipe.html)

A Big Pet Peeve

One thing that absolutely drives me nuts is when other blogs, news sites, or other sources of information do not include the year of the entry, or even the entire date itself. What the heck?! Take this for example. I was searching for information about the AA/BA deal and Google gave me [this site](http://www.usatoday.com/travel/flights/item.aspx?type=blog&ak=49288128.blog). Great, except how do I know how old this was? Maybe it was referencing another deal 4 years ago? Ugh. I had to dig into the -trash- comments for a datestamp.

I see this problem strewn everywhere especially with blog posts. Great that you published a few nice posts 3 days ago… or was it 3 days and 3 years? Always frustrates me.

Palm Pre Emulator on Linux (Networking)

I updated my Pre emulator to the 1.3.5 SDK, only to notice none of the Internet applications worked. I searched and found one post by a guy on Stack Overflow with an incredibly unhelpful answer of RTFM (which, TFM does not even apply here).

I spent some time and figured it out. So, if you run into this problem, solve it as follows:

Log into your emulator via novacom:

$ novacom -t open tty://

Show the network routes (note the default gateway):

$ ip route show

Edit /etc/resolv.conf and change the line there to the same one as the default gateway.

$ vi /etc/resolv.conf

NB you may need to remount the filesystem as readwrite. I forget if this is the case.

My resolv.conf was 10.0.2.3, when it should have been 10.0.2.2. If you’ve never used vi before, press “i” to begin edit mode, then when you’re done, press the ESC key, and then press “ZZ” (upper case z twice).

You should notice your Pre emulator suddenly has network access again.

Uncategorized

Getting Rid of X-Lite

At work we use SIP/VoIP, and since I’m the one without a hard phone (e.g., a real phone), I use a soft phone (e.g., software + headset) when I need to make or take a call. I’ve been using X-Lite for the past few months, which by all outward appearances is a solid, working softphone. However, it’s become increasingly annoying to me since it:

* Likes to forget to make my headset the default audio device
* Refuses to allow me to use the “Transfer” feature (pay upgrade)
* Pops up that annoying as hell “Video” window on start
* Has an ugly interface
* Sometimes just freezes randomly

I’ve been trying to find an alternate softphone, and finally seem to have. [3CX Phone](http://www.3cx.com/VOIP/voip-phone.html) seems to work like a charm, doesn’t nag me to pay for anything (I don’t even think there is a paid version), and lets me easily transfer calls, etc.

We’ll see how it goes on call quality, but so far, so good. Eat it, X-Lite.

Update: I now just use a Polycom Hardphone. But I do have 3CX installed on my Android for those “out of office” times I need it!