Skip to content

Instantly share code, notes, and snippets.

View bitprophet's full-sized avatar
😅
Looking for work in 2024.H2! Hire me?

Jeff Forcier bitprophet

😅
Looking for work in 2024.H2! Hire me?
View GitHub Profile
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
syntax on
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
(taken from a Trac wiki page; stuff below these two paragraphs is the actual script)
In general, needs Apache 2.0+, mod_wsgi 2.3+, Python 2.5+, MySQL 5.0+. Also needs some Bash stuff for virtualenvwrapper to correctly put stuff into /opt/envs and for some aliases/non-sudo commands used below -- see Jeff's dotfile Github repo for the .bashrc.
Might need attached mod-wsgi .deb if version in APT is not 2.3
--
USER=jforcier
aptitude install libapache2-mod-wsgi mysql-server libmysqlclient-dev python-setuptools
sudo easy_install virtualenv virtualenvwrapper
def sphinx():
with cd('/tmp'):
tgz = 'sphinx-0.9.8.1.tar.gz'
run('wget http://www.sphinxsearch.com/downloads/%s' % tgz)
run('tar xzf %s' % tgz)
with cd(tgz.replace('.tar.gz', '')):
run('./configure')
run('make')
sudo('make install')
bitprophet.org:~ [master] $ cat /srv/git/repositories/fabric.git/hooks/post-update
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, make this file executable by "chmod +x post-update".
#exec git-update-server-info
exec git push --mirror git@github.com:bitprophet/fabric.git >> /tmp/fabric-to-github.log 2>&1
ytram:/u/local [master] $ echo "$FOO"
ytram:/u/local [master] $ FOO='wtf' echo "$FOO"
ytram:/u/local [master] $ FOO='wtf' echo '$FOO'
$FOO
ytram:/u/local [master] $ FOO="wtf" echo "$FOO"
ytram:/u/local [master] $ export FOO="wtf"
ytram:/u/local [master] $ echo "$FOO"
irb(main):001:0> "bobsmith" =~ /(b.b)(.+)/
=> 0
irb(main):002:0> puts $1
bob
=> nil
irb(main):003:0> puts $2
smith
=> nil
rb(main):002:0> "bobsmith".match(/(b.b)(.+)/)
=> #<MatchData "bobsmith" 1:"bob" 2:"smith">
irb(main):003:0> result = "bobsmith".match(/(b.b)(.+)/)
=> #<MatchData "bobsmith" 1:"bob" 2:"smith">
irb(main):004:0> result[0]
=> "bobsmith"
irb(main):005:0> result[1]
=> "bob"
irb(main):006:0> result[2]
=> "smith"
@bitprophet
bitprophet / system.py
Created November 11, 2009 21:23
1st-draft quality Fabric user adding task
def add_user(name=None, password=None, admin='no', apache='no', skip='yes'):
"""
Add a new user named ``name`` to the remote system.
If ``name`` or ``password`` are unspecified, you will be prompted for them.
To have a user added to the admin/wheel group, specify ``admin=yes``.
To add the user to the appropriate Apache group, specify ``apache=yes``.
from fabric.api import *
env.host_string = 'my_user@my_django_host'
env.roledefs = {
'host1': run('workon myenv && ./manage.py account_to_shell')
}
@roles('host1')
def mytask():
run('whatever')
In [20]: list(value for key, value in vars(models).items() if isinstance(value, type) and issubclass(value, Model))
Out[20]:
[<class 'readyroom.catalog.models.Service'>,
<class 'readyroom.catalog.models.System'>,
<class 'readyroom.catalog.models.DriveType'>,
<class 'readyroom.catalog.models.DriveConfig'>,
<class 'readyroom.catalog.models.Worklog'>,
<class 'django.contrib.auth.models.User'>,
<class 'readyroom.catalog.models.Daemon'>,
<class 'readyroom.catalog.models.MemoryType'>,