Category Archives: Programming编程

solution to certificate verification failed for smtp.gmail.com via update Equifax Secure Certificate Authority

ubuntu scite Set up Java Python C/C++ FORTRAN Development Environment on SciTE

————————————–
Set up Java Python C/C++ FORTRAN Development Environment  on SciTE
———————————————————————–
for Java and python, is already setup and work perfect on ubuntu, but
C and Fortran compilation does not work without setup
here is how I setup the scite

——————————–

setup the python indentation
—————————–

# Indentation for python
tabsize=4
indent.size=4
use.tabs=0
#indent.auto=1
indent.automatic=1
indent.opening=1
indent.closing=1
#tab.indents=4
#backspace.unindents=4

——————————-

single file C/C++ Compile and run
————————————
ccopts=-pedantic -Os
cc=g++ $(ccopts) -c $(FileNameExt) -o $(FileName).o
ccc=gcc $(ccopts) -c $(FileNameExt) -o $(FileName).o

make.command=make
command.compile.*.c=$(ccc) -std=c99
command.build.*.c=$(make.command)
command.build.*.h=$(make.command)
command.go.*.c=./$(FileName)

# most important,  uncomment this line
# To make the Go command both compile (if needed) and execute, use this setting:
command.go.needs.*.c=gcc $(ccopts) -std=c99 $(FileNameExt) -o $(FileName)

—————————userProperties
file——————————————-
ccopts=
————————–CFLAGS———————————
# # set the ccopts for wxWidgets
# OpenGL  -lglut -lGL -lGLU -lX11  -lm
# `wx-config –cxxflags`  `wx-config –libs`
# OpenCL
## write a make for multiple fiels
ccopts=-pedantic -Os -lglut -lGL -lGLU -lX11  -lm `wx-config
–cxxflags`  `wx-config –libs`
———————————————————————
we need a make file for multiple files CC
a template of makefile is attached

————————-

fortran
—————————–

# how to setup the compile options?
gfortran is just like gcc,
gfortran [-c|-S|-E] [-g] [-pg] [-Olevel] [-Wwarn…] [-pedantic]
[-Idir…] [-Ldir…] [-Dmacro[=defn]…] [-Umacro] [-foption…]

#add a var: fcopts=   in userProperties file, so It can be change
options quickly for

# how to add fortran cc options, add more lib module? such as Lapack blas lib
fcopts=-L/usr/local/lib -llapack -lblas

# change the compile command to compile and link the single file mode:
# fc90=gfortran -c -o $(FileName).o $(FileNameExt)
# change to directly compile and link fotran
#   fc90=gfortran  -o $(FileName) $(fcopts) $(FileNameExt)

# a ./ is need to add to run the program:
# command.go.*.f=./$(FileName)

for multiple file . use a makefile

———————————————————————
open *.py by scite
———————————————————————–

——————————chinese input support——————
(1):在Internationalisation一段中,增加code.page=936和character.set=134两行,
其他的都注释掉。不然选择中文时出现乱码。这两项是中文的字符编码。

———————————-

set as default python editor
———————————————-
grep gedit /usr/share/applications/defaults.list | sed s/gedit/scribes/g
It is possible to set any mime type and any program that has a *.desktop entry.
Find out your favorite program’s desktop entry by looking in this folder:
/usr/share/applications/

set as default python editor
text/x-python=gedit.desktop
text/x-csrc=gedit.desktop # C/C++ files

change to scite.desktop

————————————————————————————————————
following words are copied from internet: with some of my commend

Anon 21:41, after some struggle, this is what ended up working for me:

$ sudo update-alternatives –install Scite gnome-text-editor /usr/bin/scite 1
————-I got error?———–
update-alternatives: error: alternative link is not absolute as it
should be: Scite
——————————————

$ sudo update-alternatives –config gnome-text-editor

# here, I noticed a symlink was gone – but most likely because I was
messing with the system previously
$ ls -la /usr/bin/gnome-text-editor
ls: cannot access /usr/bin/gnome-text-editor: No such file or directory

sudo ln -s /etc/alternatives/gnome-text-editor /usr/bin/gnome-text-editor

# test from command line (with existing test.txt file in the calling folder)

/usr/bin/gnome-text-editor test.txt

# all fine here, yet right-click and “open with Text Editor” in
Nautilus still fails

# edit:
$ nano ~/.local/share/applications/mimeapps.list

# and you can notice that for text/plain, gedit.desktop is first in
the list, and scite.desktop is last; simply make scite.desktop first:

# text/plain=scite.desktop;openoffice.org-writer.desktop;userapp-gedit-S5E6VU.desktop;wine-extension-txt.desktop;geany.desktop;gedit.desktop;

————————————-example Makefile————————-
for OpenGL test, you need to install the OpenGL (glut)
it is quite easy on Ubuntu just install openglut deb
———-
# Makefile
#Usage: copy and paste it as Makefile without any suffix in your project folder
########################################
#  this make file does not follow the dir and var standard of
#  The GNU Coding Standards
#  only for tiny project
########################################
#  By default, when make looks for the makefile, it tries the following names,
# in order: `GNUmakefile’, `makefile’ and `Makefile’.
#  ./configure can set the correct env var,
#
# example of schared lib compilation
#gcc -shared -Wl,-soname libname.so.verNo   -o library_name file_list library_list
#
# conditional set var:  a space need between ifeq and ()
# Please change source file suffix, .c .C or cpp or .f90 to fit your project
SUFFIX=.c
ifeq ($(SUFFIX), .c)
CC=gcc
endif
ifeq ($(SUFFIX), .C)
CC=g++
endif
ifeq ($(SUFFIX), .cpp)
CC=g++
endif
#$(findstring $(SUFFIX), .f90 .f .F .f95 .F90)
ifeq ($(findstring $(SUFFIX), .f90 .f .F .f95 .F90), find)
CC=gfortran
endif
#########################################
EXE=scube
#work dir is pwd
prefix=.
OBJDIR=.
#${prefix}/obj
#####################################
#
# # set the ccopts for wxWidgets
# OpenGL  -lglut -lGL -lGLU -lX11  -lm
# `wx-config –cxxflags`  `wx-config –libs`
# OpenCL
#
INCDIR=.
CFLAGS= -Wall -O1 -I$(INCDIR)
LIBDIR =/usr/lib
LIBS=-lglut -lGL -lGLU -lX11  -lm

##########################################
#Global substitution in a string is done by patsubst:  m4
#patsubst(string, regexp, opt replacement)
#
# header obj files list:  multiple separated by space
_DEPS =
DEPS = $(patsubst %,$(INCDIR)/%,$(_DEPS))

#  special macros $@ and $^,
# which are the left and right sides of the :
# $(patsubst  ) is built-in macro of m4
_OBJ=scube.o
OBJ = $(patsubst %,$(OBJDIR)/%,$(_OBJ))
#compiling    $<
$(OBJDIR)/%.o: %$(SUFFIX) $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)

#link
$(EXE): $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)

.PHONY: clean

clean:
rm -f $(OBJDIR)/*.o

OpenGLInstall OpenGL developing environment on 64bit Windows7 with Visual studio Express C++ 2008 & Ubuntu

========================================
Install OpenGL  on ubuntu
setup developing environment on 64bit Windows7
with Visual studio  Express C++ 2008
=======================================
The dll has been install with your graphics card   driver, you just need the header file ,
which come with windows SDK or full function Visual studio

The express editions require the Windows Platform SDK because they do not come with the OpenGL header files, etc.

Also, if you’re going to use GLUT, you need to download that separately. If you need more information let us know!

download glut  from  opengl.org.

——–step 2 ———————install to  windows SDK———————————————————–
Copy all the .h files into the C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\GL folder. This should be glut.h, freeglut.h, freeglut_ext.h, and freeglut_std.h.
Copy all the .lib files into the C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib folder. This should be freeglut.lib and glut32.lib.
Copy all the .dll files into the C:\Windows\system32 folder. This should be freeglut.dll and glut32.dll.

there may be more than one version of SDK under  folder                   C:\Program Files\Microsoft SDKs\Windows
the version can also be  v7.0A for windows 7,
there is a tool under windows SDK install folder/menu ,    ” configuration the SDK tool  ”            can switch the SDK version ,
———————————extra explanation to 64 bits Windows dll versions —————————

If you are running a 64 bit version of Windows, you might be wondering if there is a OpenGL64.dll file. The answer is no, there isn’t. On all versions of Windows,

Windows\System32 contains all the 64 bit DLLs. It contains the OpenGL32.dll which is actually a 64 bit dll.

For 32 bit programs, Windows detects the exe as a 32 bit program and instead of using System32 files,
it uses Windows\SysWOW64 which actually contains the 32 bit DLLs. WOW means Windows On Windows which is a backwards-compatibility layer.

To find your Windows’ System32 directory, go to: Start, Run… and type in %WINDIR%\System32. The system will redirect you to the default System32 directory automatically; this is also true for the 32 bits versions of Windows.

——–step 3———————–  test ————————————————————————————-
new a empty Win32 console program,  can copy your example code and save *.c (it must be the c , not cpp file ), compile and run

no need to set up Linker  property of the project, i.e.   Include/lib path setup is not needed

———step 4 ————————–Setup other IDE  such as CodeBlock————————————————————————-
Extract the ‘Glut.zip’ file you downloaded in Step 1 and do the following:-

Copy glut.dll into your ‘C:\Windows\System32′ folder (If you’re using Windows 7 64-bit, you’ll need to copy this file into ‘C:\Windows\sysWOW64′).

Copy glut.h into the ‘include\GL’ folder in the MinGW compiler folder. If you installed CodeBlocks and MinGW to the default directory in Step 3, this folder will be ‘C:\Program Files\CodeBlocks\MinGW\include\GL’.

Copy libglut32.a into the ‘MinGW\lib’ folder. If you installed CodeBlocks and MinGW to the default directory in Step 3, this folder will be ‘C:\Program Files\CodeBlocks\MinGW\lib’.

—————-> you can open you IDE program by finding the “SDK 7/VS 2008 command prompt” in start menu to open a CMD windows,
then type your IDE program path and name,
if can setup the SDK include and lib path for your favourate IDE.
Moreover, this method can compile the 64bit C++ program, perhaps the only way to compile 64bit in other IDE
—————————————————————————————————————–

—————————–install on ubuntu 10.04———————–
# it is more convenient to install the developing env. in Ubuntu
#as you have install the ATI driver, you should got newest openGL the HW supported
# just check the GL version
glxinfo | grep -i opengl
#  or open the ATI control center to check the openGL version

#you only need to install the glut  header and lib files
sudo apt-get install build-essential freeglut3-dev

gcc yourfile.cpp -lglut -lGLU -o appname
——————————————————————–

Enable Bluetooth on Sony Vaio windows 7

The sony laptop comes with bluetooth, but  I disable it for the sake of safety.

When I got a new nokia mobile with bluetooth,  I can not switch on it anymore.

It does not show on Device manager,  nor in “Sony control center”. However, bluetooth really exist, since I can use it in Ubuntu.

After huge effect, I find it can be turn on by VAIO smart network.  Which does not show up in system tray.

Solution:   services.msc  enable 2 blue tooth service, and most important:

VSNService  (VAIO smart network)  So you can see it in tray.

Double click it,  you will get the soft switch of bluetooth.  –> get connected all done

Share with friends who got similar problems:  Can not find blue tooth on the sony vaio  Windows 7.

matlab script to generate Fluent particles injection file

function GeneratFluentParticlesInjectionFile()
%
% file format of Fluent injection file:
%The file has the format that you write
%((x y z u v w diameter temperature mass-flow) injection0:ID )
%((# # # # # # # # # # #) injection0:0 ) ((# # # # # # # # # # #) injection0:1 ) ((# # # # # # # # # # #) injection0:2 ) … … … ((# # # # # # # # # # #) injection0:n )
%where # is a number under the unit that you are using.
%
% Input parameter: x, y, z and vel as init condition, only for XYZ coordination
%  Current implimentation :  rectangular seeding region and linear distribution,

%techniques for debug error:
% 1) always read fresh case and data file without injection
%    once reading the file, it will not read in next iteration
% 2) check if the mass-flow is bigger than 0,
% 3) check the injection time:  start time and stop time for unsteady flow
% 4) check if the particles  are in the domain
% 5) the InjectionName should match in fluent injection panel

x_start=0.0078; x_end=0.0178;
x_count=400;
y_start=0; y_end=0.005;
y_count=200;
x_det=(x_end – x_start)/x_count;
y_det=(y_end – y_start)/y_count;

z_start=0; z_end=0;  z_count=1;   % for 2D cases
z_det=(z_end – z_start)/z_count;

x_vel=0;  % unit m/s
y_vel=0;
z_vel=0;
x_pos=x_start+x_det/2;
y_pos=y_start+y_det/2;
z_pos=z_start+z_det/2;

diameter=1.0e-6;   % unit metre, make smallest, flow as
temperature = 293; % unit  K   default 293
density=997;  % unit: kg/m3  this should be identical as flow to be track,
mass_flow =0;

injectionName=’RectangleInjection’;
id=0;

f=fopen(‘RectangleInjection.inj’,’w’);
% initial intro duction field
fprintf(f,'((x y z u v w temperature diameter mass-flow) %s :ID )’,injectionName);
fprintf(f,’\n’);
for k=1:z_count
y_pos=y_start+y_det/2;
for j=1:y_count
x_pos=x_start+x_det/2;
for i=1:x_count
mass_flow = (1/6.0*pi)*diameter*diameter*diameter*density;  %
fprintf(f,'((%e %e %e %f %f %f %f %f %e) %s : %i )’, x_pos ,y_pos ,z_pos ,x_vel,y_vel, z_vel,  temperature,diameter, mass_flow, injectionName,id);
fprintf(f,’\n’);
x_pos=x_pos+x_det;
id=id+1;
end
y_pos=y_pos+y_det;
end
z_pos=z_pos+z_det;
end

disp(id);
disp(‘\t particles has been seeded’);
fclose(f);