Archive for the 'Uncategorized' Category

Code :: Greasemonkey Flash

Friday, May 2nd, 2008

Here is a quick one for those who need to remember things, who browse many web pages; these are flash cards.

Premise

I had this idea a couple weeks ago after not finding a great Japanese vocabulary flashcard site. I have lists in XML and spreadsheet format, and could very well make a small app that handles these things, but then there is simple Javascript and Greasemonkey. So I thought to myself, why not flash a card upon opening every web page (this is adjustable by Greasemonkey). I’d say most people open 500+ pages per day, and this turns into a fair amount of integrated studying. The best part yet, is that there is no restriction on the list, it can be anything really (biochem, languages, formulae, mp3 sound files, images, etc)… flash card away.

Code


// ==UserScript==
// @name           AlwaysFlash
// @namespace      AtmosphereIC
// @description    Flash Card roller
// @include        http://*
// ==/UserScript==

function FlashDeck(h){this._init(h);}

FlashDeck.prototype={
	// set of cards
	dictionary: new Array(
		"一	いち",
		"个	ぼう",
		"丶	てん",
		"丿	てん",
		"乙	おつ",
		"亅	はねぼう",
		"二	に",
		"亠	なべぶた",
		"人	ひと",
		"儿	にんにょう",
		"入	いる",
		"八	はちがしら",
		"冂	まきがまえ",
		"冖	わかんむり",
		"冫	にすい",
		"几	つくえ",
		"凵	うけばこ",
		"刀	かたな",
		"力	ちから",
		"勹	つつみがまえ",
		"匕	さじのひ",
		"匚	はこがまえ",
		"匚	はこがまえ",
		"十	じゅう",
		"卜	ぼくのと",
		"卩	ふしづくり",
		"厂	がんだれ",
		"厶	む",
		"又	また"
	),

	// display a card at random
	show:function(){
		sI=Math.floor(Math.random()*2);hI=sI>0?0:1;
		card=this.dictionary[ Math.floor(Math.random() * this.dictionary.length) ].split("\t");
		$('flashcard').innerHTML='‘ + card[sI] + ‘	‘ + card[hI] + ‘‘;
	},

	// inject styles
	styleNode: function(styles)
	{
		var se = E(’style’);
		se.type=’text/css’;
		se.innerHTML=styles;
		return se;
	},

	// styling the flashcards
	style:”\n\
	#flashcard\n\
	{\n\
		position:fixed;right:40px;top:40px;\n\
		z-index:1000;background:#222;\n\
		max-width:360px;\n\
		color:#fff;text-align:center;padding:10px;\n\
	}\n\
	#flashcard *{line-height:36px;font-size:32px;}\n\
	#flashcard a{color:white;}\n\
	#flashcard a.show span.hide{display:block;visibility:hidden;font-size:0.7em;}\n\
	#flashcard a.show:hover span.hide{display:block;visibility:visible;}\n”,

	// listeners
	listeners:null,

	// generic listener for clicking on a card
	click:function(e,f){return function(){f(e);}; },

	// constructor
	_init:function(handler){
		bod=T(’body’)[0];
		bod.appendChild(
			_p(_p(E(’style’),’type’,'text/css’),’innerHTML’,this.style)
		);
		bod.appendChild(
			_p(E(’div’),’id’,'flashcard’)
		);
		card=$(’flashcard’);
		card.addEventListener(”click”, this.click( card , handler ), false);
		this.show();
	}
};

// create instance on event
window.addEventListener(
	“load”,
	function(){ new FlashDeck(function(e){e.style.display=”none”;}); },
	false
);

/*
	SOME UTILITY FUNCTIONS
*/
// short for get by ID
function $(e){return document.getElementById(e);}
// short for get by tag
function T(t){return document.getElementsByTagName(t);}
// short for create element
function E(n){return document.createElement(n);}
// short for modifying property of element
function _p(E,P,V){ E[P]=V; return E; }
// short for modifying style property of element
function _sy(E,S,V){ E.style[S]=V; return E; }

Technicals

Basically, the FlashDeck is a simple class and pretty straightforward. It manages the minimal for what I wanted, flashcard per load. The addEventListener calls the defined function, which simple instantiates a new FlashDeck. The function being passed to the constructor is a handler which acts based on clicking the visible flashcard. It takes one argument ‘e’ which is the flashcard HTML element. The given code sets the element’s style to display none, so it disappears on click. Note: the dictionary is a tab delimited array, but it could be mutli-dimension or whatever, minor changes.

I think this has good expandability, which I will probably dive in when I get more free coding time (spent mostly at melative), but I like the concept. Here is the download, btw.

Ryan A

note: dictionary shown is kanji radicals of 1 and 2 stroke.

Real Girls

Wednesday, April 16th, 2008
Lars and Bianca

Yesterday, I spent the evening watching a movie with a couple family members. Lars and the Real Girl (imdb), reminded me [in premise] much of the debated escapist reality which general viewers, otaku, hikikomori, and NEET create in stimulation to mixing anime, manga, and life.

We have a presumed adult male who has a delusion about Bianca, a “Real Doll”. This entirely rang “Japan”, since we have all seen these love toys abundant on Mr. Choo’s and other sites. Unfortunately or not, the plot line soon sharply turns from any assumed building which had been taken place. Lars, though seemingly a hikikomori (but lacking the Japanese interest), is not, and his delusion about Bianca, is far from the notions one might get of another purchasing such a doll (pleasurezorz).

The film yields awkward, funny, and compelling moments, but it really makes these issues of escapist reality among anime fans seem quite feeble. It is an interesting watch that many could relate to, but not necessarily identify with, and I do recommend a viewing if one has the time and chance, as it is not entirely unrelated to the world of anime and manga.

Ryan A

In a related note, Ryan Gosling, the main actor, has appeared in also in The Notebook and Half Nelson. I recommend both, especial for HN’s slice-of-life appeal, and The Notebook’s heartwarming story.

Kyouran Kazoku Nikki

Saturday, April 12th, 2008

I can’t believe this, how is this interesting? It might be, but watching this video was just too funny.

KKN

I don’t think I will keep up with “Frenzy Family Journal/Diaries”, but I’m soo checking out the first episode. It has “Wizard of Oz” written all over, but with extra characters, such as a Starship Trooper, alt.persona loli-patch, and a tentacle jelly creature. Apparently it is sourced from a light novel series, so who knows how it will be. Hopefully, if it is “smart-funny”, like Keroro, it will be enjoyable, but who knows. The whole family grouping thing is a sort of meh premise (reminds me of Adams Family). Omni will probably have First episode impressions today. I’m hoping for a 720p version sooner or later (me thinks the eccentric is better at high res). My own reflection soon.

On a totally unrelated note, I love the French press.

Ryan A

Author on Hung [on Special A]

Thursday, April 10th, 2008

I rather enjoy Author/zaitcev’s “on” posts (I’m not sarcastic about enjoyment).

Recently Author says:

…anything that reminds of Naruto ep.22 is good, amirite?

I suppose I agree, but more importantly, one way conversations FTW!

fuukohave a starfish, she’s a starfish

Ryan A

Why the ABA can do no wrong?

Saturday, April 5th, 2008

… and what the blogging community can do right. I know I stated my next post would address this, but it is this one instead, and it will actually be pretty quick.

One of the foremost arguments against the ABA I’ve read about would be that the “popular will prevail.” Whether that is true or not will be seen, but I don’t see why not participate; we [blogoids] can make this true or not, but it isn’t easy. We all are in and out of different blogs but usually stick to some “regulars” (the ones I aggregate are in Recommended). Doesn’t that seem quite confined though?

Fine Fine Fine ConfinementSome confinement is sexy… thank you Oikawa

There are so many more blogs out there, especially off AB.net, I’ve known it, and I think it’s a universal feeling, since that is how the Internet is (infinite information). I do feel blogs with the most regulars will get the most attention in the awards, but it is an open invitation for expansion. I went back to animeblogawards.com the other night, and decided that my power is limited, but I will go regulare on a some of these nominated blogs. Why not? I mean one of these nominated blogs could be the next best thing to baby-making, relatively speaking.

Shana and BabiesSpeaking of babies… she still wants answers

I don’t know how the awards may fair, but it will be interesting to find interest without premise. It’s the one thing I can do that may turn the predictable outcome, to something of vigor and flare. The more bloggers go “off their reservation” the more fiery things will get.

Here’s to some hott awards. *sakebombz*

Ryan A

edit: I should have checked some recent stuffs, lolikitsune and Josh have recent related posts.