前几日在新购的macbook Pro上搭建PHP环境,因为网上提供的资料不够准确,故走了一些弯路,特此记录,以帮助有需要的新手。OS X自带Apache和PHP,这里讲的是使用Nginx服务器。
brew是OS X上一个优秀的命令行包管理工具,用它来安装一系列软件非常方便。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
最近在看《操作系统概念》,第二章结束有个练习是给linux内核添加一个新的system call. 今天花了不少时间才完成,记录过程和遇到的坑。
环境:macOS sierra / CentOS7 3.10.0 in Parallels Desktop
一开始是打算直接对现有内核进行修改,但是修改之后发现现在系统中的内核不完整,缺少文件syscall_32.tbl,编译失败。于是从kernel.org下载新的完整的内核,我选择的版本是3.16.51.
之后的过程基本参考 https://tssurya.wordpress.com/2014/08/19/adding-a-hello-world-system-call-to-linux-kernel-3-16-0/
但是按照该过程安装完内核,重启,在grub引导界面选择新内核启动出现黑屏。网上查到的原因有:
import os | |
# Import all files in modules dynamically | |
for module in os.listdir(os.path.dirname(__file__)): | |
if module == '__init__.py' or module[-3:] != '.py': | |
continue | |
__import__(module[:-3], locals(), globals()) | |
del module |
Computer system
Computer system
#include <stdio.h> | |
void insert_sort(int arr[], int n) { | |
int tmp; | |
for (int i = 1; i < n; i++) { | |
int tmp = arr[i]; | |
for (int j = i - 1; j >= 0 && tmp < arr[j]; j--) { | |
arr[j+1] = arr[j]; | |
arr[j] = tmp; | |
} |
FROM php:7.1.4-fpm | |
RUN apt-get update && apt-get install -y \ | |
libfreetype6-dev \ | |
libjpeg62-turbo-dev \ | |
libmcrypt-dev \ | |
libpng-dev \ | |
libz-dev \ | |
&& docker-php-ext-install -j$(nproc) iconv mcrypt \ | |
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ | |
&& docker-php-ext-install -j$(nproc) gd pdo pdo_mysql |
function addEventHandler (target, type, func) { | |
if (target.addEventListener) { | |
target.addEventListener(type, func, false); | |
} else if (target.attachEvent) { | |
target.attachEvent('on' + type, func); | |
} else { | |
target['on' + type] = func; | |
} | |
} |
async function get(url) { | |
urlArr = url.split('?'); | |
url = `${urlArr[0]}.json?${urlArr[1] || ''}` | |
const res = await fetch(url, { | |
method: 'GET', | |
headers: { | |
'Content-Type': 'application/json', | |
}, | |
mode: 'cors' | |
}); |