Skip to content

Instantly share code, notes, and snippets.

View fbigun's full-sized avatar
🏠
居家办公

FbiGun Deo fbigun

🏠
居家办公
View GitHub Profile
Pacman 命令详解
Pacman 是一个命令行工具,这意味着当你执行下面的命令时,必须在终端或控制台中进行。
1、更新系统
在 Arch Linux 中,使用一条命令即可对整个系统进行更新:
pacman -Syu
如果你已经使用 pacman -Sy 将本地的包数据库与远程的仓库进行了同步,也可以只执行:
@fbigun
fbigun / build.sh
Created July 12, 2019 13:51 — forked from Forst/build.sh
Ubuntu ISO with preseed.cfg generation script
#!/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 05:00 — forked from lanceliao/dnsmasq-gfwlist.py
将gfwlist转换成带ipset的dnsmasq规则,适用于OpenWrt智能上网
#!/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 December 30, 2015 12:42 — forked from kennethreitz/0_urllib2.py
urllib2 vs requests
#!/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 November 12, 2014 14:28
比较两个箱码,和盒码重复的条目
#!/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 August 29, 2015 14:08
测试成功
#!/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 August 29, 2015 14:08
设计Python数据库连接池1-对象的循环引用问题

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

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

@fbigun
fbigun / kindlestrip.py
Last active August 29, 2015 14:07 — forked from xwmx/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.
#
@fbigun
fbigun / dnspodsh.sh
Last active August 29, 2015 14:06 — forked from zrong/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
##############################
@fbigun
fbigun / dnspod.py
Last active August 29, 2015 14:05 — forked from bigeagle/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