A Timid Defense of Flash

Posted by knorby on May 5, 2010 under Android, Apple, Linux, coding, facebook, firebug, firefox, flash, google, internet, javascript, media, mozilla, rants, video | Be the First to Comment

First off, I hate flash. I use linux, and I have a netbook; I know very well how bad it can suck. For reasons beyond my comprehension, flash audio just breaks occasionally on me, including in AIR. On top of that, I have done a lot more web app development in javascript in an attempt to  push browsers to their limits than I ever have flash. Aside from Sound Manager 2 (which doesn’t really count), I think the last time I did everything in flash was flash 7, so aside from some side knowledge, I know very little about flash. I really hope HTML5 is successful, but I don’t think it is a direct replacement for flash, no matter how much  Steve Jobs bullshits. Here’s why:

Content Control

In the mad rush to move any web video over to flash, a serious point has been overlooked. Youtube may be able to set up backends for HTML5 video formats, but can Hulu? It is possible to save hulu apparently, probably though some strange use of rtmpdump, but from what I could see, those methods were convoluted at best. The question comes down to how something like Hulu, which must have ads on each video to survive, use something other than flash. I know from experience that ad block can stop the streaming of hulu ads, but hulu forces a longer black screen on you otherwise. I haven’t looked into the specifics of what goes on in the whole process, but it is safe to say that it is easier to restrict how content is handled on flash than the standard browser environment. The problem comes down to this: if uncompiled code is sent to clients, the client has the final control on how content is rendered. I wrote up a now broken approach to eliminating some facebook ads with simple css in firefox a while ago, but such approaches have only become more widespread. Site owners are starting to take notice of things like ad block, and some take serious offense. Facebook went as far to send a C&D to a firefox extension that modifies facebook rendering, of course they are pretty evil at this point (I am thinking of deleting my account, but that is a different story). I predict that in the near future, the question of how clients are allowed to modify the rendering of content will become a central issue to many web apps. The simple truth is that a compiled flash swf provides better code security than javascript obfuscation by several magnitude.  Both on the front of audio and video and on just general content, flash provides content control that a browser just can’t match.

Standards are Slow to Adapt

If you have been following any of the debate over H.264 vs. Ogg Theora (better format vs. open), something will be apparent: content hosters have a bad deal. Which standard will prevail (probably H.264)? Is it worth doubling the number of videos to accommodate firefox? The questions go on. When flash introduced video, it was simply a matter of “run this version” on all platforms. The thing with browsers is that they are big projects. Chrome, which doesn’t even have the task of maintaining a full rendering engine, suffers from problems already as a result of being too big. I submitted a bug to Chromuim about 6 months ago for an SVG issue in the developer tools; I submitted the same bug to firebug first, and what I have seen says a lot about chromium. The firebug issue was tagged (for triage) on the same day I submitted it, and the fix was in a beta 4 months later. It took 3 months for chromium to do what it took a day for firebug to do (look at it), and all I have seen in about 6 months is a couple extra tags, and a few irrelevant comments. Mozilla is quicker with firefox bugs, but it is also safe to say that chromium  has focused more on performance. These stats don’t even consider the number of developers on each, many of which professionally work on firefox and chromium, which can’t be said for firebug. I am not trying to raise questions in how open source development goes, but once HTML5 features lose focus, what will happen with bugs? What will happen when a better video standard exists? You can’t just fix standards; that’s why javascript and css are what they are.  There is something to be said for keeping stuff in third party apps.

Maturity

Flash games have a special place. Traditional games don’t fill that niche; mobile games can’t fill that void; the truth is that it will take a while for javascript + canvas to substitute. It is a new technology, and one with interesting potential, but it is new, not mature. You can’t expect normal flash game developers to all of a sudden start writing stuff for the pure browser, especially when it gets harder, not easier. That doesn’t even consider SVG+javascript, which is actually a more near equivalent of flash, and even as that is more widely deployed, I will just say that it is even farther from being in a real production state. I wrote a web app on it, and I encountered, and still encounter, all sorts of weird browser bugs. To keep it short, it isn’t better to develop on an immature standard on 5 different platforms on 3+ different OSs than flash.

Conclusion

I think there are a lot of pros and cons in both directions of Flash vs. HTML5, and I hope and think that HTML5 will take over many of the uses of flash now. I think my defense of flash is rather incomplete, and my love of the browser environment is hardly expressed. Regardless, java, flash, or other plugins have served as the innovators of new approaches for a long while, and there is something to that. I hope third party methods don’t disappear, as I think the web ecosystem will suffer as a result.

I realize this post was mostly a rant, so if you have anything to add, please leave it as a comment, or send something to me.

Why Gmail Gtalk is my Favorite IM Client

Posted by knorby on April 1, 2010 under IM, google, internet, javascript | Be the First to Comment

A friend of mine was complaining about Empathy today, an IM client I have never much cared for. I have serious problems with gaim/pidgin too, and really, most of the reasons are the same. Of all IM clients I have used, I have been most satisfied with gmail; here’s why.

Great Chat History

Essentially any IM client at this point has chat history, but I really started using it once I started using gtalk. Why? I can search it easily, and it isn’t local to the machine I use it on; same main reasons I like gmail. It does mean that the FBI could get my chat records, but I am not too worried about that.

Reasonable Multi-client Handling

Part of using a standard chat client is having it start up after login, which usually leads to multiple logins if you use several computers, or leave one on and logged in. Pidgin or something will usually have a login per instance of the client, which really doesn’t lead to the desired behavior anywhere. With XMPP, you usually get a message everywhere on the first message, after which messages are only sent to the chosen client. Gtalk seems to only use one login, and handle a multi-client situation somewhere between broadcast and interface restriction. The instance of gmail with the most recent activity is notified with the alert, and the chat window appears in full, with the red alert color. On other clients, the window appears minimized and alerted, or not at all  depending on several factors related to recent activity and what was already open. It works well. Android has its own model, but that is a different situation. It works really well. As an added bonus to this approach, status messages propagate well between clients, including to android.

Nice Balance Between Notification and Quietness

Most clients seem to work in one of two modes. Yell and scream activity, or say nothing. Aside from the ding, I think gmail is closer to the silent. If you are in gmail, you know when you get a message, and if you are in your browser, you probably notice the tab,  but otherwise, it is ignorable. Most clients default to playing a loud sound a lot, and bringing up the window, in addition to more silent types of alert. If I am trying to do work, this is really, really annoying. You can usually reconfigure the client to be a little more silent, but it never works just right. I check gmail a lot anyway, so it ends up working pretty well.

Reasonable Away Message Handling

Since most people check gmail frequently, especially when not focused on something else, the away timeout tends to work pretty well. Watching a co-worker of mine, the timeout is usually accurate to about 5-10 minutes. The behavior on other clients seems to be either nothing or constant switching; plus you can get annoying status change messages!

No Setup

I don’t have to install or configure anything. I just use gmail. This is one of the more obvious reasons, but it comes in handy a lot. I just need gmail open, which I usually do.

I assume I am not really documenting anything new or interesting here for most people. My point is more that gmail or the likes of meebo are in many ways preferable to a more traditional app. Really, there is no reason a web app should be more usable than a traditional gui, but I find it is often the case. Many people use gmail for email now, but IM, especially among some techies, is only seen as a fallback, especially on the web. I believe that is simply not the case.

tl;dr gtalk in gmail is my favorite IM client

Fun with One-liners

Posted by knorby on October 23, 2008 under Python, coding, javascript | Be the First to Comment

I have always enjoyed putting as much work as possible into a line, especially in higher level languages. In the crazy javascript (speaking of which, MochiKit 1.4 was finally release!) system I wrote (still need to put the final touches on that….), I was thrilled when I was able to combine all of the parts of my system into one one line. Since I mainly program in python, list comprehensions and generator expressions make it pretty easy to use one liners a lot, and at least with generators, it often means that is efficent too. Basically, what I am trying to say is that I love the one liner. Last night, while I was bored while doing my discrete homework, I came up with a memoized factorial function one liner. The standard, niave version is straightforward:

fac = lambda n: int(n==0) or n*fac(n-1)

Since I was bored, I wanted to see if I could memoize that expression, and still keep it in one line. Here is what I came up with:

fac_dict, fac = {}, lambda x: ((x in fac_dict or fac_dict.update({x:(lambda n: int(n==0) or fac(n-1)*n)(x)})) and False) or fac_dict[x]

which can be simplified slightly to:

fac_dict, fac = {0:1}, lambda x: ((x in fac_dict or fac_dict.update({x:(lambda n: fac(n-1)*n)(x)})) and False) or fac_dict[x]

There are still issues with recursion depth for large values, but a helper function could probably solve that.

I needed to write something for my blog, as I have gotten out of the habit, and this thing seemed as good as anything.

Removing Social Ads from Facebook Feeds

Posted by knorby on March 3, 2008 under coding, css, facebook, firefox, internet, javascript | Read the First Comment

Update: see my post “Fixing Facebook with userContent.css” for a corrected and more extensive way to go about this. There are some stupid errors in this post that lead me to use a bad approach, but the greasemonkey script should still work.

I am not a huge fan of ads. I say that somewhat hypocritically as adSense proudly barfs somewhat random ads out on this page, none of which I really expect will ever click on, but that is besides the point ;) . Anyway, I can normally block ads with adBlock, but social ads are trickier. Every social ad div has for a class:
feed_item clearfix social_ad
Each one is a seperate class. They do some trick so it is hard to override with a page wide css that doesn’t take out everything, so userContent.css and similar tricks are out. I ended up brute forcing it and writing a greasemonkey that does the job.

Download it here: hidefacebookfeedadsuser.js

Update: There is another class used as well. If I remember correctly, instead of social_ads, its ad_capsule with everything else the same.

Explorations of Hello World Perversion

Posted by knorby on January 10, 2008 under Linux, Python, coding, humor, javascript | 6 Comments to Read

What follows is probably the most perverse shell script I have ever written. I decided to write a script that somehow implemented Hello World for a bunch of languages. I didn’t include Java, because the installation of java on the machine I wrote this script on was somehow messed up. Plus, Java sucks hard. I didn’t do any javascript either as Rhino was messed up (see last sentence), and spidermonkey wasn’t installed. I included far too many, but I will gladly add more if someone bothers to write some. You can also download the file. Wordpress messed a few things up, which I tried to correct, so download the file copy if you actually want to try thing thing out. Also, you might need to install some stuff unless you are in the UofC CS department Linux clusters. I apologize to the world for what my boredom can cause…


#!/usr/bin/env bash
#====================================
echo "Bash:"
bash << EOF
echo "Hello World!"
EOF
#====================================
echo "Python:"
python << EOF
print "Hello World!"
EOF
#====================================
echo "C:"
TMPFILE="/tmp/stupidgcc.c"
TMPOUTPUT="/tmp/stupidgcc"
touch $TMPFILE
cat > $TMPFILE << EOF
#include <stdio.h>
int main(){
printf("Hello World!\n");
return 0;
};
EOF
gcc -o $TMPOUTPUT $TMPFILE
$TMPOUTPUT
rm $TMPFILE $TMPOUTPUT
#====================================
echo "Ruby:"
ruby << EOF
puts "Hello World!\n"
EOF
#====================================
echo "Perl:"
perl << EOF
print "Hello World!\n"
EOF
#====================================
echo "C++:"
TMPFILE="/tmp/stupidg++.cpp"
TMPOUTPUT="/tmp/stupidg++"
touch $TMPFILE
cat > $TMPFILE << EOF
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
EOF
g++ -o $TMPOUTPUT $TMPFILE
$TMPOUTPUT
rm $TMPFILE $TMPOUTPUT
#================================
echo "Haskell:"
ghci -e 'print "Hello World!"'
#================================
echo "Awk:"
echo '' |awk '{ print "Hello World!" }'
#================================
echo "Fortran77:"
TMPFILE="/tmp/stupidFortran.f"
TMPOUTPUT="/tmp/stupidFortran"
touch $TMPFILE
#http://www.roesler-ac.de/wolfram/hello.htm#Fortran77
cat > $TMPFILE << EOF
C Hello World in Fortran 77
PROGRAM HELLO
PRINT*, 'Hello World!'
END
EOF
f77 -o $TMPOUTPUT $TMPFILE
$TMPOUTPUT
rm $TMPFILE $TMPOUTPUT
#=======================================
echo "Tcl:"
tclsh << EOF
puts "Hello World!"
EOF
#=======================================
echo "Octave:"
octave -q << EOF
printf("Hello World!\n");
EOF

My Current Projects

Posted by knorby on January 4, 2008 under Python, coding, javascript, personal | Read the First Comment

This post is really for myself. I started a new project for myself last night, just another simple utility, mostly for my own use, that shouldn’t take me anytime at all. I say that before I start most things, but I think it will probably be true in this case. Anyways, I have a pretty large pile of projects that I have to work on or complete, and I wanted to make a list so that I might be able to judge which ones to work on and to just have a list.

(Mostly) Completed/There is Always More to Do

  • pyXSD – pyXSD was my first big project. It was what I worked on at ORNL as a student intern over the summer of 2006, between high school and college. It was also my first program in Python, my favorite language. It is an XML Schema Validator, which works in some funky ways. It fills a small void in th python+xml world, but it still has a few bugs to work out, and there are a few features I would like to add. It has stayed at 0.1 for some time now, and I don’t know when I will get back into it. I have been kind of hoping for a few people to submit some changes, but only one person has (and that was barely anything). I really just can’t get excited about this project anymore. I don’t use XML Schema (RelaxNG all the way!); I really don’t have a reason to do much more with it. I am guessing it will stay at 0.1 for a while….
  • ACLUofC Website – I mostly included this one, because I didn’t want this section to be one item long. There is really very little to this site. It has a simple design that I am mostly happy with, considering that I did it fairly fast. It needs content still, but I don’t really worry about that one too much.

Almost There, but Still Needs Some Work

  • xmlViewer – My project at ORNL over the summer of 2007. Basically, it is an xml-based expert system to create an editor for a specific xml format. The system is currently written in javascript. It is a really nice system, and there is a lot in it that I am proud of. It just has a few bugs at the moment. I have been planning to write an xhtml editor with it as well, as I figure it could really do some interesting things. It also needs a better name.
  • lambdaCarte – I was working on a project for a class, and I needed a nice command-line menu system in which I could associate actions, which usually are small. I did some quick searching, but I didn’t find any python packages that did just what I needed. I wrote it mostly in a night, and it seems to work surprisingly well. It needs a lot of cleanup, but it works. It’s really simple, but such things just make life easier.
  • DOIT Fortune Library - I am not going to try and justify this thing’s existence here, mostly because I have none. It is not as much a project as it is a mission; I feel it is my duty to make available in any form I can conjure (that doesn’t take that much time and requires no money) to spread a list of bad ambiguous sex jokes from USENET I found when playing on the twenex.org computer. There are few things to work out on what I have so far, but I have been planning to make a DOIT of the day rss feed, and I recently started to look into making a DOIT facebook app. I must DOIT to the world.

Partially Complete

  • xmlTools – I wanted to work with xml from the command line or in scripts, and there isn’t any easy to use toolset that I am aware. It is written in python and it uses the lxml library. A bunch of them work, but it needs further tests, and there are a few functions I want to add.
  • pySchedule – A python scheduling library. I haven’t touched this thing in a while.
  • packagemapWriter – A simple utility to create packagemaps for google code search. It is really a simple utility; I just wanted to something to pass the time over this last break, and I wanted it for some of my projects.
  • deviceXmlFileSync – I have a bunch of gadgets with file storage, specifically mp3 players. I often will get a new album and need to load it on to several different devices, but I don’t remember which ones I have put it on. This python utility helps to queue up transfers. I haven’t worked on it in a while.
  • fireScraper – The project resulting from the method I outlined to screen scrape using Firefox from the command-line. Still has a lot of work to be done, but I have already done much of the needed work.
  • Political Networks – A research job I have.
  • rstDocs – I write a lot of technical documents in reStructuredText (rst). Basically, I wanted something like google docs to write rst on and render it (except just for me and maybe some friends). I started this thing a couple nights ago. It was partly an excuse for me to play around with php.
  • New Print System Interface – I work in the Mac and Linux Lab at the UofC, where we have a print monitor to prevent users from printing things they didn’t write and to enforce a quota. As staff, we have to be able to make exceptions and correct errors. We also have to maintain kiosks so that users can select which jobs they want to print. I started to rewrite it to use ajax techniques as opposed to a simple php script with a page refresh every few seconds. I also wanted to add a few possible actions that maclab tutors and users could use on documents.

Barely Scratched

  • xmlDebt – I didn’t want to use any of the account tracking software I found, and it seemed like something simple enough to code, so I started on one, but I guess my love for accounting is not that great….
  • rsoFundTracker – Simple system designed for RSOs (clubs at UofC). Financially, most have a lot in common, as they all have to fight..err…..deal with ORSCA.
  • cssExtended – Basically, I think css sucks. It would if it was written using JSON instead, and it would be nice if the selectors included XPath and regular expressions. I started outlining this format, and a javascript engine to implement it. I was also thinking of writing a python script to implement it in  the xhtml server-side or to files after any changes are made. I was also thinking of calling it jss.

So now I have a list to remind me of all the things I started so I don’t start more when I want to code. For the ACM, Cord and I have been working on PhoenixForge, a gforge server for UofC students wishing to work on projects on campus. Hopefully, it will cause me to be more productive.

Using Firefox to Screen Scrape from the Command-line

Posted by knorby on November 6, 2007 under VNC, XUL, coding, design, firebug, firefox, internet, javascript, mozilla, screen scraping | 5 Comments to Read

So, here is the problem. I want to be able to get the source for a page after it has been rendered by Firefox (that is, loading javascript manipulations have been made, etc…). In other words, I want to be able to serialize the DOM in Firefox, from the command-line. Essentially, I am trying to write a massive hack. There are few problems that need to be overcome first. For one, Firefox requires some display. Since I only really care about Linux/BSD/Sun systems, I have to go through X11 (speaking of massive hacks…). Basically, I need a dummy X11 session. I don’t care what is displayed, I just want to send it somewhere. VNC, fortunately, provides this interface. It is worth noting at some point that I have not fully written this yet (laziness + hard-ass school = project stagnation), but I have a very good idea of what it will do. Anyways, the display is one small part of the problem; the trick here is getting the DOM out. I had some fun here. Unfortunately, DOM serialization must be done through javascript. Gecko provides a really nice little tool: XMLSerializer. I am not aware of anything like it in another browser, which just further supports my belief that Firefox/anything Gecko-based is simply the lesser of evils (bad design being evil of course). Why Mozilla decided the mix of XUL (an xml format Mozilla came up to design interfaces) and javascript would be sensible things to build a browser around, I don’t know, but it is useful here. The normal browser interface can be found at chrome://browser/content/browser.xul. You can have a lot of fun loading lots of these inside each other (see image). If you load browser.xul with firebug, you can play around with all of Firefox’s standard functions, which is always fun.

browser.xul window multiload

If you are creating a tradition extension, I suppose you would want to look at this stuff as well, but it is especially helpful here. Once this set of deep Firefox functions has been revealed, the actual loading of page is rather trivial. The real problem is I/O. I need to be able to pass firefox the link I want to open from the command-line, and write it to a specified location. Fortunately, there is JSLib, which provides things like I/O in javascript. From here, the solution is simple. I just want to make a copy of browser.xul, and add a few scripts into it. I then want to parse GET arguments on this file when loaded, since I can pass these to Firefox from the command-line. I would want one for the url, and one for the output path. Of course, these would have to be escaped before they could actually be passed to Firefox. That’s it! I was planning on calling it FireScraper. Hopefully I can finish it soon.