This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Field; | |
import java.lang.reflect.InvocationTargetException; | |
import java.lang.reflect.Method; | |
/** | |
* 方法类 | |
* @author syh | |
* | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Changes XML to JSON | |
* Modified version from here: http://davidwalsh.name/convert-xml-json | |
* @param {string} xml XML DOM tree | |
*/ | |
function xmlToJson(xml) { | |
// Create the return object | |
var obj = {}; | |
if (xml.nodeType == 1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nonebot.adapters import Event, Message | |
from nonebot.params import EventPlainText, CommandArg | |
from nonebot.plugin.on import on_message, on_command | |
from nonebot.adapters.onebot.v11.message import MessageSegment | |
import os | |
import ast | |
import json | |
import shelve | |
import aiohttp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*最近在研究网络请求数据解析的问题,发现json数据被强制转换为map结构的时候,会出现int变成double的问题 | |
*在stackoverflow上看到了一个这个How can I prevent gson from converting integers to doubles 的问题,采用了这个答案 | |
*https://stackoverflow.com/a/36529534/5279354答案 | |
*/ | |
import com.google.gson.JsonArray; | |
import com.google.gson.JsonDeserializationContext; | |
import com.google.gson.JsonDeserializer; | |
import com.google.gson.JsonElement; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int getCurrentCountryCode(Context context) { | |
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); | |
String countryIso = telephonyManager.getSimCountryIso().toUpperCase(); | |
return PhoneNumberUtil.getInstance().getCountryCodeForRegion(countryIso); | |
} | |
PhoneNumberUtil 引用自 | |
compile 'com.googlecode.libphonenumber:libphonenumber:8.3.1' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//语言和编码 | |
<?php language_attributes(); ?> //语言属性 | |
//根据不同情况来读取 title | |
<?php | |
global $page, $pages; | |
wp_title( '|', true, 'right'); //在标题的左方或右方 | |
bloginfo( 'name' ); //博客的名称 | |
$site_description = get_bloginfo( 'description', 'Display' ); //博客的描述 | |
if( $site_description && ( is_home() || is_front_page() ) ) //如果是首页,则输出博客名称和描述 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Author: Michael Fields | |
* Source: http://wordpress.mfields.org/2010/set-default-terms-for-your-custom-taxonomies-in-wordpress-3-0/ | |
* Thanks a lot for the nice tweak | |
*/ | |
/** | |
* Define default terms for custom taxonomies in WordPress 3.0.1 | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[mysqld] | |
# /etc/my.cnf | |
performance_schema = 0 | |
innodb_buffer_pool_size=5M | |
innodb_log_buffer_size=256K | |
query_cache_size=0 | |
max_connections=10 | |
key_buffer_size=8 | |
thread_cache_size=0 | |
host_cache_size=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//A Kotlin object (singleton) that handles the copying with mulitple different arguments | |
object CopyBytes { | |
@Throws(IOException::class) | |
fun copy(input: InputStream, output: OutputStream) { | |
//Creating byte array | |
val buffer = ByteArray(1024) | |
var length = input.read(buffer) | |
//Transferring data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copy from https://stackoverflow.com/a/49063199/5279354 | |
Retrofit retrofit = new Retrofit.Builder() | |
.baseUrl(YOUR_BASE_URL) | |
.client(getUnsafeOkHttpClient().build()) | |
.build(); | |
public static OkHttpClient.Builder getUnsafeOkHttpClient() { | |
try { |
NewerOlder