Skip to content

Instantly share code, notes, and snippets.

@imbyc
imbyc / checkDomainBlockedByWeixin.php
Created September 24, 2020 01:29
[PHP 检测域名是否被微信拦截]
<?php
$url = 'http://baidu.com';
$headers = get_headers('http://mp.weixinbridge.com/mp/wapredirect?&action=appmsg_redirect&uin=&biz=MzUxMTMxODc2MQ==&mid=100000007&idx=1&type=1&scene=0&url=' . $url, 1);
if ($headers['Location'] !== $url) {
echo '域名被封';
} else {
echo '域名正常';
}
@imbyc
imbyc / img2base64.php
Last active April 7, 2021 03:16
[PHP 图片转base64]
<?php
function base64EncodeImage($image_file)
{
$base64_image = '';
$image_info = getimagesize($image_file);
$image_data = fread(fopen($image_file, 'r'), filesize($image_file));
//$base64_image = 'data:' . $image_info['mime'] . ';base64,' . chunk_split(base64_encode($image_data));
$base64_image = 'data:' . $image_info['mime'] . ';base64,' . base64_encode($image_data);
return $base64_image;
@imbyc
imbyc / character.js
Last active November 23, 2020 04:16
[JS 输入框4个字符一分割] https://jsbin.com/koleleh/edit?html,js,output
function character(s){
var memt = 16;
s=s.replace(/\-/g,'');
var len=s.length;
var z=Math.ceil(len/4);
var zz=parseInt(memt)+parseInt(z)-1;
document.getElementById("sn").setAttribute("maxlength",zz);
var ss='';
for (var i = 0; i < z; i++) {
ss+=s.substr(4*i,4);
@imbyc
imbyc / secondsToHms.php
Last active November 25, 2020 02:54
[PHP 秒数时长转时分秒显示] 如: 200 秒转成 03:20
<?php
/**
* 秒数时长转时分秒显示
* @param float $seconds
*
* @return string
*/
function secondsToHms($seconds)
{
@imbyc
imbyc / getWavPlayTime.php
Last active November 25, 2020 03:01
[PHP 获取wav音频文件时长]
<?php
// 简单版本
$filename = 'LoveMe.wav';
$wavdataoffset = 44;
$wavdataend = filesize($filename);
$fp = fopen($filename, 'rb');
$fseek = fseek($fp, 28);
$bitrate = unpack('V', fread($fp, 4));
$bitrate = $bitrate[1];
@imbyc
imbyc / bom.php
Created December 7, 2020 02:33
[PHP 检测文件是否有BOM头]
<?php
header("Content-type: text/html; charset=utf-8");
set_time_limit ( 0 );
if (isset ( $_GET ['dir'] )) { // 设置文件目录
$basedir = $_GET ['dir'];
} else {
$basedir = '.';
}
$auto = 1;
checkdir ( $basedir );
@imbyc
imbyc / saveConfig.php
Last active July 6, 2023 06:10
[PHP 一行代码搞定保存数组配置到PHP文件] https://zhuanlan.zhihu.com/p/338633066
<?php
/**
* 保存配置到php文件中
* @param string $filename 文件路径
* @param mixed $content 保存的内容
*/
function saveConfig($filename, $content)
{
file_put_contents($filename, "<?php\n\nreturn " . var_export($content, true) . ';');
@imbyc
imbyc / Configuration.xml
Last active February 22, 2021 08:35
[Office Tool Plus 部署配置] 安装word/ppt/excel/visio 2019 批量版
<Configuration>
<Add OfficeClientEdition="64" Channel="PerpetualVL2019" AllowCdnFallback="True" OfficeMgmtCOM="True">
<Product ID="ProPlus2019Volume">
<Language ID="zh-cn" />
<ExcludeApp ID="Access" />
<ExcludeApp ID="Groove" />
<ExcludeApp ID="Lync" />
<ExcludeApp ID="OneDrive" />
<ExcludeApp ID="OneNote" />
<ExcludeApp ID="Outlook" />
@imbyc
imbyc / send.sh
Last active March 2, 2021 02:58
[shell 调用企业微信接口发送通知] 使用curl发送 https://work.weixin.qq.com/api/doc/90000/90135/90236
#!/bin/bash
# 发送微信通知
# 企业ID https://work.weixin.qq.com/api/doc/90000/90135/90665#corpid
CORPID=填写企业ID
# 应用的凭证密钥 https://work.weixin.qq.com/api/doc/90000/90135/90665#secret
CORPSECRET=填写应用的凭证密钥
# 企业应用的id ,整型。企业内部开发,可在应用的设置页面查看
AGENTID=填写企业应用的id
# 获取token的接口地址 https://work.weixin.qq.com/api/doc/90000/90135/91039
@imbyc
imbyc / .leptonrc
Last active March 22, 2023 01:32
[Lepton 配置文件] 自用Lepton 配置文件备份 Lepton v1.9.1 v1.10.0
{
"theme": "light",
"snippet": {
"expanded": true,
"newSnippetPrivate": false,
"sorting": "updated_at",
"sortingReverse": true
},
"editor" : {
"tabSize": 4,