Sunday, March 28, 2010
Yii framework
It is quite simple and well documented MVC framework
I like it!
So why I think it will be popular?
because it is easy to use.. and it is free
Here is few the most important features for me
Localization
first of all I pay attention to frameworks localization
only one static function
Yii::t("section", "string")
Security
It is very important to have only one entry point for all user requests
in this case you can wrap this entry with security patterns and framework itself already did it for you
All requests have the same entry for example
http://mysite.com/index.php?r=action&...
of cause you are able to create more attractive requests like
http://mysite.com/home/livingroom
http://mysite.com/2010/09/01/school
there is a trick.. all this urls redirect your request to one php file. remove php file entry name like "index.php" is done using .htaccess or if you are able to configure apache yourself it is could be done in *.conf file
Database
You are able to request data from database even if you don't know sql and even if you are not sure what database is installed on you web server. I mean code that Yii framework produces is working with any sql database platform (MySQL, PostageSQL, SQLite or other PDO php extention.
As results of the request it returns associative array and all other low-level stuff framework hides inside.
Widgets and Components
Widgets is a way to reuse you code - very powerful thing
I am not going to describe all Yii features, there is a manual for that
Friday, March 19, 2010
Android Streaming Audio
I will try to explain as detailed as possible about streaming audio in android. For this purposes in SDK 1.5 has been added AudioRecord and AudioTrack classes. AudioRecord is responsible to get samples from microphone and AudioTrack is responsible for playback samples.
This classes works only with PCM encoded data (it means that they are not encoded at all :)
Examples:
Play one buffer loop
Initialzation
AudioRecord record = null;
AudioTrack track = null;
record = new AudioRecord(MediaRecorder.AudioSource.MIC, 8000,
AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT,
AudioRecord.getMinBufferSize(8000, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT) * 4
);
log.d("AudioTrack min buffer size: "
+ AudioTrack.getMinBufferSize(8000, AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT));
track = new AudioTrack(AudioManager.STREAM_VOICE_CALL, 8000, AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT, AUDIO_SYSTEM_BUFFER_SIZE, AudioTrack.MODE_STREAM);
Initialization is quite simple. All you have to do is to create AudioRecord and AudioTrack
Start audio player
track.play();
Start audio recorder
record.startRecording();
Main Loop
while (needMoreAudioData)
{
recorder.read(buffer, bufferSize);
player.write(buffer, bufferSize);
}
Stop audio player/recorder
track.stop();
record.stop();
Remove player
Because this objects works with system resources developer has to release them when they are not in use. Java garbage collector will not release them automatically because instances hold system handlers.
track.release();
record.release();
Hope you have got the idea ...
Now few practical tips
When you call record.startRecording(); recording is already started! and to reduce latency you have to read that data immediately.
You should realize that android is not a real-time operating system and often call backs come not exactly at certain. You will end-up with increased latency over time unless you apply a sort of throttling algorithm to adjust playback side.
Wednesday, March 25, 2009
Sintral IDE
I decided to delay all my own projects and ideas to finish Sintral IDE project
this is a program for STOLL knitting machine. From the first glance it looks like very simple VB language but also it is quite specific.
I've start this project for all old STOLL machines. they are still working bug they didn't have support by vendors. Software for them was created in 80-90s. Once I was able to see STOLL program for windows 95.
My friend ask me started this project... and I agreed :)
Features that are already done:
- - BMP to TXT image converter
- - TXT to BMP converter
- - Sintral highlighter
- - export to MS Word
- - Pack/Unpack big Jackards
- - Line, Rectangle, Normal selection
- - Renumeration lines
- - Syntax check
- - STOLL communication via com port (read, write, erase)
- - Language pack (russian, english)
- - Add/remove external tools in programs menu
- - Users help
Also I remove 3rd party component UniHighlighter and wrote a plugin component for UniSyn to highlight a sin language. I could not compile UniHighlighter in 30 minutes so I decided to drop this component down and remove from future using.
If you are the one who needs this application, please contact me over email or send me request here
Saturday, January 31, 2009
Canon A540 camera problem
Hi there
I'd like to talk about files...
I have a camera Canon A540 and when I get files to PC, they have name like img_XXXX this is bad name for image because there is no information in the name. It doesn't contain when and where the photo was taken. Other problem occurs when I try to remove some small defects (red ayes for example) I am losing last modification date and then I don't know when the photo was taken If my camera is more smart I won't have this problem So I decided to create a console application for changing file name. And the main task was to add date, time and prefix to filename. Sure I understand that if I change filename the last file modification date would be changed. So I add a file description to do reverse operation if there is a need. Finally I have finished the program. It was not difficult to implement but I have no free time for that game. So about program: NameChanger - if you need one just mail me You should use program with arguments: -r - recursive search in sub-folders -d -t - rename fonded file and insert date and time in file name -pimg - insert prefix img in file name so all you files will start from this prefix. it is convinient when you just download photos from camera and wanted a prefix (for example: my_summer_holidays ) -ejpg - rename files only with jpg extension -iimg - ignore files started with "img" So in general you could use this command tool like bellow: NameChanger.exe -d -t -r -pparty -ejpg I have used it and noticed that some files have the same file modify date and time. In this case NameChanger add a letter to the resulted name. For example if you have three files with the same date and time then you will have summer_2009_06_01_13_27_10.jpg summer_2009_06_01_13_27_10A.jpg summer_2009_06_01_13_27_10B.jpg
Friday, October 31, 2008
Windows Mobile API ToolBar
You can use MFC menu wrapper class or you can use Windows WINAPI function to get access to the ToolBar
MFC class CCommandBar class has no API to access to menu items and doesn't know how to control the menu. After a brief investigation and experiments with the menu I have got a working code:
TBBUTTON tbb;
::SendMessage(m_oCommandBar.GetSafeHwnd(), TB_GETBUTTON, 1, (LPARAM)&tbb);
HMENU hMenu=HMENU(tbb.dwData);
if(hMenu)
{
::DeleteMenu(hMenu,0,MF_BYPOSITION);
::InsertMenu(hMenu,0,MF_BYPOSITION, ID_MENU_FR_SHOWDETAILS, L"Show Details");
}
Here m_oCommandBar is an instance of CCommandBar. By using windows messages you can access to WINAPI menu and create a dynamic menus :-)
Thursday, October 9, 2008
WMI database
I'd like to tell you about WMI
It's a pretty huge database with common API to access to the hardware/software information
It contains different information about operating system and hardware. For example computer name, TCP/IP address, DNS, and DHCP information and many other keys that are necessary for normal working.
Also, I notice that it builds as a COM service and it is available from different languages C++, C, Pascal, Visual Basic and scripts such as VBScript.
According to C++ to invoke a method we need to do a lot of work. So I show you how to use:
I have created two classes: first is for reading properties, second to invoke methods.
WMI divided to several groups and each group contain classes:
For example Network group contains NetworkAdapter, NetworkAdapterConfigurator
It's not a c++ classes. Actually, it is a description of the class which you can use with not C++ languages.
Tuesday, September 23, 2008
small annoying bugs :-(
Here is some suggestions that may help you with it.
This is applicable to mobile development:
1. All resources line memory allocation, files, etc., you need to put in a wrapper: shared_ptr
2. All unexpected behavior line "low memory" should throw an exception and exit.
class MyDataBlock
{
char* mData;
public:
MyDataBlock():mData(NULL){}
MyDataBlock():mData(int size)
{
ASSERT(size>0,"wrong size");
mData = new char[size];
ASSERT(mData,"low memory");
}
~MyDataBlock()
{
delete[] mData;
}
}
3. Logs
- developer logs - you must have them if there is no way to run application in debug mode. This is more applicable to OS driver development or other specific domain development.
- when exception happen try to log stack. When application crashes it is very useful to have function calls stack.