Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
34a6943d73
5 changed files with 150 additions and 97 deletions
7
codetemplates/django/basic/.gitignore
vendored
Normal file
7
codetemplates/django/basic/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
*.log
|
||||
*.pot
|
||||
*.pyc
|
||||
local_settings.py
|
||||
|
||||
env/
|
||||
local.db
|
||||
32
setup.sh
32
setup.sh
|
|
@ -13,16 +13,18 @@ typeset -A vimbundles
|
|||
# fugitive "https://github.com/tpope/vim-fugitive.git" \
|
||||
vimbundles=( \
|
||||
command-t "https://github.com/wincent/Command-T.git" \
|
||||
dash "https://github.com/rizzatti/dash.vim.git"
|
||||
funcoo "git clone https://github.com/rizzatti/funcoo.vim.git" \
|
||||
gundo "https://github.com/sjl/gundo.vim.git" \
|
||||
mw-utils "https://github.com/MarcWeber/vim-addon-mw-utils.git" \
|
||||
repeat "https://github.com/tpope/vim-repeat" \
|
||||
snipmate "https://github.com/garbas/vim-snipmate.git" \
|
||||
tlib "https://github.com/tomtom/tlib_vim.git" \
|
||||
mw-utils "https://github.com/MarcWeber/vim-addon-mw-utils.git" \
|
||||
snipmate-snippets "https://github.com/honza/snipmate-snippets.git" \
|
||||
snipmate-zope "https://github.com/zedr/zope-snipmate-bundle.git" \
|
||||
solarized "https://github.com/altercation/vim-colors-solarized.git" \
|
||||
speeddating "https://github.com/tpope/vim-speeddating.git" \
|
||||
surround "https://github.com/tpope/vim-surround.git" \
|
||||
tlib "https://github.com/tomtom/tlib_vim.git" \
|
||||
unimpaired "https://github.com/tpope/vim-unimpaired.git" \
|
||||
)
|
||||
|
||||
|
|
@ -35,31 +37,17 @@ print -P "%BSymlinking config files%b"
|
|||
for dotfile in `ls $dfdir`
|
||||
do
|
||||
# metafiles; don't link them
|
||||
[ $dotfile = 'setup.sh' ] && continue
|
||||
[ $dotfile = 'README.md' ] && continue
|
||||
[[ $dotfile = 'setup.sh' ]] && continue
|
||||
[[ $dotfile = 'README.md' ]] && continue
|
||||
|
||||
local dest="$HOME/.$dotfile"
|
||||
local action='skipped'
|
||||
|
||||
if [[ ! -L "$dest" ]]; then
|
||||
action='linked'
|
||||
else
|
||||
action='skipped'
|
||||
fi
|
||||
filler=$(($COLUMNS - ${#dest} - ${#action} - 4))
|
||||
spaces=''
|
||||
for (( i=0; $i < $filler; i++ )); do spaces="$spaces "; done
|
||||
|
||||
echo -n " $dest"
|
||||
if [[ $action == 'linked' ]]; then
|
||||
if [[! -L "$dest" ]]; then
|
||||
action='Linking'
|
||||
ln -fs "$dfdir/$dotfile" "$dest"
|
||||
action="%F{green}$action%f"
|
||||
elif [[ $action == 'skipped' ]]; then
|
||||
action="%F{yellow}$action%f"
|
||||
else
|
||||
action="%F{red}red%f"
|
||||
action='Skipping'
|
||||
fi
|
||||
print -P "$spaces$action"
|
||||
printf " %8s: %s\n" $action $dest
|
||||
done
|
||||
|
||||
echo "touch $HOME/.hushlogin"
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ setlocal expandtab
|
|||
|
||||
let s:buf_filename = expand('%:t')
|
||||
if s:buf_filename != "SConscript" && s:buf_filename != "SConstruct"
|
||||
setlocal textwidth=100
|
||||
setlocal colorcolumn=100
|
||||
setlocal textwidth=80
|
||||
setlocal colorcolumn=80
|
||||
else
|
||||
setlocal textwidth=80
|
||||
setlocal colorcolumn=80
|
||||
|
|
|
|||
|
|
@ -6,46 +6,72 @@
|
|||
local funcname=$0
|
||||
|
||||
|
||||
_usage() {
|
||||
_usage_mkdjango() {
|
||||
print_info "Usage: $funcname template_name project_name [optional destination directory]"
|
||||
}
|
||||
|
||||
if [[ ${#@} -lt 2 ]]; then
|
||||
print_error "Need moar arguments" 1>&2
|
||||
_usage
|
||||
return -1
|
||||
fi
|
||||
|
||||
|
||||
local tname=$1
|
||||
local tdir="$HOME/.codetemplates/django/$tname"
|
||||
local pname=$2
|
||||
local dest=$3
|
||||
|
||||
if [[ ! -d "$tdir" ]]; then
|
||||
print_error "Invalid template name: $tname" 1>&2
|
||||
return -2
|
||||
fi
|
||||
|
||||
|
||||
print_info "Making Django project '$pname' with template '$tname'"
|
||||
if [[ -n "$dest" && ! -d "$dest" ]]; then
|
||||
print_info_sub "Destination directory given but does not exist; creating $dest"
|
||||
mkdir -p "$dest"
|
||||
fi
|
||||
|
||||
# Determine what files might not be rendered by django-admin.py
|
||||
local names=()
|
||||
for f in `find "$tdir"`; do
|
||||
# Pick up all dotfiles
|
||||
if [[ -e "$f" && "`basename $f`" =~ "^\." ]]; then
|
||||
names+=($f)
|
||||
function mkdjango
|
||||
{
|
||||
if [[ ${#@} -lt 2 ]]; then
|
||||
print_error "Need moar arguments" 1>&2
|
||||
_usage_mkdjango
|
||||
return -1
|
||||
fi
|
||||
done
|
||||
|
||||
print_info_sub "Calling django-admin.py"
|
||||
django-admin.py startproject --template="$tdir" --name=${(j.,.)names} $pname $dest
|
||||
exitcode=$?
|
||||
local template_name=$1
|
||||
local template_dir="$HOME/.codetemplates/django/$template_name"
|
||||
local project_name=$2
|
||||
local project_dst=$3
|
||||
|
||||
unfunction _usage
|
||||
return $exitcode
|
||||
if [[ ! -d "$template_dir" ]]; then
|
||||
print_error "Invalid template name: $template_name" 1>&2
|
||||
return -2
|
||||
fi
|
||||
|
||||
if [[ -n "$project_dst" ]]; then
|
||||
if [[ ! -d "$project_dst" ]]; then
|
||||
print_info_sub "Destination directory given but does not exist; " \
|
||||
"will create $project_dst"
|
||||
fi
|
||||
else
|
||||
project_dst="`pwd`/$project_name"
|
||||
fi
|
||||
|
||||
print_info "Making Django project '$project_name'"
|
||||
print_info_sub "Template name: $template_name"
|
||||
print_info_sub "Template directory: $template_dir"
|
||||
print_info_sub "Project directory: $project_dst"
|
||||
|
||||
# Determine what files might not be rendered by django-admin.py
|
||||
local missing_files=()
|
||||
for f in `ls -A1 "$template_dir"`; do
|
||||
# Pick up all dotfiles
|
||||
if [[ -e "$f" && "$f" =~ "^\." ]]; then
|
||||
missing_files+=("$f")
|
||||
fi
|
||||
done
|
||||
print_info_sub "Missing files: ${(j., .)missing_files}"
|
||||
|
||||
mkdir -p "$project_dst"
|
||||
|
||||
print_info "Calling django-admin.py"
|
||||
django-admin.py startproject --template="$template_dir" \
|
||||
--name=${(j.,.)missing_files} \
|
||||
"$project_name" \
|
||||
"$project_dst"
|
||||
exitcode=$?
|
||||
if [[ $exitcode -ne 0 ]]; then
|
||||
print_error "django-admin.py failed"
|
||||
return $exitcode
|
||||
fi
|
||||
|
||||
# print_info "Setting up Git repo"
|
||||
# cd "$project_dir"
|
||||
# git init
|
||||
# git add * .*
|
||||
# git commit -m 'Initial commit'
|
||||
|
||||
return $exitcode
|
||||
}
|
||||
|
||||
mkdjango $@
|
||||
|
|
|
|||
104
zsh/func/pw
104
zsh/func/pw
|
|
@ -1,44 +1,76 @@
|
|||
#!/bin/zsh
|
||||
# vim:ft=zsh
|
||||
|
||||
local ALPHA_SET='A-Za-z'
|
||||
local NUMERIC_SET='0-9'
|
||||
local SYM_SET='!@#$%^&*'
|
||||
local XSYM_SET="${SYM_SET}.;:-+="
|
||||
local ALNUM_SET="${ALPHA_SET}${NUMERIC_SET}"
|
||||
local ALL_SET="${ALNUM_SET}${SYM_SET}"
|
||||
local XALL_SET="${ALNUM_SET}${XSYM_SET}"
|
||||
function _usage_pw
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: $1 [-c <num>] [-h] [-l <num>] [-s <set>]
|
||||
|
||||
local -i length=16 count=1
|
||||
local charset="$ALL_SET"
|
||||
Password generator. Uses the system random data generator to produce passwords
|
||||
of the provided length.
|
||||
|
||||
while getopts 'c:l:s:' opt; do
|
||||
case $opt in
|
||||
c) count=$OPTARG;;
|
||||
l) length=$OPTARG;;
|
||||
s) case $OPTARG in
|
||||
alpha) charset="$ALPHA_SET";;
|
||||
num) charset="$NUMERIC_SET";;
|
||||
alnum) charset="$ALNUM_SET";;
|
||||
sym) charset="$SYM_SET";;
|
||||
xsym) charset="$XSYM_SET";;
|
||||
all) charset="$ALL_SET";;
|
||||
xall) charset="$XALL_SET";;
|
||||
*) echo "Invalid set name: $OPTARG" 1>&2; return -2;;
|
||||
esac
|
||||
;;
|
||||
*) echo "Invalid argument: $opt" 1>&2; return -1;;
|
||||
esac
|
||||
done
|
||||
Arguments:
|
||||
-c Count. Number of passwords to generate. (default: 1)
|
||||
-h Help. This message.
|
||||
-l Length. Number of characters per password. (default: 16)
|
||||
-s Character set. Set of characters from which each character of a
|
||||
password is generated. (default: all)
|
||||
|
||||
local cmd='tr -dc "$charset" < /dev/urandom | fold -w $length | head -n $count'
|
||||
alpha Uppercase and lowercase ASCII characters (A-Za-z)
|
||||
num Numeric characters (0-9)
|
||||
alnum The above two sets combined
|
||||
sym Symbol set, including: ! @ # $ % ^ & *
|
||||
xsym Extended symbols. Above plus . ; : - + =
|
||||
all Alphanumeric and symbol sets above
|
||||
xall Alphanumeric and extended symbol sets above
|
||||
EOF
|
||||
}
|
||||
|
||||
if [[ $SYS == 'darwin' ]]; then
|
||||
# The way OS X >=10.6 handles unicode characters causes tr to fail with an
|
||||
# 'Illegal byte sequence' error. Setting the locale here fixes that.
|
||||
#
|
||||
# See: http://nerdbynature.de/s9y/?176
|
||||
cmd="LC_CTYPE=C $cmd"
|
||||
fi
|
||||
|
||||
eval "$cmd"
|
||||
function pw
|
||||
{
|
||||
local ALPHA_SET='A-Za-z'
|
||||
local NUMERIC_SET='0-9'
|
||||
local SYM_SET='!@#$%^&*'
|
||||
local XSYM_SET="${SYM_SET}.;:-+="
|
||||
local ALNUM_SET="${ALPHA_SET}${NUMERIC_SET}"
|
||||
local ALL_SET="${ALNUM_SET}${SYM_SET}"
|
||||
local XALL_SET="${ALNUM_SET}${XSYM_SET}"
|
||||
|
||||
local -i length=16 count=1
|
||||
local charset="$ALL_SET"
|
||||
|
||||
while getopts 'c:hl:s:' opt; do
|
||||
case $opt in
|
||||
c) count=$OPTARG;;
|
||||
h) _usage_pw $0; return 0;;
|
||||
l) length=$OPTARG;;
|
||||
s) case $OPTARG in
|
||||
alpha) charset="$ALPHA_SET";;
|
||||
num) charset="$NUMERIC_SET";;
|
||||
alnum) charset="$ALNUM_SET";;
|
||||
sym) charset="$SYM_SET";;
|
||||
xsym) charset="$XSYM_SET";;
|
||||
all) charset="$ALL_SET";;
|
||||
xall) charset="$XALL_SET";;
|
||||
*) echo "Invalid set name: $OPTARG" 1>&2; return -2;;
|
||||
esac
|
||||
;;
|
||||
*) echo "Invalid argument: $opt" 1>&2; return -1;;
|
||||
esac
|
||||
done
|
||||
|
||||
local cmd='tr -dc "$charset" < /dev/urandom | fold -w $length | head -n $count'
|
||||
|
||||
if [[ $SYS == 'darwin' ]]; then
|
||||
# The way OS X >=10.6 handles unicode characters causes tr to fail with an
|
||||
# 'Illegal byte sequence' error. Setting the locale here fixes that.
|
||||
#
|
||||
# See: http://nerdbynature.de/s9y/?176
|
||||
cmd="LC_CTYPE=C $cmd"
|
||||
fi
|
||||
|
||||
eval "$cmd"
|
||||
}
|
||||
|
||||
pw $@
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue