From 5ee983d943217f9f02ca84b42bc1ef32b0d81ce3 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 14 Apr 2013 09:31:45 -0700 Subject: [PATCH 1/5] Reset Vim python tw and cc to 80 --- vim/after/ftplugin/python.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vim/after/ftplugin/python.vim b/vim/after/ftplugin/python.vim index c2da26f..49ec05f 100644 --- a/vim/after/ftplugin/python.vim +++ b/vim/after/ftplugin/python.vim @@ -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 From b4aa59297ed6d198c4005e56c6a0491fbc0af51d Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 14 Apr 2013 11:17:10 -0700 Subject: [PATCH 2/5] Add dash and funcoo to Vim bundles --- setup.sh | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/setup.sh b/setup.sh index 55760a5..2f92c71 100755 --- a/setup.sh +++ b/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" From 5d22a2cfa589cea5bebcfe7c6dad835f18ee5783 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 9 Aug 2013 10:13:34 -0700 Subject: [PATCH 3/5] Fix up mkdjango --- zsh/func/makers/mkdjango | 100 ++++++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 37 deletions(-) diff --git a/zsh/func/makers/mkdjango b/zsh/func/makers/mkdjango index 5b6ce87..ba793f2 100644 --- a/zsh/func/makers/mkdjango +++ b/zsh/func/makers/mkdjango @@ -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 $@ From e9901e62b7391f4659f23f1ea0702d55be99c137 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 9 Aug 2013 10:13:52 -0700 Subject: [PATCH 4/5] Add .gitignore to django basic template --- codetemplates/django/basic/.gitignore | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 codetemplates/django/basic/.gitignore diff --git a/codetemplates/django/basic/.gitignore b/codetemplates/django/basic/.gitignore new file mode 100644 index 0000000..cbe218d --- /dev/null +++ b/codetemplates/django/basic/.gitignore @@ -0,0 +1,7 @@ +*.log +*.pot +*.pyc +local_settings.py + +env/ +local.db From 5882ad7d0a41418e0d7c52b9b3786c07d122f705 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 9 Aug 2013 18:21:34 -0700 Subject: [PATCH 5/5] Clean up pw() --- zsh/func/pw | 104 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 68 insertions(+), 36 deletions(-) diff --git a/zsh/func/pw b/zsh/func/pw index fb652dd..90c2f89 100644 --- a/zsh/func/pw +++ b/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 <] [-h] [-l ] [-s ] -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 $@