Skip to content

Instantly share code, notes, and snippets.

View crossmaya's full-sized avatar
🎯
Focusing

JT crossmaya

🎯
Focusing
View GitHub Profile
@crossmaya
crossmaya / formater.php
Created January 5, 2020 04:02
php格式化相关函数
<?php
class Formater
{
public static function bytesToHuman($bytes)
{
$units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
for ($i = 0; $bytes > 1024; $i++) {
$bytes /= 1024;
}
@crossmaya
crossmaya / gits01.php
Last active December 29, 2019 10:40
php代码片段
<?php
//动态修改env文件
$path = base_path('.env');
if (file_exists($path)) {
//Try to read the current content of .env
$current = file_get_contents($path);
//Store the key
$original = [];
if (preg_match('/^XCHACHA_KEY=(.+)$/m', $current, $original)) {
@crossmaya
crossmaya / nginx_rotate.sh
Created June 19, 2019 20:24
nginx日志切割
#!/bin/bash
BUCKETNAME="your_s3_bucket"
LOGDIR="/var/log/nginx"
LOGDATE=$(date +"%Y%m%d")
HOST=$(wget -q -O- http://169.254.169.254/latest/meta-data/instance-id)
LOGFILES=("access")
echo "Moving access logs to dated logs.."
@crossmaya
crossmaya / ImageUploader.php
Created June 8, 2019 16:06
laravel image uploader
<?php
use Illuminate\Support\Facades\Validator;
class ImageHelper
{
// 自定义验证函数
protected $validator;
// 上传图片字段
protected $field = 'image';
@crossmaya
crossmaya / README.md
Created July 24, 2018 04:47 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@crossmaya
crossmaya / Functions.inc.php
Last active May 8, 2021 01:59
php basic helps
<?php declare(strict_types=1);
use GuzzleHttp\Client;
use Swoft\Stdlib\Helper\ArrayHelper;
use GuzzleHttp\Exception\RequestException;
/**
* 数据格式化
*
* @access public