Category Archives: S/W Technology

Battery: How to Charge and When to Charge?

http://batteryuniversity.com/learn/article/how_to_charge_when_to_charge_table

My Macbook Pro have Lithium-ion (Li-ion, polymer) type battery, and I always wonder what is the best way to charge to prolong the battery life.

In short and based on the webpage, I can charge and discharge in anytime. It doesn’t harm and there is no “memory” if it is Lithium-ion type.

Yes, almost everyone may know it already, but I’m too lazy to check in myself about it, and now, I got it. :)

How to make a Podcasts in iTunes via Drupal

- Summary:

  1. Generate RSS 2.0 (XML file) format for iTunes
  2. Test the XML URL in iTunes (Files -> Subscribe to Podcast…)
  3. Submit the XML URL into iTunes: here

- A little bit in detail:

The Podcasts in iTunes reads RSS formatted file (XML formatted) and shows the contents of it. The detailed info is in Apple’s podcast description and FAQ: For Podcast Makers.

When you use Drupal, you can easily generate the XML file by following modules:

1. Prerequisite

Assuming you already know

  • How to install drupal modules
  • About View Module
  • How to Add new Content Type and the concept of Content in Drupal

2. Add a content with file field.

The first thing you need to do is to have proper content with the file field. Check this out.

In “Content Type”, you can either add New Content Type or Edit existing Content type. Anyway, what you have to do is to check if it has “Field type: File” or  similar field type. If not, you need to add “Field type: File” to add attachment recognizable in Drupal.

Add Content Type or Manage Field

  • Add new field and set the “Type of data to store” as “File”

Adding File Field

  • Set “Label”, “File Extensions”, “File Directory”, and Maximum Upload Size.
  • If allowed upload size is not enough, please refer to increase the upload size in php configuration. In general, upload_max_filesize and post_max_size should be modified to limit the file size. Note that upload_max_filesize is less than post_max_size in general.

Field Configuration

3. Create a View

The next thing is adding a view for the RSS Feed (XML file).

Assuming you’ve installed above modules,

View

  • Select Include an RSS feed and put the xml file name
  • Click “Continue & Edit”

create a view

click feed

  • Set the Format as “RSS Feed – Fields” and Add more Fields you want to show and make sure the MP3 Contents as File Field.

setting view

Format Setting

  • In the “Fields: Content: MP3″, Create a label and Set Formatter as “RSS <enclosure> element” (Important!)

mp3 field

  • Rest of them, you can filter how you want to reveal the view to the iTunes. It’s up to you.
  • Note that if you want to get all items having the MP3, you can specify it as (not null).

4. Check the xml with http://feedvalidator.org

It shouldn’t be perfect, but just check if you miss something else.

5. Test with iTunes

In iTunes, you can test your XML as put the XML URL in “File” -> “Subscribe to Podcast…”

6. Submit it into iTunes.

That’s it. You can submit it into iTunes here.

Pop-Up Alert in Command line using AppleScript

You can open pop-up alert in command line using AppleScript.

Let Finder or System Events display dialog like this:

osascript -e 'tell app "Finder" to display dialog "Hello World"' 
osascript -e 'tell app "System Events" to display dialog "Hello World"'

You can get the return response like this, too 

#!/bin/bash
x=`/usr/bin/osascript <<EOT
tell application "Finder"
	activate
	set myReply to button returned of (display dialog "Here is a dialog box" default button 2 buttons {"button one", "button two", "OK"})
end tell
EOT`
echo 'Button is: '$x
if [[ $x = "OK" ]]; then 
echo 'Shell script continues...'
# Your
# Code
# Here
fi
echo 'Script ends.'