david koblas
31p36 comments posted · 445 followers · following 3
546 weeks ago @ Skis / Toys / Fun - Does it all devolve? · 0 replies · +1 points
546 weeks ago @ Skis / Toys / Fun - Zend Framework vs. Dja... · 0 replies · +1 points
554 weeks ago @ Skis / Toys / Fun - Python wierdness · 0 replies · +1 points
606 weeks ago @ Skis / Toys / Fun - Web 2.0 development - ... · 1 reply · +1 points
618 weeks ago @ Skis / Toys / Fun - Facebook vs. Google · 0 replies · +1 points
FB by having distinct "entities" for friendable entities vs. fanable entities makes the service feel a little bit more disjoint. I'm a fan of "Ashton Kutcher" (not) but I might also be one of his friends, why do I need to treat the two entities as distinct.
You do make a good point about having different circles of friends on different services, FB has minimal ways to manage your groups of friends. If it was more first class it would probably make things more interesting. That way you can assign a Friend Group to a 3rd party service and that's the circle of friends that would be seen/visiable/accessible on that service.
619 weeks ago @ Skis / Toys / Fun - Content agregation vs.... · 0 replies · +1 points
621 weeks ago @ Skis / Toys / Fun - Array Intersection Bak... · 0 replies · +1 points
621 weeks ago @ Skis / Toys / Fun - Array Intersection Bak... · 0 replies · +1 points
Perl #1 - 3.227
Perl #2 - 3.702
Perl #3 - 3.091
So, it appears that somebody might want to optimize Array::Util a bit more... In playing with this, since it didn't make sense why Array::Util should be slower found the following "faster" version. Which shows that the "map" call is slow compared to array iteration -- that's not good.
sub isect(@@) {
my %h;
for my $i (@{$_[0]}) {
$h{$i} = 1;
}
return grep { $h{$_} } @{$_[1]};
}
621 weeks ago @ Skis / Toys / Fun - Array Intersection Bak... · 0 replies · +1 points
From the apache commons project... Here's the implementation of intersection, which is great, since you don't have debug your own version... But, probably not going to bring a performance benefit.
Collection intersection(final Collection a, final Collection b) {
ArrayList list = new ArrayList();
Map mapa = getCardinalityMap(a);
Map mapb = getCardinalityMap(b);
Set elts = new HashSet(a);
elts.addAll(b);
Iterator it = elts.iterator();
while(it.hasNext()) {
Object obj = it.next();
for(int i=0,m=Math.min(getFreq(obj,mapa),getFreq(obj,mapb));i<m;i++) {
list.add(obj);
}
}
return list;
}
621 weeks ago @ Skis / Toys / Fun - Array Intersection Bak... · 0 replies · +1 points
<?php
$x = array();
$y = array();
foreach (file("data.txt") as $line) {
list($a, $b) = preg_split("/\s+/", $line);
if ($b !== null) {
array_push($x, $a);
array_push($y, $b);
}
}
$t0 = microtime(true);
$xy = isect($x, $y);
$t1 = microtime(true);
printf("Set | n = %d : %d intersects found in %f seconds\n", count($x), count($xy), $t1 - $t0);
function isect($a, $b) {
return array_intersect($a, $b);
}
Here's the trivial program that creates data.txt
#!/usr/bin/python
import random
LINES = 1000000
MAX = LINES * 5
print LINES
for i in range(0, LINES) :
print "%s %s" % (random.randint(0, MAX), random.randint(0, MAX))