Javascript: 90% Science, 10% Magic

posted by pope on September 25, 2010 at 1:08 am

Yes it's been a while, and yes I'll spare you the usual, "oh I promise updates are coming soon, really." Because we all know that's a lie. But here's something I thought was worth talking about. I made a jQuery plugin. Or I'm working on one anyway. It's a pretty basic idea, take any div and turn it into one of those retro analog clocks where the numbers were cut in half and would flip down to change. At this point, it's pretty specific in what it does; images are only the ones I've provided (but I guess you could overwrite the files with your own) and the css is only there to keep things sized and positioned right to start off. But the javascript side of things is really pretty cool if I do say so myself. No markup is required beyond this:


<div id="hay">
    270
</div>

And then to make it work, just include jQuery, jQueryUI (a dependency I'm working on getting rid of), flipCounter.js, and hit it with this:


$(document).ready(function(){
    $("div#hay").flipCounter({digits:5});
});

And you've got yourself a shiny new way to show some kind of numbers, up to 5 digits long. Hell, it even supports negative numbers. You also get to use some cool methods like flipCounter('updateValueBy', 7) whose function I think you can probably guess. Even better yet, it's instance-based, so you can have as many of this divs on a page as you want. The data and methods for each one are tied to the DOM element you initialize it on, so they all live in their own special independent world.

It's stil very much in development though, and definitely not a finished product. For example I think IE still has some issues with my animation callbacks and keeping track of the instance data, and the code certainly has room to be cleaned up, but hey, who's perfect? These things will come soon enough, and maybe I'll actually make the thing available for download and all that.

For now, check out my demo on its project page: FlipCounter Demo and be sure let me know what you think.

permalink  |  Digg!  Share on Facebook  del.icio.us  Reddit  StumbleUpon  Slashdot  
tags: javascript, programming, jQuery, FlipCounter, all tags
: view   /   leave one

Sort of Update

posted by pope on August 3, 2010 at 1:05 pm

I made another site soon to be added to my portfolio. Soon meaning probably before 2011. Check it out; they're in the process of trying to get indexed and pageranked so this is mostly a plug for them, but check out my design too. Tell me what you like, what you don't like, whether you need a haircut, etc.

Shear Magic, Natick

permalink  |  Digg!  Share on Facebook  del.icio.us  Reddit  StumbleUpon  Slashdot  
tags: personal, new site, work, all tags
: view   /   leave one

I'm So Bad At This

posted by pope on April 6, 2010 at 2:45 pm

Seriously, how hard is it for someone who has such violent opinions about everything to post anything once in a while? Apparently the answer is: very. Some brief news from my life:

  • I'm working for the City of Boston, at City Hall for my next co-op, doing mostly internal web stuff
  • I've had a huge change of hear on Python and I regret saying that it blows; we have made up in private and Python will be making a statement on its twitter later today
  • Programming Languages is a class that can only be described as "hard as balls"
  • I have done exactly 0 of the things that I want(ed) to on this site
  • I'm part of a sweet design/development company called Backslash Designs
  • The comic has become actually profitable, and new stuff is coming soon
  • I'm sort of hungry right now even though I just ate

Well, there it is. And hopefully I'll find a way to post some more later. Or not. Based on previous experience, I'd have to go with not.

permalink  |  Digg!  Share on Facebook  del.icio.us  Reddit  StumbleUpon  Slashdot  
tags: site news, personal, so bad at blag, all tags
: view   /   leave one

Just A Reminder

posted by pope on January 6, 2010 at 5:31 pm

I totally exist. I mean, in real life anyway. Work became somewhat all-consuming, so I sort of disappeared from most of my internet homes. However, I am still around, and now that I've had a bit of relaxation on my winter break, I'm ready to be back and ready to start posting random nonsense that no one listens to.

permalink  |  Digg!  Share on Facebook  del.icio.us  Reddit  StumbleUpon  Slashdot  
tags: site news, personal, all tags
: view   /   leave one

Quickly: Python Loses

posted by pope on September 25, 2009 at 12:31 pm

EDIT: I've come to my senses recently, new post coming soon about why I had my opinions and why I'm now a changed man.

Here's a brief example of why I hate Python, and also why I love php. Check out the same code written in each language:

Python:


import MySQLdb 

class Eb_db:
    def __init__(self):
        try:
            connection = MySQLdb.connect(host="localhost",
            user="hammock", passwd="secret", db="waffles" )
            cursor = connection.cursor()
            cursor.execute( "SELECT * FROM Syrup WHERE taste = 'delicious'" )
        except MySQLdb.OperationalError, message:
                errorMessage = "Error %d:\n%s" % (message[ 0 ], message[ 1 ] )
                return
        else:
            self.data = cursor.fetchall()   
            self.fields = cursor.description   
            cursor.close()   
            connection.close()


PHP:

if(mysql_connect ('localhost', 'hammock', 'secret'))){
	if(!mysql_select_db('waffles')){
		echo 'Could not select the database: ' . mysql_error();
		exit();
	}
}else{
	echo 'Could not connect to the database: ' . mysql_error();
	exit();
}
$result = mysql_query("SELECT * FROM Syrup WHERE taste = 'delicious'");
if(!$result){
	echo 'No results were found: ' . mysql_error();
}else{
	while($row = mysql_fetch_array($result)){
		//do as you please, you're iterating over each row now:
		//$row['fieldName'] == 'data'
	}
}


Two lines of code less for Python, but assuming you didn't know either language, which of those is easier to read through and understand? This is of course also excluding the terrifying and often life ruining indentation-instead-of-braces deal that Python uses to define code blocks.

Someone who actually likes Python, please explain to me how this doesn't suck, because I just don't see it at all.

permalink  |  Digg!  Share on Facebook  del.icio.us  Reddit  StumbleUpon  Slashdot  
tags: Python, php, Programming, all tags
: view   /   leave one


show all posts

Please provide a reason for the ban

Ban user Cancel