Skip to content

Instantly share code, notes, and snippets.

View picasso250's full-sized avatar
💭
I may be slow to respond.

pica picasso250

💭
I may be slow to respond.
View GitHub Profile
#!/bin/bash
wget http://cn2.php.net/get/php-5.6.34.tar.gz/from/this/mirror
mv mirror php-5.6.34.tar.gz
tar xzvf php-5.6.34.tar.gz
cd php-5.6.34
./configure' '--prefix=/data/software/php' '--with-pear' '--enable-bcmath' '--with-bz2' '--with-curl' '--enable-filter' '--enable-fpm' '--with-gd' '--enable-gd-native-ttf' '--with-freetype-dir' '--with-jpeg-dir' '--with-png-dir' '--enable-intl' '--enable-mbstring' '--with-mcrypt' '--enable-mysqlnd' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-pdo-sqlite' '--disable-phpdbg' '--enable-opcache' '--with-openssl' '--enable-simplexml' '--with-sqlite3' '--enable-xmlreader' '--enable-xmlwriter' '--enable-zip' '--with-zlib'
make
make install
@picasso250
picasso250 / lib.php
Last active March 16, 2018 08:41
lib of php
<?php
function env_load($dir='.')
{
$file = "$dir/.env";
if (!is_file($file)) {
echo "no .env file $file\n";
exit(1);
}
if (!is_readable($file)) {
@picasso250
picasso250 / sql_placeholder_merge.php
Last active March 16, 2018 06:03
merge sql placeholder ? and :x
<?php
function quote_parse ($sql)
{
$n = mb_strlen($sql);
$state = 0;
$word = '';
$ret = [];
$quote = '';
for ($i=0; $i < $n; $i++) {
$ch = mb_substr($sql, $i, 1);
<?php
namespace Lib;
use Exception;
use Psr\Container\ContainerInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class Container implements ContainerInterface
{
@picasso250
picasso250 / get_first_line.php
Created February 23, 2018 07:08
get first line of file content
<?php
function get_first_line($content) {
$pos = -1;
do {
$pos = strpos($content, "\n", $pos+1);
$found = trim(substr($content, 0, $pos));
// http://blog.sina.com.cn/s/blog_49f914ab0101eyjj.html
} while (trim(substr($content, 0, $pos), "\r\n\t \xEF\xBB\xBF") === "");
return substr($content, 0, $pos);
}
@picasso250
picasso250 / input.php
Created February 8, 2018 06:15
QuickForm 魔改
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP version 4.0 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
@picasso250
picasso250 / .bashrc
Last active February 1, 2018 05:27
a fresh new system
alias tl="tmux ls"
alias ta="tmux attach"
@picasso250
picasso250 / tail.php
Created January 25, 2018 09:19
tail for web
<?php
$f = isset($_GET['f']) ? $_GET['f'] : '';
if (!$f) {
die("plz specify f");
}
if (!is_file($f))
die("$f is not a file");
header("Content-Type:text/plain;charset=UTF-8");
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<canvas id="canvas" width="220" height="220"></canvas>
<script type="text/javascript">
var canvas = document.getElementById('canvas');
@picasso250
picasso250 / unzip_windows.php
Created December 19, 2017 04:48
unzip a zip file on windows, preserve the right encode chinese
<?php
$zip = new ZipArchive;
$res = $zip->open($file);
if ($res === TRUE) {
for ($i=0;($filename=$zip->getNameIndex ($i))!==false; $i++) {
echo "$filename\n";
if ($filename[strlen($filename)-1] == '/') {
$filename = iconv('UTF-8', 'GBK', $filename);
if (!is_dir($filename)) {