Skip to content

Instantly share code, notes, and snippets.

View tw-Frey's full-sized avatar

Frey tw-Frey

  • Taipei, Taiwan
View GitHub Profile
@tw-Frey
tw-Frey / jquery-ajax-blob-arraybuffer.js
Created July 5, 2018 22:36 — forked from SaneMethod/jquery-ajax-blob-arraybuffer.js
Ajax transports to allow the sending/receiving of blobs and array buffers via the familiar jquery ajax function.To send, set data to the blob or arraybuffer to be sent, and add 'processData:false' to the ajax options.To receive, specify the 'dataType' as blob or arraybuffer in the ajax options.
(function($){
/**
* Register ajax transports for blob send/recieve and array buffer send/receive via XMLHttpRequest Level 2
* within the comfortable framework of the jquery ajax request, with full support for promises.
*
* Notice the +* in the dataType string? The + indicates we want this transport to be prepended to the list
* of potential transports (so it gets first dibs if the request passes the conditions within to provide the
* ajax transport, preventing the standard transport from hogging the request), and the * indicates that
* potentially any request with any dataType might want to use the transports provided herein.
*
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tw-Frey
tw-Frey / AndroidMethod.java
Created January 14, 2019 10:06 — forked from ishitcno1/AndroidMethod.java
Android methods to check the network connection.
public static boolean isWifiConn(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager
.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
return networkInfo.isConnected();
}
public static boolean isMobileConn(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager)
@tw-Frey
tw-Frey / ChangePassword.java
Created August 15, 2019 02:15 — forked from zach-klippenstein/ChangePassword.java
The keystore password on Java keystore files is utterly pointless. You can reset it without knowing it, as shown by this code. Note that private keys are still secure, as far as I know. The JKS implementation is copyright Casey Marshall ([email protected]), and the original source is available at http://metastatic.org/source/JKS.java. I've in…
import java.util.*;
import java.io.*;
import java.security.*;
public class ChangePassword
{
private final static JKS j = new JKS();
public static void main(String[] args) throws Exception
{
@tw-Frey
tw-Frey / Markdown Cheatsheet 中文版.md
Created September 26, 2019 03:30 — forked from billy3321/Markdown Cheatsheet 中文版.md
Markdown Cheatsheet 中文版
@tw-Frey
tw-Frey / DeCryptor.java
Created October 15, 2019 12:40 — forked from JosiasSena/DeCryptor.java
Encryptor and Decryptor for data encryption.decryption using the Android KeyStore.
/**
_____ _____ _
| __ \ / ____| | |
| | | | ___| | _ __ _ _ _ __ | |_ ___ _ __
| | | |/ _ \ | | '__| | | | '_ \| __/ _ \| '__|
| |__| | __/ |____| | | |_| | |_) | || (_) | |
|_____/ \___|\_____|_| \__, | .__/ \__\___/|_|
__/ | |
|___/|_|
*/
@tw-Frey
tw-Frey / WebViewServer.kt
Created October 23, 2019 14:56 — forked from ErikHellman/WebViewServer.kt
A simple "web server" for handling intercepted WebView requests on Android and deliver local content.
/*
MIT License
Copyright (c) 2019 Erik Hellman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@tw-Frey
tw-Frey / replace-android-system-webview-package-name.md
Last active November 21, 2025 03:01 — forked from maokwen/replace-android-system-webview.md
替换 Webview 預設 Package Name, e.g. [com.android.webview] → [com.google.android.webview]
  1. 安装最新的 Android System Webview (com.google.android.webview)
  2. 拷贝 (pull) 一份 /System/framework/framework-res.apk 的副本到任意位置
  3. 搜索在其中搜索 webview, 将 /android/string/config_webViewPackageName 的值改为 com.google.android.webview
  4. 将修改后的文件覆盖回 (push) 原位置
  5. 重启
@tw-Frey
tw-Frey / BriefLogFormatter.kt
Created November 12, 2019 10:33 — forked from mikehearn/BriefLogFormatter.kt
BriefLogFormatter
// A couple of inlined utility functions: the first is just a syntax convenience, the second lets us use
// Kotlin's string interpolation efficiently: the message is never calculated/concatenated together unless
// logging at that level is enabled.
inline fun <reified T : Any> loggerFor(): org.slf4j.Logger = LoggerFactory.getLogger(T::class.java)
inline fun org.slf4j.Logger.trace(msg: () -> String) {
if (isTraceEnabled) trace(msg())
}
/**
* A Java logging formatter that writes more compact output than the default.
@tw-Frey
tw-Frey / credit-card-regex.md
Created December 16, 2019 11:54 — forked from michaelkeevildown/credit-card-regex.md
Credit Card Regex Patterns

Credit Card Regex

  • Amex Card: ^3[47][0-9]{13}$
  • BCGlobal: ^(6541|6556)[0-9]{12}$
  • Carte Blanche Card: ^389[0-9]{11}$
  • Diners Club Card: ^3(?:0[0-5]|[68][0-9])[0-9]{11}$
  • Discover Card: ^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$
  • Insta Payment Card: ^63[7-9][0-9]{13}$
  • JCB Card: ^(?:2131|1800|35\d{3})\d{11}$
  • KoreanLocalCard: ^9[0-9]{15}$