Skip to content

Instantly share code, notes, and snippets.

@ruandao
ruandao / README.md
Last active May 14, 2022 06:53 — forked from raecoo/README.md
Surge config

Install Configurations

Download rules.conf

下面的还没试用过:

Advanced Tips:

@ruandao
ruandao / CreateTestCaseIfNoExist.sh
Last active July 2, 2019 17:21
django auto generate test fileand support doctest
#!/usr/bin/env bash
forModule() {
moduleName=$1
for f in `find ../${moduleName} -name "*.py"`;do
withoutDoubleSlash="${f#*//}"
withoutUpperLevel="${withoutDoubleSlash#../}"
file=$withoutUpperLevel
filename=$(basename $file)
d=$(dirname $file)
@ruandao
ruandao / game-node.service
Created July 20, 2018 08:16
golang 守护进程 systemctl 自动重启 配置
# /usr/lib/systemd/system/game-node.service
[Unit]
Description=Fish Game Node
After=network.target
[Service]
WorkingDirectory=/root/freeStyleGame
ExecStart=/root/freeStyleGame/b_node
Restart=always
RestartSec=10s
@ruandao
ruandao / x.go
Created July 6, 2018 10:12
2018/07/06 18:10:51 call err: gob: type not registered for interface: map[string]interface {} panic: call err: gob: type not registered for interface: map[string]interface {} 确定原因是,map赋值给interface{}字段 也就是说,rpc调用不支持interface{}字段咯
package main
import (
"net/rpc"
"log"
"fmt"
)
func failOnErr(err error, s string) {
if err != nil {
@ruandao
ruandao / connector.go
Created July 6, 2018 10:05
rpc call err: gob: type not registered for interface: map[string]interface {} 原因是: args 里面一个字段是interface{}, 然后赋值的时候,赋值为map[string]interface{} 结果就跪了一天。。。。
args := BussinessRPC.ProcessMsg{
UserId: cor.userId,
Message: message,
TimeStamp: time.Now().Format("2006-01-02 15:04:05.000"),
}
reply := &BussinessRPC.ProcessMsgReply{}
service := "FreeStyleGame.Process"
conn, err := rpc.Dial("tcp", address)
@ruandao
ruandao / trace.go
Created July 5, 2018 11:38
用于统计某个函数执行了多久 defer Trace(xxx...)()
// Trace trace
func Trace(name string, param ...interface{}) func() {
if !TraceSwitch {
return func() {}
}
start := time.Now()
log.Println("####Enter", name, param)
return func() {
# Requires Python 2.x, flask and pywin32
from flask import Flask
import flask
import win32com.client
import pythoncom
import os, os.path, sys, time
# Flask (Web Server)
ws = Flask(__name__)
@ruandao
ruandao / exercise-2.12.rkt
Created November 16, 2016 03:20
eopl 2.12
(define (empty-stack)
(lambda (action)
(cond ((eq? action 'top)
(repo-empty-stack-err))
((eq? action 'empty)
#t)
((eq? action 'pop)
(repo-empty-stack-err))
(else (repo-no-support-err)))))
@ruandao
ruandao / configureStore.js
Last active September 30, 2016 17:40
redux store file
import { createStore, combineReducers, compose, applyMiddleware } from 'redux';
import ReduxThunk from 'redux-thunk';
import { routerMiddleware } from 'react-router-redux';
import { hashHistory } from 'react-router';
import * as Reducers from '../reducers';
export default function configureStore(initialState) {
const store = createStore(
combineReducers(Reducers),
initialState,
@ruandao
ruandao / Security_Blowfish.go
Created July 28, 2016 06:39
<<Network programming with Go>> Security
package main
import (
"github.com/crypto/blowfish"
"fmt"
"bytes"
)
func main_Blowfish() {
key := []byte("my key")