Skip to content

Instantly share code, notes, and snippets.

@sevas
sevas / vax_iter.txt
Created February 20, 2012 11:44
Vissual Assist Container Iterator Macro
for ($ContainerType$::iterator $Iter=it$ = $Container$.begin();
$Iter$!=$Container$.end();
++$Iter$)
{
$end$
}
@sevas
sevas / gist:1605251
Created January 13, 2012 09:17
set french locale on windows with python
# locale string from: http://msdn.microsoft.com/en-us/library/cdax410z(v=VS.80).aspx
if sys.platform in [ 'win32']:
locale.setlocale(locale.LC_ALL, 'fra')
def hex_to_rgb(hex_string_color):
"""
Convert a color encoded in an hex string into
an rgb tuple.
Example:
>> hex_to_rgb("5b6eff")
(91, 110, 255)
"""
@sevas
sevas / gist:1021391
Created June 12, 2011 09:56
fancy prompt
select_macpython32()
{
echo "Setting environment for MacPython 3.2"
PATH="/Library/Frameworks/Python.framework/Versions/3.2/bin/:${OLD_PATH}"
export PATH
export PS1="(MacPython 3.2) \h:\W \u\$ "
}
@sevas
sevas / gist:1021386
Created June 12, 2011 09:52
source python switchers
export OLD_PATH=$PATH
. $HOME/.python_switchers.sh
@sevas
sevas / gist:1021380
Created June 12, 2011 09:35
python switcher bash funcs
export OLD_PATH=$PATH
select_system_python26()
{
echo "Setting environment for System Python 2.6"
PATH="/System/Library/Frameworks/Python.framework/Versions/2.6/bin/:${OLD_PATH}"
export PATH
}
[Sat Apr 23 11:39:26 2011] [notice] caught SIGTERM, shutting down
[Sat Apr 23 11:39:44 2011] [error] python_init: Python version mismatch, expected '2.6.5', found '2.6.6'.
[Sat Apr 23 11:39:44 2011] [error] python_init: Python executable found '/usr/bin/python'.
[Sat Apr 23 11:39:44 2011] [error] python_init: Python path being used '/usr/lib/python2.6/:/usr/lib/python2.6/plat-linux2:/usr/lib/python2.6/lib-tk:/usr/lib/python2.6/lib-old:/usr/lib/python2.6/lib-dynload'.
[Sat Apr 23 11:39:44 2011] [notice] mod_python: Creating 8 session mutexes based on 6 max processes and 25 max threads.
[Sat Apr 23 11:39:44 2011] [notice] mod_python: using mutex_directory /tmp
[Sat Apr 23 11:39:44 2011] [warn] mod_wsgi: Compiled for Python/2.6.5.
[Sat Apr 23 11:39:44 2011] [warn] mod_wsgi: Runtime using Python/2.6.6.
[Sat Apr 23 11:39:44 2011] [notice] Apache/2.2.16 (Ubuntu) mod_python/3.3.1 Python/2.6.6 mod_wsgi/3.2 configured -- resuming normal operations
from __future__ import division
import numpy as np
from scipy.weave import inline, converters
def load_data(filename):
zbuf = np.fromfile(filename, dtype=np.float32, count=128*128*4)
zbuf.shape = (128,128)
return zbuf
export OLD_PATH=$PATH
# switching functions
select_epd62()
{
echo "Setting environment for EPD 6.2 (Python 2.6)"
PATH="/Library/Frameworks/Python.framework/Versions/6.2/bin:${OLD_PATH}"
export PATH
}
@ECHO off
ECHO Setting environment for EPD 6.2.2 (Python 2.6)
@SET PYTHON_ROOT=c:\Python26_EPD622
@SET PYTHON_INCLUDE=%PYTHON_ROOT%\include
@SET PYTHON_LIB=%PYTHON_ROOT%\python26.lib
@SET PATH=%PYTHON_ROOT%;%PYTHON_ROOT%\Scripts;%PYTHON_ROOT%\Lib;%PATH%
REM Optionnal, uncomment if you want to use a specific startup file
REM @SET PYTHONSTARTUP=%APPDATA%\pythonrc.py