My Wacky Head

Just things that are going on in my life.

Monday, February 27, 2012

The "Freedom" of Ubuntu

The Problem

I've been running Ubuntu as my main OS for pretty much a couple of years now and I have to say I LOVE it. The hardware support is great, tons of apps, and its free. Well "free" as in beer for sure, but not really "free" as in freedom.

This past summer I moved back to Syria, where, as you all know, the US has restricted the imports on software products for "National Security" reasons. So I've gotten used to Google Code being blocked, SourceForge not letting me download stuff and all that jazz. Still Ubuntu worked like a champ and I could download anything I wanted from the repos. That was until I decided to update my system to 11.04.

After spending about 16 hours downloading the updates (Slow internet over here), I was greeted with this little error:

Err http://us.archive.ubuntu.com/ubuntu/ maverick/main python-libproxy all 0.3.1-1ubuntu1
  403  Forbidden [IP: 91.189.92.182 80]
So according to Canonical Ltd I don't have the right to access Open Source software... FUUUUCCKKK!

Solution 1

The first obvious solution is to try a mirror that's outside of the US... Somewhere like Ukraine, but that didn't work. Canonical is in control.

TOR to the Rescue

The second obvious solution is to make it look like I'm coming from an IP that has the "right" to download the software. This is where the mighty Tor comes into play. Thankfully the Network Proxy Manager lets you apply system wide proxies. First I tried setting the SOCKS proxy to point to Tor but that didn't work. What you need is to point the HTTP proxy to a proxy that routs through Tor, Polipo or Privoxy will both do the trick. So after I set everything up and re-ran the update manager and now I'm working on my shiny new 11.04 setup... In your face Canonical.

Sunday, January 29, 2012

Sooooooooooo True

It sure seems easy to make a table. Anyone can do it, right? Get 1 large flat rectangular piece of wood, 4 equally tall wooden poles, 4 nails and a hammer. Nail the 4 poles to each corner of the flat rectangular bit, and you have a table. Ta daaa!

Now ask a carpenter to craft you a table. First they will spend time discussing the purpose and function of the table - indoor or outdoor, kitchen or dining room, for show or heavy use, what load does it need to bear. Then they will determine the materials to use - hard vs soft woods, laminate, plywood or railway sleepers. Then they will look at the aesthetics of the table - beveled edges, foot design, center or corner mounted legs. And when they finally get down to crafting the table, they spend a lot of time to mitre, mortise and dovetail all joints, install bracing points, use quality glues, dowels and screws, test its levelness, sand it flat, stain it, seal it, polish it and produce a table they are proud of. Seems a whole bunch more work, doesn’t it? It just a table, no?

But there are differences between the two approaches, did you see any?

The table with four nails looks shoddy, it’s wobbly because the legs are not squared, has a warped top, will not last a week before a leg spins itself off and cannot be trusted to bear the weight of single salt shaker. The carpenter’s table looks better, works better, both feels and is solid, does not wobble, has squared legs, is flat, does not give you splinters, lasts way way longer, and can be relied upon to keep a full dinner and a few partygoers off the floor. Which would you rather have?

Pulled from The Hiltmon

Tuesday, February 15, 2011

Greasemonkey 101

So I'm reading InfoWorld the other day and on the side of the page ther is that annoying "Share This" toolbar. Now I have AdBlock installed but it skipped this one for some reason and AdBlock can't removes div's AFAIK. The solution I came up with was Greasemonkey

After installing the plugin go back to that article you were reading. Right click on the Greasemonkey icon on the right side of Firefox's status bar and choose to add a new script. Fill out the Dialog that pop's up (see screenshot), make sure to give an URL for the namespace, a fake one will do, and to set the include line to "http://www.infoworld.com/*".

Click on the Greasemokey dialog box and your editor should pop up. This is where you write the code for your script, which is just plain Javascript. So our goal is to get rid of the annoying toolbar which just happens to have the fixed ID of "floating_tools", making our script REALLY simple. Remember to keep the comments that were originally in the file.

// ==UserScript==
// @name           KSTB
// @namespace      http://greasemonkey.circuitsofimagination.com/
// @description    Kill the Share it Tool Bar
// @include        http://www.infoworld.com/*
// ==/UserScript==

var toolbarElement = document.getElementById("floating_tools");
toolbarElement.parentNode.removeChild(toolbarElement);

Save the script and close the editor. Refresh the infoworld page and magically no more annoying toolbar. Even better you are now a 1337 c0d3r cuz you writes amazing greasemokey scripties. Congradulations!

For more in-depth info go to the Greasemokeys Hacks Wiki which is where I learned to do this from.

Sunday, June 21, 2009

LAWIM

Gotta love CoreImageFunHouse!

Tuesday, June 2, 2009

openFrameworks is cool

openFrameworks is a set of C/C++ libraries for "Creative Coding".

I heard about openFrameworks a while back off of reddit. The video on there home page had me sold! So one Saturday morning when I wasn't too hung over I made this.

OFVideoGrabber

It only took me 100-150 lines of code to write that app. You can get the Xcode project here.

IMO the filter looks best with some kind of light source in the background and an object between it and the camera. It's trippy!

So what really happened was that I was trying to write an edge detector and it went wrong. See code for a link, since I obviously have know idea what I'm doing, I won't try to explain why the filter does what it does. But I thought it was cool so I left it the way it is.

openFrameworks uses a processing style application loop with a setup(), update(), draw(), and event functions that you hook into by implementing a subclass of ofSimpleApp. My "main" function is only two lines long.

int main (int argc, char * const argv[]) {
 ofSetupOpenGL(1024, 768, OF_WINDOW);
 ofRunApp(new OFVideoGrabberApp());
}

My real friend was ofVideoGrabber. Getting the pixels from a built in webcam takes three lines. One in setup():

videoGrabber.initGrabber(camWidth, camHeight);

The update function has the other two:

void OFVideoGrabberApp::update(){
 unsigned char *buffer = (unsigned char*)malloc(camWidth*camHeight);
 ofBackground(80, 80, 80);
 videoGrabber.grabFrame();
 if(videoGrabber.isFrameNew()){
  unsigned char* pixels = videoGrabber.getPixels();
  convert_to_greyscale(pixels, camWidth, camHeight, buffer);
  edge_detect(buffer, camWidth, camHeight, filterBuffer);
  filteredTexture.loadData(filterBuffer, camWidth, camHeight, GL_LUMINANCE);
 }
 free(buffer);
}

The reason I didn't convert the image to grey scale and do the filtering all at once, instead of looping over the image twice, is that by doing it this way I can easily replace the filter. I just write a new filter and edit a couple lines of code. Of course the proper way to do things would be to dynamically load blah blah blah. For heavens sake it's just a toy!

The same goes for allocating "buffer" every update

I like openFrameworks use of 3rd party libraries and them leaving it out there and on the surface. Most frameworks I've worked wrap the 3rd party API's with there own, or just reinvent the wheel. Which is great as long as you are working within there confines but sucks when you need that one little property that you can't get to.

The part of open frameworks that I like right now but probably wouldn't like so much if I was doing a complete project is the hackish feel that is has. There isn't a nice little config/make/install wrapper, and it _wants_ to hand you the raw pixel data. Which means there is a little less learning overhead and it help free you up to add on what you want quite easily. The flip side to that is there is a lot you have to do from scratch of you want to change/add stuff.

It did take me a little messaging for openFrameworks to compile correctly. It mostly had to do with header paths, due to the lack of a nice config/make wrapper. It also comes with pre-built versions of most of it's libraries but you might have to move some files around to fix link errors. Other then that it went pretty smooth.

Whats up with Xmonad

Xomnad... The new and hip tiling window manager written is Haskell, the new hip language. I've been hearing about xmonad a lot and have been trying to get into haskell. Ya know, gotta follow those trends.

So I go and grab a copy of xomand (0.8) and all the depends (I had haskell setup already). Compiling and installing was a breeze. At the time I had a pimped out gnome setup (compiz, emerald... the works). Just to see what would happen I run the fresh new binary called xmonad. All the friking windows start bouncing around the screen. It was kind of cool to see the two programs fight for control over to poor windows.

Getting used to the tiling thing took a little bit. I'm still working on getting used to it, but I haven't lost much as far as productivity. Configuring xmonad is pretty fun since you have all of haskell to mess around with. But if you just want to do some simple configuration it still feels like any other config file (terminal = "urxvt").

One of the cool things about xmonad is that it's still small enough that you can mess around with it without having to spend a week reading up on documentation (I'm looking at you developer.apple.com). There are bunch of pre-made config files that are easy to read, a good starting point.

The contrib extentions are really cool... Well written, do cool things, small. Doesn't get better than that. E.g.: Invisible.hs is only 45 lines, including documentation. But I have to shameingly admit that I have no idea what the hell it does. On the other hand XMonad.Util.Run is an example of awesome. Simple and sweet functions for spawning processes via xmonad.

I've been using it for a couple of weeks and some times I can hear my video card calling for some changeling renders but alas. I think I'm gonna stay xmonad for a little longer. I've been using the trminal a lot more since I've gotten a new gig and, believe me, tiling window managers are made for terminals. I kind of expected they were before I starting using xmonad but I didn't think I'd get used to it so fast. I can see every thing all at the same time with no wasted space. But for things other than that (say gimp or evolution) some times you end up looking at the screen and thinking to your self "wtf is up with that?". Basically if you aren't a programmer/sys-admin/I like to push a lot of buttons kind of person then xmonad is not for you.

And that ladies and gentlemen is a big part of how I ended up with mutt, which, depeding on how intersting my life is during the next couple of days, could be what I'm gonna write about next

P.S.: Grammer police, please leave me the fuck alone.

Monday, March 3, 2008

This is from gnome blogger

Well I'm posting this entry using gnome-blogger. I got my old laptop up and running Ubuntu again for work. I still have my Mac that I use for school and stuff I prefer to develop on Linux machines. I have written a whole three lines and I still don't see what so special about this app. I might as well use emacs and copy/paste. Any way hopefully I'll post some interesting stuff later this week.