Skip to content

Instantly share code, notes, and snippets.

@tysheng
tysheng / compress.py
Created March 14, 2023 02:34 — forked from rayrinaldy/compress.py
Image Compression with Python
#!/usr/bin/env python
# Author: Ray Rinaldy
# pip install Pillow
# put this script in every image folder that wants to be converted
# run python compress.py
#
# This script will works on .jpg, .jpeg & .png (for png files, it will auto convert to have white background)
import os, glob, PIL, sys
@tysheng
tysheng / imu.c
Created February 9, 2023 15:06 — forked from jannson/imu.c
陀螺仪重力传感器融合代码
//=====================================================================================================
// IMU.c
// S.O.H. Madgwick
// 25th September 2010
//=====================================================================================================
// Description:
//
// Quaternion implementation of the 'DCM filter' [Mayhony et al].
//
// User must define 'halfT' as the (sample period / 2), and the filter gains 'Kp' and 'Ki'.
@tysheng
tysheng / PositionBottomNavigationView.java
Created December 31, 2016 10:24
Custom BottomNavigationView
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.util.AttributeSet;
import android.util.SparseIntArray;
import android.view.Menu;
import android.view.MenuItem;
/**
* Created by tysheng
@tysheng
tysheng / BaseMultiItemAdapter.java
Created December 16, 2016 01:49
a new MultiItemAdapter for BaseQuickAdapter(2.6.6)
/**
* Created by tysheng
* Date: 2016/11/18 10:59.
* Email: tyshengsx@gmail.com
*/
public abstract class BaseMultiItemAdapter<T> extends BaseRecyclerViewAdapter<T> {
private static final int DEFAULT_VIEW_TYPE = -255;
private SparseIntArray layouts;
@tysheng
tysheng / NoBlinkItemAnimator.java
Created December 13, 2016 11:11
No blink ItemAnimator for recyclerView
/*
* 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
@tysheng
tysheng / BaseRecyclerViewAdapter.java
Last active March 9, 2017 08:17
Base adapter for BaseQuickAdapter(version 2.8.0)
/**
* Base adapter for BaseQuickAdapter
* Attention: all method called after setAdapter().
* Created by tysheng
* Date: 16/9/18 09:18.
* Email: tyshengsx@gmail.com
*/
public abstract class BaseRecyclerViewAdapter<T> extends BaseQuickAdapter<T, StyBaseViewHolder> {
protected RecyclerView mRecyclerView;
@tysheng
tysheng / LazyFragment.java
Created November 17, 2016 13:48
A fragment can be lazy.
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@tysheng
tysheng / NineView.java
Last active July 27, 2016 15:10
类似微信朋友圈的九图,List为空时自动隐藏,1-9图自动识别,只需简单继承和使用
public abstract class NineView extends LinearLayout {
public static int MAX_WIDTH = 0;
// 照片的Url列表
private List<String> mImagesList;
protected Context mContext;
/**
* 长度 单位为Pixel