Skip to content

Instantly share code, notes, and snippets.

View cloverstd's full-sized avatar
🀄
Working for living

cloverstd cloverstd

🀄
Working for living
View GitHub Profile
@bdarnell
bdarnell / streaming.py
Created January 11, 2015 21:23
Demo of streaming requests with Tornado
"""Demo of streaming requests with Tornado.
This script features a client using AsyncHTTPClient's body_producer
feature to slowly produce a large request body, and two server
handlers to receive this body (one is a proxy that forwards to the
other, also using body_producer).
It also demonstrates flow control: if --client_delay is smaller than
--server_delay, the client will eventually be suspended to allow the
server to catch up. You can see this in the logs, as the "client
@Globegitter
Globegitter / nginx-latest.sh
Last active May 7, 2022 18:19
Install the latest nginx from source for Ubuntu 14.04
# Automatically instal the latest nginx
wget -O - http://nginx.org/keys/nginx_signing.key | sudo apt-key add -
#Make a backup copy of your current sources.list file
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
#Now copy the following repositories to the end of ` /etc/apt/sources.list`
echo "deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://nginx.org/packages/mainline/ubuntu/ trusty nginx" | sudo tee -a /etc/apt/sources.list
@ldong
ldong / Vagrantfile_ubuntu
Created August 26, 2014 16:56
vagrant file for ubuntu
# -*- mode: ruby -*-
# vi: set ft=ruby :
file_location = '~/VMs/ubuntu/src'
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
@shanzi
shanzi / gittp.go
Last active February 26, 2024 03:42
A simple Git Http Server in go
/*
gittip: a basic git http server.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright 2014 Chase Zhang <yun.er.run@gmail.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
@fqrouter
fqrouter / readme.txt
Last active April 16, 2023 18:10
shadowsocks 公共代理的必要设置
good, 你已经有了一个自己的shadowsocks代理了,现在想要把这个代理公布出去给所有人分享。
但是没有两个小时,代理就没法使用了,为什么?因为你需要额外注意以下事项(以下步骤需要比较高的linux技能)
本文只关注于确保shadowsocks服务还“活着”,如果你希望让其跑得更快,请参考
https://github.com/clowwindy/shadowsocks/wiki/Optimizing-Shadowsocks
1、 shadowsocks的timeout设置
超时时间越长,连接被保持得也就越长,导致并发的tcp的连接数也就越多。对于公共代理,这个值应该调整得小一些。推荐60秒。
2、 检查操作系统的各种限制
对于openvz的vps,特别需要检查一下
@lechup
lechup / gevent_rqworker.py
Last active January 27, 2023 13:52
GeventWorker class to use with rq. All credits to https://github.com/jhorman from https://github.com/nvie/rq/issues/303#issuecomment-45304465 comment.
from __future__ import absolute_import
import signal
import gevent
import gevent.pool
from rq import Worker
from rq.timeouts import BaseDeathPenalty, JobTimeoutException
from rq.worker import StopRequested, green, blue
from rq.exceptions import DequeueTimeout
@openroc
openroc / DocumentDict.py
Last active October 18, 2021 21:58
DocumentDict (Python)
#!/user/bin/python
import json
class DocumentBase(object):
def traversal_for_init_dict(self, items):
for k in items:
if type(items[k]) == dict:
setattr(self, k, DocumentDict(**items[k]))
elif type(items[k]) == list:
@bg5sbk
bg5sbk / http_timeout.go
Last active February 1, 2018 15:50
How to set timeout for http.Get() in golang.
//
// How to set timeout for http.Get() in golang
//
package main
import (
"io"
"io/ioutil"
"log"
"net"
@hustlzp
hustlzp / permissions.py
Last active February 22, 2019 17:42
Simple permission control in Flask.
# coding: utf-8
from flask import request, g
from functools import wraps
from flask import abort, session, redirect, url_for, flash
from .models import Topic, Attachment
from . import roles
def require_visitor(func):
"""仅允许非登陆用户访问,如signin页面"""
@binux
binux / auto_vpn.sh
Created January 16, 2014 14:48
自动添加gfwlist域名的对应ip到路由表,实现动态自动翻墙
#!/bin/sh
while :
do
dev=$(ip link | grep state | awk '{ sub(":", "", $2); print $2 }' | grep vpn)
if [ $? -ne 0 ]; then
sleep 5
continue
fi
break