Userscript for Fetching duitang.com Album Images | 堆糖的抓图脚本

So userscripts are local scripts written by the user and executed in the browser. This process can be done by manually typing in your script in the console and hitting enter, but there are browser extensions to help you do this automatically.

The most famous ones are GreaseMonkey for Firefox and TamperMonkey for Chrome although the latter also supports other Chromium/WebKit based browsers.

With the help of such extensions, interesting things can be done. And in this case, it is about fetching the album images on duitang.com, a chinese website very similar to pinterest.com.

Instructions can be found here: https://github.com/kaneorotar/duitang-userscript

Have fun and Enjoy!

P.S. This is my first public GitHub repository. Hopefully more is on the way~
—————————————————Lang Cut——————————————————-
所以最近写了个GreaseMonkey/TamperMonkey用的脚本,用于抓取堆糖相册中所有图片的链接。
安装说明在此:https://github.com/kaneorotar/duitang-userscript

P.S. 这是本人第一个GitHub的repository,希望未来能增加更多~

How to Find Name of Music Using the Melody

So I came across this piano solo which I found familiar in an animation and wanted to know the name of it very badly. Although it is a BGM, meaning that there are other sound or voices going on at the same time, the melody is easily recognizable.
So I started looking for its name and here’s the tools I used:

1. Midomi (SoundHound)
This is a famous tool for finding music by singing or humming. It records at least 10s of sound using the microphone and then search in the database. For most song it works, however, since it is a piano solo this time, there was no result.

2. Shazam Encore
This tool is famous for finding out music with part of it. It requires recording the original song and therefore failed because there were other voices and sound effects in the animation as the music plays.

3. Musipedia Music Search by Flash-based Piano
Failed with my usual tools, I googled ‘how to find a piano music’ and found this to be the first result. I was not disappointed. In fact, I was even impressed because the website allows me to find the music by playing the melody! I was not sure about the notes so I tried several times. Finally I was able to recreate part of the melody using the simulated piano and proceeded to search. It took a little while (about 1 min) but there were results with Youtube videos of the music being played! I clicked the first one and Voilà! There it is! It’s Claude Debussy’s ‘La fille aux cheveux de lin’!

That sums up my music seeking journey and I wish that everyone can find the name of the music they like~

P.S. For more related tools, check out this wikiHow page.

稍微吐个槽| Just some thoughts about the rumors of 4G network

I’ve recently been seeing posts talking about how fast the 4G network is going to be and how ‘absurd’ the prices for data packages are depending on the ‘fact that the allowance could be depleted within several seconds.
There are mainly 2 misunderstandings in here:

    1. Mb/s is not MB/s

Some people are not aware of the differences between Mbps and MBps. They are quite similar, however, the relationship between them is actually:
8 Mbps (Mega bits per second) = 1 MBps (Mega bytes per second)
Generally the bandwidth we see in every advertisement are using the Mbps as it obviously tends be a bigger number.

    2. Being able to reach a higher speed doesn’t mean using your allowance at that rate

Some people are saying things like ‘I pay 40 RMB for 300 MB data allowance, which can be used up in a few seconds under the 4G speed’. Despite the fact that he made the aforementioned mistake, he is also assuming that during his time of using the network connection, data will be constantly downloaded to his phone at the highest speed causing his remaining allowance to shrink at the same speed. This can be true if he is trying to stream an online video, which is an unwise action considering the allowance is relatively not big. Most webpages are only within several hundred kilo bytes in size and applications that utilize Internet access tend to consume maximum allowances of a few mega bytes per day, which is acceptable.
In a nut shell, what the increase in speed does is simply reducing the time for data to be fetched to your phone.

J-无线网络问题诊断-1

唔,这两天被无线网折腾得头晕。于是刚刚终于解决了总是在“连接上→掉线→看似连接上其实没有→已连接上但是无线标志是叉叉→掉线”的恶性循环~

成功解决这次问题的方法是:

1.网络邻居属性-无线网络属性-无线网络配置
先在“用windows配置我的无线网络设置”前点勾,然后设置你要连接网络的密钥,确定是WAP还是什么类型,然后输入密钥,点确定,这时候图标就会显示连接!(但没有结束,如果不进行下一步过2 3分钟就会变成未连接,但还能上网,在过一会就彻底断开了)
2.现在,再进入网络邻居属性-无线网络属性-无线网络配置,把“用windows配置我的无线网络设置”前的勾取消,然后就应该好了,如果还有问题,只说明前面环节设置不对(比如密钥设置1 2 3之类

按照这两个步骤,俺的恶心循环结束了,万岁!虽然不知道这个是为什么~o(╯□╰)o

I’m Back!

Long time no see. It’s been almost a year and I hope that I have not disappointed anyone who’s interested in my blog. Hopefully I’ll start blogging regularly from now on.
Currently: Busy doing assignments and projects. Will try to learn more about WebGL and implement something like MabinogiWebVer(Prototype). 😉

co.cc挂了 | co.cc is now dead

I didn’t realize this a few days ago when I was unable to access PMangar. I though it was the server’s problem but I managed to login to the control panel. To find out the reason (with an assumption already in mind), I googled co.cc and as expected, saw another post talking about co.cc subdomains disappearing.
OK, so that’s all about the topic and let’s just hope that dot.tk is never going to be in the same situation.

Bad Apple ASCII Javasrcipt字符画版| Bad Apple ASCII Javascript

Bad Apple ASCII 版影绘简介

Bad Apple (坏苹果) 影绘是东方同人作品中的经典,经过后期加工也出现了很多版本,其中ASCII码版的字符动画是其中一大主力,并且在各个平台都有成果:视频,网页,DOS,PSP,Telnet服务器,甚至还有启动盘。
于是出于练手的目的先用Javascript (字符动画播放)和HTML5 (音频播放)实现一番。

传送门:http://rotar.tk/ba

主要工具

  1. 帧提取:Free Video to JPG Converter
  2. 字符化:ASC GEN 2.0
  3. 抽音轨:Free Video to MP3 Converter

体会

目前从效果来说马马虎虎过得去,3:39的动画源文件15.9MB,按30FPS的帧率抽出一共6572帧66.5MB,转成80×35的字符是17.9MB,自己再进行压缩到4.38MB,最后经过PHP的GZip能压缩到1.4MB。

影音不同步是个大问题,目前在想办法解决,大致的办法是使用Audio的currenttime这个属性来计算当前应该达到的帧并且修改帧的索引值。

本来是想用C++来写的,结果发现长时间未使用(plus根基不牢)竟然连读取txt文件都成了大问题,果断要找时间补课了。

Update 2012.08.15

测试了一下IE各版本下的表现,果然差得惊人。于是对IE进行了特殊处理,包括以下:

  1. 把” “(空格)改成” ”
  2. “\n”换成”<br />”
  3. IE7以下版本对于没有内容的”<br />”会直接忽略,于是只得在前添加一个”&nbsp;”
  4. 由于IE不支持ogg格式,当检测到是IE时,跳过音频控制并”建议使用Chrome” XD

Update 21:18

多浏览器支持果然是门学问,这次本以为只有IE会成问题,没想到换成火狐(Firefox)试了试出现了因为字体不是等宽(Monospaced)而产生的严重错位。问题的根源在于之前给pre的标签(tag)在CSS中设置的字体只有一个Courier,这在Win7和iOS上都没问题,可是Firefox并没有这个字体,所以才使用默认字体顶替以至于排版混乱。刚更新的CSS已经添加了6个等宽字体以确保任何系统下都能正常显示。

此外,刚把Chrome的22 Dev版下了来测试发现页面的声音出不来,起因不明,准备再下个21的Beta做对比。

股沟的提示被墙字段功能 | Google Notifying Terms Blocked in China

下图是试图搜索“学习”时 Google 的提示,有兴趣的话,还可以试试:“长江”,“体温计”,“胡说”,“毛病”,“天安门”,“广场” 。

Searching "学习" in Google.com.hk

Google

之前一直用着.co.uk没改回来,最近换回.com.hk之后看到了这喜感的一幕。

G·FW的字眼屏蔽的已经开启许多年了,作为搜索引擎的大家,股沟当然是深受其害。每每遇到“网页无法显示”,对于相对“较高端”的电脑用户来说,当然能够理解问题的真正起因,可是一般用户就会直接把责任全部挂在股沟的头上了。

添加这个提示功能大概一方面是为了撇清关系,另一方面则是对于G·FW的抗议。

GFW

这个就不做太多讨论了,公开的谈论貌似还是违法的,跨省之类的实在是怕怕。

不得不说信息公开神马的实在是个大问题,虽然考虑到某些隐情对正·腐而言还是Invisible为妙,但是连搜个“学习”,“体温计”之类的在正常不过的词都要面对“该页无法显示”实在是有些过分了。

另外值得一提的是这个过滤机制有些欲盖弥彰的感觉,就好象反黄软件被人拿来查找成人网站地址一样。

嗯…还是 PMangar | Yeah…PMangar Again

上次提到了 PMangar 会占用大量内存而导致浏览器崩溃,于是经过测试了各种清理内存的手段之后,决定还是放弃这方面的优化。虽说根据 Kindle 的浏览器配置文件wrs.ini来看默认设置是内存达到70MB的时候重启浏览器,但是实际使用总感觉70MB来得太快了……如果漫画本身是双页的,那么貌似不到10页就重启了,初步结论是变量清空(blah=””)对实际内存占用并没有神马影响。

于是接下来要改进的就是使用Cookies,这样即便浏览器没能撑住,也能保证在重启刷新页面后能够恢复到弥留之际的页面状态,可能的话还可以尝试涉足一下数据库,弄个用户注册登录神马的OLO。嗯,就写到这里。

————————Lang Sep————————–

Finally an English version post after a long time, well, this is simply because the Chinese version of the post is not so long so the rephrasing work will not trigger the limit of my laziness.

So lately I’ve been improving the online manga viewing website – PMangar, which is now almost working to my expectation. After a lot of logical improvements and the enhancement of Javascript, jQuery and some ugly UI designing, the site is now capable of basic features like manga searching, preloaded image viewing and keyboard shortcut. Even though more functions are going to be added, there is one major problem that I need to fix for now: the restart of the browser when memory limit triggered. Up to the latest version,  all data are stored in the cache and, after the restart, will be completely gone. The user will have to start from the first page and repeat all the inputs to get to the last page before the sudden death of the browser.

Therefore, I’m planning to utilize the Cookies of the browser and put the info needed for crash store in it. It might even be a good chance to have a taste of the MySQL database and try to implement some simple signup,login and comment system.

That’s me.

继续PMangar | PMangar Keeps Going

又是一番折腾,算是把CSS弄清楚一些了。首页和浏览页也勉强算是弄了个比较美观的UI,不过高兴的是首页顺利通过W3C认证了,无论结果如何,在过程中算是把规范弄得比较清楚了。

最新版PMangar已经上传到了ver0.003,目前实测在Kindle上依然有个内存不足的问题,虽然设法在浏览中删除了6页之外的旧内容,不过实测表明大约近20页之后浏览器会因为内存的原因重启,这时候Cache数据就完全丢失了。目前准备了解一下Javascript的内存清理方面是否还有优化空间,以及,把保留6页内的内容改成前5页外的全部清空试试。

几张截图:

顺带一提,做完这些的时候偶然在jsfiddle看到了jQuery Mobile,然后立马震精了,这货已经实现了近乎所有移动设备上的浏览器的HTML5兼容(Kindle 3赫然在其中),然后UI方面也有了很不错的兼容各种设备的设计器,不得不说对俺自己设计的想法是个巨大的打击。不过既然工具在此,就可以加以利用,之后的列表一类的功能估计就可以用jQuery Mobile来做了。