Skip to content

Instantly share code, notes, and snippets.

@shakalaca
shakalaca / android
Created Nov 23, 2011
patch for mobile data limitation
View android
--- ./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 Dec 17, 2011
su-binary patch for ics 4.0.3 (sdk 15)
View gist:1489990
--- 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 */
+ }
View OpenSourceEnlightenment.md

開源之道

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

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

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

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

@shakalaca
shakalaca / gist:4251100
Created Dec 10, 2012
Detect current window size for Samsung Multi-Window system
View gist:4251100
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 Dec 27, 2012
透過瀏覽 URL 的方式開啟特定 app, 如果 user 沒有安裝該 app, 則導引到 Play Store 提示使用者安裝.
View .htaccess
Redirect /path_to_redirect market://details?id=com.example.package
@shakalaca
shakalaca / fb.java
Created Jan 4, 2013
點擊按鈕導引使用者進入 Facebook 專頁, 如果使用者有安裝 facebook client, 由它開啟, 否則開啟行動版網頁.
View fb.java
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 Feb 28, 2013
透過 homebrew 切換不同版本的 gradle
View SwitchGradle.txt
[shakalaca@Shakas-MacBook-Pro.local:~ ]
$ cd /usr/local/
[shakalaca@Shakas-MacBook-Pro.local:~ ]
$ 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
View Example_RootTools_sdk3_generic_build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
@shakalaca
shakalaca / FRelativeLayout.java
Created Aug 10, 2013
RelativeLayout with foreground like FrameLayout does.
View FRelativeLayout.java
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 {
View PRNGFixes.java
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;
You can’t perform that action at this time.