Skip to content

Instantly share code, notes, and snippets.

@twocity
twocity / android_meta.md
Created October 22, 2015 08:37
android meta data
WIFI_MAC_ADDRESS
BLUETOOTH_MAC_ADDRESS
ANDROID_ID
// IMEI
ANDROID_DEVICE_ID
/** A hardware serial number, if available.  Alphanumeric only, case-insensitive. */ 
ANDROID_SERIAL
// 安装后生成的唯一ID
INSTALL_ID
@twocity
twocity / SimpleHeaderDecoration.java
Last active February 7, 2022 12:22
An empty header (or footer) decoration for RecyclerView, since RecyclerView can't clipToPadding
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;
/**
* An empty header (or footer) decoration for RecyclerView, since RecyclerView can't clipToPadding
*/
public class SimpleHeaderDecoration extends RecyclerView.ItemDecoration {
private final int headerHeight;
private final int footerHeight;
@twocity
twocity / gist:77a8fee425cff40c27a9
Created July 27, 2015 10:52
getDefaultUserAgent
/**
* Returns an HTTP user agent of the form
* "Dalvik/1.1.0 (Linux; U; Android Eclair Build/MASTER)".
*/
private static String getDefaultUserAgent() {
StringBuilder result = new StringBuilder(64);
result.append("Dalvik/");
result.append(System.getProperty("java.vm.version")); // such as 1.1.0
result.append(" (Linux; U; Android ");
_googleplayDebugCompile - ## Internal use, do not manually configure ##
+--- com.android.support:multidex:1.0.1
+--- project :core
| +--- com.android.support:support-annotations:22.1.1
| +--- com.google.code.gson:gson:2.3 -> 2.3.1
| +--- com.squareup.retrofit:retrofit:1.9.0
| | \--- com.google.code.gson:gson:2.3.1
| +--- com.squareup.okhttp:okhttp:2.4.0-RC1
| | \--- com.squareup.okio:okio:1.4.0
| +--- io.reactivex:rxjava:1.0.3
#export GITAWAREPROMPT=~/.bash/git-aware-prompt
#source $GITAWAREPROMPT/main.sh
export CLICOLOR=1
export PATH=~/bin:$PATH
export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/lib:$PATH
export PATH=${PATH}:/usr/local/lib/node_modules/hexo-cli/bin/
export PATH=${PATH}:~/Library/gradle
export PATH=${PATH}:~/Library/gradle/bin
export PATH=${PATH}:/Users/twocity/Documents/android/adt-bundle/sdk
@twocity
twocity / course.json
Last active August 29, 2015 14:22
download 100xue course
{
"code": "OK",
"message": null,
"result": [
{
"id": "fa1005fc4b3c48d3014b4970168615d5",
"parentId": null,
"courseCollectId": "fa1005fc4b323c76014b395696445398",
"title": "工程造价管理及其基本制度",
"playUrl": null,
Step1
Remove deprecated modules(overide, library,complete),ObjectGraph
Step2
Define Dagger2 style Component and module
Step3
Inject
@ApplicationScope
ApplicationComponent
NetworkModule
Okhttp
@twocity
twocity / BindingGraphValidator.md
Last active August 29, 2015 14:22
validateDependencyScopes
/**
   * Validates that among the dependencies are at most one scoped dependency,
   * that there are no cycles within the scoping chain, and that singleton
   * components have no scoped dependencies.
   */
  private void validateDependencyScopes(BindingGraph subject,
      Builder<BindingGraph> reportBuilder) {
    ComponentDescriptor descriptor = subject.componentDescriptor();
    Optional<AnnotationMirror> scope = subject.componentDescriptor().scope();
### Run this script via a cronjob every (every minute or so) on a server that has access to your dropbox.
### You must install youtube-dl (http://rg3.github.com/youtube-dl/) for this to work.
#!/bin/bash
QUEUE_DIR=~/Desktop/Dropbox/IFTTT/youtube-dl/*.txt
VIDEO_DIR=~/Desktop/Dropbox/youtube/
shopt -s nullglob
for queue_file in $QUEUE_DIR
do
video_url=`cat "$queue_file"`;
@twocity
twocity / gist:0eab5e5075a8a2d3dd1e
Created September 24, 2014 10:26
DemoObserverActivity
public class DemoObserverActivity extends ObserverActivity<String> {
final Observable<String> observable = Observable.just("hello", "world");
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
loadData();
loadData2();
}
private void loadData() {