Skip to content

Instantly share code, notes, and snippets.

View Xilesun's full-sized avatar
🐱
Working from home

YANG QIA Xilesun

🐱
Working from home
View GitHub Profile
(function CracklePop() {
for (let i = 1; i <= 100; i++) {
const div3 = i % 3;
const div5 = i % 5;
if (div3 === 0 && div5 === 0) {
console.log('CracklePop');
} else if (div3 === 0) {
console.log('Crackle');
} else if (div5 === 0) {
console.log('Pop');
@Xilesun
Xilesun / solution.js
Last active November 11, 2022 01:08
rainforest QA problem solution
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'
});
@Xilesun
Xilesun / Dockerfile
Last active July 18, 2018 13:44
docker configuration
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
#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;
}
  • Computer system

    • hardware
      • CPU
      • memory
      • I/O devices
    • operating system
    • application programs
    • users
  • Computer system

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
@Xilesun
Xilesun / 前端工具.md
Created February 3, 2018 07:33
前端工具
@Xilesun
Xilesun / addEventListener.js
Last active October 25, 2018 08:11
JavaScript代码段
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;
}
}
@Xilesun
Xilesun / Adding a Hello World System Call to Linux kernel 3.16.51.md
Created February 3, 2018 07:26
Adding a Hello World System Call to Linux kernel 3.16.51

最近在看《操作系统概念》,第二章结束有个练习是给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引导界面选择新内核启动出现黑屏。网上查到的原因有:

  • 显卡驱动缺失,需要重新安装parallels tools
@Xilesun
Xilesun / 前端布局练习总结.md
Created February 3, 2018 07:25
前端布局练习总结(table/inline/float/flex)

前段时间在霖哥的指导下,分别对table/inline/float/flex布局进行了相应的实现。做一下总结汇总。

table布局总结

优点:

  • 垂直居中
  • 等高
  • 等分布局

缺点:

  • width, margin等属性不能影响设置了table-cell的元素