Auto shutdown

Force shutdown Windows can simply execute command

shutdown -f -s -t 0

You can enhance the script by create a schedule job like auto shutdown your pc at mid night 12am. Normally I have a habit listen to radio to sleep, just like a baby arh? haha.. now the radio became online. Many online radio are offer listen online through your browser now, so you also can create a schedule job to kill your browser to prevent the radio turn on until next day which will harm to your ear even though you asleep.

taskill /IM firefox.exe

But what about if during your shutdown script you want to do some checking? Like maybe you don’t want really shutdown pc if the downloading task still running? So a more complex script is required in this case. The script below is call the row count on tasklist if found the specified exe name, then put a stop on close command.

@echo off
setlocal enableextensions
set counter=0

rem check bitcomet is running or not
for /f "tokens=*" %%a in (
'tasklist ^| find /C "BitComet.exe"'
) do (
set counta=%%a
)

rem check JDownloader is running or not
for /f "tokens=*" %%a in (
'tasklist ^| find /C "javaw.exe"'
) do (
set countb=%%a
)

rem echo %counta%
rem echo %countb%
set /A counter=%counta% + %countb%
rem echo %counter%
if %counter% equ 0 goto :CLOSE
goto :EXIT
endlocal

:CLOSE
echo c:\windows\system32\shutdown -f -s -t 0

:EXIT

Buddhist Quotes 静思语

This is a widget to display wise quotes from virtuous monk. By default it will change a new quote every half hour, but if you want to change next quote just press the next button. It contains 1,085 wise quote from 证严法师 and around 3,300 from 星云法师.

All the quotes are extract from a xml source file, which structure is like below:

<?xml version="1.0" encoding="UTF-8"?>
<quotes>
<quote from="星云法师">人生最大的悲哀,是自己对前途没有希望;人生最坏的习惯,是自己对工作没有计划。</quote>
<quote from="证严法师">自造福田,自得福绿。</quote>
</quotes>

I collected all the quotes from web http://www.fgs.org.tw/master/masterA/books/delectus/maxim/maxim.aspx then convert it into the xml structure I want. But the problem is the original resource is html, so I need to do some conversion in this case.

Steps I took:

  1. Use notepad++ to open the file I have save.
  2. Remove all the new line by replace \r\r with \r use the extended character
  3. Insert <quote from=”证严法师”> in front of each quote again by find & replace ^
  4. Find & replace $ one by one (cannot replace all the app will hang) for insert the close tag – </quote>
  5. Go to google translate change to simplified Chinese where I preferred here.
  6. Done.

Issues:

  1. Fail to view all when it is long text.

Download
source

New interface

You can find it on Google Playstore now

Propose new feature & UI- Launch an application instead of just a widget.
BuddhistQuotes

MoonWidget

This is an android widget to show today lunar date and display moon phase on your desktop. You can found this useful if you a really Buddhist who looking 1st and mid moon for praying god or, those vegetarian take vege on 1st and mid moon only.

I take the moon graphic from http://auntiemoon.files.wordpress.com/2011/03/moon-phases-april-2011.jpg then use Gimp to cut the moon shape which I want then convert all 28 days of moon day into .png so it can be use as resource in the app.

Currently a very not smart way of getting lunar date and 24 solar terms. However, I’ll try to update it in future. I create a datasheet (.xml) to store every first of lunar month with the corresponding Gregorian date, and using loop method to calculate today lunar value. Welcome any better solution to do this. Thanks.

This is the sample of the datasheet (.xml)

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!-- @see http://zh.wikipedia.org/wiki/%E8%8A%82%E6%B0%94 --&gt;
&lt;!-- @see http://wenwen.soso.com/z/q173266684.htm --&gt;
&lt;calendar&gt;
	&lt;lunar sun=&quot;2011-11-08&quot; month=&quot;11&quot; /&gt;
	&lt;lunar sun=&quot;2011-11-25&quot; term=&quot;立冬&quot; /&gt;
	&lt;lunar sun=&quot;2011-11-23&quot; term=&quot;小雪&quot; /&gt;
	&lt;lunar sun=&quot;2011-12-22&quot; term=&quot;冬至&quot; /&gt;
	&lt;lunar sun=&quot;2011-12-15&quot; month=&quot;12&quot; /&gt;
	&lt;lunar sun=&quot;2012-01-23&quot; month=&quot;1&quot; /&gt;
	&lt;lunar sun=&quot;2012-02-04&quot; term=&quot;立春&quot; /&gt;
	&lt;lunar sun=&quot;2012-02-19&quot; term=&quot;雨水&quot; /&gt;
	&lt;lunar sun=&quot;2012-02-22&quot; month=&quot;2&quot; /&gt;
	&lt;lunar sun=&quot;2012-03-05&quot; term=&quot;惊蛰&quot; /&gt;
	&lt;lunar sun=&quot;2012-03-21&quot; term=&quot;春分&quot; /&gt;
	&lt;lunar sun=&quot;2012-03-22&quot; month=&quot;3&quot; /&gt;
	&lt;lunar sun=&quot;2012-04-04&quot; term=&quot;清明&quot; /&gt;
	&lt;lunar sun=&quot;2012-04-20&quot; term=&quot;谷雨&quot; /&gt;
	&lt;lunar sun=&quot;2012-04-21&quot; month=&quot;4&quot; /&gt;
	&lt;lunar sun=&quot;2012-05-05&quot; term=&quot;立夏&quot; /&gt;
	&lt;lunar sun=&quot;2012-05-20&quot; term=&quot;小满&quot; /&gt;
	&lt;lunar sun=&quot;2012-05-21&quot; month=&quot;4&quot; /&gt;
	&lt;lunar sun=&quot;2012-06-05&quot; term=&quot;芒种&quot; /&gt;
	&lt;lunar sun=&quot;2012-06-19&quot; month=&quot;5&quot; /&gt;
	&lt;lunar sun=&quot;2012-06-21&quot; term=&quot;夏至&quot; /&gt;
	&lt;lunar sun=&quot;2012-07-07&quot; term=&quot;小暑&quot; /&gt;
	&lt;lunar sun=&quot;2012-07-19&quot; month=&quot;6&quot; /&gt;
	&lt;lunar sun=&quot;2012-07-22&quot; term=&quot;大暑&quot; /&gt;
	&lt;lunar sun=&quot;2012-08-07&quot; term=&quot;立秋&quot; /&gt;
	&lt;lunar sun=&quot;2012-08-17&quot; month=&quot;7&quot; /&gt;
	&lt;lunar sun=&quot;2012-08-23&quot; term=&quot;处暑&quot; /&gt;
	&lt;lunar sun=&quot;2012-09-07&quot; term=&quot;白露&quot; /&gt;
	&lt;lunar sun=&quot;2012-09-16&quot; month=&quot;8&quot; /&gt;
	&lt;lunar sun=&quot;2012-09-22&quot; term=&quot;秋分&quot; /&gt;
	&lt;lunar sun=&quot;2012-10-08&quot; term=&quot;寒露&quot; /&gt;
	&lt;lunar sun=&quot;2012-10-15&quot; month=&quot;9&quot; /&gt;
	&lt;lunar sun=&quot;2012-10-23&quot; term=&quot;霜降&quot; /&gt;
	&lt;lunar sun=&quot;2012-11-07&quot; term=&quot;立冬&quot; /&gt;
	&lt;lunar sun=&quot;2012-11-14&quot; month=&quot;10&quot; /&gt;
	&lt;lunar sun=&quot;2012-11-22&quot; term=&quot;小雪&quot; /&gt;
	&lt;lunar sun=&quot;2012-12-07&quot; term=&quot;大雪&quot; /&gt;
	&lt;lunar sun=&quot;2012-12-13&quot; month=&quot;11&quot; /&gt;
	&lt;lunar sun=&quot;2012-12-21&quot; term=&quot;冬至&quot; /&gt;
	&lt;lunar sun=&quot;2013-01-05&quot; term=&quot;小寒&quot; /&gt;
	&lt;lunar sun=&quot;2013-01-12&quot; month=&quot;12&quot; /&gt;
	&lt;lunar sun=&quot;2013-01-20&quot; term=&quot;大寒&quot; /&gt;
&lt;/calendar&gt;

Download

Source