First I had to install samba and smbfs. Than I created mount point /home/me/ub1 and used the commad
sudo mount -t cifs -o username=myusername,password=mysecretpass,rw,uid=1000,gid=1000 //iptoshare/sharename /home/me/ub1
i.e. some stuff and junk about Python, Perl, Matlab, Ruby, Mac X, Linux, Solaris, ...
sudo mount -t cifs -o username=myusername,password=mysecretpass,rw,uid=1000,gid=1000 //iptoshare/sharename /home/me/ub1
def calculateVar(self): N=self.N;
I=self.ima
[ans,xoffs,yoffs,dists]=self.getSearchRegion()
noOfAngles=int(ans.shape[0])
self.ROTs=zeros(xoffs.shape)
diffMtx_size=N*N/self._jump/self._jump
diffMtx=zeros(diffMtx_size,dtype=int)
for ai in range(noOfAngles):
for offi in range(xoffs.shape[1]+0):
diffMtx.fill(0)
ind=0;
xoff=xoffs[ai,offi]
yoff=-yoffs[ai,offi]
for y1 in range(0,I.shape[0],self._jump):
for x1 in range(0,I.shape[1],self._jump):
x2=x1+xoff
y2=y1+yoff
if x2>=N or y2>=N or x2<0 ind="ind+1" diffmtx2="diffMtx[diffMtx">0]
self.ROTs[ai,offi]=diffMtx2.var()
def calculateVar(self):
N=self.N;
I=self.ima
I2=array(I,dtype=int)
[ans,xoffs,yoffs,dists]=self.getSearchRegion()
#this is part in Cython!
self.ROTs=loopcore.loopcore(I2,ans.shape[0],xoffs.shape[1],
array(xoffs,dtype=int),array(yoffs,dtype=int),
N, self._jump)import numpy as np
cimport numpy as np
DTYPE = np.int
ctypedef np.int_t DTYPE_t
ctypedef np.float_t DTYPE_t2
cdef inline int int_abs(int a, int b): return abs(a-b)
def loopcore(np.ndarray[DTYPE_t, ndim=2] I,int noOfAngles,
int noOfpixels, np.ndarray[DTYPE_t, ndim=2] xoffs,
np.ndarray[DTYPE_t, ndim=2] yoffs,
int N, int jump ):
cdef int y1,x1,x2, y2, ind,ai,offi, xoff,yoff,array_size
array_size=N*N/jump/jump
cdef np.ndarray[DTYPE_t, ndim=1] p= np.zeros(array_size, dtype=DTYPE)
cdef np.ndarray[DTYPE_t, ndim=1] p2= np.zeros(0, dtype=DTYPE)
cdef np.ndarray[DTYPE_t2, ndim=2] ROTs= np.zeros([noOfAngles,noOfpixels], dtype=np.float)
for ai in range(noOfAngles):
for offi in range(noOfpixels):
p.fill(0)
ind=0
xoff=xoffs[ai,offi]
yoff=-yoffs[ai,offi]
for y1 in range(0,N,jump):
for x1 in range(0,N,jump):
x2=x1+xoff
y2=y1+yoff
if x2>=N or y2>=N or x2<0 ind="ind+1" p2="p[p">0]
ROTs[ai,offi]=p2.var()
return ROTs
cython loopcore.pyx gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -I/usr/include/python2.5 -o loopcore.so loopcore.cfrom numpy import linspace
from scipy import pi,sin,cos
def ellipse(ra,rb,ang,x0,y0,Nb=50):
'''ra - major axis length
rb - minor axis length
ang - angle
x0,y0 - position of centre of ellipse
Nb - No. of points that make an ellipse
based on matlab code ellipse.m written by D.G. Long,
Brigham Young University, based on the
CIRCLES.m original
written by Peter Blattner, Institute of Microtechnology,
University of
Neuchatel, Switzerland, blattner@imt.unine.ch
'''
xpos,ypos=x0,y0
radm,radn=ra,rb
an=ang
co,si=cos(an),sin(an)
the=linspace(0,2*pi,Nb)
X=radm*cos(the)*co-si*radn*sin(the)+xpos
Y=radm*cos(the)*si+co*radn*sin(the)+ypos
return X,Y
def test():
import pylab as p
fig = p.figure(figsize=(5,5))
p.axis([-3,3,-3,3])
#eg 1
X,Y=ellipse(2,1,pi*2.0/3.0,0,1)
p.plot(X,Y,"b.-",ms=1) # blue ellipse
#eg 2
X,Y=ellipse(2,0.2,pi/3.0,1,1)
p.plot(X,Y,"r.-",ms=1) # red ellipse
#eg 3
X,Y=ellipse(1,1,pi/3.0,-1,1,Nb=16)
p.plot(X,Y,"g.-",ms=1) # green ellipse
p.grid(True)
p.show()
if __name__ == '__main__':
test()
test_cell={1,[2,3],[5,6,7;8,9,10;11,12,13]};void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] ) {
const mxArray* temp_cell;
mxArray* cells[3];
temp_cell=prhs[0]; //cell is the only variable
//passed to mex file.
cells[0]=mxGetCell(temp_cell,0);
cells[1]=mxGetCell(temp_cell,1);
cells[2]=mxGetCell(temp_cell,2);
mexPrintf("%f,", *mxGetPr(cells[0]));
mexPrintf("\n{%f,%f}", *mxGetPr(cells[1]),
*(mxGetPr(cells[1])+1));
int N;
N= mxGetM(cells[2]);
double **Img = makeMatrixFromVector(mxGetPr(cells[2]),N);
int i,j;
for (i=0;i<N;i++) {
mexPrintf("\n");
for (j=0;j<N;j++) {
mexPrintf("\t%.1f ",Img[i][j]);
}
}
mexPrintf("\n")
}1.000000,
[2.000000 3.000000]
5.0 6.0 7.0
8.0 9.0 10.0
11.0 12.0 13.0
double ** makeMatrixFromVector(double *inData,int size) {
int x,y;
double ** Img = (double**)mxMalloc(size*sizeof(double*));
for (y=0 ; y< size ; y++) {
Img[y]=(double*) mxMalloc((size)* sizeof(double));
for (x=0 ; x< size ; x++) {
Img[y][x]=*(inData+x*size+y);
}
}
return Img;
}
cat /etc/apt/sources.list | sed 's/text1/text2/g' > out.txt cat /etc/apt/sources.list | sed 's|text1|text2|g' > out.txt cat /etc/apt/sources.list | sed -e 's/text1/text2/g' -e 's/text3/text4/g' > out.txt cat some.txt | sed -e '/blabla/d' > out.txt
VBoxManage list hdds VBoxManage clonevdi 973b3243-8168-41c3-bb29-1c9865eaec7c outfilename.vdi I noticed that when coping VDI to new Vbox, networking does not work good. sudo a2enmod userdir
#! /usr/bin/env python
from __future__ import division
import Image
from scipy import *
class FractalSurface(object):
'''Generate isotropic fractal surface image using
spectral synthesis method [1, p.]
References:
1. Yuval Fisher, Michael McGuire,
The Science of Fractal Images, 1988
'''
def __init__(self,fd=2.5, N=256):
self.N=N
self.H=1-(fd-2);
self.X=zeros((self.N,self.N),complex)
self.A=zeros((self.N,self.N),complex)
self.img=Image.Image()
def genSurface(self):
'''Spectral synthesis method
'''
N=self.N; A=self.A
powerr=-(self.H+1.0)/2.0
for i in range(int(N/2)+1):
for j in range(int(N/2)+1):
phase=2*pi*rand()
if i is not 0 or j is not 0:
rad=(i*i+j*j)**powerr*random.normal()
else:
rad=0.0
self.A[i,j]=complex(rad*cos(phase),rad*sin(phase))
if i is 0:
i0=0.0
else:
i0=N-i
if j is 0:
j0=0.0
else:
j0=N-j
self.A[i0,j0]=complex(rad*cos(phase),-rad*sin(phase))
self.A.imag[N/2][0]=0.0
self.A.imag[0,N/2]=0.0
self.A.imag[N/2][N/2]=0.0
for i in range(1,int(N/2)):
for j in range(1,int(N/2)):
phase=2*pi*rand()
rad=(i*i+j*j)**powerr*random.normal()
self.A[i,N-j]=complex(rad*cos(phase),rad*sin(phase))
self.A[N-i,j]=complex(rad*cos(phase),-rad*sin(phase))
itemp=fftpack.ifft2(self.A)
itemp=itemp-itemp.min()
self.X=itemp
def genImage(self):
#Aa=abs(Aa)
Aa=self.X
im=Aa.real/Aa.real.max()*255.0
self.img=Image.fromarray(uint8(im))
#img2=Image.fromstring("L",(N,N),uint8(im).tostring())
def showImg(self):
self.img.show()
def saveImg(self,fname="fs.tiff"):
self.img.save(fname)
def getFSimg(self):
return self.img
def main():
fs=FractalSurface()
fs.genSurface()
fs.genImage()
fs.saveImg()
fs.showImg()
if __name__ == '__main__':
main()


sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination Chain PREROUTING (policy ACCEPT)
target prot opt source destination
REDIRECT tcp -- anywhere anywhere tcp dpt:www redir ports 8080
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination