[icon] Makes you like your eggs on the Jersey side
View:Recent Entries.
View:Archive.
View:Friends.
View:User Info.
View:Website (Clowns Will Eat You).
View:Poly Geek Relationship Disclosure Form.
You're looking at the latest 20 entries.
Missed some entries? Then simply jump back 20 entries

Tags:, ,
Subject:Yesterday I learned
Time:08:06 am
That the Perl operator <=> is informally referred to as "the spaceship operator." Neat!
comments: Leave a comment Add to Memories Tell a Friend

Tags:, ,
Subject:idea
Time:07:57 pm
I was just thinking that Inksome offers a metric assload of userpics (150(!) for free users) and I think that's a fair amount of server load. I don't know what the LJ code does to optimize this at all, but what if, on Inksome, I were to do something such that if two people had the same userpic, that pic would only be stored once in the DB.

thinking about it a little more, though, I'm not sure how much good that would do. :)
comments: Leave a comment Add to Memories Tell a Friend

Tags:, ,
Subject:[CODE] There's a clever answer to this
Time:05:45 pm
I want to break a set of 1000 or more array elements into smaller arrays of up to 1000 elements each. There's some clever way to do this in a for loop with a modulus operator, but I just can't manage to figure it out. So here's how I'm doing it, in Perl:


# @array is the array I am passed, assume it has more than 999 elements. 
my $count = scalar @array; # number of array elements I got
my $size = 1000; # maximum size of subarray
my @subarrays;
for (0..($count/$size - 1)) {
  my $start = $_ * $size;
  my $end = $start + $size - 1;
  push @subarrays, [@array[($start..$end)]];
}
my $start = $count/1000;
my $end = $count;
push @subarrays, [@array[($start..$end)]];



I'm sure one of you can post a more elegant solution. :)
comments: Leave a comment Add to Memories Tell a Friend

Tags:, , ,
Subject:Yay solar sails!
Time:10:09 am
Current Mood:[mood icon] excited
http://space.newscientist.com/article/dn13776-space-spiderwebs-could-propel-future-probes.html

So basically what you've got is this gossamer-thin web of wire, miles and miles across. You put a positive charge on the wire and as the solar wind blows across it, the positive ions in the wind repel the positively-charged wire and the spacecraft starts to move. Only a tiny little bit, but over a year or two it adds up - seeing as how there is very little friction in interplanetary space - and the spacecraft starts moving at a good clip. They can maneuver the sail to steer the spacecraft.

So the upshot, apart from the "neato!" factor, is that using this technology, a spacecraft doesn't have to allocate as much weight to fuel, as the "fuel" is supplied externally. Smaller spacecraft == cheaper spacecraft, especially to lift it out of Earth's gravity well.

So props to the Finns for thinking this up. Let's hope some forward-thinking government or private individual funds them so that they can develop this technology further - right now it's all still theoretical, as they haven't yet figured out how to make this stuff in the necessary quantity.
comments: Leave a comment Add to Memories Tell a Friend

Tags:, ,
Subject:[GEEKY] Dusting off my Perl-fu
Time:10:11 am
The central issue of this little bit of code is that i'm building a hash with keys from the first line of a text file. That part wasn't bad, though I would of course appreciate any tips for doing it faster. The real kicker is in pulling the data from the file into that hash. When I knew the keys beforehand, I could just go:

# $_ here is one non-header line of the file.  
# $separator is the record separator
($hash->{foo}, $hash->{bar}, $hash->{baz}) = split /$separator/;


But since I don't know the keys beforehand, I have to do this:
# $_ here is one non-header line of the file.  
# @keys are the keys of the hash, pulled from the first line for the file. 
# $separator is the record separator
my @split = split /$separator/;
my $i = 0;
for (@split) {
  $hash->{$keys[$i]} = $split[$i];
}

And that seems a bit inelegant and overly verbose. Is there any way to do it more elegantly?

actual code behind the cut )
comments: Leave a comment Add to Memories Tell a Friend

Tags:, ,
Subject:[CODE] Replacing things delimited by brackets
Time:09:09 am
I got really tired really quickly of writing out the hyperlink for the documentation on a given table when writing my reading the database posts on Scribblit. So I decided to throw some Perl at it, as I gave up on doing it in XSL. It took a couple tries, but here is the current version of the Perl code.

code behind the cut, WS )
comments: Leave a comment Add to Memories Tell a Friend

Tags:, ,
Subject:Thinking about startups
Time:09:39 am
So i've been doing some thinking about startups, and I've posted about it in my other blog. The post is entitled Thinking About Startups and I'd like y'all's thoughts on the matter.

In particular, I've decided to hold a hack day (see the blog post for the definition) in one month's time, March 15. I need a place to hold it - somewhere with free WiFi, coffee, and room for a bunch of geeky types to get together and collaborate. Any suggestions?
comments: Leave a comment Add to Memories Tell a Friend

Tags:, ,
Subject:[GEEKY] XSL trouble
Time:06:52 pm
Current Mood:[mood icon] confused
So I've got this bit of XML that I want to do an XSL transform on, and it's stumping me.

Behind the cut, WS )

It's because the <table> element is embedded in the <p> element, and there's text in the <p> element. Can anyone give me a hand with this?
comments: Leave a comment Add to Memories Tell a Friend

Tags:, ,
Subject:[GEEKY] Slowness on beta.scribblit.com
Time:08:35 pm
Current Mood:[mood icon] tired
I have noticed on my work laptop (when I have it at home) that certain things on Scribblit's beta machine, which I administer, are poky. Specifically, editing one's userinfo and editing journal entries seem to be poky, but there may be other things I haven't seen. I'm not the only one experiencing it - several SI users have reported it as well. But when I try it from [info]ruisseau's machine, it's nice and quick. Same if I have my work laptop at work. Which leads me to believe it's an ISP issue, not a site issue. But if it were an ISP issue, why would it work differently on two machines on the same network (i.e. [info]ruisseau's and mine)? It could be that [info]ruisseau is running Linux, while I am running Windows. But if that were the case, why would Beta run quickly at work but slowly at home?

I must confess that I'm stymied. Geeky types, I have posted the headers from the quick and the slow sessions on Beta in my staff journal on SI. If any of you can offer some insight as to why Beta is running slowly, while keeping in mind everything I've said above, I'd be very grateful.
comments: Leave a comment Add to Memories Tell a Friend

Tags:, , , , ,
Subject:That pesky Scribblit redirect
Time:09:41 am
For a few days now, and only on certain computers, http://www.scribblit.com/ has been redirecting to http://ww2.zonepersonals.com/, and I can't for the life of me figure out why. The two sites have entirely separate DNS records, and I'm pretty sure their IPs belong to two different providers. So I have no idea why SI would be redirecting to this site.

Here's the output of [info]rahalia_cat telnetting to www.scribblit.com:80 and doing "GET".

Any ideas what might be going on?

Long )
comments: Leave a comment Add to Memories Tell a Friend

Tags:, , ,
Subject:Scribblit update
Time:12:26 pm
We've got the new beta box up and running, but for some reason, it's awfully poky for certain things. For example, I *can't* edit my userinfo over there with a graphical browser; I have to use Lynx. Otherwise it just hangs forever. Same way with friending someone. The weird thing is that I don't see anything hogging the CPU or the memory, and there don't appear to be any locks in the database causing trouble. And so I'm just stumped, and wondering if anyone on my flist over here has any ideas.

Now here's one thing that might be probative. Beta's "server name" in Apache and the LJ code is "www.beta.scribblit.com". However, in DNS, there's a wildcard CNAME for "*.beta.scribblit.com" to "beta.scribblit.com". Could this be a problem?

EDIT: It's only happening for me on my work laptop, which runs Windows. On [info]ruisseau's Ubuntu box, Beta runs just fine.
comments: Leave a comment Add to Memories Tell a Friend

Tags:, , , , ,
Subject:[GEEKY] Java cryptography question
Time:06:29 pm
I'm trying to extract the key used to encrypt a DES-encrypted string by brute force methods. I know the cleartext, and when it's written to the Windows registry, it's a string of eight bytes. As a first attempt, i did some Googling and threw this code at it:

code behind the cut )

When I try to run the code, I get the error: "Exception in thread "main" javax.crypto.BadPaddingException: Given final block not properly padded"

What am I doing wrong?

And don't ask me why it's DES-encrypted. I didn't write the encryption routine.
comments: Leave a comment Add to Memories Tell a Friend

Tags:, , ,
Subject:[GEEKY] Little note
Time:01:55 pm
When developing a Google Desktop Gadget, the elements described in the main.xml file are accessed programmatically by their name attribute. So if you have, say, an edit element named "foo", you can get its contents by evaluating foo.value. No need to call document.getElementsByName() or similar.
comments: Leave a comment Add to Memories Tell a Friend

Tags:, , , ,
Subject:[GEEKY] Oh, holy shit.
Time:10:05 am
Ubuntu may have killed my laptop hard disk.

Of course, I don't *know* that it's dead, but it didn't sound good when my laptop went down....
comments: Leave a comment Add to Memories Tell a Friend

Tags:, ,
Subject:[GEEKY] thoughts
Time:09:22 pm
It might be neat to write a Java class that provides arbitrary-length fixed-width integers. Not BigIntegers - they grow, and I don't want them to grow. I want overflow.

I could base it on an array of bytes, but that constrains me to multiples of eight (or I have to start doing weird stuff to simulate the absence of those extra bits). Hmm.
comments: Leave a comment Add to Memories Tell a Friend

Tags:, , , ,
Subject:Evil^H^H^H^HGood
Time:09:25 am
[Error: Invalid poll ID 1055258]
comments: Leave a comment Add to Memories Tell a Friend

Tags:, ,
Subject:BWAHAHAHAHA!
Time:07:32 am
Hi, I'm a.... (possibly NSFW for exposed boobs)

Various and sundry OSes in the style of "'Hi, I'm a Mac.' 'And I'm a PC'"
comments: Leave a comment Add to Memories Tell a Friend

Tags:, , , ,
Subject:[GEEKY] OOP Question
Time:07:43 am
Current Mood:[mood icon] curious
In Java, I can do this:

public interface foo {
  public void bar();

  public class Factory {
    public newInstance() {
      return new Foo() {
        public void bar() {
          System.out.println("bar");
        }
      }
    } 
  }
}


I.E. I can declare an interface and attach a static Factory class that spawns new anonymous classes that match that interface. Depending on conditions, I could spawn several different anonymous classes specially optimized for those conditions.

In Perl, I can't do that. There's no such thing as an interface (in Java terms) in Perl. If I wanted a single-class solutions, I would have to write the class to detect conditions on initialization and make the methods behave accordingly.

My question: is this a good thing, a bad thing, or indifferent? Discuss.
comments: Leave a comment Add to Memories Tell a Friend

Tags:, ,
Subject:[GEEKY] Non-recursive directory traversal in Java?
Time:04:07 pm
Alternatively, does anyone know a way to tune the JVM to speed up recursive directory traversals? I've got a directory structure of (estimated) 50 directories (each with between 0 and 20 subdirectories), each with 35,000 files in them. Grand total of 1.75 million files. On a test directory of only 35,000 files, the code below takes about 6 ms/file to traverse the whole structure, and I'd like to speed it up significantly if I can.

Any ideas? Using an array rather than an arrayList is a possibility, but there's going to be a lot of overhead in resizing the array unless I can think up some clever way around it.


public static ArrayList listRecursive(final File dir) {
		assert dir.isDirectory();
		assert dir.exists();

		ArrayList files;
		if (dir.list() == null) {
			files = new ArrayList(0);
		} else {
			files = new ArrayList(dir.list().length);
			for (File file : dir.listFiles()) {
				if (file.isDirectory()) {
					files.addAll(listRecursive(file));
					recursions++; // Note that this is defined statically outside of this method
				} else {
					try {
						files.add(file.getCanonicalPath());
					} catch (IOException e) {
						throw new RuntimeException("I/O Error: " + e.getMessage());
					}
				}
			}
		}
		return files;
	}


EDIT: Running this code on my test data gave me 132 recursions. This is why I think that the recursions are dominating the time the program uses.
comments: Leave a comment Add to Memories Tell a Friend

Tags:, , ,
Subject:[GEEKY} I am *way* too easily amused
Time:11:35 am

JOptionPane.showMessageDialog(chooser, "You suck");
JOptionPane.showMessageDialog(chooser, "No, really.");
JOptionPane.showMessageDialog(chooser, "You really suck.");
JOptionPane.showMessageDialog(chooser, "BURMA SHAVE");

comments: Leave a comment Add to Memories Tell a Friend

[icon] Makes you like your eggs on the Jersey side
View:Recent Entries.
View:Archive.
View:Friends.
View:User Info.
View:Website (Clowns Will Eat You).
View:Poly Geek Relationship Disclosure Form.
You're looking at the latest 20 entries.
Missed some entries? Then simply jump back 20 entries