Google+

Friday, July 10, 2015

Git most often used command

1. add untracked files: git add *
2. show status in a git folder: git status
3. remove file A in git folder: git rm A
4. rename A to B: git mv A B
5. commit with comment: git commit -m 'message'
6. push: git push

Monday, July 6, 2015

git ssh low speed push solution

git push uses ssh, if you meet low speed push problem, try do this:
  1. $ git remote -v
  2. if you see your git folder begins with http://, please use
    git remote set-url origin commande to change it to ssh url.
  3. $ sudo sysctl -w net.ipv4.tcp_sack=0
  4. then git push

Friday, May 22, 2015

Set JRE environment for smartgit in Linux

1. download smartgit linux version, try run ./smartgit.sh in the its bin folder
2. if it complains JRE version problem, run sudo apt-get install openjdk-7-jre
3. locate to your openjdk-7-jre path, see here 
4. gedit ~/.smartgit/smartgit.vmoptions, add line: jre = path-to-your-openjdk
5. redo step 1

Saturday, April 18, 2015

Youtube data client library iOS, oauth2, HTTPfetcher

1. Compiling google api

This page shows the method to compile the google api to a project. I used the second way: compiling the source files directly into iOS project.

When I downloaded its source file, the oauth2 and HTTPfetcher are not there. We need to download them separately from here and here. Then just follow the procedure in the first page to finish compiling.

2. Youtube search

To search the data on youtube, firstly, import three headers:

#import "GTLServiceYouTube.h"
#import "GTLQueryYouTube.h"
#import "GTLYouTubeSearchListResponse.h"

Then for example, we search here for the youtube id by giving a searching word string:

GTLServiceYouTube *service = [[GTLServiceYouTube alloc] init];
service.APIKey = yourAPIKey;
GTLQueryYouTube *query = [GTLQueryYouTube queryForSearchListWithPart:@"id"];
query.type = @"video";
query.q = aSearchingString;
query.maxResults = aInt;

The code is very clear itself. We declare a youtube service instance, give it the APIKey, declare a query instance. The meaning of type, q and maxResults can be found here. Finally we execute this query which will give us a ticket. In the completionHandler, we receive the returned object.

GTLServiceTicket *ticketSend = [service executeQuery:query
                                   completionHandler:^(GTLServiceTicket *ticketReceive, id object, NSError *error)
    {
        if (!error) {
            GTLYouTubeSearchListResponse *items = object;
            }
        } else {
           
        }
    }];

Wednesday, March 18, 2015

Install Scipy through pip install in mac os x

When canopy visual environment has been installed, you might find your can't install Scipy to /usr/local/lib/python2.7/ anymore, or you might encounter pip "DistributionNotFound" Error. The solution is to reinstall python like this, using the soft way. Then pip install scipy.

Python package "intonation" needs Scipy.

Plot histogram of a recording object might cause float error in mac os backend.  Try to use:

import matplotlib
matplotlib.use("Qt4Agg")

before import anything from pylab.

Tuesday, March 3, 2015

Using AcoustID in IOS

AcoustID is an audio finger print project where Chromaprint allows you to calculate finger print from audio sources, and its web service allows you to search or to submit audio information in its database by Chromaprint.

Chormaprint is the core component of AcoustID project, it is written in C and can be compiled by cmake. However to use it in IOS, one needs a toolchain file.

1. Compile Chromaprint for IOS
1) You need to download the toolchain file here: https://code.google.com/p/ios-cmake/source/browse/

2) unzip the file "iOS.cmake" to Chromaprint source files' root folder. Open it, then change IOS_PLATFORM according to what you need. The default building architecture for "OS" is armv7 and arm64, this is sufficient for nowadays IOS devises.

3) build source files into a static library

1. mkdir build.ios 
2. cd build.ios 
3. cmake -DCMAKE_TOOLCHAIN_FILE=../../../iOS.cmake -GXcode ..
4. open Xcode project, compile chromaprint_p target for "iOS Device"

4) the static library will appear in the folder src/Debug-iphoneos/libchromaprint_p.a

2. Calculate finger print
Chromaprint only receives LinearPCM as the input audio format, so one should do the conversion if his original audio file format is not LinearPCM. The conversion method can be consulted here.

Once we get the URL of the audio file, we can open it by function AudioFileOpenURL, and save the fileID to outAudioFile.

The procedure of the finger print calculation is:

1. define a finger print calculation algorithm, here we use the default one: 
int algo = CHROMAPRINT_ALGORITHM_DEFAULT.

2. declare a finger print context and start calculation:
ChromaprintContext chromaprintCtx = chromaprint_new(algo);
chromaprint_start(chromaprintCtx, samplerate, channels);

3. read data packet, feed audio buffer outBuffer into this context, this could be done in a while loop:
AudioFileReadPackets(outAudioFile, false, &outNumBytes, NULL, inStartingPacket,&ioNumPackets, outBuffer);
chromaprint_feed(chromaprintCtx, outBuffer, ioNumPackets * framesPerPackets * 2)
where ioNumPackets is the packet number of the buffer,  inStartingPacket is the starting packet of the buffer, framesPerPackets = 1 for linearPCM audio format. Notice that AcoustID web service needs only 2 minutes audio finger print for database searching.

4. finish the finger print calculation and finally get the finger print:
chromaprint_finish(chromaprintCtx)
char *fingerPrint;
chromaprint_get_fingerprint(chromaprintCtx, &fingerPrint)

Now we have the finger print, and we can use it with AcoustID API to search its database.