Using the ~/.ssh/config file is an easy way to give your
remote machines nicknames and reduce the number of keystrokes needed
to login with ssh, rsync,
hg push/pull/clone, access
files via Emacs Tramp
(Transparent Remote (file) Access, Multiple Protocol),
or use any other SSH-based tool.
Here is part of my ~/.ssh/config file. It defines the
nicknames turk, tyran, tuna, and tally for some EC2 servers I've been
working with.
Host turk User root HostName ec2-67-202-21-122.compute-1.amazonaws.com Host tuna User root HostName ec2-75-101-178-62.compute-1.amazonaws.com Host tyran User root HostName ec2-67-202-43-207.compute-1.amazonaws ...Read more...
from datetime import datetime
import time
#-------------------------------------------------
# conversions to strings
#-------------------------------------------------
# datetime object to string
dt_obj = datetime(2008, 11, 10, 17, 53, 59)
date_str = dt_obj.strftime("%Y-%m-%d %H:%M:%S")
print date_str
# time tuple to string
time_tuple = (2008, 11, 12, 13, 51, 18, 2, 317, 0)
date_str = time.strftime("%Y-%m-%d %H:%M:%S", time_tuple)
print date_str
#-------------------------------------------------
# conversions to datetime objects
#-------------------------------------------------
# time tuple to datetime object
time_tuple = (2008, 11, 12, 13, 51, 18, 2, 317, 0)
dt_obj = datetime(*time_tuple[0:6])
print repr(dt_obj)
# date string to datetime object
date_str = "2008-11-10 17:53:59"
dt_obj = datetime.strptime(date_str, "%Y- ...UnicodeEncodeError: 'ascii' codec can't encode character u'\xa1' in position 0: ordinal not in range(128)
If you've ever gotten this error, Django's smart_str
function might be able to help. I found this from James Bennett's
article,
Unicode in the real world. He provides a very good explanation
of Python's Unicode and bytestrings, their use in Django, and using
Django's Unicode utilities for working with non-Unicode-friendly
Python libraries. Here are my notes from his article as it applies
to the above error. Much of the wording is directly from James
Bennett's article.
This ...
Read more...
aws
(4)
bison_flex
(1)
blogger
(4)
c
(10)
cardstore
(5)
colinux
(2)
concurrency
(8)
conkeror
(2)
cygwin
(17)
dell
(3)
django
(31)
eclipse
(30)
emacs
(18)
email
(1)
error
(11)
gnip
(1)
json
(1)
keyboard
(3)
linux
(31)
matplotlib
(5)
mercurial
(3)
openid
(1)
personal
(4)
preferences
(4)
pyqt
(18)
python
(88)
rails
(1)
ratpoison
(3)
recursion
(1)
rsync
(3)
ruby
(2)
sql
(10)
subversion
(4)
twisted
(5)
ubuntu
(33)
untagged
(7)
urxvt
(3)
vxworks
(26)
wmii
(3)