Thursday, October 22, 2015

use ffmpeg to transform avi to mp3 on mac

  465  ./ffmpeg -i /Users/peterpeng/video/六人行/Season1/\[六人行\].Friends.01x01.The.One.Where.Monica.Gets.A.New.Roommate.DVDRip.AC3.3.2ch.JOG.avi -ss 00:00:55.000 -b:a 128k S1E01.mp3
  469  ./ffmpeg -i /Users/peterpeng/video/六人行/Season1/\[六人行\].Friends.01x02.The.One.With.The.Sonogram.At.The.End.DVDRip.AC3.3.2ch.JOG.avi -b:a 128k S1E02.mp3

batch transform for the avi in a directory:
for i in *.avi;
  do name=`echo $i | cut -d'.' -f3`;
  echo "transfroming ...$name";
  /Users/peterpeng/Downloads/ffmpeg -i $i -b:a 128k $name.mp3
done

Tuesday, October 20, 2015

Auspix todo

1. genEnter by C++
2. Refractor and backtest
2.1 real1
2.2 real2
2.3 long term
2.4 czsc
2.5 formula

Monday, October 19, 2015

Thinking in C++ note (chapter 1 - 3)


Making and using objects:
1. Declaring a variable without defining it means using the extern keyword before a description of the variable, like this:
extern int a;
The keyword is extern. It can mean the definition is external to the file, or that the definition occurs later in the file.
2. A header file is a file containing the external declarations for a library; it conventionally has a file name extension of ‘h’, such as headerfile.h.
#include "local.h" is to search for the file relative to the current directory. If the file is not found, then the include directive
is reprocessed as if it had angle brackets instead of quotes.
3. First program
#include <iostream> // Stream declarations
using namespace std;

int main() {
  cout << "Hello, World! I am "
       << 8 << " Today!" << endl;
} ///:~
C:\MinGW\sources>g++ Hello.cpp -o Hello.exe
4. system
system("ping -a www.google.com");
To use the system( ) function, you give it a character array that you would normally type at the operating system command prompt..
5. Reading and writing files
//: C02:Scopy.cpp
// Copy one file to another, a line at a time
#include <string>
#include <fstream>
using namespace std;

int main() {
  ifstream in("Scopy.cpp"); // Open for reading
  ofstream out("Scopy2.cpp"); // Open for writing
  string s;
  while(getline(in, s)) // Discards newline char
    out << s << "\n"; // ... must add it back
} ///:~

The C in C++
1. pointer
int* ip; // ip points to an int variable
int a = 47;
int* ipa = &a; //Now both a and ipa have been initialized, and ipa holds the address of a.
*ipa = 100; //Now a contains the value 100 instead of 47.
2.
Pointers work roughly the same in C and in C++, but C++ adds an additional way to pass an address into a function. This is pass-by-reference
and it exists in several other programming languages so it was not a C++ invention.
Once you assign to a void* you lose any information about what type it is. This means that before you can use the pointer, you must cast it to the correct type
int main() {
  int i = 99;
  void* vp = &i;
  // Can't dereference a void pointer:
  // *vp = 3; // Compile-time error
  // Must cast back to int before dereferencing:
  *((int*)vp) = 3;
}
3.
Global variables are defined outside all function bodies and are available to all parts of the program (even code in other files).
extern int globe;
There are restrictions to the use of register variables. You cannot take or compute the address of a register variable.
A register variable can be declared only within a block
4.
 If you want a value to be extant throughout the life of a program, you can define a function’s local variable to be static and
 give it an initial value. The initialization is performed only the first time the function is called, and the data retains its
 value between function calls.
 You may wonder why a global variable isn’t used instead. The beauty of a static variable is that it is unavailable outside the scope
 of the function, so it can’t be inadvertently changed. This localizes errors.
 #include <iostream>
using namespace std;

void func() {
  static int i = 0;
  cout << "i = " << ++i << endl;
}

int main() {
  for(int x = 0; x < 10; x++)
    func();
} ///:~

// File scope means only available in this file:
static int fs;

int main() {
  fs = 1;
} ///:~

5. const and volatile
The modifier const tells the compiler that a name represents a constant. In C++, a const must always have an initialization value
const int x = 10;
Whereas the qualifier const tells the compiler “This never changes” (which allows the compiler to perform extra optimizations),
the qualifier volatile tells the compiler “You never know when this will change,” and prevents the compiler from performing any
optimizations based on the stability of that variable.

6.
static_cast: is used for all conversions that are well-defined.
const_cast: If you want to convert from a const to a nonconst or from a volatile to a nonvolatile, you use const_cast.
reinterpret_cast: To cast to a completely different meaning.
typedef unsigned long ulong;

To read: Data Abstraction

Wednesday, October 7, 2015

English learning


1. Special VOA
Listen two package Special VOA 10 times every day, after checking the subtitles,
listen 10 times again.
2. Same steps for normal VOA
3. Same for talkshow like Saturday Night

4. Read www.economist.com or www.nytimes.com articles every day