• Home
  • About Me
  • Contact

kanorben.net - blog

My personal blog on technology, programming, life, and the random

 

October 2008
M T W T F S S
« Aug    
 12345
6789101112
13141516171819
20212223242526
2728293031  

Blogroll

  • Boing Boing
  • BorjaNet
  • Brian Mayer
  • Dean Armstrong’s Blog
  • Ellen Smith’s blog
  • Faraocious
  • Gross or Awesome?
  • Marcus Westin’s Blog
  • Nightmares of David Bowie’s Package
  • Paul Mantz’s Blog
  • Slashdot
  • Tomorrow with Alex Beinstein
  • Valleywag

Personal Sites

  • DOIT Fortune Database
  • My bookmark’s on del.icio.us
  • My CS account page
  • My Facebook Profile
  • My LinkedIn Page
  • My Picasa Albums
  • My Twitter
  • pyXSD
  • The SUCCESS Blog
  • UofC ACM Site

webcomics

  • Questionable Content
  • Saturday Morning Breakfast Cereal
  • The Perry Bible Fellowship
  • Welcome To The Future
  • xkcd

Meta

  • Register
  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
Add to Google Add to My Yahoo! Subscribe with Bloglines
Bloggers' Rights at EFF

Twitter Updates

    RSS My Del.icio.us

    • ledger
    • Git User's Manual (for version 1.5.3 or newer)
    • Don’t overuse classes in Python | The GITS Blog
    • BBC NEWS | UK | Magazine | The rival to the Bible
    • Elite Officer Recalls Bin Laden Hunt, Delta Force Commander Says The Best Plan To Kill The Al Qaeda Leader In 2001 Was Nixed - CBS News
    • How Laser TVs work at BrainStuff
    • uMac | University of Utah | Xhooks

    RSS My Facebook Posted Items

    • Elite Officer Recalls Bin Laden Hunt, Delta Force Commander Says The Best Plan To Kill The Al Qaeda
    • Language Fail
    • Safety Fail
    • Gnarls Barkley Crazy Theremin Jam
    • Domino's Scientists Test Limits Of What Humans Will Eat | The Onion - America's Finest News Source

    Removing Social Ads from Facebook Feeds

    March 3rd, 2008 by knorby

    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.

    Posted in coding, css, facebook, firefox, internet, javascript | 1 Comment

    Explorations of Hello World Perversion

    January 10th, 2008 by knorby

    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

    Posted in Linux, Python, coding, humor, javascript | 6 Comments

    My Current Projects

    January 4th, 2008 by knorby

    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.

    Posted in Python, coding, javascript, personal | No Comments

    Using Firefox to Screen Scrape from the Command-line

    November 6th, 2007 by knorby

    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.

    Posted in VNC, XUL, coding, design, firebug, firefox, internet, javascript, mozilla, screen scraping | 3 Comments

     
    Add to Technorati Favorites - Creative Commons License - © 2007 Karl Norby