Skip to content

Instantly share code, notes, and snippets.

View hainuo's full-sized avatar
🏠
Working from home

hainuo hainuo

🏠
Working from home
View GitHub Profile
@hainuo
hainuo / ruby.rb
Last active August 29, 2015 14:27
ruby 将markdown 转换为epub mobi pdf
#!/usr/bin/env ruby
# Simple script to generate EPUB book (which could be also converted
# to MOBI then) from site sources
#
# It depends on on 'eeepub' ruby gem and also you should have
# ebook-convert executable somewhere in path (or use --path argument
# for that)
#
# Usage is simple:
#
@hainuo
hainuo / NginxLog.php
Last active April 30, 2018 06:47 — forked from zwjzxh520/NginxLog.php
php写的nginx 日志分析
<?php
/**
* nginx日志文件分析。
* 根据配置的nginx日志格式,分析对应的日志内容。各变量
*/
class NginxLog {
protected static $br = "\n";
/**
@hainuo
hainuo / reactphp_push_server.php
Last active December 27, 2018 17:09
基于 reactphp 的 tcp 服务消息推送
<?php
/**
* 感谢强大的 reactphp 。
* 使用 reactphp 创建的可以限制连接数量的消息服务器
* 1. 可以群发消息
* 2. 可以客户端单对单发消息
* 3. 可以服务器对单个客户端发送消息
* usage by `composer require react/socket:^1.1`
**/
require_once __DIR__ . '/vendor/autoload.php';
@hainuo
hainuo / encrypt.php
Last active March 30, 2019 09:02
php7++ 加密解密方法
<?php
if(!function_exists('my_encrypt')) {
function my_encrypt($data, $key)
{
// Remove the base64 encoding from our key
$encryption_key = base64_decode($key);
// Generate an initialization vector
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
// Encrypt the data using AES 256 encryption in CBC mode using our encryption key and initialization vector.
$encrypted = openssl_encrypt($data, 'aes-256-cbc', $encryption_key, 0, $iv);
@hainuo
hainuo / demo.html
Created May 13, 2019 07:45
apicloud如何控制一个指向未知外部url的frame进行刷新
<style>
*{background: #fff}
</style>
<br>
<br>
<br>
<div onclick="reload()"> reload() </div>
<script>
apiready=function () {
alert('read');
@hainuo
hainuo / crc16.php
Last active August 23, 2019 17:30
php crc16校验值
<?php
// 来源 经测试是正确的 https://blog.csdn.net/zhang197093/article/details/89061957
// 增加一个crc在线校验监测网址 http://www.ip33.com/crc.html
/**
* 将一个字符按比特位进行反转 eg: 65 (01000001) --> 130(10000010)
* @param $char
* @return $char
*/
function reverseChar($char) {
@hainuo
hainuo / webp2png.php
Created January 28, 2020 02:52
将webp转换为png格式
<?php
//include 'vendor/autoload.php';
$list = glob('/Users/hainuo/Downloads/语文/*.webp');
foreach ( $list as $filename){
$dirname = dirname($filename);
$pngPath = $filename.'.png';
$img = imagecreatefromwebp($filename);
imagepng($img,$pngPath);
imagedestroy($img);
// dump('处理完成'.basename($filename));
function randomString(length, chars) {
var result = '';
for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
return result;
}
var rString = randomString(32, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
@hainuo
hainuo / php数字识别.php
Created March 25, 2021 06:08
php识别验证码
/**
* 电话号码识别.
* @author by zsc for 2010.03.24
*/
class gjPhone
{
protected $imgPath; // 图片路径
protected $imgSize; // 图片大小
protected $hecData; // 分离后数组