Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
居家办公

FbiGun Deo fbigun

🏠
居家办公
View GitHub Profile
@fbigun
fbigun / build.sh
Created Jul 12, 2019 — forked from Forst/build.sh
Ubuntu ISO with preseed.cfg generation script
View build.sh
#!/bin/bash
## FORSTWOOF UBUNTU PRESEED :: BUILD SCRIPT
# Quit on first error
set -e
# Temporary directory for the build
TMP="/var/tmp/ubuntu-build"
@fbigun
fbigun / dnsmasq-gfwlist.py
Created May 22, 2017 — forked from lanceliao/dnsmasq-gfwlist.py
将gfwlist转换成带ipset的dnsmasq规则,适用于OpenWrt智能上网
View dnsmasq-gfwlist.py
#!/usr/bin/env python
#coding=utf-8
#
# Generate a list of dnsmasq rules with ipset for gfwlist
#
# Copyright (C) 2014 http://www.shuyz.com
# Ref https://code.google.com/p/autoproxy-gfwlist/wiki/Rules
import urllib2
import re
@fbigun
fbigun / 0_urllib2.py
Created Dec 30, 2015 — forked from kennethreitz42/0_urllib2.py
urllib2 vs requests
View 0_urllib2.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
@fbigun
fbigun / contrast_Barcode.py
Created Nov 12, 2014
比较两个箱码,和盒码重复的条目
View contrast_Barcode.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# file: contrast_Barcode.py
import xml.etree.ElementTree as ET
import os
import sys
def Barcode_info(Barcode_info_filename):
tree = ET.ElementTree(element=None, file='%s.xml'%Barcode_info_filename)
@fbigun
fbigun / test.py
Last active Aug 29, 2015
测试成功
View test.py
#!/usr/bin/env python3
while True:
print('Input "exit" or "enter", Exit the program')
a = input('input a num "a":')
if a == 'quit' or a == '': break
b = input('input a num "b":')
if b == 'quit' or b == '': break
try :
a = int(a)
@fbigun
fbigun / README.md
Last active Aug 29, 2015
设计Python数据库连接池1-对象的循环引用问题
View README.md

Python中如果对象定义了__del__方法的话,在对象的引用记数为0时会自动调用__del__方法 (很象c++中的析构函数),但如果A对象引用B对象,B对象又引用A对象,就形成循环引用,此时A,B对象 引用次数都为1。python就无法正常调用__del__方法,原计划在__del__方法里释放的资源自然也就无 法释放。

一个连接池拥有多个连接,而每个连接又拥有这个连接池的实例(一个叫pool的属性)。这样就产生了刚刚 说的哪个问题。我想到的办法就是在每次从池中获取连接的时候将连接的pool设置为当前实例,然后在归 还这个连接的时候再将其设置为None,并且要在这个连接对象的__del__方法中将pool属性设置为 None。具体看代码吧。(目前只实现了SQLite3的)

View Pacman 命令详解
Pacman 命令详解
Pacman 是一个命令行工具,这意味着当你执行下面的命令时,必须在终端或控制台中进行。
1、更新系统
在 Arch Linux 中,使用一条命令即可对整个系统进行更新:
pacman -Syu
如果你已经使用 pacman -Sy 将本地的包数据库与远程的仓库进行了同步,也可以只执行:
View kindlestrip.py
#!/usr/bin/python
#
# This is a python script. You need a Python interpreter to run it.
# For example, ActiveState Python, which exists for windows.
#
# This script strips the penultimate record from a Mobipocket file.
# This is useful because the current KindleGen add a compressed copy
# of the source files used in this record, making the ebook produced
# about twice as big as it needs to be.
#
View dnspodsh.sh
#!/bin/bash
##############################
# dnspodsh v0.3
# 基于dnspod api构架的bash ddns客户端
# 作者:zrong(zengrong.net)
# 详细介绍:http://zengrong.net/post/1524.htm
# 创建日期:2012-02-13
# 更新日期:2012-03-11
##############################
View dnspod.py
#!/usr/bin/env python2
# -*- coding:utf8 -*-
'''
* forked from dnspod's offical python script for dynamic dns record
* modified by Justin Wong <bigeagle(at)xdlinux(dot)info>
* LICENSE: MIT License
'''
import httplib, urllib
You can’t perform that action at this time.