GLSL Binding Points

Alt none

Git 命令自动补全脚本

  • Checkout Script
git clone [email protected]:lnmcc/git-completion.git
  • Put the script into home directory
cp -av 	.git-completion.bash   ~/
  • Edit ~/.profile
# GIT Settings
source ~/.git-completion.bash
  • Export new env settings
source ~/.profile

Done !

FileName Checker

/* A-Za-z0-9_- */
static int safe_filename(const char *f)
{
    const char *start = f;

    for (; *f; f++) {
        if (!((unsigned)((*f | 32) - 'a') < 26 ||
              (unsigned)(*f - '0') < 10 || *f == '_' || *f == '-')) {
            if (f == start)
                return 0;
            else if (*f == '/')
                start = f + 1;
            else if (*f != '.')
                return 0;
        }
    }
    return 1;
}

Get Certificate SHA1 With Keytool

keytool -list -keystore testkey.jks

Get Certificate SHA1 With Java

public static String byte2HexFormatted(byte[] arr) {
        StringBuilder str = new StringBuilder(arr.length * 2);
        for (int i = 0; i < arr.length; i++) {
            String h = Integer.toHexString(arr[i]);
            int l = h.length();
            if (l == 1) h = "0" + h;
            if (l > 2) h = h.substring(l - 2, l);
            str.append(h.toUpperCase());
            if (i < (arr.length - 1)) str.append(':');
        }
        return str.toString();
    }

public getCertificationSHA1(Application appcontext) {
        try {
            PackageInfo packageInfo = appcontext.getPackageManager().getPackageInfo(appcontext.getPackageName(), PackageManager.GET_SIGNATURES);
            Signature sign = packageInfo.signatures[0];
            Log.d(TAG, "hashCode Java: " + sign.hashCode());

            Signature[] signatures = packageInfo.signatures;
            byte[] cert = signatures[0].toByteArray();
            InputStream input = new ByteArrayInputStream(cert);
            CertificateFactory cf = null;
            try {
                cf = CertificateFactory.getInstance("X509");
            } catch (CertificateException e) {
                e.printStackTrace();
            }
            X509Certificate c = null;
            try {
                c = (X509Certificate) cf.generateCertificate(input);
            } catch (CertificateException e) {
                e.printStackTrace();
            }
            String hexString = null;
            try {
                MessageDigest md = MessageDigest.getInstance("SHA1");
                byte[] publicKey = md.digest(c.getEncoded());
                hexString = byte2HexFormatted(publicKey);
            } catch (NoSuchAlgorithmException e1) {
                e1.printStackTrace();
            } catch (CertificateEncodingException e) {
                e.printStackTrace();
            }
            Log.d(TAG, "SHA1:" + hexString);

        } catch (Exception e) {
            e.printStackTrace();
        }
}