Skip to content

Instantly share code, notes, and snippets.

@iOS0x00
iOS0x00 / settings.py
Created September 1, 2015 06:13
Django调试ORM的日志配置
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
"console": {
'class': 'logging.StreamHandler',
}
},
'loggers': {
'django.db.backends': {
@iOS0x00
iOS0x00 / 2000w.py
Last active August 30, 2015 12:13
2000w数据csv入库修正版,基于网上的版本修正,不要太在意代码风格 :doge:
# -*- coding:utf-8 -*-
import os
import csv
import MySQLdb as mysql
inpath = '.'
uipath = unicode(inpath, "utf-8")
files = os.listdir(uipath) # 存放2000万开房数据的路径
@iOS0x00
iOS0x00 / get_aliyun_ips.py
Last active August 30, 2015 12:14
阿里云ECS获取所有vps的IP sample
# -*- coding: utf-8 -*-
import aliyun.api
import sys
aliyun.setDefaultAppInfo("key", "secret")
a = aliyun.api.Ecs20140526DescribeInstancesRequest()
def get_instance_ip(region=''):
@iOS0x00
iOS0x00 / mqpublisher.py
Created January 28, 2015 09:17
RabbitMQ pika的封装,支持多台node负载以及keepalive
# -*- coding: utf-8 -*-
# vim: ts=4:sw=4:expandtab
"""
RabbitMQ 库封装,主要是针对多台rabbitmq服务器的HA支持, 另外对执行动作时的心跳检测。
"""
import os
import pika
# coding: utf-8
# vim: ts=4:sw=4:expandtab
"""
Copyright (c) 2014 SysDev Tools.
"""
import os
import sys
@iOS0x00
iOS0x00 / pyApacheStatus.py
Created September 1, 2014 08:11
获取Apache状态页面的数据
#!/bin/env python
# Author: Neil <neil@neildd.com>
# Date: 1-24-2013
# Desc: Read information from Apache status page
import re
import urllib2
class pyApacheStatus:
def __init__(self, apache_host):
@iOS0x00
iOS0x00 / general.js
Created April 1, 2014 07:09
Js APP struct demo
var App = function() {
// Basic Config
var config = {
debug: true
};
// HomeView
var home = function() {
console.log('hello home');
@iOS0x00
iOS0x00 / com.googlecode.goagent.plist
Created March 29, 2014 04:48
goagent mac launchctl plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.googlecode.goagent</string>
# This is a hack to patch slow socket.getfqdn calls that
# BaseHTTPServer (and its subclasses) make.
# See: http://bugs.python.org/issue6085
# See: http://www.answermysearches.com/xmlrpc-server-slow-in-python-how-to-fix/2140/
import BaseHTTPServer
def _bare_address_string(self):
host, port = self.client_address[:2]
return str(host)