Archive for the 'Tech' Category

Apr 02 2011

Random Web: Where the fuck is this?

Published by under Tech

Ever seen a picture of some place on the internet and asked yourself that question? Apparently there is now a site dedicated to using the collective users of the internet to help you out. http://www.wherethefuckisthis.com

Basically you post a pic and random people go and give their opinions on where they think it is along with allowing them to pinpoint it on a google map for you. (via Jason Fried)

Share

No responses yet

Feb 19 2011

Tech Post: jQuery .live() to attach/detach events

Published by under Tech

I haven’t been putting up a bunch of tech posts lately but, despite me not having written a jQuery post in over 3 years, it’s still a regular draw of people to my site. This post is just to put a little organization to one of my more successful answer’s on stackoverflow. And to be truthfully, my old jQuery posts are pretty poor so I feel the need to redeem myself a bit with some better content.

The question that came up was “what was the best way to dynamically remove an event based on some criteria”. In the question, this was based on the value in a field. The quick and common answer was to use the obvious bind/unbind methods. In this case, there would be some onchange event that would bind/unbind the events accordingly. To be fair to those who gave answers, my solution wasn’t available when the older post was originally answered. It doesn’t say anything against all the other answers.

With the scenario given, there is also the solution that doesn’t seem to be given where the event just check the value of the field when fired. That solution seems to be just very uncreative and lacking elegance, though, so I think it says a lot about the community that it wasn’t given.

The solution I provided covers using the .live() method to dynamically “attach” the event. I’m using quotes as the live() method does not technically attach events to the elements they match, but really uses event bubbling to catch events as they happen and execute them on the elements that match the selector the event references. Since it matched to elements the time of event firing instead of needing to be bound to elements, it allows this to work for dynamically created content. Typically for ajax generated content, you would have to attach the event again (also making sure you don’t reattach the event to existing elements causing those to fire the event twice). You only have to register the event with it’s matching selector once on page load.

The benefit you get here is that all you have to do is change something on the element that would cause it to either match or be ignored based on changes to the attributes the selectors are using. A really good attribute to use is class. It’s easy to set with jQuery and it’s very robust since it can be a list unlike most of the other attributes which can only contain a singular value.

I set up an example on jsfiddle to show the example I’m describing.

For the lazy, I’ll put the relevant code here too.

The html:
<input id="eventMe" type="button" value="click me!" />
<input id="eventToggleBtn" type="button" value="toggle event" />

The JS:

$(document).ready( function () {
    $('#eventMe.clickable').live( 'click', function() {
        alert('I can haz events!');
    });
    $('#eventToggleBtn').click( function() {
        $('#eventMe').toggleClass('clickable');
        console.log($('#eventMe').class());
    });
});

In the example, I have 2 buttons. 1 with the live() event we are bind/unbinding and another button that will toggle the class (clickable) we are using as the selector. On first load, the first button does not match the selector of the live event so it doesn’t fire. Once you click the “toggle event” button, it adds the class and the event then fires when the first button is clicked. This has the added benefit of being able to dynamically change it’s appearance using the same selector in css. A disabled button could have a different appearance when the selector matches.

This isn’t completely fool proof solution, though. jQuery support for the events weren’t complete with the 1.3 version and you really would be limited to monitoring changes that could be checked in a jQuery selector, but that’s a pretty extensive set of characteristics. You could match them if they were located inside a certain parent, apply it to all matching elements other than the first, only odd elements. Your options are pretty open.

I hope that helps.

Share

One response so far

Jan 12 2011

Bring the Hate

Published by under Entertainment,Tech

Netflix posted this morning basically saying “We tried to give you Facebook integration to share stuff but it’s not being used, WTF? We are gonna take our ball and try again.” I’m paraphrasing, of course.

Then comes the hate. There were about 20 comments that came in the first hour and only 1 of them was like “Hey, I used this and it worked for me, why are you pulling it?” All the rest were of the “Facebook is shit and I’m not using it” or “I tried to use it but it’s a steaming pile of poo” variety. Again, paraphrasing, but you get the point.

Facebook is a really polarizing subject. How can something that so many people dislike get to be so popular?

As for netflix, I hope they do figure out something that doesn’t include facebook. I really think they should have facebook as an option though too. The reason why it’s so popular is because it’s has user base. You can’t ignore something like that. The mistake of offering just facebook is only trumped by the mistake of taking it away now.

Share

No responses yet

Jun 02 2009

Getting Chromed

Published by under Tech

A few friends have been talking about moving to the google chrome web browser. For a long time, I’ve been a big proponent of Firefox. And truth be told, haven’t had much of a reason to even look for an alternative. The game changed with Firefox 3. While Firefox still remains the browser of choice for many in the tech savy community, I know others as well as I have suffered through increasing instability and what feels like a bloated application. Don’t get me wrong, it’s still an awesome browser and I still whole heartedly recommend it to any poor user I come across still using IE without knowing that there are better alternatives out there.

Good thing technology is always sprouting new seeds, though. I decided to try and feed my new gadget need and trying out a some of the alternatives. I’ll give Google credit. It definitely is a nice browser and I ,surprisingly, haven’t come across many gotchas while perusing the interwebs in my new chromed out set of wheels (pun intended). But it is not without flaws.

2 jump out to me right away. First is it’s handling of xml formed documents is terrible. It seems to try and view them as if they were html documents. Also it needs to have some way to handle rss files as live bookmarks. I personally find live bookmarks as more of an annoyance, but it’s still a standard feature in todays browser and I see no reason effort shouldn’t be made to make it contain the features that have become standards. All in all, this is a pretty trivial feature missing. After all, a browser is for, well, browsing html pages. Can I seriously knock it for having non essential features? Of course I can! But it’s still not going to keep me from using a good product.

The second missing feature isn’t really something that is standard, but it is something that has become so ingrained in my web browsing usage, that I dare say I couldn’t be without it. Yes, it’s my delicious bookmarks. I’ve tried various solutions that have failed for one way or another. I have recently read that the ability to incorporate plugins is on the horizon, so I have faith that a solution will be in the works form some one, but if I’m going to use it now, I will need a solution now.

Ok, so </rant>.

Start howto:

I did, however, come up with a quasi-solution. This makes it serviceable until a more elegant solution comes along. There are tons of posts out there talking about how to get a bookmarklet to tag sites to delicious. That wasn’t really my dilemma. What I wanted was to be able to easily find any of my 1000 or so bookmarks that I have already tagged. Isn’t that the point of bookmarks? To be able to easily retrieve what you have already found?

Well, since I normally end up searching through them any ways, I figured perhaps I could harness the keyword search capability of chrome. To create a new one, follow the instructions:

  1. Right click the address bar and choose “Edit search engines”
  2. Click “add”
  3. Give it a name, something like… oh, I don’t know… “Delicious.com”
  4. Then give it a keyword like say “delicious.com”. I tried to create one without the .com, but it didn’t seem to like that.
  5. Enter the search URL. If you want to search just your own bookmarks (what I was looking for) enter this in: http://delicious.com/search?context=userposts&p=%s&lc=1&u=<your_delicious_username>

Now, when you type delicious.com <some search term> it will search through your bookmarks. Again, not nearly as elegant as the delicious plugin for firefox, but as I said, hopefully some gracious member of the community is feverishly working to right this injustice in the chrome world, but until then, I think this will get me by. Hopefully you too.

Share

2 responses so far

Mar 05 2009

Can of Worms

Published by under Tech

As a standing member of my local LUG group, I’m almost ashamed to say I haven’t spent much time on my linux boot partition since I got my new computer. In my defense, online poker is just a pain in the ass if you have windows at your disposal.

But I had a presentation to get ready for tonight’s meeting. It’s setting up xdebug in apache to do php debugging in netbeans. Awesome sounding I know, right? Don’t worry, some one is supposed to be recording it and I’ll link it up once I get a url.

Anyway, I have had the new computer for just over 3 months now and had linux installed shortly after I got it. Last night I was chugging away at it and I can’t live without my email (even though I don’t get that much of it, I still like to respond quickly when I get one) so I strike up thunderbird only to be prompted with the new account wizard. Hmm. Did I really just install it and not set it up?

If I was gonna have to set one up anyway, I decided instead of setting up thunderbird, I was gonna go install and setup mutt. What is mutt? It’s a lightweight, text based email client. Here’s a screen shot.

mutt

Pretty sweet, huh? I had tried it out looking for a lightweight and faster way to check my email on my old computer and spent some time getting used to the interface. Since I invested that time, I figured I might as well use it. I literally spent the weekend setting up a config file for it before. Not exactly the time saving technique I was hoping for, but I do think I will make up some of it in usage. I do find that it’s quicker for me to navigate through it now. Not to mention all the geek cred bonus points that I bank for using a text based email client. Yeah, that’s right. Geek cred is what gets you the chicks.

Enter: Can of Worms

So I had already set this up so it should be a snap right? Just get my old config file and boom, I’m off and running. So I run sudo apt-get install mutt, and go to my old home directory tar file to extract the probably like 11kb .muttrc config file and…. wait…. Did I mention my old home dir tar file was in the range of 25GB? Apparently I had some iso’s I forgot to delete before I made the tar file along with my Music directory. It took like 15 minutes to get my 1 file out of that archive. Sigh. At least it gave me some time to finish up my presentation notes.

Alright, got it set up and run mutt. No problems. Until I test out sending an email. Error. Ugh. I was missing ssmtp to send email. Download and install that (like 30 seconds) and try it again. Error again. Crap. Must not be setup. A quick google and running sudo vim /etc/ssmtp/ssmtp.conf, and we are back to the races. Mail got sent.

But WTF is it? WTF was that command to refresh the mailbox? Quick search through help and figure out it’s G. Bah, an error. Some crap about pop not being setup. Well no shit. The command doesn’t have a key bound to it for the imap-fetch-mail command. Ugh. Quick google again and I’m back editing the .muttrc file and overriding the G key binding to map to the imap command. All’s good there. I even ran across the colors config file for it and turned on some of the helpful coloring mappings for links and email addresses in the messages.

Hmm, url’s. Do they work? I go back into mutt and pipe the message to urlview. Ugh, crap. That’s not installed either. So again, sudo apt-get install urlview. Ok, done and it even opens in a new tab of FF (I had to change the script last time I set this up). Bonus points there.

Even though mutt has a memory footprint that isn’t even worth mentioning, I still probably don’t want to run it constantly. So I spend the next 45 minutes modifying my panels in xfce so I only had 1 panel, I added the email notification widget and tried to configure that. Hmm, now how do I get that to open mutt in a terminal window? It’s a text based app, after all. I figured out that the command xfterm4 mutt will open a terminal window and run mutt in it. Awesome. All set.

So there you go. 3 hours of configuration and googling and I’m all set to be much more productive with my email. I’m sure it will only take me 4+ years to recoup that time back. Well, at least I got all that geek cred. Sigh.

Share

One response so far

Nov 21 2008

What’s in an Image?

Published by under Personal,Tech

Despite Zooks’ relentless efforts to find me a new laptop, nothing has caught my fancy and I still haven’t gotten a replacement for my broken laptop. I don’t have a lot of spare change laying around to throw at something that will just be used for email, internet, some poker, porn, and some light development work. Really, the 4 year old laptop I had was able to keep up with my needs very aptly.

Despite my modest requirements, I still couldn’t bear breaking down and snatching up one of the many “good deals” that I have come across or been shown. What keeps coming up on the radar is some inexpensive Acer laptops from newegg.

But really??? Acer? Are you serious?

Why do I not like Acer? I’m not absolutely sure. It’s just been the poor image I have of it. Back in the day, the other clan of geeks I hung around and I associated Acer with the bargain basement products that they seemed to be. Queue up Mr. Green.

So I don’t really have any reason other than my own personal image of them, but I still find myself struggling with thought of actually owning one. Are my issues unfounded delusions of inferiority? It would seem that might be the case. These things seem to be getting reasonable reviews from both users and critics. Especially considering the price.

So here I sit, in a quandary trying to get over a 10 year old image of a product solely based on some, what was most likely, elitist view. Fair? Probably not. But it does go to show how valuable image is and how hard it is to overcome.

Back to my issue at hand, though. Any one have any first hand experience to prove I’m being unreasonable with me valuation of Acer products so that I can just get over this petty issue and get back to getting a new computer back in my hands? I’ve got tons of porn development projects to catch up on.

Share

2 responses so far

Next »