Skip to content

Instantly share code, notes, and snippets.

@nixuan
nixuan / gist:167a4ad0c67028ff54a99e88b24bd673
Created August 19, 2019 06:28
php: remove all non printable characters in a string
// It matches anything in range 0-31, 127-255 and removes it.
$string = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $string);
curl -XPUT -u elastic 'localhost:9200/_xpack/security/user/elastic/_password' -d '{
"password" : "123456"
}
<?php
set_time_limit(0);
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($curl, CURLOPT_URL, "");
$response = curl_exec($curl);
echo $response, PHP_EOL;
<?php
set_time_limit(0);
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($curl, CURLOPT_URL, "");
$response = curl_exec($curl);
echo $response, PHP_EOL;
@nixuan
nixuan / json_encode.php
Created October 23, 2018 08:16
json_encode 中文
<?php
$data = ['中文'];
echo json_encode($data, JSON_UNESCAPED_UNICODE), PHP_EOL;
@nixuan
nixuan / nvm
Last active September 4, 2017 02:50
nvm update the latest node
nvm install stable --reinstall-packages-from=${OLD_VERSION}
e.g. nvm install stable --reinstall-packages-from=6.10.0