Skip to content

Instantly share code, notes, and snippets.

View twiceyuan's full-sized avatar

twiceYuan twiceyuan

View GitHub Profile
@twiceyuan
twiceyuan / CheckableLayout.java
Last active January 16, 2017 07:00
可以保存 Check 状态的 LinearLayout
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Checkable;
import android.widget.LinearLayout;
/**
* This is a simple wrapper for {@link android.widget.LinearLayout} that implements the {@link android.widget.Checkable}
* interface by keeping an internal 'checked' state flag.

Parse -> LeanCloud 文件迁移工具

注意:这个工具是用来导入到中国区节点的

依赖: gevent、requests

Ubuntu 可以 # apt-get install python-gevent python-requests

@twiceyuan
twiceyuan / ScaleInTransformer.java
Created September 13, 2016 07:07
ViewPager 实现 Gallery 效果。主要依靠设置 clipChildren 属性和 ViewPager.Transformer 接口实现
import android.os.Build;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
import android.view.View;
public class ScaleInTransformer implements ViewPager.PageTransformer {
@Override
public void transformPage(View view, float position) {
float scale = 0.5f;
@mauron85
mauron85 / keep-adb-running.sh
Created September 22, 2016 09:55
Workaround adb disconnecting issue on macOS Sierra
#!/bin/bash
cat << EOF
###########################################################
# Workaround adb disconnecting issue on macOS Sierra
#
# More info:
# https://code.google.com/p/android/issues/detail?id=219085
# credits to: [email protected], [email protected]
###########################################################
@rednaxelafx
rednaxelafx / Demo$$Lambda$1.javap
Created October 12, 2016 08:20
Java 8 serializable lambda pitfall example, https://www.zhihu.com/question/51491241
$ javap -verbose -c -s -l -private Demo\$\$Lambda\$1
Classfile /private/tmp/Demo$$Lambda$1.class
Last modified Oct 12, 2016; size 754 bytes
MD5 checksum 81ce9dafbca34417b2dfa94f596a85a1
final class Demo$$Lambda$1 implements org.apache.spark.api.java.function.VoidFunction
minor version: 0
major version: 52
flags: ACC_FINAL, ACC_SUPER, ACC_SYNTHETIC
Constant pool:
#1 = Utf8 Demo$$Lambda$1
@mengdd
mengdd / ProcessUtils
Created November 10, 2016 02:46
method to check if is on main process
import android.app.ActivityManager;
import android.content.Context;
import android.os.Process;
import android.util.Log;
import java.util.List;
public class ProcessUtils {
@arvi
arvi / OkHttpStack.java
Created November 30, 2016 05:03 — forked from NightlyNexus/OkHttpStack.java
OkHttp 3 implementation of Volley's HttpStack
/*
* Copyright (C) 2016 Eric Cochran
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@douglasselph
douglasselph / AndroidEasySetLangCountry
Created March 15, 2017 21:13
The following allows you to very easily flip between languages and country on Android.
The following allows you to very easily flip between languages and country on Android.
This will IMMEDIATELY cause the change without even needing to shut down the target testing app.
(That is, the currently displayed page will reloaded.)
You first need to install this APP on the phone:
https://play.google.com/store/apps/details?id=net.sanapeli.adbchangelanguage&hl=en
Then to flip copy and paste one of the lines below in a terminal.
@konrad-kaminski
konrad-kaminski / CountDownLatch.kt
Last active July 14, 2022 23:50
CountDownLatch naive implementation
/*
* Copyright 2016-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
import functools
def log(func):
@functools.wraps(func)
def wrapper(*args):
print(u"request body: {}".format(args[0]))
response = func(*args)
print u"response body: {}".format(response)
return response