Skip to content

Instantly share code, notes, and snippets.

@shakalaca
shakalaca / android
Created November 23, 2011 06:52
patch for mobile data limitation
--- ./frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java~ 2011-11-15 08:04:40.000000000 +0800
+++ ./frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java 2011-11-23 11:26:00.781355800 +0800
@@ -1472,6 +1472,9 @@
loadBooleanSetting(stmt, Settings.Secure.TOUCH_EXPLORATION_ENABLED,
R.bool.def_touch_exploration_enabled);
+
+ loadBooleanSetting(stmt, Settings.Secure.NETSTATS_ENABLED,
+ R.bool.def_netstats_enabled);
} finally {
@shakalaca
shakalaca / gist:1489990
Created December 17, 2011 11:25
su-binary patch for ics 4.0.3 (sdk 15)
--- activity.cpp.old 2011-12-17 19:24:35.339670212 +0800
+++ activity.cpp 2011-12-17 19:18:13.427670430 +0800
@@ -75,6 +75,10 @@
// added in eclair rev 7
data.writeInt32(0);
}
+ if (sdk_version >= 15) {
+ // added in IceCreamSandwich 4.0.3
+ data.writeInt32(0); /* Selector */
+ }

開源之道

Original transcript: http://allisonrandal.com/2012/04/15/open-source-enlightenment/

這幾年來,我慢慢覺得,我們參與開源社群,就像是在一條道路上並肩而行:這不僅讓我們成為更好的程式設計者,也讓我們通過與人合作,而成為更好的人。

您可以將它想成一條修行之道,讓身而為人的我們能夠不斷成長。接下來,我想談談我對開源世界的個人觀點,希望能與您分享。

首先,人是一切開源專案的核心。程式碼是很重要,但最核心的永遠是人。

@shakalaca
shakalaca / gist:4251100
Created December 10, 2012 15:05
Detect current window size for Samsung Multi-Window system
mRootContainer = (RelativeLayout) findViewById(R.id.root_container);
ViewTreeObserver vto = mRootContainer.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// get current window size
int newWidth = mRootContainer.getWidth();
int newHeight = mRootContainer.getHeight();
@shakalaca
shakalaca / .htaccess
Created December 27, 2012 15:13
透過瀏覽 URL 的方式開啟特定 app, 如果 user 沒有安裝該 app, 則導引到 Play Store 提示使用者安裝.
Redirect /path_to_redirect market://details?id=com.example.package
@shakalaca
shakalaca / fb.java
Created January 4, 2013 07:29
點擊按鈕導引使用者進入 Facebook 專頁, 如果使用者有安裝 facebook client, 由它開啟, 否則開啟行動版網頁.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/<id>"));
List<ResolveInfo> activities = getPackageManager().queryIntentActivities(intent, 0);
if (activities.size() != 0) {
startActivity(intent);
} else {
intent.setData(Uri.parse("https://www.facebook.com/<你的專頁名稱>"));
startActivity(intent);
}
@shakalaca
shakalaca / SwitchGradle.txt
Created February 28, 2013 12:41
透過 homebrew 切換不同版本的 gradle
[[email protected]:~ ]
$ cd /usr/local/
[[email protected]:~ ]
$ brew versions gradle
1.4 git checkout 0b7303a /usr/local/Library/Formula/gradle.rb
1.3 git checkout c259bda /usr/local/Library/Formula/gradle.rb
1.2 git checkout 9b7d294 /usr/local/Library/Formula/gradle.rb
1.1 git checkout 7941972 /usr/local/Library/Formula/gradle.rb
1.0 git checkout dff67fb /usr/local/Library/Formula/gradle.rb
1.0-rc-3 git checkout 5f9e348 /usr/local/Library/Formula/gradle.rb
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
@shakalaca
shakalaca / FRelativeLayout.java
Created August 10, 2013 06:06
RelativeLayout with foreground like FrameLayout does.
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
public class FRelativeLayout extends RelativeLayout {
import android.os.Build;
import android.os.Process;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;