Here is the search url to list all articals in you blogger
http://xxx.blogspot.com/search?q=+
2017-08-25
2017-08-05
[Blogger] [Responsive theme "Soho"] 在網頁上方的bar加上social media icon
這篇要寫的是如何在google blogger的Responsive theme "Soho"網頁上方的會伸縮的bar
加上social media icon
1. 首先到blogger的版面配置
把Follow by email打開
如果follow by email原本沒打開會是長這樣
點"Follow by Email"旁邊的鉛筆
會跳出另一個視窗如下圖
點選"顯示 透過電子郵件追蹤"
然後儲存設定。
這樣就成功打開Follow by Email了。
完成後,網頁右上角的"搜尋"旁邊會出現"訂閱"
如果你不想要這個"訂閱功能"沒關係,等一下我們會把它隱藏掉。
但在這個步驟中我們還是要先把它打開
因為我們需要這個區塊來放social media icon。
如果不把social media icon放在這個區塊,
而是直接放在外面的話,
因為"搜尋"那個區塊會伸縮,會變得比較麻煩。
所以還是把要增加的social media icon直接放在訂閱區塊裡面會比較好看。
2. 要放在網頁上的icon
在他們的網頁上調整好自己想要的icon和效果之後
就可以下載icon
就可以下載icon
然後得到css和html
下載下來的icon檔案,解壓縮之後有四個檔案
這四個檔案你要放到另外的網頁空間
例如:google drive, 或是github, 或是其他網頁空間
然後把CSS裡面的url換成這四個檔案的網址路徑
HTML裡面的#號,則要記得改成你點下icon之後要連結的網址。
這邊的css和html等一下我們會貼到blogger。
3. 這個步驟,我們要把在perfecticons.com得到的html code貼到blogger。
首先
在blogger後台,選"主題"-->"編輯html"
按"Ctrl+F"搜尋"<section class='subscribe-section-container'>"
然後把在perfecticons.com得到的html code
貼到<section class='subscribe-section-container'>的下面
!!!記得要把在perfecticons.com得到的html裡面的#號換成你點下social media icon之後想要連結到的網址
4. 這個步驟,我們要把在perfecticons.com得到的CSS貼到blogger裡面。
在blogger後台
選"主題"-->"自訂"-->"進階"-->"新增CSS"
把在perfecticons.com得到的CSS貼上
然後點右上角的"套用至網誌"
5. 接下來,我們要把一開始跑出來的"訂閱"功能隱藏起來。
但如果你想要留著這個功能的話,那就可以跳過這個步驟~
在跟上一個步驟一樣的地方
blogger後台
選"主題"-->"自訂"-->"進階"-->"新增CSS"
貼上下面這四行
/* 隱藏'訂閱'按鈕 */
.subscribe-button{
display: none;
}
然後點右上角的"套用至網誌"
這樣就大功告成囉~
2017-07-30
[Sublime text] 批次删除行尾空格或Tab
打開replace功能(mac是option+command+f)
勾選最左邊的regular expression按鈕
find欄位: \s+$
replace欄 : (留空)
最後點replace all就完成了
2017-05-22
[Blogger] Add something only shows on Home Page
If you want to add something(ex. Slideshow) to blogger theme, but you only want it shows on Home Page, you cant wrap the code you add by the following tag....
[Blogger] Responsive theme "Soho" bug fix. How to make the Popular Post in sidebar smaller?
1. Find this code:
body.item-view .widget.PopularPosts, body.item-view .post-outer-container .inline-ad, #comments {
margin-$startSide: 220px;
width: 660px;
}
body.item-view .widget.PopularPosts, body.item-view .post-outer-container .inline-ad, #comments {
margin-$startSide: 220px;
width: 660px;
}
[Blogger] [Responsive theme "Soho"] How to hide the side bar forever?
1. find two sections of code:
First:
@media screen and (max-width: 1439px) {
.sidebar-container {
bottom: 0;
position: fixed;
top: 0;
}
.sidebar-container {
$startSide: 0;
$endSide: auto;
}
.sidebar-container.sidebar-invisible {
-webkit-transition-timing-function: cubic-bezier(0.4,0.0,0.6,1);
transition-timing-function: cubic-bezier(0.4,0.0,0.6,1);
}
html[dir=ltr] .sidebar-container.sidebar-invisible {
-webkit-transform: translateX($(sidebar.width * -1));
-ms-transform: translateX($(sidebar.width * -1));
transform: translateX($(sidebar.width * -1));
}
html[dir=rtl] .sidebar-container.sidebar-invisible {
-webkit-transform: translateX($(sidebar.width));
-ms-transform: translateX($(sidebar.width));
transform: translateX($(sidebar.width));
}
}
@media screen and (min-width: 1440px) {
.sidebar-container {
position: absolute;
top: 0;
}
.sidebar-container {
$startSide: 0;
$endSide: auto;
}
.sidebar-container .navigation {
display: none;
}
}
2015-12-18
[Golang] 用Go (golang) 寫Web Server! 使用go-restful package. Hello go-restful!
1. 安裝go
https://golang.org/doc/install
https://golang.org/dl/
*如果有安裝舊版的要先移除
*Mac版的pkg只要抓下來執行一直按下一步就安裝好。
他會幫你把go安裝在/usr/local/go,
並把/usr/local/go/bin加到環境變數PATH當中。
記得要把Terminal關掉重開才會吃到新的PATH。
2. 準備一個HelloWebServer的Workspace
1. 新增一個資料夾當作這個程式的Workspace, ex. ~/HelloWebServer/
2. 把這個folder path加入環境變數,
ex. 執行 $ export GOPATH=$HOME/HelloWebServer
3. 在work folder底下加入src/HelloWebServer/hellowebserver.go
內容為
https://golang.org/doc/install
https://golang.org/dl/
*如果有安裝舊版的要先移除
*Mac版的pkg只要抓下來執行一直按下一步就安裝好。
他會幫你把go安裝在/usr/local/go,
並把/usr/local/go/bin加到環境變數PATH當中。
記得要把Terminal關掉重開才會吃到新的PATH。
2. 準備一個HelloWebServer的Workspace
1. 新增一個資料夾當作這個程式的Workspace, ex. ~/HelloWebServer/
2. 把這個folder path加入環境變數,
ex. 執行 $ export GOPATH=$HOME/HelloWebServer
3. 在work folder底下加入src/HelloWebServer/hellowebserver.go
內容為
2015-11-12
[Mokito] 使用Mokito寫測試的筆記 (Note for writing test cases by Mokito)
Test Class Template
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import static android.os.Build.VERSION_CODES.LOLLIPOP;
@Config(sdk = LOLLIPOP, constants = BuildConfig.class)
@RunWith(RobolectricGradleTestRunner.class)
public class MyTest {
// something to mock
@Mock TypeA A;
@Spy TypeB B = new TypeB();
// ...
// Set up
@Before public void setUp() throws Exception {
initMocks(this); // create mock objects, ex. A and B above
// ... do so other init things
}
// Tear down
@After public void tearDown() {
// ... do so tear down things
}
// Test Case (which should not throw exception)
@Test public void testCase1() throws Exception {
// do something
}
// Test Case (expect exception)
@Test(expected=YouExceptException.class) public void testException1() {
// something would throw YouExceptException.class exception
}
// Test Case (expect exception)
@Test public void testException2() throws Exception {
try {
// something should throw exception
// import org.assertj.core.api.Assertions;
Assertions.failBecauseExceptionWasNotThrown(YouExpectException.class);
} catch (YouExpectException e) {
}
// verify other things here
}
// Test Case (with timeout)
@Test(timeout=100) public void infinity() {
// something should not run longer than 100ms
}
}
2015-11-02
[Android][RxJava] Run something async on non-UI thread, then back to MainThread to do something after that.
當你有某些東西要Async地在background、而且是non-UI thread運作
(例如:Android要連接網路Network、http之類的時候)
但是做完又要回到Main Thread
(例如:從網路or anywhere拿到資料之後要更新UI)
就可以用以下的Pattern來寫
Async.fromCallable(new Callable() { // T is the type you want to send back to MainThread @Override public T call() throws Exception { // do something that you want it async run on Schedulers.io() return [object in type T]; } }, Schedulers.io()) // specify the thread you want async work to run on it, here we use Schedulers.io() .observeOn(AndroidSchedulers.mainThread()) // then back to MainThread .subscribe(new Subscriber () { // run on MainThread @Override public void onCompleted() { } @Override public void onError(Throwable e) { } @Override public void onNext(T obj) { } });
2015-10-29
[Android] an Text search Adapter for AppCompatAutoCompleteTextView or AutoCompleteTextView
這是一個可以自動完成的TextView(AutoCompleteTextView)所需要的Adapter
原本的ArrayAdapter的自動完成只會搜尋到以已輸入的字串為開頭的字串。
(因為ArraryAdapter的Filter是用startWith去找字串)
例如:List當中有"安全"、"安心"、"保安"、"偏安"、"討厭"
輸入"安",只會搜尋出"安全"、"安心"
而"保安"、"偏安"就搜尋不到
"討厭"也是一樣搜尋不到
以下這個改寫過的Adapter則是只要有包含已輸入的字串都會顯示出來。
例如:List當中有"安全"、"安心"、"保安"、"偏安"、"討厭"
輸入"安",會搜尋出所有有"安"的String"安全"、"安心"、"保安"、"偏安"
而"討厭"裡面沒有"安"所以就搜尋不到
Usage:
原本的ArrayAdapter的自動完成只會搜尋到以已輸入的字串為開頭的字串。
(因為ArraryAdapter的Filter是用startWith去找字串)
例如:List當中有"安全"、"安心"、"保安"、"偏安"、"討厭"
輸入"安",只會搜尋出"安全"、"安心"
而"保安"、"偏安"就搜尋不到
"討厭"也是一樣搜尋不到
以下這個改寫過的Adapter則是只要有包含已輸入的字串都會顯示出來。
例如:List當中有"安全"、"安心"、"保安"、"偏安"、"討厭"
輸入"安",會搜尋出所有有"安"的String"安全"、"安心"、"保安"、"偏安"
而"討厭"裡面沒有"安"所以就搜尋不到
Usage:
AppCompatAutoCompleteTextView mAutoCompleteText; List<String> list; // find view by id // ... mAutoCompleteText.setAdapter(new AutoCompleteAdapter(getContext(), android.R.layout.simple_spinner_item, list));
2015-09-11
[Android] 如何改變DatePicker的Divider的顏色 (How to change the divider color of the DatePicker)
這是一個可以自己從xml指定Divider的顏色的DatePicker
可以把像下圖這樣的Spinner DatePicker的Divider從藍色換成別的自己指定的顏色
We can change the divider color of DatePicker from blue to any other color you want.
2015-08-04
[Android] 字串比較的兩種方式的比較 Comparison of Two ways of String Comparison: TextUtils.equals() and String.equals()
字串比較的兩種方式的比較
Comparison of Two ways of String Comparison:
TextUtils.equals() and String.equals()
[Java] String.valueOf() 和 Integer.toString(), Long.toString, Double.toString的差異. 為何String.valueOf()比較好?Why String.valueOf() is better than toString()?
為何String.valueOf()比 Integer.toString(), Long.toString, Double.toString好?
Why String.valueOf() is better than toString()?
1. If a value is null.
toString() would throw NullPointerException.
String.valueOf() would return a String "null".
當輸入值為null, String.valueOf()不會發生Exception.
2.
像這樣的一個function
public String example1(int num, boolean boo) {
return Integer.toString(num) + Boolean.toString(boo);
}
如果參數的type改變了, 那麼implemention就也要跟著改變
If the type of num and boo is changed, the the implementation have to change depends on the type of num and boo.
但如果使用String.valueOf() 那麼就不用改變implementation了
像下面這個function, 就算參數的type一直改, function implementation也都不用改
You don't have to change implementation when the type of num and boo is changed.
public String example2(int num, boolean boo) {
return String.valueOf(num) + " " + String.valueOf(boo);
}
3.
2015-07-20
[Android] 一天有幾毫秒? 一星期有幾毫秒? 一年有幾毫秒? 使用DateUtils的Constants! How many milliseconds in one Day? Week? Year?
一天有幾毫秒?
一星期有幾毫秒?
一年有幾毫秒?
使用DateUtils的Constants!
http://developer.android.com/reference/android/text/format/DateUtils.html
DateUtils.SECOND_IN_MILLIS
DateUtils.MINUTE_IN_MILLIS
DateUtils.HOUR_IN_MILLIS
DateUtils.DAY_IN_MILLIS
DateUtils.WEEK_IN_MILLIS
DateUtils.YEAR_IN_MILLIS
2015-06-27
[Android] 從鈴聲的URI取得鈴聲的標題名稱. Get ringtone title from ringtone uri
String getRingtoneTitle(String ringtoneUriString) {
String defaultRingtoneTitle = "No Ringtone";
Uri ringtoneUri = null;
try {
ringtoneUri = Uri.parse(ringtoneUriString);
} catch (Exception ignored) {
Logcat.w(ignored, "Settings parse notification ringtone uri fail."
+ "ringtoneUriString = ", ringtoneUriString);
}
if (ringtoneUriString.isEmpty() || ringtoneUri == null) {
return defaultRingtoneTitle;
}
Context context = getContext();
Ringtone ringtone = RingtoneManager.getRingtone(context, ringtoneUri);
if (ringtone == null) {
return defaultRingtoneTitle;
}
return ringtone.getTitle(context);
}
[Android] 如何設定"提醒"的聲音、閃光、震動形式. How to set the Sound, Lights, and Vibrate of a Notification
If you don't want any ringtone, don't set Notification.DEFAULT_SOUND to setDefault(), and don't call setSound(ringtoneUri) of NotificationCompat.Builder.
If you just want default ringtone, call setDefault(Notification.DEFAULT_SOUND);
If you just want default vibrate, call setDefault(Notification.DEFAULT_VIBRATE);
If you just want default lights, call setDefault(Notification.DEFAULT_LIGHTS);
If you need a custom ringtone, call setSound(ringtoneUri), but don't call setDefault(DEFAULT_ALL) or setDefault(DEFAULT_SOUND).
Because setDefault(DEFAULT_ALL) or setDefault(DEFAULT_SOUND) make setSound(ringtoneUri) useless.
Check here about how to use Ringtone Picker to get a ringtone Uri.
http://codeviki.blogspot.tw/2015/06/android-show-ringtone-picker-activity.html
Check here about how to get ringtone title from ringtone Uri.
http://codeviki.blogspot.tw/2015/06/android-get-ringtone-title-from-ringtone-uri.html
If you just want default ringtone, call setDefault(Notification.DEFAULT_SOUND);
If you just want default vibrate, call setDefault(Notification.DEFAULT_VIBRATE);
If you just want default lights, call setDefault(Notification.DEFAULT_LIGHTS);
If you need a custom ringtone, call setSound(ringtoneUri), but don't call setDefault(DEFAULT_ALL) or setDefault(DEFAULT_SOUND).
Because setDefault(DEFAULT_ALL) or setDefault(DEFAULT_SOUND) make setSound(ringtoneUri) useless.
Check here about how to use Ringtone Picker to get a ringtone Uri.
http://codeviki.blogspot.tw/2015/06/android-show-ringtone-picker-activity.html
Check here about how to get ringtone title from ringtone Uri.
http://codeviki.blogspot.tw/2015/06/android-get-ringtone-title-from-ringtone-uri.html
static Notification buildNotification(
boolean vibrateEnabled,
boolean lightsEnabled,
String ringtoneUriString)
{
int defaults = 0;
// set vibrate to defaults
if (vibrateEnabled) {
// use default vibrate pattern
defaults |= Notification.DEFAULT_VIBRATE;
}
// set lights to defaults
if (lightsEnabled) {
// use default light blink pattern
defaults |= Notification.DEFAULT_LIGHTS;
}
// parse ringtone
Uri ringtoneUri = null;
try {
ringtoneUri = Uri.parse(ringtoneUriString);
} catch (Exception ignored) {
Logcat.w(ignored, "Parse notification ringtone uri fail. "
+ "ringtoneUriString = ", ringtoneUriString);
// if parse ringtone fail, use default ringtone
defaults |= Notification.DEFAULT_SOUND;
}
NotificationCompat.Builder builder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.my_notification_icon)
.setContentTitle("title")
.setContentText("contentText")
.setAutoCancel(true)
.setDefaults(defaults);
// if ringtoneUriString is empty string, the uri won't be null
if (!ringtoneUriString.isEmpty() && ringtoneUri != null) {
builder.setSound(ringtoneUri);
}
return builder.build();
}
[Android] 顯示讓使用者選擇鈴聲的對話方塊. Show Ringtone Picker Activity
// just define a unique int for this ringtone picker activity
public static final int RINGTONE_PICKER_REQUEST = 10;
void showRingtonePicker() {
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
Activity activity =getActivity();
if (activity == null) {
return;
}
try {
activity.startActivityForResult(intent, RINGTONE_PICKER_REQUEST);
} catch (ActivityNotFoundException ignored) {
Logcat.e(ignored, "Settings showRingtonePicker error");
}
}
To get the result of ringtone picker, override onActivityResult in Activity.
@Override public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode != RINGTONE_PICKER_REQUEST || resultCode != Activity.RESULT_OK) {
return false;
}
Uri ringtoneUri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
// if user choose "no ringtone" in the ringtone picker, the ringtoneUri would be null.
String ringtoneUriString = "";
if (uri != null) {
ringtoneUriString = uri.toString();
}
// TODO : save the ringtoneUri or ringtoneUriString to anywhere you want
return true;
}
2015-05-18
[Android] 讀取放在專案內的assets資料夾中的檔案到一個String變數當中. Read files in assets to String
If we have a file named "licenses.html" under [your project]/src/main/assets/ ,
you can use the following function to read its content to a String.
String readLicensesHtml() {
StringBuilder buf = new StringBuilder();
InputStream stream;
BufferedReader in;
String str;
try {
stream = getAssets().open("licenses.html");
in = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
while ((str = in.readLine()) != null) {
buf.append(str);
}
in.close();
} catch (IOException ignored) {
Log.e(DEBUG_TAG, ignored.getMessage(), ignored);
}
return buf.toString();
}
[Android] 在AlertDialog當中顯示HTML格式的字串. Show HTML String in a AlertDialog
Show HTML String in a AlertDialog.
But not all html tag is supported.
See HTML tags supported by TextView.
https://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html
/**
* Show HTML String is AlertDialog
*/
static void showHtmlDialog(Context context, String title, String htmlString) {
new AlertDialog.Builder(context)
.setTitle(title)
.setMessage(Html.fromHtml(htmlString))
.setPositiveButton(android.R.string.ok, null)
.show();
}
Usage :
showHtmlDialog(this, "This is HTML", "<html><body>This is HTML</body></html>");
訂閱:
文章 (Atom)










