I am tired to upload figures , I just give it as PDF file with figures inside
Setup Codelite to work with visual studio toolset (totorial version)
I am tired to upload figures , I just give it as PDF file with figures inside
Setup Codelite to work with visual studio toolset (totorial version)
git clone https://github.com/qingfengxia/pinyin.py.git
Pinyin python module
Origin: Author:cleverdeng E-mail:clverdeng@gmail.com (not reachable)
forked by Qingfeng Xia based on v0.9:
(1)renamed class name from PinYin to Pinyin,
(2)dict file "word.data" is renamed as "pinyin.data"
(3) add encoding support, or it will not work for windows cmd prompt!
(4) move load_word() (renamed as loaddict() ) into __init__(), to make API concise
(5) word.data "ord(UNICODE)= list of pinyin", for quick loading and human readable check
why some unicode has multiple pinyin units???
installation:
copy the two files: pinyin.py, pinyin.data , into your project folder, or under $PYTHONPATH , or your sitepackages
test: testing code is under __main__ section
python -m pinyin.py
Continue reading
as a further explanation to:
” Comparsion of DateTime classes in popular programming Languages (1)”
This part is a copy and paste of lang/lib spec.
C boost::Datetime Java JDK8(javax.time) Qt Python and Javascript
(1) Table comparison
(2) Further explanation from each language spec
Joda package for (Java) is not described here, whose API is analoguous to Qt and Python. As there is new API of LocalDateTime, it is the equivalent to QDatetime, and python’s datetime.
Previous C++ standard is C++03 (2003); previous C std is C99.They are not released together, but they did this time as a combo of C11 and C++11.
__STDC_VERSION__ == 201112L
C11 (formerly C1X) is an informal name for ISO/IEC 9899:2011 (see wiki)
http://en.wikipedia.org/wiki/C11_%28C_standard_revision%29
Recently, I have been working on Arduino 2/4 wheel car robot in my spare time.
===============design goals==================
Robot car composing 4 DCMotors, Senors, ServoArm, BlueTooth remote control
Phase 1:
(1) two/four wheel driving car steering,
There is no designated positive or negative pole for DC motor, swapping pin1 and pin2 can made motor rotate reversely
Phase 2:
(2) sensors: using PID for sensor fusion ,
a) altrasound range sensors included
b) acceleration or angle speed
c) Infrared receiver
(3) Control by Infrared remote or PC control via bluetooth
Phase 3:
(4) usb Camera supervision using Raspberry Pi usb wifi
(5) voice command recogniation by raspberry Pi connected to internet
I have made a C++ library class for Melexis90620 (in order to use multiple sensors simultanuously ), a test program to demo this class, python program to show the contour.
Also, I made I2C C program to control itby Raspberry PI, but raspberry Pi can not read from RAM (reading EEPROM is fine).
A new plan under evaluation is to use 4 Melexis90620 togother to make 16X16 pixel IR camera. The only obstacle is to change the I2C slave address. I saw some guy has change the address of Melexis90614. I dump EEPROM of reserved addr, I found some byte should be addr, but I dont know how to write EEPROM. (command sequence)
http://blog.qt.digia.com/blog/2009/08/25/count-with-me-how-many-smart-pointer-classes-does-qt-have/
| Smart pointers | Introduction | Ver |
| QPointer<T> | Qt Object , guarded pointer, set NULL after delete/deconstruction However, pointed resource not released |
Qt4.0 |
| QSharedPointer | reference-counted strong sharing of pointers | Qt4.5 |
| QWeakPointer | reference-counted weak sharing of pointers | Qt4.5 |
| QScopedPointer | Qt4.6 | |
| QScopedArrayPointer | QScopedPointer drived | Qt4.6 |
| QSharedDataPointer | Qt (Implicit Sharing) copy-on-write | Qt4.0 |
| QExplicitlySharedDataPointer | ExplicitlyShared | Qt4.4 |
C++11 <smart_pointer>
Introduction to smart pointers: http://en.wikipedia.org/wiki/Smart_pointer
| std::auto_ptr | Not recommended in C++11 | C++03 |
| std::shared_ptr | Reference counting | C++11 |
| std::weak_ptr | Intended for Garbage collection | C++11 |
| std::unique_ptr | non-copyable, but can be transfered | C++11 |
| boost::scoped_ptr<T> | Equal to QScopedPointer
neither copyable nor movable. |
Threading is always tricky, I dare not comment on this topics.
If some useful articles are found, this page will be updated!
just read the article: < Understand the Qt containers >
http://marcmutz.wordpress.com/effective-qt/containers/
key points
(1) difference:
a)Qt Containers: implicitly shared (Copy-On-Write) !
b) size type: QT return signed int, while STL return size_t (unsigned int)
c) Iterator
(2)Qt has C++ STL style API, stick to these API style(3) Usage QVector instead of QList as much as possible
The following table summarises the main sequential and associative Qt containers and their STL counterparts. For the most part, we will ignore the string classes, even though technically, they are also containers.
| Qt | STL |
|---|---|
| Sequential Containers | |
| QVector | std::vector |
| — | std::deque |
| QList | — |
| QLinkedList | std::list |
| — | std::forward_list |
| Associative Containers | |
| QMap | std::map |
| QMultiMap | std::multimap |
| — | std::set |
| — | std::multiset |
| QHash | std::unordered_map |
| QMultiHash | std::unordered_multimap |
| QSet | std::unordered_set |
| — | std::unordered_multiset |
QFile is the class for everyday File IO, while C++ STL using stream
===========based class: std::stream =========
<iostream> (qDebug() or #include <iostream> cin/cout )
<fstream> (QFile)
<sstream> (QBuffer)
<boost/archive> ( QDataStream for serialization )
===========QIODevice===========
The QIODevice class is the base interface class of all I/O devices in Qt.
#include <QIODevice>
Inherits: QObject.
Inherited by: Q3Socket, Q3SocketDevice,
QAbstractSocket, QBuffer, QFile, QLocalSocket, QNetworkReply,
and QProcess ( just like bash shell pipe input and output, Python).
QtCore vs C++ STL & boost lib
Author: Qingfeng Xia
Date: March 05 2013
Copyright:
since most of the content is from documentation or forum threads, it can be regards as same license as QT documentation. Most of text are copied from internet, reference to original link, I just organized them into sub topics: I did not spend much to retouch the text and grammer, so it will not suitable to be copied into your report or thesis (joking!).
=======================
QtCore has cover a wide range of C standard lib/C++ standard lib, but you still can use the standard C/C++ lib. For example, threading is newly added into C++11, but is already in QtCore: QRunnable QMutex QThread (not in QtConcurrent, usage is more or less like python and Java). <qglobal> includes a lot of Macros (e.g. qint64, no need for <stdint.h> ) , Q_ASSERT for C++11 static_assert. Even, there are
<qmath qnumeric qlocale qendian>.
This article focuses on Qt5 only, as it is mentioned C++11 is prerequisit for QT5 see: http://www.macieira.org/blog/2011/09/cxx11-support-in-qt-5/
It is not clear, that lambda will be allows in QT slot?
C++11 is still lacking the type system information, boost seems improve it on this topics. The metadata of QObject is the basis of QT lib. Reading and understanding QObject and all classes in QtCore before go through this series. For example, QFlag is more powerful than enuml it supports bit “and or xor” operation. see “KDAB contributions to Qt 5.0 (part 1 – 4)” http://www.kdab.com/kdab-contributions-to-qt-5-0-part-4/
On the other hand, there are some merits in C++11 that are abscent in QtCore. C++ <algorithm> is a good companian to STL containters, while QtAlgorithm is available for Qt 4.8 (in Qt5.0 it is recommended to use STL algorithm). C++ has <function> (function as a class and lambda) and <functional>, but C++ function can not be used as slot of QT!!! (http://stackoverflow.com/questions/9922005/using-any-c-function-as-a-qt-slot)
Personallly, I recommended to use QtCore utility as much as possible, e.g. using QFile instead of STL stream <fstream> for style compatible, and QString for itis power.
=======================
(1) IO
(2) STL container (important! QVector is recommended over QList)
(3) Threading ()
(4) smart pointers (table comparison)
(5) slot and signal ( C++11 in QT5)
(6) boost filesystem and QDir QFile programming notes
(7) serialization boost vs Qt
(8) Boost.Variant vs. Boost.Any QVariant
=======================
Arduino IDE has its standard “LiquidCrystall” library, but MCP23008 1602 LCD needed a customed library. Simply installation may lead to unexpected result
Arduino ide 1.5 , Arduino mega 2560, scl(clk 21) sda(20 DAT) connection is fine,
but example “HelloWorld_i2c”, compiled sucessfully, but it does not give correct character display, instead, “//??-> **”, unmeaningful characters are shown on LCD.
Reason:
test on Arduino 1.0.3, this example links to “LiquidCrystal.h” of standard library, Leading to compiling error. Corrected included header should be the “LiquidCrystal.h” in the customed liquidcrystall lib.
simple and dirty solution:
After install axxxxliquidcrystall , delete the standard liquidcrystall lib.
Then the example will link to correct header.
tested for IDE 1.0.3 and 1.5
Using python-sudoku 0.13 generate sudoku image, and solve the parsed puzzle;
Using Tesseract 3 python wrapper to do digit, but it will not be sucessful for all times.
download the package pythonsudoku-0.13-orcsudoku, extract to anywhere, cd pythonsudoku-0.13/ocrsudoku/, run: python cvsudoku.py <inputimagefile>
compiling from soruce is hard, but it can be easy if you just want to link to it
/**
Extended java bit manipulaiton example BitDemo.java
wikipedia
bit shifting for C/C++ is implicitly dependent on the left-handside operand!(arithmatic for signed int)
The >> operator in C and C++ is not necessarily an arithmetic shift. Usually it is only an arithmetic shift if used with a signed integer type on its left-hand side. If it is used on an unsigned integer type instead, it will be a logical shift.
java 5 got Bit Manipulation, but there is no unsigned int,
*For example, in Java and JavaScript, the arithmetic right shift operator is >>;
whereas the logical right shift operator is >>>.
(Java only has one left shift operator (<<), because arithmetic left shift and logical left shift have the same effect.)
Tips for C++ bitwise manipulaiton:
Using only unsigned int and explicitly specified the byte size,
defined variable/constant with full width to int type: uint32_t d=0x000000FF; // not as 0xFF
logic or arithmetic left shifting has the identical effect, notably, a positive int can be << into nagetive int( overflow)!
that is why signed int bitwise is not recommended!
third kind of shifting is called circular shifting
*/
class BitDemo {
public static void main(String[] args) {
int bitmask = 0x000F;
int val = 0×2222;
// prints “2″
System.out.println(val & bitmask);
System.out.println(“Shifting test …”);
int a=1;
System.out.println(String.format(“a=%d, a<<2 = %d”,a, a<<2)); // multiply by 4
System.out.println(String.format(“a=%x, a>>2 = %x”,a, a>>2)); // div by 4 underflow -> 0
int b=0×80000008;
System.out.println(String.format(“b=%d, b<<2 = %d”,b, b<<2));
// sign bit is been replaced by 0, it is positive now
System.out.println(String.format(“b=%d, b>>2 = %d”,b, b>>2));
// arithmetic shifting, it is still negative int
System.out.print(“what happen if there is one bit moved to sign bit? for <<3 on c=”);
int c=0x1FFFFFFF;
System.out.println(c<<3); // positive number become negative, overflow!
int d=0xFFFFFFFF;
System.out.print(“Before the >>> bitwise op, d=”);
System.out.println(d);
System.out.println(d>>>3);
}
}
ni-wsn 9791 can not receive user or debug message from strain gauge node
original link on NI forum
I am lazy to reupload all figures, refer to the forum post for figures.
Here I give the link to the word document tutorial and labview program file
“”" parse netstat command lines output into python named-tuples!
update v0.2 and onwards has been uploaded to PyPI; using pip to install it
Recently, I am doing VOF simulation on Fluent 6.3, But I can not init the mass-fraction in define_INIT()
————————–reply from fluent tech support———————
the Patching option in the GUI panel of Fluent which is more easier and straight forward compared to UDF Hook.(init hook)