feed   myspace   facebook   last.fm   send an email   twitter   tumblr   send a message via aim to graykicksass

Posts tagged ‘javascript’

Python

Alright so it’s been a while since I posted anything and I wanted to put something out there, while I have been working a lot on many projects I couldn’t really speak of, I have a few quick things to update you on before I get on to the main content:

First thing, the staff of Opensock have acquired MMOCCForum, this is pretty exciting and we are going to help get that place in shape.
Second, Axcid.org has had a complete rewrite of it’s API, now including keyword search. http://tunebin.info/ does a great job showing this.

Alright now onto the main content of the post:

After hating python and it’s syntax for a few years, I got the push of actually LEARNING the language, including some of it’s many libraries and functions. Once you get used to it, the syntax isn’t too bad actually. It’s actually pretty easy, for example:

import system, string """ Python block style comments """ # Python one line bash-style comments # Rather then braces for syntax blocking, python uses whitespace #Functions in python must be declared before use, unlike in javascript. # The Syntax for this is def # e.g. def SayHello(text):         # This is the body of the function         print(text) # Say Hello would be considered a 'function alias', and would be used like this: SayHello("test") # Some built in python functions string = "123" # set a variable integer = int(string) # Convert string to integer string = str(integer) # Convert integer to string # And block statements use : to start the block, e.g. if (string = str(integer)):         SayHello(str(integer))         # Else if is elif         elif (string = int(string)):         SayHello("Oh..")                 # Not gonna reach this else:         SayHello("Else reached, so none of them was correct")

Just for an example of python, Axcid’s new JSON api can be used like this:

# axcid import sys, string, urllib import simplejson as json AXCID_URL="http://two.axcid.org/new/api/?method=search.keyword&format=json&allpages=1&q=" def GetResults(query):         query = query.replace(" ", "%20")         url = AXCID_URL+query         f = urllib.urlopen(url)         obj = json.load(f)         return(obj["track"])

And the result from that:

results = GetResults("sublime") if (results):         for track in results:                 print(track["title"]+" - " + track["artist"]

Writing a IRC bot in python the other day was simple as well. And a python-spidermonkey binding exists so it would be possible to bind the syntax of JS to python, Python-Spidermoney

Anyways, that’s all for my update. Hope it was useful to someone.

printr

http://graysblog.org/printr/

sometimes people get REALLY bored and have 5 minutes..

The breakdown:
this is a 5 minute practice script (wanted to do more regular expressions and strip_tags) and I got really bored.

So when you run this bookmarklet, it formats the page so it can be printed and read wherever you got 5 minutes.

Opensocial

After much bitching, moaning and complaining, I’ve taken the time to start writing an opensocial app.
Only doing it now because I ended up developing a twitter PHP api today, and I wanted a myspace app that would post my current status to twitter when I updated it.

A couple hundred lines of code later, I quit for the night. I will finish sometime in the coming days but let me just take the time to pointout now just how shitty this platform can actually be.

Granted it’s well organized, reminds me somewhat of Android’s organization. However it’s encouraging bloated, slow, web 2.0 sickening applications.

They have a large, powerful framework. But the trouble is that the whole thing is bloatware waiting to happen. You may be excited that as a developer you get to use javascript in the little iframe they give you to play with.

Not only does the iframes thing suck (well, how myspace pulls it off), and make anything but shitty flash games a pain in the ass to implement. (not that iFrames can’t be used, just don’t use them to make bloatware..)

Now I certainly don’t have all the answers, and I may sound like a jerk when I say how I would have my social network do things, but on the other hand, this is my blog.

While some failed games turned social networks did seem to take a general step in the right direction however limited. (Seems pretty damn amateur).

First off I want crossdomain communication to be as easy as possible. Since I don’t plan to make an insanely huge (cough* myspace, facebook) social network and am aiming for a more community feel, I have no problems proxying the data on my server.

So the coder could use something like:

crossDomainRequest = new CrossDomain();
crossDomainRequest.open(‘GET’, “http://graysblog.org/feed/”, true);

crossDomainRequest.onreadystatechange = function () {
if (crossDomainRequest.readyState == 4) {
alert crossDomainRequest.responseText;
}
}

crossDomainRequest.send(”);

Incase you don’t see the freakin’ obvious resemblance to XMLHttpRequest, just get your eyes checked.

So how do I plan to keep users safe? I do plan to (eek) use an iFrame and separate domain for the apps.

Don’t worry, all apps will have standard CSS applied to them because I don’t want a jumbled up crapload of apps that don’t look standard and end up ugly.

The framework will be a collection of objects. When an app is loaded, it will be sent 2 ID’s, owner and viewer. With this it can access the users information (according to allow/deny preferences) via the javascript object, or the REST API.

————————————————————-

And yes, I do plan to implement an API with my network. Access will use specific keys, and each user will be assigned an API-Use-Key. Keeping abusive users away from this will be a chore, but I have ideas for that already.

-woah that was a long post, I do apologize if parts didn’t make sense, tv+blogging+no sleep = bad

Back.. Oh and SongBird + Axcid = Greatness!!

Fixed the problem.

Now for the big news:

http://sharingiscaring.us/

Integrated Songbird + Axcid search api earlier today. It’s done in JS (using php to proxy for crossdomain shit), and hooks into the Axcid XML API.

Letting you have iTunes store like downloading functionality, free.

http://getsongbird.com/

http://sharingiscaring.us/

(Did I mention songbird works with iPods?)

Sorry for the lack of updates..

I’ve been a bit busy :P , but a lot has been done since I last posted something..

1. I finished the Rhymbee Freelance client, PHP based server + Shockwave Client. All done (http://graymatter.hostkiwi.co.uk/rhbee/ <<version without graphics when server is up)

2. Did some more JS practice ( http://graymatter.hostkiwi.co.uk/jswalk/walk.htm and http://graymatter.hostkiwi.co.uk/jsfield.htm# ).

3. Created an AIML based message poster, that ‘intelligently’ replied to posts on a certain board.. (will post source later)

I’ll be posting more code snippets soon, and will have theme sorted (gonna share with scriptd) in a while.

The ego framework.

There’s a long story behind this and in the coming days, all will be explained.

But I now present to you the code of a page using the ego framework, when we get it all finished properly it will be awesome:

The internet before ego:
<html>
<head>
<title>The ugly page</title>
</head>
<body>
<h1>The Ugly Page</h1><br />
<div id="bla">This page sucks, loads links normally, and doesn't come out of the browser looking good. Why would a market-demographic like a teenager or somebody want to look at this page? Unless your a coder and it's full of awesome content, you don't.</div>
</body>
</html>

The internet after ego:
<?php
    include('ego_framework.php');
    $ego = new ego();
    $ego->__init();
?>
<html>
<head>
<title>The new hot page</title>
</head>
<body>
<?php echo $ego->WriteHeadBar(); ?>
<h1>The HOT Page</h1><br />
<div id="bla">This page doesn't suck because it used the 'Ego' framework, it looks nice and is auto stylized with the 'ego' template. And don't worry about CSS classes ego's JS system will take care of that.<a href="two.php" type="ajax">Click here</a></div>
<?php echo $ego->WriteFooterBar(); ?>
<div id="extra-footer">And here ego's JS system will automatically stylize this bit. For copyrights and shit</div>
</body>
</html>
two.php:
<div id="bla">This content will be dynamically loaded and replaced! All with a simple link</div>

It’s awesome, make pages look good and enter a network of sites. And use OpenLogin’s existing framework(<< secret) at the same time. Cool.

More news on this and it’s big parent project in a couple days. Expect blog about sushi later.

Today I learned.. All about Google Maps & AJAX

http://graymatter.hostkiwi.co.uk/maps_experiment/#

Best viewed with FireFox 3, Fullscreen mode. Search does not seem to work in google chrome and I do NOT expect it to work in IE.

But anyways this was me learning the Google Maps API, GeoCoding and AJAX all in one day, plus some cool UI tricks.

F11 does the fullscreen for firefox 3 on windows btw ;) . Now let’s tear the thing apart:
I used the google maps api (http://code.google.com/apis/maps/documentation/) and tried to learn as much as possible. My own code to generate the 3 buttons used. AJAX for the search and google / my code for the ajax search (geosearch.php). That basically created and parsed calls to a geocoder which converted the search query into a latitude / longitude pair. That was then passed in my navigation function thru the XMLHTTP object and then eval’d. So my function would run and navigate it.

A pretty cool way to learn ajax and the maps api huh? I’ll give the source to anyone who is intrested but the page source tells a lot of the story :P . Great learning experience. I’m gonna go take a look at what other API’s google has :P .
EDIT:

Screenshot of the original running fullscreen: http://graymatter.hostkiwi.co.uk/supercool.png

before it had supercool stuff :P