Friday, December 2, 2011

keyboard navigation for google search


tl;dr - the alternatives worked, but they were no substitute for the real thing, so i wrote my own wrapper


google's experimental search page used to list a keyboard shortcuts feature. it's been deprecated for a long time, and was showing some rust, but was still working, was still an invaluable part of my desktop. a few days ago it finally stopped working. so i tried the google-recommended replacement, the accessibility experiment
  • it's not officially supported for chrome
  • instead of a cursor (a la gmail) it highlights the selected item
    • too large, can't change defaults, leaves artifacts
  • it works, though it's a bit clunky
i sent the usual scathing critique to google begging them to give us back the keyboard shortcuts experiment (i'd actually be willing to pay for search + shortcuts, i should have mentioned that). but i wanted to list some of the good stuff about the accessibility experiment
  • "n" and "p" move to the next and previous item, including to the next and previous page ... this is a feature that was often requested (and at one point worked iirc) for the shortcuts
  • shift-enter is an undocumented shortcut that will open the selected link in a new page
  • just tried it in firefox - the highlight box is still too large and no obvious way to change the default. but it does make a cute clicking and wooshing sound as you move though the results, unfortunately a second or two after moving the cursor
another option is google's standard search. pressing tab provides a small cursor that can be controlled with the up and down arrows. enter or ctrl-enter open an item. it's workable, but kludgey. i also tried the 43131 userscript, but couldn't get it to work on chrome

google still hosts the javascript that does the actual control, they just don't provide a means of injecting it, and it's got a little bit-rot. so i wrote my own wrapper. it looks like a userscript, but it doesn't really work right on firefox, so consider it chrome-specific. the shortcuts conflict with google's instant search, so i have a kludge to fix some focus issues that mostly works. here it is: keyboard navigation for google search on chrome. at some point i'll probably write my own javascript (as opposed to wrapping googles), but in the meantime i hope this works for some people


Sunday, January 30, 2011

voip take two

voip take two ...

sflphone is my softphone
  can't get transfers to work
  0.9.8 phonebook doesn't work right
    built 0.9.12 from source and it's better, but still weak
  tends to drop registration to sip.sflphone.org after calls ...
nexus s
  builtin sip dialer
    seems to loose registration after calls
  cSIPsimple
    my DOD needs the country code prefix, and css can prepend it
callcentric.com
  free account, i'm using this one for incoming calls, ie a gateway
sflphone.org
  free account, seems a little flaky ... but might just be that i'm trying to use to many providers
anveo.com
  DID: $1.50 per month, DOD/DID calls: $0.01 per minute
  not intended as a sip account ... my sip address is 100 chars long :)
  SMS seems to work, $0.04 per sms
  connects using the nexus/gingerbread sip dialer
  account transaction log is excellent, though it lacks a running total in the report
  outgoing calls to PSTN just by prefixing the country code ... use cSIPsimple filters to auto-prefix
  for both the nexus sip and cSIPsimple, requires a proxy: sip.anveo.com:5010
ipkall.com
  DID: free, can forward to any of the sip accounts (haven't tried anveo)
  google voice won't forward to this number - someone else has already registered it
    might try getting a new number
google voice
  almost the holy grail, free DID/DOD, great service
  no voice service on the nexus
  to forward to sip you need to use a PSTN gateway
  i can't figure out how proprietary the service is ... eg, ekiga ???



google voice can forward to the DIDs. my nexus s (android ginberbread) can connect to both accounts using the builtin sip, and i can receive and initiate sip calls (though if i make a provider the default i can no longer receive calls to that account). call quality over wifi seems ok

i'd like to be able to answer a call on my desktop and then transfer it to the nexus sip stack if i want to roam, but multiple accounts on multiple ip addresses behind my NAT seem to cause problems. so for now i'm giving up on this

Saturday, January 29, 2011

codemash microsoft shills ???

codemash is a tech conference that happens down the road at kalahari each january. each year i'm tempted to go, but it's seemed too microsoft centric for my taste. looking at #codemash i saw lazycoder wrote: With the #WebMatrix launch event at #CodeMash, does CodeMash become just another MS event? Or can it retain it's uniqueness & independence?, and later: Or more generally: is there a connection between vendor involvement and lack of variety at a conference?. the codemash people vehemently denied it, and he ends up retracting the statement, but it prompted me to finally sit down and try to quantify the MS influence ...

the core organizing committee (commentary is mine, based on reading the first few pages of the twitter feeds and blogs, following prominent links, and quick google searches for each of them):

  • Jim Holmes, President, Board of Directors
    sharepoint, .NET, some C# (though it looks like he's at least familiar with java)
  • Brian Prince, Vice President, Board of Directors
    windows azure, silverlight, ASP, and hosts windows bootcamps
  • Jason Gilmore, Secretary, Board of Directors and co-chair, speaker committee
    PHP, mysql, web apis
  • Dianne Marsh, co-chair, speaker committee
    founded SRT: .NET, Visual Studio, C#, microsoft MVP
    mentions a bunch of non-MS tech in passing ... guava, scala, google tools
  • Jason Follas, Sponsor Coordinator
    Twitter Bio: .NET and WoW... Is there anything else in life?
  • Mike Woelmer, VIP Coordinator
    Twitter Bio: Software consultant at SRT Solutions, C# developer
  • Darrell Hawley, Jack of All Trades
    Twitter Bio: C# Developer and Python enthusiast; Blog: C# MVP
  • Jeff Blankenburg, Graphics
    works for microsoft pimping the zune
of the bunch, only jim and dianne acknowledged java. didn't notice anything about linux or android, don't remember seeing anything about iOS (though i'm not an iOS dev, so i could have missed something). lots of C#, .NET, microsoft MVP, and azure. some windows phone 7. 5 guys that are outright pro-MS, 1 pure web play, and 2 generalists that appear to lean towards MS technology

looking at the sessions, 36 .NET sessions. 15 Java sessions, of which most are really Scala or Groovy. and not one mention of linux as a platform (several speakers bio's mention it), vs dozens for windows. the first sentence or 2 in the java sessions abstracts:
  • The rumors of the death of Swing have been greatly exaggerated
  • Java developers are typically hamstrung when it comes to rapid application development and prototyping
  • Are you a Java/Scala/Clojure developer? Are you jealous of all your Ruby buddies using Cucumber to write clean, readable acceptance tests?
  • The state of Java web development is in pretty sad shape
for the most part negative towards Java. the .NET blurbs are much more positive, including this charmer: Windows Presentation Foundation (WPF) is an extremely powerful and flexible framework. the numbers and the tone lean heavily toward .NET and various windows tech.

the codeplex guys responded to the critical tweets that prompted my "investigation" with this defensive tweet: @lazycoder Why does one launch event turn us into MS shills? I think we've got the chops and history to prove we're remaining independent.

no. one launch event doesn't prove anything. but a history of pro-microsoft and anti-linux and anti-java bias does. ignoring and painting Java in a negative light, completely ignoring linux as a platform, a microsoft launch event, and a committee that's loaded with MS technologists does. and denying that bias makes it worse

codemash should either fess up and admit that they're a microsoft-centric conference or acknowledge that they've failed to maintain a proper balance, add a bunch of non-microsoft technologists to their committee and present a balanced view of the technology landscape in the coming years

Thursday, December 9, 2010

pulseaudio mixer applet - building on ubuntu 10.10

trying to build this, i ran into a bunch of errors about build-aux, ltmain.sh and install-sh. you need to run the developer build tools
bzr branch lp:pama
libtoolize
aclocal
autoheader
automake --add-missing
autoconf
# omit CFLAGS for defaults
# might also want to pass PKG_CONFIG_PATH, eg to use a debug-enabled gtk+
CFLAGS="-g -O0" ./configure
make
make install

if you use a custom install prefix, you'll have to copy install/lib/bonobo/servers/PulseAudioMixerApplet.server to /usr/lib/bonobo/servers/ -- gnome-panel looks like a mess. no easy way to "inject" an applet from the command line :(

netbeans 6.9.1 + cnd: create a new C project from existing sources, choose the automatic configuration

Wednesday, December 8, 2010

voip providers - sip, iax2, xmpp

looking for a voip provider. assume that it'll be sip, iax2 or xmpp, but really open to whatever

must have:
sip to sip calls should be freeish, easy to initiate
should be able to call anyone that's on sip using there sip uri ...
need a DID and DOD ... ie termination

want to have:
able to make my DID/DOD appear to be another number (maybe my cell)
some sort of fallthru ... try my sip, then try my cell
sms

pricing should be reasonable, but beyond that it's secondary. not sure what the "fair" price is ???


voxalot/679376 - no softphone registration with the free account (voxbasic)
i guess this is intended as an aggregation service ???

pbxes.com/nqzero - my test calls to sip:nqzero@pbxes.org silently terminate
they do show up in the call log, so it's probably possible to do something with them
complicated, and i don't think it's intended for what i want.
signup asked for a lot of semi-personal info - just seems sketchy

sipsorcery -- didn't try this one, but it seems to be more of the same. they all seem to be meta-sip, without actually providing sip itself

anveo/7089916429 - incredibly complicated to do basic stuff, but i think i finally got it to work. but i tried so many things, i can't actually remember :( claims that it does sms, though not to verizon. it sent to my google voice number, but gv wouldn't send back to it. maybe if i had a DID. initial credit to allow testing, but no sip account out of the box. support guy activated it almost instantly :) DOD works with caller id set properly. not enough free credit to get a DID so i haven't tried that. sip to sip seems more problematic - they don't peer with anyone as far as i can tell. no sipbroker. i think i successfully called out, but it was using sflphone to an sflphone.org account ... pretty sure that sip-in doesn't work. all in all, it's the most contradictory service i could imagine - the site is very early-00s, looks amateurish today - just enough javascript to be scary, but not really web-2.0 or ajax or whatever. and doing the most basic things is complicated. but it appears to do everything i could ask for, and then some, and then the kitchen sink

google voice chat is my default option ... everything seems to work ok, if a little inflexible. more time needed to figure out if it really is the holy grail :)



good list of providers:
http://www.voip-info.org/wiki/view/DID+Service+Providers

sflphone.org
ekiga.net
callcentric.com - think that this one is a pretty basic provider. seems respectable and i think i could sip in and out. sipbroker
voovox.com - can send sms, looks reasonable but i didn't try it. doesn't look like they peer with sipbroker. but they're somehow tied to phonegnome, and pg claims that you should be able to sip in and out:
http://www.phonegnome.com/blog/2007/02/20/phonegnome-sip-tricks/

Tuesday, December 7, 2010

google apps transition - new infrastructure

some account features don't transition automatically. rather than wait some indefinite period for the manual transition to happen, i changed my primary email for the google account to an old yahoo email address. this allowed the transition to complete, meaning my google apps user is now a google account. and now i'm moving the "data" back to the google apps account ...

move google voice to a new account using this form, which isn't listed in any official documents. the closest thing to a confirmation from google that this link is legit is this post by ilya 2009 (listed as a google employee as of today 2010.12.07). ie, it appears that it's not a phish, but really poor form for google not to provide a more official endorsement (and heaven forbid that ilya leaves google :) ... don't want to encourage users to blindly provide credentials to unverifiable forms ...

update: happy to report that this was successful - took about a week, but the number and my old smss transfered to my google apps (migrated) google account

Saturday, November 27, 2010

gmail-gchat-gtalk choppy audio on ubuntu / pulseaudio

using the browser plugin for gmail's voice-chat (sometimes referred to as gchat or gtalk, though i think that technically those are other products) on my ubuntu 64bit box with onboard audio (via vt1708s) resulted in choppy sound and lots of dropouts. my typical test was counting from one to ten ... you could hear most of the numbers clearly, but several would be entirely silent. i tried 2 other boxes running 32bit ubuntu and didn't have any trouble

after some googling i found this post that details how to correct the problem (see the answer by grimwisdom). rjincorvia (the asker) has done a good job of letting people with similar questions know that his post is what they need to read, but the keywords don't match the symptoms that i was seeing, and really don't even match the symptoms he describes, which makes finding the answer using a google search difficult. so writing this post to make it easier for others to find

grimwisdom says to enter the shell prompt:
pactl load-module module-null-sink sink_name=myGoogleVoice
pactl load-module module-loopback sink=myGoogleVoice
and then select "monitor of null output" from gmail::settings::chat::voice chat::mic

to make the changes permanent, add those lines (without the pactl) to the end of /etc/pulse/default.pa



Monday, November 15, 2010

netbeans c/c++ execution environment variables

running (or debugging)  code using the netbeans c/c++ development module (cnd). i need to set environment variables, eg LD_LIBRARY_PATH. the project properties "run" page has an entry for environment variables which pops up a dialog. "add"ing a variable adds a blank line. but i can't find any way to actually set the variable name or value. clicking, double clicking, pressing space or enter, or just typing all have no effect

as a work-around, you can edit nbproject/private/configurations.xml file and set the section. close and reopen the project (or restart netbeans)
        <environment>
          <variable name="LD_LIBRARY_PATH" value="/opt/local/lib"/>
        </environment>
i'm on amd-64, ubuntu 10.10, java-6-openjdk and i've seen the problem with both nb6.8 and nb6.9.1
here's the forum post, and the bug report

Sunday, November 14, 2010

honesty

teddy tso gives a remarkably frank analysis of the ext2 filesystem's lost+found directory -- if only everyone was so straight forward. probably applies to ext3 and ext4 as well. short answer - if the lost+found directory annoys you, just delete it ...

Thursday, October 7, 2010

ghana

still trying to find words for today's game ... pretty good result, made it out of the first round. and can't fault the work ethic, the persistence, the effort. but jesus - a few more balls on the ground, an occasional shot that finds the back of the net. and a defense that doesn't crumble whenever a ball goes thru the middle ... these are things that most teams can take for granted. donovan would be a role player on the lakers ... good guy, but he's never going to be a dominant force on the field. we need to let that go. let him be the cog in the machine that he should be, that he's capable of. and look for magic elsewhere, realize that most of his production is cleanup, is reaping the seeds that dempsey and jozy have planted. he gets credit for gettting the job done, but it's a workman's lunch he deserves, not a heroes welcome

yeah, clark f'd up, lost the ball in midfield. but so did donovan, and bocanegra, and cherundelo. and the dependence on the long ball created dozens of extra chances for ghana. so i think it'd be a huge mistake to look to place blame. to think that things were ok. they weren't.

Tuesday, August 24, 2010

creating an empty tar: "Cowardly refusing to create an empty archive"

creating an empty tar archive so that you can append to it is a little harder than one might think. the obvious thing would be to create a new archive with no files listed. but the developers have decided that this is too risky. here's the workaround (reads the list of files from a file that is empty) ...


tar -tf blah.tar
# tar: Cowardly refusing to create an empty archive
tar -cfT blah.tar /dev/null
# success

Monday, August 23, 2010

connecting to nokia 2700 with ubuntu linux

the nokia 2700 is a quad band gsm phone that i picked up unlocked in germany. trying to connect it with linux. the os is nokia series 40, not symbian. uses nokia ca-126 cable, which is a micro-usb connector without power (ie, it doesn't charge from the usb cable). i'm using ubuntu 9.10 (karmic) linux ... about to upgrade

looks the like the modules aren't loading right. i probably need to do something with /etc/modprobe.d, but for now i'm just doing:
gnokii --identify
### Couldn't open PHONET device: Device or resource busy

sudo modprobe cdc-acm
sudo rmmod cdc_phonet phonet

gammu / wammu look great, but i couldn't get them to work reliably with the 2700. fell back on gnokii. created ~/.gnokiirc


[global]
port = 1
model = series40
connection = dku2libusb

at this point can copy messages, contacts, calls and browse the filesystem using sudo, but if i tried gnokii without sudo, it failed. copied the udev rules and restarted udev

gnokii --identify
### Couldn't open PHONET device: Operation not permitted

sudo cp /usr/share/doc/gnokii/sample/45-nokiadku2.rules /etc/udev/rules.d/
sudo service udev restart


everything i've tried has worked - haven't tried making calls, sending messages, or copying files. have the cell acting as a modem at one point, but seem to have broken it. will try to document that next


https://bugs.cihar.com/view.php?id=1130

Saturday, April 17, 2010

google-chrome, google's keyboard search and the back button

a recent release of google chrome, maybe this one, broke the google keyboard shortcut search experiment. perform a search in the experiment, eg rattlesnake, select the wikipedia article by pressing "o" or "enter". the page opens as expected. press back ...

you should go back to the search results, but most of the time i don't - instead getting pushed back a little further to the page before the search (in my case that's usually a blank tab). the search shows up in the history ... it just isn't honored by the back button

seems to work ok in firefox, and works fine if you click instead of using the keyboard. i'm seeing the problem on ubuntu 10.04, amd/x64


related google search stuff: adding &nfpr=1 to the end of a search will cause google to honor the search instead of using their "search for blah instead" logic

Thursday, April 8, 2010

please unsubscribe me from obama email list

from the beginning, i believed more in the campaign than in the candidate - i believe in a minimal govt whose primary role is to facilitate commerce. i knew that obama was more progressive than i was, and that his support base was significantly more progressive. in spite of that, obama showed an appreciation of the rights of others, eg he opposed the health care individual mandate, and seemed to respect the right to bear arms, so i entertained hopes that he might be able to walk the fine line.  and the campaign that was at least initially based on small donations was something that i believed in - so i joined and donated and i'm proud that we won

overall i'm reasonably happy with what the president has done from a policy standpoint. i certainly oppose the health insurance stuff and the bailout of the banks and gm, but i recognize that most americans wanted something done. and in the case of the bailouts, that we won't know whether they were needed for years to come. and i'm very happy that we've treated israel as just another country - for as long as i can remember we've treated them as infallible, and given them a blank check. i am disappointed with the strong intellectual property stance that the president has taken, and the inclusion of people with strong ties to the big media companies in the govt

my biggest disappointment has been the president's failure to play the game of politics - the fundamental challenge that a president faces is maintaining his popularity and power. instead of focusing on this, the president has put too much effort into passing legislation. and because of the lack of power and popularity, he's become beholden to the democratic party. eg, instead of focusing on passing the health care reform bill, he should have used it as a bully pulpit - go to the american people and explain that republican filibusters are holding up the bill, that the lack of a bill is costing the american people millions each day. that is, to force the republicans to play ball. he'd be more popular, more powerful, and would have gotten a better bill (though still one i'd probably oppose :)

i'm still optimistic and wish the best for the president and his team. but i don't think i'm part of it any more. please unsubscribe me from this list for now, though perhaps i'll be back in 2012

Friday, March 12, 2010

SOLVED: google experimental search -- keyboard shortcuts

google has an experimental search keyboard shortcuts experiment. i've been using this as my primary search since i've found it a few years ago, and i love it. lets you navigate search results with j/k/o, instead of having to click on everything. stopped working today ...

The experiment you're trying to access is no longer available. Go to experiments overview

the keyboard shortcuts experiment is still listed, so hoping against hope that it's just a bug and that it will get fixed quickly. has anybody heard anything ???

here's an example of how to search for "stuff"

http://www.google.com/search?q=stuff&esrch=BetaShortcuts


Update (2010 March 17) -- SOLVED
this is working again (since the 12th i think)

alkaline33 from the mailing list suggested an alternative user script. might be useful if google does eventually disable the experiment: http://userscripts.org/scripts/show/43131



Update (2011 November 30) -- BROKEN AGAIN

i get the "no longer available" message and the shortcuts don't work. there's a bunch of noise on the mailing list to the same effect. and google announced that they were dropping a bunch of experiments and lab projects. so i'm guessing that this really is the end of the road, but holding out hope. i haven't tried the userscript, 

Thursday, March 4, 2010

java to json using a javascript constructor -- classy javascript

i've got a simple class with both java and javascript representations

// java
package foobar;
public static class FoodStuff {
  String name;
  int index;
}

// javascript
foobar = {}
foobar.FoodStuff = function() {}
foobar.FoodStuff.prototype.blah = function() { return 7*this.index + name; }
foobar.mix = function(obj,props) { for (var ii in props) obj[ii] = props[ii]; return obj; }

i want to convert an java instance to json, and then instantiate it in javascript using the javascript class as the constructor. normally the json might look like '{name:"Sarah",index:77}'. i'd like to be able to do something like this

'{ food: foobar.mix( new foobar.FoodStuff(), { name:"Sarah", index:77 } ) }'

then i could (in javascript, where data has been assigned the string above, eg by an xhr call) say

var stuff = foobar.fromJson( data );
var magicValue = stuff.food.blah();

for this simple example i could obviously just augment stuff.food in javascript, but for a bigger heirarchy of data, i don't want to have to decend and replace the whole thing with a bunch of different constructors. i think that gson is going to support this in the next version by allowing custom serializers to call the default serializer, which should allow me to wrap the obj with my foobar.mix

is there an easy way to accomplish this in jackson or gson ? or another json serializer that does automatic conversion of POJOs (ie without getters and setters) to json ?

note: i don't want to serialize the data myself, i just want to augment it. ideally i'd just set an annotation that told jackson what javascript constructor should be used, but wrapping the default serialization myself would be fine if it was easy enough

Tuesday, January 26, 2010

godaddy .us registrations are expensive, ie godaddy sucks

5 years of a .us domain from godaddy.com: $90. i've already got an account with them, i'd be happy to purchase from them again. pretty expensive - quick check of a few other registrars. the price from everyone else: $45.  wtf ?

so i guess godaddy sucks ... blah. used name.com, appears to be fine

Tuesday, December 22, 2009

air fuel ratio for firewood

you're burning wood to heat your home. but the inside air gets dry ... you're pulling in cold dry outside air to replace the air used in combustion. you need to add water to the air. but how much ?

first, how much air is needed to burn a kg of firewood ?

there isn't as much info on firewood on the intrawebs as i'd have thought.

cellulose
50%
c6h10o5
hemicellulose
25%
c6h12o6
lignin
25%
c43h44o13


stoichiometry for dry firewood ends up being about: c6h9.5o4.45 + 6o2 --> 6co2 + 4.75h2o, and air is 21% o2. resulting in an air/fuel ratio for firewood of about 6.

all the numbers are very imprecise, wood is heterogenous, moisture varies a lot, combustion probably isn't perfect, hemicellulose is a mixture and lignin isn't well defined, so the result is only approximate (and that assumes i haven't made any errors :). i'm guessing the true mean is plus or minus .5

assuming that you're drawing in cold outside air with very little humidity, and you have to add all the water to it to achieve 50% relative humidity at 25oC (which is 10g water per kg air), you'll need to add 60g water per kg of firewood. realistically, the incoming air has some water, and we don't need to go to 50%, so maybe 30g-40g water per kg of firewood will work
http://en.wikipedia.org/wiki/Cellulose
http://en.wikipedia.org/wiki/Hemicellulose
http://en.wikipedia.org/wiki/Relative_humidity

other stuff:
firewood: 15MJ/kg HHV (ie including the energy that's lost with the combustion gases)






Thursday, November 12, 2009

performance of various javascript calling methods and proxies



median times in miliseconds for 20000 reps of a simple counting algorithm, testing various forms of dispatch, eg closures, classes, goog.inherit, dojo.hitch (method.apply), dojo.delegate, dojo.extend, a few of my methods similar to hitch, inline, custom function as a proxy, and proxies using method.call instead of method.apply


caveat emptor: benchmarking is hard, and i'm new enough to javascript that i'm not 100% confident in the numbers. my tests are very simple, but i have tried to make them difficult to optimize out. the basic algorithm is the following, which is far from foolproof.



function(ko) {
    ko = ++ko % this.po;
    ko == 0 && (this.po++);
    return ko;
}








median
std dev

Chrome
Firefox 3.5
IE 7
Chrome
Firefox 3.5
IE 7
class
2
14
62
0.41
0.85
0.5
goog.inherit
2
16
78
0.73
0.9
0.35
closure
2
16
63
0.5
0.62
0.5
dojo.delegate
3
15
63
0.52
0.7
4.03
dojo.extend
3
14
63
0.62
0.64
0.45
dojo.hitch
13
141
297
1.25
190.2
7.93
nqo.proxy
4
136
281
0.41
139.61
0.5
hitchArgs
256
381
1312
3.33
189.79
7.18
proxyArgs
202
273
813
5.58
190.16
6.43
functionProxy
3
24
125
0.26
0.88
0
functionArgs
3
24
125
0.41
0.9
4.12
callProxy
6
35
156
0.45
1.08
0
callProxy1
3
29
141
0.35
1.42
5.44
callArgs
25
40
172
0.72
1.55
0.41
inline
1
5
15*
0.41
0.26
5.43



Conclusions: Chrome > Firefox > IE 7, function.call > function.apply, any of the class or closure based approaches worked about the same, regardless of the inheritance mechanism. the dojo.extend style seems slightly faster to invoke, but for any real problem i don't think it's worth worrying about. dojo.hitch and function.apply seem massively slow, especially when combining arguments from the hitch and the invocation. function.call is much faster, and a custom function as a proxy is faster yet - taking about twice as long as directly accessing the source object

* my tool reported mostly 0 msec on IE 7, but every by-hand test that i did was 15 or 16 msec. pretty sure that the delta in Date() isn't working in tight loops

Tuesday, November 10, 2009

wtf is an attribute ?

never quite understood the subtleties of HTML attributes. reading the DOM Level 2 Core spec and finally getting a grasp of it ... overload soup, FTL

summary:
you've got a javascript object that implements the DOM Node and Element interfaces. the object has properties, since it's javascript. the Node interface provides an array-like "attributes[]", accessed by attribute index. it's also an DOM Element which provides getAttributeNode(), accessed by attribute name. they both give an Attr, which is again a javascript object representing a DOM Node. but the object properties also provide access to the same stuff, eg an "A" tag has an 'href' property, and an 'href' attribute


a.href
javascript object property
http://localhost/#search
a.getAttribute( 'href' )
String
#search
a.getAttributeNode( 'href' )
DOM Attr
Attr( '#search' )
a.attributes[0]
DOM Attr
Attr( '#search' )

i guess the property part is implementation dependent. for common stuff like 'href' it must be pretty safe to use the property. but i've got no idea if it's actually specified anywhere. and for less common stuff, you can have a property and an attribute of the same name that have different values, eg "foo". good thing dojo provides dojo.attr()

still don't know the answer to my original question: when is it safe to add properties to a javascript object that represents a DOM Node ?


the worst part: the DOM spec is written in IDL, in which an "Attribute" is a member of an interface. so we've got Node.attributes, an IDL Attribute of the DOM's Node interface. and Attr.name, an IDL Attribute of the DOM's Attr interface, which represents an "attribute".

attributes, FTL

Sunday, November 8, 2009

javascript rendering performance: innerHTML vs DOM methods

i'm working on some javascript content creation code. content can be created using innerHTML or DOM methods. conventional wisdom is conflicted - there are arguments for both based on compatibility. but most comments suggest that innerHTML is faster. how much faster ?

i wrote two routines that render an object into a table, one using document.createElement, the other using innerHTML. to test the performance, i regenerated an object that is 10 rows of 4 columns of Math.random() every 100 msec. i run the test for 10 or 30 seconds and i measure total cpu usage using the cpu line from /proc/stat while nothing else major is running. there's some noise from other processes, but it's the best snapshot i could find since the cpu is shared by the browser and X (my graphics card offloads a far amount to the cpu)

there's two factors of performance: the percentage of the redraws that happen, and the cpu usage that's required

firefox-3.5 on linux, amd x2
  • dom methods: 84-95% of the redraws in 1260-1600 msec
  • innerHTML: 95% of the redraws in 1300 msec
google-chrome on linux, amd x2
  • dom methods: 98% of the redraws in 810 msec
  • innerHTML: 98-99% of the redraws in 770-850 msec
IE7 on MS-Windows, core duo
  • dom methods: 80% of the redraws, using 14% of the cpu
  • innerHTML: 91% of the redraws, using 8% of the cpu


conclusions: innerHTML seems marginally faster

one disadvantage of this testing methodology is that it allows the browsers to JIT the code ... it's doing a whole lot of the same operation. but it does measure actual redraws accurately

Monday, September 28, 2009

health care reform ???

How about health care common sense ...

  • tax the benefits that companies provide to their employees the same way that income is taxed ... is health insurance somehow more of a fundamental human right than food or shelter or education ?
  • require that providers clearly state their prices, the same way that a grocery store is required to label the prices. let the customer shop around, let the free market work
  • relax the restrictions on becoming a doctor - 4 years of premed undergrad, the MCAT, medical school, rotations, match day, the boards, residency, and ultimately licensing by the board ... the whole process is out of control and allows high paid "doctors" to decide who is qualified to work
  • ban providers from accepting gifts and those doing business with providers from showing preferential treatment - the gifts and treatment disrupt the provider-patient relationship - is that drug really the best value, or is the one with the cutest rep willing to take your doctor out to lunch
  • force providers to disclose their conflicts of interest
  • require providers to disclose their track record
  • zero liability for good faith providers - if a provider has disclosed their education, prices, track record, and any conditions that might limit their effectiveness (eg, being an alcoholic), has refused gifts that compromise their decision making, and wasn't intentionally harming the patient - the provider should have zero liability

in short, let the free market solve the "crisis". make it easy to become a doctor or a nurse, make it easy for a patient to evaluate their options, and make it obvious to the patient the true cost of the services provided - the rest will take care of itself


Friday, September 25, 2009

flexjson deserialization of pojos ???

FLEXJSON includes code for deserialization in version 1.7

Hero hero = new JSONDeserializer().use( null, Hero.class ).deserialize( jsonHarvey ); 

doesn't appear to work with a POJO (might work with a bean, not interested in that). serialization works with POJOs, and the deserialization docs don't mention that it doesn't ... the code runs, but the fields aren't set correctly, ie they're left with the values set by the no-arg constructor

anyone have any luck deserializing a POJO ?

here's a guy using deserialization, but he doesn't say whether he's got a POJO or a Bean ...

[SOLVED] ok - just tried google-gson, and it deserializes POJOs ... only a very simple example so far, but it works. guess i'll switch to gson



Wednesday, September 23, 2009

yahoo mail -- FTL !!!

been using it since 2000, maybe earlier. at times over a 24k modem, or using fetchyahoo, or pop3 way back when when it was free. i've tried "yahoo mail beta" a dozen times, and "All-New Mail" too, but mostly used "mail classic". or just "yahoo mail", since that's what it was before there was "All-New"

all i ever wanted was what i had, what they promised would be always free. and piece by piece they've dismantled it, introduced bugs, crippled the reliability, turned it into a web app, removed functionality, broken ctrl-click, ... and on and on

  • trapping ctrl-click
  • webappification
  • connection problems: "error code 2"
  • breakage with multiple tabs
  • and now, the latest and greatest ...
  • my mail now shows up as coming from "false"
yaaaahoooooooo !!!

anyway, not sure what the meme is these days, but i'll cover all the ground i know. if i'm missing one, let me know - i'd love to be feature complete

  • yahoo mail sucks
  • yahoo mail considered harmful
  • yahoo mail is dead

enough. i made the switch a few months ago, thank god. but still check the yahoo account ... and damn, it's getting more and more painful. avoid :)








Friday, September 11, 2009

ubuntu netbeans: javadoc popup fail -- solved

after a recent upgrade to the ubuntu java* packages, netbeans' javadoc popup for core java, eg java.lang.Class.*, wasn't working. showed "no comments found"

solved: under Tools --> Java Platform --> Sources :: remove any existing sources and add /usr/lib/jvm/java-6-sun/src.zip (if you're not on ubuntu, then the path to the source, i guess :)

related note: had another problem a few days ago with the debugger bombing out after an upgrade to netbeans. solved: remove all breakpoints

Wednesday, September 9, 2009

dojocampus.org login info

docs.dojocampus.org is a MoinMoin wiki for documenting the Dojo Toolkit, and it seems to be the future of dojo documentation. but it's hard to create an account there

the login page directs you to UserPreferences, which claims that you can create an account:
If you click on Create Profile, a user profile will be created for you.
but there's no button to click, and if you press enter you get an error:
ImportError
cannot import name wikiaction
the solution is to create an account at dojotoolkit.org, and then use those credentials at dojocampus. here's the official word. and it looks like once you do have an account, trying to save any changes in the UserPreferences will result in the same error above




Wednesday, August 26, 2009

Dojo API Code Assist in Netbeans

I'm using the Dojo Toolkit, a Javascript library, for the front end of a project I'm working on. It's fast, expressive, easy to program for, well documented, and has an active developer community

I want code assistance for dojo, both completion and the display of the API docs. Javascript has dynamic types and duck binding, making the code analysis that's needed for this sort of a thing a lot more challenging than for a more strongly typed language such as java. I've looked at a few IDEs

Aptana keeps saying that it has dojo support, but every time I try it, nothing works. Today was no exception. Real soon now, I'm sure ...

Netbeans used to support dojo 1.1.1, but that's pretty old. and with netbeans 6.7, even that seemed to stop working. and at it's best, half the methods showed "no comments found". but it was still the best i had and i was already using it for java, so i stuck with it ... and today i tried one more time, and got it to work

simple instructions:

  1. netbeans 6.7 (i'm using the java se bundle, ie no glassfish)
  2. download the dojo source version, eg dojo 1.3.2
  3. unpack the source
  4. put the source in your netbeans project web directory (i use a symlink to my local copy since i really don't want dojo mixed in with my own code ... makes revision control, managing multiple projects and upgrading easier)
  5. you may need to exit netbeans, remove the cache (.netbeans/6.7/var/cache) and restart ... i needed to, since i had the remnants of dojo 1.1.1 still laying around

coding bliss
here's the changeset that implemented the dojo parsing

Thursday, January 8, 2009

Surgeon General

don't know a thing about sanjay gupta, so no comment on him. but i think a sad state of affairs that the head of the public health service is a surgeon in the first place - a specialized branch of medicine that while important, doesn't really come into play until things are pretty f'd up, doesn't seem relevant to the vast majority of public health issues, and in particular poorly qualified to deal with rising costs of health care

keywords: anti-gupta, health, govt

Wednesday, December 31, 2008

missing an old friend

hi amy

i miss you and don't know how to contact you anymore - i just dug out an old hard drive to find your address and wish you happy new year, but my mail bounced. So I'm posting here, hoping that you'll google yourself, find this page, and get back in touch with me. Leave a comment or mail me - i'm still s***_lytle@yahoo.com

keywords: amy susmita barua sushidesire umass boston somerville davis

a story of yours about 1000 years of bengali music

Monday, December 29, 2008

Lenovo x60 battery failure / warranty

bought a lenovo x60 1709 a few years ago. it's been a great machine - light and sturdy, the size of a netbook, but a full-powered machine that i can use for netbeans development.

the battery just failed. and i mean failed.
the taskbar shows "Irrepairable damage to the battery has been detected", and the battery LED indicator blinks orange at about 1 hz. the laptop works fine on ac power, but as soon as i unplug it, it shuts off instantly. ie, the battery is completely dead. it sounds like the microcontroller has disabled the battery. my battery was an "fru 92p1167"

here's the lenovo page that describes the problem

when i bought the machine, i purchased the "3 year depot 9x5 Next Business Day" "warranty service upgrade". so i felt that i deserved a new (or repaired) battery. i checked the lenovo site and my warranty is active:



Type: Model: Serial number:
1709 47U ********

Status: Expiration date: Location:
In warranty 2009-06-04 UNITED STATES


Description:
This product has a three year limited warranty which includes a ThinkPlus warranty upgrade. This product is entitled to parts and labor and is entitled to EZServ. Customers may call their local service center for more information.



yay - i got lucky, my battery failed under warranty. i looked up and called the service center, and spoke to garrett, who told me the battery warranty only lasted one year. "what?"

i read the agreement they sent with the machine, and scoured the lenovo site looking for additional info. i couldn't find anything indicating that the battery wasn't covered, and the lenovo page suggests that the problem with the battery is a question of workmanship, which the warranty explicitly covers


2. What caused this problem?
A. Internal detection in the battery determined that it was not charging properly and disabled it. While this problem can cause any battery to fail, certain batteries are more susceptible to failing than others.

3. What is Lenovo doing about this problem?
A. If your battery has failed due to this problem, Lenovo will replace it for free. Use the Battery Verification Tool to determine if you are eligible for a replacement. Lenovo will replace these failed batteries for up to 6 months past the expiration date of the battery warranty.

4. What is the battery manufacturer doing about this problem?
A. The manufacturer of these batteries has made improvements to the battery that will help eliminate this problem. Only a small percentage of batteries will fail due to this problem.


not clear-cut, but good enough for me. if the battery was operating at 30% or 40%, i'm ok with that. but an internal circuit detecting that the battery is failed and making it inoperable isn't acceptable workmanship in my book.

so i call garrett back and ask him for the lenovo document that states that the battery isn't covered. he can't find it, but he gives me the lenovo contact number. i call lenovo and ask the same question. the tech found a few relevant documents, one that talked about the x300 warranties, and another that mentioned a 1 year warranty for my x60 1709 (that does break out the battery as a separate line item, but both items are 1 year). but nothing that stated that my 3 year warranty didn't include the battery.

the tech told me several times that he was transferring me to a super, but then would come back with yet another irrelevant link. after about an hour i finally talked to a super. he said that they didn't cover the battery, whether or not they had any documents stating that policy.

while i was on hold i had googled small claims court, and it looked pretty doable. so i asked the manager if he could send me an email stating that they didn't cover the battery with the 3 year warranty, so that i could sue to get my warranty refunded. at this point, he politely told me that he could no longer talk to me, and he needed to transfer me to legal. legal took my contact info, and said they'd get back to me within 48 hours.

i went to the grocery this morning to get ready for partying tonight, and a brand new battery was sitting on my stoop, overnighted thru ups.

yay

Saturday, December 27, 2008

migrate / transfer Evolution to a new machine

trying to restore an evolution installation from a backup. started by just copying the dot-evolution folder (ie, .evolution) and starting evolution, a method that used to work back in 2005. evolution doesn't seem to recognize the dot-dir, starts the "evolution setup assistant", and prints a warning:

(evolution:6898): camel-WARNING **: Cannot load summary file: `/home/lytles/.evolution/mail/local/Outbox.ev-summary': No such file or directory


i posted to the evolution mailing list, and was referred to the faq

Exit gnome, and then
gconftool-2 --shutdown
evolution --force-shutdown
cp $OLDHOME/.evolution $OLDHOME/.camel_certs ~
# if the old Evolution version is 2.12 or earlier
cp $OLDHOME/.gnome2_private/Evolution ~/.gnome2_private
cp -R $OLDHOME/.gconf/apps/evolution ~/.gconf/apps


where OLDHOME is the path to the previous home directory (or a backup of it).





keywords: transfer, evolution, data, new computer, migrate

Thursday, October 30, 2008

Capital-This

Java ...

Update: Matthias Ernst proposes an even better solution that I've thought of as well - it would accomplish the same thing as Capital-This, but without requiring changing the code. Anything that returns void would "cascade". This would be awesome

fill the void. An invocation expression of a method with return type void could be treated as if returning the receiver, enabling cascaded sends. Bean b = new Bean().setA(a).setB(b);



I'm always writing methods that return "this" so that calls can be chained.

class Blah {
Blah setText(String stuff) {}
}
...
Blah blah = new Blah().setText( "stuff" ).setReps( 2 );

Which works fine for a single class. But java is supposed to be OO - as soon as I extend Blah, I run into trouble when I:
public class Foo extends Blah { ... }
Foo foo = new Foo().setText( "again" ).fooInit( 0 );
setText returns a Blah, not a Foo and I'm left with an error. To overcome this problem, I have to override setText, and any other methods that follow the same convention, in every subclass. Not practical, and not very OO - instead we tend to write:
Foo foo = new Foo();
foo.setText( "again" );
foo.fooInit( 0 );
which works, but isn't as elegant. Eg, it sucks with with matrix algebra, b1 is much clearer than b2:
// calculate 1-a1*a2
Matrix b1 = new Matrix(a1.size()).set(1).sub(a1.mult(a2));
Matrix b2 = new FloatMatrix(a1.size()), tmp = a1.mult( a2 );
b2.set(1);
b2.sub( tmp );
Java needs a "This" return type that is equivelent to
class Blah { This myMethod() { return this; }
class Foo extends Blah {
Foo myMethod() { super.myMethod(); return this; }
}

"This" makes so much sense to me, and makes the language more "Java". Am i missing something ? Why isn't it implemented ? Java needs Capital-This.

Tuesday, October 21, 2008

virgin post

Let the editing begin :)