Sunday, October 25, 2009

Let It Snow!

Almost a year ago, I posted a post about how to add falling snow script on my another blog (I didn't create this blog yet).



This year, I pulled the time ahead for another month. I added four buttons that you can more easier to add on your Blogger blogs.

Choose one you like to put on your Blogger blogs.

Collecting Snow + Snowman


Collecting Snow + No Snowman


Non-Collecting Snow + Snowman


Non-Collecting Snow + No Snowman


You can read more about the scripts or the raw HTML code at that post.

Saturday, October 24, 2009

Favorite Music of Blogger Profile

I have been wondering how I could edit my favorite music section in my Blogger Profile. One good way may be the Last.fm's top tracks feed.



It's an XML feed (e.g. my overall feed), you need to process it. An easy way is to use XSLT processor, xsltproc, you should be no big deal if you are a Linux user.

Linux User (Mac also?)

I have already written a Bash script and a template for use.

Please download lastfm-tracks.sh and lasfm-track.xslt.

Put them together and run the script, you will get something like:
$ ./lastfm-tracks.sh
Your Last.fm username: livibetter
                               
Choose type of your tracks:    
 1 - Last 7 Days
 2 - Last 3 Months
 3 - Last 6 Months
 4 - Last 12 Months
 Other - Overall

Select?
--2009-10-24 16:24:37--  http://ws.audioscrobbler.com/2.0/user/livibetter/toptracks.xml
Resolving ws.audioscrobbler.com... 195.24.233.55
Connecting to ws.audioscrobbler.com|195.24.233.55|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/xml]
Saving to: “lastfm-tracks.xml”

    [    <=>                                                                                                                                       ] 37,546      33.3K/s   in 1.1s

2009-10-24 16:24:40 (33.3 KB/s) - “lastfm-tracks.xml” saved [37546]

===== BEGIN =====
Lebe lauter, Fieber, Das Beste, Optimist, Ohne Dich, Meer sein, Misery Business, Nie genug, An Sommertagen, Augenblick am Tag, Mitten unterm Jahr, That's What You Get, Come to your senses, Ich wünsch dir was, Ich Lebe, Anders, Revolution, Stupid for You, Free Loop, Engel fliegen einsam, Spell, Umbrella, Traffic, Orchester in mir, Reine Nebensache, Seite Eins, Nie zu spät, Better Off Alone, Scherbenmeer, Geile Zeit, Warum, Wenn die anderen, Glücklich, Voice on the Radio, Regen und Meer, Nein danke, Dieses Leben, Ich verschwinde, Zu Weit, Sonne hinter dem Nebel, So Wie Jetzt, Das Ende vom Kreis, Say It Again, Unendlich, Unsere besten Tage, Um bei Dir zu sein, In Zeiten wie diesen, November, Unfold, Kurz vor der Sonne
====== END ======

You can also open the result text file lastfm-track-result.txt.

I don't know if Mac user have xsltproc or not, I believe it has. Mac has no problem with shell script, this should also work.

Windows User

Please follow the instructions in this page, Installing an XSLT processor.” I didn't try it.

Once you install it, you should be able to use it. You need to manual download the feed from Last.fm and run this command with the XSLT template alongside:
xsltproc lastfm-tracks.xslt DOWNLOADED_FEED.xml

Final Note

If I wrote it in Python, there should not have much problem and could have a GUI, but I don't think it's worth. I want to make it fully automatic not just semi-automatic. But I also need Blogger API to support Profile update, unfortunately, it doesn't support that at this moment. I am not sure if it will in future. I don't want to trick Blogger, which means simulating your editing in that page.

There is also a other sections like movies and books, but I don't know any websites provide similar feed as Last.fm do for music.

Thursday, October 22, 2009

<a name="Damn">Blogger Drives Me Crazy!</a>

If you know about HTML, you probably had use:
<a name="Damn">Blogger Drives Me Crazy!</a>
blah...
blah...
<a href="Damn">Go to Blogger Drives Me Crazy</a>
blah...
blah...

So the code above provides a in-page link. I tried to write a blog posting with that, Blogger's Compose mode made me crazy!

You have to enter the HTML code name="Damn" in HTML mode, that would be fine as long as you don't switch back to Compose mode. If you do, your code will be inserted with new attribution href and a link will be assigned to it. That wasn't the result you would like to see.

So basically, you must stay in HTML mode. However, sometimes, WYSIWYG is too convenient. Even you are a HTML nuts, you may accidentally switch to Compose mode. If your page is still Draft, God bless you! Your code has been messed up! Because of autosave.

So, I go back to Google Docs, I had been using it to write a while ago. The only problem with it is the images. I used to compose in it, then paste into Blogger's edit and inserted the photos.

Obviously, this will not be working this time.

So, I put image in Google Docs and modify the code to make it hotlink to Google Docs' server to serve images.

Here is the steps:
  1. Edit your document in Google Docs
  2. Copy HTML code from Edit/Edit HTML
  3. Use a editor can support regular expression replacement. I use Vim. After the HTML in VIm, type :%s_"File_"http://docs.google.com/File_g
  4. Paste the modified code to Blogger's editor. Don't switch to Compose mode.
This is terrible, just for name attribution. But I really don't know if there is a better way to do this. However there is a benefit of using Google Docs to do such task, it's easy to maintain those links (Bookmarks in Google Docs), you don't have to type those anchor names, you can choose from list. No typos any more.

Wednesday, October 7, 2009

Official LabelCloud (Labels) Gadget with Post Counts

The Label Cloud feature has been released for one and a half months, I just tried it out. The representation of cloud is fine, not as good as my LabelX (An external JavaScript to convert original Labels gadget into a label cloud representation). The benefit of using original official functionality is I don't need to add more JavaScript, which will slow a bit the page loading.

However, it doesn't show the post count when your mouse cursor stay on a label. I know you can show post count after label, but it's too ugly! The original partial XML code is as follows:
      <b:loop values="data:labels" var="label">
          <b:if cond="data:blog.url == data:label.url">
            <data:label.name></data:label.name>
          <b:else>
            <a expr:dir="data:blog.languageDirection" expr:href="data:label.url" href=""><data:label.name></data:label.name></a>
          </b:else>
          <b:if cond="data:showFreqNumbers">
            <span dir="ltr">(<data:label.count>)</data:label.count></span>
          </b:if>
        </b:if>
      </b:loop>

I have modified this part code, the revised version is as follows:
      <b:loop values="data:labels" var="label">
          <b:if cond="data:blog.url == data:label.url">
            <b:if cond="data:label.count == 1">
              <data:label.name></data:label.name>
            <b:else>
              <data:label.name></data:label.name>
            </b:else>
          <b:else>
            <b:if cond="data:label.count == 1">
              <a expr:dir="data:blog.languageDirection" expr:href="data:label.url" expr:title="data:label.count + &quot; post&quot;" href=""><data:label.name></data:label.name></a>
            <b:else>
              <a expr:dir="data:blog.languageDirection" expr:href="data:label.url" expr:title="data:label.count + &quot; posts&quot;" href=""><data:label.name></data:label.name></a>
            </b:else>
          </b:if>
          <b:if cond="data:showFreqNumbers">
            <span dir="ltr">(<data:label.count>)</data:label.count></span>
          </b:if>
        </b:else></b:if></b:if>
      </b:loop>

Now it can show the post count, it's not really a necessary point to all blogger, but I want that. You can scroll down to bottom to check it out.

Sunday, April 12, 2009

[BRPS] This sub-blog has been moved.

The BRPS blog has been moved to new place, see you there!

Wednesday, March 25, 2009

BRPS: Tracking Helper

By request of westius, BRPS now is able to append a small piece that may help your track if your visitor click on posts of related posts list.

The new option is append_src:
<script type="text/javascript">
window.brps_options = {
  "append_src": true
  }
</script>

The the links in related posts list will look like
http://example.blogspot.com/2009/03/post-title.html?src=brps

Monday, March 23, 2009

BRPS Featured blog: Milkberryland


Milkberryland is a blog about Japanese art, food/cooking, music, crafts and probably anything about Japan, which is written in English by @milkberry. You can see many cute drawing on this blog. Pink FTW!