Skip to content

Instantly share code, notes, and snippets.

@Chion82
Chion82 / webpack-for-node-modules.js
Created May 16, 2017 08:57 — forked from mxstbr/webpack-for-node-modules.js
How to use webpack to compile node modules
/* eslint-disable no-var */
var path = require('path');
var autoprefixer = require('autoprefixer');
const MATCH_ALL_NON_RELATIVE_IMPORTS = /^\w.*$/i;
module.exports = [{
output: {
filename: '[name].js',
library: 'atrium-react-plugin-beta',
@Chion82
Chion82 / 来抢课了.js
Last active June 12, 2017 04:02
选课高亮提示
electCourseTable.config.time=500;
window.confirm=function(){
return true;
};
function updateCountHint(){
$('.stdCount').each(function(){
var numArray = $(this).html().split('/');
if (numArray[2] >= 1) {
$(this).css({'background-color':'red'});
if ($(this).parent().find('a[title="点击查看教学任务信息"]').html().indexOf('日语') !== -1) {
@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);
@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
#!/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 / 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)
@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 / server
Last active August 29, 2015 14:27
http://chiontang.zyns.com:90

#项目整体架构

##概述

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

  • 交互图示如下:

交互图示

<!--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) {