Skip to content

Instantly share code, notes, and snippets.

View stanwu's full-sized avatar

Stan Wu stanwu

View GitHub Profile
@stanwu
stanwu / auto_mkdir.sh
Created October 25, 2011 12:05
auto_mkdir
#!/bin/bash
# by stanwu http://stanwu.org
for i in `cat stan/passwd | grep -v \# | awk -F: '{print $1}'`
do
echo $i
mkdir -p $i
chown $i $i
done
@stanwu
stanwu / rsync_usb.sh
Created November 6, 2011 10:40
rsync_usb.sh
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 [backup/restore]"
exit
fi
mydir=`dirname $1`
mybase=`basename $1`
mypath="$mydir/$mybase"
@stanwu
stanwu / backup.sh
Created July 11, 2012 15:14
backup mail server
#!/bin/bash
mydate=`date +%m%d%y`
mkdir -p $mydate
tar cvzf - \
/etc \
/usr/local/bin \
/var/mail \
/home | split -b 2048M - $mydate/xxxxxxxx.tgz-
@stanwu
stanwu / onload.php
Created July 17, 2012 09:50
loading page wait please
<head>
<style type='text/css'>
#loading {
background: #ffffff;
position:absolute; width:100%; height:100%;
top:0; bottom:0; left:0; right:0; margin:auto;
filter:alpha(opacity=20);
-moz-opacity: 0.8;
opacity: 0.8;
z-index: 999999999;
@stanwu
stanwu / auto_pack.sh
Created July 17, 2012 17:56
auto backup folder (if less then 8GB total space)
#!/bin/bash
for i in `ls`
do
#echo "[$i]"
if [ -d $i ]; then
mysize=`du -d 0 $i | awk '{print $1}'`
mydate=`date +%m%d%y`
if [ $mysize -lt 8388608 ]; then
echo "Pack $i -> $mysize"
@stanwu
stanwu / go2url.js
Created July 18, 2012 12:20
javascript go to URL
<a href="javascript:go2url('contact.php');" ondblclick="alrt('You double clicked on the link')">HERE</a>
<script>
function go2url(myURL)
{
//alert (clickBusy);
if (clickBusy == 0 ) {
document.location.href=(myURL);
clickBusy = 1;
}
@stanwu
stanwu / test_tgz.sh
Created July 21, 2012 16:00
check tgz files automatically
#!/bin/bash
mkdir -p log
for i in `ls *.tgz *.tar.gz`
do
echo "Check $i..."
tar tvzf $i > log/$i.log
if [ $? != 0 ]; then
mv $i $i.error
@stanwu
stanwu / create_md5.sh
Created July 24, 2012 11:39
create md5 check sum
#!/bin/sh
for i in `ls | grep -v md5$ | grep -v txt$`
do
if [ -s "$i.md5" ]; then
echo "$i had md5sum"
else
echo "Create $i"
md5sum "$i" > "$i.md5"
fi
@stanwu
stanwu / archive.sh
Created July 24, 2012 13:31
archive files to target folder
#!/bin/sh
#
# This shell script is design for Synology DS-411
# auto move all of the archived files to /volume1/archives folder
#
b=`basename "$1"`
d=`pwd`
echo "[RUN] Check [$b] $d/$1"
@stanwu
stanwu / test.vbs
Created July 24, 2012 14:52
write a file
Dim objFSO
Dim objStream
Set objFSO = createobject("scripting.filesystemobject")
Set objStream = objFSO.CreateTextFile("test.csv", True)
for i=1 to 100000
buf=""
for j=1 to 10
buf = buf & i & "000" & j & ","