🔍 登录 注册
分类:
标签: 共 1222 篇文章

node-mysql的使用

编写mysql的config配置 ``` { connectionLimit: 2,//连接数限制 host: 'localhost',//数据库host user: 'root',//用户名 password: 'root',//密码 database: 'db',//数据库 debug: false,//是否开启调试 multipleStatements: true//是否允许同时执行多条语句 } ``` 使用连接池创建一个mysql连接的单例 ``` const mysql = require('mysql'); let conn = undefined; /** * 数据库连接 */ class Connection { /** * 构造函数 * @param {Object} config */ constructor(config) { this.config = config; } /** * 获取连接池

大 大苹果 2017/7/19 👍 0 ⭐ 0 💬 0

rust的安装

# 安装 Rust 使用 Rust 的第一步是安装它。总的来说,你需要联网执行本部分的命令,因为我们要从网上下载 Rust。 Rust 编译器可以运行和编译在许多平台上,不过在 x86 和 x86-64 CPU 构架的 Linux、Mac 和 Windows 平台上的支持是最好的。对于这些和其他一些平台提供官方构建的 Rust 编译器和标准库。[关于官方平台支持的全部细节请查看这个网站](https://forge.rust-lang.org/platform-support.html)。 1.在 Unix 类系统如 Linux 和 macOS 上,你只需打开终端并输入: ``` curl https://sh.rustup.rs -sSf | sh ``` 2.这样会下载一个脚本并开始安装。如果一切顺利,你将会看到: ``` Rust is installed now. Great! ``` 3.在 Windows 上安装也同样简单:下载并运行[rustup-init.exe](https://win.rustup.rs/)。其会在终端中开始安装并在成功时显示以上信息。

大 大苹果 2017/7/18 👍 0 ⭐ 0 💬 0

PHP unpack() 函数

# PHP unpack() 函数 ## 定义和用法 unpack() 函数从二进制字符串对数据进行解包。 ### 语法 ``` unpack(format,data) ``` ||| |---|---| |参数|描述| |format|必需。规定在解包数据时所使用的格式。| |data|可选。规定被解包的二进制数据。| ### format 参数的可能值: * a - NUL-padded string * A - SPACE-padded string * h - Hex string, low nibble first * H - Hex string, high nibble first * c - signed char * C - unsigned char * s - signed short (always 16 bit, machine byte order) * S - unsigned short (always 16 bit, machine byte order) * n - unsigned short (always 16 b

大 大苹果 2017/6/1 👍 0 ⭐ 0 💬 0

svn权限配置

配置文件passwd 配置用户名与密码,格式如下: ``` [users] harry = harryssecret sally = sallyssecret ``` harry与sally是用户名,harryssecret与sallyssecret是密码; 配置文件svnserve.conf 开启权限访问 ``` anon-access = read # auth-access = write #认证可写 ### The password-db option controls the location of the password ### database file. Unless you specify a path starting with a /, ### the file's location is relative to the directory containing ### this configuration file. ### If SASL is enabled (see below), this file will NOT be used.

大 大苹果 2017/5/24 👍 0 ⭐ 0 💬 0

svn错误:there has been a problem contacting the server

svn查看日志出现如下错误解决方案, ![blob.png](/ueditor/php/upload/image/20170601/1496282200308118.png) 查看svn下的配置文件svnserve.conf找到anon-access = none,此处必须设置为none。

大 大苹果 2017/5/24 👍 0 ⭐ 0 💬 0

javascript的三中弹框模式

``` <!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>三种弹出对话框的用法实例</title></head><script language="javascript">function dialog(){ //这个基本没有什么说的,就是弹出一个提醒的对话框 alert("我敢保证,你现在用的是演示一");}function comfirmbox(){ //利用对话框返回的值 (true 或者 false) if(confirm("你确信要转去zyw327的博客?")){ //如果是true ,那么就把页面转向thcjp.cnblogs.com location.href="http://blog.okgoes.com/index/blog/lists/uuid/10300003.html"; } else { //否则说明下了,呵呵 alert("你按了取消,那就是返回f

大 大苹果 2017/5/24 👍 0 ⭐ 0 💬 0

安装package control

sublime安装package control ``` import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s),

大 大苹果 2017/5/25 👍 0 ⭐ 0 💬 0

stripslashes — 反引用一个引用字符串

### 说明 string **stripslashes** ( string `$str` ) 反引用一个引用字符串。 > **Note**: > > 如果 magic\_quotes\_sybase 项开启,反斜线将被去除,但是两个反斜线将会被替换成一个。 > 一个使用范例是使用 PHP 检测 magic\_quotes\_gpc 配置项的 *开启*情况(在 PHP 5.4之 前默认是开启的)并且你不需要将数据插入到一个需要转义的位置(例如数据库)。例如,你只是简单地将表单数据直接输出。 ### 参数 * `str` * 输入字符串。 ### 返回值 返回一个去除转义反斜线后的字符串(*\\'* 转换为 *'* 等等)。双反斜线(*\\\\*)被转换为单个反斜线(*\\*)。 ``` <?php $str = "Is your name O\'reilly?" ; // 输出: Is your name O'reilly? echo stripslashes ( $str );?> ``` **Note**: **stripslashes()** 是非

大 大苹果 2017/5/24 👍 0 ⭐ 0 💬 0

php下载文件

php下载文件 ``` $filename = basename($sourceFile); //获取文件名字$outFile_extension = strtolower(substr(strrchr($outFile, "."), 1)); //获取文件扩展名//根据扩展名 指出输出浏览器格式switch ($outFile_extension) { case "exe" : $ctype = "application/octet-stream"; break; case "zip" : $ctype = "application/zip"; break; case "mp3" : $ctype = "audio/mpeg"; break; case "mpg" : $ctype = "video/mpeg"; break; case "avi" : $ctype = "video/x-msvideo"; bre

大 大苹果 2017/5/24 👍 0 ⭐ 0 💬 0

​redis消息通知(任务队列和发布订阅模式)

# 1\. 任务队列 ### 1.1 任务队列的特点 任务队列:顾名思义,就是“传递消息的队列”。与任务队列进行交互的实体有两类,一类是生产者(producer),另一类则是消费者(consumer)。生产者将需要处理的任务放入任务队列中,而消费者则不断地从任务独立中读入任务信息并执行。 任务队列的好处: 1. 松耦合。生产者和消费者只需按照约定的任务描述格式,进行编写代码。 2. 易于扩展。多消费者模式下,消费者可以分布在多个不同的服务器中,由此降低单台服务器的负载。 ### 1.2 Redis实现任务队列 使用Redis实现任务队列首先想到的就是Redis的列表类型,因为在Redis内部,==列表类型是由双向链表实现==的。 实现任务队列,只需让生产者将任务使用LPUSH加入到某个键中,然后另一个消费者不断地使用RPOP命令从该键中取出任务即可。 ``` //生产者只需将task LPUSH到队列中127.0.0.1:6379> LPUSH queue task (integer) 1127.0.0.1:6379> LRANGE queue 0 -11) "tas

大 大苹果 2017/5/19 👍 0 ⭐ 0 💬 0

删除某个文件夹所有的.svn文件及文件夹

删除某个文件夹所有的.svn文件及文件夹 ``` <?phpfunction delsvn($dir) { $dh=opendir($dir); //找出所有".svn“ 的文件夹: while ($file=readdir($dh)) { if($file!="." && $file!="..") { $fullpath=$dir."/".$file; if(is_dir($fullpath)) { if($file==".svn"){ delsvndir($fullpath); }else{ delsvn($fullpath); } } } } closedir($dh);}function delsvndir($svndir){ //先删除目录下的文件: $dh=opendir($svndir); while($file=readdir($dh)){ if($file!

大 大苹果 2017/5/24 👍 0 ⭐ 0 💬 0

get_magic_quotes_gpc方法的作用

get\_magic\_quotes\_gpc — 获取当前 magic\_quotes\_gpc 的配置选项设置 说明 ``` bool get_magic_quotes_gpc ( void ) ``` 返回当前 magic\_quotes\_gpc 配置选项的设置 记住,尝试在运行时设置 magic\_quotes\_gpc 将不会生效。 更多关于 magic\_quotes 的信息参见安全一章。 返回值 如果 magic\_quotes\_gpc 为关闭时返回 0,否则返回 1。在 PHP 5.4.O 起将始终返回 FALSE 。 更新日志 版本 说明 php5.4.0 始终返回 FALSE ,因为这个魔术引号功能已经从 PHP 中移除了。 范例 Example #1 get\_magic\_quotes\_gpc() 例子 ``` <?php // 如果启用了魔术引号echo $_POST [ 'lastname' ]; // O\'reillyecho addslashes ( $_POST [ 'lastname'

大 大苹果 2017/6/2 👍 0 ⭐ 0 💬 0