Skip to content

Instantly share code, notes, and snippets.

@chuehnone
chuehnone / php-array.groovy
Created March 22, 2022 10:34
DataGrip extractor for PHP array format
/*
* Available context bindings:
* COLUMNS List<DataColumn>
* ROWS Iterable<DataRow>
* OUT { append() }
* FORMATTER { format(row, col); formatValue(Object, col); getTypeName(Object, col); isStringLiteral(Object, col); }
* TRANSPOSED Boolean
* plus ALL_COLUMNS, TABLE, DIALECT
*
* where:
@chuehnone
chuehnone / swagit.php
Last active July 30, 2021 07:30 — forked from ls-dac-chartrand/swagit.php
Swag It: Reverse engineer Swagger-PHP annotations from an existing JSON payload
<?php
// -------------------------------------------------------------------------------------
// Add your JSON in the $input to generate Swagger-PHP annotation
// Inspired by: https://github.com/Roger13/SwagDefGen
// HOWTO:
// php -S localhost:8888 -t .
// http://localhost:8888/swagit.php
// -------------------------------------------------------------------------------------
@chuehnone
chuehnone / DbHelper.php
Last active December 16, 2019 04:10
PHP convert wkb point
class DbHelper
{
/**
* WKB is Well-known binary.
*
* @param Point $point
*
* @return string
*/
public static function convertPointToWKB(Point $point): string
@chuehnone
chuehnone / DebugHelper.php
Last active June 11, 2019 10:53
PHP simple debug helper
class DebugHelper
{
/**
* @var int
*/
static $lastTime = 0;
/**
* @var int
*/
@chuehnone
chuehnone / BoyerMooreExample.php
Last active November 30, 2018 03:08
PHP implement Boyer–Moore algorithm
<?php
/**
* @param string $text The string to search in.
* @param string $search The target string to search
*
* @return int The start index of the search string
*/
function getStringStartIndexByBoyerMoore($text, $search) {
$textLength = strlen($text);
@chuehnone
chuehnone / EmojiFilter.php
Created May 24, 2018 03:03
Remove emoji
<?php
function removeEmoji($text) {
return preg_replace('/([0-9|#][\x{20E3}])|[\x{00ae}|\x{00a9}|\x{203C}|\x{2047}|\x{2048}|\x{2049}|\x{3030}|\x{303D}|\x{2139}|\x{2122}|\x{3297}|\x{3299}][\x{FE00}-\x{FEFF}]?|[\x{2190}-\x{21FF}][\x{FE00}-\x{FEFF}]?|[\x{2300}-\x{23FF}][\x{FE00}-\x{FEFF}]?|[\x{2460}-\x{24FF}][\x{FE00}-\x{FEFF}]?|[\x{25A0}-\x{25FF}][\x{FE00}-\x{FEFF}]?|[\x{2600}-\x{27BF}][\x{FE00}-\x{FEFF}]?|[\x{2600}-\x{27BF}][\x{1F000}-\x{1FEFF}]?|[\x{2900}-\x{297F}][\x{FE00}-\x{FEFF}]?|[\x{2B00}-\x{2BF0}][\x{FE00}-\x{FEFF}]?|[\x{1F000}-\x{1F9FF}][\x{FE00}-\x{FEFF}]?|[\x{1F000}-\x{1F9FF}][\x{1F000}-\x{1FEFF}]?/u', '', $text);
}
?>
import android.os.Build;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.WebView;
import java.util.ArrayList;
public class CookieTool {
public static String filterCookie(String url) {
CookieManager manager = CookieManager.getInstance();
@chuehnone
chuehnone / SonarQube-docker-compose.yml
Last active November 9, 2017 01:52
SonarQube Docker Compose file
sonarqube:
restart: always
image: sonarqube
ports:
- "9000:9000"
- "9092:9092"
@chuehnone
chuehnone / detect_brower.js
Created October 17, 2017 08:09
Javascript detect browser
// Opera 8.0+
var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Firefox 1.0+
var isFirefox = typeof InstallTrigger !== 'undefined';
// Safari 3.0+ "[object HTMLElementConstructor]"
var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || (typeof safari !== 'undefined' && safari.pushNotification));
// Internet Explorer 6-11
@chuehnone
chuehnone / Android_defend.java
Last active March 27, 2017 07:20
Android defend
// 檢查Java程式碼是否可以被debug的方法
public boolean isApplicationDebuggable(String paramString) {
return (0x2 & this.context.getPackageManager().getApplicationInfo(this.context.getPackageName(), 128).flags) == 2;
}
// 檢查App是否安裝在模擬器內的方法
public boolean IsInstallEmulator() {
try {
if(!Build.FINGERPRINT.startsWith("generic") && !Build.FINGERPRINT.startsWith("unknown") && !Build.MODEL.contains("google_sdk") && !Build.MODEL.contains("Emulator") && !Build.MODEL.contains("Android SDK built for x86") && !Build.MANUFACTURER.contains("Genymotion")) {
if((Build.BRAND.startsWith("generic")) && (Build.DEVICE.startsWith("generic"))) {