Browse Source

merge, README update, rvm crap, move html-gallery to its own repo

exuberance
Brennen Bearnes 8 years ago
parent
commit
087b2b6c09
4 changed files with 19 additions and 104 deletions
  1. +13
    -13
      README.md
  2. +4
    -0
      home/.bashrc
  3. +2
    -0
      home/.zshrc
  4. +0
    -91
      home/bin/html-gallery

+ 13
- 13
README.md View File

@ -3,7 +3,8 @@ bpb-kit
This repo is for dotfiles, utility scripts, and other things in my personal
setup. I used to keep more of these in separate repos, but it seemed like
overkill.
overkill. Ideally, this would include most of the bits and pieces that
make a personal machine usable for me.
I mostly use Debian and Debian-like GNU/Linux systems (including Ubuntu). I
usually edit text in Vim, and use the [xmonad][xmonad] tiling window manager.
@ -14,7 +15,7 @@ be relevant.
status
------
As of April 2016, most of this collection is actively maintained, although it
As of July 2016, most of this collection is actively maintained, although it
doesn't meet the standards of quality, consistency, or documentation you might
quite reasonably want from a real software project.
@ -43,24 +44,23 @@ contents
### shell stuff
These days I use ZSH on personal systems and Bash when authoring tutorial
content or doing tech support. I like to keep lots and lots of history. I
think shell scripting is a nightmare for most real tasks, but I do it sometimes
anyway.
These days I use ZSH on personal systems and Bash when writing tutorials or
doing tech support. I like to keep lots and lots of history. I think shell
scripting is a nightmare for most real tasks, but I do it sometimes anyway.
- [`.bashrc`](.bashrc)
- [`.zshrc`](.zshrc) - nothing fancy
- [`.sh_common`](.sh_common) - aliases and variables for both Bash and ZSH;
- [`.bashrc`](home/.bashrc)
- [`.zshrc`](home/.zshrc) - nothing fancy
- [`.sh_common`](home/.sh_common) - aliases and variables for both Bash and ZSH;
no Bash compatibility guarantees here, since I mostly don't use custom
aliases in Bash
### vim config
- [`.vimrc`](.vimrc) - see file for installation details
- [`.vimrc`](home/.vimrc) - see file for installation details
- uses [Vundle][vundle] to manage plugins and such
- pulls in a ton of plugins, some more useful than others
### scripts in [bin/](bin)
### scripts in [home/bin/](home/bin)
Scripts here fall into a handful of categories:
@ -142,8 +142,8 @@ In practice, this means that I rely on it for:
session
- capturing and scrolling back through a bunch of output
My [`.tmux.conf`][.tmux.conf] is brief, but does contain one useful snippet
for correcting weird Esc-key behavior in Vim.
My [`.tmux.conf`](home/.tmux.conf) is brief, but does contain one useful
snippet for correcting weird Esc-key behavior in Vim.
building a debian package for dependencies
------------------------------------------


+ 4
- 0
home/.bashrc View File

@ -58,3 +58,7 @@ esac
# common path, aliases etc. for both shells i actually use
source ~/.sh_common
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

+ 2
- 0
home/.zshrc View File

@ -117,3 +117,5 @@ function chpwd {
# common path, aliases etc. for both shells i actually use
source ~/.sh_common
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

+ 0
- 91
home/bin/html-gallery View File

@ -1,91 +0,0 @@
#!/usr/bin/env python3
"""html-gallery - generate thumbnails and print html for images
Usage:
html-gallery [--base_url=<url>] [--base_dir=<dir>] [-x=<pixels>] [-y=<pixels>] [--source=<pattern>...]
html-gallery (-h | --help)
html-gallery (-v | --version)
Options:
-h --help Show this screen.
--base_url=<url> Base URL for images.
--base_dir=<dir> Base directory on local filesystem for images and thumbs.
--source=<pattern> Source directory or image file(s) to make gallery from.
-x=<pixels> Width of thumbnails
-y=<pixels> Height of thumbnails
-v --version Display version
"""
from docopt import docopt
from PIL import Image
import dominate
import getopt
from dominate.tags import *
from resizeimage import resizeimage
import glob as g, os, sys
def get_images(source):
images = []
if os.path.isdir(source):
# grab things with common file extensions out of dirs
images.extend(g.glob(source + '/*.JPG'))
images.extend(g.glob(source + '/*.jpg'))
images.extend(g.glob(source + '/*.jpeg'))
images.extend(g.glob(source + '/*.png'))
images.extend(g.glob(source + '/*.gif'))
images.extend(g.glob(source + '/*.bmp'))
else:
# assume a specific image file - no checking on path
# because we expect that the user knows they want
# this image
images.extend(g.glob(source))
return images
def main(base_url, base_dir, sources, thumb_x, thumb_y):
for source in sources:
# expand sources as necessary - will grab things from a directory, or just
# return the filename if it's a single file:
images = get_images(source)
if not images:
continue
# ensure that thumbnail directory exists
thumb_directory = base_dir + "/Thumbs"
os.makedirs(thumb_directory, exist_ok=True)
html_output = ''
for image in images:
image_basename = os.path.basename(image)
thumbnail_file = thumb_directory + '/' + image_basename
thumbnail_src = base_url + 'Thumbs/' + image_basename
image_href = base_url + image_basename
html_output += a(img(src=thumbnail_src), href=image_href).render() + "\n"
with open(image, 'r+b') as f:
with Image.open(f) as source_image:
thumb = resizeimage.resize_cover(source_image, [thumb_x, thumb_y])
thumb.save(thumbnail_file, source_image.format)
print(html_output.strip())
if __name__ == '__main__':
args = docopt(__doc__, version='html-gallery 0.0.1')
# defaults - TODO: make this less shit
if not args['--base_url']:
args['--base_url'] = ""
if not args['--base_dir']:
args['--base_dir'] = '.'
if not args['--source']:
args['--source'] = [ args['--base_dir'] ]
if not args['-x']:
args['-x'] = 128
if not args['-y']:
args['-y'] = 128
main(args['--base_url'], args['--base_dir'], args['--source'], args['-x'], args['-y'])
sys.exit()

|||||||
x
 
000:0
Loading…
Cancel
Save