Skip to content

Instantly share code, notes, and snippets.

View twiceyuan's full-sized avatar

twiceYuan twiceyuan

View GitHub Profile
@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
@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: hans...@meetme.com, vs...@google.com
###########################################################
@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;

Parse -> LeanCloud 文件迁移工具

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

依赖: gevent、requests

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

@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.
@tsuharesu
tsuharesu / AddCookiesInterceptor.java
Last active June 8, 2024 07:30
Handle Cookies easily with Retrofit/OkHttp
/**
* This interceptor put all the Cookies in Preferences in the Request.
* Your implementation on how to get the Preferences MAY VARY.
* <p>
* Created by tsuharesu on 4/1/15.
*/
public class AddCookiesInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active May 7, 2024 13:07
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@JakeWharton
JakeWharton / ForegroundImageView.java
Created July 10, 2014 16:42
An ImageView which supports a foreground drawable.
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
public class ForegroundImageView extends ImageView {
private Drawable foreground;
@alexfu
alexfu / DividerItemDecoration.java
Last active February 9, 2023 05:09
An ItemDecoration that draws dividers between items. Pulled from Android support demos.
/*
* Copyright (C) 2014 The Android Open Source Project
*
* 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
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active June 8, 2024 10:07
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k