Tuesday, February 07, 2012

Set up DfpAdView/AdView of admob

教學有很多, 但大多十分多肺話, 所以我的十分精簡:

1) Reg On Admob site to get the Publisher ID -  a14exxxxxxxxxx

2) Mainfest.xml:
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <activity
            android:name="com.google.ads.AdActivity"            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

3) Add a LinearLayout called ad_layout to the Activity "XML" file that u want to show the ad.

4a) Add the code to the correspondence Activity "JAVA Code" file
   
    ------- Field -------
     private DfpAdView mAdView;

      I----- onCreate ------
      final LinearLayout adRow = (LinearLayout) findViewById(R.id.ad_layout);
mAdView = new DfpAdView(this, AdSize.SMART_BANNER, "a14exxxxxxxxxx");
adRow.addView(mAdView);
mAdView.loadAd(new AdRequest());

4b) Change DfpAdView to AdView, if u want AdView

5) Override onDestory
     @Override
protected void onDestroy() {
if (mAdView != null) {
mAdView.removeAllViews();
mAdView.destroy();
}
super.onDestroy();
}

6) Run Test !!!!

PS: Add DfpInterstitialAd Later
 

Saturday, January 27, 2007

Hafnium Vally ?

Intel and IBM announces a research result tothe use of alloy of hafnium to replace the silicon dioxide can makes Morrow's Law to be valid in the future.

New York Time

Sunday, January 21, 2007

Wednesday, January 17, 2007

Proxy + 代理猎手

我现在是proxy switcher 跟 代理猎手一起用,proxy switcher 有个功能是自动下载代理服务器网站的代理列表,找到后在全部拿到代理猎手上verify,看哪个连到gindis的比较快。。。具体操作嘛。。。。

proxy switcher
Actions-->Download Proxy Lists,等待几分钟,程序如果开始testing 那些代理的话你把他给stop掉,这时你应该可以在左边
NEW里看到一些刚刚下载的代理,点那个new的文件夹,全选右边的代理,然后File-->export to text file-->命名


代理猎手
System-->Change Option 出来一个option,按中间那个Verification Data Option tab, 选择下面的Add
会出现一个窗口
Name:随便
URL:你要verify 的网址,http://www.gindis.com, 这个填完后按旁边的get, 新窗口弹出再按get一次,这时你会在那个新窗口收到一些数据,随便copy 一下army commander 之类的当你的key word,然后按ok,接着回到你之前的Verification Data Option tab, 选择刚刚你才加的verification,然后按下面的use。这是为了以后测试你那些代理服务器连到这个网址后能不能在找到这个keyword,找到 的速度越快代表你的代理越快(当然可能连接gindis快的,连接论坛就慢了,有时根本不能连)

接下来去代理猎手主窗口,点Results-->import-->之前找到的代理,加完后点中间那个Result tab,按右边的verify all,等几分钟,good就是可以用的代理,你点Timing 可以从最快到最慢排序

回到proxy switcher
选择左边的proxyswitcher 文件夹,把刚刚那些good的代理加进去,剩下的就一个个试,看哪个速度快

Monday, January 15, 2007

Next Generation of Fortan -- Fortress

Sun released Fortress as a replacement of well know scientific purpose language -- Fortran.
Fortress is target on JVM 1.5.

The most natural different between it and Java is that it assume that a process should be run in parallel instead of single-threaded. It also means to target to high-performance computing area.

Tuesday, January 09, 2007

iPhone come out from Jobs's packet

In today Macworld San Franciso 2007, Jobs took a new iPod from his packet !!!

Ohhhhhhh~~ wait that is not iPod !!!!


~~ iPhone ~~

The details released were:
  1. 3.5-inch widescreen display

  2. 2.0 Megapixel camer

  3. 8GB /4GB storage

  4. Bluetooth with EDR

  5. WiFi

  6. quadband GSM radio with EDGE.
7. It will be availiable in June for $499 for 4GB and $599 for 8GB
iPhone Offical Site


Sunday, December 03, 2006

Quake 3 's InvSqrt

float InvSqrt (float x){
float xhalf = 0.5f*x;
int i = *(int*)&x;
i = 0x5f3759df - (i >> 1);
x = *(float*)&i;
x = x*(1.5f - xhalf*x*x);
return x;
}

Math explanation here (PDF)

Thursday, November 23, 2006

Send File !?!? 沒有困難 ~~~

Ha, I find the simple input is just a PDF file, so to check the programe is correct or not, just remain the output to .bin file..

Source Code Later !!

Sunday, November 12, 2006

Download from You Tube

"View Page Source” and do a text search for

player2.swf?video_id=

For example the internal prolonged video identification code may be:

b4Knsa7kBPE&l=48&t=OEgsToPDskI3D6CVWsTxEa4BzcTHKXc7
&s=E04B5F8107785BA4:8A51374783A7BCE6

Keep in mind that the code between “&t=” and “&s=” may be session-sensitive and changed every time the video is accessed.

To save the video, the URL path format is

http://www.youtube.com/get_video?video_id=prolonged_video_identification_code

Set the range of SQL result

SQL LIMIT

如果在某項查詢結果中,我們想要的僅是其中一部份時,可以使用 LIMIT 來限制資料被讀取的筆數。
例如,找出座號最前面的五位學生姓名:

SELECT realname FROM student ORDER BY num LIMIT 0, 5

在此例中,LIMIT 後方的 0 代表「從第 0 筆資料開始」,5 表示「取出 5 筆資料」。

Monday, October 30, 2006

Here's some code for blurring an image:

float[] kernelData = new float[9];
for (int i = 0; i < kernelData.length; i++)
{
kernelData[i] = 0.15f;
}
ConvolveOp blur = new ConvolveOp(new Kernel(3, 3, kernelData));
BufferedImage blurryImage = new BufferedImage(w, h, w, h,
BufferedImage.TYPE_INT_ARGB);
blurryImage.createGraphics().drawImage(imageToBlur, blur, 0, 2);

Add time stamp to picture using Java

public static void addDate(File inputFile) throws Exception {
String inputFilename = inputFile.getPath();
System.out.println("Starting with '" + inputFilename + "'");
BufferedImage input = ImageIO.read(inputFile);
Graphics2D graphics = (Graphics2D) input.createGraphics();
Date lastModified = new Date(inputFile.lastModified());
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
String dateStamp = sdf.format(lastModified);
int fontSize = (int) (0.4 * input.getHeight() / 10.0);
Font font = new Font("Arial", Font.BOLD, fontSize);
graphics.setFont(font);
int height = graphics.getFontMetrics().getHeight();
int width = graphics.getFontMetrics().stringWidth(dateStamp);

BufferedImage dateImage = new BufferedImage(2 * fontSize + width, 2
* fontSize + height, BufferedImage.TYPE_INT_ARGB);
Graphics2D dateGraphics = (Graphics2D) dateImage.getGraphics().create();
dateGraphics.setColor(new Color(0, 0, 0, 0));
dateGraphics.setComposite(AlphaComposite.Src);
dateGraphics.fillRect(0, 0, width, height);

dateGraphics.setComposite(AlphaComposite.SrcOver);
dateGraphics.setFont(font);
dateGraphics.setColor(Color.black);
dateGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
GlyphVector gv = font.createGlyphVector(dateGraphics
.getFontRenderContext(), dateStamp);
// dateGraphics.drawString(dateStamp, fontSize, fontSize);
dateGraphics.translate(fontSize, 2 * fontSize);
for (int i = 0; i < gv.getNumGlyphs(); i++) {
Shape glyph = gv.getGlyphOutline(i);
dateGraphics.setStroke(new BasicStroke(fontSize / 10));
dateGraphics.draw(glyph);
}
float[] kernel = new float[25];
for (int i = 0; i < kernel.length; i++)
kernel[i] = 1.0f / kernel.length;
ConvolveOp cOp = new ConvolveOp(new Kernel(5, 5, kernel));
BufferedImage blurred = cOp.filter(dateImage, null);
dateGraphics.dispose();

int iWidth = input.getWidth();
int iHeight = input.getHeight();
int cHeight = iWidth * 2 / 3;
int dHeight = (iHeight - cHeight) / 2;

int y = (iHeight - dHeight) - blurred.getHeight();
int x = iWidth - blurred.getWidth();

graphics.drawImage(blurred, x - fontSize, y - 2 * fontSize, null);
graphics.setFont(font);
graphics.setColor(Color.white);
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
graphics.drawString(dateStamp, x, y);
graphics.dispose();

int lastDotIndex = inputFilename.lastIndexOf('.');
String outputFilename = inputFilename.substring(0, lastDotIndex)
+ ".new" + inputFilename.substring(lastDotIndex);
FileOutputStream out = new FileOutputStream(outputFilename);
/* encodes image as a JPEG data stream */
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(input);
param.setQuality(0.9f, true);
encoder.setJPEGEncodeParam(param);
encoder.encode(input);
System.out.println("Ending with '" + inputFilename + "'");
}

Of course, it's not a pinnacle of Java2D programming, nor was it intended to. Since i don't have any imaging-related java.net project, i'm not intending to polish it to perfection. It even uses classes in the com.sun.image.codec.jpeg package. Hereby it is released to the public domain - feel free to use, reuse and abuse it in any way - but don't come back if your nuclear reactor stops functioning because of this :)

The result is quite OK:

Tuesday, October 24, 2006

Add new Features to Java

Fun :) Very funny :)

A much fair comparsion should be Rudy vs Groovy vs Python vs Perl.

Java should and it should be much complex than Ruby becuz of its strong typing system.

However, some of the Ease of Development(EoD) of Ruby can be absorded by Java, to richer Java's expression prower without damaging the strong typing system.

For example:
'yield return' can save your works from creating a new array to store the results in list.

Direct "regular expression' support like what Javascript does can save works from createing/managing Pattern, Matcher Objects.

Lambda provide better DSL support in Java.

...... etc.

You may(are going to) say: 'Hey !!! we the community don't need them all. Seriously, I dun need them.'

Okay, who asked for GC, Object-Oriented programming support, RTTI, Bytecode and Cross platform support ???

Back to just 3 years back now, I think sun is the one person who support GC. If you read the javalobby and even the Sun's Java REF DB. NOBODY think GC is good, everybody just try to reinforce the 'delete' key into the language.

Now, I think 99% of us agreed that GC is a must.
(hey, u disagree !!! Why?? I'm Sorry, I forget that C programmers do read javalobby :)

We're lucky that we get some smart folks to do the R&D for us. Sometime even all of us think that something go wrong, maybe its bucz (we're)||(the things) is wrong.

I'm not telling you that the community is making the wrong decisions to any change in java language( I agree that the current generic implementation sucks). Spring, iBat, Tomcat...etc from the java community are the masterpiece. But sometime people object to the new language changes just bcuz:

I dun understand it
I dun like it BUCZ I dun learned it b4
I dun use it I dunno the advantage of it
I just simple dislike changes
I have a good reason blah blah...

I know many people (of course just surrounding me, U is not the one) hate something just bcuz they dun understand it. This is a psychology topic I learned in uni:
If someone put a unopenable, sealed, opaque large box in your house with no good reason and order you to not open it. At the beginning u should be curious about it. But later on experts found out two very funny results:

1) treat it as normal, the box is here just like it should be.

2) lock/hidden/throw/remove/return the box. Someone even called the police. Why? bcuz people afraid the stuffs inside the box. if the box is similar to a human size 50% people think a dead body inside. if the size is similar to the 21" TV 30% of people afraid that it is dirty $$ ....so on.

Now, the reaction of the java community is similar. Why add closure????? it is damager??? why ??? I dunno why.....

Well, dun start a flame war that Java shouldn't add XXXXX. This is not related to this topic.

What I want to say is the main purpose of comparing Java and Rudy is to show that java is bad or show that xxx features from ruby should be added to java bucz java is weak in this use case.

I PERDICT:

I THINK ALL RUBY FEATURES WILL BE ADDED TO JAVA SOON OR LATER.

u: omg/suck/shit, I want clear and simple java only, dun change java into ruby.

Hey, hold one. U misunderstand me. I means JRuby == power of ruby + power of java

What !?!? It doesn't look like Java.

Then look for Groovy == ruby power + Java syntax

What ?!?!?! You just want part of the ruby in java.
Please move to other post that talk about adding new features like closure .... etc.

It is meaningless to compare the color and size of an apple and orange.
Go and make something like Rudy vs Perl --- Why Perl sucks? Or C# vs Java why people always think C# is easier? Or Java vs VB.Net why Java can’t replace VB for the past 10 ten is much educational and meaningful that Java vs Ruby – Why Strong typed language always look sucks in front of dynamic typed language.

Friday, September 22, 2006

如何用google檢索密碼

實際上用google檢索密碼非常的容易,就像一個朋友曾經講的,設定檢索關鍵詞非常重要,我的經驗有以下幾點,與大家交流:

1 任何想查的+password(注意 +號不打),而且PASSWORD在西文中都是相同的,不會漏檢,不像username有很多詞能夠替代,比如userID,userlogin等等。
2 在查到初步結果後,用google的高級檢索,具體設定每頁的檢索結果,然後用IE頁面上的編輯→查找→「PASSWORD」,可以大大提高檢索效率。
3 最關鍵的是主題詞設定,這裡還是強調不要僅僅用刊物名+password查,會漏掉很多寶貝。用「medicine journal password」,「medicine databases password」,「health journal/databases password」,「medical e-journal password」,「medicine e-resourse password」或者直接用「Ovid journal password 」「proquest password」「ebsco password」等等來查。
4上述方法就是高手常用的一般方法,有的朋友還用別人找到的密碼反查,也有很好的效果,這種竅門應該值得提倡。
5 實際上如此檢索仍有漏洞,因為西方文獻檢索的書目編排與中文不同,很多我們認為天經地義屬於醫學的類目不在「medicine」下,因此造成漏檢,比如護 理、精神病以及生物學往往自成體系,與「medicine」並列,因此除了上述檢索式外,還應該用「. ..... password」查,這裡仍然賣個關子,實際上聰明人已經知道該怎樣去做了.
6 當然還有其他更絕的方法,留待以後再講吧.

首先聲明,這只是我自己的經驗,不一定適合大家。
找期刊或數據庫密碼,當然www.google.com,就用「期刊名(數據庫) +password」就可以了,通常username有很多形式,比如「username」「useraccount」「useer ID」等等,只有password不變,因此上述方法就可以了。注意在google頁面上進入高級檢索,對上述檢索式進一步修訂,通常google只分頁 顯示800個條目,這已經夠你找的了,一般每次你用不同的檢索式都會有驚喜。
上述方法能夠很快使你成為中級戰友的,而且越來越不用求人。我想這是很多中級戰友的共同體會,這也是我為什麼討厭有的新手一進來就嚷嚷要密碼,自己沒有試過最好試完以後再說。
當學會這種方法以後,實際上你會越來越迷上找密碼,有些朋友公佈的密碼和另一些人重複就不足為奇了。
至於用代理服務器甚至hecker軟件,並不足取,也沒必要,但代理服務器的好處是一旦擁有,別無所求,可以一勞永逸的「吃飽吃好」,再無密碼失效的煩惱。

繼續我們之前的話題:
1 千萬重視在檢索密碼時的某些PDF格式文件,常常有驚人的發現,我有兩個密碼就是通過這種方法查到的,趕緊下載閱讀PDF閱讀軟件吧。
2 很多朋友在查密碼的時候會發現非英語國家的圖書館密碼,這就是目前的現狀——歐洲國家的文明與科學開化程度決定的。因此如果你進入到一個非英語的圖書館, 要學會用當時頁面某些詞作為關鍵詞回到GOOGLE檢索,會有發現的,舉例說明MEDICINE在德文 或丹麥語中為「MEDIZINE」。
3 強調對檢到的網頁不要輕言無效,由於GOOGLE的時效性,某些頁面已經被調整了,因此如果高度懷疑會有密碼的話,一定要勤於研究。這也是為什麼我不願意隨便公開密碼,或痛恨隨便洩露密碼的原因,因為這是艱苦搜索換來得。
4 說來說去,檢索密碼的關鍵在於檢索詞,目前的引擎技術或搜索引擎沒有大的區別,就我的經驗來看,GOOGLE是首選,因為其頁面明確標明PASSWORD,易於快速尋找,不像某些引擎。

通過檢索發現國外的密碼公佈在94~2001上半年是比較多的,前期連數據庫都有,後期以個別期刊的密碼為主,也就是說數據庫的管理越來越嚴,入口限制的很厲害,看來未來的發展應該是以期刊入口為主了。這方面還是應該有所準備的好。
台灣/南韓的密碼好像很容易得到,真正好用的也不少,但我以前比較輕視台灣/南韓,這一點,FRIEND88作的非常好,向他祝賀!

大家請看以下內容(來http://libinfo.uark.edu/eresources/eresources.asp )就知道以前我所說的不虛,與醫學有關的都在Science & Technology 大條目下,又細分為:
Agriculture & Food | Biology | Botany | Chemistry | Computer Science | Engineering | Environmental Dynamics | Geology | Kinesiology | Mathematics | Medicine | Nursing | Physics | Psychology | Statistics | Zoology。
因此如果僅以medicine檢索,就會漏掉不少很有價值的信息,特別是漏掉的專業的,損失慘重也。

我曾用過的密碼檢索詞
medicine journal ID pw
chemWEB.COM PASSWORD
Virtuelle Bibliothek PASSWORD
「Online Full Text Resources password」
「health sciences library password 」
「OvidLWW password」
「medizin bibliothek password」
「medizin Volltext password」
「medizin literatur password」
「health ejournals password 」
「medizin elektronik password」
Medizin Bibliothek Datenbank Benutzername Kennwort
medicina BIBLIOTECA password
médecine PéRIODIQUES éLECTRONIQUES password
health ejournals password
American Journal of Medicine OnLine FULL TEXT Journals username password
medicine journal fulltext username
大家如果有興趣可參考我以前的貼子,自設關鍵詞,在GOOGLE上檢索,慢慢的就明白原來如此簡單、有趣...艱苦、吐血...

A GOOD NETSITE
http://www.tcd.ie/Library/People/Mark.Walsh/JournalA.html
http://210.119.137.155/journal/journal_main_06.html
http://www.galaxyofhealth.com/journals.html
http://www.hamdenlibrary.org/reference.html

和多朋友都知道「medicine journal username password」....或者進一步擴充上述檢索詞,能夠找到很多有價值的地址。
實際上有一種竅門,可以減少工作量:
既然我們在找全文雜誌密碼,那麼有全文網址的地方一定會登載一些醫學界經典雜誌,比如新英格蘭、自然等雜誌的密碼和用戶名,我們只要用一本經典雜誌名+username password就能事半功倍,例如:
username password "American Heart Journal"
就能大有收穫,如果再對上述檢索式修飾一下,比如:
username password "American Heart Journal" site:ac.jp
就將檢索範圍限制在日本的大學中(建議少用ac,直接用site:jp就行)

tips:
1. 注意,日本和韓國圖書館多用「userid password」或「USERID PWD」,這一點要注意。
2. 上面提到的檢索式中,那個「經典雜誌」的選擇很重要,不要用自然或新英格蘭醫學,要用美國心臟雜誌、美國婦產科雜誌...你選擇什麼雜誌與你的檢索收穫成正比,如果幸運的話,能夠有驚人發現,包括ovid以及目前肯定沒有被公開的全文密碼站點!!!
3. 上述檢索式還能夠對時間進行限制,更減少工作量。
4. 雜誌名一定要用雙引號!

http://www.bcrp.pcarp.usp.br/recursos_onlineB-D.htm
www.unicaen.fr/unicaen/service/scd/periodiques-integral.htm
http://www.acta.nl/page_nl.asp?pid=26

http://lib.ghil.com/ej/c.htm 站內有很多雜誌,而且鏈接也作的非常精美!值得推薦,但是這些都掩飾不住其中的奧妙:
凡是雜誌倩影旁邊有綠色筆記本樣標記,就代表「fulltext」,將鼠標放在該雜誌上,就會顯示出雜誌的用戶名與密碼!試一試吧!

www.lib.nctu.edu.tw/n_service/joulist.htm
http://216.239.33.100/search?q=c ... =zh-CN&ie=UTF-8
http://goserv.iis.sinica.edu.tw/LIB/USERS/sevena.html

目前經過驗證,最簡單有效的密碼檢索式應該是:
"medicine journal password OR pw OR pwd "american heart journal" -telnet -forget -forgot -required"
說明:以上檢索在GOOGLE中進行
1. 檢索目的在於查找能夠提供絕大多數醫學雜誌的username password的網頁,通常醫學核心雜誌沒有不是帶有"醫學雜誌"稱謂的,故選擇american 和journal.
2. "password OR pw OR pwd" 在於password是password的衍生(當然還有一兩個,這裡保密),絕大多數不會超過這三個詞,不像username 有user name\user login\userlogin\accunt\nickname\userid\user ID...等等衍生.不利於精檢.
3. "American Heart Journal"則仁者見仁,智者見智,也可以選其他最知名雜誌名稱,大大提高檢出率,並顯著減少工作量.
4 -TELNET 代表刪去帶有telnet的頁面,因為很多醫學站點提供的telnet根本永不上,常常與期刊雜誌混淆.其他刪減原因自明.
5. 當然你還可以增刪,包括限定時間,國家,語言,或加入語法