Skip to content

Instantly share code, notes, and snippets.

@Chion82
Chion82 / API_doc.md
Last active August 29, 2015 14:22
Back-end API doc of InfoRobot_Article_Editor

#后端API文档

##php/article.php?action=get_default_page

  • 描述:获取默认页(第一个未经page review的页)
  • 请求方式:GET
  • 请求参数:无
  • 返回参数:
  • state: 状态码(200:OK,404:找不到页,-1:请求参数不合法)
  • article_name: 文章标题(一个文章标题对应多页)
  • page_number: 当前页的索引号(最小值为0)
@Chion82
Chion82 / server.py
Created July 4, 2015 12:34
Backend server for nodejs_midway sample
from flask import Flask, jsonify, request, make_response
from urllib import unquote
app = Flask(__name__)
@app.route('/api/user', methods=['GET'])
def api_user():
if (request.cookies.get('test_cookie') != None):
test_cookie = unquote(request.cookies['test_cookie'])
else:
test_cookie = 'NOT SET'
<!--TODO : 修改图片路径 -->
<img src="test.jpg" id="pic" />
<textarea id="result_text" rows="10" cols="30">
</textarea>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
(function() {
function get_init_point(e) {

#项目整体架构

##概述

本项目采用基于Node全栈式开发的NodeJS Midway架构,详细实现原理请参照 淘宝UED
前端除了需要编写UI层的HTML、CSS和JavaScript等浏览器端UI和控制逻辑,还需要编写NodeJS中间层控制逻辑。NodeJS中间层与后端服务器进行RESTful通信并预渲染页面,同时返回部分静态文件。用户在浏览器端访问的服务器是NodeJS中间层的预渲染服务,真后端服务器不暴露。

  • 交互图示如下:

交互图示

@Chion82
Chion82 / server
Last active August 29, 2015 14:27
http://chiontang.zyns.com:90
@Chion82
Chion82 / ss-rules
Created November 10, 2015 13:58
ss-rules
#!/bin/sh
usage() {
cat <<-EOF
Usage: ss-rules [options]
Valid options are:
-s <server_host> hostname or ip of shadowsocks remote server
-l <local_port> port number of shadowsocks local server
@Chion82
Chion82 / ascii_art.py
Created January 2, 2016 17:48
Easy way to convert image to ASCII art
from PIL import Image
ASCII_CHARS = [ '#', '?', '%', '.', 'S', '+', '.', '*', ':', ',', '@']
def scale_image(image, new_width=100):
"""Resizes an image preserving the aspect ratio.
"""
(original_width, original_height) = image.size
aspect_ratio = original_height/float(original_width)
new_height = int(aspect_ratio * new_width)
#!/bin/bash
LOG_FILE=/var/log/xiaoyu/error.log
ERROR_KEYWORD="Error"
EMAIL="sdspeedonion@gmail.com"
SUBJECT="Error Report from loveoncampus.cn"
PREFIX="<h2>Error detected on server loveoncampus!</h2><br/>Error log:<br/><div style='background-color:#f1f1f1;padding:10px;'>"
FOLLOW="</div>"
LAST_LOG_TIME=$(stat -c %Y $LOG_FILE)
@Chion82
Chion82 / Makefile
Created November 27, 2016 16:51 — forked from llj098/Makefile
a sample tcp server runs in kernel
obj-m += tcp_svr_sample.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clea
@Chion82
Chion82 / client.c
Created February 12, 2017 14:56
fake TCP test
#include <stdio.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <string.h>
#include "trans_packet.h"
void on_packet_recv(char* from_ip, uint16_t from_port, char* payload, int size, unsigned int seq) {
printf("Packet received from=%s:%d, seq=%d\n", from_ip, from_port, seq);
char* message = (char*)malloc(size);
memcpy(message, payload, size);