In zsh:
alias ':q'=exit
I can’t count the number of times I’ve typed ‘:q’ by mistake in a shell expecting it to quit.
Now it will
|
|||
|
In zsh:
I can’t count the number of times I’ve typed ‘:q’ by mistake in a shell expecting it to quit. Now it will To calculate the amount of free disk space in Python, you can use the os.stafvfs() function. For some reason, I can never find the docs for os.statvfs() on the first or second try (it’s in the “Files and Directories” section in the os module), and I never remember how it works, so I’m posting this as a note to myself, and maybe to help out anybody else wanting to do the same thing. A simple free space function can be written as: import os def freespace(p): """ Returns the number of free bytes on the drive that ``p`` is on """ s = os.statvfs(p) return s.f_bsize * s.f_bavail I use the f_bavail attribute instead of f_bfree, since the latter includes blocks that are reserved for the the super-user’s use. I’m not sure, however, on the distinction between f_bsize and f_frsize.
Will, I am in 100% agreement. Thanks a ton for this! Will posted a link to the Python Sidebar which adds a sidebar to Mozilla or Firefox for accessing Python’s excellent online documentation. via Planet Python Via Planet Debian: Enrico Zini posts about using the clipboard with vim Two cool things I learned from Enrico’s post:
Wow! Every good linux user knows about the kill command. You use it all the time to kill off out of control or dead processes. kill 1234 will kill off the process with pid 1234. But did you know that kill -TERM -1234 will kill off all processes in 1234′s process group? I didn’t until just a few minutes ago! Super-handy! You learn something new every day! Today I learned about the disown builtin in bash and zsh. When you disown a job, it will no longer receive a HUP signal when you exit your shell. catlee@sherwood:~ [1015]% while true; do date >> date.log; sleep 10; done& [1] 7380 So now you’ve got the current date being appended to date.log every 10 seconds. Try exiting your shell: catlee@sherwood:~ [1016%1]% exit zsh: you have running jobs. But use the disown command: catlee@sherwood:~ [1017%1]% disown %1 catlee@sherwood:~ [1018]% exit and your shell exits without complaining. Meanwhile, your job keeps running in the background! I saw this a while back: Philip Kern talks blogs about ssh control connections The gist of it is that you can multiplex several ssh sessions over a single connection, saving you from having to authenticate every time. Very handy when you can’t set up authorized keys for whatever reason. At least that’s the way it feels! I just realized that my laptop supports 1600×1200 resolution! And I’ve been running it at 1024×768 all this time! So after fighting with the fglrx drivers for Debian, I can finally surf the web and read e-mails without having to scroll left and right all the time! Setting up fglrx was less than painless to put it mildly. For future reference, I had to do something like this: aptitude install fglrx-kernel-src
cd /usr/src
tar jxf fglrx.tar.bz2
cd modules/fglrx
export KVERS=2.6.16-1-686
export KSRC=/usr/src/linux-headers-${KVERS}
debian/rules binary_modules
I would have hoped that Oh, and other thing. ATI: it isn’t cool to lock up the machine just because your driver doesn’t support 16 bit colour. I had set my default colour depth to 16bpp previously in an effort to get higher resolution with the radeon driver, but when I started using the fglrx driver things would just lock up. Here’s another little script I’m sharing with the world. It’s a plugin for vim that will look for aborted svn commit log messages and read the latest one into the current buffer. For more information, check out my svn-commit page. |
|||
|
Copyright © 2012 chris' random ramblings - All Rights Reserved
|
|||