tag:blogger.com,1999:blog-60664993032226256532024-03-08T18:06:05.983+04:00John Khvatov's BlogAnonymoushttp://www.blogger.com/profile/10987267584048000341noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-6066499303222625653.post-38210323986964601312013-05-29T13:27:00.000+04:002013-05-29T13:27:57.213+04:00Rebuild Debian/Ubuntu binary package from source packageIn short:
<pre>$ dpkg-source -x foo_version-revision.dsc
$ dpkg-buildpackage -rfakeroot -b
</pre>
<br />
For more information see: <a href="http://www.cyberciti.biz/faq/rebuilding-ubuntu-debian-linux-binary-package/">How to: Recompiling / Rebuild Debian / Ubuntu Linux Binary Source File Packages</a>.Anonymoushttp://www.blogger.com/profile/10987267584048000341noreply@blogger.com0tag:blogger.com,1999:blog-6066499303222625653.post-39021879212340852092013-04-04T12:24:00.002+04:002013-04-04T12:24:40.555+04:00Go vs. Scala vs. Erlang<span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 18px;">I added Go benchmark to <a href="https://github.com/Neverlord/cppa-benchmarks/pull/5" target="_blank">cppa-bechmarks</a>.</span><br style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 18px;" /><span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 18px;">Benchmark algorithm is described in <a href="http://libcppa.blogspot.kr/2012/02/libcppa-vs-erlang-vs-scala-performance.html" target="_blank">libcppa blogpost</a>. </span><br style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 18px;" /><span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 18px;">I've got results on 2 x Intel(R) Xeon(R) CPU E5620 @ 2.40GHz (16 cores):</span><br style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 18px;" /><br style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 18px;" /><span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 18px;">Go: 17.87 seconds</span><br style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 18px;" /><span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 18px;">Scala: 41.18 seconds</span><br style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 18px;" /><span style="background-color: white; font-family: Arial, sans-serif; font-size: 13px; line-height: 18px;">Erlang: 52.98 seconds</span>Anonymoushttp://www.blogger.com/profile/10987267584048000341noreply@blogger.com0tag:blogger.com,1999:blog-6066499303222625653.post-41661093248528425612013-04-04T11:54:00.000+04:002013-04-04T11:54:33.277+04:00PostgreSQL commandsTop 10 largest relations in database:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">SELECT relname, relpages FROM pg_class ORDER BY relpages DESC LIMIT 10;</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<h2>
<span style="font-weight: normal;">Useful links</span></h2>
<ul>
<li><a href="http://www.thegeekstuff.com/2009/05/15-advanced-postgresql-commands-with-examples/" target="_blank">15 advanced PostgreSQL Commands with Examples</a>.</li>
<li><a href="http://www.postgresql.org/docs/devel/static/functions-admin.html" target="_blank">System administration functions</a>.</li>
</ul>
Anonymoushttp://www.blogger.com/profile/10987267584048000341noreply@blogger.com0tag:blogger.com,1999:blog-6066499303222625653.post-18762373778770330252010-10-31T12:39:00.006+03:002010-10-31T13:34:41.693+03:00Using Intel© Math Kernel Library in PythonAs a way to interact with MKL library from Python is build a shared library from MKL and interface to it using ctypes.<br /><br />Below is description of the process of creating shared library from MKL.<br /><ol><br /><li> Download MKL Library from: <a href="http://software.intel.com/en-us/articles/non-commercial-software-download/">http://software.intel.com/en-us/articles/non-commercial-software-download/</a> (for noncommercial use).</li><br /><li> Unpack archive and install</li><br /><li> Follow this useful article: <a href="http://software.intel.com/en-us/articles/using-intel-mkl-in-your-python-programs/">http://software.intel.com/en-us/articles/using-intel-mkl-in-your-python-programs/</a></li><br /></ol><br />Steps for me:<br /><ol><br /><li> <MKLROOT>/tools/environment/mklvarsem64t.sh </li><br /><li> cd <MKLROOT>/tools/builder </li><br /><li> $ cat > ring_list<br />dsyevr_<br />^D<br /></li><br /><li> $ make em64t name=mkl4py export=ring_list </li><br /><li> Done. Use mklpy.so and <MKLROON>/lib/em64t/libiomp5.so. </li><br /></ol><br />MKL online documentation: <a href="http://software.intel.com/en-us/articles/intel-math-kernel-library-documentation/">http://software.intel.com/en-us/articles/intel-math-kernel-library-documentation/</a>. See "Building Custom Shared Object".Anonymoushttp://www.blogger.com/profile/10987267584048000341noreply@blogger.com0tag:blogger.com,1999:blog-6066499303222625653.post-41228760982580091182010-10-08T12:54:00.008+04:002010-11-02T19:46:49.225+03:00Build OpenSIPS deb package from SVN. Step by step.If you want to build OpenSIPS package for debian/ubuntu from svn, that this is post for you.<br /><br />First, checkout OpenSIPS sourses from svn as described <a href="http://www.opensips.org/Resources/Downloads#svn">here</a>.<br /><br />For example, to download latest 1.6 branch do:<br />$ svn co https://opensips.svn.sourceforge.net/svnroot/opensips/branches/1.6 opensips<br /><br />Enter opensips directory and move debian-directory on top-level:<br />$ cd opensips<br />$ ln -s packaging/debian debian<br /><br />Increase the Debian release number:<br />$ debchange -i<br /><br />Finally, build package:<br />$ debuild -us -uc<br /><br />Debian packaging utilites can be installed with "sudo aptitude install devscripts build-essential fakeroot".Anonymoushttp://www.blogger.com/profile/10987267584048000341noreply@blogger.com0tag:blogger.com,1999:blog-6066499303222625653.post-87441479876562820652010-06-19T19:20:00.005+04:002010-06-20T01:24:39.445+04:00Book review: Building Telephony Systems with OpenSIPS 1.6A few months ago I was asked by Packt Publishing to review the book "Building Telephony Systems with <a href="http://opensips.org">OpenSIPS</a> 1.6" by Flavio E. Goncalves. They sent me a free physical copy of this book. Thanks to them for it.<br /><br />Before exploring OpenSIPS, you will be taught the basics of SIP. The book will help you install OpenSIPS, and after that you'll be able to work with it. It's good for newbies who want to learn OpenSIPS from scratch.<br /><br />The main part of the book explains principles needed to create an OpenSIPS routing script for real solutions. You will be able to set up authentication, integrate OpenSIPS with media server, integrate Asterisk Real Time with OpenSIPS, solve NAT traversal problems, configure accounting, and, most importantly, will understand how it works.<br /><br />Unfortunately, a part of complex issues is not covered in the book. These are, primarily: building high availability solutions with OpenSIPS; SIP presence problems; MediaProxy; etc.<br /><br />This book is an upgraded version of the "Building Telephony Systems with OpenSER: A step-by-step guide to building a high performance Telephony System" book. Some examples remain actual for Openser, but not for OpenSIPS. Some new OpenSIPS modules are not covered in the book. I've also found several typos in the example scripts. So, if you have problems with the examples in the book, just check the <a href="http://www.opensips.org/Resources/Documentation">current documentation</a>. <br /><br />An excellent start to learn OpenSIPS is to read this unique book. The on-line documentation is your friend too.Anonymoushttp://www.blogger.com/profile/10987267584048000341noreply@blogger.com0tag:blogger.com,1999:blog-6066499303222625653.post-57092312011256383782010-01-29T19:01:00.004+04:002010-01-29T19:27:20.461+04:00New book about OpenSIPS!I'm glad to say that the book "<a href="http://www.packtpub.com/building-telephony-systems-with-opensips-1-6/book">Building Telephony Systems with OpenSIPS 1.6</a>" was released! This book is update of the book about OpenSER. The book was written to answer many questions about building VoIP systems based on the SIP-proxy OpenSIPS.<br /><br />I'm waiting for delivery of the book to read and review.Anonymoushttp://www.blogger.com/profile/10987267584048000341noreply@blogger.com0tag:blogger.com,1999:blog-6066499303222625653.post-59702927833812064642009-11-30T01:59:00.004+04:002009-11-30T02:27:21.829+04:00C++: compile time square root (sqrt) using templatesThis code computes square root in compile time using C++ templates and <a href="http://en.wikipedia.org/wiki/Binary_search">binary search</a>:<br /><br /><code><br />#include <iostream><br />using namespace std;<br /><br />#define MID(a, b) ((a+b)/2)<br />#define POW(a) (a*a)<br /><br />template<int res, int l = 1, int r = res><br />class SQRT;<br /><br />template<int res, int r><br />class SQRT<res, r, r> {<br /> public:<br /> static const int value = r;<br />};<br /><br />template <int res, int l, int r><br />class SQRT {<br /> public:<br /> static const int value = SQRT<res, (POW(MID(r, l)) >= res ? l : MID(r, l)+1), (POW(MID(r, l)) >= res ? MID(r, l) : r)>::value;<br />};<br /><br />int main() {<br /> cout << SQRT<256>::value << endl;<br /> return 0;<br />}<br /></code><br /><br />See <a href="http://codepad.org/Pm8U6R89">codepad paste</a> for more information.<br /><br />Thanks HELLER[i] for idea.Anonymoushttp://www.blogger.com/profile/10987267584048000341noreply@blogger.com2tag:blogger.com,1999:blog-6066499303222625653.post-537560167772256622009-11-22T19:47:00.001+04:002009-11-22T19:52:56.369+04:00C++: what is difference between "new T" from "new T()"Recently I received an interesting question: what difference between "<code><b>new</b> T</code>" from "<code><b>new</b> T()</code>" in C++?<br />
<br />
Let's look at example:<br />
<code><br />
#include <iostream></iostream><br />
#include <cstring></cstring><br />
using namespace std;<br />
<br />
class ST {<br />
public:<br />
ST() {<br />
cout << "ST constructor executed" << endl;<br />
}<br />
};<br />
<br />
class T {<br />
public:<br />
int i;<br />
ST st;<br />
};<br />
<br />
int main() {<br />
char mem[1000];<br />
T *t_ptr;<br />
<br />
memset(mem, 0x0F, sizeof(mem));<br />
t_ptr = new(mem) T;<br />
cout << "new T: " << int(t_ptr->i) << endl;<br />
<br />
memset(mem, 0x0F, sizeof(mem));<br />
t_ptr = new(mem) T();<br />
cout << "new T(): " << int(t_ptr->i) << endl;<br />
<br />
T t;<br />
cout << "T t: " << int(t.i) << endl;<br />
<br />
t = T();<br />
cout << "t = T(): " << int(t.i) << endl;<br />
<br />
return 0;<br />
}<br />
</code><br />
<br />
Output is:<br />
<code><br />
ST constructor executed<br />
new T: 252645135<br />
ST constructor executed<br />
new T(): 0<br />
ST constructor executed<br />
T t: 134515321<br />
ST constructor executed<br />
t = T(): 0<br />
</code><br />
<br />
When we use <code>"<b>new</b> T"</code> and <code>"T t"</code> form, t-object default-initialized (in our example via default constructor). In C++ for backward compatibility with C default constructor initialize only non-POD class members. Therefore, called ST constructor and 'i' not initialized.<br />
<br />
In case with <code>"<b>new</b> T()"</code> and <code>"t = T()"</code> we get value-initialized object. In our example each class member initialized separately.<br />
<br />
For more information read this quotes from the <a href="http://openassist.googlecode.com/files/C%2B%2B%20Standard%20-%20ANSI%20ISO%20IEC%2014882%202003.pdf">C++ standard</a> (ANSI ISO IEC 14882 2003):<br />
<blockquote>A new-expression that creates an object of type T initializes that object as follows:<br />
<ul><li>If the new-initializer is omitted:</li>
<ul><li>If T is a (possibly cv-qualified) non-POD class type (or array thereof), the object is default-initialized (8.5). If T is a const-qualified type, the underlying class type shall have a user-declared default constructor.<br />
</li>
<li>Otherwise, the object created has indeterminate value. If T is a const-qualified type, or a (possibly cv-qualified) POD class type (or array thereof) containing (directly or indirectly) a member of const-qualified type, the program is ill-formed;<br />
</li>
</ul><li>If the new-initializer is of the form (), the item is value-initialized (8.5);<br />
</li>
<li>If the new-initializer is of the form (expression-list) and T is a class type, the appropriate constructor is called, using expression-list as the arguments (8.5);<br />
</li>
<li>If the new-initializer is of the form (expression-list) and T is an arithmetic, enumeration, pointer, or pointer-to-member type and expression-list comprises exactly one expression, then the object is initialized to the (possibly converted) value of the expression (8.5);<br />
</li>
<li>Otherwise the new-expression is ill-formed.</li>
</ul></blockquote>(5.4.3. New, page 82)<br />
<br />
<br />
<blockquote>To zero-initialize an object of type T means:<br />
<ul><li>if T is a scalar type (3.9), the object is set to the value of 0 (zero) converted to T;</li>
<li>if T is a non-union class type, each nonstatic data member and each base-class subobject is zero-initialized;</li>
<li>if T is a union type, the object’s first named data member89) is zero-initialized;</li>
<li>if T is an array type, each element is zero-initialized;</li>
<li>if T is a reference type, no initialization is performed.</li>
</ul>To default-initialize an object of type T means:<br />
<ul><li>if T is a non-POD class type (clause 9), the default constructor for T is called (and the initialization is ill-formed if T has no accessible default constructor);</li>
<li>if T is an array type, each element is default-initialized;</li>
<li>otherwise, the object is zero-initialized.</li>
</ul>To value-initialize an object of type T means:<br />
<ul><li>if T is a class type (clause 9) with a user-declared constructor (12.1), then the default constructor for T is called (and the initialization is ill-formed if T has no accessible default constructor);</li>
<li>if T is a non-union class type without a user-declared constructor, then every non-static data member and base-class component of T is value-initialized;</li>
<li>if T is an array type, then each element is value-initialized;</li>
<li>otherwise, the object is zero-initialized.</li>
</ul>An object whose initializer is an empty set of parentheses, i.e., (), shall be value-initialized. <br />
</blockquote></code><br />
(8.5. Initializers, page 145)Anonymoushttp://www.blogger.com/profile/10987267584048000341noreply@blogger.com0tag:blogger.com,1999:blog-6066499303222625653.post-53322836923695767972009-11-15T21:58:00.005+04:002009-11-17T00:49:24.701+04:00Python in scienceGuido van Rossum wrote a very useful post about python tools in science:<br />
<a href="http://neopythonic.blogspot.com/2009/11/python-in-scientific-world.html">Neopythonic: Python in the Scientific World</a><br />
<br />
I'll research the languages and their libraries for my project work. Perhaps it would be python.Anonymoushttp://www.blogger.com/profile/10987267584048000341noreply@blogger.com0tag:blogger.com,1999:blog-6066499303222625653.post-81127330617391761942009-11-04T15:50:00.004+04:002009-11-08T22:53:30.351+04:00OpenSIPS 1.6 available on Fedora<a href="http://opensips.org/">OpenSIPS</a> (former OpenSER) is fastest open source implementation of a SIP proxy.<br />
<br />
Recently I added new rpm-package <i>opensips-1.6</i> to fedora. OpenSIPS can be installed parallel with current openser package. At the moment package is pending to adding to updates for <i>F-11.</i><br />
<a href="https://admin.fedoraproject.org/pkgdb/packages/name/opensips">https://admin.fedoraproject.org/pkgdb/packages/name/opensips</a><i> <br />
</i><br />
<i> </i> <br />
People who want to use db_oracle module should to install proprietary <i>instantclient-sdk-10.2.0.3</i> from Oracle and to rebuild package with --with-oracle rpmbuild option. Then <i>opensips-oracle</i> rpm package will be available to install.<br />
<br />
Thanks Peter Lemenkov for help and package review.<br />
<br />
UPD: package is pushed to stable updates.Anonymoushttp://www.blogger.com/profile/10987267584048000341noreply@blogger.com2