Skip to content

Instantly share code, notes, and snippets.

View forecho's full-sized avatar
🎯
Focusing

蔡正海 forecho

🎯
Focusing
View GitHub Profile
@forecho
forecho / test-graph-abi.json
Last active May 17, 2023 10:24
test-graph-abi.json
[
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
@forecho
forecho / wsj.user.js
Created December 24, 2021 09:58
Wall Street Journal Paywall bypass
/* jshint esversion: 6 */
// ==UserScript==
// @name WSJ and Barrons Paywall Hack
// @include https://*.wsj.com/*
// @include https://*.barrons.com/*
// @run-at document-end
// @grant none
// @version 2
// ==/UserScript==
@forecho
forecho / github-action.yml
Created March 17, 2020 07:45
GitHub Action 部署示例
name: PHP Composer
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
<?php
/**
* author : forecho <caizhenghai@gmail.com>
* createTime : 2016/3/30 16:47
* description:
*/
namespace common\helpers;
class StringHelper
@forecho
forecho / TimeHelper.php
Last active April 20, 2017 10:41
PHP 处理时间助手
namespace common\helpers;
class TimeHelper
{
/**
* 离现在时间几个月
* @param integer|string $time 时间戳或者时间
* @return int
*/
public static function dieMonth($time)
@forecho
forecho / SearchModel.php
Last active July 15, 2022 11:14
Yii2 Search Model
<?php
/**
* author : forecho <caizhenghai@gmail.com>
* createTime : 2015/12/29 15:33
* description:
*/
namespace common\components;
use yii\base\InvalidParamException;
@forecho
forecho / explode.php
Last active February 26, 2016 02:57
textarea 换行分割
<?php
$code = "12243324324234234
23123123123123123
37489347589347895";
$newCode = explode("\r\n", $code);
print_r($newCode);
// Array ( [0] => 12243324324234234 [1] => 23123123123123123 [2] => 37489347589347895 )
@forecho
forecho / tree.php
Last active July 15, 2022 11:15
PHP 递归方法实现无限分类两种实例
<?php
/**
* @link http://ideone.com/gAsKlI
*/
$items = array(
array('id' => 1, 'pid' => 0, 'name' => '一级11'),
array('id' => 11, 'pid' => 0, 'name' => 'www.111cn.net 一级12'),
array('id' => 2, 'pid' => 1, 'name' => '二级21'),
array('id' => 10, 'pid' => 11, 'name' => '二级22'),
array('id' => 3, 'pid' => 1, 'name' => '二级23'),
@forecho
forecho / Pk.php
Last active December 25, 2015 08:38
Primary Id
<?php
static $OUR_EPOCH = 1444647842959;
static $DEFAULT_SHARD_ID = 1;
/**
* 生成 bigint64 位主键
* @return int
*/
public static function generatePk()
{
@forecho
forecho / new_gist_file.php
Created December 7, 2015 08:45
传一个数组,返回一个最小值和最大值。应用场景是获取商品SKU的价格区间
// TFuncProduct::getInterval(array(
// 10 => array('title' => 'a', 'size' => 1),
// 20 => array('title' => 'b', 'size' => 2),
// 30 => array('title' => 'c', 'size' => 3),
// ),
// 'size'
// );
// 输出 array(1, 3)