Skip to content

Instantly share code, notes, and snippets.

@410063005
410063005 / palindrome.js
Created November 22, 2019 02:33
回文检测
// https://www.freecodecamp.cn/challenges/check-for-palindromes
function palindrome(str) {
// 回文检测
str = str.replace('_', '');
str = str.replace(/\W/gi, '');
str = str.replace(/\s/gi, '');
str = str.toLowerCase();
newStr = str.split('').reverse().join('');
return str == newStr;
}
@410063005
410063005 / palindrome.js
Created November 22, 2019 02:33
回文检测
// https://www.freecodecamp.cn/challenges/check-for-palindromes
function palindrome(str) {
// 回文检测
str = str.replace('_', '');
str = str.replace(/\W/gi, '');
str = str.replace(/\s/gi, '');
str = str.toLowerCase();
newStr = str.split('').reverse().join('');
return str == newStr;
}
@410063005
410063005 / circle_avatar_with_placeholder.dart
Created October 29, 2019 02:57
(Flutter) 带 placeholder 的圆形网络头像
Widget circleAvatarWithBorder2(url) {
return Stack(
alignment: AlignmentDirectional.center,
children: <Widget>[
Container(
width: 32.0,
height: 32.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(50.0)),
border: Border.all(
@410063005
410063005 / comparable-contract-test.kt
Created September 27, 2019 08:09
用于验证 java.lang.IllegalArgumentException: Comparison method violates its general contract! 的测试用例
package com.tencent.tip.bitmapprofiler.extension
import org.junit.Test
import java.lang.ref.WeakReference
import java.util.*
import kotlin.collections.ArrayList
class ContractTest {
@Test
@410063005
410063005 / main.c
Created June 4, 2019 03:45
dlsym 示例。so 编译命令 gcc -fPIC -shared op.c -o libop.so
#include "op.h"
#include <dlfcn.h>
#include <stdio.h>
typedef int (*CACULATE_FUNC)(int, int);
int main(int argc, char* argv[])
{
dlerror();
@410063005
410063005 / AndroidManifest.xml
Created December 7, 2018 10:02
用于测试华为nova手机内存泄漏的demo
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.demo_glide">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name=".MyApp"
android:allowBackup="true"
@410063005
410063005 / Helper.java
Created July 26, 2018 08:43
用于打印当前MessageQueue中的所有Message
// usage: Choreographer.getInstance().postFrameCallback(new Helper());
public class Helper implements Choreographer.FrameCallback {
private static final String TAG = "IndexHelper";
private Field messagesField;
private Field nextField;
public Helper() {
try {
/*
* Copyright (C) 2016 Google Inc.
*
* 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
@410063005
410063005 / png_finder.py
Last active June 4, 2018 06:31
一个可寻找目录中重复图片文件的脚本,用于找到android项目中重复的图片资源
import os
import os.path
import hashlib
import sys
hash_array = {}
def file_md5(file_path):
md5 = hashlib.md5()
with file(file_path, "rb") as f:
@410063005
410063005 / CosClient.java
Last active February 2, 2018 07:18
CosClient 上传腾讯云对象存储服务
/**
* 上传腾讯云cos.
* <p>
* Created by 410063005 on 2018/1/31.
*/
// Config: https://cloud.tencent.com/document/product/436/12159
// Usage:
// File file = new File(Environment.getExternalStorageDirectory(), "hello.png");
// CosClient.create(IndexActivity.this, getAssets().open("heap.json")).upload(file);
public class CosClient {