Skip to content

Instantly share code, notes, and snippets.

package com.example;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
@shaobin0604
shaobin0604 / IndexGen.java
Created September 17, 2010 03:24
WordMemo index generator
package com.example;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
public class IndexGen {
private static final byte CR = 0x0D;
private static final byte LF = 0x0A;
// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov Date: 2010-8-24 22:45:44
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: ClockWidget.java
package com.sonyericsson.android.digitalclock;
import android.app.Service;
import android.appwidget.AppWidgetManager;
import android.content.BroadcastReceiver;
@shaobin0604
shaobin0604 / gist:544946
Created August 23, 2010 06:45
Weather Config Layout
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<!--
public class LyricView extends View {
private Lyric mLyric;
private Sentence mSentence;
public void update(long time) {
mSentence = mLyric.getSentence(time);
invalidate();
}
@Override
<weatherdata>
<weather weatherlocationcode="wc:CHXX0008" weatherlocationname="Beijing, CHN" zipcode="" encodedlocationname="Beijing%2c+CHN" url="http://weather.msn.com/local.aspx?wealocations=wc:CHXX0008&amp;q=Beijing%2c+CHN" imagerelativeurl="http://blst.msn.com/as/wea3/i/en-us/" degreetype="C" provider="Foreca" attribution="Data provided by Foreca" attribution2="© Foreca" lat="39.9125748" long="116.3889847" timezone="8" alert="">
<current temperature="22" skycode="28" skytext="Mostly Cloudy" date="2010-06-11" day="Friday" shortday="Fri" observationtime="09:30:00" observationpoint="Tianjin / Zhangguizhu" feelslike="22" humidity="69" windspeed="11" winddisplay="11 km/hr SSE"/>
<forecast low="19" high="27" skycodeday="26" skytextday="Cloudy" date="2010-06-11" day="Friday" shortday="Fri" precip="35"/>
<forecast low="20" high="31" skycodeday="28" skytextday="PM Clouds" date="2010-06-12" day="Saturday" shortday="Sat" precip="10"/>
<forecast low="20" high="31" skycodeday="26" skytextday="Cloudy" date="201
private void parseWeather() {
mForecasts = new ArrayList<Map<String,String>>();
mCondition = new HashMap<String, String>();
InputStream is = null;
try {
// is = getLocalWeatherSource();
is = getWebWeatherSource();
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_height="wrap_content"
android:layout_width="fill_parent">
<TextView android:id="@+id/TextView01" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="This text view should act as header " />
<ScrollView android:layout_marginBottom="50dip" android:id="@+id/ScrollView01"
android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1.0">
<RadioGroup android:id="@+id/RadioGroup01"
android:layout_width="wrap_content" android:layout_height="wrap_content">
@shaobin0604
shaobin0604 / gist:335393
Created March 17, 2010 16:07
最大公约数
public class Test {
public static void main(String[] args) {
int a = 165, b = 55;
System.out.printf("%d 和 %d 的最大公约数是: %d\n", a, b, gcd(a, b));
}
public static int gcd(int a, int b) {
// suppose a > b;
int r = a % b;
while (r != 0) {
@shaobin0604
shaobin0604 / Test.java
Created March 17, 2010 13:34
素数测试
public class Test {
public static void main(String[] args) {
int number = 37;
if(isPrime(number))
System.out.println(number + " is a prime number");
else
System.out.println(number + " is not a prime number");
}
public static boolean isPrime(int number) {