Skip to content

Instantly share code, notes, and snippets.

View hellowmq's full-sized avatar
🐱
love tech & coding

DaftKen hellowmq

🐱
love tech & coding
View GitHub Profile
@hellowmq
hellowmq / AndroidStudioInspection.xml
Last active July 29, 2025 02:48
AndroidStudio 中一些语法结构检查,可以避免一些低级错误。低级错误不会永远不发生,但是只要有恰当的提示,就可以意识到。(无能之错比无知之错更不能接受)
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="15081240-e5f7-3bc9-a0ad-c3b1d502c560" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="18972239-2a78-3b70-9e07-0aabf0a5ccd4" enabled="true" level="ERROR" enabled_by_default="true" editorAttributes="ERRORS_ATTRIBUTES" />
<inspection_tool class="1948d804-a1bc-3721-8cc5-64a4898bd260" enabled="true" level="ERROR" enabled_by_default="true" editorAttributes="ERRORS_ATTRIBUTES" />
<inspection_tool class="9c5d90f8-66c5-3330-90fb-c3178656cadc" enabled="true" level="WEAK WARNING" enabled_by_default="true" editorAttributes="INFO_ATTRIBUTES" />
<inspection_tool class="SSBasedInspection" enabled="true" level="WARNING" enabled_by_default="true">
<searchConfiguration name="ConstraintLayout 使用 match_parent" description="ConstraintLayout 不建议使用 match_parent 约束&amp;#10;建议使用 0dp + 双向 parent 约束来处理" text="&lt;androidx.constraintlayout.widget.ConstraintLayout $pT$&gt;&#10; $prefix$&#
@hellowmq
hellowmq / TestWhenStatement.kt
Last active June 8, 2022 05:34
Kotlin 基础: when 语句研究:在 when 逻辑用作语句时,限制了入参类型为:密封类、枚举类和 Boolean 下的强制 else 逻辑
/***
* 枚举类型定义
*/
enum class Color {
RED, GREEN, BLUE
}
/***
* 密封类定义
*/
@hellowmq
hellowmq / PowerOfTwoSolution.java
Created February 25, 2022 17:45
位运算用于2的幂
package com.wenmq.algo.binary;
/**
* 二进制对于 2 的指数的优化
*/
public class PowerOfTwoSolution {
/**
* 判断一个数是不是 2 的非负整数次幂:
*
@hellowmq
hellowmq / javac.java
Created September 24, 2020 15:53
javac 中的 String 字面量在编译时会校验长度。因此定义字符串字面量时长度不能大于 65534。
private void checkStringConstant(DiagnosticPosition var1, Object var2) {
if (this.nerrs == 0 && var2 != null && var2 instanceof String && ((String)var2).length() >= 65535) {
this.log.error(var1, "limit.string", new Object[0]);
++this.nerrs;
}
}
@hellowmq
hellowmq / TAliPackageChangedReceiver.java
Created September 15, 2020 11:24
嗅探安装事件及包名
package com.hellowmq.third;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.to8to.api.network.TCommonParamsManager;
/**
* Created by @ifans.wen
@hellowmq
hellowmq / SingletonBestArray.java
Last active September 22, 2020 06:05
Singleton 单例模式的兼顾性能,线程安全和简洁的三种写法。
package com.wenmq.algo.design;
public class SingletonBestArray {
/**
* 线程安全
* 双检查锁机制保证性能
* 延迟初始化
*/
public static class DoubleLockSingleton {
public volatile static DoubleLockSingleton _instance;
@hellowmq
hellowmq / compare_version.dart
Created June 9, 2020 09:16
A sample of compare a String-type version code.
int compareVersion(String version1, String version2) {
List<String> nums1 = version1.split("\.");
List<String> nums2 = version2.split("\\.");
int i = 0, j = 0;
while (i < nums1.length || j < nums2.length) {
String num1 = i < nums1.length ? nums1[i] : "0";
String num2 = j < nums2.length ? nums2[j] : "0";
int res = compare(num1, num2);
if (res == 0) {
i++;
@hellowmq
hellowmq / dart-tear-offs-sample.dart
Created March 12, 2020 16:45
This is a example of dart tear-offs.
/// This is a example of dart tear-offs.
/// a "tear-offs" is a closure that takes the same parameters as the method and invokes it when you call it.
List<int> a = [1,2,3,4,5,6];
Map<int,String> b = new Map()
..[0]= "0000"
..[1]= "1111"
..[2]= "2222"
..[3]= "3333";
@hellowmq
hellowmq / weiboSpider.py
Last active February 23, 2020 11:40
爬取指定微博用户的微博内容,存到 MongoDB
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 21 12:41:20 2018
@author: bdmin
"""
import requests
from urllib.parse import urlencode
from pyquery import PyQuery as pq
@hellowmq
hellowmq / testAnimationList.dart
Last active August 13, 2020 05:21
This examplae show the list of animation test. View onDartPad https://dartpad.dev/89cbe63d036ef05dba1e3375141dddc8
// Copyright 2019 the Dart project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file.
import 'package:flutter/material.dart';
import 'dart:math' as math;
final Color primaryColor = Colors.red;
final TargetPlatform platform = TargetPlatform.android;