System & Nethood


System & Nethood15 Jun 2009 07:03 pm

Last weekend TwitterF0x was upgraded to version 1.8.x . As they have not yet integrate translate functions, or take/endorse my code, I plan to redo the hacking again.

Guess what ? A new license file added since veriosn 1.8.0 make TwitterF0x Proprietary. Thus I am not legally accepted to do any tenhancement nor investigate at the software.

That shits! NaanStudi0 used to place LGPL inside the scripts of TwitterF0x 1.7.x or earlier, what have changed their mind ?

As far as I know, TwitterF0x was not for profit. Are the NaanStudi0 guys going to inject AdM0d into the Firefox plugin, like what they do last month in TwitterF0n for the i-Phone ?

I would say that last month TwitterF0n was degraded into crap. Not because of having Ads, I am not that mean, but because of broken layout. Naan Studio has released two updates after the crap version, non of them addressed the layout problem. Do they care about users ?

Another possibility is they hate Fanfox, they don’t want to be cloned by the Chinese copycat any more. I can understand if this is their real cause, yet not a good / appreciable one.

So, if I have to continue the hack, I have two choice:

1. Fork from twitterf0x 1.7.x

2. Hack Fanfox and contribute to fanfox instead

Any idea ? Please throw to twitter.com/bencrox

( P.S. According to the new SLA, twitterF0x , twitterF0n and NaanStudi0 are their 0wn trademarks. Yeah! I am not affiliated with these traders. Would be happy to misspell all TM shit. )

System & Nethood10 Jun 2009 11:11 pm

If you don’t care about the story, here is the file, eat your own dog food to install. ( some screen shots here TwitterFox + gTranslate)

—-

After attending Barcamp Bangkok #3 , I have added some new twitter friends all over South East Asia.

In order to read their tweet, which may be in Thai, Vietnamese or whatsoever language I don’t know or that I am not quite familiar with ( such as Japanese … ) , I use the build-in translation function in Tweetdeck / Nambu in MacOS.

Problem arise when I switch to a PC, in which I am used to tweet with Twitterfox. Twitterfox does not yet have embedded translation function. Although Tweetdeck can be installed into Windows, windows itself sucks enough. I don’t what to open one more app and kick start the AIR runtime. Another reason is that Twitterfox is a firefox plug-in, I can use it in Windows, MacOS, Linux and even BSD desktop and keep similar ( err…. ) working experience.

So I decided to h… Hey! I decided to look at the change-log first .

Don’t reinvent the wheel before you hack things, that sucks.

But what I had found is the Naan Studio guys in behind, are shifting their focus on TwitterFon, another piece of software, or an iPhone App, that I use a lot. Peer comments also reveals that TwitterFox is not to be made complicated.

OK, time to hack.

First, most firefox plug-ins are just javascript and XUL files in a zipped archive. Just find out the directory path and unzip files in chrome, most likely you can read and edit the source. For my TwitterFon, the file path is somewhat like:

W:\Document and Settings\%USER%\Application Data\Mozilla\Firefox\Profiles\%your.default%\extensions\twitternotifier@naan.net\chrome

I just use Windows search to find TwitterFox.jar , and that is it.

If you have installed firefox and twitterfox, just want and dare to test my crap hack, just download my file and replace the original one. Needless to say, you don’t back up, you bare your own blame.

For me, I unzip it with 7zip , and check out what can I do.

Obviously, “content\twitternotifier.js” should be the main file for fun.

What I want to do is to

1. Add a new item to the context menu ( right click ) , like the retweet stuff.
2. Use Google translate API ( RESTful part ) to do the job.
3. make the translated result usable for retweet
4. auto detect original language ( google api takes care about it ) and user preferred language ( as set in browser )

It turns out more files are involved, including i18n thingies, for point 1, which I spend most of the time to clean up tonight.

For point 2, just read Google’s document. It is by far easier than what I used to work with ( babelfish… ) 6 years ago. I add this follow code within 30 minutes, most time are wasted for my many many bugs and typos and thus firefox restarts.

( this is added just after the retweet function )

translate: function(target) {
var tweet = target.parentNode.node;
/*I don't care what "target" is, the code in above tells me how to get the "tweet". */
var req = new XMLHttpRequest;
/* Ajax translation kind of stuff */
req.open('GET', GTranslateAPI + tweet.getAttribute('text') ,true);
/* constants have be defined in the header */
req.onreadystatechange = function(){
if(req.readyState == 1)
req.setRequestHeader('Referer', Referrer);
/* google requires developers to state the referrer, although the function would work without it*/
if(req.readyState != 4) return;
result=eval('('+req.responseText+')');
/* json stuff */
r=result.responseData.translatedText;
/* fixit: yeah I am super lazy, even there are some available functions to normalize the result, I do nothing */
t=document.createTextNode(r);
p=document.createElement('description');
p.className = "twitternotifier-message-translate";
/* add some styling, thus the CSS file is also changed */
p.appendChild(t);
tweet.appendChild(p);
/* fixit: this part is definitely sick, may be CSS problem exists */
tweet.setAttribute('text',r);
/* How DIRTY ! :DDD , translate and retweet result is that easy (3) */
};
req.send('');
},

For point 4, just read the setting of the browser is not enough. Google translate does not know ALL languages.
Even worse, it takes only first two letter in locale for most langauge. Chinese is the only exception. The worst thing ture out to be zh-HK, which I am suppose to support even though I don’t like to use, is not supported by Google Translate. Thus this is the REAL Hack, if anything in this post means to be a hack :

( in the header )

var tolang;
switch(navigator.language) {
case 'zh-TW':
case 'zh-HK':
tolang='zh-tw';
break;
default:
tolang=navigator.language.substr(0,2);
}
const GTranslateAPI = 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&langpair=%7C'
+ tolang + '&q=';
const Referrer = 'http://twitterfox.net/';

And that’s it .

Wait, I have also changed the behavior of Retweet , from
RT: @someone:
to
RT @someone

What is the point for adding two colons ? Funny ? Waste two more precious digit space ?

Moreover, I add a “zh-HK” locale.
Otherwise, HK users ( not me ) will be depreciated to be broken Chinese (破體中文) readers.

( Doh!)

By the way, I know there are many many bugs as you can see in the above code snippets ( at least look at the Fixits ).
I don’t care too much, but I may update if have time.

Hope that the Naan studio guys will read this post, throw away my crap, and implement something really works.

Before that, my dog food might be good enough for you darn lazy geeks.
You can always hack it better. I hope you will notice me after tasting your own shit.

The above code is a damned deviate (dd). Never attribute me if you copy and distribute. Yet I don’t care if you make it even more horrible and throw me some tipjoy to fix it. I will NOT fix it for you. I will fix it perhaps for my own pleasure.

If your firefox is corrupted by my file, please feel free to shout out your foul words to @bencrox.

System & Nethood24 Feb 2009 06:59 pm

I bet #gmail will sky rocket in twitter today ( 2009 Feb 24 )


( the above is a dynamic graph, if you are reading RSS, try to look at this link instead )

System & Nethood12 Feb 2009 04:33 pm

Here is a story of a lazy man.

1. 2 min b4, I want to make a short url service for my own.
2. 1 min b4, I surf for solution, and someone suggested you may not have a database.
3. I have a (few) database(s), but I am willing to pump it, what then ?
4. I don’t even want to setup accounts, what then ?
5. 30sec later, I add this line to my dot-htaccess:

RewriteRule ^is\.gd/(.*) http://is.gd/$1 [QSA,L]

( of course I have deleted it after trial… and, you can replace the first clause with something like ^\.(.*) and any other capable service in the second clause )

6. What then? Before I delete the RewriteRule, http://bencrox.info/is.gd/evil is equivalent to http://is.gd/evil . And that works

Yes I know, it maybe fairly simple to setup something like http://bencrox.is.bad/blah , and get rid of all those spam urls others pump in and taint your DN ( because of yours own evil/unauthorized endorsement… ). But if you are lazy enough and being a console man, a one liner RewriteRule is always your candy.


What’s more ?

Hmm… say you know how to play with curl ( and any cgi stuff ) , you can redirect the short url to your cgi and RegEx match / show preview(s) / do any evil restructuring ( perhaps by … jQuery ? ) to check and claim others resources.

Conclusion ? You don’t need to learn any API to play with, in order to add functionality with your DN. ModRewrite is the ultimate answer.

Mobile11 Feb 2009 07:15 pm

This is how I learn my i-phone by accident.
Just type in some note, and wonder why the font is changing.
What then ? Search Google . So I can also get rid of the “handwritten” style font in i-phone.

OK, by reading the above, I want to know how other do Screen Cap.
1. Ready ?
2. Search !
3. Go through results until getting things done.
Here is one entry about how to do screen cap in iphone.

Mobile24 Jan 2009 01:35 pm

Hmm, this post is not typed on the iphone. //think

1. I have installed the Chinese Lunar Calendar, as required by Mum and commended by Daisy.

2. To get connected with some know local i-phone apps developers, I install the… free version, of Walkamap.

3. Facebook for iphone, a no-brainer .

Then, updated status on FB via iphone, add some bookmarks ( hey ! no sync please ! ) , test some of my sites ( and get disappointed by the UI performance on i-phone ) , and last but not the least, heavy edited my PBX so that my iphone
would just serve as a text messaging / roaming to VoIP agent.

Any more suggestion ? ( ff/fb to me pls ! )

System & Nethood20 Oct 2008 12:10 pm

We all go Expos, do demos and roadshows. Sometimes we need to set up for field training, ad-hoc site-office.

But… have you ever Get Stuck by the expensive LAN line and unstable WiFi ? Or that you simple want to save your valuable time?

I use a lot of the 3G data network. And now, with cheap and fast 3G infrastructure in Hong Kong, please just forget about the unsecured WiFi ( Don’t you know how easy to hack and log wifi channels ? Ask Youtube, they show how you by video)

But to use 3G for REAL work, you cannot rely on a simple 3G cell-phone plus bluetooth ad-hoc network. That’s unstable and expensive.

At least, you need a 3G data card and 3G data SIM. Perhaps you can find cheap 3G card for 1.5k HKD . A pre-paid data SIM can be as cheap as 120 HKD. Thus the minimum entrance price is 1.6k HKD. If you are willing to pay 200 HKD per month and sign for 2 year contract ( thus 4.8K ) , you’ve got a free ( subsidized ) data card and very limited throughput access ( 60Mb per month) .

Hey! Still not feeling good about the price ?

Now here is what I am considering to offer:

A preset 3G data card / SIM / router ( wifi can be disabled, has 4 LAN ports ) setup, NO throughput limit, 700kbps to 5Mbps down link ( average 1.2 Mbps in new towns, over 2 Mbps in Business area ) for rent

Say, HKD 500 per 3 days. ( Hmm… plus 500 deposit ? )

Advantages:

1. Very easy setup, just supply electricity and plug your LAN cables to it.
2. Support application service, such as Video cam / surveillance systems. ( I am very experienced in setting up Voip / Video systems )
3. A lot cheaper than renting LAN from Expo/Training centers, such as HKCEC . ( They will charge you 1K ~ 3.6K per event, while the network is NOT stable in fact ! )

Any comment ?
( Interested people please contact me at lxb [at] hkday [dot] net , of course you may negotiate for the price and term. )

System & Nethood& Read News13 Oct 2008 11:08 am

[Update : The issue seems to be relieved. The following are *real record* of what evil things happened in between 12 Oct - 13 Oct ]

MartinOei blogs that Yahoo HK’s Image search is probably interfered by PRC’s Golden Shield ( the GFW / keyword blocking system ).

I hope it will be relieved very soon, otherwise it would be Yahoo’s own Doomsday.

Let the links speak for themselves:

1. Search 64 in Yahoo HK / Yahoo US Image
2. Search 65 in Yahoo HK / Yahoo US Image
3. Search 64 in Google HK Image

64 means June 4 massacre, or the TianAnMen Incident in 1989. In fact there are lots of non political content contains “64″, the word itself can be as natural and neutral as 65. Up till now, Yahoo HK image search flows me lots of blocked items ( an red [X] , usually coined as the pork bun ) for “64″, but no problem for “65″. This is totally non-sense, meaning nothing other then brutal Political interference.

And that is absolutely not acceptable.

According to Martin, lots of other keywords are censored.

Many of them are crucial for public interest, such as those related to the recent Poisoned Milk scandal. ( Ref )

Can we sue Yahoo HK for “Access to computer with dishonest intent” ?

Furthermore, will Yahoo HK’s auxiliary, such as popular photo sharing site Flickr falls down ? Yet not so far, Please DO BACKUP your Flickr account if any worry !

How about Yahoo Knowledge plus ? Lots of students just learn from that mess of interpretation. Will anyone speak up the truth got recorded and therefore censored by the Chinese agents ?

Tell you, I was once annoyed by the agents for a year, even in HK. That’s a hint about why this blog has been blocked by the GFW since 2004. ( It seems to be relieved just months ago, to my pleasure )

Related links :
0. Long long ago, Flickr HK had already leaned to HK Govn’t ’s indecent policy , refer to Deki’s blog and Oiwan of Inmediahk
1. First discussed at HK Golden
2. Very soon, EVCHK wiki get a page
3. Some more blog post
- Kirk Lim
- Jacky See
- MartinOei and Me as mentioned…
4. Facebook group, as you can expect ( but I am not interested to join … facebook is such an opinion sucker, dudes not for action )

Mobile29 Sep 2008 06:28 pm

This is for the Lazy guys only!

pppd stable 2.4.4 is already two years old. Don’t expect your pre-compiled pppd can be patched easily. I have to set up a virtual box for compilation for my own EEEpc’s sake.

For the 3G network bogus WINS / DNS issue, in case you are using EEEpc with ubuntu like me, you can try my compiled pppd.

After downloading, do this:

chmod 755 pppd

It is up to you to check against virus and malware.

sudo mv /usr/sbin/pppd pppd.backup
sudo mv pppd /usr/sbin/pppd

If it does not run ( wvdial something ) , just replace it with the backup.

I will test more (with different Netbooks, hopefully) and make some trim down ( possible from 600k -> 300k ) before further announcement.

Mobile29 Sep 2008 11:01 am

Get bogus DNS when connecting ?

Last year I sent a fix for pppd to a router vendor. It seems the discussion had gone open a lot.
That’s good, I don’t need to care about NDA any more.

Please refer to this thread.

Notice that Pete’s latest suggestion is to accept 3 MS-WINS. The patch posted accepts 2 only.

In HK, I do find some cell pumping 3 MS-WINS. So, it would be better modify it before compile. Another approach I have tried is to cache DNS address of the specific profile ( carrier + APN ) to be used. That was my solution dated in Oct 2007. But it seems the DNS problem can be solved by future pppd/distro package update.

Next Page »