Skip to content

Instantly share code, notes, and snippets.

View wgzhao's full-sized avatar

wgzhao wgzhao

  • China
View GitHub Profile
@wgzhao
wgzhao / heredoc-argoff-2.sh
Created December 29, 2011 14:36
shell here document usage sample
#!/bin/bash
# generate-script.sh
# Based on an idea by Albert Reiner.
OUTFILE=generated.sh # Name of the file to generate.
# -----------------------------------------------------------
# 'Here document containing the body of the generated script.
(
@wgzhao
wgzhao / re-simple.sh
Created December 30, 2011 02:24
shell regular expression sample
bash$ cat textfile
This is line 1, of which there is only one instance.
This is the only instance of line 2.
This is line 3, another line.
This is line 4.
bash$ grep 'the' textfile
This is line 1, of which there is only one instance.
This is the only instance of line 2.
This is line 3, another line.
@wgzhao
wgzhao / ctrl-h.sh
Created December 30, 2011 03:05
Special Characters with shell
#!/bin/bash
# Embedding Ctl-H in a string.
a="^H^H" # Two Ctl-H's -- backspaces
# ctl-V ctl-H, using vi/vim
echo "abcdef" # abcdef
echo
echo -n "abcdef$a " # abcd f
# Space at end ^ ^ Backspaces twice.
echo
@wgzhao
wgzhao / datediff.sql
Created August 15, 2012 06:51
create simple date diff function ,can return the number of years/months/days between two date
--
create or replace function datediff(m text,d1 date,d2 date) returns int as $$
declare
d1_year int;
d1_month int;
d2_year int;
d2_month int;
day int;
@wgzhao
wgzhao / books_grid.xml
Last active December 10, 2015 10:09
图书馆图书信息,xml格式保存
<?xml version='1.0' encoding='utf-8' ?>
<?xml-stylesheet type='text/xsl' href='grid.xsl' ?>
<all_books>
<book>
<分类号>TN01</分类号>
<书名>模拟电子技术</书名>
<作者>胡宴如主编</作者>
<版次></版次>
<出版社>高等教育出版社</出版社>
<出版时间>2000.8</出版时间>
@wgzhao
wgzhao / grid.xsl
Created December 31, 2012 11:22
解析books_grid.xml文件,并带分页功能
<?xml version="1.0" encoding="utf-8" ?>
<!--
/**********************************************
图书管理系统 v1.0
作者: 赵卫国
联系方式: mlsx@cie.xtu.edu.cn http:/www.xplore.cn
完成时间: 2004年4月
************************************************/
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
@wgzhao
wgzhao / amandserver
Created January 4, 2013 02:27
Amanda services configuration
# default: on
#
# description: Amanda services for Amanda server and client.
#
service amanda
{
disable = no
# flags = IPv6
socket_type = stream
@wgzhao
wgzhao / amandaclient
Created January 4, 2013 02:30
The Amanda backup client should be enabled for systems which will be backed up by an Amanda backup server.
# default: on
#
# description: The Amanda backup client should be enabled for systems
# which will be backed up by an Amanda backup server.
service amanda
{
disable = no
flags = IPv6
socket_type = stream
@wgzhao
wgzhao / makelabel.sh
Created January 4, 2013 02:32
create amand backup server device label
-su-3.2$ for (( i=1;$i < =9;i++)); do amlable FileBackup FileBackup-0$i slot $i;done
labeling tape in slot 1 (file://yourpath/FileBackup/slots):
Reading label...
Found an empty tape.
Writing label FileBackup-01..
Checking label...
Success!
labeling tape in slot 2 (file://yourpath/FileBackup/slots):
Reading label...
Found an empty tape.
@wgzhao
wgzhao / slot_status
Created January 4, 2013 02:33
amand tape slot status
amtape FileBackup show
amtape: scanning all 25 slots in tape-changer rack:
slot 5: time 20090413030002 label FileBackup-05
slot 6: time X label FileBackup-06
slot 7: time X label FileBackup-07
slot 8: time X label FileBackup-08
slot 9: time X label FileBackup-09
slot 10: time X label FileBackup-10
slot 11: time X label FileBackup-11
slot 12: time X label FileBackup-12