Skip to content

Instantly share code, notes, and snippets.

View archerslaw's full-sized avatar
:octocat:
Focusing

Archers Law archerslaw

:octocat:
Focusing
View GitHub Profile
#!/usr/bin/python
#coding:utf-8
import re
import sys
import os
def filerev(somefile, buffer=256):
somefile.seek(0, os.SEEK_END)
size = somefile.tell()
#!/usr/bin/python
#coding:utf-8
import sys
def readfilerev(fd):
buff = 256
fd.seek(0,2)
size = fd.tell()
rem = size % buff
pos = max(0, size - (buff + rem))
#!/usr/bin/python
#coding:utf-8
def readfilerev(fd):
buff = 256
fd.seek(0,2)
size = fd.tell()
rem = size % buff
#pos = max(0, (size / buff -1) * buff)
line = ''
@archerslaw
archerslaw / deploy.py
Created September 7, 2013 06:06 — forked from guixing/deploy.py
import sys
import os
import urllib
import urllib2
import tarfile
import shutil
APP_NAME="wordpress"
input {
file {
path => "/var/log/messages"
type => "syslog"
}
file {
path => "/var/log/php_errors.log"
type => "phperror"
}
file {
@archerslaw
archerslaw / log.py
Created September 14, 2013 07:39 — forked from guixing/log.py
import logging
from logging.handlers import *
import sys
logger = logging.getLogger(name='error')
logger.setLevel(logging.NOTSET)
handle = logging.FileHandler('/tmp/aaa.log')
@archerslaw
archerslaw / network-bridge-scripts.sh
Last active December 23, 2015 02:29
network-bridge-scripts.sh
# cat network-bridge-scripts.sh
#!/bin/bash
#ifcfg-eth0
sed -i 's/^BOOTPROTO=dhcp$/BOOTPROTO=none/g' /etc/sysconfig/network-scripts/ifcfg-eth0
echo "BRIDGE=switch">>/etc/sysconfig/network-scripts/ifcfg-eth0
#ifcfg-br0
echo "DEVICE=switch
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Bridge">>/etc/sysconfig/network-scripts/ifcfg-br0
target=/var/www/html/deploy/package/wordpress-$WP_VERSION.tgz
md5file=$target.md5
tar zcvf $target wordpress-$WP_VERSION
md5sum $target | cut -d\ -f 1 > $md5file
echo $WP_VERSION > /var/www/html/deploy/lastver
@archerslaw
archerslaw / pwgen.py
Created September 28, 2013 04:09 — forked from guixing/pwgen.py
import random
import string
smailar_chars = '01oilLIOpP'
upper = "".join(set(string.uppercase) - set(smailar_chars))
lower = "".join(set(string.lowercase) - set(smailar_chars))
chars = upper + lower
numbers = '23456789'
symbols = '#$%&+,-./:;_~?=@!'
@archerslaw
archerslaw / fabfile.py
Created September 28, 2013 04:12 — forked from guixing/fabfile.py
from fabric.api import *
env.user = 'vagrant'
env.password = 'vagrant'
env.hosts = ['127.0.0.1',]
#env.roledefs = {
# 'web':['localhost'],
# 'db':['127.0.0.1'],
#}
def host_type():