Skip to content

Instantly share code, notes, and snippets.

View thomasgogo's full-sized avatar

thomas thomasgogo

  • 06:58 (UTC +08:00)
View GitHub Profile
@terrancesnyder
terrancesnyder / setenv.sh
Created May 23, 2011 00:07
./setenv.sh - example setenv.sh with defaults set for minimal time spent in garbage collection
#! /bin/sh
# ==================================================================
# ______ __ _____
# /_ __/___ ____ ___ _________ _/ /_ /__ /
# / / / __ \/ __ `__ \/ ___/ __ `/ __/ / /
# / / / /_/ / / / / / / /__/ /_/ / /_ / /
#/_/ \____/_/ /_/ /_/\___/\__,_/\__/ /_/
# Multi-instance Apache Tomcat installation with a focus
# on best-practices as defined by Apache, SpringSource, and MuleSoft
@chmouel
chmouel / noclientdebug.py
Created September 2, 2011 02:54
debugging novaclient
import novaclient
from novaclient.v1_1 import client
import logging
ch = logging.StreamHandler()
novaclient.client._logger.setLevel(logging.DEBUG)
novaclient.client._logger.addHandler(ch)
@pcn
pcn / logback.conf
Created May 24, 2012 17:31
trying for a logstash conf file that works with java's logback logger
input {
# file {
# path => ["/var/log/knewton/*/*.log"]
# type => "knewton_logback"
# }
stdin {
type => "knewton_logback"
}
}
@jessone
jessone / hosts
Last active June 29, 2022 13:40
hosts BlockAD update:2022/06/29
#Copyright (c) 2011-2018 huaqing.org
#Update 2020-02-11
127.0.0.1 localhost
0.0.0.0 license.sublimehq.com
#Video
0.0.0.0 atm.youku.com
0.0.0.0 p-log.ykimg.com
0.0.0.0 Fvid.atm.youku.com
0.0.0.0 html.atm.youku.com
0.0.0.0 vhtml.atm.youku.com
@tomheng
tomheng / gist:6149779
Last active May 21, 2019 08:21
用Memcache实现分布式的锁服务
<?php
/**
* 锁服务(用Memcache模拟锁)
*/
class Lock{
private $mc = null;
private $key_prefix = "memcache_lock_service_key_";
@wangwen1220
wangwen1220 / js-trim.js
Created January 26, 2014 07:03
JS: 去掉 String 中的多余空格 | trim
// 去掉 String 中的多余空格
if (!String.prototype.trim) {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
};
}
// 用法
var str = " some string ";
str.trim();

介绍

由于GFW的域名黑名单是不断变化的,如果所有DNS查询都走VPN会丧失CDN加速功能,经常出现本地电信线路,但是却访问网站的联通线路,而且当VPN线路不稳定的时候,会影响所有网站的访问。如果使用域名白名单或黑名单,对于经常访问外国网站的用户,体验很不好,需要用户自己维护域名列表。 该文章介绍如何通过判断并丢弃包含特征IP的DNS包来防止DNS污染,但是又不会失去本地DNS的CDN加速功能,而且还不需要VPN。

前期准备

  • 一台Openwrt路由器
  • 使用dnsmasq作为Openwrt的dns服务器
  • 安装 dig (opkg install bind-dig bind-libs)
  • 安装 iptables 的 string 模块及对应的内核模块 (opkg install iptables-mod-filter kmod-ipt-filter)
# This gist is compatible with Ansible 1.x .
# For Ansible 2.x , please check out:
# - https://gist.github.com/dmsimard/cd706de198c85a8255f6
# - https://github.com/n0ts/ansible-human_log
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@darklow
darklow / celery_tasks_error_handling.py
Last active April 20, 2024 16:25
Celery tasks error handling example
from celery import Task
from celery.task import task
from my_app.models import FailedTask
from django.db import models
@task(base=LogErrorsTask)
def some task():
return result
class LogErrorsTask(Task):
@deviantony
deviantony / vsphere_info.py
Last active March 5, 2023 14:51
VMWare Vsphere info in Python using pyvmomi
#!/usr/bin/env python
import pyVmomi
import argparse
import atexit
import itertools
from pyVmomi import vim, vmodl
from pyVim.connect import SmartConnect, Disconnect
import humanize