EvoTalk

Archive for the ‘Code Snippet’ Category

1. 安裝「python-2.5.4」
2. 安裝「PyGtk, PyOpenGL, PyGtkGlExt, PyWin32 all in one installer」
使用 「Glade」拉界面 ,「Pythonwin」  IDE  debug,

13 十月, 2009

Perl Here Document

Posted by: asd In: Code Snippet| Perl| 程式設計

Use Perl here documents to print multiple lines of output
example:
view plain

PERL:

print <<FOO;

Perl offers a convenient way of printing multiple lines of output through an interesting feature known as a "Perl here document".

 

A multiline Perl here document works like this:

<ol>

    <li>The first line of your command will include the two characters <code>&lt;&lt;</code> followed by a [...]

30 七月, 2009

Sort Map Value

Posted by: asd In: C++| Code Snippet| 程式設計

use stl set to simulate map
view plain

CODE:

#include &lt;iostream&gt;

#include &lt;vector&gt;

#include &lt;algorithm&gt;

#include &lt;set&gt;

#include &lt;map&gt;

using namespace std;

 

class compare

{

public:

 

 //the error is over here

 bool operator()(pair&lt;int, int&gt; p1, pair &lt;int, int&gt; p2) const

 {

  if (p1.second == p2.second)

   return p1.first &lt;p2.first;

  else

     return p1.second &lt;p2.second;

 }

};

 

typedef set&lt;pair&lt;int, int&gt;, compare&gt; MMap;

 

void main(int argc, char* argv[])

{

 MMap D;

 D.insert(make_pair&lt;int, int&gt;(1, 10));

 D.insert(make_pair&lt;int, int&gt;(2, 2));

 D.insert(make_pair&lt;int, int&gt;(3, 2));

 D.insert(make_pair&lt;int, int&gt;(4, 3));

 D.insert(make_pair&lt;int, int&gt;(5, 6));

 

 MMap::const_iterator iter(D.begin());

 MMap::const_iterator [...]

Tags:

24 六月, 2009

AMR Codec

Posted by: asd In: C++| Code Snippet| 程式設計

--AMR-NB--
-    The fixed-point (TS26.073)
-    The float (TS26.104)
-    The specification(TS26.071)
--AMR-WB--
-    The fixed-point (TS26.173)
-    The float (TS26.204)
-    The specification(TS26.171)

3GPP Specification 26-series

先安裝需用到的 module
#ppm-shell
#install DBI
#install DBD-ODBC
view plain

PERL:

#!/usr/bin/perl -w

use strict; # 使用變數前一定要定義

use DBI; # 使用DBI模組, 連結資料庫

use DBD::ODBC;

 

my $server='localhost\SQLEXPRESS';

my $database="your_db";

my $user="sa";

my $password="123456";

my $DSN = "driver={SQL Server};Server=$server;database=$database;uid=$user;pwd=$password;";

my $dbh = DBI-&gt;connect("dbi:ODBC:$DSN", { RaiseError =&gt; 1, AutoCommit =&gt; 1 }) || die "Can't connect: $DBI::errstr\n";

 

# 執行 sql 敘述

my $sql_statement = "select * from user_data";

my $sth = $dbh-&gt;prepare($sql_statement) || die "Can't prepare the [...]

Tags:

Page 2 of 3612345...Last »