First project on github.

Well it isn’t much but I have my first jQuery plugin that I’ve made for others to consume up on github. I feel so trendy now. Seriously though I think git-hub is probably the greatest offering on the web since when Netflix hit the scene.

So for now I have put up jquery-checkbox-edit. I had a need for a “user profile” type form where a user can have many options for each category. The multi-select didn’t really look good in this case.

So what I wanted was to just show the list of what the person had selected and if they wanted to modify them they would be presented with the rest of the options. I’d like to put in a callback mechanism so that you could have an ajax update on done or something fancy.

Check out the demo.

enjoy… 

Blogging from TextMate

I am messing around with TextMate automations. I’ve been reading the book on TextMate lately and finally getting to write some Ruby :D

Python find longest line

I had to write a script for my course to find the longest line in a file. Pretty basic and of course about 100+ different ways to do it… anyhow here is mine:


#! /usr/bin/python
import sys

try:
	f = open('lorenipsum.txt','r')
except IOError, e:
	print >>sys.stderr, "File open failed: %d (%s)\n" % (e.errno, e.strerror)
print "...checking for longest line\n"
lines = f.readlines()
i = 0
h = [0,0] # list line:length
for l in lines:
	i = i + 1
	print 'Line %s is %s characters long' % (i,len(l))
	if(len(l) > h[1]):
		h = [i,len(l)]
print "\nLine %s is the longest" % h[0]

print "\n\nprogram finished\n"
f.close()

My Deck Shuffle in JavaScript

I’ve been really looking into algorithms lately for reasons I can’t disclose ;) but I had this problem to shuffle a deck of cards in an array and I finally sat down and gave it a crack. here it is… 


<script type="text/javascript" charset="utf-8">
	var deck 		= new Array();
	for(i=0;i<=51;i++){
		// fill deck
		deck[i] = i;
	}
	document.write(deck.toString() + '<hr>');
	var date1 = new Date();
	var milliseconds1 = date1.getTime();
	for(i=0;i<deck.length;i++){
		j = Math.floor(Math.random()*deck.length) % (deck.length - i);
		if(j > 0){
			a = deck.slice(j);
			a.reverse()
			deck.splice(j);
			deck = a.concat(deck);
		}
	}
	var date2 = new Date();
	var milliseconds2 = date2.getTime();
	document.write(deck.toString() + '<hr>');
	document.write(milliseconds2 - milliseconds1 + 'ms');
</script>

Python

So I am looking at taking some online courses at Berkeley. I loved my courses in Java when I lived in the bay area. I am looking at the Python course. Gotta increase the quiver…

update: got python cgi working on my host. 

Coming soon…

I hope to get working this weekend a RSS reader with the GWT. Why an RSS reader? Well because I want to focus on the tools and working with XML and not spend the time making XML. There is XML everywhere for the taking [parsing]. Even iTunes lets you export your playlist as XML… I just don’t want to be dealing with a 14mb XML file on my host ;)  

That’s right true believers… between feeding, and playing with Liam this weekend I hope to be hard at work on a new sample. Wish me luck. 

update

well it turns out my host doesn’t support JAVA. So The tests may not actually run but I can still post code. Site5 does however support Python.

GWT

I’ve downloaded and started to work wit the Google Web Toolkit. It is very cool to be working with Java again. I hope to have some samples this weekend…. I do have to put down the notebook every once in a while however…

Portfolio Posted

I put together a small portfolio. It is pretty cool it uses the Spry accordian and Lightwindow.js

Spry Sample Βeta

I checked out the Spry Ajax Framework a bit more over the weekend. Really cool stuff. I have to figure out how to traverse down the XML a little more with the same request. I thought a good start with doing a REST request to my Amazon wishlist.

View Demo

First I started with a proxy for the request:


$URL = 'http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&Version=2006-06-07&AWSAccessKeyId=[MYAPIKEY]';
if($_GET['ProductPage']!='')
$ProductPage=$_GET['ProductPage'];
else
$_GET['ProductPage'] = 1;
$ch = curl_init($URL.'&Operation=ListLookup&ListType=WishList&ListId=1BZUD8ZOIEA62&Sort=DateAdded&ResponseGroup=ItemAttributes,ListInfo,Images&ProductPage='.$ProductPage);

curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);

Then I created the Spry page:


<!--Spry libraries-->
<script src="/js/widgets/accordion/SpryAccordion.js" type="text/javascript"></script>
<link href="/js/widgets/accordion/SpryAccordion.css" rel="stylesheet" type="text/css" />
<script src="/js/includes/SpryDOMUtils.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript" src="/js/includes/xpath.js"></script>
<script type="text/javascript" src="/js/includes/SpryData.js"></script>
<!--Create a data set object-->
<script type="text/javascript">
var ProductPage = 1;
var dsAmazonWishList = new Spry.Data.XMLDataSet("/exec_code/proxy.php?ProductPage="+ProductPage, "ListLookupResponse/Lists/List/ListItem/Item/ItemAttributes");
</script>
<style type="text/css" media="screen">
body{ font-family: Monaco;
}
.AccordionPanelTab{
font-size:10px;
font-weight:heavy;
}
.AccordionPanelContent{
font-size:9px;
}
</style>
<div id="MainRegion" spry:region="dsAmazonWishList">
<div id="accord1" class="Accordion" tabindex="0">
<div spry:repeat="dsAmazonWishList" class="AccordionPanel">
<div class="AccordionPanelTab" >{Title}</div>
<div class="AccordionPanelContent">Publisher:  {Publisher}<br/>
<span spry:if='"{Brand}" != "{Publisher}";'>Brand: {Brand}<br/></span>
<span spry:if='"{UPC}".search(/./) != -1;'>UPC: {UPC}<br/></span>
<span spry:if='"{Warranty}".search(/./) != -1;'>Warranty: {Warranty}</span>
<br>{Format}
</div>
</div>
</div>
<script type="text/javascript">
var a1 = new Spry.Widget.Accordion("accord1");

</script>
</div>

Well it is about time…

That I got this thing up and running again. I have some ideas for a new portfolio. I should have it up this weekend.