Skip to content

Instantly share code, notes, and snippets.

View alanljj's full-sized avatar
🎯
Focusing

ITGeeker alanljj

🎯
Focusing
View GitHub Profile
@dervn
dervn / re.py
Created March 8, 2011 02:08
Python中过滤HTML标签的函数
#用正则简单过滤html的<>标签
import re
str = "<img /><a>srcd</a>hello</br><br/>"
str = re.sub(r'</?\w+[^>]*>','',str)
print str
@mmrwoods
mmrwoods / postgres
Created January 20, 2012 13:47
Postgres maintenance crontab file
# dump all databases once every 24 hours
45 4 * * * root nice -n 19 su - postgres -c "pg_dumpall --clean" | gzip -9 > /var/local/backup/postgres/postgres_all.sql.gz
# vacuum all databases every night (full vacuum on Sunday night, lazy vacuum every other night)
45 3 * * 0 root nice -n 19 su - postgres -c "vacuumdb --all --full --analyze"
45 3 * * 1-6 root nice -n 19 su - postgres -c "vacuumdb --all --analyze --quiet"
# re-index all databases once a week
0 3 * * 0 root nice -n 19 su - postgres -c 'psql -t -c "select datname from pg_database order by datname;" | xargs -n 1 -I"{}" -- psql -U postgres {} -c "reindex database {};"'
@mmrwoods
mmrwoods / mysql
Created January 20, 2012 13:49
MySQL maintenance crontab file
# note: MySQL_maintenance.pl can be obtained from http://danbuettner.net/mysql-tools/
# check, optimise and repair MySQL databases (extended check on Sunday, quick every other day)
15 3 * * 0 root nice -n 19 /usr/local/sbin/MySQL_maintenance.pl --check-type=extended --optimize --repair --exclude-dbs=information_schema
15 3 * * 1-6 root nice -n 19 /usr/local/sbin/MySQL_maintenance.pl --check-type=quick --optimize --repair --exclude-dbs=information_schema > /dev/null
# dump all mysql databases once every 24 hours
15 4 * * * root nice -n 19 mysqldump --opt --all-databases --allow-keywords | gzip -9 > /var/local/backup/mysql/mysql_all.sql.gz
@filippo
filippo / zimbra-all-accounts-and-domains.sh
Last active May 27, 2021 13:40
Zimbra remove all accounts TODO: find a better way to automate this
# as zimbra user
$ zmprov -l gaa |grep -v admin-domain.com >/tmp/accounts.zmp
$ zmprov -l gad |grep -v admin-domain.com >/tmp/domains.zmp
@macbleser
macbleser / wp-permissions-script
Created February 21, 2014 15:37
WordPress Permissions Configuration Script
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro
#
WP_OWNER=changeme # &lt;-- wordpress owner
WP_GROUP=changeme # &lt;-- wordpress group
WP_ROOT=/home/changeme # &lt;-- wordpress root directory
@kjprince
kjprince / Wordpress Nginx Config
Last active April 14, 2021 17:31
/etc/nginx/wordpress.conf
##################################
# WORDPRESS NGINX CONFIGURATIONS
##################################
# /etc/nginx/wordpress.conf
#
# Contains a common configuration for use by nginx on a WordPress
# installation. This file should be included in any WordPress site
# nginx virtual host config located in sites-available with the following line:
#
# include /etc/nginx/wordpress.config;
@ognjenm
ognjenm / export.sh
Last active June 19, 2019 06:28
The following script will export all zimbra accounts to an import script
#!/bin/bash
# The following script will export all accounts to an import script.
# this script should be run as zimbra user
# target for ZCS 8, single server deployment
# last update 2014-04-04
# ognjen.miletic@gmail.com
# original at http://www.3open.org/d/zimbra/export_accounts
# customize these to your needs
@nerr
nerr / g.bat
Created June 11, 2014 10:10
git操作菜单批处理脚本(For Windows)
@echo off
:: color 17
:: title
@title git batch
:: check
:check
cls
echo. =-=-=-=-=git status=-=-=-=-=
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@filippo
filippo / zimbra-backup-emails.sh
Created January 28, 2015 16:04
How to backup and restore emails of a specific account on zimbra
# The command below creates a tgz file with all emails for user@domain.com in .eml format:
# execute as root
/opt/zimbra/bin/zmmailbox -z -m user@domain.com getRestURL "//?fmt=tgz" > /tmp/account.tgz
# You can do the same via a REST URL:
wget http://ZIMBRA.SERVER/home/user@domain.com/?fmt=tgz
# to restore email:
/opt/zimbra/bin/zmmailbox -z -m user@domain.com postRestURL "//?fmt=tgz&resolve=reset" /tmp/account.tgz