Archive for the 'technology' Category

Micro-Blogging Revisited

Monday, June 2nd, 2008

I took the time and signed up for Twitter, after learning about it sometime in Autumn 2006. I’ll just say, MAL “microblogging” is not, even melative “reflections” are not (though pushing towards the lightweight implementation and availability). These lack the interfacing and simplicity, and that thing of time-saving. Truthfully, “Notepadding” is closer to microblogging, but it isn’t social.

Here is a presentation by Jyri Engestrom, and I ask where do anime blogs stand in this social currency market, because blogs are quite the slow and time-consuming bag. Mind you, this is not new stuff, but Jyri makes a good point about “value” and while the steam of the otakusphere is “the current, the hot, the seasonal”, a couple months later it just doesn’t matter (editorials rule the time! glad to see more of these in recent months!!).

So what we have are blogs that just don’t stand, are continually “hot” and updated, but it’s being done in a very tedious way. It’s gotta be the mobile ease, and probably my stimulation here is my lack of leisure computer-time in the past few weeks to realize that the mobile connection works even being away from “home” half the time (adventure always calls, usually nature).

Efficiency and effectiveness will find a way :) and I’ve found sitting on a computer looking at the RSS feeds just isn’t that effective, because eventually time explodes and I just won’t be on the computer very often.

Ryan A

btw: relevant film reflection, Cafe Lumiere, see it. [reflection]

Code :: Blogs, php and URI access

Friday, May 9th, 2008

This will be a shorty, as the week has been turbulent and sweet.

So a couple months back, I posted about wp-melative, and in the code I was using a “socket download” since, the opening of URI has been disabled? on AB.net; I didn’t look into it much, just used socket connections as a workaround.

The Problem

Shortly after using the socket download wrapper-func, I noticed odd digits and characters appearing in the RSS. A very bad thing since, these renegade characters would sometimes appear in xml tags, thus invalidating and breaking the chain of events (the sidebar). Again, I didn’t look to much into it, but thought of another solution, this one is easy, and is today’s code.

Code

function wget($uri, $dest)
{
	// renamed from exec
	return EXECUTE( "wget -O $dest '$uri'" );
}

function getXmlFromWget( $uri, $rssfile )
{
	// do the wget
	wget( $uri, $rssfile );

	// get destination contents
	$rv = file_get_contents( $rssfile );

	// arbitrary length checking
	return strlen($rv)>5?$rv:false;
}

Techincals

The two functions are very simple. getXmlFromWget() takes the URI and the destination rssfile. It calls the wget function and passes the same parameters. wget() uses php’s exec built-in to pass a terminal command to the system, in this case it is specifically wget.

There should be a word of caution when passing stuff to exec, and especially with wget, since it can download/mirror an entire site with certain switches. I have only included the modest -O switch implying the single file download will be output to $dest.

Is this better than socket download? I believe so, wget seems more stable than php socket looping, and I haven’t noticed any strange characters appearing in the output. There is one small problem of downloading or not downloading, as it wget appears to receive blank files sometimes, hence the reason I include a file length check.

Usage

Since AB.net has limited URI access, the wget wrapper is a good alternative. This would be good for any bloggers wanting load up offsite RSS/XML/API data, as there needs to be a way to obtain the data that isn’t on AB.net. Wget manages this, as well as caching the data to the file system.

What’s that you say? Javascript… sorry XSS is usually a no-no.

RyanA

Note: this was written 6 hours ago, but for some reason WP rejected the above code, until I renamed the ‘exec’ function to EXECUTE… weird

Code :: PleasurePoker

Friday, April 25th, 2008

This is going to be a day late, but wow that was a long day. Fridays are code days. Personally, I think Fridays are a bit slow in the anime blogosphere, I mean its Friday, time to shed those weekly ambitions and let is ride. It goes without saying that I don’t expect much reading or feedback on these posts, there won’t be pretty pictures. It goes without saying there should be a disclaimer on any code I bring out on Fridays, as it is merely prototype-level stuff. Of course, I wouldn’t mind touching up some hacks if there is a need for it… personally I can work with hacks [and meta-hacks]. Hopefully, the relations to anime, or animeblogging, will be apparent.

Pleasure Poking and Bongo Party

Today’s code is quite simple/redundant, and for anyone that doesn’t want to look at code, I’ll just say what it does. It is a python XChat script (yes, that crazy stuff), which merely listens for the triggers: !bongos or !pokeme, and does a /me command based on the calling nick. Lame right?

pleasure

This has no intention of being an end script, but it does give some insight into useful XChat events, in case anyone wants to do this sort of thing, but doesn’t want to spend 4 hours looking at the documentation. Here is the code:


__module_name__ = "BongoPoke"
__module_version__ = "0.0"
__module_description__ = "Shakes bongos, and pokes for pleasurez"

import xchat, re

def pleasurepoke(word, word_eol, userdata):
	if xchat.get_info('nick')=='PleasurePoker' and re.search("^!pokeme$", word[1])!=None:
		xchat.command("me pokes "+ word[0] +" with pleasurez *ehew*")
		return xchat.EAT_ALL
	return xchat.EAT_NONE

def bongos( word ):
	if re.search("^!bongos$", word[1] ) != None:
		xchat.command("me shakes the bongos for "+ word[0]  +" ~()~");
		return 1
	else:
		return None

def echo_cb(nickchan):
	def f(word, word_eol, userdata):
		if xchat.get_info('nick')+xchat.get_info('channel')==nickchan:
		    res=bongos( word )
		    if res == 1:
		    	return xchat.EAT_ALL
		    else:
		    	return xchat.EAT_NONE
	return f

xchat.prnt("Loading module for " + xchat.get_info('nick') + " in " + xchat.get_info('channel') )
xchat.hook_print( "Channel Message", echo_cb( xchat.get_info('nick')+xchat.get_info('channel') ) )
xchat.hook_print( "Channel Message", pleasurepoke )

The Technicals

So here we have two handlers, pleasurepoke and bongos, which merely do some checking of the word data (state) and execute the xchat.command “me” (action command, we all know this one, the one to not use is say). The third function, echo_cb, is slightly more complex, it creates a function f, based on nickchan and returns the function f, the handler (here it is passing stuff to bongos). In this way, echo_cb is a mini “function factory” which abstracts the flow control that chooses to execute the handler or not. ( This simply means we can restrict the handlers to certain channels, nicks, servers, etc )

Well, I think it is straightforward, so I’ll stop here. Also, some of this is repeated from a previous XChat python post. One step closer to being l33t in all those anime IRC channels right!? This is pretty general use though :p

Ryan A

melative reflects the thoughts

Thursday, April 24th, 2008

Today I didn’t do a weekly adventure post, though I plan on doing one for code Friday. Rather, while reading some of the blog list this week, I noticed a couple bloggers mention the use of MyAnimeList for twittering “micro-blogging.” It isn’t difficult to see why I am putting this post out there, but I think melative reflections need some light.

Credentials

One of the first mentions of melative here on AloeDream, was this post, but the concept of “reflections” came somewhere about month after Maestro gave me this blog, and I asked myself, “Is there a better way?” I got into blogging wanting to bring my cluttered notebook of small ramblings to the world web, but this *stares at WP* was just overkill for what I wanted.

I had been planning a web-app at the time, but I grew this unrelated idea of “short notes” in the mix of things. A previous 2004 application I coded did a small version of tracking my anime experience and notes as I went along (all in AJAX), but I gave that up when I went S.A Hikari-mode with school. Funny thing… melative reflections weren’t stimulated by that project, they were stimulated by episodic blogging.

When I started to blog, I did the episode to episode thing, but it was tiring. The snapshots were tiring, the summary was tiring, layout was tiring, and the only enjoyable part was writing what I felt about it ( the reflection ). It is a different time. If the short list on the right doesn’t do justice, here is an example of extremely undemanding reflecting…

rss

I want to repeat that extremely undemanding part. I’ll say it, I’m lazy, I can’t spend 2 hours on a post about ONE episode, or ONE volume of a manga. Still, why reflections? why melative? Even though the site is in rubble (SRSLY ごめんなさい), some things work, reflections I made sure of since I use them. *smacks himself for dancing around the questions*

Answers and Rambling

melative reflections are “directed at specific pieces of media“. So what’s the difference between MAL’s ‘related’ posts, or better yet, Last.fm’s journal connections (I respect that thing). Well, the words have different meanings (directed, connected, related). This isn’t so say a reflection is unable to connect or relate, because that is already built into melative with bbcode links (ie. [anime]Kanokon[/anime] or [creator]Katsumi Nishino[/creator] or [actor]Miyū Takeuchi[/actor] … don’ ask me why I used Kanokon references, because I entireli don’t know :P).

Why not Twitter or Pownce?

It’s feasible, but these sites are more about “events” in the life of a person. How many users post about the experience. melative aims to display the experience. I could Twitter, “I just watched episode 12 of True Tears, the chicken should have died” or I could reflect … “the chicken should have died” (directly at True Tears, on an episode, no.12). Very similar approaches, but it’s about organization of thought vs a stream of events, the latter being Twitter.

Lastly, one of the greater purposes of melative is the fact that MAL and Last.fm are different sites, but still toying with media. melative encompasses all media (or 13-14 areas planned). So a reflection doesn’t have to relate to another anime or manga, it can just as well be connected to an album, game, poem whatever. And just as important, reflections and melative do not eliminate the need for a blog; it is a tool, the informaiton is meant to be portable and accessible (code code and more code).

Anyway, the melative story doesn’t end with reflective micro-blogging, which it is a very small, almost unintended piece of the pie. It is a personal tool which fits precisely into the scheme of this animeblogging. Hence, the reason I use it.

Ryan A

is un-XChat haxor

Wednesday, April 9th, 2008

Well, for those who were in the #animeblogger IRC earlier today, I apologize for activating a test echo script in XChat, which apparently went ballistic (I wasn’t physically watching the channel and was totally unaware). The trouble was that this script was activated on another server window and in another [empty] channel, but it was handling every event, no matter the server. I just want to put my two-cents out there for anyone who is going to write a python module for XChat, and what NOT to do.

Teh Scriptz

echo like a monkey:

__module_name__ = "testing"
__module_version__ = "0.0"
__module_description__ = "Test mod"

import xchat

def echo_cb(word, word_eol, userdata):
	# DO STUFF HERE, I was doing xchat.command('say ' + word[1])
	return xchat.EAT_NONE

xchat.hook_print("Channel Message", echo_cb)

In the above code, I added a hook (event handler) to the print, for Channel Message. This only means, echo_cb is going to be called on the channel message event, great. The earlier problem arose because echo_cb doesn’t check it’s context, it just goes. I was under the impression that the plugin was context partitioned. Rather, xchat-python is global, so any loaded module will handle any event in xchat. This is good I guess, but I really wish I would have known about that (it isn’t in the doc).

a better method:

For those that may test stuff out, here is a better way to create handlers, so that they stay in “context” and not run amok.

__module_name__ = "testing"
__module_version__ = "0.0"
__module_description__ = "Test mod"

import xchat

def echo_cb(nick,channel):
	def f(word, word_eol, userdata):
		if xchat.get_info('channel')==channel and  xchat.get_info('nick')==nick:
		#DO STUFF HERE
		return xchat.EAT_NONE
	return f

xchat.prnt("Loading module for " + xchat.get_info('nick'))
xchat.hook_print( "Channel Message", echo_cb( 'YOUR NICK', "#CHANNEL TO ACTIVATE" ) )

What this manages is a small part of declarative programming; I am calling echo_cb with a nick and channel name, and echo_cb is returning the handler (f is an inner function being returned). The good news is that even on any channel message event, that if statement will prevent action unless it is from the channel specified and you are using the nick specified.

Had I used the second of these methods, there would not have been a problem since I wasn’t activating the module in AB or on IrcHighway. So, a good lesson.

Ryan A

ps. I wanted to write this earlier, but alas, school, which also made me miss the two UEFA Champions League matches ;.;