Skip to content

Instantly share code, notes, and snippets.

View xmaihh's full-sized avatar
🗡️

xmaihh

🗡️
  • 12:37 (UTC -12:00)
View GitHub Profile
@xmaihh
xmaihh / keyboardheightobserver.md
Last active November 2, 2018 02:12
监听布局的变化来计算输入法的高度

监听布局的变化来计算输入法的高度,这种方式在Activity的配置中配置为"android:windowSoftInputMode="adjustResize""时没有问题,可以正确获取输入法的高度,因为布局此时确实会动态的调整。 但是当Activity配置为"android:windowSoftInputMode="adjustNothing""时,布局不会在输入法弹出时进行调整

KeyboardHeightObserver.java

/**
 * The observer that will be notified when the height of 
 * the keyboard has changed
 */
public interface KeyboardHeightObserver {
@xmaihh
xmaihh / Java-base64util.md
Last active December 28, 2018 03:30
图片Base64

Android中ImageView加载Base64图片其实非常简单,并不需要引入第三方库,方法如下:

import android.util.Base64;

代码片段

String base64 = "data:image/png;base64, x.xx.x.xx..."
byte[] decodedString = Base64.decode(base64, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
imageView.setImageBitmap(decodedByte);
@xmaihh
xmaihh / fake-useragent.md
Last active November 2, 2018 02:09
python之构造随机请求头

Installation

pip install fake-useragent

Usage

from fake_useragent import UserAgent
ua = UserAgent()

ua.ie
@xmaihh
xmaihh / QRCodeUtil.java
Created December 6, 2018 03:51
QRCodeUtil.java
package xmaihh.pay.zxing;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.PointF;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

git设置和取消代理

git config --global https.proxy http://127.0.0.1:1080

git config --global https.proxy https://127.0.0.1:1080

git config --global --unset http.proxy

git config --global --unset https.proxy
/**
 * 节气计算类
 */
public final class SolarTerm {
    // 提供定位的年份
    private static final int baseYear = 1901;

    /**
     * 计算公历年当月的中气,公历月从0起始!
@xmaihh
xmaihh / SendEmailUtils.md
Last active July 23, 2019 09:10
Java邮件发送程序
public class SendEmailUtils {

    /**
     * 邮件发送程序
     *
     *           接收邮件的address
     * @param subject
     *            邮件主题
     * @param content
@xmaihh
xmaihh / ByteArray.kt
Created June 30, 2020 08:57 — forked from fabiomsr/ByteArray.kt
ByteArray and String extension to add hexadecimal methods in Kotlin
private val HEX_CHARS = "0123456789ABCDEF".toCharArray()
fun ByteArray.toHex() : String{
val result = StringBuffer()
forEach {
val octet = it.toInt()
val firstIndex = (octet and 0xF0).ushr(4)
val secondIndex = octet and 0x0F
result.append(HEX_CHARS[firstIndex])
@xmaihh
xmaihh / close_p.sh
Last active March 25, 2022 09:54
Close the progress by name.
#!/bin/bash
echo "*********************************"
echo "Close the progress by name!"
echo "usage: ./close_p.sh progressName"
echo "*********************************"
echo
#echo "PID of this script: $$"
#echo "PPID of this script: $PPID"
@xmaihh
xmaihh / ylgy.js
Created September 27, 2022 03:34
ylgy.js
console.log('ylgy script start');
var Body = JSON.parse($response.body);
switch ($request.url.match(/map|personal|json/)[0]){
case "map":
Body.data.map_md5[1] = '046ef1bab26e5b9bfe2473ded237b572';
break;
case "personal":
var objk = Body.data;
objk["daily_count"] = "1e+308";
objk["nick_name"] = "金字塔的顶端";