Skip to content

Instantly share code, notes, and snippets.

View guananddu's full-sized avatar

James666 guananddu

  • ShenZhen
View GitHub Profile
@guananddu
guananddu / install-ripgrep-on-ubuntu.sh
Created May 15, 2019 13:13 — forked from cyio/install-ripgrep-on-ubuntu.sh
Install ripgrep on Debian / Ubuntu
#!/bin/bash
[[ $UID == 0 ]] || { echo "run as sudo to install"; exit 1; }
if ! [ -x "$(command -v jq)" ]; then
echo 'Error: jq is not installed.' >&2
apt install jq -y
fi
REPO="https://github.com/BurntSushi/ripgrep/releases/download/"
RG_LATEST=$(curl -sSL "https://api.github.com/repos/BurntSushi/ripgrep/releases/latest" | jq --raw-output .tag_name)
@guananddu
guananddu / WriteToFile.groovy
Created April 28, 2019 09:53 — forked from aaukhatov/WriteToFile.groovy
How to write String to File by Groovy
String content = 'Some text'
def myFile = new File('mySuperFile.txt')
myFile.write(content)
@guananddu
guananddu / - IDE Scripting.md
Created April 22, 2019 13:22 — forked from gregsh/- IDE Scripting.md
IDE Scripting

Here are my attempts to script an IntelliJ-based IDE.

IDE Scripting Console is backed by JSR-223 (javax.script.*) API.

Groovy, Clojure, JavaScript and other scripting languages may be used.

Open IDE Scripting Console, type a statement, hit Ctrl-Enter to execute the current line or selection.

.profile.language-extension file in the same directory will be executed along with it if present.

@guananddu
guananddu / KeyUtils.java
Created April 1, 2019 09:56 — forked from d-smith/KeyUtils.java
Read and write passwords to a Java keystore file
package keystuff;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.security.KeyStore;
public class KeyUtils {
public static FileInputStream getFileInputStreamFromArg(String filePath) throws FileNotFoundException {
@guananddu
guananddu / KeyUtils.java
Created April 1, 2019 09:56 — forked from d-smith/KeyUtils.java
Read and write passwords to a Java keystore file
package keystuff;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.security.KeyStore;
public class KeyUtils {
public static FileInputStream getFileInputStreamFromArg(String filePath) throws FileNotFoundException {
@guananddu
guananddu / java
Created March 21, 2019 07:53 — forked from Macrow/java
Android studio 统一替换JCenter为国内阿里云maven
摘要: jcenter替换为国内阿里云maven地址
在你的USER_HOME/.gradle/目录下,新建一个文件init.gradle
把这一段内容拷贝进去
以下为部分XML标志符的数字和字符串转义符:
“ 双引号 (" 或 ")
’ 单引号 (' 或 ')
& and符号 (& 或 &)
< 小于号 (&#60; 或 &lt;)
> 大于号 (&#62; 或 &gt;)
@ at符号 (&#64;)
© 版权 (&#169;或 &copy;)
® 注册商标 (&#174;或 &reg;)
@guananddu
guananddu / proguard-rules.pro
Created March 28, 2018 09:56 — forked from kosiara/proguard-rules.pro
RxJava RxAndroid Proguard rules
#build.gradle
#
# compile 'io.reactivex:rxandroid:1.0.1'
# compile 'io.reactivex:rxjava:1.0.14'
# compile 'io.reactivex:rxjava-math:1.0.0'
# compile 'com.jakewharton.rxbinding:rxbinding:0.2.0'
# rxjava
-keep class rx.schedulers.Schedulers {
public static <methods>;
@guananddu
guananddu / RexChainesPhone.js
Created January 9, 2018 12:10 — forked from JerryC8080/RexChainesPhone.js
匹配中国电话号码的正则表达式
/**
电信
中国电信手机号码开头数字
2G/3G号段(CDMA2000网络)133、153、180、181、189
4G号段 177
联通
中国联通手机号码开头数字
@guananddu
guananddu / matrixScaling.md
Created August 27, 2017 13:19 — forked from vxhviet/matrixScaling.md
Android scale bitmap with the highest quality

Source: StackOverflow

Question: How to scale Bitmap without losing much quality

Answer: Use Matrix instead of Bitmap.createScaledBitmap()

    /**
     * @param bitmap the Bitmap to be scaled
     * @param threshold the maxium dimension (either width or height) of the scaled bitmap