Skip to content

Instantly share code, notes, and snippets.

@yusureabc
yusureabc / web.config
Created November 21, 2017 14:44
iis7 + laravel 伪静态配置 <rewrite>部分
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<clear />
<add name="php-7.1.11" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="D:\Program Files\php\php-7.1.11\php-cgi.exe" resourceType="Either" requireAccess="Script" />
<add name="ISAPI-dll" path="*.dll" verb="*" modules="IsapiModule" resourceType="File" requireAccess="Execute" allowPathInfo="true" />
<add name="ExtensionlessUrl-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="AXD-ISAPI-4.0_32bit" path="*.axd" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
@yusureabc
yusureabc / uuid.php
Created November 22, 2017 02:23
PHP生成uuid
<?php
function uuid($prefix = '')
{
$chars = md5(uniqid(mt_rand(), true));
$uuid = substr($chars,0,8) . '-';
$uuid .= substr($chars,8,4) . '-';
$uuid .= substr($chars,12,4) . '-';
$uuid .= substr($chars,16,4) . '-';
$uuid .= substr($chars,20,12);
return $prefix . $uuid;
@yusureabc
yusureabc / page_adapter.html
Last active April 11, 2018 13:27
手机 H5页面适配
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
@media screen and (max-width:359px) and (min-width:320px) {
html,body{
font-size: 8px !important;
}
}
@yusureabc
yusureabc / 1px边框.css
Created November 24, 2017 10:51
CSS3实现手机页面1px边框(发丝边框)
.panel{
height: 48vmin;
width: 50%;
margin-top: 0px;
margin-bottom: 0px;
border-radius:0px;
color: #ffffff;
position: relative;
border: none;
overflow:hidden;
@yusureabc
yusureabc / cron.sh
Last active May 7, 2020 06:06
crontab 秒级实现
#!/bin/bash
step=2 #间隔的秒数,不能大于60
for (( i = 0; i < 60; i=(i+step) )); do
/usr/bin/curl 'http:/xxx.com/api/hello'
sleep $step
done
exit 0
@yusureabc
yusureabc / 16进制转换.php
Last active December 1, 2017 09:30
PHP实现连接设备、通讯和发送命令的方法
<?php
/**
* 16进制转换
* @param string $hex
* @return string 返回值
*/
function hexToStr($hex) {
$string = "";
for ($i = 0; $i < strlen($hex) - 1; $i+=3) {
$string.=chr(hexdec($hex[$i] . $hex[$i + 1]));
@yusureabc
yusureabc / replace_array_key.php
Created December 15, 2017 07:25
用二维数组的某个元素做key
<?php
/**
* 用二维数组的某个元素做key
*/
function replace_array_key( $data, $field, $append = [] )
{
$result = [];
foreach ( (array)$data as $key => $val )
{
@yusureabc
yusureabc / arrayToObject.php
Created December 15, 2017 07:26
数组对象互转
<?php
/**
* 数组转换对象
*
* @param $e 数组
* @return object|void
*/
function arrayToObject($e)
{
@yusureabc
yusureabc / asyncExecute.php
Created December 27, 2017 07:44
PHP Fire and Forget
<?php
/**
* https://www.eertime.com/archives/85.html
* [asyncExecute PHP异步执行任务]
* @param string $url 执行任务的url地址
* @param array $post_data 需要post提交的数据POST
* @param array $cookie cookie数据用于登录等的设置
* @return boole
*/
function asyncExecute($url, $post_data = array(), $cookie = array()) {
@yusureabc
yusureabc / memcache_session.php
Last active January 2, 2018 14:05
配置php的session存储到memcache或redis
<?php
ini_set("session.save_handler", "memcache");
ini_set("session.save_path", "tcp://192.168.48.128:11211");
session_start();
if ( ! isset( $_SESSION['TEST'] ) )
{
$_SESSION['TEST'] = time();
}