Skip to content

Instantly share code, notes, and snippets.

View liuxd's full-sized avatar
🗿
Hi, there.

Allen Liu liuxd

🗿
Hi, there.
  • Tax Traders
  • Auckland, New Zealand
View GitHub Profile
@liuxd
liuxd / content.md
Created July 27, 2022 04:37
[Crash Gitlab Pipeline by Deleting an Empty Line.] #EXP
tags
bug
fun

Crash Gitlab Pipeline by Deleting an Empty Line.

In the CI process, there are some lines about setting configuration files like this:

@liuxd
liuxd / content.md
Created July 26, 2022 04:08
[#14 Coder Creed] #EXP

Coder Creed

  • Trust nothing before testing.
  • Only pick the proper part to use.
@liuxd
liuxd / parseSOAP.php
Created June 15, 2022 21:59
[Parsing SOAP xml in PHP]
<?php
function parseSOAP(string $response): array
{
$content = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $response);
$xml = new SimpleXMLElement($content);
$body = $xml->xpath('//sBody')[0]; // 'sBody' is from '<s:Body>', the body tag in your xml file.
$json = json_encode((array)$body, JSON_THROW_ON_ERROR);
$data = json_decode($json, true, 512, JSON_THROW_ON_ERROR);
@liuxd
liuxd / 1.sql
Last active January 19, 2022 03:56
[Check MySQL DB size] #TaxTraders
use information_schema;
select ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) "DB size in MB" from tables;
@liuxd
liuxd / content.md
Created October 2, 2021 10:08
[机器学习、数据挖掘及人工智能的关系] #DataMining

机器学习、数据挖掘及人工智能的关系

目前人工智能很热门,但是很多人容易将人工智能与机器学习混淆。此外,数据挖掘、人工智能和机器学习之间的关系也容易被混淆。

从本质上看,数据科学的目标是通过处理各种数据促进人们的决策,机器学习的主要任务是使机器模仿人类的学习,从而获得知识。而人工智能借助机器学习和推理最终是形成具体的智能行为。机器学习与其他领域之间的关系如下图(此处是简图,文末还有详图)所示。

机器学习、数据挖掘及人工智能三者间的关系(简图) 简图:机器学习、数据挖掘及人工智能三者间的关系

@liuxd
liuxd / demo.js
Created September 17, 2021 01:15
[Check element existance with jQuery] #jQuery
// User .length to do so.
if ($('#id').length) {
// do something.
}
@liuxd
liuxd / test.sh
Last active May 16, 2022 23:01
[Unit test CLI demo] #TaxTraders
/usr/bin/php /var/www/public/vendor/phpunit/phpunit/phpunit --bootstrap vendor/silverstripe/framework/tests/bootstrap.php account/tests/CorporateTaxManagerUploaderTest.php flush=1
@liuxd
liuxd / demo.php
Last active September 2, 2021 04:26
[in_array() in PHP] #Tricky #TaxTraders
<?php
$arr = ['123-123-123', '111-111-111'];
$a = 123;
var_dump(in_array($a, $arr)); // true
var_dump(in_array($a, $arr, true)); // false
@liuxd
liuxd / demo.php
Created July 21, 2021 05:00
[PHP token generator] #token
<?php
$token = bin2hex(random_bytes(16));
@liuxd
liuxd / demo.js
Created July 19, 2021 01:04
[Detect Back Button Event]
if (performance.getEntriesByType("navigation")[0].type === 'back_forward') {
// do something.
}