Skip to content

Instantly share code, notes, and snippets.

View flxxyz's full-sized avatar
🙏
happening

一个不知名の睡觉高手 flxxyz

🙏
happening
View GitHub Profile
@flxxyz
flxxyz / Db.php
Last active October 25, 2018 03:10
简单封装的PDO操作类
<?php
/**
* Class Db
*/
class Db
{
private static $instance = null;
private $host = '127.0.0.1';
@flxxyz
flxxyz / Log.php
Last active April 15, 2019 10:06
简易日志记录类
<?php
/**
* Class Log
*
* @package Log
* @method static notice($channel, ...$message)
* @method static info($channel, ...$message)
* @method static debug($channel, ...$message)
* @method static warn($channel, ...$message)
@flxxyz
flxxyz / drawChessBoard.js
Created September 20, 2018 11:10
五子棋基本模块
var drawChessBoard = function(){
for(var i = 0; i < 15; i++){
context.moveTo(15 + i * 30 , 15);
context.lineTo(15 + i * 30 , 435);
context.stroke();
context.moveTo(15 , 15 + i * 30);
context.lineTo(435 , 15 + i * 30);
context.stroke();
}
}
@flxxyz
flxxyz / get_safe_filesize.php
Last active August 28, 2018 15:19
读取大于2GB以上的文件
<?php
function get_safe_filesize($file)
{
$size = filesize($file);
if ($size <= 0) {
if (!(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')) {
$size = trim(`stat -c%s $file`);
} else {
$fsobj = new COM("Scripting.FileSystemObject");
$f = $fsobj->GetFile($file);
@flxxyz
flxxyz / limit_speed_print_file.php
Last active August 28, 2018 16:15
限制文件读取速度
<?php
function limit_speed_print_file($filename, $limit_rate = 100)
{
if (file_exists($filename) && is_file($filename)) {
header('Cache-control: private');
header('Content-Type: application/octet-stream');
header('Content-Length: '.get_safe_filesize($filename));
header('Content-Disposition: attachment; filename='
.basename($filename));
header('Content-Transfer-Encoding: binary');
@flxxyz
flxxyz / xbin.php
Last active July 13, 2021 12:18
自定义多进制很骚
<?php
/**
* 自定义多进制
* @param $str 自定义的多进制字符串
* @param $num 十进制数字
* @return string
* @author alexander_phper
* @link https://blog.csdn.net/alexander_phper/article/details/51363491
*/
function xbin($str, $num){
@flxxyz
flxxyz / Config.php
Last active July 7, 2018 10:47
自用简易控制器
<?php
namespace App;
class Config
{
private static $name = '';
private static $arr = [];
/**
* @return array
*/
public static function getArr()
@flxxyz
flxxyz / url_query_str.js
Created July 7, 2018 10:35
javascript自用简易获取url参数
var url = {
key: function _get(name, query) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
if (query) {
var r = query.match(reg);
} else {
var r = window.location.search.substr(1).match(reg);
}
if (r != null) {
return unescape(r[2]);
@flxxyz
flxxyz / example.js
Created July 6, 2018 12:23
javascript简易时间处理类
var w = require('./with.js');
const serveTime = '2017-01-01 00:00:00';
setInterval(()=> {
console.log(w.serve(serveTime));
}, 1000);
@flxxyz
flxxyz / click_str.js
Created June 29, 2018 09:31
点击网页随机出现预设的文字
$(document).click(function() {
var a = ['富强', '民煮', '自由', '平等', '友爱', '河蟹', '神马', '香甜'];
var v = a[Math.floor(Math.random() * a.length)];
var tips = $('<div style="position:fixed;z-index:9999;color:red;top:200px;left:600px"></div>').text(v).animate({top:'160px'}, 750, function() {$(this).remove()});
$('body').append(tips);
})