Skip to content

Instantly share code, notes, and snippets.

@icuy
icuy / array_number.js
Created July 3, 2019 13:55
create an array containing 1…N
[...new Array(10).keys()]
@icuy
icuy / xml2array.php
Created June 14, 2019 02:34
xml转数组
<?php
$xml='<?xml version="1.0" encoding="UTF-8"?><qm:response xmlns:qm="http://tour.ectrip.com/2014/QMResponseSchema" xsi:schemaLocation="http://tour.ectrip.com/2014/QMResponseSchema QMRequestDataSchema-1.1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><qm:header><qm:application>tour.ectrip.com</qm:application><qm:processor>DataExchangeProcessor</qm:processor><qm:version>v2.0.0</qm:version><qm:bodyType>CreateOrderPaymentRequestBody</qm:bodyType><qm:createUser>xxx</qm:createUser><qm:createTime>2019-06-05 15:31:32</qm:createTime><qm:code>1000</qm:code><qm:describe>SUCCESS</qm:describe></qm:header><qm:body xsi:type="qm:CreatePaymentOrderResponseBody"><qm:orderInfo><qm:partnerorderId>20190605999777004</qm:partnerorderId><qm:orderStatus>PREPAY_ORDER_PRINT_SUCCESS</qm:orderStatus><qm:qrCodeStr>CYT_837f99</qm:qrCodeStr><qm:qrCodeUrl>http://dy.jingqu.cn/z/2xxx6.do</qm:qrCodeUrl><qm:verifyCode>19831207</qm:verifyCode></qm:orderInfo></qm:body></qm:response>';
$p = xml_parser_create();
xml_parse_into_str
@icuy
icuy / generateRandomString.php
Created April 19, 2019 06:54
获取随机字符串
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyz';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
@icuy
icuy / getUrlParameter.js
Created April 16, 2019 15:03
获取url的参数
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
@icuy
icuy / create-post-request.php
Last active January 22, 2018 03:30
Create POST request
function postRequest($postdata,$url)
{
$postdata = http_build_query($postdata);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
@icuy
icuy / shairport.sh
Last active April 19, 2019 06:56 — forked from hkurosawa/gist:c306f3fb84833c2b1207
Raspberry Pi 搭建 AirPlay 音乐播放器
$ cat /etc/debian_version
7.6
$ sudo apt-get update
$ sudo apt-get upgrade
# install dependencies
$ sudo apt-get install libssl-dev libavahi-client-dev libasound2-dev
# clone source