Month: October 2018

Linux 开发的五大必备工具, Linux容器, 版本控制, 文本编辑, IDE, 文本比较

Linux 已经成为工作、娱乐和个人生活等多个领域的支柱,人们已经越来越离不开它。在 Linux 的帮助下,技术的变革速度超出了人们的想象,Linux 开发的速度也以指数规模增长。因此,越来越多的开发者也不断地加入开源和学习 Linux 开发地潮流当中。在这个过程之中,合适的工具是必不可少的,可喜的是,随着 Linux 的发展,大量适用于 Linux 的开发工具也不断成熟。甚至可以说,这样的工具已经多得有点惊人。 为了选择更合适自己的开发工具,缩小选择范围是很必要的。但是这篇文章并不会要求你必须使用某个工具,而只是缩小到五个工具类别,然后对每个类别提供一个例子。然而,对于大多数类别,都会有不止一种选择。下面我们来看… Read More

MySQL: 永远不要在MySQL中使用“utf8”, MySQL中的utf8mb4和utf8

  最近我遇到了一个 bug,我试着通过 Rails 在以“utf8”编码的 MariaDB 中保存一个 UTF-8 字符串,然后出现了一个离奇的错误: Incorrect string value: ‘\xF0\x9F\x98\x83 <…’ for column ‘summary’ at row 1 我用的是 UTF-8 编码的客户端,服务器也是 UTF-8 编码的,数据库也是,就连要保存的这个字符串“ <…”也是合法的 UTF-8。 问题的症结在于,MySQL 的“utf8”实际上不是真正的 UTF-8。 “utf8”只支持每个字符最多三个字节,而真正的 UTF-8 是每个字符最多四个字节。 MySQL 一直没有修复这个 bug,他们… Read More

PHP: 模拟 POST 提交表单, Sending POST data without form, send a POST request with PHP

  方法有很多种,比如用 AJAX: $.post('/foo.php', { key1: 'value1', key2: 'value2' }, function(result) { alert('successfully posted key1=value1&key2=value2 to foo.php'); }); 又比如用CURL: function httpPost($url, $data) { $curl = curl_init($url); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_qu… Read More

JavaScript: 文本替换, 替换全部, 正则替换文本, How to replace all occurrences of a string in JavaScript?

一次 replace只能替换一个,例如: var str = 'test test test test' console.log(str.replace('test', 'tester')) 通过正则可以一下替换全部: someString = 'the cat looks like a cat'; anotherString = someString.replace(/cat/g, 'dog'); // anotherString now contains "the dog looks like a dog"     更多参考:http://www.tizag.com/javascriptT/javascript-string-replace… Read More

手动升级phpMyAdmin, How to Manually Upgrade phpMyAdmin

  首先要去下载最新版本: phpMyAdmin download page 1. Backup phpMyAdmin 备份当前phpmyadmin # 备份 sudo mv /usr/share/phpmyadmin/ /usr/share/phpmyadmin.bak # 创建新的文件夹 sudo mkdir /usr/share/phpmyadmin/ # 进入这个文件夹 cd /usr/share/phpmyadmin/   2. Download and Extract phpMyAdmin 下载并解压 下载需要的版本: phpMyAdmin download page # 我们用4.8.3版本测试 sudo wget https://… Read More

PHP操作远程mongodb数据库, MongoDB PHP Library, php connects with remote MongoDB

MongoDB PHP Library 项目地址:https://github.com/mongodb/mongo-php-library 官网手册:https://docs.mongodb.com/php-library/master/tutorial/crud/ php driver for mongodb : 安装mongodb的php驱动:Ubuntu: 安装MongoDB, Install MongoDB With Apache2, PHP 7.2 Support On Ubuntu 16.04 / 17.10 / 18.04 官网可视化工具:https://www.mongodb.com/download-center?initi… Read More

shell文件无法用sh执行, sh无法执行数组, `Syntax error: “(” unexpected` when creating an array

Ubuntu bash functions..syntax error: “(” or “}” unexpected 如果用 sh 不执行一个shell文件,可以尝试使用 bash 执行 # 不通过 sh init.sh # 尝试 bash init.sh 如果bash可行,那么为了使sh也可以使用,你需要修改默认的dash方式,如下图: dpkg-reconfigure dash 如图,设置为 NO 即可,这样的话,取消了 sh 作为默认的 dash,那么,当你使用 sh 命令的时候,其实就是执行了 bash 命令。       拓展: Linux 中的 shell 有很多类型,其中最常用的几种是: Bourne shell (sh)、C shell… Read More