Showing posts with label tricks. Show all posts
Showing posts with label tricks. Show all posts

Wednesday, November 28, 2012

How to ship eggs with pyo files only in Python

There is sometimes a need to ship python egg distribution with pyo files only. There is confusion using bdist_egg command since it doesn't have any options to do that; instead, you can instruct install_lib command. Here is what you need in setup.cfg file:
[install_lib]
compile = 0
optimize = 2

[bdist_egg]
exclude-source-files = 1
Issue the following command to build egg.
python setup.py -q bdist_egg
Note, the egg file has only python byte code optimized module files (look at dist directory). You can read about compiled modules here.

Wednesday, August 22, 2012

How to restore vim screen when exiting

When you exit vim it does not restore the terminal screen (particularly in FreeBSD), here is how to fix that (file ~/.vimrc):
" Restore terminal screen when exiting Vim
if &term =~ "xterm"
  let &t_ti = "\<Esc>[?47h"
  let &t_te = "\<Esc>[?47l"
endif

Sunday, August 19, 2012

Rebuilding World and Kernel on FreeBSD

Building the world and kernel on FreeBSD is just few steps procedure. The Handbook explains everything in great details. Here is short version.

Saturday, August 18, 2012

FreeBSD make.conf example

make.conf stores system-wide build settings that apply each time you run make. Copy example:
cp /usr/share/examples/etc/make.conf /etc
Compile the source code specific to your CPU:
CPUTYPE?=native
It is recommended uncomment the following: CFLAGS, CXXFLAGS, COPTFLAGS.
# 2 jobs per CPU
MAKE_JOBS_NUMBER=4

# KNOBS -- A list of popular knobs and their descriptions
# http://svn.freebsd.org/ports/head/KNOBS?view=markup

# Do not to compile X11 support
WITHOUT_X11=
# Include python support, e.g. in Vim
WITH_PYTHON=
# Do not build and install the doc, examples, mans
WITHOUT_EXAMPLES=
WITHOUT_DOCS=
NOPORTDOCS=
NOPORTEXAMPLES=
NO_INSTALL_MANPAGES=

How to setup HTTP Proxy in FreeBSD

The HTTP proxy is set through environment variable HTTP_PROXY. Environment variables can be controlled during user login. Assuming the proxy is proxy.somewhere.net:3128 ensure the following in /etc/login.conf:
:setenv=HTTP_PROXY=http\c//proxy.somewhere.net\c3128:\
Update login capability database:
cap_mkdb /etc/login.conf
Re-login and ensure it is properly set:
env | grep HTTP_PROXY

FreeBSD C Shell Tricks

C shell is default shell for root account in FreeBSD. You can control settings through the following configuration files:

~/.cshrc - user specific settings
/etc/csh.cshrc - global settings

Color Prompt: display hostname in red color for shell prompt (read more here):
set prompt="%{\033[1;31m%}%m %{\33[34m%}%. %{\033[0m%}%# "
set promptchars = "%#"
or if above doesn't work:
alias setprompt 'set prompt="%{\033[1;31m%}`/bin/hostname -s` %{\33[34m%}$cwd:t %{\033[0m%}# "'
setprompt
alias cd 'chdir \!* && setprompt'
List directories in color:
alias ls        ls -G
Del Key In Terminal:
bindkey ^[[3~ delete-char

FreeBSD Bourne Shell Tricks

Bourne shell is default shell for user account in FreeBSD. You can control settings through the following configuration files:

~/.shrc - user specific settings
/etc/profile - global settings

Color Prompt: display hostname in green color for shell prompt (read more here):
# vi ^[: ctrl+v and then Esc
#PS1="^[[32m$^[[0m "
PS1="^[[1;32m`whoami`@\h ^[[34m\W ^[[0m$ "
List directories in color:
alias ls='ls -G'
Color case insensitive grep:
export GREP_OPTIONS='-i --color=auto'