Skip to content

Instantly share code, notes, and snippets.

@mywaiting
mywaiting / rules-both.iptables
Created November 11, 2015 17:34 — forked from jirutka/rules-both.iptables
Basic iptables template for ordinary servers (both IPv4 and IPv6)
###############################################################################
# The MIT License
#
# Copyright 2012-2014 Jakub Jirutka <jakub@jirutka.cz>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is

新闻w

RHEL 7 发布应该算是比较大的新闻了吧~

人民群众纷纷表示红帽步子太大不要扯着蛋了比较好...

F_XZ: 完全没关心...

猫注意的新功能有 virtio 等 KVM 优化, docker 支持, 以及 ruby 2.0, python 2.7, java 7 之类的吧

@mywaiting
mywaiting / test.html
Last active August 29, 2015 14:03
小小的JS测试题,可以试试看。
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
// require.js
this.require || this.define || (function() {
var head = document.getElementsByTagName("head")[0],
iModules = {},
oModules = {};
@mywaiting
mywaiting / recaptcha.py
Created July 4, 2014 14:29
Tornado-Recaptcha
#!/usr/bin/env python
# -*- coding: utf-8 -*-
try:
import urllib.parse as urllib_parse # py3
except ImportError:
import urllib as urllib_parse # py2
import tornado
var list = new Array("Bulgaria", "93.123.23.1/59",
"Egypt", "197.199.253.1/59",
"Egypt", "197.199.254.1/59",
"Hong Kong", "218.189.25.129/187",
"Hong Kong", "218.253.0.76/92", "218.253.0.140/187",
"Iceland", "149.126.86.1/59",
"Indonesia", "111.92.162.4/6", "111.92.162.12/59",
"Iraq", "62.201.216.196/251",
"Japan", "218.176.242.4/251",
"Kenya", "41.84.159.12/30",
@mywaiting
mywaiting / require.quora.js
Last active December 26, 2015 00:39
Quora Require for Browser in 2013-10-20
this.require || function(global, undefined) {
/**
require
var module = require("ModuleName");
*/
function require(a) {
if (!exported[a]) {
rec("loader.require", "Required", a);
var b, c = installed[a];
@mywaiting
mywaiting / graceful_shutdown_tornado_web_server.py
Last active May 7, 2022 08:30
The example to how to shutdown tornado web server gracefully...
#!/usr/bin/env python
"""
How to use it:
1. Just `kill -2 PROCESS_ID` or `kill -15 PROCESS_ID` , The Tornado Web Server Will shutdown after process all the request.
2. When you run it behind Nginx, it can graceful reboot your production server.
3. Nice Print in http://weibo.com/1682780325/zgkb7g8k7
"""
@mywaiting
mywaiting / chrome_capture_window.js
Created August 25, 2012 14:33
Chrome截图的实现
/*
可以实现:
1. 选择区域截图
2. 可视区域截图
3. 整张网页截图
*/
var screenshot = {
tab: 0,
@mywaiting
mywaiting / gist:3452130
Created August 24, 2012 15:42 — forked from mitchellh/gist:1241519
reCaptcha field for WTForms
"""
Contains reCaptcha fields for WTForms which can be used
for various forms. This library depends on `recaptcha-client` ~> 1.0.6.
Example usage is below.
Defining a form with a ``RecaptchaField``:
from wtforms import Form
from recaptcha_field import RecaptchaField
@mywaiting
mywaiting / tornado.file.upload.py
Created August 23, 2012 16:45
Tornado上传文件的例子!
"""
http://saepy.sinaapp.com/topic/24/Tornado%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6%E7%A4%BA%E4%BE%8B
在bcore的开发过程中涉及到上传文件有两个地方一个是相册一个是文章图文混排这里作为一个备忘罗列一些关键点
文件上传的内容体在tornado.web.RequestHandler.request.files属性中并且是以数组形式存放的
使用临时文件存储时在write完成后要记着把seek重置到文件头要不然文件无法被读取
再使用Image模块的thumbnail方法进行缩放时,resample=1作为重载渲染参数能够有效的使图片平滑消除锯齿